sa1100_badge4.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 <asm/hardware.h>
  21. #include <asm/mach-types.h>
  22. #include <asm/arch/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(__FUNCTION__, "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(__FUNCTION__, "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(__FUNCTION__, "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 0;
  111. }
  112. static struct pcmcia_low_level badge4_pcmcia_ops = {
  113. .owner = THIS_MODULE,
  114. .hw_init = sa1111_pcmcia_hw_init,
  115. .hw_shutdown = sa1111_pcmcia_hw_shutdown,
  116. .socket_state = sa1111_pcmcia_socket_state,
  117. .configure_socket = badge4_pcmcia_configure_socket,
  118. .socket_init = sa1111_pcmcia_socket_init,
  119. .socket_suspend = sa1111_pcmcia_socket_suspend,
  120. };
  121. int pcmcia_badge4_init(struct device *dev)
  122. {
  123. int ret = -ENODEV;
  124. if (machine_is_badge4()) {
  125. printk(KERN_INFO
  126. "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n",
  127. __FUNCTION__,
  128. badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc);
  129. ret = sa11xx_drv_pcmcia_probe(dev, &badge4_pcmcia_ops, 0, 2);
  130. }
  131. return ret;
  132. }
  133. static int __init pcmv_setup(char *s)
  134. {
  135. int v[4];
  136. s = get_options(s, ARRAY_SIZE(v), v);
  137. if (v[0] >= 1) badge4_pcmvcc = v[1];
  138. if (v[0] >= 2) badge4_pcmvpp = v[2];
  139. if (v[0] >= 3) badge4_cfvcc = v[3];
  140. return 1;
  141. }
  142. __setup("pcmv=", pcmv_setup);