pxa2xx_e740.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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->wrprot = 0;
  41. state->vs_Xv = 0;
  42. }
  43. static int e740_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  44. const socket_state_t *state)
  45. {
  46. if (state->flags & SS_RESET) {
  47. if (skt->nr == 0)
  48. gpio_set_value(GPIO_E740_PCMCIA_RST0, 1);
  49. else
  50. gpio_set_value(GPIO_E740_PCMCIA_RST1, 1);
  51. } else {
  52. if (skt->nr == 0)
  53. gpio_set_value(GPIO_E740_PCMCIA_RST0, 0);
  54. else
  55. gpio_set_value(GPIO_E740_PCMCIA_RST1, 0);
  56. }
  57. switch (state->Vcc) {
  58. case 0: /* Socket off */
  59. if (skt->nr == 0)
  60. gpio_set_value(GPIO_E740_PCMCIA_PWR0, 0);
  61. else
  62. gpio_set_value(GPIO_E740_PCMCIA_PWR1, 1);
  63. break;
  64. case 50:
  65. case 33: /* socket on */
  66. if (skt->nr == 0)
  67. gpio_set_value(GPIO_E740_PCMCIA_PWR0, 1);
  68. else
  69. gpio_set_value(GPIO_E740_PCMCIA_PWR1, 0);
  70. break;
  71. default:
  72. printk(KERN_ERR "e740_cs: Unsupported Vcc: %d\n", state->Vcc);
  73. }
  74. return 0;
  75. }
  76. static struct pcmcia_low_level e740_pcmcia_ops = {
  77. .owner = THIS_MODULE,
  78. .hw_init = e740_pcmcia_hw_init,
  79. .socket_state = e740_pcmcia_socket_state,
  80. .configure_socket = e740_pcmcia_configure_socket,
  81. .nr = 2,
  82. };
  83. static struct platform_device *e740_pcmcia_device;
  84. static int __init e740_pcmcia_init(void)
  85. {
  86. int ret;
  87. if (!machine_is_e740())
  88. return -ENODEV;
  89. e740_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
  90. if (!e740_pcmcia_device)
  91. return -ENOMEM;
  92. ret = platform_device_add_data(e740_pcmcia_device, &e740_pcmcia_ops,
  93. sizeof(e740_pcmcia_ops));
  94. if (!ret)
  95. ret = platform_device_add(e740_pcmcia_device);
  96. if (ret)
  97. platform_device_put(e740_pcmcia_device);
  98. return ret;
  99. }
  100. static void __exit e740_pcmcia_exit(void)
  101. {
  102. platform_device_unregister(e740_pcmcia_device);
  103. }
  104. module_init(e740_pcmcia_init);
  105. module_exit(e740_pcmcia_exit);
  106. MODULE_LICENSE("GPL v2");
  107. MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
  108. MODULE_ALIAS("platform:pxa2xx-pcmcia");
  109. MODULE_DESCRIPTION("e740 PCMCIA platform support");