X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fnet%2Fat1700.c;h=56ae8babd919d3d302c332fa783c9072d9d93e7a;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=9981968a830f4f9b3e4a79de074904a37dbfc2ea;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c index 9981968a8..56ae8babd 100644 --- a/drivers/net/at1700.c +++ b/drivers/net/at1700.c @@ -18,7 +18,7 @@ straight-forward Fujitsu MB86965 implementations. Modification for Fujitsu FMV-18X cards is done by Yutaka Tamiya - (tamy@flab.fujitsu.co.jp). + (tamy@flab.fujitsu.co.jp). Sources: The Fujitsu MB86965 datasheet. @@ -34,12 +34,7 @@ only is it difficult to detect, it also moves around in I/O space in response to inb()s from other device probes! */ -/* - 99/03/03 Allied Telesis RE1000 Plus support by T.Hagawa - 99/12/30 port to 2.3.35 by K.Takai -*/ -#include #include #include #include @@ -56,14 +51,16 @@ #include #include #include +#include #include -#include #include #include static char version[] __initdata = - "at1700.c:v1.15 4/7/98 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; + "at1700.c:v1.16 9/11/06 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; + +#define DRV_NAME "at1700" /* Tunable parameters. */ @@ -80,21 +77,14 @@ static int fmv18x_probe_list[] __initdata = { * ISA */ -#ifndef CONFIG_X86_PC9800 static unsigned at1700_probe_list[] __initdata = { 0x260, 0x280, 0x2a0, 0x240, 0x340, 0x320, 0x380, 0x300, 0 }; -#else /* CONFIG_X86_PC9800 */ -static unsigned at1700_probe_list[] __initdata = { - 0x1d6, 0x1d8, 0x1da, 0x1d4, 0xd4, 0xd2, 0xd8, 0xd0, 0 -}; - -#endif /* CONFIG_X86_PC9800 */ /* * MCA */ -#ifdef CONFIG_MCA +#ifdef CONFIG_MCA_LEGACY static int at1700_ioaddr_pattern[] __initdata = { 0x00, 0x04, 0x01, 0x05, 0x02, 0x06, 0x03, 0x07 }; @@ -133,7 +123,6 @@ struct net_local { /* Offsets from the base address. */ -#ifndef CONFIG_X86_PC9800 #define STATUS 0 #define TX_STATUS 0 #define RX_STATUS 1 @@ -161,34 +150,6 @@ struct net_local { #define RESET 31 /* Write to reset some parts of the chip. */ #define AT1700_IO_EXTENT 32 #define PORT_OFFSET(o) (o) -#else /* CONFIG_X86_PC9800 */ -#define STATUS (0x0000) -#define TX_STATUS (0x0000) -#define RX_STATUS (0x0001) -#define TX_INTR (0x0200)/* Bit-mapped interrupt enable registers. */ -#define RX_INTR (0x0201) -#define TX_MODE (0x0400) -#define RX_MODE (0x0401) -#define CONFIG_0 (0x0600)/* Misc. configuration settings. */ -#define CONFIG_1 (0x0601) -/* Run-time register bank 2 definitions. */ -#define DATAPORT (0x0800)/* Word-wide DMA or programmed-I/O dataport. */ -#define TX_START (0x0a00) -#define COL16CNTL (0x0a01)/* Controll Reg for 16 collisions */ -#define MODE13 (0x0c01) -#define RX_CTRL (0x0e00) -/* Configuration registers only on the '865A/B chips. */ -#define EEPROM_Ctrl (0x1000) -#define EEPROM_Data (0x1200) -#define CARDSTATUS 16 /* FMV-18x Card Status */ -#define CARDSTATUS1 17 /* FMV-18x Card Status */ -#define IOCONFIG (0x1400)/* Either read the jumper, or move the I/O. */ -#define IOCONFIG1 (0x1600) -#define SAPROM 20 /* The station address PROM, if no EEPROM. */ -#define MODE24 (0x1800)/* The station address PROM, if no EEPROM. */ -#define RESET (0x1e01)/* Write to reset some parts of the chip. */ -#define PORT_OFFSET(o) ({ int _o_ = (o); (_o_ & ~1) * 0x100 + (_o_ & 1); }) -#endif /* CONFIG_X86_PC9800 */ #define TX_TIMEOUT 10 @@ -200,15 +161,15 @@ static int at1700_probe1(struct net_device *dev, int ioaddr); static int read_eeprom(long ioaddr, int location); static int net_open(struct net_device *dev); static int net_send_packet(struct sk_buff *skb, struct net_device *dev); -static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs *regs); +static irqreturn_t net_interrupt(int irq, void *dev_id); static void net_rx(struct net_device *dev); static int net_close(struct net_device *dev); static struct net_device_stats *net_get_stats(struct net_device *dev); static void set_rx_mode(struct net_device *dev); static void net_tx_timeout (struct net_device *dev); - -#ifdef CONFIG_MCA + +#ifdef CONFIG_MCA_LEGACY struct at1720_mca_adapters_struct { char* name; int id; @@ -230,31 +191,19 @@ static struct at1720_mca_adapters_struct at1720_mca_adapters[] __initdata = { (detachable devices only). */ -#ifndef CONFIG_X86_PC9800 static int io = 0x260; -#else -static int io = 0xd0; -#endif static int irq; static void cleanup_card(struct net_device *dev) { -#ifdef CONFIG_MCA +#ifdef CONFIG_MCA_LEGACY struct net_local *lp = netdev_priv(dev); if (lp->mca_slot >= 0) mca_mark_as_unused(lp->mca_slot); -#endif +#endif free_irq(dev->irq, NULL); -#ifndef CONFIG_X86_PC9800 release_region(dev->base_addr, AT1700_IO_EXTENT); -#else - { - int i; - for (i = 0; i < 0x2000; i += 0x200) - release_region(dev->base_addr + i, 2); - } -#endif } struct net_device * __init at1700_probe(int unit) @@ -321,20 +270,8 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr) int slot, ret = -ENODEV; struct net_local *lp = netdev_priv(dev); -#ifndef CONFIG_X86_PC9800 - if (!request_region(ioaddr, AT1700_IO_EXTENT, dev->name)) + if (!request_region(ioaddr, AT1700_IO_EXTENT, DRV_NAME)) return -EBUSY; -#else - for (i = 0; i < 0x2000; i += 0x0200) { - if (!request_region(ioaddr + i, 2, dev->name)) { - while (i > 0) { - i -= 0x0200; - release_region(ioaddr + i, 2); - } - return -EBUSY; - } - } -#endif /* Resetting the chip doesn't reset the ISA interface, so don't bother. That means we have to be careful with the register values we probe @@ -346,7 +283,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr) read_eeprom(ioaddr, 6), inw(ioaddr + EEPROM_Ctrl)); #endif -#ifdef CONFIG_MCA +#ifdef CONFIG_MCA_LEGACY /* rEnE (rene@bss.lu): got this from 3c509 driver source , adapted for AT1720 */ /* Based on Erik Nygren's (nygren@mit.edu) 3c529 patch, heavily @@ -364,7 +301,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr) for (j = 0; at1720_mca_adapters[j].name != NULL; j ++) { slot = 0; while (slot != MCA_NOTFOUND) { - + slot = mca_find_unused_adapter( at1720_mca_adapters[j].id, slot ); if (slot == MCA_NOTFOUND) break; @@ -378,7 +315,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr) if (( pos3 & 0x07) == at1700_ioaddr_pattern[l_i]) break; ioaddr = at1700_mca_probe_list[l_i]; - + for (irq = 0; irq < 0x10; irq++) if (((((pos4>>4) & 0x0f) | (pos3 & 0xf0)) & 0xff) == at1700_irq_pattern[irq]) break; @@ -391,7 +328,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr) } dev->irq = irq; - + /* claim the slot */ mca_set_adapter_name( slot, at1720_mca_adapters[j].name ); mca_mark_as_used(slot); @@ -416,8 +353,8 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr) else { goto err_out; } - -#ifdef CONFIG_MCA + +#ifdef CONFIG_MCA_LEGACY found: #endif @@ -425,15 +362,8 @@ found: outb(0, ioaddr + RESET); if (is_at1700) { -#ifndef CONFIG_X86_PC9800 irq = at1700_irqmap[(read_eeprom(ioaddr, 12)&0x04) | (read_eeprom(ioaddr, 0)>>14)]; -#else - { - char re1000plus_irqmap[4] = {3, 5, 6, 12}; - irq = re1000plus_irqmap[inb(ioaddr + IOCONFIG1) >> 6]; - } -#endif } else { /* Check PnP mode for FMV-183/184/183A/184A. */ /* This PnP routine is very poor. IO and IRQ should be known. */ @@ -517,11 +447,7 @@ found: /* Switch to bank 2 */ /* Lock our I/O address, and set manual processing mode for 16 collisions. */ outb(0x08, ioaddr + CONFIG_1); -#ifndef CONFIG_X86_PC9800 outb(dev->if_port, ioaddr + MODE13); -#else - outb(0, ioaddr + MODE13); -#endif outb(0x00, ioaddr + COL16CNTL); if (net_debug) @@ -542,7 +468,7 @@ found: lp->jumpered = is_fmv18x; lp->mca_slot = slot; /* Snarf the interrupt vector now. */ - ret = request_irq(irq, &net_interrupt, 0, dev->name, dev); + ret = request_irq(irq, &net_interrupt, 0, DRV_NAME, dev); if (ret) { printk (" AT1700 at %#3x is unusable due to a conflict on" "IRQ %d.\n", ioaddr, irq); @@ -552,34 +478,22 @@ found: return 0; err_mca: -#ifdef CONFIG_MCA +#ifdef CONFIG_MCA_LEGACY if (slot >= 0) mca_mark_as_unused(slot); #endif err_out: -#ifndef CONFIG_X86_PC9800 release_region(ioaddr, AT1700_IO_EXTENT); -#else - for (i = 0; i < 0x2000; i += 0x0200) - release_region(ioaddr + i, 2); -#endif return ret; } - + /* EEPROM_Ctrl bits. */ #define EE_SHIFT_CLK 0x40 /* EEPROM shift clock, in reg. 16. */ #define EE_CS 0x20 /* EEPROM chip select, in reg. 16. */ #define EE_DATA_WRITE 0x80 /* EEPROM chip data in, in reg. 17. */ #define EE_DATA_READ 0x80 /* EEPROM chip data out, in reg. 17. */ -/* Delay between EEPROM clock transitions. */ -#ifndef CONFIG_X86_PC9800 -#define eeprom_delay() do { } while (0) -#else -#define eeprom_delay() __asm__ ("out%B0 %%al,%0" :: "N"(0x5f)) -#endif - /* The EEPROM commands include the alway-set leading bit. */ #define EE_WRITE_CMD (5 << 6) #define EE_READ_CMD (6 << 6) @@ -598,28 +512,23 @@ static int __init read_eeprom(long ioaddr, int location) short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0; outb(EE_CS, ee_addr); outb(dataval, ee_daddr); - eeprom_delay(); outb(EE_CS | EE_SHIFT_CLK, ee_addr); /* EEPROM clock tick. */ - eeprom_delay(); } outb(EE_DATA_WRITE, ee_daddr); for (i = 16; i > 0; i--) { outb(EE_CS, ee_addr); - eeprom_delay(); outb(EE_CS | EE_SHIFT_CLK, ee_addr); - eeprom_delay(); retval = (retval << 1) | ((inb(ee_daddr) & EE_DATA_READ) ? 1 : 0); } /* Terminate the EEPROM access. */ outb(EE_CS, ee_addr); - eeprom_delay(); outb(EE_SHIFT_CLK, ee_addr); outb(0, ee_addr); return retval; } - + static int net_open(struct net_device *dev) { @@ -736,11 +645,10 @@ static int net_send_packet (struct sk_buff *skb, struct net_device *dev) return 0; } - + /* The typical workload of the driver: Handle the network interface interrupts. */ -static irqreturn_t -net_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t net_interrupt(int irq, void *dev_id) { struct net_device *dev = dev_id; struct net_local *lp; @@ -754,9 +662,9 @@ net_interrupt(int irq, void *dev_id, struct pt_regs *regs) ioaddr = dev->base_addr; lp = netdev_priv(dev); - + spin_lock (&lp->lock); - + status = inw(ioaddr + TX_STATUS); outw(status, ioaddr + TX_STATUS); @@ -942,8 +850,6 @@ set_rx_mode(struct net_device *dev) int i; if (dev->flags & IFF_PROMISC) { - /* Unconditionally log net taps. */ - printk("%s: Promiscuous mode enabled.\n", dev->name); memset(mc_filter, 0xff, sizeof(mc_filter)); outb(3, ioaddr + RX_MODE); /* Enable promiscuous mode */ } else if (dev->mc_count > MC_FILTERBREAK @@ -985,14 +891,14 @@ set_rx_mode(struct net_device *dev) #ifdef MODULE static struct net_device *dev_at1700; -MODULE_PARM(io, "i"); -MODULE_PARM(irq, "i"); -MODULE_PARM(net_debug, "i"); +module_param(io, int, 0); +module_param(irq, int, 0); +module_param(net_debug, int, 0); MODULE_PARM_DESC(io, "AT1700/FMV18X I/O base address"); MODULE_PARM_DESC(irq, "AT1700/FMV18X IRQ number"); MODULE_PARM_DESC(net_debug, "AT1700/FMV18X debug level (0-6)"); -int init_module(void) +int __init init_module(void) { if (io == 0) printk("at1700: You should not use auto-probing with insmod!\n"); @@ -1002,7 +908,7 @@ int init_module(void) return 0; } -void +void __exit cleanup_module(void) { unregister_netdev(dev_at1700); @@ -1012,7 +918,7 @@ cleanup_module(void) #endif /* MODULE */ MODULE_LICENSE("GPL"); - + /* * Local variables: * compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c at1700.c"