#include <asm/system.h>
#include "8390.h"
-#include "smc-mca.h"
+
+#define DRV_NAME "smc-mca"
static int ultramca_open(struct net_device *dev);
static void ultramca_reset_8390(struct net_device *dev);
static int ultra_irq[MAX_ULTRAMCA_CARDS];
MODULE_LICENSE("GPL");
-MODULE_PARM(ultra_io, "1-" __MODULE_STRING(MAX_ULTRAMCA_CARDS) "i");
-MODULE_PARM(ultra_irq, "1-" __MODULE_STRING(MAX_ULTRAMCA_CARDS) "i");
+module_param_array(ultra_io, int, NULL, 0);
+module_param_array(ultra_irq, int, NULL, 0);
MODULE_PARM_DESC(ultra_io, "SMC Ultra/EtherEZ MCA I/O base address(es)");
MODULE_PARM_DESC(ultra_irq, "SMC Ultra/EtherEZ MCA IRQ number(s)");
+static const struct {
+ unsigned int base_addr;
+} addr_table[] = {
+ { 0x0800 },
+ { 0x1800 },
+ { 0x2800 },
+ { 0x3800 },
+ { 0x4800 },
+ { 0x5800 },
+ { 0x6800 },
+ { 0x7800 },
+ { 0x8800 },
+ { 0x9800 },
+ { 0xa800 },
+ { 0xb800 },
+ { 0xc800 },
+ { 0xd800 },
+ { 0xe800 },
+ { 0xf800 }
+};
+
+#define MEM_MASK 64
+
+static const struct {
+ unsigned char mem_index;
+ unsigned long mem_start;
+ unsigned char num_pages;
+} mem_table[] = {
+ { 16, 0x0c0000, 40 },
+ { 18, 0x0c4000, 40 },
+ { 20, 0x0c8000, 40 },
+ { 22, 0x0cc000, 40 },
+ { 24, 0x0d0000, 40 },
+ { 26, 0x0d4000, 40 },
+ { 28, 0x0d8000, 40 },
+ { 30, 0x0dc000, 40 },
+ {144, 0xfc0000, 40 },
+ {148, 0xfc8000, 40 },
+ {154, 0xfd0000, 40 },
+ {156, 0xfd8000, 40 },
+ { 0, 0x0c0000, 20 },
+ { 1, 0x0c2000, 20 },
+ { 2, 0x0c4000, 20 },
+ { 3, 0x0c6000, 20 }
+};
+
+#define IRQ_MASK 243
+static const struct {
+ unsigned char new_irq;
+ unsigned char old_irq;
+} irq_table[] = {
+ { 3, 3 },
+ { 4, 4 },
+ { 10, 10 },
+ { 14, 15 }
+};
+
static short smc_mca_adapter_ids[] __initdata = {
0x61c8,
0x61c9,
static int ultra_found = 0;
-int __init ultramca_probe(struct device *gen_dev)
+static int __init ultramca_probe(struct device *gen_dev)
{
unsigned short ioaddr;
struct net_device *dev;
break;
}
}
-
- if(!tirq || !tbase
- || (irq && irq != tirq)
+
+ if(!tirq || !tbase
+ || (irq && irq != tirq)
|| (base_addr && tbase != base_addr))
/* FIXME: we're trying to force the ordering of the
* devices here, there should be a way of getting this
* the index of the 0x2000 step.
* beware different number of pages [hs]
*/
- dev->mem_start = (unsigned long)
+ dev->mem_start = (unsigned long)
mca_device_transform_memory(mca_dev, (void *)(0xc0000 + (0x2000 * (pos3 & 0xf))));
num_pages = 0x20 + (2 * (pos3 & 0x10));
break;
goto err_unclaim;
}
- if (!request_region(ioaddr, ULTRA_IO_EXTENT, dev->name)) {
+ if (!request_region(ioaddr, ULTRA_IO_EXTENT, DRV_NAME)) {
rc = -ENODEV;
goto err_unclaim;
}
ei_status.rx_start_page = START_PG + TX_PAGES;
ei_status.stop_page = num_pages;
- ei_status.rmem_start = dev->mem_start + TX_PAGES * 256;
- dev->mem_end = ei_status.rmem_end =
- dev->mem_start + (ei_status.stop_page - START_PG) * 256;
+ ei_status.mem = ioremap(dev->mem_start, (ei_status.stop_page - START_PG) * 256);
+ if (!ei_status.mem) {
+ rc = -ENOMEM;
+ goto err_release_region;
+ }
+
+ dev->mem_end = dev->mem_start + (ei_status.stop_page - START_PG) * 256;
printk(", IRQ %d memory %#lx-%#lx.\n",
dev->irq, dev->mem_start, dev->mem_end - 1);
rc = register_netdev(dev);
if (rc)
- goto err_release_region;
+ goto err_unmap;
return 0;
+err_unmap:
+ iounmap(ei_status.mem);
err_release_region:
release_region(ioaddr, ULTRA_IO_EXTENT);
err_unclaim:
static void ultramca_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
{
- unsigned long hdr_start = dev->mem_start + ((ring_page - START_PG) << 8);
+ void __iomem *hdr_start = ei_status.mem + ((ring_page - START_PG) << 8);
#ifdef notdef
/* Officially this is what we are doing, but the readl() is faster */
- isa_memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
+ memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
#else
- ((unsigned int*)hdr)[0] = isa_readl(hdr_start);
+ ((unsigned int*)hdr)[0] = readl(hdr_start);
#endif
}
static void ultramca_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
{
- unsigned long xfer_start = dev->mem_start + ring_offset - (START_PG << 8);
+ void __iomem *xfer_start = ei_status.mem + ring_offset - START_PG * 256;
- if (xfer_start + count > ei_status.rmem_end) {
+ if (ring_offset + count > ei_status.stop_page * 256) {
/* We must wrap the input move. */
- int semi_count = ei_status.rmem_end - xfer_start;
- isa_memcpy_fromio(skb->data, xfer_start, semi_count);
+ int semi_count = ei_status.stop_page * 256 - ring_offset;
+ memcpy_fromio(skb->data, xfer_start, semi_count);
count -= semi_count;
- isa_memcpy_fromio(skb->data + semi_count, ei_status.rmem_start, count);
+ memcpy_fromio(skb->data + semi_count, ei_status.mem + TX_PAGES * 256, count);
} else {
/* Packet is in one chunk -- we can copy + cksum. */
- isa_eth_io_copy_and_sum(skb, xfer_start, count, 0);
+ eth_io_copy_and_sum(skb, xfer_start, count, 0);
}
}
static void ultramca_block_output(struct net_device *dev, int count, const unsigned char *buf,
int start_page)
{
- unsigned long shmem = dev->mem_start + ((start_page - START_PG) << 8);
+ void __iomem *shmem = ei_status.mem + ((start_page - START_PG) << 8);
- isa_memcpy_toio(shmem, buf, count);
+ memcpy_toio(shmem, buf, count);
}
static int ultramca_close_card(struct net_device *dev)
int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET; /* ASIC addr */
netif_stop_queue(dev);
-
+
if (ei_debug > 1)
printk("%s: Shutting down ethercard.\n", dev->name);
unregister_netdev(dev);
mca_device_set_claim(mca_dev, 0);
release_region(ioaddr, ULTRA_IO_EXTENT);
+ iounmap(ei_status.mem);
free_netdev(dev);
}
return 0;