sa1111_lubbock.c 3.4 KB

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