Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /*====================================================================== |
2 | ||
3 | Aironet driver for 4500 and 4800 series cards | |
4 | ||
5 | This code is released under both the GPL version 2 and BSD licenses. | |
6 | Either license may be used. The respective licenses are found at | |
7 | the end of this file. | |
8 | ||
9 | This code was developed by Benjamin Reed <breed@users.sourceforge.net> | |
10 | including portions of which come from the Aironet PC4500 | |
11 | Developer's Reference Manual and used with permission. Copyright | |
12 | (C) 1999 Benjamin Reed. All Rights Reserved. Permission to use | |
13 | code in the Developer's manual was granted for this driver by | |
14 | Aironet. | |
15 | ||
16 | In addition this module was derived from dummy_cs. | |
17 | The initial developer of dummy_cs is David A. Hinds | |
18 | <dahinds@users.sourceforge.net>. Portions created by David A. Hinds | |
19 | are Copyright (C) 1999 David A. Hinds. All Rights Reserved. | |
20 | ||
21 | ======================================================================*/ | |
22 | ||
23 | #include <linux/config.h> | |
24 | #ifdef __IN_PCMCIA_PACKAGE__ | |
25 | #include <pcmcia/k_compat.h> | |
26 | #endif | |
27 | #include <linux/init.h> | |
28 | #include <linux/kernel.h> | |
29 | #include <linux/module.h> | |
30 | #include <linux/ptrace.h> | |
31 | #include <linux/slab.h> | |
32 | #include <linux/string.h> | |
33 | #include <linux/timer.h> | |
34 | #include <linux/netdevice.h> | |
35 | ||
1da177e4 LT |
36 | #include <pcmcia/cs_types.h> |
37 | #include <pcmcia/cs.h> | |
38 | #include <pcmcia/cistpl.h> | |
39 | #include <pcmcia/cisreg.h> | |
40 | #include <pcmcia/ds.h> | |
41 | ||
42 | #include <asm/io.h> | |
43 | #include <asm/system.h> | |
44 | ||
45 | /* | |
46 | All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If | |
47 | you do not define PCMCIA_DEBUG at all, all the debug code will be | |
48 | left out. If you compile with PCMCIA_DEBUG=0, the debug code will | |
49 | be present but disabled -- but it can then be enabled for specific | |
50 | modules at load time with a 'pc_debug=#' option to insmod. | |
51 | */ | |
52 | #ifdef PCMCIA_DEBUG | |
53 | static int pc_debug = PCMCIA_DEBUG; | |
54 | module_param(pc_debug, int, 0); | |
55 | static char *version = "$Revision: 1.2 $"; | |
56 | #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args); | |
57 | #else | |
58 | #define DEBUG(n, args...) | |
59 | #endif | |
60 | ||
61 | /*====================================================================*/ | |
62 | ||
63 | MODULE_AUTHOR("Benjamin Reed"); | |
64 | MODULE_DESCRIPTION("Support for Cisco/Aironet 802.11 wireless ethernet \ | |
65 | cards. This is the module that links the PCMCIA card \ | |
66 | with the airo module."); | |
67 | MODULE_LICENSE("Dual BSD/GPL"); | |
68 | MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards"); | |
69 | ||
70 | /*====================================================================*/ | |
71 | ||
72 | /* | |
73 | The event() function is this driver's Card Services event handler. | |
74 | It will be called by Card Services when an appropriate card status | |
75 | event is received. The config() and release() entry points are | |
76 | used to configure or release a socket, in response to card | |
77 | insertion and ejection events. They are invoked from the airo_cs | |
78 | event handler. | |
79 | */ | |
80 | ||
81 | struct net_device *init_airo_card( int, int, int, struct device * ); | |
82 | void stop_airo_card( struct net_device *, int ); | |
83 | int reset_airo_card( struct net_device * ); | |
84 | ||
85 | static void airo_config(dev_link_t *link); | |
86 | static void airo_release(dev_link_t *link); | |
87 | static int airo_event(event_t event, int priority, | |
88 | event_callback_args_t *args); | |
89 | ||
90 | /* | |
91 | The attach() and detach() entry points are used to create and destroy | |
92 | "instances" of the driver, where each instance represents everything | |
93 | needed to manage one actual PCMCIA card. | |
94 | */ | |
95 | ||
96 | static dev_link_t *airo_attach(void); | |
97 | static void airo_detach(dev_link_t *); | |
98 | ||
99 | /* | |
100 | You'll also need to prototype all the functions that will actually | |
101 | be used to talk to your device. See 'pcmem_cs' for a good example | |
102 | of a fully self-sufficient driver; the other drivers rely more or | |
103 | less on other parts of the kernel. | |
104 | */ | |
105 | ||
106 | /* | |
107 | The dev_info variable is the "key" that is used to match up this | |
108 | device driver with appropriate cards, through the card configuration | |
109 | database. | |
110 | */ | |
111 | ||
112 | static dev_info_t dev_info = "airo_cs"; | |
113 | ||
114 | /* | |
115 | A linked list of "instances" of the aironet device. Each actual | |
116 | PCMCIA card corresponds to one device instance, and is described | |
117 | by one dev_link_t structure (defined in ds.h). | |
118 | ||
119 | You may not want to use a linked list for this -- for example, the | |
120 | memory card driver uses an array of dev_link_t pointers, where minor | |
121 | device numbers are used to derive the corresponding array index. | |
122 | */ | |
123 | ||
124 | static dev_link_t *dev_list = NULL; | |
125 | ||
126 | /* | |
127 | A dev_link_t structure has fields for most things that are needed | |
128 | to keep track of a socket, but there will usually be some device | |
129 | specific information that also needs to be kept track of. The | |
130 | 'priv' pointer in a dev_link_t structure can be used to point to | |
131 | a device-specific private data structure, like this. | |
132 | ||
133 | A driver needs to provide a dev_node_t structure for each device | |
134 | on a card. In some cases, there is only one device per card (for | |
135 | example, ethernet cards, modems). In other cases, there may be | |
136 | many actual or logical devices (SCSI adapters, memory cards with | |
137 | multiple partitions). The dev_node_t structures need to be kept | |
138 | in a linked list starting at the 'dev' field of a dev_link_t | |
139 | structure. We allocate them in the card's private data structure, | |
140 | because they generally shouldn't be allocated dynamically. | |
141 | ||
142 | In this case, we also provide a flag to indicate if a device is | |
143 | "stopped" due to a power management event, or card ejection. The | |
144 | device IO routines can use a flag like this to throttle IO to a | |
145 | card that is not ready to accept it. | |
146 | */ | |
147 | ||
148 | typedef struct local_info_t { | |
149 | dev_node_t node; | |
150 | struct net_device *eth_dev; | |
151 | } local_info_t; | |
152 | ||
153 | /*====================================================================== | |
154 | ||
155 | airo_attach() creates an "instance" of the driver, allocating | |
156 | local data structures for one device. The device is registered | |
157 | with Card Services. | |
158 | ||
159 | The dev_link structure is initialized, but we don't actually | |
160 | configure the card at this point -- we wait until we receive a | |
161 | card insertion event. | |
162 | ||
163 | ======================================================================*/ | |
164 | ||
165 | static dev_link_t *airo_attach(void) | |
166 | { | |
167 | client_reg_t client_reg; | |
168 | dev_link_t *link; | |
169 | local_info_t *local; | |
170 | int ret; | |
171 | ||
172 | DEBUG(0, "airo_attach()\n"); | |
173 | ||
174 | /* Initialize the dev_link_t structure */ | |
175 | link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); | |
176 | if (!link) { | |
177 | printk(KERN_ERR "airo_cs: no memory for new device\n"); | |
178 | return NULL; | |
179 | } | |
180 | memset(link, 0, sizeof(struct dev_link_t)); | |
181 | ||
182 | /* Interrupt setup */ | |
183 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; | |
184 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | |
185 | link->irq.Handler = NULL; | |
186 | ||
187 | /* | |
188 | General socket configuration defaults can go here. In this | |
189 | client, we assume very little, and rely on the CIS for almost | |
190 | everything. In most clients, many details (i.e., number, sizes, | |
191 | and attributes of IO windows) are fixed by the nature of the | |
192 | device, and can be hard-wired here. | |
193 | */ | |
194 | link->conf.Attributes = 0; | |
195 | link->conf.Vcc = 50; | |
196 | link->conf.IntType = INT_MEMORY_AND_IO; | |
197 | ||
198 | /* Allocate space for private device-specific data */ | |
199 | local = kmalloc(sizeof(local_info_t), GFP_KERNEL); | |
200 | if (!local) { | |
201 | printk(KERN_ERR "airo_cs: no memory for new device\n"); | |
202 | kfree (link); | |
203 | return NULL; | |
204 | } | |
205 | memset(local, 0, sizeof(local_info_t)); | |
206 | link->priv = local; | |
207 | ||
208 | /* Register with Card Services */ | |
209 | link->next = dev_list; | |
210 | dev_list = link; | |
211 | client_reg.dev_info = &dev_info; | |
1da177e4 LT |
212 | client_reg.Version = 0x0210; |
213 | client_reg.event_callback_args.client_data = link; | |
214 | ret = pcmcia_register_client(&link->handle, &client_reg); | |
215 | if (ret != 0) { | |
216 | cs_error(link->handle, RegisterClient, ret); | |
217 | airo_detach(link); | |
218 | return NULL; | |
219 | } | |
220 | ||
221 | return link; | |
222 | } /* airo_attach */ | |
223 | ||
224 | /*====================================================================== | |
225 | ||
226 | This deletes a driver "instance". The device is de-registered | |
227 | with Card Services. If it has been released, all local data | |
228 | structures are freed. Otherwise, the structures will be freed | |
229 | when the device is released. | |
230 | ||
231 | ======================================================================*/ | |
232 | ||
233 | static void airo_detach(dev_link_t *link) | |
234 | { | |
235 | dev_link_t **linkp; | |
236 | ||
237 | DEBUG(0, "airo_detach(0x%p)\n", link); | |
238 | ||
239 | /* Locate device structure */ | |
240 | for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) | |
241 | if (*linkp == link) break; | |
242 | if (*linkp == NULL) | |
243 | return; | |
244 | ||
245 | if (link->state & DEV_CONFIG) | |
246 | airo_release(link); | |
247 | ||
248 | if ( ((local_info_t*)link->priv)->eth_dev ) { | |
249 | stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); | |
250 | } | |
251 | ((local_info_t*)link->priv)->eth_dev = NULL; | |
252 | ||
253 | /* Break the link with Card Services */ | |
254 | if (link->handle) | |
255 | pcmcia_deregister_client(link->handle); | |
256 | ||
257 | ||
258 | ||
259 | /* Unlink device structure, free pieces */ | |
260 | *linkp = link->next; | |
b4558ea9 | 261 | kfree(link->priv); |
1da177e4 LT |
262 | kfree(link); |
263 | ||
264 | } /* airo_detach */ | |
265 | ||
266 | /*====================================================================== | |
267 | ||
268 | airo_config() is scheduled to run after a CARD_INSERTION event | |
269 | is received, to configure the PCMCIA socket, and to make the | |
270 | device available to the system. | |
271 | ||
272 | ======================================================================*/ | |
273 | ||
274 | #define CS_CHECK(fn, ret) \ | |
275 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | |
276 | ||
277 | static void airo_config(dev_link_t *link) | |
278 | { | |
279 | client_handle_t handle; | |
280 | tuple_t tuple; | |
281 | cisparse_t parse; | |
282 | local_info_t *dev; | |
283 | int last_fn, last_ret; | |
284 | u_char buf[64]; | |
285 | win_req_t req; | |
286 | memreq_t map; | |
287 | ||
288 | handle = link->handle; | |
289 | dev = link->priv; | |
290 | ||
291 | DEBUG(0, "airo_config(0x%p)\n", link); | |
292 | ||
293 | /* | |
294 | This reads the card's CONFIG tuple to find its configuration | |
295 | registers. | |
296 | */ | |
297 | tuple.DesiredTuple = CISTPL_CONFIG; | |
298 | tuple.Attributes = 0; | |
299 | tuple.TupleData = buf; | |
300 | tuple.TupleDataMax = sizeof(buf); | |
301 | tuple.TupleOffset = 0; | |
302 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | |
303 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | |
304 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | |
305 | link->conf.ConfigBase = parse.config.base; | |
306 | link->conf.Present = parse.config.rmask[0]; | |
307 | ||
308 | /* Configure card */ | |
309 | link->state |= DEV_CONFIG; | |
310 | ||
311 | /* | |
312 | In this loop, we scan the CIS for configuration table entries, | |
313 | each of which describes a valid card configuration, including | |
314 | voltage, IO window, memory window, and interrupt settings. | |
315 | ||
316 | We make no assumptions about the card to be configured: we use | |
317 | just the information available in the CIS. In an ideal world, | |
318 | this would work for any PCMCIA card, but it requires a complete | |
319 | and accurate CIS. In practice, a driver usually "knows" most of | |
320 | these things without consulting the CIS, and most client drivers | |
321 | will only use the CIS to fill in implementation-defined details. | |
322 | */ | |
323 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | |
324 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | |
325 | while (1) { | |
326 | cistpl_cftable_entry_t dflt = { 0 }; | |
327 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | |
328 | if (pcmcia_get_tuple_data(handle, &tuple) != 0 || | |
329 | pcmcia_parse_tuple(handle, &tuple, &parse) != 0) | |
330 | goto next_entry; | |
331 | ||
332 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | |
333 | if (cfg->index == 0) goto next_entry; | |
334 | link->conf.ConfigIndex = cfg->index; | |
335 | ||
336 | /* Does this card need audio output? */ | |
337 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | |
338 | link->conf.Attributes |= CONF_ENABLE_SPKR; | |
339 | link->conf.Status = CCSR_AUDIO_ENA; | |
340 | } | |
341 | ||
342 | /* Use power settings for Vcc and Vpp if present */ | |
343 | /* Note that the CIS values need to be rescaled */ | |
344 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) | |
345 | link->conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000; | |
346 | else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) | |
347 | link->conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000; | |
348 | ||
349 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | |
350 | link->conf.Vpp1 = link->conf.Vpp2 = | |
351 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | |
352 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | |
353 | link->conf.Vpp1 = link->conf.Vpp2 = | |
354 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | |
355 | ||
356 | /* Do we need to allocate an interrupt? */ | |
357 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | |
358 | link->conf.Attributes |= CONF_ENABLE_IRQ; | |
359 | ||
360 | /* IO window settings */ | |
361 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | |
362 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | |
363 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | |
364 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | |
365 | if (!(io->flags & CISTPL_IO_8BIT)) | |
366 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | |
367 | if (!(io->flags & CISTPL_IO_16BIT)) | |
368 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | |
369 | link->io.BasePort1 = io->win[0].base; | |
370 | link->io.NumPorts1 = io->win[0].len; | |
371 | if (io->nwin > 1) { | |
372 | link->io.Attributes2 = link->io.Attributes1; | |
373 | link->io.BasePort2 = io->win[1].base; | |
374 | link->io.NumPorts2 = io->win[1].len; | |
375 | } | |
376 | } | |
377 | ||
378 | /* This reserves IO space but doesn't actually enable it */ | |
379 | if (pcmcia_request_io(link->handle, &link->io) != 0) | |
380 | goto next_entry; | |
381 | ||
382 | /* | |
383 | Now set up a common memory window, if needed. There is room | |
384 | in the dev_link_t structure for one memory window handle, | |
385 | but if the base addresses need to be saved, or if multiple | |
386 | windows are needed, the info should go in the private data | |
387 | structure for this device. | |
388 | ||
389 | Note that the memory window base is a physical address, and | |
390 | needs to be mapped to virtual space with ioremap() before it | |
391 | is used. | |
392 | */ | |
393 | if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { | |
394 | cistpl_mem_t *mem = | |
395 | (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; | |
396 | req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; | |
397 | req.Base = mem->win[0].host_addr; | |
398 | req.Size = mem->win[0].len; | |
399 | req.AccessSpeed = 0; | |
400 | if (pcmcia_request_window(&link->handle, &req, &link->win) != 0) | |
401 | goto next_entry; | |
402 | map.Page = 0; map.CardOffset = mem->win[0].card_addr; | |
403 | if (pcmcia_map_mem_page(link->win, &map) != 0) | |
404 | goto next_entry; | |
405 | } | |
406 | /* If we got this far, we're cool! */ | |
407 | break; | |
408 | ||
409 | next_entry: | |
410 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); | |
411 | } | |
412 | ||
413 | /* | |
414 | Allocate an interrupt line. Note that this does not assign a | |
415 | handler to the interrupt, unless the 'Handler' member of the | |
416 | irq structure is initialized. | |
417 | */ | |
418 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | |
419 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); | |
420 | ||
421 | /* | |
422 | This actually configures the PCMCIA socket -- setting up | |
423 | the I/O windows and the interrupt mapping, and putting the | |
424 | card and host interface into "Memory and IO" mode. | |
425 | */ | |
426 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); | |
427 | ((local_info_t*)link->priv)->eth_dev = | |
428 | init_airo_card( link->irq.AssignedIRQ, | |
429 | link->io.BasePort1, 1, &handle_to_dev(handle) ); | |
430 | if (!((local_info_t*)link->priv)->eth_dev) goto cs_failed; | |
431 | ||
432 | /* | |
433 | At this point, the dev_node_t structure(s) need to be | |
434 | initialized and arranged in a linked list at link->dev. | |
435 | */ | |
436 | strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); | |
437 | dev->node.major = dev->node.minor = 0; | |
438 | link->dev = &dev->node; | |
439 | ||
440 | /* Finally, report what we've done */ | |
441 | printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", | |
442 | dev->node.dev_name, link->conf.ConfigIndex, | |
443 | link->conf.Vcc/10, link->conf.Vcc%10); | |
444 | if (link->conf.Vpp1) | |
445 | printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); | |
446 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | |
447 | printk(", irq %d", link->irq.AssignedIRQ); | |
448 | if (link->io.NumPorts1) | |
449 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, | |
450 | link->io.BasePort1+link->io.NumPorts1-1); | |
451 | if (link->io.NumPorts2) | |
452 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, | |
453 | link->io.BasePort2+link->io.NumPorts2-1); | |
454 | if (link->win) | |
455 | printk(", mem 0x%06lx-0x%06lx", req.Base, | |
456 | req.Base+req.Size-1); | |
457 | printk("\n"); | |
458 | ||
459 | link->state &= ~DEV_CONFIG_PENDING; | |
460 | return; | |
461 | ||
462 | cs_failed: | |
463 | cs_error(link->handle, last_fn, last_ret); | |
464 | airo_release(link); | |
465 | ||
466 | } /* airo_config */ | |
467 | ||
468 | /*====================================================================== | |
469 | ||
470 | After a card is removed, airo_release() will unregister the | |
471 | device, and release the PCMCIA configuration. If the device is | |
472 | still open, this will be postponed until it is closed. | |
473 | ||
474 | ======================================================================*/ | |
475 | ||
476 | static void airo_release(dev_link_t *link) | |
477 | { | |
478 | DEBUG(0, "airo_release(0x%p)\n", link); | |
479 | ||
480 | /* Unlink the device chain */ | |
481 | link->dev = NULL; | |
482 | ||
483 | /* | |
484 | In a normal driver, additional code may be needed to release | |
485 | other kernel data structures associated with this device. | |
486 | */ | |
487 | ||
488 | /* Don't bother checking to see if these succeed or not */ | |
489 | if (link->win) | |
490 | pcmcia_release_window(link->win); | |
491 | pcmcia_release_configuration(link->handle); | |
492 | if (link->io.NumPorts1) | |
493 | pcmcia_release_io(link->handle, &link->io); | |
494 | if (link->irq.AssignedIRQ) | |
495 | pcmcia_release_irq(link->handle, &link->irq); | |
496 | link->state &= ~DEV_CONFIG; | |
497 | } | |
498 | ||
499 | /*====================================================================== | |
500 | ||
501 | The card status event handler. Mostly, this schedules other | |
502 | stuff to run after an event is received. | |
503 | ||
504 | When a CARD_REMOVAL event is received, we immediately set a | |
505 | private flag to block future accesses to this device. All the | |
506 | functions that actually access the device should check this flag | |
507 | to make sure the card is still present. | |
508 | ||
509 | ======================================================================*/ | |
510 | ||
511 | static int airo_event(event_t event, int priority, | |
512 | event_callback_args_t *args) | |
513 | { | |
514 | dev_link_t *link = args->client_data; | |
515 | local_info_t *local = link->priv; | |
516 | ||
517 | DEBUG(1, "airo_event(0x%06x)\n", event); | |
518 | ||
519 | switch (event) { | |
520 | case CS_EVENT_CARD_REMOVAL: | |
521 | link->state &= ~DEV_PRESENT; | |
522 | if (link->state & DEV_CONFIG) { | |
523 | netif_device_detach(local->eth_dev); | |
524 | airo_release(link); | |
525 | } | |
526 | break; | |
527 | case CS_EVENT_CARD_INSERTION: | |
528 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | |
529 | airo_config(link); | |
530 | break; | |
531 | case CS_EVENT_PM_SUSPEND: | |
532 | link->state |= DEV_SUSPEND; | |
533 | /* Fall through... */ | |
534 | case CS_EVENT_RESET_PHYSICAL: | |
535 | if (link->state & DEV_CONFIG) { | |
536 | netif_device_detach(local->eth_dev); | |
537 | pcmcia_release_configuration(link->handle); | |
538 | } | |
539 | break; | |
540 | case CS_EVENT_PM_RESUME: | |
541 | link->state &= ~DEV_SUSPEND; | |
542 | /* Fall through... */ | |
543 | case CS_EVENT_CARD_RESET: | |
544 | if (link->state & DEV_CONFIG) { | |
545 | pcmcia_request_configuration(link->handle, &link->conf); | |
546 | reset_airo_card(local->eth_dev); | |
547 | netif_device_attach(local->eth_dev); | |
548 | } | |
549 | break; | |
550 | } | |
551 | return 0; | |
552 | } /* airo_event */ | |
553 | ||
7018d06d DB |
554 | static struct pcmcia_device_id airo_ids[] = { |
555 | PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a), | |
556 | PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005), | |
557 | PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0007), | |
558 | PCMCIA_DEVICE_MANF_CARD(0x0105, 0x0007), | |
559 | PCMCIA_DEVICE_NULL, | |
560 | }; | |
561 | MODULE_DEVICE_TABLE(pcmcia, airo_ids); | |
562 | ||
1da177e4 LT |
563 | static struct pcmcia_driver airo_driver = { |
564 | .owner = THIS_MODULE, | |
565 | .drv = { | |
566 | .name = "airo_cs", | |
567 | }, | |
568 | .attach = airo_attach, | |
1e212f36 | 569 | .event = airo_event, |
1da177e4 | 570 | .detach = airo_detach, |
7018d06d | 571 | .id_table = airo_ids, |
1da177e4 LT |
572 | }; |
573 | ||
574 | static int airo_cs_init(void) | |
575 | { | |
576 | return pcmcia_register_driver(&airo_driver); | |
577 | } | |
578 | ||
579 | static void airo_cs_cleanup(void) | |
580 | { | |
581 | pcmcia_unregister_driver(&airo_driver); | |
582 | BUG_ON(dev_list != NULL); | |
583 | } | |
584 | ||
585 | /* | |
586 | This program is free software; you can redistribute it and/or | |
587 | modify it under the terms of the GNU General Public License | |
588 | as published by the Free Software Foundation; either version 2 | |
589 | of the License, or (at your option) any later version. | |
590 | ||
591 | This program is distributed in the hope that it will be useful, | |
592 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
593 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
594 | GNU General Public License for more details. | |
595 | ||
596 | In addition: | |
597 | ||
598 | Redistribution and use in source and binary forms, with or without | |
599 | modification, are permitted provided that the following conditions | |
600 | are met: | |
601 | ||
602 | 1. Redistributions of source code must retain the above copyright | |
603 | notice, this list of conditions and the following disclaimer. | |
604 | 2. Redistributions in binary form must reproduce the above copyright | |
605 | notice, this list of conditions and the following disclaimer in the | |
606 | documentation and/or other materials provided with the distribution. | |
607 | 3. The name of the author may not be used to endorse or promote | |
608 | products derived from this software without specific prior written | |
609 | permission. | |
610 | ||
611 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
612 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
613 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
614 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
615 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
616 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
617 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
618 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
619 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
620 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
621 | POSSIBILITY OF SUCH DAMAGE. | |
622 | */ | |
623 | ||
624 | module_init(airo_cs_init); | |
625 | module_exit(airo_cs_cleanup); |