Commit | Line | Data |
---|---|---|
ff1d2767 JM |
1 | #define PRISM2_PCCARD |
2 | ||
ff1d2767 JM |
3 | #include <linux/module.h> |
4 | #include <linux/init.h> | |
5 | #include <linux/if.h> | |
5a0e3ad6 | 6 | #include <linux/slab.h> |
ff1d2767 JM |
7 | #include <linux/wait.h> |
8 | #include <linux/timer.h> | |
9 | #include <linux/skbuff.h> | |
10 | #include <linux/netdevice.h> | |
11 | #include <linux/workqueue.h> | |
12 | #include <linux/wireless.h> | |
13 | #include <net/iw_handler.h> | |
14 | ||
ff1d2767 JM |
15 | #include <pcmcia/cs.h> |
16 | #include <pcmcia/cistpl.h> | |
17 | #include <pcmcia/cisreg.h> | |
18 | #include <pcmcia/ds.h> | |
19 | ||
20 | #include <asm/io.h> | |
21 | ||
22 | #include "hostap_wlan.h" | |
23 | ||
24 | ||
ac8b4228 | 25 | static char *dev_info = "hostap_cs"; |
ff1d2767 JM |
26 | |
27 | MODULE_AUTHOR("Jouni Malinen"); | |
28 | MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN " | |
29 | "cards (PC Card)."); | |
30 | MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PC Card)"); | |
31 | MODULE_LICENSE("GPL"); | |
32 | ||
33 | ||
ff1d2767 JM |
34 | static int ignore_cis_vcc; |
35 | module_param(ignore_cis_vcc, int, 0444); | |
36 | MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry"); | |
37 | ||
38 | ||
67e0e473 JM |
39 | /* struct local_info::hw_priv */ |
40 | struct hostap_cs_priv { | |
fba395ee | 41 | struct pcmcia_device *link; |
67e0e473 JM |
42 | int sandisk_connectplus; |
43 | }; | |
44 | ||
45 | ||
ff1d2767 JM |
46 | #ifdef PRISM2_IO_DEBUG |
47 | ||
48 | static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v) | |
49 | { | |
50 | struct hostap_interface *iface; | |
51 | local_info_t *local; | |
52 | unsigned long flags; | |
53 | ||
54 | iface = netdev_priv(dev); | |
55 | local = iface->local; | |
56 | spin_lock_irqsave(&local->lock, flags); | |
57 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v); | |
58 | outb(v, dev->base_addr + a); | |
59 | spin_unlock_irqrestore(&local->lock, flags); | |
60 | } | |
61 | ||
62 | static inline u8 hfa384x_inb_debug(struct net_device *dev, int a) | |
63 | { | |
64 | struct hostap_interface *iface; | |
65 | local_info_t *local; | |
66 | unsigned long flags; | |
67 | u8 v; | |
68 | ||
69 | iface = netdev_priv(dev); | |
70 | local = iface->local; | |
71 | spin_lock_irqsave(&local->lock, flags); | |
72 | v = inb(dev->base_addr + a); | |
73 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v); | |
74 | spin_unlock_irqrestore(&local->lock, flags); | |
75 | return v; | |
76 | } | |
77 | ||
78 | static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v) | |
79 | { | |
80 | struct hostap_interface *iface; | |
81 | local_info_t *local; | |
82 | unsigned long flags; | |
83 | ||
84 | iface = netdev_priv(dev); | |
85 | local = iface->local; | |
86 | spin_lock_irqsave(&local->lock, flags); | |
87 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v); | |
88 | outw(v, dev->base_addr + a); | |
89 | spin_unlock_irqrestore(&local->lock, flags); | |
90 | } | |
91 | ||
92 | static inline u16 hfa384x_inw_debug(struct net_device *dev, int a) | |
93 | { | |
94 | struct hostap_interface *iface; | |
95 | local_info_t *local; | |
96 | unsigned long flags; | |
97 | u16 v; | |
98 | ||
99 | iface = netdev_priv(dev); | |
100 | local = iface->local; | |
101 | spin_lock_irqsave(&local->lock, flags); | |
102 | v = inw(dev->base_addr + a); | |
103 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v); | |
104 | spin_unlock_irqrestore(&local->lock, flags); | |
105 | return v; | |
106 | } | |
107 | ||
108 | static inline void hfa384x_outsw_debug(struct net_device *dev, int a, | |
109 | u8 *buf, int wc) | |
110 | { | |
111 | struct hostap_interface *iface; | |
112 | local_info_t *local; | |
113 | unsigned long flags; | |
114 | ||
115 | iface = netdev_priv(dev); | |
116 | local = iface->local; | |
117 | spin_lock_irqsave(&local->lock, flags); | |
118 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTSW, a, wc); | |
119 | outsw(dev->base_addr + a, buf, wc); | |
120 | spin_unlock_irqrestore(&local->lock, flags); | |
121 | } | |
122 | ||
123 | static inline void hfa384x_insw_debug(struct net_device *dev, int a, | |
124 | u8 *buf, int wc) | |
125 | { | |
126 | struct hostap_interface *iface; | |
127 | local_info_t *local; | |
128 | unsigned long flags; | |
129 | ||
130 | iface = netdev_priv(dev); | |
131 | local = iface->local; | |
132 | spin_lock_irqsave(&local->lock, flags); | |
133 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INSW, a, wc); | |
134 | insw(dev->base_addr + a, buf, wc); | |
135 | spin_unlock_irqrestore(&local->lock, flags); | |
136 | } | |
137 | ||
138 | #define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v)) | |
139 | #define HFA384X_INB(a) hfa384x_inb_debug(dev, (a)) | |
140 | #define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v)) | |
141 | #define HFA384X_INW(a) hfa384x_inw_debug(dev, (a)) | |
142 | #define HFA384X_OUTSW(a, buf, wc) hfa384x_outsw_debug(dev, (a), (buf), (wc)) | |
143 | #define HFA384X_INSW(a, buf, wc) hfa384x_insw_debug(dev, (a), (buf), (wc)) | |
144 | ||
145 | #else /* PRISM2_IO_DEBUG */ | |
146 | ||
147 | #define HFA384X_OUTB(v,a) outb((v), dev->base_addr + (a)) | |
148 | #define HFA384X_INB(a) inb(dev->base_addr + (a)) | |
149 | #define HFA384X_OUTW(v,a) outw((v), dev->base_addr + (a)) | |
150 | #define HFA384X_INW(a) inw(dev->base_addr + (a)) | |
151 | #define HFA384X_INSW(a, buf, wc) insw(dev->base_addr + (a), buf, wc) | |
152 | #define HFA384X_OUTSW(a, buf, wc) outsw(dev->base_addr + (a), buf, wc) | |
153 | ||
154 | #endif /* PRISM2_IO_DEBUG */ | |
155 | ||
156 | ||
157 | static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf, | |
158 | int len) | |
159 | { | |
160 | u16 d_off; | |
161 | u16 *pos; | |
162 | ||
163 | d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF; | |
164 | pos = (u16 *) buf; | |
165 | ||
166 | if (len / 2) | |
167 | HFA384X_INSW(d_off, buf, len / 2); | |
168 | pos += len / 2; | |
169 | ||
170 | if (len & 1) | |
171 | *((char *) pos) = HFA384X_INB(d_off); | |
172 | ||
173 | return 0; | |
174 | } | |
175 | ||
176 | ||
177 | static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len) | |
178 | { | |
179 | u16 d_off; | |
180 | u16 *pos; | |
181 | ||
182 | d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF; | |
183 | pos = (u16 *) buf; | |
184 | ||
185 | if (len / 2) | |
186 | HFA384X_OUTSW(d_off, buf, len / 2); | |
187 | pos += len / 2; | |
188 | ||
189 | if (len & 1) | |
190 | HFA384X_OUTB(*((char *) pos), d_off); | |
191 | ||
192 | return 0; | |
193 | } | |
194 | ||
195 | ||
196 | /* FIX: This might change at some point.. */ | |
197 | #include "hostap_hw.c" | |
198 | ||
199 | ||
200 | ||
cc3b4866 | 201 | static void prism2_detach(struct pcmcia_device *p_dev); |
ff1d2767 | 202 | static void prism2_release(u_long arg); |
fba395ee | 203 | static int prism2_config(struct pcmcia_device *link); |
ff1d2767 JM |
204 | |
205 | ||
206 | static int prism2_pccard_card_present(local_info_t *local) | |
207 | { | |
67e0e473 | 208 | struct hostap_cs_priv *hw_priv = local->hw_priv; |
9940ec36 | 209 | if (hw_priv != NULL && hw_priv->link != NULL && pcmcia_dev_present(hw_priv->link)) |
ff1d2767 JM |
210 | return 1; |
211 | return 0; | |
212 | } | |
213 | ||
214 | ||
215 | /* | |
216 | * SanDisk CompactFlash WLAN Flashcard - Product Manual v1.0 | |
217 | * Document No. 20-10-00058, January 2004 | |
218 | * http://www.sandisk.com/pdf/industrial/ProdManualCFWLANv1.0.pdf | |
219 | */ | |
220 | #define SANDISK_WLAN_ACTIVATION_OFF 0x40 | |
221 | #define SANDISK_HCR_OFF 0x42 | |
222 | ||
223 | ||
224 | static void sandisk_set_iobase(local_info_t *local) | |
225 | { | |
226 | int res; | |
67e0e473 | 227 | struct hostap_cs_priv *hw_priv = local->hw_priv; |
ff1d2767 | 228 | |
1d5cc192 DB |
229 | res = pcmcia_write_config_byte(hw_priv->link, 0x10, |
230 | hw_priv->link->io.BasePort1 & 0x00ff); | |
4c89e88b | 231 | if (res != 0) { |
ff1d2767 JM |
232 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" |
233 | " res=%d\n", res); | |
234 | } | |
235 | udelay(10); | |
236 | ||
1d5cc192 DB |
237 | res = pcmcia_write_config_byte(hw_priv->link, 0x12, |
238 | (hw_priv->link->io.BasePort1 >> 8) & 0x00ff); | |
4c89e88b | 239 | if (res != 0) { |
ff1d2767 JM |
240 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" |
241 | " res=%d\n", res); | |
242 | } | |
243 | } | |
244 | ||
245 | ||
246 | static void sandisk_write_hcr(local_info_t *local, int hcr) | |
247 | { | |
248 | struct net_device *dev = local->dev; | |
249 | int i; | |
250 | ||
251 | HFA384X_OUTB(0x80, SANDISK_WLAN_ACTIVATION_OFF); | |
252 | udelay(50); | |
253 | for (i = 0; i < 10; i++) { | |
254 | HFA384X_OUTB(hcr, SANDISK_HCR_OFF); | |
255 | } | |
256 | udelay(55); | |
257 | HFA384X_OUTB(0x45, SANDISK_WLAN_ACTIVATION_OFF); | |
258 | } | |
259 | ||
260 | ||
261 | static int sandisk_enable_wireless(struct net_device *dev) | |
262 | { | |
263 | int res, ret = 0; | |
6dbc9c89 | 264 | struct hostap_interface *iface = netdev_priv(dev); |
ff1d2767 | 265 | local_info_t *local = iface->local; |
67e0e473 | 266 | struct hostap_cs_priv *hw_priv = local->hw_priv; |
ff1d2767 | 267 | |
67e0e473 | 268 | if (hw_priv->link->io.NumPorts1 < 0x42) { |
ff1d2767 JM |
269 | /* Not enough ports to be SanDisk multi-function card */ |
270 | ret = -ENODEV; | |
271 | goto done; | |
272 | } | |
273 | ||
efd50585 | 274 | if (hw_priv->link->manf_id != 0xd601 || hw_priv->link->card_id != 0x0101) { |
ff1d2767 JM |
275 | /* No SanDisk manfid found */ |
276 | ret = -ENODEV; | |
277 | goto done; | |
278 | } | |
279 | ||
7d2e8d00 | 280 | if (hw_priv->link->socket->functions < 2) { |
ff1d2767 JM |
281 | /* No multi-function links found */ |
282 | ret = -ENODEV; | |
283 | goto done; | |
284 | } | |
285 | ||
286 | printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected" | |
287 | " - using vendor-specific initialization\n", dev->name); | |
67e0e473 | 288 | hw_priv->sandisk_connectplus = 1; |
ff1d2767 | 289 | |
1d5cc192 DB |
290 | res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, |
291 | COR_SOFT_RESET); | |
4c89e88b | 292 | if (res != 0) { |
ff1d2767 JM |
293 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", |
294 | dev->name, res); | |
295 | goto done; | |
296 | } | |
297 | mdelay(5); | |
298 | ||
ff1d2767 JM |
299 | /* |
300 | * Do not enable interrupts here to avoid some bogus events. Interrupts | |
301 | * will be enabled during the first cor_sreset call. | |
302 | */ | |
1d5cc192 DB |
303 | res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, |
304 | (COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | | |
305 | COR_FUNC_ENA)); | |
4c89e88b | 306 | if (res != 0) { |
ff1d2767 JM |
307 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", |
308 | dev->name, res); | |
309 | goto done; | |
310 | } | |
311 | mdelay(5); | |
312 | ||
313 | sandisk_set_iobase(local); | |
314 | ||
315 | HFA384X_OUTB(0xc5, SANDISK_WLAN_ACTIVATION_OFF); | |
316 | udelay(10); | |
317 | HFA384X_OUTB(0x4b, SANDISK_WLAN_ACTIVATION_OFF); | |
318 | udelay(10); | |
319 | ||
320 | done: | |
ff1d2767 JM |
321 | return ret; |
322 | } | |
323 | ||
324 | ||
325 | static void prism2_pccard_cor_sreset(local_info_t *local) | |
326 | { | |
327 | int res; | |
1d5cc192 | 328 | u8 val; |
67e0e473 | 329 | struct hostap_cs_priv *hw_priv = local->hw_priv; |
ff1d2767 JM |
330 | |
331 | if (!prism2_pccard_card_present(local)) | |
332 | return; | |
333 | ||
1d5cc192 | 334 | res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &val); |
4c89e88b | 335 | if (res != 0) { |
ff1d2767 JM |
336 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", |
337 | res); | |
338 | return; | |
339 | } | |
340 | printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n", | |
1d5cc192 | 341 | val); |
ff1d2767 | 342 | |
1d5cc192 DB |
343 | val |= COR_SOFT_RESET; |
344 | res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val); | |
4c89e88b | 345 | if (res != 0) { |
ff1d2767 JM |
346 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", |
347 | res); | |
348 | return; | |
349 | } | |
350 | ||
67e0e473 | 351 | mdelay(hw_priv->sandisk_connectplus ? 5 : 2); |
ff1d2767 | 352 | |
1d5cc192 | 353 | val &= ~COR_SOFT_RESET; |
67e0e473 | 354 | if (hw_priv->sandisk_connectplus) |
1d5cc192 DB |
355 | val |= COR_IREQ_ENA; |
356 | res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val); | |
4c89e88b | 357 | if (res != 0) { |
ff1d2767 JM |
358 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", |
359 | res); | |
360 | return; | |
361 | } | |
362 | ||
67e0e473 | 363 | mdelay(hw_priv->sandisk_connectplus ? 5 : 2); |
ff1d2767 | 364 | |
67e0e473 | 365 | if (hw_priv->sandisk_connectplus) |
ff1d2767 JM |
366 | sandisk_set_iobase(local); |
367 | } | |
368 | ||
369 | ||
370 | static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |
371 | { | |
372 | int res; | |
1d5cc192 | 373 | u8 old_cor; |
67e0e473 | 374 | struct hostap_cs_priv *hw_priv = local->hw_priv; |
ff1d2767 JM |
375 | |
376 | if (!prism2_pccard_card_present(local)) | |
377 | return; | |
378 | ||
67e0e473 | 379 | if (hw_priv->sandisk_connectplus) { |
ff1d2767 JM |
380 | sandisk_write_hcr(local, hcr); |
381 | return; | |
382 | } | |
383 | ||
1d5cc192 | 384 | res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &old_cor); |
4c89e88b | 385 | if (res != 0) { |
ff1d2767 JM |
386 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " |
387 | "(%d)\n", res); | |
388 | return; | |
389 | } | |
390 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n", | |
1d5cc192 | 391 | old_cor); |
ff1d2767 | 392 | |
1d5cc192 DB |
393 | res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, |
394 | old_cor | COR_SOFT_RESET); | |
4c89e88b | 395 | if (res != 0) { |
ff1d2767 JM |
396 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " |
397 | "(%d)\n", res); | |
398 | return; | |
399 | } | |
400 | ||
401 | mdelay(10); | |
402 | ||
403 | /* Setup Genesis mode */ | |
1d5cc192 | 404 | res = pcmcia_write_config_byte(hw_priv->link, CISREG_CCSR, hcr); |
4c89e88b | 405 | if (res != 0) { |
ff1d2767 JM |
406 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " |
407 | "(%d)\n", res); | |
408 | return; | |
409 | } | |
410 | mdelay(10); | |
411 | ||
1d5cc192 DB |
412 | res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, |
413 | old_cor & ~COR_SOFT_RESET); | |
4c89e88b | 414 | if (res != 0) { |
ff1d2767 JM |
415 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " |
416 | "(%d)\n", res); | |
417 | return; | |
418 | } | |
419 | ||
420 | mdelay(10); | |
421 | } | |
422 | ||
423 | ||
ff1d2767 JM |
424 | static struct prism2_helper_functions prism2_pccard_funcs = |
425 | { | |
426 | .card_present = prism2_pccard_card_present, | |
427 | .cor_sreset = prism2_pccard_cor_sreset, | |
ff1d2767 JM |
428 | .genesis_reset = prism2_pccard_genesis_reset, |
429 | .hw_type = HOSTAP_HW_PCCARD, | |
430 | }; | |
431 | ||
432 | ||
433 | /* allocate local data and register with CardServices | |
434 | * initialize dev_link structure, but do not configure the card yet */ | |
15b99ac1 | 435 | static int hostap_cs_probe(struct pcmcia_device *p_dev) |
ff1d2767 | 436 | { |
15b99ac1 DB |
437 | int ret; |
438 | ||
ff1d2767 | 439 | PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); |
fd238232 | 440 | p_dev->conf.IntType = INT_MEMORY_AND_IO; |
f8cfa618 | 441 | |
15b99ac1 DB |
442 | ret = prism2_config(p_dev); |
443 | if (ret) { | |
f8cfa618 | 444 | PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); |
15b99ac1 | 445 | } |
f8cfa618 | 446 | |
15b99ac1 | 447 | return ret; |
ff1d2767 JM |
448 | } |
449 | ||
450 | ||
fba395ee | 451 | static void prism2_detach(struct pcmcia_device *link) |
ff1d2767 | 452 | { |
ff1d2767 JM |
453 | PDEBUG(DEBUG_FLOW, "prism2_detach\n"); |
454 | ||
e2d40963 | 455 | prism2_release((u_long)link); |
ff1d2767 | 456 | |
ff1d2767 JM |
457 | /* release net devices */ |
458 | if (link->priv) { | |
c355184c | 459 | struct hostap_cs_priv *hw_priv; |
67e0e473 JM |
460 | struct net_device *dev; |
461 | struct hostap_interface *iface; | |
462 | dev = link->priv; | |
463 | iface = netdev_priv(dev); | |
c355184c | 464 | hw_priv = iface->local->hw_priv; |
67e0e473 | 465 | prism2_free_local_data(dev); |
c355184c | 466 | kfree(hw_priv); |
ff1d2767 | 467 | } |
ff1d2767 JM |
468 | } |
469 | ||
470 | ||
ff1d2767 JM |
471 | /* run after a CARD_INSERTION event is received to configure the PCMCIA |
472 | * socket and make the device available to the system */ | |
b54bf94b | 473 | |
b54bf94b DB |
474 | static int prism2_config_check(struct pcmcia_device *p_dev, |
475 | cistpl_cftable_entry_t *cfg, | |
8e2fc39d | 476 | cistpl_cftable_entry_t *dflt, |
ad913c11 | 477 | unsigned int vcc, |
b54bf94b DB |
478 | void *priv_data) |
479 | { | |
b54bf94b DB |
480 | if (cfg->index == 0) |
481 | return -ENODEV; | |
482 | ||
b54bf94b | 483 | PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X " |
8e2fc39d | 484 | "(default 0x%02X)\n", cfg->index, dflt->index); |
b54bf94b DB |
485 | |
486 | /* Does this card need audio output? */ | |
487 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | |
488 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; | |
489 | p_dev->conf.Status = CCSR_AUDIO_ENA; | |
490 | } | |
491 | ||
492 | /* Use power settings for Vcc and Vpp if present */ | |
493 | /* Note that the CIS values need to be rescaled */ | |
494 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | |
ad913c11 | 495 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / |
b54bf94b DB |
496 | 10000 && !ignore_cis_vcc) { |
497 | PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping" | |
498 | " this entry\n"); | |
499 | return -ENODEV; | |
500 | } | |
8e2fc39d | 501 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { |
ad913c11 | 502 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / |
b54bf94b DB |
503 | 10000 && !ignore_cis_vcc) { |
504 | PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " | |
505 | "- skipping this entry\n"); | |
506 | return -ENODEV; | |
507 | } | |
508 | } | |
509 | ||
510 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | |
511 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | |
8e2fc39d DB |
512 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
513 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | |
b54bf94b DB |
514 | |
515 | /* Do we need to allocate an interrupt? */ | |
eb14120f | 516 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; |
b54bf94b DB |
517 | |
518 | /* IO window settings */ | |
519 | PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " | |
8e2fc39d DB |
520 | "dflt->io.nwin=%d\n", |
521 | cfg->io.nwin, dflt->io.nwin); | |
b54bf94b | 522 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; |
8e2fc39d DB |
523 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { |
524 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | |
b54bf94b DB |
525 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
526 | PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " | |
527 | "io.base=0x%04x, len=%d\n", io->flags, | |
528 | io->win[0].base, io->win[0].len); | |
529 | if (!(io->flags & CISTPL_IO_8BIT)) | |
530 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | |
531 | if (!(io->flags & CISTPL_IO_16BIT)) | |
532 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | |
533 | p_dev->io.IOAddrLines = io->flags & | |
534 | CISTPL_IO_LINES_MASK; | |
535 | p_dev->io.BasePort1 = io->win[0].base; | |
536 | p_dev->io.NumPorts1 = io->win[0].len; | |
537 | if (io->nwin > 1) { | |
538 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | |
539 | p_dev->io.BasePort2 = io->win[1].base; | |
540 | p_dev->io.NumPorts2 = io->win[1].len; | |
541 | } | |
542 | } | |
543 | ||
544 | /* This reserves IO space but doesn't actually enable it */ | |
545 | return pcmcia_request_io(p_dev, &p_dev->io); | |
546 | } | |
547 | ||
fba395ee | 548 | static int prism2_config(struct pcmcia_device *link) |
ff1d2767 JM |
549 | { |
550 | struct net_device *dev; | |
551 | struct hostap_interface *iface; | |
552 | local_info_t *local; | |
553 | int ret = 1; | |
67e0e473 | 554 | struct hostap_cs_priv *hw_priv; |
d6a574ff | 555 | unsigned long flags; |
ff1d2767 JM |
556 | |
557 | PDEBUG(DEBUG_FLOW, "prism2_config()\n"); | |
558 | ||
b0471bb7 | 559 | hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); |
b54bf94b | 560 | if (hw_priv == NULL) { |
ff1d2767 JM |
561 | ret = -ENOMEM; |
562 | goto failed; | |
563 | } | |
564 | ||
ff1d2767 | 565 | /* Look for an appropriate configuration table entry in the CIS */ |
2caff147 DB |
566 | ret = pcmcia_loop_config(link, prism2_config_check, NULL); |
567 | if (ret) { | |
b54bf94b DB |
568 | if (!ignore_cis_vcc) |
569 | printk(KERN_ERR "GetNextTuple(): No matching " | |
570 | "CIS configuration. Maybe you need the " | |
571 | "ignore_cis_vcc=1 parameter.\n"); | |
b54bf94b | 572 | goto failed; |
ff1d2767 JM |
573 | } |
574 | ||
575 | /* Need to allocate net_device before requesting IRQ handler */ | |
0cd545d6 | 576 | dev = prism2_init_local_data(&prism2_pccard_funcs, 0, |
dd2e5a15 | 577 | &link->dev); |
ff1d2767 JM |
578 | if (dev == NULL) |
579 | goto failed; | |
580 | link->priv = dev; | |
581 | ||
fbff868d JM |
582 | iface = netdev_priv(dev); |
583 | local = iface->local; | |
584 | local->hw_priv = hw_priv; | |
585 | hw_priv->link = link; | |
fbff868d | 586 | |
d6a574ff TG |
587 | /* |
588 | * Make sure the IRQ handler cannot proceed until at least | |
589 | * dev->base_addr is initialized. | |
590 | */ | |
591 | spin_lock_irqsave(&local->irq_init_lock, flags); | |
592 | ||
eb14120f DB |
593 | ret = pcmcia_request_irq(link, prism2_interrupt); |
594 | if (ret) | |
d6a574ff | 595 | goto failed_unlock; |
ff1d2767 JM |
596 | |
597 | /* | |
598 | * This actually configures the PCMCIA socket -- setting up | |
599 | * the I/O windows and the interrupt mapping, and putting the | |
600 | * card and host interface into "Memory and IO" mode. | |
601 | */ | |
2caff147 DB |
602 | ret = pcmcia_request_configuration(link, &link->conf); |
603 | if (ret) | |
d6a574ff | 604 | goto failed_unlock; |
ff1d2767 | 605 | |
eb14120f | 606 | dev->irq = link->irq; |
ff1d2767 JM |
607 | dev->base_addr = link->io.BasePort1; |
608 | ||
d6a574ff TG |
609 | spin_unlock_irqrestore(&local->irq_init_lock, flags); |
610 | ||
ff1d2767 | 611 | /* Finally, report what we've done */ |
70294b46 DB |
612 | printk(KERN_INFO "%s: index 0x%02x: ", |
613 | dev_info, link->conf.ConfigIndex); | |
614 | if (link->conf.Vpp) | |
615 | printk(", Vpp %d.%d", link->conf.Vpp / 10, | |
616 | link->conf.Vpp % 10); | |
ff1d2767 | 617 | if (link->conf.Attributes & CONF_ENABLE_IRQ) |
eb14120f | 618 | printk(", irq %d", link->irq); |
ff1d2767 JM |
619 | if (link->io.NumPorts1) |
620 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, | |
621 | link->io.BasePort1+link->io.NumPorts1-1); | |
622 | if (link->io.NumPorts2) | |
623 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, | |
624 | link->io.BasePort2+link->io.NumPorts2-1); | |
625 | printk("\n"); | |
626 | ||
ff1d2767 JM |
627 | local->shutdown = 0; |
628 | ||
629 | sandisk_enable_wireless(dev); | |
630 | ||
631 | ret = prism2_hw_config(dev, 1); | |
317b6d63 | 632 | if (!ret) |
ff1d2767 | 633 | ret = hostap_hw_ready(dev); |
317b6d63 | 634 | |
ff1d2767 JM |
635 | return ret; |
636 | ||
d6a574ff TG |
637 | failed_unlock: |
638 | spin_unlock_irqrestore(&local->irq_init_lock, flags); | |
ff1d2767 | 639 | failed: |
67e0e473 | 640 | kfree(hw_priv); |
ff1d2767 JM |
641 | prism2_release((u_long)link); |
642 | return ret; | |
643 | } | |
644 | ||
645 | ||
646 | static void prism2_release(u_long arg) | |
647 | { | |
fba395ee | 648 | struct pcmcia_device *link = (struct pcmcia_device *)arg; |
ff1d2767 JM |
649 | |
650 | PDEBUG(DEBUG_FLOW, "prism2_release\n"); | |
651 | ||
652 | if (link->priv) { | |
653 | struct net_device *dev = link->priv; | |
654 | struct hostap_interface *iface; | |
655 | ||
656 | iface = netdev_priv(dev); | |
e2d40963 | 657 | prism2_hw_shutdown(dev, 0); |
ff1d2767 JM |
658 | iface->local->shutdown = 1; |
659 | } | |
660 | ||
fba395ee | 661 | pcmcia_disable_device(link); |
ff1d2767 JM |
662 | PDEBUG(DEBUG_FLOW, "release - done\n"); |
663 | } | |
664 | ||
fba395ee | 665 | static int hostap_cs_suspend(struct pcmcia_device *link) |
98e4c28b | 666 | { |
98e4c28b DB |
667 | struct net_device *dev = (struct net_device *) link->priv; |
668 | int dev_open = 0; | |
e2d40963 | 669 | struct hostap_interface *iface = NULL; |
ff1d2767 | 670 | |
fcee7a01 JL |
671 | if (!dev) |
672 | return -ENODEV; | |
673 | ||
674 | iface = netdev_priv(dev); | |
98e4c28b | 675 | |
e2d40963 DB |
676 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); |
677 | if (iface && iface->local) | |
678 | dev_open = iface->local->num_dev_open > 0; | |
679 | if (dev_open) { | |
680 | netif_stop_queue(dev); | |
681 | netif_device_detach(dev); | |
98e4c28b | 682 | } |
e2d40963 | 683 | prism2_suspend(dev); |
98e4c28b DB |
684 | |
685 | return 0; | |
686 | } | |
687 | ||
fba395ee | 688 | static int hostap_cs_resume(struct pcmcia_device *link) |
ff1d2767 | 689 | { |
ff1d2767 | 690 | struct net_device *dev = (struct net_device *) link->priv; |
bab76198 | 691 | int dev_open = 0; |
e2d40963 DB |
692 | struct hostap_interface *iface = NULL; |
693 | ||
fcee7a01 JL |
694 | if (!dev) |
695 | return -ENODEV; | |
696 | ||
697 | iface = netdev_priv(dev); | |
bab76198 | 698 | |
98e4c28b DB |
699 | PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); |
700 | ||
e2d40963 DB |
701 | if (iface && iface->local) |
702 | dev_open = iface->local->num_dev_open > 0; | |
98e4c28b | 703 | |
e2d40963 DB |
704 | prism2_hw_shutdown(dev, 1); |
705 | prism2_hw_config(dev, dev_open ? 0 : 1); | |
706 | if (dev_open) { | |
707 | netif_device_attach(dev); | |
708 | netif_start_queue(dev); | |
bab76198 | 709 | } |
ff1d2767 | 710 | |
98e4c28b DB |
711 | return 0; |
712 | } | |
713 | ||
093853c3 HBA |
714 | static struct pcmcia_device_id hostap_cs_ids[] = { |
715 | PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), | |
716 | PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), | |
717 | PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), | |
718 | PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), | |
719 | PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), | |
46232d29 | 720 | PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x3301), |
093853c3 | 721 | PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), |
1e4adbdb | 722 | PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b), |
093853c3 HBA |
723 | PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), |
724 | PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), | |
725 | PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), | |
726 | PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), | |
727 | PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), | |
728 | PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001), | |
729 | PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), | |
fd99ddd0 | 730 | /* PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), conflict with pcnet_cs */ |
449fecca | 731 | PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), |
093853c3 HBA |
732 | PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), |
733 | PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), | |
734 | PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), | |
884d3a2b | 735 | PCMCIA_DEVICE_MANF_CARD(0x0126, 0x0002), |
25ac6c26 MJ |
736 | PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0xd601, 0x0005, "ADLINK 345 CF", |
737 | 0x2d858104), | |
40e3cad6 PR |
738 | PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "INTERSIL", |
739 | 0x74c5e40d), | |
740 | PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "Intersil", | |
741 | 0x4b801a17), | |
093853c3 HBA |
742 | PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus", |
743 | 0x7a954bd9, 0x74be00c6), | |
093853c3 HBA |
744 | PCMCIA_DEVICE_PROD_ID123( |
745 | "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02", | |
746 | 0xe6ec52ce, 0x08649af2, 0x4b74baa0), | |
747 | PCMCIA_DEVICE_PROD_ID123( | |
748 | "D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02", | |
749 | 0x71b18589, 0xb6f1b0ab, 0x4b74baa0), | |
750 | PCMCIA_DEVICE_PROD_ID123( | |
751 | "Instant Wireless ", " Network PC CARD", "Version 01.02", | |
752 | 0x11d901af, 0x6e9bd926, 0x4b74baa0), | |
753 | PCMCIA_DEVICE_PROD_ID123( | |
754 | "SMC", "SMC2632W", "Version 01.02", | |
755 | 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0), | |
1e4adbdb | 756 | PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", |
6c5b90d2 | 757 | 0x2decece3, 0x82067c18), |
093853c3 HBA |
758 | PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", |
759 | 0x54f7c49c, 0x15a75e5b), | |
760 | PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", | |
761 | 0x74c5e40d, 0xdb472a18), | |
762 | PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", | |
763 | 0x0733cc81, 0x0c52f395), | |
764 | PCMCIA_DEVICE_PROD_ID12( | |
765 | "ZoomAir 11Mbps High", "Rate wireless Networking", | |
766 | 0x273fe3db, 0x32a1eaee), | |
df8ccb9b MJ |
767 | PCMCIA_DEVICE_PROD_ID123( |
768 | "Pretec", "CompactWLAN Card 802.11b", "2.5", | |
769 | 0x1cadd3e5, 0xe697636c, 0x7a5bfcf1), | |
770 | PCMCIA_DEVICE_PROD_ID123( | |
771 | "U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02", | |
772 | 0xc7b8df9d, 0x1700d087, 0x4b74baa0), | |
01918d16 DB |
773 | PCMCIA_DEVICE_PROD_ID123( |
774 | "Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio", | |
775 | "Ver. 1.00", | |
776 | 0x5cd01705, 0x4271660f, 0x9d08ee12), | |
5d635ead MJ |
777 | PCMCIA_DEVICE_PROD_ID123( |
778 | "Wireless LAN" , "11Mbps PC Card", "Version 01.02", | |
779 | 0x4b8870ff, 0x70e946d1, 0x4b74baa0), | |
fbc87d67 PR |
780 | PCMCIA_DEVICE_PROD_ID3("HFA3863", 0x355cb092), |
781 | PCMCIA_DEVICE_PROD_ID3("ISL37100P", 0x630d52b2), | |
782 | PCMCIA_DEVICE_PROD_ID3("ISL37101P-10", 0xdd97a26b), | |
783 | PCMCIA_DEVICE_PROD_ID3("ISL37300P", 0xc9049a39), | |
093853c3 HBA |
784 | PCMCIA_DEVICE_NULL |
785 | }; | |
786 | MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids); | |
787 | ||
788 | ||
ff1d2767 JM |
789 | static struct pcmcia_driver hostap_driver = { |
790 | .drv = { | |
791 | .name = "hostap_cs", | |
792 | }, | |
15b99ac1 | 793 | .probe = hostap_cs_probe, |
cc3b4866 | 794 | .remove = prism2_detach, |
ff1d2767 | 795 | .owner = THIS_MODULE, |
093853c3 | 796 | .id_table = hostap_cs_ids, |
98e4c28b DB |
797 | .suspend = hostap_cs_suspend, |
798 | .resume = hostap_cs_resume, | |
ff1d2767 JM |
799 | }; |
800 | ||
801 | static int __init init_prism2_pccard(void) | |
802 | { | |
ff1d2767 JM |
803 | return pcmcia_register_driver(&hostap_driver); |
804 | } | |
805 | ||
806 | static void __exit exit_prism2_pccard(void) | |
807 | { | |
808 | pcmcia_unregister_driver(&hostap_driver); | |
ff1d2767 JM |
809 | } |
810 | ||
811 | ||
812 | module_init(init_prism2_pccard); | |
813 | module_exit(exit_prism2_pccard); |