sa1100_badge4.c 4.1 KB

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