Commit fc638fe2 authored by Andrew Morton's avatar Andrew Morton Committed by Jeff Garzik

[PATCH] m68k: Amiga A2065 Ethernet new driver model

From: Geert Uytterhoeven <geert@linux-m68k.org>

A2065 Ethernet: Convert to the new driver model
parent dd6143d3
/* /*
* Amiga Linux/68k A2065 Ethernet Driver * Amiga Linux/68k A2065 Ethernet Driver
* *
* (C) Copyright 1995 by Geert Uytterhoeven <geert@linux-m68k.org> * (C) Copyright 1995-2003 by Geert Uytterhoeven <geert@linux-m68k.org>
* *
* Fixes and tips by: * Fixes and tips by:
* - Janos Farkas (CHEXUM@sparta.banki.hu) * - Janos Farkas (CHEXUM@sparta.banki.hu)
...@@ -130,14 +130,8 @@ struct lance_private { ...@@ -130,14 +130,8 @@ struct lance_private {
int burst_sizes; /* ledma SBus burst sizes */ int burst_sizes; /* ledma SBus burst sizes */
#endif #endif
struct timer_list multicast_timer; struct timer_list multicast_timer;
struct net_device *dev; /* Backpointer */
struct lance_private *next_module;
}; };
#ifdef MODULE
static struct lance_private *root_a2065_dev;
#endif
#define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\ #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\
lp->tx_old+lp->tx_ring_mod_mask-lp->tx_new:\ lp->tx_old+lp->tx_ring_mod_mask-lp->tx_new:\
lp->tx_old - lp->tx_new-1) lp->tx_old - lp->tx_new-1)
...@@ -704,133 +698,141 @@ static void lance_set_multicast (struct net_device *dev) ...@@ -704,133 +698,141 @@ static void lance_set_multicast (struct net_device *dev)
netif_wake_queue(dev); netif_wake_queue(dev);
} }
static int __init a2065_probe(void) static int __devinit a2065_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent);
static void __devexit a2065_remove_one(struct zorro_dev *z);
static struct zorro_device_id a2065_zorro_tbl[] __devinitdata = {
{ ZORRO_PROD_CBM_A2065_1 },
{ ZORRO_PROD_CBM_A2065_2 },
{ ZORRO_PROD_AMERISTAR_A2065 },
{ 0 }
};
static struct zorro_driver a2065_driver = {
.name = "a2065",
.id_table = a2065_zorro_tbl,
.probe = a2065_init_one,
.remove = __devexit_p(a2065_remove_one),
};
static int __devinit a2065_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent)
{ {
struct zorro_dev *z = NULL;
struct net_device *dev; struct net_device *dev;
struct lance_private *priv; struct lance_private *priv;
int res = -ENODEV; unsigned long board, base_addr, mem_start;
struct resource *r1, *r2;
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { int err;
unsigned long board, base_addr, mem_start;
struct resource *r1, *r2; board = z->resource.start;
int is_cbm; base_addr = board+A2065_LANCE;
mem_start = board+A2065_RAM;
if (z->id == ZORRO_PROD_CBM_A2065_1 ||
z->id == ZORRO_PROD_CBM_A2065_2) r1 = request_mem_region(base_addr, sizeof(struct lance_regs),
is_cbm = 1; "Am7990");
else if (z->id == ZORRO_PROD_AMERISTAR_A2065) if (!r1)
is_cbm = 0; return -EBUSY;
else r2 = request_mem_region(mem_start, A2065_RAM_SIZE, "RAM");
continue; if (!r2) {
release_resource(r1);
return -EBUSY;
}
board = z->resource.start; dev = alloc_etherdev(sizeof(struct lance_private));
base_addr = board+A2065_LANCE; if (dev == NULL) {
mem_start = board+A2065_RAM; release_resource(r1);
release_resource(r2);
return -ENOMEM;
}
r1 = request_mem_region(base_addr, sizeof(struct lance_regs), SET_MODULE_OWNER(dev);
"Am7990"); priv = dev->priv;
if (!r1) continue;
r2 = request_mem_region(mem_start, A2065_RAM_SIZE, "RAM");
if (!r2) {
release_resource(r1);
continue;
}
dev = alloc_etherdev(sizeof(struct lance_private)); r1->name = dev->name;
r2->name = dev->name;
if (dev == NULL) { dev->dev_addr[0] = 0x00;
release_resource(r1); if (z->id != ZORRO_PROD_AMERISTAR_A2065) { /* Commodore */
release_resource(r2); dev->dev_addr[1] = 0x80;
return -ENOMEM; dev->dev_addr[2] = 0x10;
} } else { /* Ameristar */
SET_MODULE_OWNER(dev); dev->dev_addr[1] = 0x00;
priv = dev->priv; dev->dev_addr[2] = 0x9f;
r1->name = dev->name;
r2->name = dev->name;
priv->dev = dev;
dev->dev_addr[0] = 0x00;
if (is_cbm) { /* Commodore */
dev->dev_addr[1] = 0x80;
dev->dev_addr[2] = 0x10;
} else { /* Ameristar */
dev->dev_addr[1] = 0x00;
dev->dev_addr[2] = 0x9f;
}
dev->dev_addr[3] = (z->rom.er_SerialNumber>>16) & 0xff;
dev->dev_addr[4] = (z->rom.er_SerialNumber>>8) & 0xff;
dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff;
printk("%s: A2065 at 0x%08lx, Ethernet Address "
"%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, board,
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
dev->base_addr = ZTWO_VADDR(base_addr);
dev->mem_start = ZTWO_VADDR(mem_start);
dev->mem_end = dev->mem_start+A2065_RAM_SIZE;
priv->ll = (volatile struct lance_regs *)dev->base_addr;
priv->init_block = (struct lance_init_block *)dev->mem_start;
priv->lance_init_block = (struct lance_init_block *)A2065_RAM;
priv->auto_select = 0;
priv->busmaster_regval = LE_C3_BSWP;
priv->lance_log_rx_bufs = LANCE_LOG_RX_BUFFERS;
priv->lance_log_tx_bufs = LANCE_LOG_TX_BUFFERS;
priv->rx_ring_mod_mask = RX_RING_MOD_MASK;
priv->tx_ring_mod_mask = TX_RING_MOD_MASK;
dev->open = &lance_open;
dev->stop = &lance_close;
dev->hard_start_xmit = &lance_start_xmit;
dev->tx_timeout = &lance_tx_timeout;
dev->watchdog_timeo = 5*HZ;
dev->get_stats = &lance_get_stats;
dev->set_multicast_list = &lance_set_multicast;
dev->dma = 0;
init_timer(&priv->multicast_timer);
priv->multicast_timer.data = (unsigned long) dev;
priv->multicast_timer.function =
(void (*)(unsigned long)) &lance_set_multicast;
res = register_netdev(dev);
if (res) {
release_resource(r1);
release_resource(r2);
free_netdev(dev);
break;
}
#ifdef MODULE
priv->next_module = root_a2065_dev;
root_a2065_dev = priv;
#endif
} }
return res; dev->dev_addr[3] = (z->rom.er_SerialNumber>>16) & 0xff;
dev->dev_addr[4] = (z->rom.er_SerialNumber>>8) & 0xff;
dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff;
printk("%s: A2065 at 0x%08lx, Ethernet Address "
"%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, board,
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
dev->base_addr = ZTWO_VADDR(base_addr);
dev->mem_start = ZTWO_VADDR(mem_start);
dev->mem_end = dev->mem_start+A2065_RAM_SIZE;
priv->ll = (volatile struct lance_regs *)dev->base_addr;
priv->init_block = (struct lance_init_block *)dev->mem_start;
priv->lance_init_block = (struct lance_init_block *)A2065_RAM;
priv->auto_select = 0;
priv->busmaster_regval = LE_C3_BSWP;
priv->lance_log_rx_bufs = LANCE_LOG_RX_BUFFERS;
priv->lance_log_tx_bufs = LANCE_LOG_TX_BUFFERS;
priv->rx_ring_mod_mask = RX_RING_MOD_MASK;
priv->tx_ring_mod_mask = TX_RING_MOD_MASK;
dev->open = &lance_open;
dev->stop = &lance_close;
dev->hard_start_xmit = &lance_start_xmit;
dev->tx_timeout = &lance_tx_timeout;
dev->watchdog_timeo = 5*HZ;
dev->get_stats = &lance_get_stats;
dev->set_multicast_list = &lance_set_multicast;
dev->dma = 0;
init_timer(&priv->multicast_timer);
priv->multicast_timer.data = (unsigned long) dev;
priv->multicast_timer.function =
(void (*)(unsigned long)) &lance_set_multicast;
err = register_netdev(dev);
if (err) {
release_resource(r1);
release_resource(r2);
free_netdev(dev);
return err;
}
zorro_set_drvdata(z, dev);
return 0;
} }
static void __exit a2065_cleanup(void) static void __devexit a2065_remove_one(struct zorro_dev *z)
{ {
#ifdef MODULE struct net_device *dev = zorro_get_drvdata(z);
struct lance_private *next;
struct net_device *dev;
while (root_a2065_dev) { unregister_netdev(dev);
next = root_a2065_dev->next_module; release_mem_region(ZTWO_PADDR(dev->base_addr),
dev = root_a2065_dev->dev; sizeof(struct lance_regs));
unregister_netdev(dev); release_mem_region(ZTWO_PADDR(dev->mem_start), A2065_RAM_SIZE);
release_mem_region(ZTWO_PADDR(dev->base_addr), free_netdev(dev);
sizeof(struct lance_regs)); }
release_mem_region(ZTWO_PADDR(dev->mem_start), A2065_RAM_SIZE);
free_netdev(dev); static int __init a2065_init_module(void)
root_a2065_dev = next; {
} return zorro_module_init(&a2065_driver);
#endif
} }
module_init(a2065_probe); static void __exit a2065_cleanup_module(void)
module_exit(a2065_cleanup); {
zorro_unregister_driver(&a2065_driver);
}
module_init(a2065_init_module);
module_exit(a2065_cleanup_module);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment