sa1111_neponset.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * linux/drivers/pcmcia/sa1100_neponset.c
  3. *
  4. * Neponset PCMCIA specific routines
  5. */
  6. #include <linux/module.h>
  7. #include <linux/kernel.h>
  8. #include <linux/device.h>
  9. #include <linux/errno.h>
  10. #include <linux/init.h>
  11. #include <mach/hardware.h>
  12. #include <asm/mach-types.h>
  13. #include <mach/neponset.h>
  14. #include <asm/hardware/sa1111.h>
  15. #include "sa1111_generic.h"
  16. /*
  17. * Neponset uses the Maxim MAX1600, with the following connections:
  18. *
  19. * MAX1600 Neponset
  20. *
  21. * A0VCC SA-1111 GPIO A<1>
  22. * A1VCC SA-1111 GPIO A<0>
  23. * A0VPP CPLD NCR A0VPP
  24. * A1VPP CPLD NCR A1VPP
  25. * B0VCC SA-1111 GPIO A<2>
  26. * B1VCC SA-1111 GPIO A<3>
  27. * B0VPP ground (slot B is CF)
  28. * B1VPP ground (slot B is CF)
  29. *
  30. * VX VCC (5V)
  31. * VY VCC3_3 (3.3V)
  32. * 12INA 12V
  33. * 12INB ground (slot B is CF)
  34. *
  35. * The MAX1600 CODE pin is tied to ground, placing the device in
  36. * "Standard Intel code" mode. Refer to the Maxim data sheet for
  37. * the corresponding truth table.
  38. */
  39. static int
  40. neponset_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
  41. {
  42. struct sa1111_pcmcia_socket *s = to_skt(skt);
  43. unsigned int ncr_mask, ncr_set, pa_dwr_mask, pa_dwr_set;
  44. int ret;
  45. switch (skt->nr) {
  46. case 0:
  47. pa_dwr_mask = GPIO_A0 | GPIO_A1;
  48. ncr_mask = NCR_A0VPP | NCR_A1VPP;
  49. if (state->Vpp == 0)
  50. ncr_set = 0;
  51. else if (state->Vpp == 120)
  52. ncr_set = NCR_A1VPP;
  53. else if (state->Vpp == state->Vcc)
  54. ncr_set = NCR_A0VPP;
  55. else {
  56. printk(KERN_ERR "%s(): unrecognized VPP %u\n",
  57. __func__, state->Vpp);
  58. return -1;
  59. }
  60. break;
  61. case 1:
  62. pa_dwr_mask = GPIO_A2 | GPIO_A3;
  63. ncr_mask = 0;
  64. ncr_set = 0;
  65. if (state->Vpp != state->Vcc && state->Vpp != 0) {
  66. printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n",
  67. __func__, state->Vpp);
  68. return -1;
  69. }
  70. break;
  71. default:
  72. return -1;
  73. }
  74. /*
  75. * pa_dwr_set is the mask for selecting Vcc on both sockets.
  76. * pa_dwr_mask selects which bits (and therefore socket) we change.
  77. */
  78. switch (state->Vcc) {
  79. default:
  80. case 0: pa_dwr_set = 0; break;
  81. case 33: pa_dwr_set = GPIO_A1|GPIO_A2; break;
  82. case 50: pa_dwr_set = GPIO_A0|GPIO_A3; break;
  83. }
  84. ret = sa1111_pcmcia_configure_socket(skt, state);
  85. if (ret == 0) {
  86. neponset_ncr_frob(ncr_mask, ncr_set);
  87. sa1111_set_io(s->dev, pa_dwr_mask, pa_dwr_set);
  88. }
  89. return ret;
  90. }
  91. static struct pcmcia_low_level neponset_pcmcia_ops = {
  92. .owner = THIS_MODULE,
  93. .configure_socket = neponset_pcmcia_configure_socket,
  94. .first = 0,
  95. .nr = 2,
  96. };
  97. int pcmcia_neponset_init(struct sa1111_dev *sadev)
  98. {
  99. int ret = -ENODEV;
  100. if (machine_is_assabet()) {
  101. /*
  102. * Set GPIO_A<3:0> to be outputs for the MAX1600,
  103. * and switch to standby mode.
  104. */
  105. sa1111_set_io_dir(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0);
  106. sa1111_set_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0);
  107. sa1111_set_sleep_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0);
  108. sa11xx_drv_pcmcia_ops(&neponset_pcmcia_ops);
  109. ret = sa1111_pcmcia_add(sadev, &neponset_pcmcia_ops,
  110. sa11xx_drv_pcmcia_add_one);
  111. }
  112. return ret;
  113. }