sa1100_assabet.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * drivers/pcmcia/sa1100_assabet.c
  3. *
  4. * PCMCIA implementation routines for Assabet
  5. *
  6. */
  7. #include <linux/module.h>
  8. #include <linux/kernel.h>
  9. #include <linux/errno.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/device.h>
  12. #include <linux/init.h>
  13. #include <asm/hardware.h>
  14. #include <asm/mach-types.h>
  15. #include <asm/irq.h>
  16. #include <asm/signal.h>
  17. #include <asm/arch/assabet.h>
  18. #include "sa1100_generic.h"
  19. static struct pcmcia_irqs irqs[] = {
  20. { 1, ASSABET_IRQ_GPIO_CF_CD, "CF CD" },
  21. { 1, ASSABET_IRQ_GPIO_CF_BVD2, "CF BVD2" },
  22. { 1, ASSABET_IRQ_GPIO_CF_BVD1, "CF BVD1" },
  23. };
  24. static int assabet_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  25. {
  26. skt->irq = ASSABET_IRQ_GPIO_CF_IRQ;
  27. return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
  28. }
  29. /*
  30. * Release all resources.
  31. */
  32. static void assabet_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  33. {
  34. soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
  35. }
  36. static void
  37. assabet_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
  38. {
  39. unsigned long levels = GPLR;
  40. state->detect = (levels & ASSABET_GPIO_CF_CD) ? 0 : 1;
  41. state->ready = (levels & ASSABET_GPIO_CF_IRQ) ? 1 : 0;
  42. state->bvd1 = (levels & ASSABET_GPIO_CF_BVD1) ? 1 : 0;
  43. state->bvd2 = (levels & ASSABET_GPIO_CF_BVD2) ? 1 : 0;
  44. state->wrprot = 0; /* Not available on Assabet. */
  45. state->vs_3v = 1; /* Can only apply 3.3V on Assabet. */
  46. state->vs_Xv = 0;
  47. }
  48. static int
  49. assabet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
  50. {
  51. unsigned int mask;
  52. switch (state->Vcc) {
  53. case 0:
  54. mask = 0;
  55. break;
  56. case 50:
  57. printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
  58. __FUNCTION__);
  59. case 33: /* Can only apply 3.3V to the CF slot. */
  60. mask = ASSABET_BCR_CF_PWR;
  61. break;
  62. default:
  63. printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__,
  64. state->Vcc);
  65. return -1;
  66. }
  67. /* Silently ignore Vpp, output enable, speaker enable. */
  68. if (state->flags & SS_RESET)
  69. mask |= ASSABET_BCR_CF_RST;
  70. ASSABET_BCR_frob(ASSABET_BCR_CF_RST | ASSABET_BCR_CF_PWR, mask);
  71. return 0;
  72. }
  73. /*
  74. * Enable card status IRQs on (re-)initialisation. This can
  75. * be called at initialisation, power management event, or
  76. * pcmcia event.
  77. */
  78. static void assabet_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
  79. {
  80. /*
  81. * Enable CF bus
  82. */
  83. ASSABET_BCR_clear(ASSABET_BCR_CF_BUS_OFF);
  84. soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
  85. }
  86. /*
  87. * Disable card status IRQs on suspend.
  88. */
  89. static void assabet_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
  90. {
  91. soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
  92. /*
  93. * Tristate the CF bus signals. Also assert CF
  94. * reset as per user guide page 4-11.
  95. */
  96. ASSABET_BCR_set(ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_CF_RST);
  97. }
  98. static struct pcmcia_low_level assabet_pcmcia_ops = {
  99. .owner = THIS_MODULE,
  100. .hw_init = assabet_pcmcia_hw_init,
  101. .hw_shutdown = assabet_pcmcia_hw_shutdown,
  102. .socket_state = assabet_pcmcia_socket_state,
  103. .configure_socket = assabet_pcmcia_configure_socket,
  104. .socket_init = assabet_pcmcia_socket_init,
  105. .socket_suspend = assabet_pcmcia_socket_suspend,
  106. };
  107. int __init pcmcia_assabet_init(struct device *dev)
  108. {
  109. int ret = -ENODEV;
  110. if (machine_is_assabet() && !machine_has_neponset())
  111. ret = sa11xx_drv_pcmcia_probe(dev, &assabet_pcmcia_ops, 1, 1);
  112. return ret;
  113. }