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