pxa2xx_e740.c 3.1 KB

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