Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / net / smc-mca.c
index c176df6..f00c476 100644 (file)
@@ -49,7 +49,6 @@
 #include <asm/system.h>
 
 #include "8390.h"
-#include "smc-mca.h"
 
 #define DRV_NAME "smc-mca"
 
@@ -95,11 +94,68 @@ static int ultra_io[MAX_ULTRAMCA_CARDS];
 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,
@@ -126,7 +182,7 @@ static char *smc_mca_adapter_names[] __initdata = {
 
 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;
@@ -310,9 +366,13 @@ int __init ultramca_probe(struct device *gen_dev)
        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);
@@ -334,10 +394,12 @@ int __init ultramca_probe(struct device *gen_dev)
 
        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:
@@ -395,13 +457,13 @@ static void ultramca_reset_8390(struct net_device *dev)
 
 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
 }
 
@@ -411,17 +473,17 @@ static void ultramca_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *
 
 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);
        }
 
 }
@@ -429,9 +491,9 @@ static void ultramca_block_input(struct net_device *dev, int count, struct sk_bu
 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)
@@ -466,6 +528,7 @@ static int ultramca_remove(struct device *gen_dev)
                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;