pxa2xx_e740.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Toshiba e740 PCMCIA specific routines.
  4. *
  5. * (c) 2004 Ian Molton <spyro@f2s.com>
  6. */
  7. #include <linux/init.h>
  8. #include <linux/module.h>
  9. #include <linux/kernel.h>
  10. #include <linux/errno.h>
  11. #include <linux/gpio.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/platform_device.h>
  14. #include <mach/eseries-gpio.h>
  15. #include <asm/irq.h>
  16. #include <asm/mach-types.h>
  17. #include "soc_common.h"
  18. static int e740_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  19. {
  20. if (skt->nr == 0) {
  21. skt->stat[SOC_STAT_CD].gpio = GPIO_E740_PCMCIA_CD0;
  22. skt->stat[SOC_STAT_CD].name = "CF card detect";
  23. skt->stat[SOC_STAT_RDY].gpio = GPIO_E740_PCMCIA_RDY0;
  24. skt->stat[SOC_STAT_RDY].name = "CF ready";
  25. } else {
  26. skt->stat[SOC_STAT_CD].gpio = GPIO_E740_PCMCIA_CD1;
  27. skt->stat[SOC_STAT_CD].name = "Wifi switch";
  28. skt->stat[SOC_STAT_RDY].gpio = GPIO_E740_PCMCIA_RDY1;
  29. skt->stat[SOC_STAT_RDY].name = "Wifi ready";
  30. }
  31. return 0;
  32. }
  33. static void e740_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  34. struct pcmcia_state *state)
  35. {
  36. state->vs_3v = 1;
  37. state->vs_Xv = 0;
  38. }
  39. static int e740_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  40. const socket_state_t *state)
  41. {
  42. if (state->flags & SS_RESET) {
  43. if (skt->nr == 0)
  44. gpio_set_value(GPIO_E740_PCMCIA_RST0, 1);
  45. else
  46. gpio_set_value(GPIO_E740_PCMCIA_RST1, 1);
  47. } else {
  48. if (skt->nr == 0)
  49. gpio_set_value(GPIO_E740_PCMCIA_RST0, 0);
  50. else
  51. gpio_set_value(GPIO_E740_PCMCIA_RST1, 0);
  52. }
  53. switch (state->Vcc) {
  54. case 0: /* Socket off */
  55. if (skt->nr == 0)
  56. gpio_set_value(GPIO_E740_PCMCIA_PWR0, 0);
  57. else
  58. gpio_set_value(GPIO_E740_PCMCIA_PWR1, 1);
  59. break;
  60. case 50:
  61. case 33: /* socket on */
  62. if (skt->nr == 0)
  63. gpio_set_value(GPIO_E740_PCMCIA_PWR0, 1);
  64. else
  65. gpio_set_value(GPIO_E740_PCMCIA_PWR1, 0);
  66. break;
  67. default:
  68. printk(KERN_ERR "e740_cs: Unsupported Vcc: %d\n", state->Vcc);
  69. }
  70. return 0;
  71. }
  72. static struct pcmcia_low_level e740_pcmcia_ops = {
  73. .owner = THIS_MODULE,
  74. .hw_init = e740_pcmcia_hw_init,
  75. .socket_state = e740_pcmcia_socket_state,
  76. .configure_socket = e740_pcmcia_configure_socket,
  77. .nr = 2,
  78. };
  79. static struct platform_device *e740_pcmcia_device;
  80. static int __init e740_pcmcia_init(void)
  81. {
  82. int ret;
  83. if (!machine_is_e740())
  84. return -ENODEV;
  85. e740_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
  86. if (!e740_pcmcia_device)
  87. return -ENOMEM;
  88. ret = platform_device_add_data(e740_pcmcia_device, &e740_pcmcia_ops,
  89. sizeof(e740_pcmcia_ops));
  90. if (!ret)
  91. ret = platform_device_add(e740_pcmcia_device);
  92. if (ret)
  93. platform_device_put(e740_pcmcia_device);
  94. return ret;
  95. }
  96. static void __exit e740_pcmcia_exit(void)
  97. {
  98. platform_device_unregister(e740_pcmcia_device);
  99. }
  100. module_init(e740_pcmcia_init);
  101. module_exit(e740_pcmcia_exit);
  102. MODULE_LICENSE("GPL v2");
  103. MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
  104. MODULE_ALIAS("platform:pxa2xx-pcmcia");
  105. MODULE_DESCRIPTION("e740 PCMCIA platform support");