2 * Driver for 802.11b cards using RAM-loadable Symbol firmware, such as
3 * Symbol Wireless Networker LA4137, CompactFlash cards by Socket
4 * Communications and Intel PRO/Wireless 2011B.
6 * The driver implements Symbol firmware download. The rest is handled
7 * in hermes.c and orinoco.c.
9 * Utilities for downloading the Symbol firmware are available at
10 * http://sourceforge.net/projects/orinoco/
12 * Copyright (C) 2002-2005 Pavel Roskin <proski@gnu.org>
13 * Portions based on orinoco_cs.c:
14 * Copyright (C) David Gibson, Linuxcare Australia
15 * Portions based on Spectrum24tDnld.c from original spectrum24 driver:
16 * Copyright (C) Symbol Technologies.
18 * See copyright notice in file orinoco.c.
21 #define DRIVER_NAME "spectrum_cs"
22 #define PFX DRIVER_NAME ": "
24 #include <linux/module.h>
25 #include <linux/kernel.h>
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/firmware.h>
29 #include <pcmcia/cs_types.h>
30 #include <pcmcia/cs.h>
31 #include <pcmcia/cistpl.h>
32 #include <pcmcia/cisreg.h>
33 #include <pcmcia/ds.h>
37 static const char primary_fw_name
[] = "symbol_sp24t_prim_fw";
38 static const char secondary_fw_name
[] = "symbol_sp24t_sec_fw";
40 /********************************************************************/
42 /********************************************************************/
44 MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>");
45 MODULE_DESCRIPTION("Driver for Symbol Spectrum24 Trilogy cards with firmware downloader");
46 MODULE_LICENSE("Dual MPL/GPL");
48 /* Module parameters */
50 /* Some D-Link cards have buggy CIS. They do work at 5v properly, but
51 * don't have any CIS entry for it. This workaround it... */
52 static int ignore_cis_vcc
; /* = 0 */
53 module_param(ignore_cis_vcc
, int, 0);
54 MODULE_PARM_DESC(ignore_cis_vcc
, "Allow voltage mismatch between card and socket");
56 /********************************************************************/
58 /********************************************************************/
60 /* PCMCIA specific device information (goes in the card field of
61 * struct orinoco_private */
62 struct orinoco_pccard
{
63 struct pcmcia_device
*p_dev
;
67 /********************************************************************/
68 /* Function prototypes */
69 /********************************************************************/
71 static int spectrum_cs_config(struct pcmcia_device
*link
);
72 static void spectrum_cs_release(struct pcmcia_device
*link
);
74 /********************************************************************/
75 /* Firmware downloader */
76 /********************************************************************/
78 /* Position of PDA in the adapter memory */
79 #define EEPROM_ADDR 0x3000
80 #define EEPROM_LEN 0x200
81 #define PDA_OFFSET 0x100
83 #define PDA_ADDR (EEPROM_ADDR + PDA_OFFSET)
84 #define PDA_WORDS ((EEPROM_LEN - PDA_OFFSET) / 2)
86 /* Constants for the CISREG_CCSR register */
87 #define HCR_RUN 0x07 /* run firmware after reset */
88 #define HCR_IDLE 0x0E /* don't run firmware after reset */
89 #define HCR_MEM16 0x10 /* memory width bit, should be preserved */
92 * AUX port access. To unlock the AUX port write the access keys to the
93 * PARAM0-2 registers, then write HERMES_AUX_ENABLE to the HERMES_CONTROL
94 * register. Then read it and make sure it's HERMES_AUX_ENABLED.
96 #define HERMES_AUX_ENABLE 0x8000 /* Enable auxiliary port access */
97 #define HERMES_AUX_DISABLE 0x4000 /* Disable to auxiliary port access */
98 #define HERMES_AUX_ENABLED 0xC000 /* Auxiliary port is open */
100 #define HERMES_AUX_PW0 0xFE01
101 #define HERMES_AUX_PW1 0xDC23
102 #define HERMES_AUX_PW2 0xBA45
105 #define PDI_END 0x00000000 /* End of PDA */
106 #define BLOCK_END 0xFFFFFFFF /* Last image block */
107 #define TEXT_END 0x1A /* End of text header */
110 * The following structures have little-endian fields denoted by
111 * the leading underscore. Don't access them directly - use inline
112 * functions defined below.
116 * The binary image to be downloaded consists of series of data blocks.
117 * Each block has the following structure.
120 __le32 addr
; /* adapter address where to write the block */
121 __le16 len
; /* length of the data only, in bytes */
122 char data
[0]; /* data to be written */
123 } __attribute__ ((packed
));
126 * Plug Data References are located in in the image after the last data
127 * block. They refer to areas in the adapter memory where the plug data
128 * items with matching ID should be written.
131 __le32 id
; /* record ID */
132 __le32 addr
; /* adapter address where to write the data */
133 __le32 len
; /* expected length of the data, in bytes */
134 char next
[0]; /* next PDR starts here */
135 } __attribute__ ((packed
));
139 * Plug Data Items are located in the EEPROM read from the adapter by
140 * primary firmware. They refer to the device-specific data that should
141 * be plugged into the secondary firmware.
144 __le16 len
; /* length of ID and data, in words */
145 __le16 id
; /* record ID */
146 char data
[0]; /* plug data */
147 } __attribute__ ((packed
));
150 /* Functions for access to little-endian data */
152 dblock_addr(const struct dblock
*blk
)
154 return le32_to_cpu(blk
->addr
);
158 dblock_len(const struct dblock
*blk
)
160 return le16_to_cpu(blk
->len
);
164 pdr_id(const struct pdr
*pdr
)
166 return le32_to_cpu(pdr
->id
);
170 pdr_addr(const struct pdr
*pdr
)
172 return le32_to_cpu(pdr
->addr
);
176 pdr_len(const struct pdr
*pdr
)
178 return le32_to_cpu(pdr
->len
);
182 pdi_id(const struct pdi
*pdi
)
184 return le16_to_cpu(pdi
->id
);
187 /* Return length of the data only, in bytes */
189 pdi_len(const struct pdi
*pdi
)
191 return 2 * (le16_to_cpu(pdi
->len
) - 1);
195 /* Set address of the auxiliary port */
197 spectrum_aux_setaddr(hermes_t
*hw
, u32 addr
)
199 hermes_write_reg(hw
, HERMES_AUXPAGE
, (u16
) (addr
>> 7));
200 hermes_write_reg(hw
, HERMES_AUXOFFSET
, (u16
) (addr
& 0x7F));
204 /* Open access to the auxiliary port */
206 spectrum_aux_open(hermes_t
*hw
)
211 if (hermes_read_reg(hw
, HERMES_CONTROL
) == HERMES_AUX_ENABLED
)
214 hermes_write_reg(hw
, HERMES_PARAM0
, HERMES_AUX_PW0
);
215 hermes_write_reg(hw
, HERMES_PARAM1
, HERMES_AUX_PW1
);
216 hermes_write_reg(hw
, HERMES_PARAM2
, HERMES_AUX_PW2
);
217 hermes_write_reg(hw
, HERMES_CONTROL
, HERMES_AUX_ENABLE
);
219 for (i
= 0; i
< 20; i
++) {
221 if (hermes_read_reg(hw
, HERMES_CONTROL
) ==
230 #define CS_CHECK(fn, ret) \
231 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
234 * Reset the card using configuration registers COR and CCSR.
235 * If IDLE is 1, stop the firmware, so that it can be safely rewritten.
238 spectrum_reset(struct pcmcia_device
*link
, int idle
)
240 int last_ret
, last_fn
;
244 /* Doing it if hardware is gone is guaranteed crash */
245 if (!pcmcia_dev_present(link
))
248 /* Save original COR value */
250 reg
.Action
= CS_READ
;
251 reg
.Offset
= CISREG_COR
;
252 CS_CHECK(AccessConfigurationRegister
,
253 pcmcia_access_configuration_register(link
, ®
));
254 save_cor
= reg
.Value
;
256 /* Soft-Reset card */
257 reg
.Action
= CS_WRITE
;
258 reg
.Offset
= CISREG_COR
;
259 reg
.Value
= (save_cor
| COR_SOFT_RESET
);
260 CS_CHECK(AccessConfigurationRegister
,
261 pcmcia_access_configuration_register(link
, ®
));
265 reg
.Action
= CS_READ
;
266 reg
.Offset
= CISREG_CCSR
;
267 CS_CHECK(AccessConfigurationRegister
,
268 pcmcia_access_configuration_register(link
, ®
));
271 * Start or stop the firmware. Memory width bit should be
272 * preserved from the value we've just read.
274 reg
.Action
= CS_WRITE
;
275 reg
.Offset
= CISREG_CCSR
;
276 reg
.Value
= (idle
? HCR_IDLE
: HCR_RUN
) | (reg
.Value
& HCR_MEM16
);
277 CS_CHECK(AccessConfigurationRegister
,
278 pcmcia_access_configuration_register(link
, ®
));
281 /* Restore original COR configuration index */
282 reg
.Action
= CS_WRITE
;
283 reg
.Offset
= CISREG_COR
;
284 reg
.Value
= (save_cor
& ~COR_SOFT_RESET
);
285 CS_CHECK(AccessConfigurationRegister
,
286 pcmcia_access_configuration_register(link
, ®
));
291 cs_error(link
, last_fn
, last_ret
);
297 * Scan PDR for the record with the specified RECORD_ID.
298 * If it's not found, return NULL.
301 spectrum_find_pdr(struct pdr
*first_pdr
, u32 record_id
)
303 struct pdr
*pdr
= first_pdr
;
305 while (pdr_id(pdr
) != PDI_END
) {
307 * PDR area is currently not terminated by PDI_END.
308 * It's followed by CRC records, which have the type
309 * field where PDR has length. The type can be 0 or 1.
311 if (pdr_len(pdr
) < 2)
314 /* If the record ID matches, we are done */
315 if (pdr_id(pdr
) == record_id
)
318 pdr
= (struct pdr
*) pdr
->next
;
324 /* Process one Plug Data Item - find corresponding PDR and plug it */
326 spectrum_plug_pdi(hermes_t
*hw
, struct pdr
*first_pdr
, struct pdi
*pdi
)
330 /* Find the PDI corresponding to this PDR */
331 pdr
= spectrum_find_pdr(first_pdr
, pdi_id(pdi
));
333 /* No match is found, safe to ignore */
337 /* Lengths of the data in PDI and PDR must match */
338 if (pdi_len(pdi
) != pdr_len(pdr
))
341 /* do the actual plugging */
342 spectrum_aux_setaddr(hw
, pdr_addr(pdr
));
343 hermes_write_bytes(hw
, HERMES_AUXDATA
, pdi
->data
, pdi_len(pdi
));
349 /* Read PDA from the adapter */
351 spectrum_read_pda(hermes_t
*hw
, __le16
*pda
, int pda_len
)
356 /* Issue command to read EEPROM */
357 ret
= hermes_docmd_wait(hw
, HERMES_CMD_READMIF
, 0, NULL
);
361 /* Open auxiliary port */
362 ret
= spectrum_aux_open(hw
);
366 /* read PDA from EEPROM */
367 spectrum_aux_setaddr(hw
, PDA_ADDR
);
368 hermes_read_words(hw
, HERMES_AUXDATA
, pda
, pda_len
/ 2);
370 /* Check PDA length */
371 pda_size
= le16_to_cpu(pda
[0]);
372 if (pda_size
> pda_len
)
379 /* Parse PDA and write the records into the adapter */
381 spectrum_apply_pda(hermes_t
*hw
, const struct dblock
*first_block
,
386 struct pdr
*first_pdr
;
387 const struct dblock
*blk
= first_block
;
389 /* Skip all blocks to locate Plug Data References */
390 while (dblock_addr(blk
) != BLOCK_END
)
391 blk
= (struct dblock
*) &blk
->data
[dblock_len(blk
)];
393 first_pdr
= (struct pdr
*) blk
;
395 /* Go through every PDI and plug them into the adapter */
396 pdi
= (struct pdi
*) (pda
+ 2);
397 while (pdi_id(pdi
) != PDI_END
) {
398 ret
= spectrum_plug_pdi(hw
, first_pdr
, pdi
);
402 /* Increment to the next PDI */
403 pdi
= (struct pdi
*) &pdi
->data
[pdi_len(pdi
)];
409 /* Load firmware blocks into the adapter */
411 spectrum_load_blocks(hermes_t
*hw
, const struct dblock
*first_block
)
413 const struct dblock
*blk
;
418 blkaddr
= dblock_addr(blk
);
419 blklen
= dblock_len(blk
);
421 while (dblock_addr(blk
) != BLOCK_END
) {
422 spectrum_aux_setaddr(hw
, blkaddr
);
423 hermes_write_bytes(hw
, HERMES_AUXDATA
, blk
->data
,
426 blk
= (struct dblock
*) &blk
->data
[blklen
];
427 blkaddr
= dblock_addr(blk
);
428 blklen
= dblock_len(blk
);
435 * Process a firmware image - stop the card, load the firmware, reset
436 * the card and make sure it responds. For the secondary firmware take
437 * care of the PDA - read it and then write it on top of the firmware.
440 spectrum_dl_image(hermes_t
*hw
, struct pcmcia_device
*link
,
441 const unsigned char *image
, int secondary
)
444 const unsigned char *ptr
;
445 const struct dblock
*first_block
;
447 /* Plug Data Area (PDA) */
448 __le16 pda
[PDA_WORDS
];
450 /* Binary block begins after the 0x1A marker */
452 while (*ptr
++ != TEXT_END
);
453 first_block
= (const struct dblock
*) ptr
;
457 ret
= spectrum_read_pda(hw
, pda
, sizeof(pda
));
462 /* Stop the firmware, so that it can be safely rewritten */
463 ret
= spectrum_reset(link
, 1);
467 /* Program the adapter with new firmware */
468 ret
= spectrum_load_blocks(hw
, first_block
);
472 /* Write the PDA to the adapter */
474 ret
= spectrum_apply_pda(hw
, first_block
, pda
);
479 /* Run the firmware */
480 ret
= spectrum_reset(link
, 0);
484 /* Reset hermes chip and make sure it responds */
485 ret
= hermes_init(hw
);
487 /* hermes_reset() should return 0 with the secondary firmware */
488 if (secondary
&& ret
!= 0)
491 /* And this should work with any firmware */
492 if (!hermes_present(hw
))
500 * Download the firmware into the card, this also does a PCMCIA soft
501 * reset on the card, to make sure it's in a sane state.
504 spectrum_dl_firmware(hermes_t
*hw
, struct pcmcia_device
*link
)
507 const struct firmware
*fw_entry
;
509 if (request_firmware(&fw_entry
, primary_fw_name
,
510 &handle_to_dev(link
)) != 0) {
511 printk(KERN_ERR PFX
"Cannot find firmware: %s\n",
516 /* Load primary firmware */
517 ret
= spectrum_dl_image(hw
, link
, fw_entry
->data
, 0);
518 release_firmware(fw_entry
);
520 printk(KERN_ERR PFX
"Primary firmware download failed\n");
524 if (request_firmware(&fw_entry
, secondary_fw_name
,
525 &handle_to_dev(link
)) != 0) {
526 printk(KERN_ERR PFX
"Cannot find firmware: %s\n",
531 /* Load secondary firmware */
532 ret
= spectrum_dl_image(hw
, link
, fw_entry
->data
, 1);
533 release_firmware(fw_entry
);
535 printk(KERN_ERR PFX
"Secondary firmware download failed\n");
541 /********************************************************************/
543 /********************************************************************/
546 spectrum_cs_hard_reset(struct orinoco_private
*priv
)
548 struct orinoco_pccard
*card
= priv
->card
;
549 struct pcmcia_device
*link
= card
->p_dev
;
552 if (!hermes_present(&priv
->hw
)) {
553 /* The firmware needs to be reloaded */
554 if (spectrum_dl_firmware(&priv
->hw
, link
) != 0) {
555 printk(KERN_ERR PFX
"Firmware download failed\n");
559 /* Soft reset using COR and HCR */
560 spectrum_reset(link
, 0);
566 /********************************************************************/
568 /********************************************************************/
571 * This creates an "instance" of the driver, allocating local data
572 * structures for one device. The device is registered with Card
575 * The dev_link structure is initialized, but we don't actually
576 * configure the card at this point -- we wait until we receive a card
577 * insertion event. */
579 spectrum_cs_probe(struct pcmcia_device
*link
)
581 struct net_device
*dev
;
582 struct orinoco_private
*priv
;
583 struct orinoco_pccard
*card
;
585 dev
= alloc_orinocodev(sizeof(*card
), spectrum_cs_hard_reset
);
588 priv
= netdev_priv(dev
);
591 /* Link both structures together */
595 /* Interrupt setup */
596 link
->irq
.Attributes
= IRQ_TYPE_EXCLUSIVE
| IRQ_HANDLE_PRESENT
;
597 link
->irq
.IRQInfo1
= IRQ_LEVEL_ID
;
598 link
->irq
.Handler
= orinoco_interrupt
;
599 link
->irq
.Instance
= dev
;
601 /* General socket configuration defaults can go here. In this
602 * client, we assume very little, and rely on the CIS for
603 * almost everything. In most clients, many details (i.e.,
604 * number, sizes, and attributes of IO windows) are fixed by
605 * the nature of the device, and can be hard-wired here. */
606 link
->conf
.Attributes
= 0;
607 link
->conf
.IntType
= INT_MEMORY_AND_IO
;
609 return spectrum_cs_config(link
);
610 } /* spectrum_cs_attach */
613 * This deletes a driver "instance". The device is de-registered with
614 * Card Services. If it has been released, all local data structures
615 * are freed. Otherwise, the structures will be freed when the device
618 static void spectrum_cs_detach(struct pcmcia_device
*link
)
620 struct net_device
*dev
= link
->priv
;
623 unregister_netdev(dev
);
625 spectrum_cs_release(link
);
627 free_orinocodev(dev
);
628 } /* spectrum_cs_detach */
631 * spectrum_cs_config() is scheduled to run after a CARD_INSERTION
632 * event is received, to configure the PCMCIA socket, and to make the
633 * device available to the system.
636 struct spectrum_cs_config_data
{
640 static int spectrum_cs_config_check(struct pcmcia_device
*p_dev
,
641 cistpl_cftable_entry_t
*cfg
,
642 cistpl_cftable_entry_t
*dflt
,
645 struct spectrum_cs_config_data
*cfg_mem
= priv_data
;
650 /* Use power settings for Vcc and Vpp if present */
651 /* Note that the CIS values need to be rescaled */
652 if (cfg
->vcc
.present
& (1 << CISTPL_POWER_VNOM
)) {
653 if (cfg_mem
->conf
.Vcc
!= cfg
->vcc
.param
[CISTPL_POWER_VNOM
] / 10000) {
654 DEBUG(2, "spectrum_cs_config: Vcc mismatch (cfg_mem->conf.Vcc = %d, CIS = %d)\n", cfg_mem
->conf
.Vcc
, cfg
->vcc
.param
[CISTPL_POWER_VNOM
] / 10000);
658 } else if (dflt
->vcc
.present
& (1 << CISTPL_POWER_VNOM
)) {
659 if (cfg_mem
->conf
.Vcc
!= dflt
->vcc
.param
[CISTPL_POWER_VNOM
] / 10000) {
660 DEBUG(2, "spectrum_cs_config: Vcc mismatch (cfg_mem->conf.Vcc = %d, CIS = %d)\n", cfg_mem
->conf
.Vcc
, dflt
->vcc
.param
[CISTPL_POWER_VNOM
] / 10000);
666 if (cfg
->vpp1
.present
& (1 << CISTPL_POWER_VNOM
))
668 cfg
->vpp1
.param
[CISTPL_POWER_VNOM
] / 10000;
669 else if (dflt
->vpp1
.present
& (1 << CISTPL_POWER_VNOM
))
671 dflt
->vpp1
.param
[CISTPL_POWER_VNOM
] / 10000;
673 /* Do we need to allocate an interrupt? */
674 p_dev
->conf
.Attributes
|= CONF_ENABLE_IRQ
;
676 /* IO window settings */
677 p_dev
->io
.NumPorts1
= p_dev
->io
.NumPorts2
= 0;
678 if ((cfg
->io
.nwin
> 0) || (dflt
->io
.nwin
> 0)) {
679 cistpl_io_t
*io
= (cfg
->io
.nwin
) ? &cfg
->io
: &dflt
->io
;
680 p_dev
->io
.Attributes1
= IO_DATA_PATH_WIDTH_AUTO
;
681 if (!(io
->flags
& CISTPL_IO_8BIT
))
682 p_dev
->io
.Attributes1
= IO_DATA_PATH_WIDTH_16
;
683 if (!(io
->flags
& CISTPL_IO_16BIT
))
684 p_dev
->io
.Attributes1
= IO_DATA_PATH_WIDTH_8
;
685 p_dev
->io
.IOAddrLines
= io
->flags
& CISTPL_IO_LINES_MASK
;
686 p_dev
->io
.BasePort1
= io
->win
[0].base
;
687 p_dev
->io
.NumPorts1
= io
->win
[0].len
;
689 p_dev
->io
.Attributes2
= p_dev
->io
.Attributes1
;
690 p_dev
->io
.BasePort2
= io
->win
[1].base
;
691 p_dev
->io
.NumPorts2
= io
->win
[1].len
;
694 /* This reserves IO space but doesn't actually enable it */
695 if (pcmcia_request_io(p_dev
, &p_dev
->io
) != 0)
701 pcmcia_disable_device(p_dev
);
706 spectrum_cs_config(struct pcmcia_device
*link
)
708 struct spectrum_cs_config_data
*cfg_mem
;
709 struct net_device
*dev
= link
->priv
;
710 struct orinoco_private
*priv
= netdev_priv(dev
);
711 struct orinoco_pccard
*card
= priv
->card
;
712 hermes_t
*hw
= &priv
->hw
;
713 int last_fn
, last_ret
;
716 cfg_mem
= kzalloc(sizeof(struct spectrum_cs_config_data
), GFP_KERNEL
);
720 /* Look up the current Vcc */
721 CS_CHECK(GetConfigurationInfo
,
722 pcmcia_get_configuration_info(link
, &cfg_mem
->conf
));
725 * In this loop, we scan the CIS for configuration table
726 * entries, each of which describes a valid card
727 * configuration, including voltage, IO window, memory window,
728 * and interrupt settings.
730 * We make no assumptions about the card to be configured: we
731 * use just the information available in the CIS. In an ideal
732 * world, this would work for any PCMCIA card, but it requires
733 * a complete and accurate CIS. In practice, a driver usually
734 * "knows" most of these things without consulting the CIS,
735 * and most client drivers will only use the CIS to fill in
736 * implementation-defined details.
738 last_ret
= pcmcia_loop_config(link
, spectrum_cs_config_check
, cfg_mem
);
741 printk(KERN_ERR PFX
"GetNextTuple(): No matching "
742 "CIS configuration. Maybe you need the "
743 "ignore_cis_vcc=1 parameter.\n");
744 cs_error(link
, RequestIO
, last_ret
);
749 * Allocate an interrupt line. Note that this does not assign
750 * a handler to the interrupt, unless the 'Handler' member of
751 * the irq structure is initialized.
753 CS_CHECK(RequestIRQ
, pcmcia_request_irq(link
, &link
->irq
));
755 /* We initialize the hermes structure before completing PCMCIA
756 * configuration just in case the interrupt handler gets
758 mem
= ioport_map(link
->io
.BasePort1
, link
->io
.NumPorts1
);
762 hermes_struct_init(hw
, mem
, HERMES_16BIT_REGSPACING
);
765 * This actually configures the PCMCIA socket -- setting up
766 * the I/O windows and the interrupt mapping, and putting the
767 * card and host interface into "Memory and IO" mode.
769 CS_CHECK(RequestConfiguration
,
770 pcmcia_request_configuration(link
, &link
->conf
));
772 /* Ok, we have the configuration, prepare to register the netdev */
773 dev
->base_addr
= link
->io
.BasePort1
;
774 dev
->irq
= link
->irq
.AssignedIRQ
;
775 card
->node
.major
= card
->node
.minor
= 0;
777 /* Reset card and download firmware */
778 if (spectrum_cs_hard_reset(priv
) != 0) {
782 SET_NETDEV_DEV(dev
, &handle_to_dev(link
));
783 /* Tell the stack we exist */
784 if (register_netdev(dev
) != 0) {
785 printk(KERN_ERR PFX
"register_netdev() failed\n");
789 /* At this point, the dev_node_t structure(s) needs to be
790 * initialized and arranged in a linked list at link->dev_node. */
791 strcpy(card
->node
.dev_name
, dev
->name
);
792 link
->dev_node
= &card
->node
; /* link->dev_node being non-NULL is also
793 used to indicate that the
794 net_device has been registered */
796 /* Finally, report what we've done */
797 printk(KERN_DEBUG
"%s: " DRIVER_NAME
" at %s, irq %d, io "
798 "0x%04x-0x%04x\n", dev
->name
, dev
->dev
.parent
->bus_id
,
799 link
->irq
.AssignedIRQ
, link
->io
.BasePort1
,
800 link
->io
.BasePort1
+ link
->io
.NumPorts1
- 1);
806 cs_error(link
, last_fn
, last_ret
);
809 spectrum_cs_release(link
);
812 } /* spectrum_cs_config */
815 * After a card is removed, spectrum_cs_release() will unregister the
816 * device, and release the PCMCIA configuration. If the device is
817 * still open, this will be postponed until it is closed.
820 spectrum_cs_release(struct pcmcia_device
*link
)
822 struct net_device
*dev
= link
->priv
;
823 struct orinoco_private
*priv
= netdev_priv(dev
);
826 /* We're committed to taking the device away now, so mark the
827 * hardware as unavailable */
828 spin_lock_irqsave(&priv
->lock
, flags
);
829 priv
->hw_unavailable
++;
830 spin_unlock_irqrestore(&priv
->lock
, flags
);
832 pcmcia_disable_device(link
);
834 ioport_unmap(priv
->hw
.iobase
);
835 } /* spectrum_cs_release */
839 spectrum_cs_suspend(struct pcmcia_device
*link
)
841 struct net_device
*dev
= link
->priv
;
842 struct orinoco_private
*priv
= netdev_priv(dev
);
845 /* Mark the device as stopped, to block IO until later */
846 spin_lock(&priv
->lock
);
848 err
= __orinoco_down(dev
);
850 printk(KERN_WARNING
"%s: Error %d downing interface\n",
853 netif_device_detach(dev
);
854 priv
->hw_unavailable
++;
856 spin_unlock(&priv
->lock
);
862 spectrum_cs_resume(struct pcmcia_device
*link
)
864 struct net_device
*dev
= link
->priv
;
865 struct orinoco_private
*priv
= netdev_priv(dev
);
867 netif_device_attach(dev
);
868 priv
->hw_unavailable
--;
869 schedule_work(&priv
->reset_work
);
875 /********************************************************************/
876 /* Module initialization */
877 /********************************************************************/
879 /* Can't be declared "const" or the whole __initdata section will
881 static char version
[] __initdata
= DRIVER_NAME
" " DRIVER_VERSION
882 " (Pavel Roskin <proski@gnu.org>,"
883 " David Gibson <hermes@gibson.dropbear.id.au>, et al)";
885 static struct pcmcia_device_id spectrum_cs_ids
[] = {
886 PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4137 */
887 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */
888 PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */
891 MODULE_DEVICE_TABLE(pcmcia
, spectrum_cs_ids
);
893 static struct pcmcia_driver orinoco_driver
= {
894 .owner
= THIS_MODULE
,
898 .probe
= spectrum_cs_probe
,
899 .remove
= spectrum_cs_detach
,
900 .suspend
= spectrum_cs_suspend
,
901 .resume
= spectrum_cs_resume
,
902 .id_table
= spectrum_cs_ids
,
906 init_spectrum_cs(void)
908 printk(KERN_DEBUG
"%s\n", version
);
910 return pcmcia_register_driver(&orinoco_driver
);
914 exit_spectrum_cs(void)
916 pcmcia_unregister_driver(&orinoco_driver
);
919 module_init(init_spectrum_cs
);
920 module_exit(exit_spectrum_cs
);