sa1100_cerf.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * drivers/pcmcia/sa1100_cerf.c
  3. *
  4. * PCMCIA implementation routines for CerfBoard
  5. * Based off the Assabet.
  6. *
  7. */
  8. #include <linux/module.h>
  9. #include <linux/kernel.h>
  10. #include <linux/device.h>
  11. #include <linux/init.h>
  12. #include <linux/delay.h>
  13. #include <mach/hardware.h>
  14. #include <asm/mach-types.h>
  15. #include <asm/irq.h>
  16. #include <mach/cerf.h>
  17. #include "sa1100_generic.h"
  18. #define CERF_SOCKET 1
  19. static struct pcmcia_irqs irqs[] = {
  20. { CERF_SOCKET, CERF_IRQ_GPIO_CF_CD, "CF_CD" },
  21. { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD2, "CF_BVD2" },
  22. { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD1, "CF_BVD1" }
  23. };
  24. static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  25. {
  26. skt->socket.pci_irq = CERF_IRQ_GPIO_CF_IRQ;
  27. return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
  28. }
  29. static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  30. {
  31. soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
  32. }
  33. static void
  34. cerf_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
  35. {
  36. unsigned long levels = GPLR;
  37. state->detect = (levels & CERF_GPIO_CF_CD) ?0:1;
  38. state->ready = (levels & CERF_GPIO_CF_IRQ) ?1:0;
  39. state->bvd1 = (levels & CERF_GPIO_CF_BVD1)?1:0;
  40. state->bvd2 = (levels & CERF_GPIO_CF_BVD2)?1:0;
  41. state->wrprot = 0;
  42. state->vs_3v = 1;
  43. state->vs_Xv = 0;
  44. }
  45. static int
  46. cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  47. const socket_state_t *state)
  48. {
  49. switch (state->Vcc) {
  50. case 0:
  51. case 50:
  52. case 33:
  53. break;
  54. default:
  55. printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
  56. __func__, state->Vcc);
  57. return -1;
  58. }
  59. if (state->flags & SS_RESET) {
  60. GPSR = CERF_GPIO_CF_RESET;
  61. } else {
  62. GPCR = CERF_GPIO_CF_RESET;
  63. }
  64. return 0;
  65. }
  66. static void cerf_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
  67. {
  68. soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
  69. }
  70. static void cerf_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
  71. {
  72. soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
  73. }
  74. static struct pcmcia_low_level cerf_pcmcia_ops = {
  75. .owner = THIS_MODULE,
  76. .hw_init = cerf_pcmcia_hw_init,
  77. .hw_shutdown = cerf_pcmcia_hw_shutdown,
  78. .socket_state = cerf_pcmcia_socket_state,
  79. .configure_socket = cerf_pcmcia_configure_socket,
  80. .socket_init = cerf_pcmcia_socket_init,
  81. .socket_suspend = cerf_pcmcia_socket_suspend,
  82. };
  83. int __devinit pcmcia_cerf_init(struct device *dev)
  84. {
  85. int ret = -ENODEV;
  86. if (machine_is_cerf())
  87. ret = sa11xx_drv_pcmcia_probe(dev, &cerf_pcmcia_ops, CERF_SOCKET, 1);
  88. return ret;
  89. }