diff options
-rw-r--r-- | drivers/net/Kconfig | 7 | ||||
-rw-r--r-- | drivers/net/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/sni_82596.c | 185 |
3 files changed, 193 insertions, 0 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index dbf773356326..5cc3d517e39b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -431,6 +431,13 @@ config LASI_82596 | |||
431 | Say Y here to support the builtin Intel 82596 ethernet controller | 431 | Say Y here to support the builtin Intel 82596 ethernet controller |
432 | found in Hewlett-Packard PA-RISC machines with 10Mbit ethernet. | 432 | found in Hewlett-Packard PA-RISC machines with 10Mbit ethernet. |
433 | 433 | ||
434 | config SNI_82596 | ||
435 | tristate "SNI RM ethernet" | ||
436 | depends on NET_ETHERNET && SNI_RM | ||
437 | help | ||
438 | Say Y here to support the on-board Intel 82596 ethernet controller | ||
439 | built into SNI RM machines. | ||
440 | |||
434 | config MIPS_JAZZ_SONIC | 441 | config MIPS_JAZZ_SONIC |
435 | tristate "MIPS JAZZ onboard SONIC Ethernet support" | 442 | tristate "MIPS JAZZ onboard SONIC Ethernet support" |
436 | depends on MACH_JAZZ | 443 | depends on MACH_JAZZ |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index a77affa4f6e6..eb62fb48e4b7 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -157,6 +157,7 @@ obj-$(CONFIG_ELPLUS) += 3c505.o | |||
157 | obj-$(CONFIG_AC3200) += ac3200.o 8390.o | 157 | obj-$(CONFIG_AC3200) += ac3200.o 8390.o |
158 | obj-$(CONFIG_APRICOT) += 82596.o | 158 | obj-$(CONFIG_APRICOT) += 82596.o |
159 | obj-$(CONFIG_LASI_82596) += lasi_82596.o | 159 | obj-$(CONFIG_LASI_82596) += lasi_82596.o |
160 | obj-$(CONFIG_SNI_82596) += sni_82596.o | ||
160 | obj-$(CONFIG_MVME16x_NET) += 82596.o | 161 | obj-$(CONFIG_MVME16x_NET) += 82596.o |
161 | obj-$(CONFIG_BVME6000_NET) += 82596.o | 162 | obj-$(CONFIG_BVME6000_NET) += 82596.o |
162 | obj-$(CONFIG_SC92031) += sc92031.o | 163 | obj-$(CONFIG_SC92031) += sc92031.o |
diff --git a/drivers/net/sni_82596.c b/drivers/net/sni_82596.c new file mode 100644 index 000000000000..2cf6794acb4f --- /dev/null +++ b/drivers/net/sni_82596.c | |||
@@ -0,0 +1,185 @@ | |||
1 | /* | ||
2 | * sni_82596.c -- driver for intel 82596 ethernet controller, as | ||
3 | * used in older SNI RM machines | ||
4 | */ | ||
5 | |||
6 | #include <linux/module.h> | ||
7 | #include <linux/kernel.h> | ||
8 | #include <linux/string.h> | ||
9 | #include <linux/errno.h> | ||
10 | #include <linux/ioport.h> | ||
11 | #include <linux/slab.h> | ||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/delay.h> | ||
14 | #include <linux/netdevice.h> | ||
15 | #include <linux/etherdevice.h> | ||
16 | #include <linux/skbuff.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/types.h> | ||
19 | #include <linux/bitops.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/io.h> | ||
22 | #include <linux/irq.h> | ||
23 | |||
24 | #define SNI_82596_DRIVER_VERSION "SNI RM 82596 driver - Revision: 0.01" | ||
25 | |||
26 | static const char sni_82596_string[] = "snirm_82596"; | ||
27 | |||
28 | #define DMA_ALLOC dma_alloc_coherent | ||
29 | #define DMA_FREE dma_free_coherent | ||
30 | #define DMA_WBACK(priv, addr, len) do { } while (0) | ||
31 | #define DMA_INV(priv, addr, len) do { } while (0) | ||
32 | #define DMA_WBACK_INV(priv, addr, len) do { } while (0) | ||
33 | |||
34 | #define SYSBUS 0x00004400 | ||
35 | |||
36 | /* big endian CPU, 82596 little endian */ | ||
37 | #define SWAP32(x) cpu_to_le32((u32)(x)) | ||
38 | #define SWAP16(x) cpu_to_le16((u16)(x)) | ||
39 | |||
40 | #define OPT_MPU_16BIT 0x01 | ||
41 | |||
42 | #include "lib82596.c" | ||
43 | |||
44 | MODULE_AUTHOR("Thomas Bogendoerfer"); | ||
45 | MODULE_DESCRIPTION("i82596 driver"); | ||
46 | MODULE_LICENSE("GPL"); | ||
47 | module_param(i596_debug, int, 0); | ||
48 | MODULE_PARM_DESC(i596_debug, "82596 debug mask"); | ||
49 | |||
50 | static inline void ca(struct net_device *dev) | ||
51 | { | ||
52 | struct i596_private *lp = netdev_priv(dev); | ||
53 | |||
54 | writel(0, lp->ca); | ||
55 | } | ||
56 | |||
57 | |||
58 | static void mpu_port(struct net_device *dev, int c, dma_addr_t x) | ||
59 | { | ||
60 | struct i596_private *lp = netdev_priv(dev); | ||
61 | |||
62 | u32 v = (u32) (c) | (u32) (x); | ||
63 | |||
64 | if (lp->options & OPT_MPU_16BIT) { | ||
65 | writew(v & 0xffff, lp->mpu_port); | ||
66 | wmb(); /* order writes to MPU port */ | ||
67 | udelay(1); | ||
68 | writew(v >> 16, lp->mpu_port); | ||
69 | } else { | ||
70 | writel(v, lp->mpu_port); | ||
71 | wmb(); /* order writes to MPU port */ | ||
72 | udelay(1); | ||
73 | writel(v, lp->mpu_port); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | |||
78 | static int __devinit sni_82596_probe(struct platform_device *dev) | ||
79 | { | ||
80 | struct net_device *netdevice; | ||
81 | struct i596_private *lp; | ||
82 | struct resource *res, *ca, *idprom, *options; | ||
83 | int retval = -ENOMEM; | ||
84 | void __iomem *mpu_addr; | ||
85 | void __iomem *ca_addr; | ||
86 | u8 __iomem *eth_addr; | ||
87 | |||
88 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
89 | ca = platform_get_resource(dev, IORESOURCE_MEM, 1); | ||
90 | options = platform_get_resource(dev, 0, 0); | ||
91 | idprom = platform_get_resource(dev, IORESOURCE_MEM, 2); | ||
92 | if (!res || !ca || !options || !idprom) | ||
93 | return -ENODEV; | ||
94 | mpu_addr = ioremap_nocache(res->start, 4); | ||
95 | if (!mpu_addr) | ||
96 | return -ENOMEM; | ||
97 | ca_addr = ioremap_nocache(ca->start, 4); | ||
98 | if (!ca_addr) | ||
99 | goto probe_failed_free_mpu; | ||
100 | |||
101 | printk(KERN_INFO "Found i82596 at 0x%x\n", res->start); | ||
102 | |||
103 | netdevice = alloc_etherdev(sizeof(struct i596_private)); | ||
104 | if (!netdevice) | ||
105 | goto probe_failed_free_ca; | ||
106 | |||
107 | SET_NETDEV_DEV(netdevice, &dev->dev); | ||
108 | platform_set_drvdata (dev, netdevice); | ||
109 | |||
110 | netdevice->base_addr = res->start; | ||
111 | netdevice->irq = platform_get_irq(dev, 0); | ||
112 | |||
113 | eth_addr = ioremap_nocache(idprom->start, 0x10); | ||
114 | if (!eth_addr) | ||
115 | goto probe_failed; | ||
116 | |||
117 | /* someone seems to like messed up stuff */ | ||
118 | netdevice->dev_addr[0] = readb(eth_addr + 0x0b); | ||
119 | netdevice->dev_addr[1] = readb(eth_addr + 0x0a); | ||
120 | netdevice->dev_addr[2] = readb(eth_addr + 0x09); | ||
121 | netdevice->dev_addr[3] = readb(eth_addr + 0x08); | ||
122 | netdevice->dev_addr[4] = readb(eth_addr + 0x07); | ||
123 | netdevice->dev_addr[5] = readb(eth_addr + 0x06); | ||
124 | iounmap(eth_addr); | ||
125 | |||
126 | if (!netdevice->irq) { | ||
127 | printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n", | ||
128 | __FILE__, netdevice->base_addr); | ||
129 | goto probe_failed; | ||
130 | } | ||
131 | |||
132 | lp = netdev_priv(netdevice); | ||
133 | lp->options = options->flags & IORESOURCE_BITS; | ||
134 | lp->ca = ca_addr; | ||
135 | lp->mpu_port = mpu_addr; | ||
136 | |||
137 | retval = i82596_probe(netdevice); | ||
138 | if (retval == 0) | ||
139 | return 0; | ||
140 | |||
141 | probe_failed: | ||
142 | free_netdev(netdevice); | ||
143 | probe_failed_free_ca: | ||
144 | iounmap(ca_addr); | ||
145 | probe_failed_free_mpu: | ||
146 | iounmap(mpu_addr); | ||
147 | return retval; | ||
148 | } | ||
149 | |||
150 | static int __devexit sni_82596_driver_remove(struct platform_device *pdev) | ||
151 | { | ||
152 | struct net_device *dev = platform_get_drvdata(pdev); | ||
153 | struct i596_private *lp = netdev_priv(dev); | ||
154 | |||
155 | unregister_netdev(dev); | ||
156 | DMA_FREE(dev->dev.parent, sizeof(struct i596_private), | ||
157 | lp->dma, lp->dma_addr); | ||
158 | iounmap(lp->ca); | ||
159 | iounmap(lp->mpu_port); | ||
160 | free_netdev (dev); | ||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static struct platform_driver sni_82596_driver = { | ||
165 | .probe = sni_82596_probe, | ||
166 | .remove = __devexit_p(sni_82596_driver_remove), | ||
167 | .driver = { | ||
168 | .name = sni_82596_string, | ||
169 | }, | ||
170 | }; | ||
171 | |||
172 | static int __devinit sni_82596_init(void) | ||
173 | { | ||
174 | printk(KERN_INFO SNI_82596_DRIVER_VERSION "\n"); | ||
175 | return platform_driver_register(&sni_82596_driver); | ||
176 | } | ||
177 | |||
178 | |||
179 | static void __exit sni_82596_exit(void) | ||
180 | { | ||
181 | platform_driver_unregister(&sni_82596_driver); | ||
182 | } | ||
183 | |||
184 | module_init(sni_82596_init); | ||
185 | module_exit(sni_82596_exit); | ||