sa1111_badge4.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/drivers/pcmcia/sa1100_badge4.c
  4. *
  5. * BadgePAD 4 PCMCIA specific routines
  6. *
  7. * Christopher Hoover <[email protected]>
  8. *
  9. * Copyright (C) 2002 Hewlett-Packard Company
  10. */
  11. #include <linux/module.h>
  12. #include <linux/kernel.h>
  13. #include <linux/device.h>
  14. #include <linux/errno.h>
  15. #include <linux/init.h>
  16. #include <mach/hardware.h>
  17. #include <asm/mach-types.h>
  18. #include <mach/badge4.h>
  19. #include <asm/hardware/sa1111.h>
  20. #include "sa1111_generic.h"
  21. /*
  22. * BadgePAD 4 Details
  23. *
  24. * PCM Vcc:
  25. *
  26. * PCM Vcc on BadgePAD 4 can be jumpered for 3v3 (short pins 1 and 3
  27. * on JP6) or 5v0 (short pins 3 and 5 on JP6).
  28. *
  29. * PCM Vpp:
  30. *
  31. * PCM Vpp on BadgePAD 4 can be jumpered for 12v0 (short pins 4 and 6
  32. * on JP6) or tied to PCM Vcc (short pins 2 and 4 on JP6). N.B.,
  33. * 12v0 operation requires that the power supply actually supply 12v0
  34. * via pin 7 of JP7.
  35. *
  36. * CF Vcc:
  37. *
  38. * CF Vcc on BadgePAD 4 can be jumpered either for 3v3 (short pins 1
  39. * and 2 on JP10) or 5v0 (short pins 2 and 3 on JP10).
  40. *
  41. * Unfortunately there's no way programmatically to determine how a
  42. * given board is jumpered. This code assumes a default jumpering
  43. * as described below.
  44. *
  45. * If the defaults aren't correct, you may override them with a pcmv
  46. * setup argument: pcmv=<pcm vcc>,<pcm vpp>,<cf vcc>. The units are
  47. * tenths of volts; e.g. pcmv=33,120,50 indicates 3v3 PCM Vcc, 12v0
  48. * PCM Vpp, and 5v0 CF Vcc.
  49. *
  50. */
  51. static int badge4_pcmvcc = 50; /* pins 3 and 5 jumpered on JP6 */
  52. static int badge4_pcmvpp = 50; /* pins 2 and 4 jumpered on JP6 */
  53. static int badge4_cfvcc = 33; /* pins 1 and 2 jumpered on JP10 */
  54. static void complain_about_jumpering(const char *whom,
  55. const char *supply,
  56. int given, int wanted)
  57. {
  58. printk(KERN_ERR
  59. "%s: %s %d.%dV wanted but board is jumpered for %s %d.%dV operation"
  60. "; re-jumper the board and/or use pcmv=xx,xx,xx\n",
  61. whom, supply,
  62. wanted / 10, wanted % 10,
  63. supply,
  64. given / 10, given % 10);
  65. }
  66. static int
  67. badge4_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
  68. {
  69. int ret;
  70. switch (skt->nr) {
  71. case 0:
  72. if ((state->Vcc != 0) &&
  73. (state->Vcc != badge4_pcmvcc)) {
  74. complain_about_jumpering(__func__, "pcmvcc",
  75. badge4_pcmvcc, state->Vcc);
  76. // Apply power regardless of the jumpering.
  77. // return -1;
  78. }
  79. if ((state->Vpp != 0) &&
  80. (state->Vpp != badge4_pcmvpp)) {
  81. complain_about_jumpering(__func__, "pcmvpp",
  82. badge4_pcmvpp, state->Vpp);
  83. return -1;
  84. }
  85. break;
  86. case 1:
  87. if ((state->Vcc != 0) &&
  88. (state->Vcc != badge4_cfvcc)) {
  89. complain_about_jumpering(__func__, "cfvcc",
  90. badge4_cfvcc, state->Vcc);
  91. return -1;
  92. }
  93. break;
  94. default:
  95. return -1;
  96. }
  97. ret = sa1111_pcmcia_configure_socket(skt, state);
  98. if (ret == 0) {
  99. unsigned long flags;
  100. int need5V;
  101. local_irq_save(flags);
  102. need5V = ((state->Vcc == 50) || (state->Vpp == 50));
  103. badge4_set_5V(BADGE4_5V_PCMCIA_SOCK(skt->nr), need5V);
  104. local_irq_restore(flags);
  105. }
  106. return ret;
  107. }
  108. static struct pcmcia_low_level badge4_pcmcia_ops = {
  109. .owner = THIS_MODULE,
  110. .configure_socket = badge4_pcmcia_configure_socket,
  111. .first = 0,
  112. .nr = 2,
  113. };
  114. int pcmcia_badge4_init(struct sa1111_dev *dev)
  115. {
  116. printk(KERN_INFO
  117. "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n",
  118. __func__,
  119. badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc);
  120. sa11xx_drv_pcmcia_ops(&badge4_pcmcia_ops);
  121. return sa1111_pcmcia_add(dev, &badge4_pcmcia_ops,
  122. sa11xx_drv_pcmcia_add_one);
  123. }
  124. #ifndef MODULE
  125. static int __init pcmv_setup(char *s)
  126. {
  127. int v[4];
  128. s = get_options(s, ARRAY_SIZE(v), v);
  129. if (v[0] >= 1) badge4_pcmvcc = v[1];
  130. if (v[0] >= 2) badge4_pcmvpp = v[2];
  131. if (v[0] >= 3) badge4_cfvcc = v[3];
  132. return 1;
  133. }
  134. __setup("pcmv=", pcmv_setup);
  135. #endif