Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 1 | /* |
| 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. |
| 5 | * |
| 6 | * The driver implements Symbol firmware download. The rest is handled |
| 7 | * in hermes.c and orinoco.c. |
| 8 | * |
| 9 | * Utilities for downloading the Symbol firmware are available at |
| 10 | * http://sourceforge.net/projects/orinoco/ |
| 11 | * |
| 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. |
| 17 | * |
| 18 | * See copyright notice in file orinoco.c. |
| 19 | */ |
| 20 | |
| 21 | #define DRIVER_NAME "spectrum_cs" |
| 22 | #define PFX DRIVER_NAME ": " |
| 23 | |
| 24 | #include <linux/config.h> |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 25 | #include <linux/module.h> |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/init.h> |
Pavel Roskin | ef846bf | 2005-09-23 04:18:07 -0400 | [diff] [blame] | 28 | #include <linux/delay.h> |
Pavel Roskin | 65853b1 | 2005-09-16 02:15:13 -0400 | [diff] [blame] | 29 | #include <linux/firmware.h> |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 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> |
| 35 | |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 36 | #include "orinoco.h" |
| 37 | |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 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"; |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 42 | |
| 43 | /********************************************************************/ |
| 44 | /* Module stuff */ |
| 45 | /********************************************************************/ |
| 46 | |
| 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"); |
| 50 | |
| 51 | /* Module parameters */ |
| 52 | |
| 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"); |
| 58 | |
| 59 | /********************************************************************/ |
| 60 | /* Magic constants */ |
| 61 | /********************************************************************/ |
| 62 | |
| 63 | /* |
| 64 | * The dev_info variable is the "key" that is used to match up this |
| 65 | * device driver with appropriate cards, through the card |
| 66 | * configuration database. |
| 67 | */ |
| 68 | static dev_info_t dev_info = DRIVER_NAME; |
| 69 | |
| 70 | /********************************************************************/ |
| 71 | /* Data structures */ |
| 72 | /********************************************************************/ |
| 73 | |
| 74 | /* PCMCIA specific device information (goes in the card field of |
| 75 | * struct orinoco_private */ |
| 76 | struct orinoco_pccard { |
| 77 | dev_link_t link; |
| 78 | dev_node_t node; |
| 79 | }; |
| 80 | |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 81 | /********************************************************************/ |
| 82 | /* Function prototypes */ |
| 83 | /********************************************************************/ |
| 84 | |
Pavel Roskin | 393da59 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 85 | static void spectrum_cs_release(dev_link_t *link); |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 86 | static void spectrum_cs_detach(struct pcmcia_device *p_dev); |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 87 | |
| 88 | /********************************************************************/ |
| 89 | /* Firmware downloader */ |
| 90 | /********************************************************************/ |
| 91 | |
| 92 | /* Position of PDA in the adapter memory */ |
| 93 | #define EEPROM_ADDR 0x3000 |
| 94 | #define EEPROM_LEN 0x200 |
| 95 | #define PDA_OFFSET 0x100 |
| 96 | |
| 97 | #define PDA_ADDR (EEPROM_ADDR + PDA_OFFSET) |
| 98 | #define PDA_WORDS ((EEPROM_LEN - PDA_OFFSET) / 2) |
| 99 | |
| 100 | /* Constants for the CISREG_CCSR register */ |
| 101 | #define HCR_RUN 0x07 /* run firmware after reset */ |
| 102 | #define HCR_IDLE 0x0E /* don't run firmware after reset */ |
| 103 | #define HCR_MEM16 0x10 /* memory width bit, should be preserved */ |
| 104 | |
| 105 | /* |
| 106 | * AUX port access. To unlock the AUX port write the access keys to the |
| 107 | * PARAM0-2 registers, then write HERMES_AUX_ENABLE to the HERMES_CONTROL |
| 108 | * register. Then read it and make sure it's HERMES_AUX_ENABLED. |
| 109 | */ |
| 110 | #define HERMES_AUX_ENABLE 0x8000 /* Enable auxiliary port access */ |
| 111 | #define HERMES_AUX_DISABLE 0x4000 /* Disable to auxiliary port access */ |
| 112 | #define HERMES_AUX_ENABLED 0xC000 /* Auxiliary port is open */ |
| 113 | |
| 114 | #define HERMES_AUX_PW0 0xFE01 |
| 115 | #define HERMES_AUX_PW1 0xDC23 |
| 116 | #define HERMES_AUX_PW2 0xBA45 |
| 117 | |
| 118 | /* End markers */ |
| 119 | #define PDI_END 0x00000000 /* End of PDA */ |
| 120 | #define BLOCK_END 0xFFFFFFFF /* Last image block */ |
| 121 | #define TEXT_END 0x1A /* End of text header */ |
| 122 | |
| 123 | /* |
| 124 | * The following structures have little-endian fields denoted by |
| 125 | * the leading underscore. Don't access them directly - use inline |
| 126 | * functions defined below. |
| 127 | */ |
| 128 | |
| 129 | /* |
| 130 | * The binary image to be downloaded consists of series of data blocks. |
| 131 | * Each block has the following structure. |
| 132 | */ |
| 133 | struct dblock { |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 134 | __le32 _addr; /* adapter address where to write the block */ |
| 135 | __le16 _len; /* length of the data only, in bytes */ |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 136 | char data[0]; /* data to be written */ |
| 137 | } __attribute__ ((packed)); |
| 138 | |
| 139 | /* |
| 140 | * Plug Data References are located in in the image after the last data |
| 141 | * block. They refer to areas in the adapter memory where the plug data |
| 142 | * items with matching ID should be written. |
| 143 | */ |
| 144 | struct pdr { |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 145 | __le32 _id; /* record ID */ |
| 146 | __le32 _addr; /* adapter address where to write the data */ |
| 147 | __le32 _len; /* expected length of the data, in bytes */ |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 148 | char next[0]; /* next PDR starts here */ |
| 149 | } __attribute__ ((packed)); |
| 150 | |
| 151 | |
| 152 | /* |
| 153 | * Plug Data Items are located in the EEPROM read from the adapter by |
| 154 | * primary firmware. They refer to the device-specific data that should |
| 155 | * be plugged into the secondary firmware. |
| 156 | */ |
| 157 | struct pdi { |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 158 | __le16 _len; /* length of ID and data, in words */ |
| 159 | __le16 _id; /* record ID */ |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 160 | char data[0]; /* plug data */ |
| 161 | } __attribute__ ((packed));; |
| 162 | |
| 163 | |
| 164 | /* Functions for access to little-endian data */ |
| 165 | static inline u32 |
| 166 | dblock_addr(const struct dblock *blk) |
| 167 | { |
| 168 | return le32_to_cpu(blk->_addr); |
| 169 | } |
| 170 | |
| 171 | static inline u32 |
| 172 | dblock_len(const struct dblock *blk) |
| 173 | { |
| 174 | return le16_to_cpu(blk->_len); |
| 175 | } |
| 176 | |
| 177 | static inline u32 |
| 178 | pdr_id(const struct pdr *pdr) |
| 179 | { |
| 180 | return le32_to_cpu(pdr->_id); |
| 181 | } |
| 182 | |
| 183 | static inline u32 |
| 184 | pdr_addr(const struct pdr *pdr) |
| 185 | { |
| 186 | return le32_to_cpu(pdr->_addr); |
| 187 | } |
| 188 | |
| 189 | static inline u32 |
| 190 | pdr_len(const struct pdr *pdr) |
| 191 | { |
| 192 | return le32_to_cpu(pdr->_len); |
| 193 | } |
| 194 | |
| 195 | static inline u32 |
| 196 | pdi_id(const struct pdi *pdi) |
| 197 | { |
| 198 | return le16_to_cpu(pdi->_id); |
| 199 | } |
| 200 | |
| 201 | /* Return length of the data only, in bytes */ |
| 202 | static inline u32 |
| 203 | pdi_len(const struct pdi *pdi) |
| 204 | { |
| 205 | return 2 * (le16_to_cpu(pdi->_len) - 1); |
| 206 | } |
| 207 | |
| 208 | |
| 209 | /* Set address of the auxiliary port */ |
| 210 | static inline void |
| 211 | spectrum_aux_setaddr(hermes_t *hw, u32 addr) |
| 212 | { |
| 213 | hermes_write_reg(hw, HERMES_AUXPAGE, (u16) (addr >> 7)); |
| 214 | hermes_write_reg(hw, HERMES_AUXOFFSET, (u16) (addr & 0x7F)); |
| 215 | } |
| 216 | |
| 217 | |
| 218 | /* Open access to the auxiliary port */ |
| 219 | static int |
| 220 | spectrum_aux_open(hermes_t *hw) |
| 221 | { |
| 222 | int i; |
| 223 | |
| 224 | /* Already open? */ |
| 225 | if (hermes_read_reg(hw, HERMES_CONTROL) == HERMES_AUX_ENABLED) |
| 226 | return 0; |
| 227 | |
| 228 | hermes_write_reg(hw, HERMES_PARAM0, HERMES_AUX_PW0); |
| 229 | hermes_write_reg(hw, HERMES_PARAM1, HERMES_AUX_PW1); |
| 230 | hermes_write_reg(hw, HERMES_PARAM2, HERMES_AUX_PW2); |
| 231 | hermes_write_reg(hw, HERMES_CONTROL, HERMES_AUX_ENABLE); |
| 232 | |
| 233 | for (i = 0; i < 20; i++) { |
| 234 | udelay(10); |
| 235 | if (hermes_read_reg(hw, HERMES_CONTROL) == |
| 236 | HERMES_AUX_ENABLED) |
| 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | return -EBUSY; |
| 241 | } |
| 242 | |
| 243 | |
| 244 | #define CS_CHECK(fn, ret) \ |
| 245 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
| 246 | |
| 247 | /* |
| 248 | * Reset the card using configuration registers COR and CCSR. |
| 249 | * If IDLE is 1, stop the firmware, so that it can be safely rewritten. |
| 250 | */ |
| 251 | static int |
| 252 | spectrum_reset(dev_link_t *link, int idle) |
| 253 | { |
| 254 | int last_ret, last_fn; |
| 255 | conf_reg_t reg; |
| 256 | u_int save_cor; |
| 257 | |
| 258 | /* Doing it if hardware is gone is guaranteed crash */ |
| 259 | if (!(link->state & DEV_CONFIG)) |
| 260 | return -ENODEV; |
| 261 | |
| 262 | /* Save original COR value */ |
| 263 | reg.Function = 0; |
| 264 | reg.Action = CS_READ; |
| 265 | reg.Offset = CISREG_COR; |
| 266 | CS_CHECK(AccessConfigurationRegister, |
| 267 | pcmcia_access_configuration_register(link->handle, ®)); |
| 268 | save_cor = reg.Value; |
| 269 | |
| 270 | /* Soft-Reset card */ |
| 271 | reg.Action = CS_WRITE; |
| 272 | reg.Offset = CISREG_COR; |
| 273 | reg.Value = (save_cor | COR_SOFT_RESET); |
| 274 | CS_CHECK(AccessConfigurationRegister, |
| 275 | pcmcia_access_configuration_register(link->handle, ®)); |
| 276 | udelay(1000); |
| 277 | |
| 278 | /* Read CCSR */ |
| 279 | reg.Action = CS_READ; |
| 280 | reg.Offset = CISREG_CCSR; |
| 281 | CS_CHECK(AccessConfigurationRegister, |
| 282 | pcmcia_access_configuration_register(link->handle, ®)); |
| 283 | |
| 284 | /* |
| 285 | * Start or stop the firmware. Memory width bit should be |
| 286 | * preserved from the value we've just read. |
| 287 | */ |
| 288 | reg.Action = CS_WRITE; |
| 289 | reg.Offset = CISREG_CCSR; |
| 290 | reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16); |
| 291 | CS_CHECK(AccessConfigurationRegister, |
| 292 | pcmcia_access_configuration_register(link->handle, ®)); |
| 293 | udelay(1000); |
| 294 | |
| 295 | /* Restore original COR configuration index */ |
| 296 | reg.Action = CS_WRITE; |
| 297 | reg.Offset = CISREG_COR; |
| 298 | reg.Value = (save_cor & ~COR_SOFT_RESET); |
| 299 | CS_CHECK(AccessConfigurationRegister, |
| 300 | pcmcia_access_configuration_register(link->handle, ®)); |
| 301 | udelay(1000); |
| 302 | return 0; |
| 303 | |
| 304 | cs_failed: |
| 305 | cs_error(link->handle, last_fn, last_ret); |
| 306 | return -ENODEV; |
| 307 | } |
| 308 | |
| 309 | |
| 310 | /* |
| 311 | * Scan PDR for the record with the specified RECORD_ID. |
| 312 | * If it's not found, return NULL. |
| 313 | */ |
| 314 | static struct pdr * |
| 315 | spectrum_find_pdr(struct pdr *first_pdr, u32 record_id) |
| 316 | { |
| 317 | struct pdr *pdr = first_pdr; |
| 318 | |
| 319 | while (pdr_id(pdr) != PDI_END) { |
| 320 | /* |
| 321 | * PDR area is currently not terminated by PDI_END. |
| 322 | * It's followed by CRC records, which have the type |
| 323 | * field where PDR has length. The type can be 0 or 1. |
| 324 | */ |
| 325 | if (pdr_len(pdr) < 2) |
| 326 | return NULL; |
| 327 | |
| 328 | /* If the record ID matches, we are done */ |
| 329 | if (pdr_id(pdr) == record_id) |
| 330 | return pdr; |
| 331 | |
| 332 | pdr = (struct pdr *) pdr->next; |
| 333 | } |
| 334 | return NULL; |
| 335 | } |
| 336 | |
| 337 | |
| 338 | /* Process one Plug Data Item - find corresponding PDR and plug it */ |
| 339 | static int |
| 340 | spectrum_plug_pdi(hermes_t *hw, struct pdr *first_pdr, struct pdi *pdi) |
| 341 | { |
| 342 | struct pdr *pdr; |
| 343 | |
| 344 | /* Find the PDI corresponding to this PDR */ |
| 345 | pdr = spectrum_find_pdr(first_pdr, pdi_id(pdi)); |
| 346 | |
| 347 | /* No match is found, safe to ignore */ |
| 348 | if (!pdr) |
| 349 | return 0; |
| 350 | |
| 351 | /* Lengths of the data in PDI and PDR must match */ |
| 352 | if (pdi_len(pdi) != pdr_len(pdr)) |
| 353 | return -EINVAL; |
| 354 | |
| 355 | /* do the actual plugging */ |
| 356 | spectrum_aux_setaddr(hw, pdr_addr(pdr)); |
| 357 | hermes_write_words(hw, HERMES_AUXDATA, pdi->data, |
| 358 | pdi_len(pdi) / 2); |
| 359 | |
| 360 | return 0; |
| 361 | } |
| 362 | |
| 363 | |
| 364 | /* Read PDA from the adapter */ |
| 365 | static int |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 366 | spectrum_read_pda(hermes_t *hw, __le16 *pda, int pda_len) |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 367 | { |
| 368 | int ret; |
| 369 | int pda_size; |
| 370 | |
| 371 | /* Issue command to read EEPROM */ |
| 372 | ret = hermes_docmd_wait(hw, HERMES_CMD_READMIF, 0, NULL); |
| 373 | if (ret) |
| 374 | return ret; |
| 375 | |
| 376 | /* Open auxiliary port */ |
| 377 | ret = spectrum_aux_open(hw); |
| 378 | if (ret) |
| 379 | return ret; |
| 380 | |
| 381 | /* read PDA from EEPROM */ |
| 382 | spectrum_aux_setaddr(hw, PDA_ADDR); |
| 383 | hermes_read_words(hw, HERMES_AUXDATA, pda, pda_len / 2); |
| 384 | |
| 385 | /* Check PDA length */ |
| 386 | pda_size = le16_to_cpu(pda[0]); |
| 387 | if (pda_size > pda_len) |
| 388 | return -EINVAL; |
| 389 | |
| 390 | return 0; |
| 391 | } |
| 392 | |
| 393 | |
| 394 | /* Parse PDA and write the records into the adapter */ |
| 395 | static int |
| 396 | spectrum_apply_pda(hermes_t *hw, const struct dblock *first_block, |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 397 | __le16 *pda) |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 398 | { |
| 399 | int ret; |
| 400 | struct pdi *pdi; |
| 401 | struct pdr *first_pdr; |
| 402 | const struct dblock *blk = first_block; |
| 403 | |
| 404 | /* Skip all blocks to locate Plug Data References */ |
| 405 | while (dblock_addr(blk) != BLOCK_END) |
| 406 | blk = (struct dblock *) &blk->data[dblock_len(blk)]; |
| 407 | |
| 408 | first_pdr = (struct pdr *) blk; |
| 409 | |
| 410 | /* Go through every PDI and plug them into the adapter */ |
| 411 | pdi = (struct pdi *) (pda + 2); |
| 412 | while (pdi_id(pdi) != PDI_END) { |
| 413 | ret = spectrum_plug_pdi(hw, first_pdr, pdi); |
| 414 | if (ret) |
| 415 | return ret; |
| 416 | |
| 417 | /* Increment to the next PDI */ |
| 418 | pdi = (struct pdi *) &pdi->data[pdi_len(pdi)]; |
| 419 | } |
| 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | |
| 424 | /* Load firmware blocks into the adapter */ |
| 425 | static int |
| 426 | spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block) |
| 427 | { |
| 428 | const struct dblock *blk; |
| 429 | u32 blkaddr; |
| 430 | u32 blklen; |
| 431 | |
| 432 | blk = first_block; |
| 433 | blkaddr = dblock_addr(blk); |
| 434 | blklen = dblock_len(blk); |
| 435 | |
| 436 | while (dblock_addr(blk) != BLOCK_END) { |
| 437 | spectrum_aux_setaddr(hw, blkaddr); |
| 438 | hermes_write_words(hw, HERMES_AUXDATA, blk->data, |
| 439 | blklen / 2); |
| 440 | |
| 441 | blk = (struct dblock *) &blk->data[blklen]; |
| 442 | blkaddr = dblock_addr(blk); |
| 443 | blklen = dblock_len(blk); |
| 444 | } |
| 445 | return 0; |
| 446 | } |
| 447 | |
| 448 | |
| 449 | /* |
| 450 | * Process a firmware image - stop the card, load the firmware, reset |
| 451 | * the card and make sure it responds. For the secondary firmware take |
| 452 | * care of the PDA - read it and then write it on top of the firmware. |
| 453 | */ |
| 454 | static int |
| 455 | spectrum_dl_image(hermes_t *hw, dev_link_t *link, |
| 456 | const unsigned char *image) |
| 457 | { |
| 458 | int ret; |
| 459 | const unsigned char *ptr; |
| 460 | const struct dblock *first_block; |
| 461 | |
| 462 | /* Plug Data Area (PDA) */ |
Pavel Roskin | d133ae4 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 463 | __le16 pda[PDA_WORDS]; |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 464 | |
| 465 | /* Binary block begins after the 0x1A marker */ |
| 466 | ptr = image; |
| 467 | while (*ptr++ != TEXT_END); |
| 468 | first_block = (const struct dblock *) ptr; |
| 469 | |
| 470 | /* Read the PDA */ |
| 471 | if (image != primsym) { |
| 472 | ret = spectrum_read_pda(hw, pda, sizeof(pda)); |
| 473 | if (ret) |
| 474 | return ret; |
| 475 | } |
| 476 | |
| 477 | /* Stop the firmware, so that it can be safely rewritten */ |
| 478 | ret = spectrum_reset(link, 1); |
| 479 | if (ret) |
| 480 | return ret; |
| 481 | |
| 482 | /* Program the adapter with new firmware */ |
| 483 | ret = spectrum_load_blocks(hw, first_block); |
| 484 | if (ret) |
| 485 | return ret; |
| 486 | |
| 487 | /* Write the PDA to the adapter */ |
| 488 | if (image != primsym) { |
| 489 | ret = spectrum_apply_pda(hw, first_block, pda); |
| 490 | if (ret) |
| 491 | return ret; |
| 492 | } |
| 493 | |
| 494 | /* Run the firmware */ |
| 495 | ret = spectrum_reset(link, 0); |
| 496 | if (ret) |
| 497 | return ret; |
| 498 | |
| 499 | /* Reset hermes chip and make sure it responds */ |
| 500 | ret = hermes_init(hw); |
| 501 | |
| 502 | /* hermes_reset() should return 0 with the secondary firmware */ |
| 503 | if (image != primsym && ret != 0) |
| 504 | return -ENODEV; |
| 505 | |
| 506 | /* And this should work with any firmware */ |
| 507 | if (!hermes_present(hw)) |
| 508 | return -ENODEV; |
| 509 | |
| 510 | return 0; |
| 511 | } |
| 512 | |
| 513 | |
| 514 | /* |
| 515 | * Download the firmware into the card, this also does a PCMCIA soft |
| 516 | * reset on the card, to make sure it's in a sane state. |
| 517 | */ |
| 518 | static int |
| 519 | spectrum_dl_firmware(hermes_t *hw, dev_link_t *link) |
| 520 | { |
| 521 | int ret; |
| 522 | client_handle_t handle = link->handle; |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 523 | const struct firmware *fw_entry; |
| 524 | |
| 525 | if (request_firmware(&fw_entry, primary_fw_name, |
| 526 | &handle_to_dev(handle)) == 0) { |
| 527 | primsym = fw_entry->data; |
| 528 | } else { |
| 529 | printk(KERN_ERR PFX "Cannot find firmware: %s\n", |
| 530 | primary_fw_name); |
| 531 | return -ENOENT; |
| 532 | } |
| 533 | |
| 534 | if (request_firmware(&fw_entry, secondary_fw_name, |
| 535 | &handle_to_dev(handle)) == 0) { |
| 536 | secsym = fw_entry->data; |
| 537 | } else { |
| 538 | printk(KERN_ERR PFX "Cannot find firmware: %s\n", |
| 539 | secondary_fw_name); |
| 540 | return -ENOENT; |
| 541 | } |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 542 | |
| 543 | /* Load primary firmware */ |
| 544 | ret = spectrum_dl_image(hw, link, primsym); |
| 545 | if (ret) { |
| 546 | printk(KERN_ERR PFX "Primary firmware download failed\n"); |
| 547 | return ret; |
| 548 | } |
| 549 | |
| 550 | /* Load secondary firmware */ |
| 551 | ret = spectrum_dl_image(hw, link, secsym); |
| 552 | |
| 553 | if (ret) { |
| 554 | printk(KERN_ERR PFX "Secondary firmware download failed\n"); |
| 555 | } |
| 556 | |
| 557 | return ret; |
| 558 | } |
| 559 | |
| 560 | /********************************************************************/ |
| 561 | /* Device methods */ |
| 562 | /********************************************************************/ |
| 563 | |
| 564 | static int |
| 565 | spectrum_cs_hard_reset(struct orinoco_private *priv) |
| 566 | { |
| 567 | struct orinoco_pccard *card = priv->card; |
| 568 | dev_link_t *link = &card->link; |
| 569 | int err; |
| 570 | |
| 571 | if (!hermes_present(&priv->hw)) { |
| 572 | /* The firmware needs to be reloaded */ |
| 573 | if (spectrum_dl_firmware(&priv->hw, &card->link) != 0) { |
| 574 | printk(KERN_ERR PFX "Firmware download failed\n"); |
| 575 | err = -ENODEV; |
| 576 | } |
| 577 | } else { |
| 578 | /* Soft reset using COR and HCR */ |
| 579 | spectrum_reset(link, 0); |
| 580 | } |
| 581 | |
| 582 | return 0; |
| 583 | } |
| 584 | |
| 585 | /********************************************************************/ |
| 586 | /* PCMCIA stuff */ |
| 587 | /********************************************************************/ |
| 588 | |
| 589 | /* |
| 590 | * This creates an "instance" of the driver, allocating local data |
| 591 | * structures for one device. The device is registered with Card |
| 592 | * Services. |
| 593 | * |
| 594 | * The dev_link structure is initialized, but we don't actually |
| 595 | * configure the card at this point -- we wait until we receive a card |
| 596 | * insertion event. */ |
| 597 | static dev_link_t * |
| 598 | spectrum_cs_attach(void) |
| 599 | { |
| 600 | struct net_device *dev; |
| 601 | struct orinoco_private *priv; |
| 602 | struct orinoco_pccard *card; |
| 603 | dev_link_t *link; |
| 604 | client_reg_t client_reg; |
| 605 | int ret; |
| 606 | |
| 607 | dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); |
| 608 | if (! dev) |
| 609 | return NULL; |
| 610 | priv = netdev_priv(dev); |
| 611 | card = priv->card; |
| 612 | |
| 613 | /* Link both structures together */ |
| 614 | link = &card->link; |
| 615 | link->priv = dev; |
| 616 | |
| 617 | /* Interrupt setup */ |
| 618 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; |
| 619 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
| 620 | link->irq.Handler = orinoco_interrupt; |
| 621 | link->irq.Instance = dev; |
| 622 | |
| 623 | /* General socket configuration defaults can go here. In this |
| 624 | * client, we assume very little, and rely on the CIS for |
| 625 | * almost everything. In most clients, many details (i.e., |
| 626 | * number, sizes, and attributes of IO windows) are fixed by |
| 627 | * the nature of the device, and can be hard-wired here. */ |
| 628 | link->conf.Attributes = 0; |
| 629 | link->conf.IntType = INT_MEMORY_AND_IO; |
| 630 | |
| 631 | /* Register with Card Services */ |
| 632 | /* FIXME: need a lock? */ |
Dominik Brodowski | b463581 | 2005-11-14 21:25:35 +0100 | [diff] [blame^] | 633 | link->next = NULL; /* not needed */ |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 634 | |
| 635 | client_reg.dev_info = &dev_info; |
| 636 | client_reg.Version = 0x0210; /* FIXME: what does this mean? */ |
| 637 | client_reg.event_callback_args.client_data = link; |
| 638 | |
| 639 | ret = pcmcia_register_client(&link->handle, &client_reg); |
| 640 | if (ret != CS_SUCCESS) { |
| 641 | cs_error(link->handle, RegisterClient, ret); |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 642 | spectrum_cs_detach(link->handle); |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 643 | return NULL; |
| 644 | } |
| 645 | |
| 646 | return link; |
| 647 | } /* spectrum_cs_attach */ |
| 648 | |
| 649 | /* |
| 650 | * This deletes a driver "instance". The device is de-registered with |
| 651 | * Card Services. If it has been released, all local data structures |
| 652 | * are freed. Otherwise, the structures will be freed when the device |
| 653 | * is released. |
| 654 | */ |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 655 | static void spectrum_cs_detach(struct pcmcia_device *p_dev) |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 656 | { |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 657 | dev_link_t *link = dev_to_instance(p_dev); |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 658 | struct net_device *dev = link->priv; |
| 659 | |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 660 | if (link->state & DEV_CONFIG) |
| 661 | spectrum_cs_release(link); |
| 662 | |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 663 | DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); |
| 664 | if (link->dev) { |
| 665 | DEBUG(0, PFX "About to unregister net device %p\n", |
| 666 | dev); |
| 667 | unregister_netdev(dev); |
| 668 | } |
| 669 | free_orinocodev(dev); |
| 670 | } /* spectrum_cs_detach */ |
| 671 | |
| 672 | /* |
| 673 | * spectrum_cs_config() is scheduled to run after a CARD_INSERTION |
| 674 | * event is received, to configure the PCMCIA socket, and to make the |
| 675 | * device available to the system. |
| 676 | */ |
| 677 | |
| 678 | static void |
| 679 | spectrum_cs_config(dev_link_t *link) |
| 680 | { |
| 681 | struct net_device *dev = link->priv; |
| 682 | client_handle_t handle = link->handle; |
| 683 | struct orinoco_private *priv = netdev_priv(dev); |
| 684 | struct orinoco_pccard *card = priv->card; |
| 685 | hermes_t *hw = &priv->hw; |
| 686 | int last_fn, last_ret; |
| 687 | u_char buf[64]; |
| 688 | config_info_t conf; |
| 689 | cisinfo_t info; |
| 690 | tuple_t tuple; |
| 691 | cisparse_t parse; |
| 692 | void __iomem *mem; |
| 693 | |
| 694 | CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info)); |
| 695 | |
| 696 | /* |
| 697 | * This reads the card's CONFIG tuple to find its |
| 698 | * configuration registers. |
| 699 | */ |
| 700 | tuple.DesiredTuple = CISTPL_CONFIG; |
| 701 | tuple.Attributes = 0; |
| 702 | tuple.TupleData = buf; |
| 703 | tuple.TupleDataMax = sizeof(buf); |
| 704 | tuple.TupleOffset = 0; |
| 705 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); |
| 706 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); |
| 707 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); |
| 708 | link->conf.ConfigBase = parse.config.base; |
| 709 | link->conf.Present = parse.config.rmask[0]; |
| 710 | |
| 711 | /* Configure card */ |
| 712 | link->state |= DEV_CONFIG; |
| 713 | |
| 714 | /* Look up the current Vcc */ |
| 715 | CS_CHECK(GetConfigurationInfo, |
| 716 | pcmcia_get_configuration_info(handle, &conf)); |
| 717 | link->conf.Vcc = conf.Vcc; |
| 718 | |
| 719 | /* |
| 720 | * In this loop, we scan the CIS for configuration table |
| 721 | * entries, each of which describes a valid card |
| 722 | * configuration, including voltage, IO window, memory window, |
| 723 | * and interrupt settings. |
| 724 | * |
| 725 | * We make no assumptions about the card to be configured: we |
| 726 | * use just the information available in the CIS. In an ideal |
| 727 | * world, this would work for any PCMCIA card, but it requires |
| 728 | * a complete and accurate CIS. In practice, a driver usually |
| 729 | * "knows" most of these things without consulting the CIS, |
| 730 | * and most client drivers will only use the CIS to fill in |
| 731 | * implementation-defined details. |
| 732 | */ |
| 733 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
| 734 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); |
| 735 | while (1) { |
| 736 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); |
| 737 | cistpl_cftable_entry_t dflt = { .index = 0 }; |
| 738 | |
| 739 | if ( (pcmcia_get_tuple_data(handle, &tuple) != 0) |
| 740 | || (pcmcia_parse_tuple(handle, &tuple, &parse) != 0)) |
| 741 | goto next_entry; |
| 742 | |
| 743 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) |
| 744 | dflt = *cfg; |
| 745 | if (cfg->index == 0) |
| 746 | goto next_entry; |
| 747 | link->conf.ConfigIndex = cfg->index; |
| 748 | |
| 749 | /* Does this card need audio output? */ |
| 750 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { |
| 751 | link->conf.Attributes |= CONF_ENABLE_SPKR; |
| 752 | link->conf.Status = CCSR_AUDIO_ENA; |
| 753 | } |
| 754 | |
| 755 | /* Use power settings for Vcc and Vpp if present */ |
| 756 | /* Note that the CIS values need to be rescaled */ |
| 757 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { |
| 758 | if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { |
| 759 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); |
| 760 | if (!ignore_cis_vcc) |
| 761 | goto next_entry; |
| 762 | } |
| 763 | } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { |
| 764 | if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) { |
| 765 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); |
| 766 | if(!ignore_cis_vcc) |
| 767 | goto next_entry; |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
| 772 | link->conf.Vpp1 = link->conf.Vpp2 = |
| 773 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
| 774 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) |
| 775 | link->conf.Vpp1 = link->conf.Vpp2 = |
| 776 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; |
| 777 | |
| 778 | /* Do we need to allocate an interrupt? */ |
| 779 | link->conf.Attributes |= CONF_ENABLE_IRQ; |
| 780 | |
| 781 | /* IO window settings */ |
| 782 | link->io.NumPorts1 = link->io.NumPorts2 = 0; |
| 783 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { |
| 784 | cistpl_io_t *io = |
| 785 | (cfg->io.nwin) ? &cfg->io : &dflt.io; |
| 786 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
| 787 | if (!(io->flags & CISTPL_IO_8BIT)) |
| 788 | link->io.Attributes1 = |
| 789 | IO_DATA_PATH_WIDTH_16; |
| 790 | if (!(io->flags & CISTPL_IO_16BIT)) |
| 791 | link->io.Attributes1 = |
| 792 | IO_DATA_PATH_WIDTH_8; |
| 793 | link->io.IOAddrLines = |
| 794 | io->flags & CISTPL_IO_LINES_MASK; |
| 795 | link->io.BasePort1 = io->win[0].base; |
| 796 | link->io.NumPorts1 = io->win[0].len; |
| 797 | if (io->nwin > 1) { |
| 798 | link->io.Attributes2 = |
| 799 | link->io.Attributes1; |
| 800 | link->io.BasePort2 = io->win[1].base; |
| 801 | link->io.NumPorts2 = io->win[1].len; |
| 802 | } |
| 803 | |
| 804 | /* This reserves IO space but doesn't actually enable it */ |
| 805 | if (pcmcia_request_io(link->handle, &link->io) != 0) |
| 806 | goto next_entry; |
| 807 | } |
| 808 | |
| 809 | |
| 810 | /* If we got this far, we're cool! */ |
| 811 | |
| 812 | break; |
| 813 | |
| 814 | next_entry: |
| 815 | if (link->io.NumPorts1) |
| 816 | pcmcia_release_io(link->handle, &link->io); |
| 817 | last_ret = pcmcia_get_next_tuple(handle, &tuple); |
| 818 | if (last_ret == CS_NO_MORE_ITEMS) { |
| 819 | printk(KERN_ERR PFX "GetNextTuple(): No matching " |
| 820 | "CIS configuration. Maybe you need the " |
| 821 | "ignore_cis_vcc=1 parameter.\n"); |
| 822 | goto cs_failed; |
| 823 | } |
| 824 | } |
| 825 | |
| 826 | /* |
| 827 | * Allocate an interrupt line. Note that this does not assign |
| 828 | * a handler to the interrupt, unless the 'Handler' member of |
| 829 | * the irq structure is initialized. |
| 830 | */ |
| 831 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); |
| 832 | |
| 833 | /* We initialize the hermes structure before completing PCMCIA |
| 834 | * configuration just in case the interrupt handler gets |
| 835 | * called. */ |
| 836 | mem = ioport_map(link->io.BasePort1, link->io.NumPorts1); |
| 837 | if (!mem) |
| 838 | goto cs_failed; |
| 839 | |
| 840 | hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); |
| 841 | |
| 842 | /* |
| 843 | * This actually configures the PCMCIA socket -- setting up |
| 844 | * the I/O windows and the interrupt mapping, and putting the |
| 845 | * card and host interface into "Memory and IO" mode. |
| 846 | */ |
| 847 | CS_CHECK(RequestConfiguration, |
| 848 | pcmcia_request_configuration(link->handle, &link->conf)); |
| 849 | |
| 850 | /* Ok, we have the configuration, prepare to register the netdev */ |
| 851 | dev->base_addr = link->io.BasePort1; |
| 852 | dev->irq = link->irq.AssignedIRQ; |
| 853 | SET_MODULE_OWNER(dev); |
| 854 | card->node.major = card->node.minor = 0; |
| 855 | |
| 856 | /* Reset card and download firmware */ |
| 857 | if (spectrum_cs_hard_reset(priv) != 0) { |
| 858 | goto failed; |
| 859 | } |
| 860 | |
| 861 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); |
| 862 | /* Tell the stack we exist */ |
| 863 | if (register_netdev(dev) != 0) { |
| 864 | printk(KERN_ERR PFX "register_netdev() failed\n"); |
| 865 | goto failed; |
| 866 | } |
| 867 | |
| 868 | /* At this point, the dev_node_t structure(s) needs to be |
| 869 | * initialized and arranged in a linked list at link->dev. */ |
| 870 | strcpy(card->node.dev_name, dev->name); |
| 871 | link->dev = &card->node; /* link->dev being non-NULL is also |
| 872 | used to indicate that the |
| 873 | net_device has been registered */ |
| 874 | link->state &= ~DEV_CONFIG_PENDING; |
| 875 | |
| 876 | /* Finally, report what we've done */ |
| 877 | printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d", |
| 878 | dev->name, link->conf.ConfigIndex, |
| 879 | link->conf.Vcc / 10, link->conf.Vcc % 10); |
| 880 | if (link->conf.Vpp1) |
| 881 | printk(", Vpp %d.%d", link->conf.Vpp1 / 10, |
| 882 | link->conf.Vpp1 % 10); |
| 883 | printk(", irq %d", link->irq.AssignedIRQ); |
| 884 | if (link->io.NumPorts1) |
| 885 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, |
| 886 | link->io.BasePort1 + link->io.NumPorts1 - 1); |
| 887 | if (link->io.NumPorts2) |
| 888 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, |
| 889 | link->io.BasePort2 + link->io.NumPorts2 - 1); |
| 890 | printk("\n"); |
| 891 | |
| 892 | return; |
| 893 | |
| 894 | cs_failed: |
| 895 | cs_error(link->handle, last_fn, last_ret); |
| 896 | |
| 897 | failed: |
| 898 | spectrum_cs_release(link); |
| 899 | } /* spectrum_cs_config */ |
| 900 | |
| 901 | /* |
| 902 | * After a card is removed, spectrum_cs_release() will unregister the |
| 903 | * device, and release the PCMCIA configuration. If the device is |
| 904 | * still open, this will be postponed until it is closed. |
| 905 | */ |
| 906 | static void |
| 907 | spectrum_cs_release(dev_link_t *link) |
| 908 | { |
| 909 | struct net_device *dev = link->priv; |
| 910 | struct orinoco_private *priv = netdev_priv(dev); |
| 911 | unsigned long flags; |
| 912 | |
| 913 | /* We're committed to taking the device away now, so mark the |
| 914 | * hardware as unavailable */ |
| 915 | spin_lock_irqsave(&priv->lock, flags); |
| 916 | priv->hw_unavailable++; |
| 917 | spin_unlock_irqrestore(&priv->lock, flags); |
| 918 | |
| 919 | /* Don't bother checking to see if these succeed or not */ |
| 920 | pcmcia_release_configuration(link->handle); |
| 921 | if (link->io.NumPorts1) |
| 922 | pcmcia_release_io(link->handle, &link->io); |
| 923 | if (link->irq.AssignedIRQ) |
| 924 | pcmcia_release_irq(link->handle, &link->irq); |
| 925 | link->state &= ~DEV_CONFIG; |
| 926 | if (priv->hw.iobase) |
| 927 | ioport_unmap(priv->hw.iobase); |
| 928 | } /* spectrum_cs_release */ |
| 929 | |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 930 | |
| 931 | static int |
| 932 | spectrum_cs_suspend(struct pcmcia_device *p_dev) |
| 933 | { |
| 934 | dev_link_t *link = dev_to_instance(p_dev); |
| 935 | struct net_device *dev = link->priv; |
| 936 | struct orinoco_private *priv = netdev_priv(dev); |
| 937 | unsigned long flags; |
| 938 | int err = 0; |
| 939 | |
| 940 | link->state |= DEV_SUSPEND; |
| 941 | /* Mark the device as stopped, to block IO until later */ |
| 942 | if (link->state & DEV_CONFIG) { |
| 943 | spin_lock_irqsave(&priv->lock, flags); |
| 944 | |
| 945 | err = __orinoco_down(dev); |
| 946 | if (err) |
| 947 | printk(KERN_WARNING "%s: Error %d downing interface\n", |
| 948 | dev->name, err); |
| 949 | |
| 950 | netif_device_detach(dev); |
| 951 | priv->hw_unavailable++; |
| 952 | |
| 953 | spin_unlock_irqrestore(&priv->lock, flags); |
| 954 | |
| 955 | pcmcia_release_configuration(link->handle); |
| 956 | } |
| 957 | |
| 958 | return 0; |
| 959 | } |
| 960 | |
| 961 | static int |
| 962 | spectrum_cs_resume(struct pcmcia_device *p_dev) |
| 963 | { |
| 964 | dev_link_t *link = dev_to_instance(p_dev); |
| 965 | struct net_device *dev = link->priv; |
| 966 | struct orinoco_private *priv = netdev_priv(dev); |
| 967 | |
| 968 | link->state &= ~DEV_SUSPEND; |
| 969 | if (link->state & DEV_CONFIG) { |
| 970 | /* FIXME: should we double check that this is |
| 971 | * the same card as we had before */ |
| 972 | pcmcia_request_configuration(link->handle, &link->conf); |
| 973 | netif_device_attach(dev); |
| 974 | priv->hw_unavailable--; |
| 975 | schedule_work(&priv->reset_work); |
| 976 | } |
| 977 | return 0; |
| 978 | } |
| 979 | |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 980 | /* |
| 981 | * The card status event handler. Mostly, this schedules other stuff |
| 982 | * to run after an event is received. |
| 983 | */ |
| 984 | static int |
| 985 | spectrum_cs_event(event_t event, int priority, |
| 986 | event_callback_args_t * args) |
| 987 | { |
| 988 | dev_link_t *link = args->client_data; |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 989 | |
| 990 | switch (event) { |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 991 | case CS_EVENT_CARD_INSERTION: |
| 992 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
| 993 | spectrum_cs_config(link); |
| 994 | break; |
| 995 | |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 996 | } |
| 997 | |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 998 | return 0; |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 999 | } /* spectrum_cs_event */ |
| 1000 | |
| 1001 | /********************************************************************/ |
| 1002 | /* Module initialization */ |
| 1003 | /********************************************************************/ |
| 1004 | |
| 1005 | /* Can't be declared "const" or the whole __initdata section will |
| 1006 | * become const */ |
| 1007 | static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION |
| 1008 | " (Pavel Roskin <proski@gnu.org>," |
| 1009 | " David Gibson <hermes@gibson.dropbear.id.au>, et al)"; |
| 1010 | |
| 1011 | static struct pcmcia_device_id spectrum_cs_ids[] = { |
| 1012 | PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4100 */ |
| 1013 | PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */ |
Pavel Roskin | 9c8a11d | 2005-09-16 02:18:31 -0400 | [diff] [blame] | 1014 | PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */ |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 1015 | PCMCIA_DEVICE_NULL, |
| 1016 | }; |
| 1017 | MODULE_DEVICE_TABLE(pcmcia, spectrum_cs_ids); |
| 1018 | |
| 1019 | static struct pcmcia_driver orinoco_driver = { |
| 1020 | .owner = THIS_MODULE, |
| 1021 | .drv = { |
| 1022 | .name = DRIVER_NAME, |
| 1023 | }, |
| 1024 | .attach = spectrum_cs_attach, |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 1025 | .remove = spectrum_cs_detach, |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 1026 | .suspend = spectrum_cs_suspend, |
| 1027 | .resume = spectrum_cs_resume, |
Pavel Roskin | 393da59 | 2005-09-23 04:18:06 -0400 | [diff] [blame] | 1028 | .event = spectrum_cs_event, |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 1029 | .id_table = spectrum_cs_ids, |
| 1030 | }; |
| 1031 | |
| 1032 | static int __init |
| 1033 | init_spectrum_cs(void) |
| 1034 | { |
| 1035 | printk(KERN_DEBUG "%s\n", version); |
| 1036 | |
| 1037 | return pcmcia_register_driver(&orinoco_driver); |
| 1038 | } |
| 1039 | |
| 1040 | static void __exit |
| 1041 | exit_spectrum_cs(void) |
| 1042 | { |
| 1043 | pcmcia_unregister_driver(&orinoco_driver); |
Pavel Roskin | 3a48c4c | 2005-09-01 20:10:06 -0400 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | module_init(init_spectrum_cs); |
| 1047 | module_exit(exit_spectrum_cs); |