1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/device.h>
20#include <linux/errno.h>
21#include <linux/init.h>
22#include <linux/delay.h>
23
24#include <mach/hardware.h>
25#include <asm/hardware/sa1111.h>
26#include <asm/mach-types.h>
27#include <mach/lubbock.h>
28
29#include "sa1111_generic.h"
30
31static int
32lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
33 const socket_state_t *state)
34{
35 struct sa1111_pcmcia_socket *s = to_skt(skt);
36 unsigned int pa_dwr_mask, pa_dwr_set, misc_mask, misc_set;
37 int ret = 0;
38
39 pa_dwr_mask = pa_dwr_set = misc_mask = misc_set = 0;
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 again:
72 switch (skt->nr) {
73 case 0:
74 pa_dwr_mask = GPIO_A0 | GPIO_A1 | GPIO_A2 | GPIO_A3;
75
76 switch (state->Vcc) {
77 case 0:
78 break;
79
80 case 33:
81 pa_dwr_set |= GPIO_A3;
82 break;
83
84 case 50:
85 pa_dwr_set |= GPIO_A2;
86 break;
87
88 default:
89 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
90 __func__, state->Vcc);
91 ret = -1;
92 }
93
94 switch (state->Vpp) {
95 case 0:
96 break;
97
98 case 120:
99 pa_dwr_set |= GPIO_A1;
100 break;
101
102 default:
103 if (state->Vpp == state->Vcc)
104 pa_dwr_set |= GPIO_A0;
105 else {
106 printk(KERN_ERR "%s(): unrecognized Vpp %u\n",
107 __func__, state->Vpp);
108 ret = -1;
109 break;
110 }
111 }
112 break;
113
114 case 1:
115 misc_mask = (1 << 15) | (1 << 14);
116
117 switch (state->Vcc) {
118 case 0:
119 break;
120
121 case 33:
122 misc_set |= 1 << 15;
123 break;
124
125 case 50:
126 misc_set |= 1 << 14;
127 break;
128
129 default:
130 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
131 __func__, state->Vcc);
132 ret = -1;
133 break;
134 }
135
136 if (state->Vpp != state->Vcc && state->Vpp != 0) {
137 printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n",
138 __func__, state->Vpp);
139 ret = -1;
140 break;
141 }
142 break;
143
144 default:
145 ret = -1;
146 }
147
148 if (ret == 0)
149 ret = sa1111_pcmcia_configure_socket(skt, state);
150
151 if (ret == 0) {
152 lubbock_set_misc_wr(misc_mask, misc_set);
153 sa1111_set_io(s->dev, pa_dwr_mask, pa_dwr_set);
154 }
155
156#if 1
157 if (ret == 0 && state->Vcc == 33) {
158 struct pcmcia_state new_state;
159
160
161
162
163
164
165
166
167
168
169
170 mdelay(3);
171
172 sa1111_pcmcia_socket_state(skt, &new_state);
173
174 if (!new_state.vs_3v && !new_state.vs_Xv) {
175
176
177
178 lubbock_set_misc_wr(misc_mask, 0);
179 sa1111_set_io(s->dev, pa_dwr_mask, 0);
180
181
182
183
184 mdelay(100);
185
186
187
188
189
190
191
192 ((socket_state_t *)state)->Vcc = 50;
193 ((socket_state_t *)state)->Vpp = 50;
194 goto again;
195 }
196 }
197#endif
198
199 return ret;
200}
201
202static struct pcmcia_low_level lubbock_pcmcia_ops = {
203 .owner = THIS_MODULE,
204 .configure_socket = lubbock_pcmcia_configure_socket,
205 .first = 0,
206 .nr = 2,
207};
208
209#include "pxa2xx_base.h"
210
211int pcmcia_lubbock_init(struct sa1111_dev *sadev)
212{
213 int ret = -ENODEV;
214
215 if (machine_is_lubbock()) {
216
217
218
219
220 sa1111_set_io_dir(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0);
221 sa1111_set_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0);
222 sa1111_set_sleep_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0);
223
224
225 lubbock_set_misc_wr((1 << 15) | (1 << 14), 0);
226
227 pxa2xx_drv_pcmcia_ops(&lubbock_pcmcia_ops);
228 pxa2xx_configure_sockets(&sadev->dev);
229 ret = sa1111_pcmcia_add(sadev, &lubbock_pcmcia_ops,
230 pxa2xx_drv_pcmcia_add_one);
231 }
232
233 return ret;
234}
235
236MODULE_LICENSE("GPL");
237