pxa2xx_palmtx.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/drivers/pcmcia/pxa2xx_palmtx.c
  4. *
  5. * Driver for Palm T|X PCMCIA
  6. *
  7. * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
  8. */
  9. #include <linux/module.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/gpio.h>
  12. #include <asm/mach-types.h>
  13. #include <mach/palmtx.h>
  14. #include "soc_common.h"
  15. static struct gpio palmtx_pcmcia_gpios[] = {
  16. { GPIO_NR_PALMTX_PCMCIA_POWER1, GPIOF_INIT_LOW, "PCMCIA Power 1" },
  17. { GPIO_NR_PALMTX_PCMCIA_POWER2, GPIOF_INIT_LOW, "PCMCIA Power 2" },
  18. { GPIO_NR_PALMTX_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
  19. };
  20. static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  21. {
  22. int ret;
  23. ret = gpio_request_array(palmtx_pcmcia_gpios,
  24. ARRAY_SIZE(palmtx_pcmcia_gpios));
  25. skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMTX_PCMCIA_READY;
  26. skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
  27. return ret;
  28. }
  29. static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  30. {
  31. gpio_free_array(palmtx_pcmcia_gpios, ARRAY_SIZE(palmtx_pcmcia_gpios));
  32. }
  33. static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  34. struct pcmcia_state *state)
  35. {
  36. state->detect = 1; /* always inserted */
  37. state->vs_3v = 1;
  38. state->vs_Xv = 0;
  39. }
  40. static int
  41. palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  42. const socket_state_t *state)
  43. {
  44. gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER1, 1);
  45. gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER2, 1);
  46. gpio_set_value(GPIO_NR_PALMTX_PCMCIA_RESET,
  47. !!(state->flags & SS_RESET));
  48. return 0;
  49. }
  50. static struct pcmcia_low_level palmtx_pcmcia_ops = {
  51. .owner = THIS_MODULE,
  52. .first = 0,
  53. .nr = 1,
  54. .hw_init = palmtx_pcmcia_hw_init,
  55. .hw_shutdown = palmtx_pcmcia_hw_shutdown,
  56. .socket_state = palmtx_pcmcia_socket_state,
  57. .configure_socket = palmtx_pcmcia_configure_socket,
  58. };
  59. static struct platform_device *palmtx_pcmcia_device;
  60. static int __init palmtx_pcmcia_init(void)
  61. {
  62. int ret;
  63. if (!machine_is_palmtx())
  64. return -ENODEV;
  65. palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
  66. if (!palmtx_pcmcia_device)
  67. return -ENOMEM;
  68. ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops,
  69. sizeof(palmtx_pcmcia_ops));
  70. if (!ret)
  71. ret = platform_device_add(palmtx_pcmcia_device);
  72. if (ret)
  73. platform_device_put(palmtx_pcmcia_device);
  74. return ret;
  75. }
  76. static void __exit palmtx_pcmcia_exit(void)
  77. {
  78. platform_device_unregister(palmtx_pcmcia_device);
  79. }
  80. module_init(palmtx_pcmcia_init);
  81. module_exit(palmtx_pcmcia_exit);
  82. MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
  83. MODULE_DESCRIPTION("PCMCIA support for Palm T|X");
  84. MODULE_ALIAS("platform:pxa2xx-pcmcia");
  85. MODULE_LICENSE("GPL");