sa1111_badge4.c 3.9 KB

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