sa1100_shannon.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * drivers/pcmcia/sa1100_shannon.c
  3. *
  4. * PCMCIA implementation routines for Shannon
  5. *
  6. */
  7. #include <linux/module.h>
  8. #include <linux/kernel.h>
  9. #include <linux/device.h>
  10. #include <linux/init.h>
  11. #include <mach/hardware.h>
  12. #include <asm/mach-types.h>
  13. #include <mach/shannon.h>
  14. #include <asm/irq.h>
  15. #include "sa1100_generic.h"
  16. static struct pcmcia_irqs irqs[] = {
  17. { 0, SHANNON_IRQ_GPIO_EJECT_0, "PCMCIA_CD_0" },
  18. { 1, SHANNON_IRQ_GPIO_EJECT_1, "PCMCIA_CD_1" },
  19. };
  20. static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  21. {
  22. /* All those are inputs */
  23. GPDR &= ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 |
  24. SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
  25. GAFR &= ~(SHANNON_GPIO_EJECT_0 | SHANNON_GPIO_EJECT_1 |
  26. SHANNON_GPIO_RDY_0 | SHANNON_GPIO_RDY_1);
  27. skt->socket.pci_irq = skt->nr ? SHANNON_IRQ_GPIO_RDY_1 : SHANNON_IRQ_GPIO_RDY_0;
  28. return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
  29. }
  30. static void shannon_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  31. {
  32. soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
  33. }
  34. static void
  35. shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  36. struct pcmcia_state *state)
  37. {
  38. unsigned long levels = GPLR;
  39. switch (skt->nr) {
  40. case 0:
  41. state->detect = (levels & SHANNON_GPIO_EJECT_0) ? 0 : 1;
  42. state->ready = (levels & SHANNON_GPIO_RDY_0) ? 1 : 0;
  43. state->wrprot = 0; /* Not available on Shannon. */
  44. state->bvd1 = 1;
  45. state->bvd2 = 1;
  46. state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
  47. state->vs_Xv = 0;
  48. break;
  49. case 1:
  50. state->detect = (levels & SHANNON_GPIO_EJECT_1) ? 0 : 1;
  51. state->ready = (levels & SHANNON_GPIO_RDY_1) ? 1 : 0;
  52. state->wrprot = 0; /* Not available on Shannon. */
  53. state->bvd1 = 1;
  54. state->bvd2 = 1;
  55. state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
  56. state->vs_Xv = 0;
  57. break;
  58. }
  59. }
  60. static int
  61. shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  62. const socket_state_t *state)
  63. {
  64. switch (state->Vcc) {
  65. case 0: /* power off */
  66. printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__);
  67. break;
  68. case 50:
  69. printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__);
  70. case 33:
  71. break;
  72. default:
  73. printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
  74. __func__, state->Vcc);
  75. return -1;
  76. }
  77. printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__);
  78. /* Silently ignore Vpp, output enable, speaker enable. */
  79. return 0;
  80. }
  81. static void shannon_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
  82. {
  83. soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
  84. }
  85. static void shannon_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
  86. {
  87. soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
  88. }
  89. static struct pcmcia_low_level shannon_pcmcia_ops = {
  90. .owner = THIS_MODULE,
  91. .hw_init = shannon_pcmcia_hw_init,
  92. .hw_shutdown = shannon_pcmcia_hw_shutdown,
  93. .socket_state = shannon_pcmcia_socket_state,
  94. .configure_socket = shannon_pcmcia_configure_socket,
  95. .socket_init = shannon_pcmcia_socket_init,
  96. .socket_suspend = shannon_pcmcia_socket_suspend,
  97. };
  98. int __devinit pcmcia_shannon_init(struct device *dev)
  99. {
  100. int ret = -ENODEV;
  101. if (machine_is_shannon())
  102. ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2);
  103. return ret;
  104. }