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 unsigned char *primsym
;
38 static unsigned char *secsym
;
39 static const char primary_fw_name
[] = "symbol_sp24t_prim_fw";
40 static const char secondary_fw_name
[] = "symbol_sp24t_sec_fw";
42 /********************************************************************/
44 /********************************************************************/
46 MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>");
47 MODULE_DESCRIPTION("Driver for Symbol Spectrum24 Trilogy cards with firmware downloader");
48 MODULE_LICENSE("Dual MPL/GPL");
50 /* Module parameters */
52 /* Some D-Link cards have buggy CIS. They do work at 5v properly, but
53 * don't have any CIS entry for it. This workaround it... */
54 static int ignore_cis_vcc
; /* = 0 */
55 module_param(ignore_cis_vcc
, int, 0);
56 MODULE_PARM_DESC(ignore_cis_vcc
, "Allow voltage mismatch between card and socket");
58 /********************************************************************/
60 /********************************************************************/
62 /* PCMCIA specific device information (goes in the card field of
63 * struct orinoco_private */
64 struct orinoco_pccard
{
65 struct pcmcia_device
*p_dev
;
69 /********************************************************************/
70 /* Function prototypes */
71 /********************************************************************/
73 static int spectrum_cs_config(struct pcmcia_device
*link
);
74 static void spectrum_cs_release(struct pcmcia_device
*link
);
76 /********************************************************************/
77 /* Firmware downloader */
78 /********************************************************************/
80 /* Position of PDA in the adapter memory */
81 #define EEPROM_ADDR 0x3000
82 #define EEPROM_LEN 0x200
83 #define PDA_OFFSET 0x100
85 #define PDA_ADDR (EEPROM_ADDR + PDA_OFFSET)
86 #define PDA_WORDS ((EEPROM_LEN - PDA_OFFSET) / 2)
88 /* Constants for the CISREG_CCSR register */
89 #define HCR_RUN 0x07 /* run firmware after reset */
90 #define HCR_IDLE 0x0E /* don't run firmware after reset */
91 #define HCR_MEM16 0x10 /* memory width bit, should be preserved */
94 * AUX port access. To unlock the AUX port write the access keys to the
95 * PARAM0-2 registers, then write HERMES_AUX_ENABLE to the HERMES_CONTROL
96 * register. Then read it and make sure it's HERMES_AUX_ENABLED.
98 #define HERMES_AUX_ENABLE 0x8000 /* Enable auxiliary port access */
99 #define HERMES_AUX_DISABLE 0x4000 /* Disable to auxiliary port access */
100 #define HERMES_AUX_ENABLED 0xC000 /* Auxiliary port is open */
102 #define HERMES_AUX_PW0 0xFE01
103 #define HERMES_AUX_PW1 0xDC23
104 #define HERMES_AUX_PW2 0xBA45
107 #define PDI_END 0x00000000 /* End of PDA */
108 #define BLOCK_END 0xFFFFFFFF /* Last image block */
109 #define TEXT_END 0x1A /* End of text header */
112 * The following structures have little-endian fields denoted by
113 * the leading underscore. Don't access them directly - use inline
114 * functions defined below.
118 * The binary image to be downloaded consists of series of data blocks.
119 * Each block has the following structure.
122 __le32 addr
; /* adapter address where to write the block */
123 __le16 len
; /* length of the data only, in bytes */
124 char data
[0]; /* data to be written */
125 } __attribute__ ((packed
));
128 * Plug Data References are located in in the image after the last data
129 * block. They refer to areas in the adapter memory where the plug data
130 * items with matching ID should be written.
133 __le32 id
; /* record ID */
134 __le32 addr
; /* adapter address where to write the data */
135 __le32 len
; /* expected length of the data, in bytes */
136 char next
[0]; /* next PDR starts here */
137 } __attribute__ ((packed
));
141 * Plug Data Items are located in the EEPROM read from the adapter by
142 * primary firmware. They refer to the device-specific data that should
143 * be plugged into the secondary firmware.
146 __le16 len
; /* length of ID and data, in words */
147 __le16 id
; /* record ID */
148 char data
[0]; /* plug data */
149 } __attribute__ ((packed
));
152 /* Functions for access to little-endian data */
154 dblock_addr(const struct dblock
*blk
)
156 return le32_to_cpu(blk
->addr
);
160 dblock_len(const struct dblock
*blk
)
162 return le16_to_cpu(blk
->len
);
166 pdr_id(const struct pdr
*pdr
)
168 return le32_to_cpu(pdr
->id
);
172 pdr_addr(const struct pdr
*pdr
)
174 return le32_to_cpu(pdr
->addr
);
178 pdr_len(const struct pdr
*pdr
)
180 return le32_to_cpu(pdr
->len
);
184 pdi_id(const struct pdi
*pdi
)
186 return le16_to_cpu(pdi
->id
);
189 /* Return length of the data only, in bytes */
191 pdi_len(const struct pdi
*pdi
)
193 return 2 * (le16_to_cpu(pdi
->len
) - 1);
197 /* Set address of the auxiliary port */
199 spectrum_aux_setaddr(hermes_t
*hw
, u32 addr
)
201 hermes_write_reg(hw
, HERMES_AUXPAGE
, (u16
) (addr
>> 7));
202 hermes_write_reg(hw
, HERMES_AUXOFFSET
, (u16
) (addr
& 0x7F));
206 /* Open access to the auxiliary port */
208 spectrum_aux_open(hermes_t
*hw
)
213 if (hermes_read_reg(hw
, HERMES_CONTROL
) == HERMES_AUX_ENABLED
)
216 hermes_write_reg(hw
, HERMES_PARAM0
, HERMES_AUX_PW0
);
217 hermes_write_reg(hw
, HERMES_PARAM1
, HERMES_AUX_PW1
);
218 hermes_write_reg(hw
, HERMES_PARAM2
, HERMES_AUX_PW2
);
219 hermes_write_reg(hw
, HERMES_CONTROL
, HERMES_AUX_ENABLE
);
221 for (i
= 0; i
< 20; i
++) {
223 if (hermes_read_reg(hw
, HERMES_CONTROL
) ==
232 #define CS_CHECK(fn, ret) \
233 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
236 * Reset the card using configuration registers COR and CCSR.
237 * If IDLE is 1, stop the firmware, so that it can be safely rewritten.
240 spectrum_reset(struct pcmcia_device
*link
, int idle
)
242 int last_ret
, last_fn
;
246 /* Doing it if hardware is gone is guaranteed crash */
247 if (pcmcia_dev_present(link
))
250 /* Save original COR value */
252 reg
.Action
= CS_READ
;
253 reg
.Offset
= CISREG_COR
;
254 CS_CHECK(AccessConfigurationRegister
,
255 pcmcia_access_configuration_register(link
, ®
));
256 save_cor
= reg
.Value
;
258 /* Soft-Reset card */
259 reg
.Action
= CS_WRITE
;
260 reg
.Offset
= CISREG_COR
;
261 reg
.Value
= (save_cor
| COR_SOFT_RESET
);
262 CS_CHECK(AccessConfigurationRegister
,
263 pcmcia_access_configuration_register(link
, ®
));
267 reg
.Action
= CS_READ
;
268 reg
.Offset
= CISREG_CCSR
;
269 CS_CHECK(AccessConfigurationRegister
,
270 pcmcia_access_configuration_register(link
, ®
));
273 * Start or stop the firmware. Memory width bit should be
274 * preserved from the value we've just read.
276 reg
.Action
= CS_WRITE
;
277 reg
.Offset
= CISREG_CCSR
;
278 reg
.Value
= (idle
? HCR_IDLE
: HCR_RUN
) | (reg
.Value
& HCR_MEM16
);
279 CS_CHECK(AccessConfigurationRegister
,
280 pcmcia_access_configuration_register(link
, ®
));
283 /* Restore original COR configuration index */
284 reg
.Action
= CS_WRITE
;
285 reg
.Offset
= CISREG_COR
;
286 reg
.Value
= (save_cor
& ~COR_SOFT_RESET
);
287 CS_CHECK(AccessConfigurationRegister
,
288 pcmcia_access_configuration_register(link
, ®
));
293 cs_error(link
, last_fn
, last_ret
);
299 * Scan PDR for the record with the specified RECORD_ID.
300 * If it's not found, return NULL.
303 spectrum_find_pdr(struct pdr
*first_pdr
, u32 record_id
)
305 struct pdr
*pdr
= first_pdr
;
307 while (pdr_id(pdr
) != PDI_END
) {
309 * PDR area is currently not terminated by PDI_END.
310 * It's followed by CRC records, which have the type
311 * field where PDR has length. The type can be 0 or 1.
313 if (pdr_len(pdr
) < 2)
316 /* If the record ID matches, we are done */
317 if (pdr_id(pdr
) == record_id
)
320 pdr
= (struct pdr
*) pdr
->next
;
326 /* Process one Plug Data Item - find corresponding PDR and plug it */
328 spectrum_plug_pdi(hermes_t
*hw
, struct pdr
*first_pdr
, struct pdi
*pdi
)
332 /* Find the PDI corresponding to this PDR */
333 pdr
= spectrum_find_pdr(first_pdr
, pdi_id(pdi
));
335 /* No match is found, safe to ignore */
339 /* Lengths of the data in PDI and PDR must match */
340 if (pdi_len(pdi
) != pdr_len(pdr
))
343 /* do the actual plugging */
344 spectrum_aux_setaddr(hw
, pdr_addr(pdr
));
345 hermes_write_bytes(hw
, HERMES_AUXDATA
, pdi
->data
, pdi_len(pdi
));
351 /* Read PDA from the adapter */
353 spectrum_read_pda(hermes_t
*hw
, __le16
*pda
, int pda_len
)
358 /* Issue command to read EEPROM */
359 ret
= hermes_docmd_wait(hw
, HERMES_CMD_READMIF
, 0, NULL
);
363 /* Open auxiliary port */
364 ret
= spectrum_aux_open(hw
);
368 /* read PDA from EEPROM */
369 spectrum_aux_setaddr(hw
, PDA_ADDR
);
370 hermes_read_words(hw
, HERMES_AUXDATA
, pda
, pda_len
/ 2);
372 /* Check PDA length */
373 pda_size
= le16_to_cpu(pda
[0]);
374 if (pda_size
> pda_len
)
381 /* Parse PDA and write the records into the adapter */
383 spectrum_apply_pda(hermes_t
*hw
, const struct dblock
*first_block
,
388 struct pdr
*first_pdr
;
389 const struct dblock
*blk
= first_block
;
391 /* Skip all blocks to locate Plug Data References */
392 while (dblock_addr(blk
) != BLOCK_END
)
393 blk
= (struct dblock
*) &blk
->data
[dblock_len(blk
)];
395 first_pdr
= (struct pdr
*) blk
;
397 /* Go through every PDI and plug them into the adapter */
398 pdi
= (struct pdi
*) (pda
+ 2);
399 while (pdi_id(pdi
) != PDI_END
) {
400 ret
= spectrum_plug_pdi(hw
, first_pdr
, pdi
);
404 /* Increment to the next PDI */
405 pdi
= (struct pdi
*) &pdi
->data
[pdi_len(pdi
)];
411 /* Load firmware blocks into the adapter */
413 spectrum_load_blocks(hermes_t
*hw
, const struct dblock
*first_block
)
415 const struct dblock
*blk
;
420 blkaddr
= dblock_addr(blk
);
421 blklen
= dblock_len(blk
);
423 while (dblock_addr(blk
) != BLOCK_END
) {
424 spectrum_aux_setaddr(hw
, blkaddr
);
425 hermes_write_bytes(hw
, HERMES_AUXDATA
, blk
->data
,
428 blk
= (struct dblock
*) &blk
->data
[blklen
];
429 blkaddr
= dblock_addr(blk
);
430 blklen
= dblock_len(blk
);
437 * Process a firmware image - stop the card, load the firmware, reset
438 * the card and make sure it responds. For the secondary firmware take
439 * care of the PDA - read it and then write it on top of the firmware.
442 spectrum_dl_image(hermes_t
*hw
, struct pcmcia_device
*link
,
443 const unsigned char *image
)
446 const unsigned char *ptr
;
447 const struct dblock
*first_block
;
449 /* Plug Data Area (PDA) */
450 __le16 pda
[PDA_WORDS
];
452 /* Binary block begins after the 0x1A marker */
454 while (*ptr
++ != TEXT_END
);
455 first_block
= (const struct dblock
*) ptr
;
458 if (image
!= primsym
) {
459 ret
= spectrum_read_pda(hw
, pda
, sizeof(pda
));
464 /* Stop the firmware, so that it can be safely rewritten */
465 ret
= spectrum_reset(link
, 1);
469 /* Program the adapter with new firmware */
470 ret
= spectrum_load_blocks(hw
, first_block
);
474 /* Write the PDA to the adapter */
475 if (image
!= primsym
) {
476 ret
= spectrum_apply_pda(hw
, first_block
, pda
);
481 /* Run the firmware */
482 ret
= spectrum_reset(link
, 0);
486 /* Reset hermes chip and make sure it responds */
487 ret
= hermes_init(hw
);
489 /* hermes_reset() should return 0 with the secondary firmware */
490 if (image
!= primsym
&& ret
!= 0)
493 /* And this should work with any firmware */
494 if (!hermes_present(hw
))
502 * Download the firmware into the card, this also does a PCMCIA soft
503 * reset on the card, to make sure it's in a sane state.
506 spectrum_dl_firmware(hermes_t
*hw
, struct pcmcia_device
*link
)
509 const struct firmware
*fw_entry
;
511 if (request_firmware(&fw_entry
, primary_fw_name
,
512 &handle_to_dev(link
)) == 0) {
513 primsym
= fw_entry
->data
;
515 printk(KERN_ERR PFX
"Cannot find firmware: %s\n",
520 if (request_firmware(&fw_entry
, secondary_fw_name
,
521 &handle_to_dev(link
)) == 0) {
522 secsym
= fw_entry
->data
;
524 printk(KERN_ERR PFX
"Cannot find firmware: %s\n",
529 /* Load primary firmware */
530 ret
= spectrum_dl_image(hw
, link
, primsym
);
532 printk(KERN_ERR PFX
"Primary firmware download failed\n");
536 /* Load secondary firmware */
537 ret
= spectrum_dl_image(hw
, link
, secsym
);
540 printk(KERN_ERR PFX
"Secondary firmware download failed\n");
546 /********************************************************************/
548 /********************************************************************/
551 spectrum_cs_hard_reset(struct orinoco_private
*priv
)
553 struct orinoco_pccard
*card
= priv
->card
;
554 struct pcmcia_device
*link
= card
->p_dev
;
557 if (!hermes_present(&priv
->hw
)) {
558 /* The firmware needs to be reloaded */
559 if (spectrum_dl_firmware(&priv
->hw
, link
) != 0) {
560 printk(KERN_ERR PFX
"Firmware download failed\n");
564 /* Soft reset using COR and HCR */
565 spectrum_reset(link
, 0);
571 /********************************************************************/
573 /********************************************************************/
576 * This creates an "instance" of the driver, allocating local data
577 * structures for one device. The device is registered with Card
580 * The dev_link structure is initialized, but we don't actually
581 * configure the card at this point -- we wait until we receive a card
582 * insertion event. */
584 spectrum_cs_probe(struct pcmcia_device
*link
)
586 struct net_device
*dev
;
587 struct orinoco_private
*priv
;
588 struct orinoco_pccard
*card
;
590 dev
= alloc_orinocodev(sizeof(*card
), spectrum_cs_hard_reset
);
593 priv
= netdev_priv(dev
);
596 /* Link both structures together */
600 /* Interrupt setup */
601 link
->irq
.Attributes
= IRQ_TYPE_EXCLUSIVE
| IRQ_HANDLE_PRESENT
;
602 link
->irq
.IRQInfo1
= IRQ_LEVEL_ID
;
603 link
->irq
.Handler
= orinoco_interrupt
;
604 link
->irq
.Instance
= dev
;
606 /* General socket configuration defaults can go here. In this
607 * client, we assume very little, and rely on the CIS for
608 * almost everything. In most clients, many details (i.e.,
609 * number, sizes, and attributes of IO windows) are fixed by
610 * the nature of the device, and can be hard-wired here. */
611 link
->conf
.Attributes
= 0;
612 link
->conf
.IntType
= INT_MEMORY_AND_IO
;
614 return spectrum_cs_config(link
);
615 } /* spectrum_cs_attach */
618 * This deletes a driver "instance". The device is de-registered with
619 * Card Services. If it has been released, all local data structures
620 * are freed. Otherwise, the structures will be freed when the device
623 static void spectrum_cs_detach(struct pcmcia_device
*link
)
625 struct net_device
*dev
= link
->priv
;
628 unregister_netdev(dev
);
630 spectrum_cs_release(link
);
632 free_orinocodev(dev
);
633 } /* spectrum_cs_detach */
636 * spectrum_cs_config() is scheduled to run after a CARD_INSERTION
637 * event is received, to configure the PCMCIA socket, and to make the
638 * device available to the system.
642 spectrum_cs_config(struct pcmcia_device
*link
)
644 struct net_device
*dev
= link
->priv
;
645 struct orinoco_private
*priv
= netdev_priv(dev
);
646 struct orinoco_pccard
*card
= priv
->card
;
647 hermes_t
*hw
= &priv
->hw
;
648 int last_fn
, last_ret
;
656 * This reads the card's CONFIG tuple to find its
657 * configuration registers.
659 tuple
.DesiredTuple
= CISTPL_CONFIG
;
660 tuple
.Attributes
= 0;
661 tuple
.TupleData
= buf
;
662 tuple
.TupleDataMax
= sizeof(buf
);
663 tuple
.TupleOffset
= 0;
664 CS_CHECK(GetFirstTuple
, pcmcia_get_first_tuple(link
, &tuple
));
665 CS_CHECK(GetTupleData
, pcmcia_get_tuple_data(link
, &tuple
));
666 CS_CHECK(ParseTuple
, pcmcia_parse_tuple(link
, &tuple
, &parse
));
667 link
->conf
.ConfigBase
= parse
.config
.base
;
668 link
->conf
.Present
= parse
.config
.rmask
[0];
670 /* Look up the current Vcc */
671 CS_CHECK(GetConfigurationInfo
,
672 pcmcia_get_configuration_info(link
, &conf
));
675 * In this loop, we scan the CIS for configuration table
676 * entries, each of which describes a valid card
677 * configuration, including voltage, IO window, memory window,
678 * and interrupt settings.
680 * We make no assumptions about the card to be configured: we
681 * use just the information available in the CIS. In an ideal
682 * world, this would work for any PCMCIA card, but it requires
683 * a complete and accurate CIS. In practice, a driver usually
684 * "knows" most of these things without consulting the CIS,
685 * and most client drivers will only use the CIS to fill in
686 * implementation-defined details.
688 tuple
.DesiredTuple
= CISTPL_CFTABLE_ENTRY
;
689 CS_CHECK(GetFirstTuple
, pcmcia_get_first_tuple(link
, &tuple
));
691 cistpl_cftable_entry_t
*cfg
= &(parse
.cftable_entry
);
692 cistpl_cftable_entry_t dflt
= { .index
= 0 };
694 if ( (pcmcia_get_tuple_data(link
, &tuple
) != 0)
695 || (pcmcia_parse_tuple(link
, &tuple
, &parse
) != 0))
698 if (cfg
->flags
& CISTPL_CFTABLE_DEFAULT
)
702 link
->conf
.ConfigIndex
= cfg
->index
;
704 /* Use power settings for Vcc and Vpp if present */
705 /* Note that the CIS values need to be rescaled */
706 if (cfg
->vcc
.present
& (1 << CISTPL_POWER_VNOM
)) {
707 if (conf
.Vcc
!= cfg
->vcc
.param
[CISTPL_POWER_VNOM
] / 10000) {
708 DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf
.Vcc
, cfg
->vcc
.param
[CISTPL_POWER_VNOM
] / 10000);
712 } else if (dflt
.vcc
.present
& (1 << CISTPL_POWER_VNOM
)) {
713 if (conf
.Vcc
!= dflt
.vcc
.param
[CISTPL_POWER_VNOM
] / 10000) {
714 DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf
.Vcc
, dflt
.vcc
.param
[CISTPL_POWER_VNOM
] / 10000);
720 if (cfg
->vpp1
.present
& (1 << CISTPL_POWER_VNOM
))
722 cfg
->vpp1
.param
[CISTPL_POWER_VNOM
] / 10000;
723 else if (dflt
.vpp1
.present
& (1 << CISTPL_POWER_VNOM
))
725 dflt
.vpp1
.param
[CISTPL_POWER_VNOM
] / 10000;
727 /* Do we need to allocate an interrupt? */
728 link
->conf
.Attributes
|= CONF_ENABLE_IRQ
;
730 /* IO window settings */
731 link
->io
.NumPorts1
= link
->io
.NumPorts2
= 0;
732 if ((cfg
->io
.nwin
> 0) || (dflt
.io
.nwin
> 0)) {
734 (cfg
->io
.nwin
) ? &cfg
->io
: &dflt
.io
;
735 link
->io
.Attributes1
= IO_DATA_PATH_WIDTH_AUTO
;
736 if (!(io
->flags
& CISTPL_IO_8BIT
))
737 link
->io
.Attributes1
=
738 IO_DATA_PATH_WIDTH_16
;
739 if (!(io
->flags
& CISTPL_IO_16BIT
))
740 link
->io
.Attributes1
=
741 IO_DATA_PATH_WIDTH_8
;
742 link
->io
.IOAddrLines
=
743 io
->flags
& CISTPL_IO_LINES_MASK
;
744 link
->io
.BasePort1
= io
->win
[0].base
;
745 link
->io
.NumPorts1
= io
->win
[0].len
;
747 link
->io
.Attributes2
=
748 link
->io
.Attributes1
;
749 link
->io
.BasePort2
= io
->win
[1].base
;
750 link
->io
.NumPorts2
= io
->win
[1].len
;
753 /* This reserves IO space but doesn't actually enable it */
754 if (pcmcia_request_io(link
, &link
->io
) != 0)
759 /* If we got this far, we're cool! */
764 pcmcia_disable_device(link
);
765 last_ret
= pcmcia_get_next_tuple(link
, &tuple
);
766 if (last_ret
== CS_NO_MORE_ITEMS
) {
767 printk(KERN_ERR PFX
"GetNextTuple(): No matching "
768 "CIS configuration. Maybe you need the "
769 "ignore_cis_vcc=1 parameter.\n");
775 * Allocate an interrupt line. Note that this does not assign
776 * a handler to the interrupt, unless the 'Handler' member of
777 * the irq structure is initialized.
779 CS_CHECK(RequestIRQ
, pcmcia_request_irq(link
, &link
->irq
));
781 /* We initialize the hermes structure before completing PCMCIA
782 * configuration just in case the interrupt handler gets
784 mem
= ioport_map(link
->io
.BasePort1
, link
->io
.NumPorts1
);
788 hermes_struct_init(hw
, mem
, HERMES_16BIT_REGSPACING
);
791 * This actually configures the PCMCIA socket -- setting up
792 * the I/O windows and the interrupt mapping, and putting the
793 * card and host interface into "Memory and IO" mode.
795 CS_CHECK(RequestConfiguration
,
796 pcmcia_request_configuration(link
, &link
->conf
));
798 /* Ok, we have the configuration, prepare to register the netdev */
799 dev
->base_addr
= link
->io
.BasePort1
;
800 dev
->irq
= link
->irq
.AssignedIRQ
;
801 SET_MODULE_OWNER(dev
);
802 card
->node
.major
= card
->node
.minor
= 0;
804 /* Reset card and download firmware */
805 if (spectrum_cs_hard_reset(priv
) != 0) {
809 SET_NETDEV_DEV(dev
, &handle_to_dev(link
));
810 /* Tell the stack we exist */
811 if (register_netdev(dev
) != 0) {
812 printk(KERN_ERR PFX
"register_netdev() failed\n");
816 /* At this point, the dev_node_t structure(s) needs to be
817 * initialized and arranged in a linked list at link->dev_node. */
818 strcpy(card
->node
.dev_name
, dev
->name
);
819 link
->dev_node
= &card
->node
; /* link->dev_node being non-NULL is also
820 used to indicate that the
821 net_device has been registered */
823 /* Finally, report what we've done */
824 printk(KERN_DEBUG
"%s: " DRIVER_NAME
" at %s, irq %d, io "
825 "0x%04x-0x%04x\n", dev
->name
, dev
->class_dev
.dev
->bus_id
,
826 link
->irq
.AssignedIRQ
, link
->io
.BasePort1
,
827 link
->io
.BasePort1
+ link
->io
.NumPorts1
- 1);
832 cs_error(link
, last_fn
, last_ret
);
835 spectrum_cs_release(link
);
837 } /* spectrum_cs_config */
840 * After a card is removed, spectrum_cs_release() will unregister the
841 * device, and release the PCMCIA configuration. If the device is
842 * still open, this will be postponed until it is closed.
845 spectrum_cs_release(struct pcmcia_device
*link
)
847 struct net_device
*dev
= link
->priv
;
848 struct orinoco_private
*priv
= netdev_priv(dev
);
851 /* We're committed to taking the device away now, so mark the
852 * hardware as unavailable */
853 spin_lock_irqsave(&priv
->lock
, flags
);
854 priv
->hw_unavailable
++;
855 spin_unlock_irqrestore(&priv
->lock
, flags
);
857 pcmcia_disable_device(link
);
859 ioport_unmap(priv
->hw
.iobase
);
860 } /* spectrum_cs_release */
864 spectrum_cs_suspend(struct pcmcia_device
*link
)
866 struct net_device
*dev
= link
->priv
;
867 struct orinoco_private
*priv
= netdev_priv(dev
);
870 /* Mark the device as stopped, to block IO until later */
871 spin_lock(&priv
->lock
);
873 err
= __orinoco_down(dev
);
875 printk(KERN_WARNING
"%s: Error %d downing interface\n",
878 netif_device_detach(dev
);
879 priv
->hw_unavailable
++;
881 spin_unlock(&priv
->lock
);
887 spectrum_cs_resume(struct pcmcia_device
*link
)
889 struct net_device
*dev
= link
->priv
;
890 struct orinoco_private
*priv
= netdev_priv(dev
);
892 netif_device_attach(dev
);
893 priv
->hw_unavailable
--;
894 schedule_work(&priv
->reset_work
);
900 /********************************************************************/
901 /* Module initialization */
902 /********************************************************************/
904 /* Can't be declared "const" or the whole __initdata section will
906 static char version
[] __initdata
= DRIVER_NAME
" " DRIVER_VERSION
907 " (Pavel Roskin <proski@gnu.org>,"
908 " David Gibson <hermes@gibson.dropbear.id.au>, et al)";
910 static struct pcmcia_device_id spectrum_cs_ids
[] = {
911 PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4137 */
912 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */
913 PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */
916 MODULE_DEVICE_TABLE(pcmcia
, spectrum_cs_ids
);
918 static struct pcmcia_driver orinoco_driver
= {
919 .owner
= THIS_MODULE
,
923 .probe
= spectrum_cs_probe
,
924 .remove
= spectrum_cs_detach
,
925 .suspend
= spectrum_cs_suspend
,
926 .resume
= spectrum_cs_resume
,
927 .id_table
= spectrum_cs_ids
,
931 init_spectrum_cs(void)
933 printk(KERN_DEBUG
"%s\n", version
);
935 return pcmcia_register_driver(&orinoco_driver
);
939 exit_spectrum_cs(void)
941 pcmcia_unregister_driver(&orinoco_driver
);
944 module_init(init_spectrum_cs
);
945 module_exit(exit_spectrum_cs
);