1
2
3
4
5
6
7
8
9
10
11
12
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
21#include <mach/hardware.h>
22#include <asm/mach-types.h>
23#include <mach/badge4.h>
24#include <asm/hardware/sa1111.h>
25
26#include "sa1111_generic.h"
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59static int badge4_pcmvcc = 50;
60static int badge4_pcmvpp = 50;
61static int badge4_cfvcc = 33;
62
63static void complain_about_jumpering(const char *whom,
64 const char *supply,
65 int given, int wanted)
66{
67 printk(KERN_ERR
68 "%s: %s %d.%dV wanted but board is jumpered for %s %d.%dV operation"
69 "; re-jumper the board and/or use pcmv=xx,xx,xx\n",
70 whom, supply,
71 wanted / 10, wanted % 10,
72 supply,
73 given / 10, given % 10);
74}
75
76static int
77badge4_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
78{
79 int ret;
80
81 switch (skt->nr) {
82 case 0:
83 if ((state->Vcc != 0) &&
84 (state->Vcc != badge4_pcmvcc)) {
85 complain_about_jumpering(__func__, "pcmvcc",
86 badge4_pcmvcc, state->Vcc);
87
88
89 }
90 if ((state->Vpp != 0) &&
91 (state->Vpp != badge4_pcmvpp)) {
92 complain_about_jumpering(__func__, "pcmvpp",
93 badge4_pcmvpp, state->Vpp);
94 return -1;
95 }
96 break;
97
98 case 1:
99 if ((state->Vcc != 0) &&
100 (state->Vcc != badge4_cfvcc)) {
101 complain_about_jumpering(__func__, "cfvcc",
102 badge4_cfvcc, state->Vcc);
103 return -1;
104 }
105 break;
106
107 default:
108 return -1;
109 }
110
111 ret = sa1111_pcmcia_configure_socket(skt, state);
112 if (ret == 0) {
113 unsigned long flags;
114 int need5V;
115
116 local_irq_save(flags);
117
118 need5V = ((state->Vcc == 50) || (state->Vpp == 50));
119
120 badge4_set_5V(BADGE4_5V_PCMCIA_SOCK(skt->nr), need5V);
121
122 local_irq_restore(flags);
123 }
124
125 return ret;
126}
127
128static struct pcmcia_low_level badge4_pcmcia_ops = {
129 .owner = THIS_MODULE,
130 .configure_socket = badge4_pcmcia_configure_socket,
131 .first = 0,
132 .nr = 2,
133};
134
135int pcmcia_badge4_init(struct sa1111_dev *dev)
136{
137 printk(KERN_INFO
138 "%s: badge4_pcmvcc=%d, badge4_pcmvpp=%d, badge4_cfvcc=%d\n",
139 __func__,
140 badge4_pcmvcc, badge4_pcmvpp, badge4_cfvcc);
141
142 sa11xx_drv_pcmcia_ops(&badge4_pcmcia_ops);
143 return sa1111_pcmcia_add(dev, &badge4_pcmcia_ops,
144 sa11xx_drv_pcmcia_add_one);
145}
146
147static int __init pcmv_setup(char *s)
148{
149 int v[4];
150
151 s = get_options(s, ARRAY_SIZE(v), v);
152
153 if (v[0] >= 1) badge4_pcmvcc = v[1];
154 if (v[0] >= 2) badge4_pcmvpp = v[2];
155 if (v[0] >= 3) badge4_cfvcc = v[3];
156
157 return 1;
158}
159
160__setup("pcmv=", pcmv_setup);
161