2 * linux/drivers/pcmcia/sa1100_badge4.c
4 * BadgePAD 4 PCMCIA specific routines
6 * Christopher Hoover <ch@hpl.hp.com>
8 * Copyright (C) 2002 Hewlett-Packard Company
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.
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
17 #include <linux/init.h>
19 #include <asm/hardware.h>
20 #include <asm/arch/badge4.h>
21 #include <asm/hardware/sa1111.h>
23 #include "sa1100_generic.h"
24 #include "sa1111_generic.h"
31 * PCM Vcc on BadgePAD 4 can be jumpered for 3.3V (short pins 1 and 3
32 * on JP6) or 5V (short pins 3 and 5 on JP6). N.B., 5V supply rail
33 * is enabled by the SA-1110's BADGE4_GPIO_PCMEN5V (GPIO 24).
37 * PCM Vpp on BadgePAD 4 can be jumpered for 12V (short pins 2 and 4
38 * on JP6) or tied to PCM Vcc (short pins 4 and 6 on JP6). N.B., 12V
39 * operation requires that the power supply actually supply 12V.
43 * CF Vcc on BadgePAD 4 can be jumpered either for 3.3V (short pins 1
44 * and 2 on JP10) or 5V (short pins 2 and 3 on JP10). The note above
45 * about the 5V supply rail applies.
47 * There's no way programmatically to determine how a given board is
48 * jumpered. This code assumes a default jumpering: 5V PCM Vcc (pins
49 * 3 and 5 shorted) and PCM Vpp = PCM Vcc (pins 4 and 6 shorted) and
50 * no jumpering for CF Vcc. If this isn't correct, Override these
51 * defaults with a pcmv setup argument: pcmv=<pcm vcc>,<pcm vpp>,<cf
52 * vcc>. E.g. pcmv=33,120,50 indicates 3.3V PCM Vcc, 12.0V PCM Vpp,
57 static int badge4_pcmvcc = 50;
58 static int badge4_pcmvpp = 50;
59 static int badge4_cfvcc = 0;
61 static int badge4_pcmcia_init(struct pcmcia_init *init)
63 printk(KERN_INFO __FUNCTION__
64 ": badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n",
65 badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc);
67 return sa1111_pcmcia_init(init);
70 static int badge4_pcmcia_shutdown(void)
72 int rc = sa1111_pcmcia_shutdown();
74 /* be sure to disable 5V use */
75 badge4_set_5V(BADGE4_5V_PCMCIA_SOCK0, 0);
76 badge4_set_5V(BADGE4_5V_PCMCIA_SOCK1, 0);
81 static void complain_about_jumpering(const char *whom,
83 int given, int wanted)
86 "%s: %s %d.%dV wanted but board is jumpered for %s %d.%dV operation"
87 "; re-jumper the board and/or use pcmv=xx,xx,xx\n",
89 wanted / 10, wanted % 10,
91 given / 10, given % 10);
94 static unsigned badge4_need_5V_bitmap = 0;
97 badge4_pcmcia_configure_socket(const struct pcmcia_configure *conf)
101 switch (conf->sock) {
103 if ((conf->vcc != 0) &&
104 (conf->vcc != badge4_pcmvcc)) {
105 complain_about_jumpering(__FUNCTION__, "pcmvcc",
106 badge4_pcmvcc, conf->vcc);
109 if ((conf->vpp != 0) &&
110 (conf->vpp != badge4_pcmvpp)) {
111 complain_about_jumpering(__FUNCTION__, "pcmvpp",
112 badge4_pcmvpp, conf->vpp);
118 if ((conf->vcc != 0) &&
119 (conf->vcc != badge4_cfvcc)) {
120 complain_about_jumpering(__FUNCTION__, "cfvcc",
121 badge4_cfvcc, conf->vcc);
130 ret = sa1111_pcmcia_configure_socket(conf);
135 local_irq_save(flags);
137 need5V = ((conf->vcc == 50) || (conf->vpp == 50));
139 badge4_set_5V(BADGE4_5V_PCMCIA_SOCK(conf->sock), need5V);
141 local_irq_restore(flags);
147 struct pcmcia_low_level badge4_pcmcia_ops = {
148 init: badge4_pcmcia_init,
149 shutdown: badge4_pcmcia_shutdown,
150 socket_state: sa1111_pcmcia_socket_state,
151 get_irq_info: sa1111_pcmcia_get_irq_info,
152 configure_socket: badge4_pcmcia_configure_socket,
154 socket_init: sa1111_pcmcia_socket_init,
155 socket_suspend: sa1111_pcmcia_socket_suspend,
159 static int __init pcmv_setup(char *s)
163 s = get_options(s, ARRAY_SIZE(v), v);
165 if (v[0] >= 1) badge4_pcmvcc = v[1];
166 if (v[0] >= 2) badge4_pcmvpp = v[2];
167 if (v[0] >= 3) badge4_cfvcc = v[3];
172 __setup("pcmv=", pcmv_setup);