sa1100_simpad.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * drivers/pcmcia/sa1100_simpad.c
  3. *
  4. * PCMCIA implementation routines for simpad
  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 <asm/irq.h>
  14. #include <mach/simpad.h>
  15. #include "sa1100_generic.h"
  16. static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  17. {
  18. simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
  19. skt->stat[SOC_STAT_CD].gpio = GPIO_CF_CD;
  20. skt->stat[SOC_STAT_CD].name = "CF_CD";
  21. skt->stat[SOC_STAT_RDY].gpio = GPIO_CF_IRQ;
  22. skt->stat[SOC_STAT_RDY].name = "CF_RDY";
  23. return 0;
  24. }
  25. static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  26. {
  27. /* Disable CF bus: */
  28. /*simpad_set_cs3_bit(PCMCIA_BUFF_DIS);*/
  29. simpad_clear_cs3_bit(PCMCIA_RESET);
  30. }
  31. static void
  32. simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  33. struct pcmcia_state *state)
  34. {
  35. long cs3reg = simpad_get_cs3_ro();
  36. /* the detect signal is inverted - fix that up here */
  37. state->detect = !state->detect;
  38. state->bvd1 = 1; /* Might be cs3reg & PCMCIA_BVD1 */
  39. state->bvd2 = 1; /* Might be cs3reg & PCMCIA_BVD2 */
  40. if ((cs3reg & (PCMCIA_VS1|PCMCIA_VS2)) ==
  41. (PCMCIA_VS1|PCMCIA_VS2)) {
  42. state->vs_3v=0;
  43. state->vs_Xv=0;
  44. } else {
  45. state->vs_3v=1;
  46. state->vs_Xv=0;
  47. }
  48. }
  49. static int
  50. simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  51. const socket_state_t *state)
  52. {
  53. unsigned long flags;
  54. local_irq_save(flags);
  55. /* Murphy: see table of MIC2562a-1 */
  56. switch (state->Vcc) {
  57. case 0:
  58. simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
  59. break;
  60. case 33:
  61. simpad_clear_cs3_bit(VCC_3V_EN|EN1);
  62. simpad_set_cs3_bit(VCC_5V_EN|EN0);
  63. break;
  64. case 50:
  65. simpad_clear_cs3_bit(VCC_5V_EN|EN1);
  66. simpad_set_cs3_bit(VCC_3V_EN|EN0);
  67. break;
  68. default:
  69. printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
  70. __func__, state->Vcc);
  71. simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
  72. local_irq_restore(flags);
  73. return -1;
  74. }
  75. local_irq_restore(flags);
  76. return 0;
  77. }
  78. static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
  79. {
  80. simpad_set_cs3_bit(PCMCIA_RESET);
  81. }
  82. static struct pcmcia_low_level simpad_pcmcia_ops = {
  83. .owner = THIS_MODULE,
  84. .hw_init = simpad_pcmcia_hw_init,
  85. .hw_shutdown = simpad_pcmcia_hw_shutdown,
  86. .socket_state = simpad_pcmcia_socket_state,
  87. .configure_socket = simpad_pcmcia_configure_socket,
  88. .socket_suspend = simpad_pcmcia_socket_suspend,
  89. };
  90. int pcmcia_simpad_init(struct device *dev)
  91. {
  92. int ret = -ENODEV;
  93. if (machine_is_simpad())
  94. ret = sa11xx_drv_pcmcia_probe(dev, &simpad_pcmcia_ops, 1, 1);
  95. return ret;
  96. }