pxa2xx_cm_x270.c 2.4 KB

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