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.
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 <linux/config.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/crc32.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <asm/io.h>
#include <asm/dma.h>
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. */
* 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
};
/* Offsets from the base address. */
-#ifndef CONFIG_X86_PC9800
#define STATUS 0
#define TX_STATUS 0
#define RX_STATUS 1
#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
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);
-\f
-#ifdef CONFIG_MCA
+
+#ifdef CONFIG_MCA_LEGACY
struct at1720_mca_adapters_struct {
char* name;
int id;
(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)
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
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
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;
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;
}
dev->irq = irq;
-
+
/* claim the slot */
mca_set_adapter_name( slot, at1720_mca_adapters[j].name );
mca_mark_as_used(slot);
else {
goto err_out;
}
-
-#ifdef CONFIG_MCA
+
+#ifdef CONFIG_MCA_LEGACY
found:
#endif
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. */
/* 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)
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);
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;
}
-\f
+
/* 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)
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;
}
-\f
+
static int net_open(struct net_device *dev)
{
return 0;
}
-\f
+
/* 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;
ioaddr = dev->base_addr;
lp = netdev_priv(dev);
-
+
spin_lock (&lp->lock);
-
+
status = inw(ioaddr + TX_STATUS);
outw(status, ioaddr + TX_STATUS);
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
#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");
return 0;
}
-void
+void __exit
cleanup_module(void)
{
unregister_netdev(dev_at1700);
#endif /* MODULE */
MODULE_LICENSE("GPL");
-\f
+
/*
* Local variables:
* compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c at1700.c"