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