sa1111_lubbock.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/drivers/pcmcia/pxa2xx_lubbock.c
  4. *
  5. * Author: George Davis
  6. * Created: Jan 10, 2002
  7. * Copyright: MontaVista Software Inc.
  8. *
  9. * Originally based upon linux/drivers/pcmcia/sa1100_neponset.c
  10. *
  11. * Lubbock PCMCIA specific routines.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/device.h>
  16. #include <linux/errno.h>
  17. #include <linux/init.h>
  18. #include <linux/delay.h>
  19. #include <asm/hardware/sa1111.h>
  20. #include <asm/mach-types.h>
  21. #include "sa1111_generic.h"
  22. #include "max1600.h"
  23. static int lubbock_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  24. {
  25. struct max1600 *m;
  26. int ret;
  27. ret = max1600_init(skt->socket.dev.parent, &m,
  28. skt->nr ? MAX1600_CHAN_B : MAX1600_CHAN_A,
  29. MAX1600_CODE_HIGH);
  30. if (ret == 0)
  31. skt->driver_data = m;
  32. return ret;
  33. }
  34. static int
  35. lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  36. const socket_state_t *state)
  37. {
  38. struct max1600 *m = skt->driver_data;
  39. int ret = 0;
  40. /* Lubbock uses the Maxim MAX1602, with the following connections:
  41. *
  42. * Socket 0 (PCMCIA):
  43. * MAX1602 Lubbock Register
  44. * Pin Signal
  45. * ----- ------- ----------------------
  46. * A0VPP S0_PWR0 SA-1111 GPIO A<0>
  47. * A1VPP S0_PWR1 SA-1111 GPIO A<1>
  48. * A0VCC S0_PWR2 SA-1111 GPIO A<2>
  49. * A1VCC S0_PWR3 SA-1111 GPIO A<3>
  50. * VX VCC
  51. * VY +3.3V
  52. * 12IN +12V
  53. * CODE +3.3V Cirrus Code, CODE = High (VY)
  54. *
  55. * Socket 1 (CF):
  56. * MAX1602 Lubbock Register
  57. * Pin Signal
  58. * ----- ------- ----------------------
  59. * A0VPP GND VPP is not connected
  60. * A1VPP GND VPP is not connected
  61. * A0VCC S1_PWR0 MISC_WR<14>
  62. * A1VCC S1_PWR1 MISC_WR<15>
  63. * VX VCC
  64. * VY +3.3V
  65. * 12IN GND VPP is not connected
  66. * CODE +3.3V Cirrus Code, CODE = High (VY)
  67. *
  68. */
  69. again:
  70. switch (skt->nr) {
  71. case 0:
  72. case 1:
  73. break;
  74. default:
  75. ret = -1;
  76. }
  77. if (ret == 0)
  78. ret = sa1111_pcmcia_configure_socket(skt, state);
  79. if (ret == 0)
  80. ret = max1600_configure(m, state->Vcc, state->Vpp);
  81. #if 1
  82. if (ret == 0 && state->Vcc == 33) {
  83. struct pcmcia_state new_state;
  84. /*
  85. * HACK ALERT:
  86. * We can't sense the voltage properly on Lubbock before
  87. * actually applying some power to the socket (catch 22).
  88. * Resense the socket Voltage Sense pins after applying
  89. * socket power.
  90. *
  91. * Note: It takes about 2.5ms for the MAX1602 VCC output
  92. * to rise.
  93. */
  94. mdelay(3);
  95. sa1111_pcmcia_socket_state(skt, &new_state);
  96. if (!new_state.vs_3v && !new_state.vs_Xv) {
  97. /*
  98. * Switch to 5V, Configure socket with 5V voltage
  99. */
  100. max1600_configure(m, 0, 0);
  101. /*
  102. * It takes about 100ms to turn off Vcc.
  103. */
  104. mdelay(100);
  105. /*
  106. * We need to hack around the const qualifier as
  107. * well to keep this ugly workaround localized and
  108. * not force it to the rest of the code. Barf bags
  109. * available in the seat pocket in front of you!
  110. */
  111. ((socket_state_t *)state)->Vcc = 50;
  112. ((socket_state_t *)state)->Vpp = 50;
  113. goto again;
  114. }
  115. }
  116. #endif
  117. return ret;
  118. }
  119. static struct pcmcia_low_level lubbock_pcmcia_ops = {
  120. .owner = THIS_MODULE,
  121. .hw_init = lubbock_pcmcia_hw_init,
  122. .configure_socket = lubbock_pcmcia_configure_socket,
  123. .first = 0,
  124. .nr = 2,
  125. };
  126. #include "pxa2xx_base.h"
  127. int pcmcia_lubbock_init(struct sa1111_dev *sadev)
  128. {
  129. pxa2xx_drv_pcmcia_ops(&lubbock_pcmcia_ops);
  130. pxa2xx_configure_sockets(&sadev->dev, &lubbock_pcmcia_ops);
  131. return sa1111_pcmcia_add(sadev, &lubbock_pcmcia_ops,
  132. pxa2xx_drv_pcmcia_add_one);
  133. }
  134. MODULE_LICENSE("GPL");