sa1100_jornada720.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * drivers/pcmcia/sa1100_jornada720.c
  3. *
  4. * Jornada720 PCMCIA specific routines
  5. *
  6. */
  7. #include <linux/module.h>
  8. #include <linux/kernel.h>
  9. #include <linux/device.h>
  10. #include <linux/errno.h>
  11. #include <linux/init.h>
  12. #include <mach/hardware.h>
  13. #include <asm/hardware/sa1111.h>
  14. #include <asm/mach-types.h>
  15. #include "sa1111_generic.h"
  16. /* Does SOCKET1_3V actually do anything? */
  17. #define SOCKET0_POWER GPIO_GPIO0
  18. #define SOCKET0_3V GPIO_GPIO2
  19. #define SOCKET1_POWER (GPIO_GPIO1 | GPIO_GPIO3)
  20. #define SOCKET1_3V GPIO_GPIO3
  21. static int
  22. jornada720_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
  23. {
  24. struct sa1111_pcmcia_socket *s = to_skt(skt);
  25. unsigned int pa_dwr_mask, pa_dwr_set;
  26. int ret;
  27. printk(KERN_INFO "%s(): config socket %d vcc %d vpp %d\n", __func__,
  28. skt->nr, state->Vcc, state->Vpp);
  29. switch (skt->nr) {
  30. case 0:
  31. pa_dwr_mask = SOCKET0_POWER | SOCKET0_3V;
  32. switch (state->Vcc) {
  33. default:
  34. case 0:
  35. pa_dwr_set = 0;
  36. break;
  37. case 33:
  38. pa_dwr_set = SOCKET0_POWER | SOCKET0_3V;
  39. break;
  40. case 50:
  41. pa_dwr_set = SOCKET0_POWER;
  42. break;
  43. }
  44. break;
  45. case 1:
  46. pa_dwr_mask = SOCKET1_POWER;
  47. switch (state->Vcc) {
  48. default:
  49. case 0:
  50. pa_dwr_set = 0;
  51. break;
  52. case 33:
  53. pa_dwr_set = SOCKET1_POWER;
  54. break;
  55. case 50:
  56. pa_dwr_set = SOCKET1_POWER;
  57. break;
  58. }
  59. break;
  60. default:
  61. return -1;
  62. }
  63. if (state->Vpp != state->Vcc && state->Vpp != 0) {
  64. printk(KERN_ERR "%s(): slot cannot support VPP %u\n",
  65. __func__, state->Vpp);
  66. return -EPERM;
  67. }
  68. ret = sa1111_pcmcia_configure_socket(skt, state);
  69. if (ret == 0) {
  70. unsigned long flags;
  71. local_irq_save(flags);
  72. sa1111_set_io(s->dev, pa_dwr_mask, pa_dwr_set);
  73. local_irq_restore(flags);
  74. }
  75. return ret;
  76. }
  77. static struct pcmcia_low_level jornada720_pcmcia_ops = {
  78. .owner = THIS_MODULE,
  79. .configure_socket = jornada720_pcmcia_configure_socket,
  80. .socket_init = sa1111_pcmcia_socket_init,
  81. .first = 0,
  82. .nr = 2,
  83. };
  84. int __devinit pcmcia_jornada720_init(struct device *dev)
  85. {
  86. int ret = -ENODEV;
  87. if (machine_is_jornada720()) {
  88. unsigned int pin = GPIO_A0 | GPIO_A1 | GPIO_A2 | GPIO_A3;
  89. GRER |= 0x00000002;
  90. /* Set GPIO_A<3:1> to be outputs for PCMCIA/CF power controller: */
  91. sa1111_set_io_dir(dev, pin, 0, 0);
  92. sa1111_set_io(dev, pin, 0);
  93. sa1111_set_sleep_io(dev, pin, 0);
  94. sa11xx_drv_pcmcia_ops(&jornada720_pcmcia_ops);
  95. ret = sa1111_pcmcia_add(dev, &jornada720_pcmcia_ops,
  96. sa11xx_drv_pcmcia_add_one);
  97. }
  98. return ret;
  99. }