sa1100_shannon.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 <linux/io.h>
  12. #include <mach/hardware.h>
  13. #include <asm/mach-types.h>
  14. #include <mach/shannon.h>
  15. #include <asm/irq.h>
  16. #include "sa1100_generic.h"
  17. static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  18. {
  19. /* All those are inputs */
  20. GAFR &= ~(GPIO_GPIO(SHANNON_GPIO_EJECT_0) |
  21. GPIO_GPIO(SHANNON_GPIO_EJECT_1) |
  22. GPIO_GPIO(SHANNON_GPIO_RDY_0) |
  23. GPIO_GPIO(SHANNON_GPIO_RDY_1));
  24. if (skt->nr == 0) {
  25. skt->stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_0;
  26. skt->stat[SOC_STAT_CD].name = "PCMCIA_CD_0";
  27. skt->stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_0;
  28. skt->stat[SOC_STAT_RDY].name = "PCMCIA_RDY_0";
  29. } else {
  30. skt->stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_1;
  31. skt->stat[SOC_STAT_CD].name = "PCMCIA_CD_1";
  32. skt->stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_1;
  33. skt->stat[SOC_STAT_RDY].name = "PCMCIA_RDY_1";
  34. }
  35. return 0;
  36. }
  37. static void
  38. shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  39. struct pcmcia_state *state)
  40. {
  41. switch (skt->nr) {
  42. case 0:
  43. state->bvd1 = 1;
  44. state->bvd2 = 1;
  45. state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
  46. state->vs_Xv = 0;
  47. break;
  48. case 1:
  49. state->bvd1 = 1;
  50. state->bvd2 = 1;
  51. state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
  52. state->vs_Xv = 0;
  53. break;
  54. }
  55. }
  56. static int
  57. shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  58. const socket_state_t *state)
  59. {
  60. switch (state->Vcc) {
  61. case 0: /* power off */
  62. printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__);
  63. break;
  64. case 50:
  65. printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__);
  66. case 33:
  67. break;
  68. default:
  69. printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
  70. __func__, state->Vcc);
  71. return -1;
  72. }
  73. printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__);
  74. /* Silently ignore Vpp, output enable, speaker enable. */
  75. return 0;
  76. }
  77. static struct pcmcia_low_level shannon_pcmcia_ops = {
  78. .owner = THIS_MODULE,
  79. .hw_init = shannon_pcmcia_hw_init,
  80. .socket_state = shannon_pcmcia_socket_state,
  81. .configure_socket = shannon_pcmcia_configure_socket,
  82. };
  83. int pcmcia_shannon_init(struct device *dev)
  84. {
  85. int ret = -ENODEV;
  86. if (machine_is_shannon())
  87. ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2);
  88. return ret;
  89. }