diff options
Diffstat (limited to 'drivers/net/irda/smsc-ircc2.c')
-rw-r--r-- | drivers/net/irda/smsc-ircc2.c | 523 |
1 files changed, 523 insertions, 0 deletions
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c index ec94ecdb103d..58f76cefbc83 100644 --- a/drivers/net/irda/smsc-ircc2.c +++ b/drivers/net/irda/smsc-ircc2.c | |||
@@ -11,6 +11,7 @@ | |||
11 | * Copyright (c) 2002 Daniele Peri | 11 | * Copyright (c) 2002 Daniele Peri |
12 | * All Rights Reserved. | 12 | * All Rights Reserved. |
13 | * Copyright (c) 2002 Jean Tourrilhes | 13 | * Copyright (c) 2002 Jean Tourrilhes |
14 | * Copyright (c) 2006 Linus Walleij | ||
14 | * | 15 | * |
15 | * | 16 | * |
16 | * Based on smc-ircc.c: | 17 | * Based on smc-ircc.c: |
@@ -61,6 +62,9 @@ | |||
61 | 62 | ||
62 | #include <linux/spinlock.h> | 63 | #include <linux/spinlock.h> |
63 | #include <linux/pm.h> | 64 | #include <linux/pm.h> |
65 | #ifdef CONFIG_PCI | ||
66 | #include <linux/pci.h> | ||
67 | #endif | ||
64 | 68 | ||
65 | #include <net/irda/wrapper.h> | 69 | #include <net/irda/wrapper.h> |
66 | #include <net/irda/irda.h> | 70 | #include <net/irda/irda.h> |
@@ -100,6 +104,22 @@ MODULE_PARM_DESC(ircc_transceiver, "Transceiver type"); | |||
100 | 104 | ||
101 | /* Types */ | 105 | /* Types */ |
102 | 106 | ||
107 | #ifdef CONFIG_PCI | ||
108 | struct smsc_ircc_subsystem_configuration { | ||
109 | unsigned short vendor; /* PCI vendor ID */ | ||
110 | unsigned short device; /* PCI vendor ID */ | ||
111 | unsigned short subvendor; /* PCI subsystem vendor ID */ | ||
112 | unsigned short subdevice; /* PCI sybsystem device ID */ | ||
113 | unsigned short sir_io; /* I/O port for SIR */ | ||
114 | unsigned short fir_io; /* I/O port for FIR */ | ||
115 | unsigned char fir_irq; /* FIR IRQ */ | ||
116 | unsigned char fir_dma; /* FIR DMA */ | ||
117 | unsigned short cfg_base; /* I/O port for chip configuration */ | ||
118 | int (*preconfigure)(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); /* Preconfig function */ | ||
119 | const char *name; /* name shown as info */ | ||
120 | }; | ||
121 | #endif | ||
122 | |||
103 | struct smsc_transceiver { | 123 | struct smsc_transceiver { |
104 | char *name; | 124 | char *name; |
105 | void (*set_for_speed)(int fir_base, u32 speed); | 125 | void (*set_for_speed)(int fir_base, u32 speed); |
@@ -202,6 +222,18 @@ static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned shor | |||
202 | static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type); | 222 | static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type); |
203 | static int __init smsc_superio_fdc(unsigned short cfg_base); | 223 | static int __init smsc_superio_fdc(unsigned short cfg_base); |
204 | static int __init smsc_superio_lpc(unsigned short cfg_base); | 224 | static int __init smsc_superio_lpc(unsigned short cfg_base); |
225 | #ifdef CONFIG_PCI | ||
226 | static int __init preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf); | ||
227 | static int __init preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); | ||
228 | static void __init preconfigure_ali_port(struct pci_dev *dev, | ||
229 | unsigned short port); | ||
230 | static int __init preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); | ||
231 | static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg, | ||
232 | unsigned short ircc_fir, | ||
233 | unsigned short ircc_sir, | ||
234 | unsigned char ircc_dma, | ||
235 | unsigned char ircc_irq); | ||
236 | #endif | ||
205 | 237 | ||
206 | /* Transceivers specific functions */ | 238 | /* Transceivers specific functions */ |
207 | 239 | ||
@@ -353,6 +385,13 @@ static int __init smsc_ircc_init(void) | |||
353 | return ret; | 385 | return ret; |
354 | } | 386 | } |
355 | 387 | ||
388 | #ifdef CONFIG_PCI | ||
389 | if (smsc_ircc_preconfigure_subsystems(ircc_cfg, ircc_fir, ircc_sir, ircc_dma, ircc_irq) < 0) { | ||
390 | /* Ignore errors from preconfiguration */ | ||
391 | IRDA_ERROR("%s, Preconfiguration failed !\n", driver_name); | ||
392 | } | ||
393 | #endif | ||
394 | |||
356 | dev_count = 0; | 395 | dev_count = 0; |
357 | 396 | ||
358 | if (ircc_fir > 0 && ircc_sir > 0) { | 397 | if (ircc_fir > 0 && ircc_sir > 0) { |
@@ -2285,6 +2324,490 @@ static int __init smsc_superio_lpc(unsigned short cfg_base) | |||
2285 | return ret; | 2324 | return ret; |
2286 | } | 2325 | } |
2287 | 2326 | ||
2327 | /* | ||
2328 | * Look for some specific subsystem setups that need | ||
2329 | * pre-configuration not properly done by the BIOS (especially laptops) | ||
2330 | * This code is based in part on smcinit.c, tosh1800-smcinit.c | ||
2331 | * and tosh2450-smcinit.c. The table lists the device entries | ||
2332 | * for ISA bridges with an LPC (Low Pin Count) controller which | ||
2333 | * handles the communication with the SMSC device. After the LPC | ||
2334 | * controller is initialized through PCI, the SMSC device is initialized | ||
2335 | * through a dedicated port in the ISA port-mapped I/O area, this latter | ||
2336 | * area is used to configure the SMSC device with default | ||
2337 | * SIR and FIR I/O ports, DMA and IRQ. Different vendors have | ||
2338 | * used different sets of parameters and different control port | ||
2339 | * addresses making a subsystem device table necessary. | ||
2340 | */ | ||
2341 | #ifdef CONFIG_PCI | ||
2342 | #define PCIID_VENDOR_INTEL 0x8086 | ||
2343 | #define PCIID_VENDOR_ALI 0x10b9 | ||
2344 | static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __devinitdata = { | ||
2345 | { | ||
2346 | .vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */ | ||
2347 | .device = 0x24cc, | ||
2348 | .subvendor = 0x103c, | ||
2349 | .subdevice = 0x088c, | ||
2350 | /* Quite certain these are the same for nc8000 as for nc6000 */ | ||
2351 | .sir_io = 0x02f8, | ||
2352 | .fir_io = 0x0130, | ||
2353 | .fir_irq = 0x05, | ||
2354 | .fir_dma = 0x03, | ||
2355 | .cfg_base = 0x004e, | ||
2356 | .preconfigure = preconfigure_through_82801, | ||
2357 | .name = "HP nc8000", | ||
2358 | }, | ||
2359 | { | ||
2360 | .vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */ | ||
2361 | .device = 0x24cc, | ||
2362 | .subvendor = 0x103c, | ||
2363 | .subdevice = 0x0890, | ||
2364 | .sir_io = 0x02f8, | ||
2365 | .fir_io = 0x0130, | ||
2366 | .fir_irq = 0x05, | ||
2367 | .fir_dma = 0x03, | ||
2368 | .cfg_base = 0x004e, | ||
2369 | .preconfigure = preconfigure_through_82801, | ||
2370 | .name = "HP nc6000", | ||
2371 | }, | ||
2372 | { | ||
2373 | /* Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge */ | ||
2374 | .vendor = PCIID_VENDOR_INTEL, | ||
2375 | .device = 0x24c0, | ||
2376 | .subvendor = 0x1179, | ||
2377 | .subdevice = 0xffff, /* 0xffff is "any" */ | ||
2378 | .sir_io = 0x03f8, | ||
2379 | .fir_io = 0x0130, | ||
2380 | .fir_irq = 0x07, | ||
2381 | .fir_dma = 0x01, | ||
2382 | .cfg_base = 0x002e, | ||
2383 | .preconfigure = preconfigure_through_82801, | ||
2384 | .name = "Toshiba laptop with Intel 82801DB/DBL LPC bridge", | ||
2385 | }, | ||
2386 | { | ||
2387 | .vendor = PCIID_VENDOR_INTEL, /* Intel 82801CAM ISA bridge */ | ||
2388 | .device = 0x248c, | ||
2389 | .subvendor = 0x1179, | ||
2390 | .subdevice = 0xffff, /* 0xffff is "any" */ | ||
2391 | .sir_io = 0x03f8, | ||
2392 | .fir_io = 0x0130, | ||
2393 | .fir_irq = 0x03, | ||
2394 | .fir_dma = 0x03, | ||
2395 | .cfg_base = 0x002e, | ||
2396 | .preconfigure = preconfigure_through_82801, | ||
2397 | .name = "Toshiba laptop with Intel 82801CAM ISA bridge", | ||
2398 | }, | ||
2399 | { | ||
2400 | /* 82801DBM (ICH4-M) LPC Interface Bridge */ | ||
2401 | .vendor = PCIID_VENDOR_INTEL, | ||
2402 | .device = 0x24cc, | ||
2403 | .subvendor = 0x1179, | ||
2404 | .subdevice = 0xffff, /* 0xffff is "any" */ | ||
2405 | .sir_io = 0x03f8, | ||
2406 | .fir_io = 0x0130, | ||
2407 | .fir_irq = 0x03, | ||
2408 | .fir_dma = 0x03, | ||
2409 | .cfg_base = 0x002e, | ||
2410 | .preconfigure = preconfigure_through_82801, | ||
2411 | .name = "Toshiba laptop with Intel 8281DBM LPC bridge", | ||
2412 | }, | ||
2413 | { | ||
2414 | /* ALi M1533/M1535 PCI to ISA Bridge [Aladdin IV/V/V+] */ | ||
2415 | .vendor = PCIID_VENDOR_ALI, | ||
2416 | .device = 0x1533, | ||
2417 | .subvendor = 0x1179, | ||
2418 | .subdevice = 0xffff, /* 0xffff is "any" */ | ||
2419 | .sir_io = 0x02e8, | ||
2420 | .fir_io = 0x02f8, | ||
2421 | .fir_irq = 0x07, | ||
2422 | .fir_dma = 0x03, | ||
2423 | .cfg_base = 0x002e, | ||
2424 | .preconfigure = preconfigure_through_ali, | ||
2425 | .name = "Toshiba laptop with ALi ISA bridge", | ||
2426 | }, | ||
2427 | { } // Terminator | ||
2428 | }; | ||
2429 | |||
2430 | |||
2431 | /* | ||
2432 | * This sets up the basic SMSC parameters | ||
2433 | * (FIR port, SIR port, FIR DMA, FIR IRQ) | ||
2434 | * through the chip configuration port. | ||
2435 | */ | ||
2436 | static int __init preconfigure_smsc_chip(struct | ||
2437 | smsc_ircc_subsystem_configuration | ||
2438 | *conf) | ||
2439 | { | ||
2440 | unsigned short iobase = conf->cfg_base; | ||
2441 | unsigned char tmpbyte; | ||
2442 | |||
2443 | outb(LPC47N227_CFGACCESSKEY, iobase); // enter configuration state | ||
2444 | outb(SMSCSIOFLAT_DEVICEID_REG, iobase); // set for device ID | ||
2445 | tmpbyte = inb(iobase +1); // Read device ID | ||
2446 | IRDA_DEBUG(0, | ||
2447 | "Detected Chip id: 0x%02x, setting up registers...\n", | ||
2448 | tmpbyte); | ||
2449 | |||
2450 | /* Disable UART1 and set up SIR I/O port */ | ||
2451 | outb(0x24, iobase); // select CR24 - UART1 base addr | ||
2452 | outb(0x00, iobase + 1); // disable UART1 | ||
2453 | outb(SMSCSIOFLAT_UART2BASEADDR_REG, iobase); // select CR25 - UART2 base addr | ||
2454 | outb( (conf->sir_io >> 2), iobase + 1); // bits 2-9 of 0x3f8 | ||
2455 | tmpbyte = inb(iobase + 1); | ||
2456 | if (tmpbyte != (conf->sir_io >> 2) ) { | ||
2457 | IRDA_WARNING("ERROR: could not configure SIR ioport.\n"); | ||
2458 | IRDA_WARNING("Try to supply ircc_cfg argument.\n"); | ||
2459 | return -ENXIO; | ||
2460 | } | ||
2461 | |||
2462 | /* Set up FIR IRQ channel for UART2 */ | ||
2463 | outb(SMSCSIOFLAT_UARTIRQSELECT_REG, iobase); // select CR28 - UART1,2 IRQ select | ||
2464 | tmpbyte = inb(iobase + 1); | ||
2465 | tmpbyte &= SMSCSIOFLAT_UART1IRQSELECT_MASK; // Do not touch the UART1 portion | ||
2466 | tmpbyte |= (conf->fir_irq & SMSCSIOFLAT_UART2IRQSELECT_MASK); | ||
2467 | outb(tmpbyte, iobase + 1); | ||
2468 | tmpbyte = inb(iobase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK; | ||
2469 | if (tmpbyte != conf->fir_irq) { | ||
2470 | IRDA_WARNING("ERROR: could not configure FIR IRQ channel.\n"); | ||
2471 | return -ENXIO; | ||
2472 | } | ||
2473 | |||
2474 | /* Set up FIR I/O port */ | ||
2475 | outb(SMSCSIOFLAT_FIRBASEADDR_REG, iobase); // CR2B - SCE (FIR) base addr | ||
2476 | outb((conf->fir_io >> 3), iobase + 1); | ||
2477 | tmpbyte = inb(iobase + 1); | ||
2478 | if (tmpbyte != (conf->fir_io >> 3) ) { | ||
2479 | IRDA_WARNING("ERROR: could not configure FIR I/O port.\n"); | ||
2480 | return -ENXIO; | ||
2481 | } | ||
2482 | |||
2483 | /* Set up FIR DMA channel */ | ||
2484 | outb(SMSCSIOFLAT_FIRDMASELECT_REG, iobase); // CR2C - SCE (FIR) DMA select | ||
2485 | outb((conf->fir_dma & LPC47N227_FIRDMASELECT_MASK), iobase + 1); // DMA | ||
2486 | tmpbyte = inb(iobase + 1) & LPC47N227_FIRDMASELECT_MASK; | ||
2487 | if (tmpbyte != (conf->fir_dma & LPC47N227_FIRDMASELECT_MASK)) { | ||
2488 | IRDA_WARNING("ERROR: could not configure FIR DMA channel.\n"); | ||
2489 | return -ENXIO; | ||
2490 | } | ||
2491 | |||
2492 | outb(SMSCSIOFLAT_UARTMODE0C_REG, iobase); // CR0C - UART mode | ||
2493 | tmpbyte = inb(iobase + 1); | ||
2494 | tmpbyte &= ~SMSCSIOFLAT_UART2MODE_MASK | | ||
2495 | SMSCSIOFLAT_UART2MODE_VAL_IRDA; | ||
2496 | outb(tmpbyte, iobase + 1); // enable IrDA (HPSIR) mode, high speed | ||
2497 | |||
2498 | outb(LPC47N227_APMBOOTDRIVE_REG, iobase); // CR07 - Auto Pwr Mgt/boot drive sel | ||
2499 | tmpbyte = inb(iobase + 1); | ||
2500 | outb(tmpbyte | LPC47N227_UART2AUTOPWRDOWN_MASK, iobase + 1); // enable UART2 autopower down | ||
2501 | |||
2502 | /* This one was not part of tosh1800 */ | ||
2503 | outb(0x0a, iobase); // CR0a - ecp fifo / ir mux | ||
2504 | tmpbyte = inb(iobase + 1); | ||
2505 | outb(tmpbyte | 0x40, iobase + 1); // send active device to ir port | ||
2506 | |||
2507 | outb(LPC47N227_UART12POWER_REG, iobase); // CR02 - UART 1,2 power | ||
2508 | tmpbyte = inb(iobase + 1); | ||
2509 | outb(tmpbyte | LPC47N227_UART2POWERDOWN_MASK, iobase + 1); // UART2 power up mode, UART1 power down | ||
2510 | |||
2511 | outb(LPC47N227_FDCPOWERVALIDCONF_REG, iobase); // CR00 - FDC Power/valid config cycle | ||
2512 | tmpbyte = inb(iobase + 1); | ||
2513 | outb(tmpbyte | LPC47N227_VALID_MASK, iobase + 1); // valid config cycle done | ||
2514 | |||
2515 | outb(LPC47N227_CFGEXITKEY, iobase); // Exit configuration | ||
2516 | |||
2517 | return 0; | ||
2518 | } | ||
2519 | |||
2520 | /* 82801CAM generic registers */ | ||
2521 | #define VID 0x00 | ||
2522 | #define DID 0x02 | ||
2523 | #define PIRQ_A_D_ROUT 0x60 | ||
2524 | #define SIRQ_CNTL 0x64 | ||
2525 | #define PIRQ_E_H_ROUT 0x68 | ||
2526 | #define PCI_DMA_C 0x90 | ||
2527 | /* LPC-specific registers */ | ||
2528 | #define COM_DEC 0xe0 | ||
2529 | #define GEN1_DEC 0xe4 | ||
2530 | #define LPC_EN 0xe6 | ||
2531 | #define GEN2_DEC 0xec | ||
2532 | /* | ||
2533 | * Sets up the I/O range using the 82801CAM ISA bridge, 82801DBM LPC bridge | ||
2534 | * or Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge. | ||
2535 | * They all work the same way! | ||
2536 | */ | ||
2537 | static int __init preconfigure_through_82801(struct pci_dev *dev, | ||
2538 | struct | ||
2539 | smsc_ircc_subsystem_configuration | ||
2540 | *conf) | ||
2541 | { | ||
2542 | unsigned short tmpword; | ||
2543 | unsigned char tmpbyte; | ||
2544 | |||
2545 | IRDA_MESSAGE("Setting up Intel 82801 controller and SMSC device\n"); | ||
2546 | /* | ||
2547 | * Select the range for the COMA COM port (SIR) | ||
2548 | * Register COM_DEC: | ||
2549 | * Bit 7: reserved | ||
2550 | * Bit 6-4, COMB decode range | ||
2551 | * Bit 3: reserved | ||
2552 | * Bit 2-0, COMA decode range | ||
2553 | * | ||
2554 | * Decode ranges: | ||
2555 | * 000 = 0x3f8-0x3ff (COM1) | ||
2556 | * 001 = 0x2f8-0x2ff (COM2) | ||
2557 | * 010 = 0x220-0x227 | ||
2558 | * 011 = 0x228-0x22f | ||
2559 | * 100 = 0x238-0x23f | ||
2560 | * 101 = 0x2e8-0x2ef (COM4) | ||
2561 | * 110 = 0x338-0x33f | ||
2562 | * 111 = 0x3e8-0x3ef (COM3) | ||
2563 | */ | ||
2564 | pci_read_config_byte(dev, COM_DEC, &tmpbyte); | ||
2565 | tmpbyte &= 0xf8; /* mask COMA bits */ | ||
2566 | switch(conf->sir_io) { | ||
2567 | case 0x3f8: | ||
2568 | tmpbyte |= 0x00; | ||
2569 | break; | ||
2570 | case 0x2f8: | ||
2571 | tmpbyte |= 0x01; | ||
2572 | break; | ||
2573 | case 0x220: | ||
2574 | tmpbyte |= 0x02; | ||
2575 | break; | ||
2576 | case 0x228: | ||
2577 | tmpbyte |= 0x03; | ||
2578 | break; | ||
2579 | case 0x238: | ||
2580 | tmpbyte |= 0x04; | ||
2581 | break; | ||
2582 | case 0x2e8: | ||
2583 | tmpbyte |= 0x05; | ||
2584 | break; | ||
2585 | case 0x338: | ||
2586 | tmpbyte |= 0x06; | ||
2587 | break; | ||
2588 | case 0x3e8: | ||
2589 | tmpbyte |= 0x07; | ||
2590 | break; | ||
2591 | default: | ||
2592 | tmpbyte |= 0x01; /* COM2 default */ | ||
2593 | } | ||
2594 | IRDA_DEBUG(1, "COM_DEC (write): 0x%02x\n", tmpbyte); | ||
2595 | pci_write_config_byte(dev, COM_DEC, tmpbyte); | ||
2596 | |||
2597 | /* Enable Low Pin Count interface */ | ||
2598 | pci_read_config_word(dev, LPC_EN, &tmpword); | ||
2599 | /* These seem to be set up at all times, | ||
2600 | * just make sure it is properly set. | ||
2601 | */ | ||
2602 | switch(conf->cfg_base) { | ||
2603 | case 0x04e: | ||
2604 | tmpword |= 0x2000; | ||
2605 | break; | ||
2606 | case 0x02e: | ||
2607 | tmpword |= 0x1000; | ||
2608 | break; | ||
2609 | case 0x062: | ||
2610 | tmpword |= 0x0800; | ||
2611 | break; | ||
2612 | case 0x060: | ||
2613 | tmpword |= 0x0400; | ||
2614 | break; | ||
2615 | default: | ||
2616 | IRDA_WARNING("Uncommon I/O base address: 0x%04x\n", | ||
2617 | conf->cfg_base); | ||
2618 | break; | ||
2619 | } | ||
2620 | tmpword &= 0xfffd; /* disable LPC COMB */ | ||
2621 | tmpword |= 0x0001; /* set bit 0 : enable LPC COMA addr range (GEN2) */ | ||
2622 | IRDA_DEBUG(1, "LPC_EN (write): 0x%04x\n", tmpword); | ||
2623 | pci_write_config_word(dev, LPC_EN, tmpword); | ||
2624 | |||
2625 | /* | ||
2626 | * Configure LPC DMA channel | ||
2627 | * PCI_DMA_C bits: | ||
2628 | * Bit 15-14: DMA channel 7 select | ||
2629 | * Bit 13-12: DMA channel 6 select | ||
2630 | * Bit 11-10: DMA channel 5 select | ||
2631 | * Bit 9-8: Reserved | ||
2632 | * Bit 7-6: DMA channel 3 select | ||
2633 | * Bit 5-4: DMA channel 2 select | ||
2634 | * Bit 3-2: DMA channel 1 select | ||
2635 | * Bit 1-0: DMA channel 0 select | ||
2636 | * 00 = Reserved value | ||
2637 | * 01 = PC/PCI DMA | ||
2638 | * 10 = Reserved value | ||
2639 | * 11 = LPC I/F DMA | ||
2640 | */ | ||
2641 | pci_read_config_word(dev, PCI_DMA_C, &tmpword); | ||
2642 | switch(conf->fir_dma) { | ||
2643 | case 0x07: | ||
2644 | tmpword |= 0xc000; | ||
2645 | break; | ||
2646 | case 0x06: | ||
2647 | tmpword |= 0x3000; | ||
2648 | break; | ||
2649 | case 0x05: | ||
2650 | tmpword |= 0x0c00; | ||
2651 | break; | ||
2652 | case 0x03: | ||
2653 | tmpword |= 0x00c0; | ||
2654 | break; | ||
2655 | case 0x02: | ||
2656 | tmpword |= 0x0030; | ||
2657 | break; | ||
2658 | case 0x01: | ||
2659 | tmpword |= 0x000c; | ||
2660 | break; | ||
2661 | case 0x00: | ||
2662 | tmpword |= 0x0003; | ||
2663 | break; | ||
2664 | default: | ||
2665 | break; /* do not change settings */ | ||
2666 | } | ||
2667 | IRDA_DEBUG(1, "PCI_DMA_C (write): 0x%04x\n", tmpword); | ||
2668 | pci_write_config_word(dev, PCI_DMA_C, tmpword); | ||
2669 | |||
2670 | /* | ||
2671 | * GEN2_DEC bits: | ||
2672 | * Bit 15-4: Generic I/O range | ||
2673 | * Bit 3-1: reserved (read as 0) | ||
2674 | * Bit 0: enable GEN2 range on LPC I/F | ||
2675 | */ | ||
2676 | tmpword = conf->fir_io & 0xfff8; | ||
2677 | tmpword |= 0x0001; | ||
2678 | IRDA_DEBUG(1, "GEN2_DEC (write): 0x%04x\n", tmpword); | ||
2679 | pci_write_config_word(dev, GEN2_DEC, tmpword); | ||
2680 | |||
2681 | /* Pre-configure chip */ | ||
2682 | return preconfigure_smsc_chip(conf); | ||
2683 | } | ||
2684 | |||
2685 | /* | ||
2686 | * Pre-configure a certain port on the ALi 1533 bridge. | ||
2687 | * This is based on reverse-engineering since ALi does not | ||
2688 | * provide any data sheet for the 1533 chip. | ||
2689 | */ | ||
2690 | static void __init preconfigure_ali_port(struct pci_dev *dev, | ||
2691 | unsigned short port) | ||
2692 | { | ||
2693 | unsigned char reg; | ||
2694 | /* These bits obviously control the different ports */ | ||
2695 | unsigned char mask; | ||
2696 | unsigned char tmpbyte; | ||
2697 | |||
2698 | switch(port) { | ||
2699 | case 0x0130: | ||
2700 | case 0x0178: | ||
2701 | reg = 0xb0; | ||
2702 | mask = 0x80; | ||
2703 | break; | ||
2704 | case 0x03f8: | ||
2705 | reg = 0xb4; | ||
2706 | mask = 0x80; | ||
2707 | break; | ||
2708 | case 0x02f8: | ||
2709 | reg = 0xb4; | ||
2710 | mask = 0x30; | ||
2711 | break; | ||
2712 | case 0x02e8: | ||
2713 | reg = 0xb4; | ||
2714 | mask = 0x08; | ||
2715 | break; | ||
2716 | default: | ||
2717 | IRDA_ERROR("Failed to configure unsupported port on ALi 1533 bridge: 0x%04x\n", port); | ||
2718 | return; | ||
2719 | } | ||
2720 | |||
2721 | pci_read_config_byte(dev, reg, &tmpbyte); | ||
2722 | /* Turn on the right bits */ | ||
2723 | tmpbyte |= mask; | ||
2724 | pci_write_config_byte(dev, reg, tmpbyte); | ||
2725 | IRDA_MESSAGE("Activated ALi 1533 ISA bridge port 0x%04x.\n", port); | ||
2726 | return; | ||
2727 | } | ||
2728 | |||
2729 | static int __init preconfigure_through_ali(struct pci_dev *dev, | ||
2730 | struct | ||
2731 | smsc_ircc_subsystem_configuration | ||
2732 | *conf) | ||
2733 | { | ||
2734 | /* Configure the two ports on the ALi 1533 */ | ||
2735 | preconfigure_ali_port(dev, conf->sir_io); | ||
2736 | preconfigure_ali_port(dev, conf->fir_io); | ||
2737 | |||
2738 | /* Pre-configure chip */ | ||
2739 | return preconfigure_smsc_chip(conf); | ||
2740 | } | ||
2741 | |||
2742 | static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg, | ||
2743 | unsigned short ircc_fir, | ||
2744 | unsigned short ircc_sir, | ||
2745 | unsigned char ircc_dma, | ||
2746 | unsigned char ircc_irq) | ||
2747 | { | ||
2748 | struct pci_dev *dev = NULL; | ||
2749 | unsigned short ss_vendor = 0x0000; | ||
2750 | unsigned short ss_device = 0x0000; | ||
2751 | int ret = 0; | ||
2752 | |||
2753 | dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev); | ||
2754 | |||
2755 | while (dev != NULL) { | ||
2756 | struct smsc_ircc_subsystem_configuration *conf; | ||
2757 | |||
2758 | /* | ||
2759 | * Cache the subsystem vendor/device: | ||
2760 | * some manufacturers fail to set this for all components, | ||
2761 | * so we save it in case there is just 0x0000 0x0000 on the | ||
2762 | * device we want to check. | ||
2763 | */ | ||
2764 | if (dev->subsystem_vendor != 0x0000U) { | ||
2765 | ss_vendor = dev->subsystem_vendor; | ||
2766 | ss_device = dev->subsystem_device; | ||
2767 | } | ||
2768 | conf = subsystem_configurations; | ||
2769 | for( ; conf->subvendor; conf++) { | ||
2770 | if(conf->vendor == dev->vendor && | ||
2771 | conf->device == dev->device && | ||
2772 | conf->subvendor == ss_vendor && | ||
2773 | /* Sometimes these are cached values */ | ||
2774 | (conf->subdevice == ss_device || | ||
2775 | conf->subdevice == 0xffff)) { | ||
2776 | struct smsc_ircc_subsystem_configuration | ||
2777 | tmpconf; | ||
2778 | |||
2779 | memcpy(&tmpconf, conf, | ||
2780 | sizeof(struct smsc_ircc_subsystem_configuration)); | ||
2781 | |||
2782 | /* | ||
2783 | * Override the default values with anything | ||
2784 | * passed in as parameter | ||
2785 | */ | ||
2786 | if (ircc_cfg != 0) | ||
2787 | tmpconf.cfg_base = ircc_cfg; | ||
2788 | if (ircc_fir != 0) | ||
2789 | tmpconf.fir_io = ircc_fir; | ||
2790 | if (ircc_sir != 0) | ||
2791 | tmpconf.sir_io = ircc_sir; | ||
2792 | if (ircc_dma != 0xff) | ||
2793 | tmpconf.fir_dma = ircc_dma; | ||
2794 | if (ircc_irq != 0xff) | ||
2795 | tmpconf.fir_irq = ircc_irq; | ||
2796 | |||
2797 | IRDA_MESSAGE("Detected unconfigured %s SMSC IrDA chip, pre-configuring device.\n", conf->name); | ||
2798 | if (conf->preconfigure) | ||
2799 | ret = conf->preconfigure(dev, &tmpconf); | ||
2800 | else | ||
2801 | ret = -ENODEV; | ||
2802 | } | ||
2803 | } | ||
2804 | dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev); | ||
2805 | } | ||
2806 | |||
2807 | return ret; | ||
2808 | } | ||
2809 | #endif // CONFIG_PCI | ||
2810 | |||
2288 | /************************************************ | 2811 | /************************************************ |
2289 | * | 2812 | * |
2290 | * Transceivers specific functions | 2813 | * Transceivers specific functions |