2 * Driver for 802.11b cards using RAM-loadable Symbol firmware, such as
3 * Symbol Wireless Networker LA4100, 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/config.h>
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/firmware.h>
30 #include <pcmcia/cs_types.h>
31 #include <pcmcia/cs.h>
32 #include <pcmcia/cistpl.h>
33 #include <pcmcia/cisreg.h>
34 #include <pcmcia/ds.h>
38 static unsigned char *primsym;
39 static unsigned char *secsym;
40 static const char primary_fw_name[] = "symbol_sp24t_prim_fw";
41 static const char secondary_fw_name[] = "symbol_sp24t_sec_fw";
43 /********************************************************************/
45 /********************************************************************/
47 MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>");
48 MODULE_DESCRIPTION("Driver for Symbol Spectrum24 Trilogy cards with firmware downloader");
49 MODULE_LICENSE("Dual MPL/GPL");
51 /* Module parameters */
53 /* Some D-Link cards have buggy CIS. They do work at 5v properly, but
54 * don't have any CIS entry for it. This workaround it... */
55 static int ignore_cis_vcc; /* = 0 */
56 module_param(ignore_cis_vcc, int, 0);
57 MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket");
59 /********************************************************************/
61 /********************************************************************/
63 /* PCMCIA specific device information (goes in the card field of
64 * struct orinoco_private */
65 struct orinoco_pccard {
70 /********************************************************************/
71 /* Function prototypes */
72 /********************************************************************/
74 static void spectrum_cs_config(dev_link_t *link);
75 static void spectrum_cs_release(dev_link_t *link);
77 /********************************************************************/
78 /* Firmware downloader */
79 /********************************************************************/
81 /* Position of PDA in the adapter memory */
82 #define EEPROM_ADDR 0x3000
83 #define EEPROM_LEN 0x200
84 #define PDA_OFFSET 0x100
86 #define PDA_ADDR (EEPROM_ADDR + PDA_OFFSET)
87 #define PDA_WORDS ((EEPROM_LEN - PDA_OFFSET) / 2)
89 /* Constants for the CISREG_CCSR register */
90 #define HCR_RUN 0x07 /* run firmware after reset */
91 #define HCR_IDLE 0x0E /* don't run firmware after reset */
92 #define HCR_MEM16 0x10 /* memory width bit, should be preserved */
95 * AUX port access. To unlock the AUX port write the access keys to the
96 * PARAM0-2 registers, then write HERMES_AUX_ENABLE to the HERMES_CONTROL
97 * register. Then read it and make sure it's HERMES_AUX_ENABLED.
99 #define HERMES_AUX_ENABLE 0x8000 /* Enable auxiliary port access */
100 #define HERMES_AUX_DISABLE 0x4000 /* Disable to auxiliary port access */
101 #define HERMES_AUX_ENABLED 0xC000 /* Auxiliary port is open */
103 #define HERMES_AUX_PW0 0xFE01
104 #define HERMES_AUX_PW1 0xDC23
105 #define HERMES_AUX_PW2 0xBA45
108 #define PDI_END 0x00000000 /* End of PDA */
109 #define BLOCK_END 0xFFFFFFFF /* Last image block */
110 #define TEXT_END 0x1A /* End of text header */
113 * The following structures have little-endian fields denoted by
114 * the leading underscore. Don't access them directly - use inline
115 * functions defined below.
119 * The binary image to be downloaded consists of series of data blocks.
120 * Each block has the following structure.
123 __le32 _addr; /* adapter address where to write the block */
124 __le16 _len; /* length of the data only, in bytes */
125 char data[0]; /* data to be written */
126 } __attribute__ ((packed));
129 * Plug Data References are located in in the image after the last data
130 * block. They refer to areas in the adapter memory where the plug data
131 * items with matching ID should be written.
134 __le32 _id; /* record ID */
135 __le32 _addr; /* adapter address where to write the data */
136 __le32 _len; /* expected length of the data, in bytes */
137 char next[0]; /* next PDR starts here */
138 } __attribute__ ((packed));
142 * Plug Data Items are located in the EEPROM read from the adapter by
143 * primary firmware. They refer to the device-specific data that should
144 * be plugged into the secondary firmware.
147 __le16 _len; /* length of ID and data, in words */
148 __le16 _id; /* record ID */
149 char data[0]; /* plug data */
150 } __attribute__ ((packed));
153 /* Functions for access to little-endian data */
155 dblock_addr(const struct dblock *blk)
157 return le32_to_cpu(blk->_addr);
161 dblock_len(const struct dblock *blk)
163 return le16_to_cpu(blk->_len);
167 pdr_id(const struct pdr *pdr)
169 return le32_to_cpu(pdr->_id);
173 pdr_addr(const struct pdr *pdr)
175 return le32_to_cpu(pdr->_addr);
179 pdr_len(const struct pdr *pdr)
181 return le32_to_cpu(pdr->_len);
185 pdi_id(const struct pdi *pdi)
187 return le16_to_cpu(pdi->_id);
190 /* Return length of the data only, in bytes */
192 pdi_len(const struct pdi *pdi)
194 return 2 * (le16_to_cpu(pdi->_len) - 1);
198 /* Set address of the auxiliary port */
200 spectrum_aux_setaddr(hermes_t *hw, u32 addr)
202 hermes_write_reg(hw, HERMES_AUXPAGE, (u16) (addr >> 7));
203 hermes_write_reg(hw, HERMES_AUXOFFSET, (u16) (addr & 0x7F));
207 /* Open access to the auxiliary port */
209 spectrum_aux_open(hermes_t *hw)
214 if (hermes_read_reg(hw, HERMES_CONTROL) == HERMES_AUX_ENABLED)
217 hermes_write_reg(hw, HERMES_PARAM0, HERMES_AUX_PW0);
218 hermes_write_reg(hw, HERMES_PARAM1, HERMES_AUX_PW1);
219 hermes_write_reg(hw, HERMES_PARAM2, HERMES_AUX_PW2);
220 hermes_write_reg(hw, HERMES_CONTROL, HERMES_AUX_ENABLE);
222 for (i = 0; i < 20; i++) {
224 if (hermes_read_reg(hw, HERMES_CONTROL) ==
233 #define CS_CHECK(fn, ret) \
234 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
237 * Reset the card using configuration registers COR and CCSR.
238 * If IDLE is 1, stop the firmware, so that it can be safely rewritten.
241 spectrum_reset(dev_link_t *link, int idle)
243 int last_ret, last_fn;
247 /* Doing it if hardware is gone is guaranteed crash */
248 if (!(link->state & DEV_CONFIG))
251 /* Save original COR value */
253 reg.Action = CS_READ;
254 reg.Offset = CISREG_COR;
255 CS_CHECK(AccessConfigurationRegister,
256 pcmcia_access_configuration_register(link->handle, ®));
257 save_cor = reg.Value;
259 /* Soft-Reset card */
260 reg.Action = CS_WRITE;
261 reg.Offset = CISREG_COR;
262 reg.Value = (save_cor | COR_SOFT_RESET);
263 CS_CHECK(AccessConfigurationRegister,
264 pcmcia_access_configuration_register(link->handle, ®));
268 reg.Action = CS_READ;
269 reg.Offset = CISREG_CCSR;
270 CS_CHECK(AccessConfigurationRegister,
271 pcmcia_access_configuration_register(link->handle, ®));
274 * Start or stop the firmware. Memory width bit should be
275 * preserved from the value we've just read.
277 reg.Action = CS_WRITE;
278 reg.Offset = CISREG_CCSR;
279 reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16);
280 CS_CHECK(AccessConfigurationRegister,
281 pcmcia_access_configuration_register(link->handle, ®));
284 /* Restore original COR configuration index */
285 reg.Action = CS_WRITE;
286 reg.Offset = CISREG_COR;
287 reg.Value = (save_cor & ~COR_SOFT_RESET);
288 CS_CHECK(AccessConfigurationRegister,
289 pcmcia_access_configuration_register(link->handle, ®));
294 cs_error(link->handle, last_fn, last_ret);
300 * Scan PDR for the record with the specified RECORD_ID.
301 * If it's not found, return NULL.
304 spectrum_find_pdr(struct pdr *first_pdr, u32 record_id)
306 struct pdr *pdr = first_pdr;
308 while (pdr_id(pdr) != PDI_END) {
310 * PDR area is currently not terminated by PDI_END.
311 * It's followed by CRC records, which have the type
312 * field where PDR has length. The type can be 0 or 1.
314 if (pdr_len(pdr) < 2)
317 /* If the record ID matches, we are done */
318 if (pdr_id(pdr) == record_id)
321 pdr = (struct pdr *) pdr->next;
327 /* Process one Plug Data Item - find corresponding PDR and plug it */
329 spectrum_plug_pdi(hermes_t *hw, struct pdr *first_pdr, struct pdi *pdi)
333 /* Find the PDI corresponding to this PDR */
334 pdr = spectrum_find_pdr(first_pdr, pdi_id(pdi));
336 /* No match is found, safe to ignore */
340 /* Lengths of the data in PDI and PDR must match */
341 if (pdi_len(pdi) != pdr_len(pdr))
344 /* do the actual plugging */
345 spectrum_aux_setaddr(hw, pdr_addr(pdr));
346 hermes_write_words(hw, HERMES_AUXDATA, pdi->data,
353 /* Read PDA from the adapter */
355 spectrum_read_pda(hermes_t *hw, __le16 *pda, int pda_len)
360 /* Issue command to read EEPROM */
361 ret = hermes_docmd_wait(hw, HERMES_CMD_READMIF, 0, NULL);
365 /* Open auxiliary port */
366 ret = spectrum_aux_open(hw);
370 /* read PDA from EEPROM */
371 spectrum_aux_setaddr(hw, PDA_ADDR);
372 hermes_read_words(hw, HERMES_AUXDATA, pda, pda_len / 2);
374 /* Check PDA length */
375 pda_size = le16_to_cpu(pda[0]);
376 if (pda_size > pda_len)
383 /* Parse PDA and write the records into the adapter */
385 spectrum_apply_pda(hermes_t *hw, const struct dblock *first_block,
390 struct pdr *first_pdr;
391 const struct dblock *blk = first_block;
393 /* Skip all blocks to locate Plug Data References */
394 while (dblock_addr(blk) != BLOCK_END)
395 blk = (struct dblock *) &blk->data[dblock_len(blk)];
397 first_pdr = (struct pdr *) blk;
399 /* Go through every PDI and plug them into the adapter */
400 pdi = (struct pdi *) (pda + 2);
401 while (pdi_id(pdi) != PDI_END) {
402 ret = spectrum_plug_pdi(hw, first_pdr, pdi);
406 /* Increment to the next PDI */
407 pdi = (struct pdi *) &pdi->data[pdi_len(pdi)];
413 /* Load firmware blocks into the adapter */
415 spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block)
417 const struct dblock *blk;
422 blkaddr = dblock_addr(blk);
423 blklen = dblock_len(blk);
425 while (dblock_addr(blk) != BLOCK_END) {
426 spectrum_aux_setaddr(hw, blkaddr);
427 hermes_write_words(hw, HERMES_AUXDATA, blk->data,
430 blk = (struct dblock *) &blk->data[blklen];
431 blkaddr = dblock_addr(blk);
432 blklen = dblock_len(blk);
439 * Process a firmware image - stop the card, load the firmware, reset
440 * the card and make sure it responds. For the secondary firmware take
441 * care of the PDA - read it and then write it on top of the firmware.
444 spectrum_dl_image(hermes_t *hw, dev_link_t *link,
445 const unsigned char *image)
448 const unsigned char *ptr;
449 const struct dblock *first_block;
451 /* Plug Data Area (PDA) */
452 __le16 pda[PDA_WORDS];
454 /* Binary block begins after the 0x1A marker */
456 while (*ptr++ != TEXT_END);
457 first_block = (const struct dblock *) ptr;
460 if (image != primsym) {
461 ret = spectrum_read_pda(hw, pda, sizeof(pda));
466 /* Stop the firmware, so that it can be safely rewritten */
467 ret = spectrum_reset(link, 1);
471 /* Program the adapter with new firmware */
472 ret = spectrum_load_blocks(hw, first_block);
476 /* Write the PDA to the adapter */
477 if (image != primsym) {
478 ret = spectrum_apply_pda(hw, first_block, pda);
483 /* Run the firmware */
484 ret = spectrum_reset(link, 0);
488 /* Reset hermes chip and make sure it responds */
489 ret = hermes_init(hw);
491 /* hermes_reset() should return 0 with the secondary firmware */
492 if (image != primsym && ret != 0)
495 /* And this should work with any firmware */
496 if (!hermes_present(hw))
504 * Download the firmware into the card, this also does a PCMCIA soft
505 * reset on the card, to make sure it's in a sane state.
508 spectrum_dl_firmware(hermes_t *hw, dev_link_t *link)
511 client_handle_t handle = link->handle;
512 const struct firmware *fw_entry;
514 if (request_firmware(&fw_entry, primary_fw_name,
515 &handle_to_dev(handle)) == 0) {
516 primsym = fw_entry->data;
518 printk(KERN_ERR PFX "Cannot find firmware: %s\n",
523 if (request_firmware(&fw_entry, secondary_fw_name,
524 &handle_to_dev(handle)) == 0) {
525 secsym = fw_entry->data;
527 printk(KERN_ERR PFX "Cannot find firmware: %s\n",
532 /* Load primary firmware */
533 ret = spectrum_dl_image(hw, link, primsym);
535 printk(KERN_ERR PFX "Primary firmware download failed\n");
539 /* Load secondary firmware */
540 ret = spectrum_dl_image(hw, link, secsym);
543 printk(KERN_ERR PFX "Secondary firmware download failed\n");
549 /********************************************************************/
551 /********************************************************************/
554 spectrum_cs_hard_reset(struct orinoco_private *priv)
556 struct orinoco_pccard *card = priv->card;
557 dev_link_t *link = &card->link;
560 if (!hermes_present(&priv->hw)) {
561 /* The firmware needs to be reloaded */
562 if (spectrum_dl_firmware(&priv->hw, &card->link) != 0) {
563 printk(KERN_ERR PFX "Firmware download failed\n");
567 /* Soft reset using COR and HCR */
568 spectrum_reset(link, 0);
574 /********************************************************************/
576 /********************************************************************/
579 * This creates an "instance" of the driver, allocating local data
580 * structures for one device. The device is registered with Card
583 * The dev_link structure is initialized, but we don't actually
584 * configure the card at this point -- we wait until we receive a card
585 * insertion event. */
587 spectrum_cs_attach(struct pcmcia_device *p_dev)
589 struct net_device *dev;
590 struct orinoco_private *priv;
591 struct orinoco_pccard *card;
594 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset);
597 priv = netdev_priv(dev);
600 /* Link both structures together */
604 /* Interrupt setup */
605 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
606 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
607 link->irq.Handler = orinoco_interrupt;
608 link->irq.Instance = dev;
610 /* General socket configuration defaults can go here. In this
611 * client, we assume very little, and rely on the CIS for
612 * almost everything. In most clients, many details (i.e.,
613 * number, sizes, and attributes of IO windows) are fixed by
614 * the nature of the device, and can be hard-wired here. */
615 link->conf.Attributes = 0;
616 link->conf.IntType = INT_MEMORY_AND_IO;
618 link->handle = p_dev;
619 p_dev->instance = link;
621 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
622 spectrum_cs_config(link);
625 } /* spectrum_cs_attach */
628 * This deletes a driver "instance". The device is de-registered with
629 * Card Services. If it has been released, all local data structures
630 * are freed. Otherwise, the structures will be freed when the device
633 static void spectrum_cs_detach(struct pcmcia_device *p_dev)
635 dev_link_t *link = dev_to_instance(p_dev);
636 struct net_device *dev = link->priv;
638 if (link->state & DEV_CONFIG)
639 spectrum_cs_release(link);
641 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev);
643 DEBUG(0, PFX "About to unregister net device %p\n",
645 unregister_netdev(dev);
647 free_orinocodev(dev);
648 } /* spectrum_cs_detach */
651 * spectrum_cs_config() is scheduled to run after a CARD_INSERTION
652 * event is received, to configure the PCMCIA socket, and to make the
653 * device available to the system.
657 spectrum_cs_config(dev_link_t *link)
659 struct net_device *dev = link->priv;
660 client_handle_t handle = link->handle;
661 struct orinoco_private *priv = netdev_priv(dev);
662 struct orinoco_pccard *card = priv->card;
663 hermes_t *hw = &priv->hw;
664 int last_fn, last_ret;
672 CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info));
675 * This reads the card's CONFIG tuple to find its
676 * configuration registers.
678 tuple.DesiredTuple = CISTPL_CONFIG;
679 tuple.Attributes = 0;
680 tuple.TupleData = buf;
681 tuple.TupleDataMax = sizeof(buf);
682 tuple.TupleOffset = 0;
683 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
684 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
685 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
686 link->conf.ConfigBase = parse.config.base;
687 link->conf.Present = parse.config.rmask[0];
690 link->state |= DEV_CONFIG;
692 /* Look up the current Vcc */
693 CS_CHECK(GetConfigurationInfo,
694 pcmcia_get_configuration_info(handle, &conf));
695 link->conf.Vcc = conf.Vcc;
698 * In this loop, we scan the CIS for configuration table
699 * entries, each of which describes a valid card
700 * configuration, including voltage, IO window, memory window,
701 * and interrupt settings.
703 * We make no assumptions about the card to be configured: we
704 * use just the information available in the CIS. In an ideal
705 * world, this would work for any PCMCIA card, but it requires
706 * a complete and accurate CIS. In practice, a driver usually
707 * "knows" most of these things without consulting the CIS,
708 * and most client drivers will only use the CIS to fill in
709 * implementation-defined details.
711 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
712 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
714 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
715 cistpl_cftable_entry_t dflt = { .index = 0 };
717 if ( (pcmcia_get_tuple_data(handle, &tuple) != 0)
718 || (pcmcia_parse_tuple(handle, &tuple, &parse) != 0))
721 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
725 link->conf.ConfigIndex = cfg->index;
727 /* Does this card need audio output? */
728 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
729 link->conf.Attributes |= CONF_ENABLE_SPKR;
730 link->conf.Status = CCSR_AUDIO_ENA;
733 /* Use power settings for Vcc and Vpp if present */
734 /* Note that the CIS values need to be rescaled */
735 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
736 if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) {
737 DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000);
741 } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
742 if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) {
743 DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, dflt.vcc.param[CISTPL_POWER_VNOM] / 10000);
749 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
750 link->conf.Vpp1 = link->conf.Vpp2 =
751 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
752 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
753 link->conf.Vpp1 = link->conf.Vpp2 =
754 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
756 /* Do we need to allocate an interrupt? */
757 link->conf.Attributes |= CONF_ENABLE_IRQ;
759 /* IO window settings */
760 link->io.NumPorts1 = link->io.NumPorts2 = 0;
761 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
763 (cfg->io.nwin) ? &cfg->io : &dflt.io;
764 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
765 if (!(io->flags & CISTPL_IO_8BIT))
766 link->io.Attributes1 =
767 IO_DATA_PATH_WIDTH_16;
768 if (!(io->flags & CISTPL_IO_16BIT))
769 link->io.Attributes1 =
770 IO_DATA_PATH_WIDTH_8;
771 link->io.IOAddrLines =
772 io->flags & CISTPL_IO_LINES_MASK;
773 link->io.BasePort1 = io->win[0].base;
774 link->io.NumPorts1 = io->win[0].len;
776 link->io.Attributes2 =
777 link->io.Attributes1;
778 link->io.BasePort2 = io->win[1].base;
779 link->io.NumPorts2 = io->win[1].len;
782 /* This reserves IO space but doesn't actually enable it */
783 if (pcmcia_request_io(link->handle, &link->io) != 0)
788 /* If we got this far, we're cool! */
793 if (link->io.NumPorts1)
794 pcmcia_release_io(link->handle, &link->io);
795 last_ret = pcmcia_get_next_tuple(handle, &tuple);
796 if (last_ret == CS_NO_MORE_ITEMS) {
797 printk(KERN_ERR PFX "GetNextTuple(): No matching "
798 "CIS configuration. Maybe you need the "
799 "ignore_cis_vcc=1 parameter.\n");
805 * Allocate an interrupt line. Note that this does not assign
806 * a handler to the interrupt, unless the 'Handler' member of
807 * the irq structure is initialized.
809 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
811 /* We initialize the hermes structure before completing PCMCIA
812 * configuration just in case the interrupt handler gets
814 mem = ioport_map(link->io.BasePort1, link->io.NumPorts1);
818 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
821 * This actually configures the PCMCIA socket -- setting up
822 * the I/O windows and the interrupt mapping, and putting the
823 * card and host interface into "Memory and IO" mode.
825 CS_CHECK(RequestConfiguration,
826 pcmcia_request_configuration(link->handle, &link->conf));
828 /* Ok, we have the configuration, prepare to register the netdev */
829 dev->base_addr = link->io.BasePort1;
830 dev->irq = link->irq.AssignedIRQ;
831 SET_MODULE_OWNER(dev);
832 card->node.major = card->node.minor = 0;
834 /* Reset card and download firmware */
835 if (spectrum_cs_hard_reset(priv) != 0) {
839 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
840 /* Tell the stack we exist */
841 if (register_netdev(dev) != 0) {
842 printk(KERN_ERR PFX "register_netdev() failed\n");
846 /* At this point, the dev_node_t structure(s) needs to be
847 * initialized and arranged in a linked list at link->dev. */
848 strcpy(card->node.dev_name, dev->name);
849 link->dev = &card->node; /* link->dev being non-NULL is also
850 used to indicate that the
851 net_device has been registered */
852 link->state &= ~DEV_CONFIG_PENDING;
854 /* Finally, report what we've done */
855 printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d",
856 dev->name, link->conf.ConfigIndex,
857 link->conf.Vcc / 10, link->conf.Vcc % 10);
859 printk(", Vpp %d.%d", link->conf.Vpp1 / 10,
860 link->conf.Vpp1 % 10);
861 printk(", irq %d", link->irq.AssignedIRQ);
862 if (link->io.NumPorts1)
863 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
864 link->io.BasePort1 + link->io.NumPorts1 - 1);
865 if (link->io.NumPorts2)
866 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
867 link->io.BasePort2 + link->io.NumPorts2 - 1);
873 cs_error(link->handle, last_fn, last_ret);
876 spectrum_cs_release(link);
877 } /* spectrum_cs_config */
880 * After a card is removed, spectrum_cs_release() will unregister the
881 * device, and release the PCMCIA configuration. If the device is
882 * still open, this will be postponed until it is closed.
885 spectrum_cs_release(dev_link_t *link)
887 struct net_device *dev = link->priv;
888 struct orinoco_private *priv = netdev_priv(dev);
891 /* We're committed to taking the device away now, so mark the
892 * hardware as unavailable */
893 spin_lock_irqsave(&priv->lock, flags);
894 priv->hw_unavailable++;
895 spin_unlock_irqrestore(&priv->lock, flags);
897 /* Don't bother checking to see if these succeed or not */
898 pcmcia_release_configuration(link->handle);
899 if (link->io.NumPorts1)
900 pcmcia_release_io(link->handle, &link->io);
901 if (link->irq.AssignedIRQ)
902 pcmcia_release_irq(link->handle, &link->irq);
903 link->state &= ~DEV_CONFIG;
905 ioport_unmap(priv->hw.iobase);
906 } /* spectrum_cs_release */
910 spectrum_cs_suspend(struct pcmcia_device *p_dev)
912 dev_link_t *link = dev_to_instance(p_dev);
913 struct net_device *dev = link->priv;
914 struct orinoco_private *priv = netdev_priv(dev);
918 link->state |= DEV_SUSPEND;
919 /* Mark the device as stopped, to block IO until later */
920 if (link->state & DEV_CONFIG) {
921 spin_lock_irqsave(&priv->lock, flags);
923 err = __orinoco_down(dev);
925 printk(KERN_WARNING "%s: Error %d downing interface\n",
928 netif_device_detach(dev);
929 priv->hw_unavailable++;
931 spin_unlock_irqrestore(&priv->lock, flags);
933 pcmcia_release_configuration(link->handle);
940 spectrum_cs_resume(struct pcmcia_device *p_dev)
942 dev_link_t *link = dev_to_instance(p_dev);
943 struct net_device *dev = link->priv;
944 struct orinoco_private *priv = netdev_priv(dev);
946 link->state &= ~DEV_SUSPEND;
947 if (link->state & DEV_CONFIG) {
948 /* FIXME: should we double check that this is
949 * the same card as we had before */
950 pcmcia_request_configuration(link->handle, &link->conf);
951 netif_device_attach(dev);
952 priv->hw_unavailable--;
953 schedule_work(&priv->reset_work);
959 /********************************************************************/
960 /* Module initialization */
961 /********************************************************************/
963 /* Can't be declared "const" or the whole __initdata section will
965 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
966 " (Pavel Roskin <proski@gnu.org>,"
967 " David Gibson <hermes@gibson.dropbear.id.au>, et al)";
969 static struct pcmcia_device_id spectrum_cs_ids[] = {
970 PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4100 */
971 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */
972 PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */
975 MODULE_DEVICE_TABLE(pcmcia, spectrum_cs_ids);
977 static struct pcmcia_driver orinoco_driver = {
978 .owner = THIS_MODULE,
982 .probe = spectrum_cs_attach,
983 .remove = spectrum_cs_detach,
984 .suspend = spectrum_cs_suspend,
985 .resume = spectrum_cs_resume,
986 .id_table = spectrum_cs_ids,
990 init_spectrum_cs(void)
992 printk(KERN_DEBUG "%s\n", version);
994 return pcmcia_register_driver(&orinoco_driver);
998 exit_spectrum_cs(void)
1000 pcmcia_unregister_driver(&orinoco_driver);
1003 module_init(init_spectrum_cs);
1004 module_exit(exit_spectrum_cs);