pxa2xx_cm_x270.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/drivers/pcmcia/pxa/pxa_cm_x270.c
  4. *
  5. * Compulab Ltd., 2003, 2007, 2008
  6. * Mike Rapoport <mike@compulab.co.il>
  7. */
  8. #include <linux/platform_device.h>
  9. #include <linux/irq.h>
  10. #include <linux/delay.h>
  11. #include <linux/gpio.h>
  12. #include <linux/export.h>
  13. #include "soc_common.h"
  14. #define GPIO_PCMCIA_S0_CD_VALID (84)
  15. #define GPIO_PCMCIA_S0_RDYINT (82)
  16. #define GPIO_PCMCIA_RESET (53)
  17. static int cmx270_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  18. {
  19. int ret = gpio_request(GPIO_PCMCIA_RESET, "PCCard reset");
  20. if (ret)
  21. return ret;
  22. gpio_direction_output(GPIO_PCMCIA_RESET, 0);
  23. skt->stat[SOC_STAT_CD].gpio = GPIO_PCMCIA_S0_CD_VALID;
  24. skt->stat[SOC_STAT_CD].name = "PCMCIA0 CD";
  25. skt->stat[SOC_STAT_RDY].gpio = GPIO_PCMCIA_S0_RDYINT;
  26. skt->stat[SOC_STAT_RDY].name = "PCMCIA0 RDY";
  27. return ret;
  28. }
  29. static void cmx270_pcmcia_shutdown(struct soc_pcmcia_socket *skt)
  30. {
  31. gpio_free(GPIO_PCMCIA_RESET);
  32. }
  33. static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  34. struct pcmcia_state *state)
  35. {
  36. state->vs_3v = 0;
  37. state->vs_Xv = 0;
  38. }
  39. static int cmx270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  40. const socket_state_t *state)
  41. {
  42. switch (skt->nr) {
  43. case 0:
  44. if (state->flags & SS_RESET) {
  45. gpio_set_value(GPIO_PCMCIA_RESET, 1);
  46. udelay(10);
  47. gpio_set_value(GPIO_PCMCIA_RESET, 0);
  48. }
  49. break;
  50. }
  51. return 0;
  52. }
  53. static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = {
  54. .owner = THIS_MODULE,
  55. .hw_init = cmx270_pcmcia_hw_init,
  56. .hw_shutdown = cmx270_pcmcia_shutdown,
  57. .socket_state = cmx270_pcmcia_socket_state,
  58. .configure_socket = cmx270_pcmcia_configure_socket,
  59. .nr = 1,
  60. };
  61. static struct platform_device *cmx270_pcmcia_device;
  62. int __init cmx270_pcmcia_init(void)
  63. {
  64. int ret;
  65. cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
  66. if (!cmx270_pcmcia_device)
  67. return -ENOMEM;
  68. ret = platform_device_add_data(cmx270_pcmcia_device, &cmx270_pcmcia_ops,
  69. sizeof(cmx270_pcmcia_ops));
  70. if (ret == 0) {
  71. printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n");
  72. ret = platform_device_add(cmx270_pcmcia_device);
  73. }
  74. if (ret)
  75. platform_device_put(cmx270_pcmcia_device);
  76. return ret;
  77. }
  78. void __exit cmx270_pcmcia_exit(void)
  79. {
  80. platform_device_unregister(cmx270_pcmcia_device);
  81. }