diff options
author | <jgarzik@pretzel.yyz.us> | 2005-06-04 17:12:32 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-06-04 17:12:32 -0400 |
commit | bdb7a3427be1e31327df0543cc397bf3c994b039 (patch) | |
tree | a5cc2585912388a454e23177181c6dd365983681 /drivers/net | |
parent | 140fedb5f2efd1f23b26afb2d812004556ba9515 (diff) | |
parent | 5aa83a4c0a1568257ff7e249d39af64f75978b97 (diff) |
Automatic merge of /spare/repo/netdev-2.6 branch remove-drivers
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/Kconfig | 23 | ||||
-rw-r--r-- | drivers/net/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/Space.c | 6 | ||||
-rw-r--r-- | drivers/net/fmv18x.c | 689 | ||||
-rw-r--r-- | drivers/net/sk_g16.c | 2066 | ||||
-rw-r--r-- | drivers/net/sk_g16.h | 165 |
6 files changed, 0 insertions, 2951 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index cebee528f3c7..60e3b968553a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -1001,21 +1001,6 @@ config EEXPRESS_PRO | |||
1001 | <file:Documentation/networking/net-modules.txt>. The module | 1001 | <file:Documentation/networking/net-modules.txt>. The module |
1002 | will be called eepro. | 1002 | will be called eepro. |
1003 | 1003 | ||
1004 | config FMV18X | ||
1005 | tristate "FMV-181/182/183/184 support (OBSOLETE)" | ||
1006 | depends on NET_ISA && OBSOLETE | ||
1007 | ---help--- | ||
1008 | If you have a Fujitsu FMV-181/182/183/184 network (Ethernet) card, | ||
1009 | say Y and read the Ethernet-HOWTO, available from | ||
1010 | <http://www.tldp.org/docs.html#howto>. | ||
1011 | |||
1012 | If you use an FMV-183 or FMV-184 and it is not working, you may need | ||
1013 | to disable Plug & Play mode of the card. | ||
1014 | |||
1015 | To compile this driver as a module, choose M here and read | ||
1016 | <file:Documentation/networking/net-modules.txt>. The module | ||
1017 | will be called fmv18x. | ||
1018 | |||
1019 | config HPLAN_PLUS | 1004 | config HPLAN_PLUS |
1020 | tristate "HP PCLAN+ (27247B and 27252A) support" | 1005 | tristate "HP PCLAN+ (27247B and 27252A) support" |
1021 | depends on NET_ISA | 1006 | depends on NET_ISA |
@@ -1104,14 +1089,6 @@ config SEEQ8005 | |||
1104 | <file:Documentation/networking/net-modules.txt>. The module | 1089 | <file:Documentation/networking/net-modules.txt>. The module |
1105 | will be called seeq8005. | 1090 | will be called seeq8005. |
1106 | 1091 | ||
1107 | config SK_G16 | ||
1108 | tristate "SK_G16 support (OBSOLETE)" | ||
1109 | depends on NET_ISA && OBSOLETE | ||
1110 | help | ||
1111 | If you have a network (Ethernet) card of this type, say Y and read | ||
1112 | the Ethernet-HOWTO, available from | ||
1113 | <http://www.tldp.org/docs.html#howto>. | ||
1114 | |||
1115 | config SKMC | 1092 | config SKMC |
1116 | tristate "SKnet MCA support" | 1093 | tristate "SKnet MCA support" |
1117 | depends on NET_ETHERNET && MCA && BROKEN | 1094 | depends on NET_ETHERNET && MCA && BROKEN |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 0d97be0c77d4..a8a656718054 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -74,7 +74,6 @@ obj-$(CONFIG_MAC8390) += mac8390.o 8390.o | |||
74 | obj-$(CONFIG_APNE) += apne.o 8390.o | 74 | obj-$(CONFIG_APNE) += apne.o 8390.o |
75 | obj-$(CONFIG_PCMCIA_PCNET) += 8390.o | 75 | obj-$(CONFIG_PCMCIA_PCNET) += 8390.o |
76 | obj-$(CONFIG_SHAPER) += shaper.o | 76 | obj-$(CONFIG_SHAPER) += shaper.o |
77 | obj-$(CONFIG_SK_G16) += sk_g16.o | ||
78 | obj-$(CONFIG_HP100) += hp100.o | 77 | obj-$(CONFIG_HP100) += hp100.o |
79 | obj-$(CONFIG_SMC9194) += smc9194.o | 78 | obj-$(CONFIG_SMC9194) += smc9194.o |
80 | obj-$(CONFIG_FEC) += fec.o | 79 | obj-$(CONFIG_FEC) += fec.o |
@@ -122,7 +121,6 @@ obj-$(CONFIG_DEFXX) += defxx.o | |||
122 | obj-$(CONFIG_SGISEEQ) += sgiseeq.o | 121 | obj-$(CONFIG_SGISEEQ) += sgiseeq.o |
123 | obj-$(CONFIG_SGI_O2MACE_ETH) += meth.o | 122 | obj-$(CONFIG_SGI_O2MACE_ETH) += meth.o |
124 | obj-$(CONFIG_AT1700) += at1700.o | 123 | obj-$(CONFIG_AT1700) += at1700.o |
125 | obj-$(CONFIG_FMV18X) += fmv18x.o | ||
126 | obj-$(CONFIG_EL1) += 3c501.o | 124 | obj-$(CONFIG_EL1) += 3c501.o |
127 | obj-$(CONFIG_EL16) += 3c507.o | 125 | obj-$(CONFIG_EL16) += 3c507.o |
128 | obj-$(CONFIG_ELMC) += 3c523.o | 126 | obj-$(CONFIG_ELMC) += 3c523.o |
diff --git a/drivers/net/Space.c b/drivers/net/Space.c index fb433325aa27..3707df6b0cfa 100644 --- a/drivers/net/Space.c +++ b/drivers/net/Space.c | |||
@@ -210,9 +210,6 @@ static struct devprobe2 isa_probes[] __initdata = { | |||
210 | #ifdef CONFIG_AT1700 | 210 | #ifdef CONFIG_AT1700 |
211 | {at1700_probe, 0}, | 211 | {at1700_probe, 0}, |
212 | #endif | 212 | #endif |
213 | #ifdef CONFIG_FMV18X /* Fujitsu FMV-181/182 */ | ||
214 | {fmv18x_probe, 0}, | ||
215 | #endif | ||
216 | #ifdef CONFIG_ETH16I | 213 | #ifdef CONFIG_ETH16I |
217 | {eth16i_probe, 0}, /* ICL EtherTeam 16i/32 */ | 214 | {eth16i_probe, 0}, /* ICL EtherTeam 16i/32 */ |
218 | #endif | 215 | #endif |
@@ -243,9 +240,6 @@ static struct devprobe2 isa_probes[] __initdata = { | |||
243 | #ifdef CONFIG_ELPLUS /* 3c505 */ | 240 | #ifdef CONFIG_ELPLUS /* 3c505 */ |
244 | {elplus_probe, 0}, | 241 | {elplus_probe, 0}, |
245 | #endif | 242 | #endif |
246 | #ifdef CONFIG_SK_G16 | ||
247 | {SK_init, 0}, | ||
248 | #endif | ||
249 | #ifdef CONFIG_NI5010 | 243 | #ifdef CONFIG_NI5010 |
250 | {ni5010_probe, 0}, | 244 | {ni5010_probe, 0}, |
251 | #endif | 245 | #endif |
diff --git a/drivers/net/fmv18x.c b/drivers/net/fmv18x.c deleted file mode 100644 index 04c748523471..000000000000 --- a/drivers/net/fmv18x.c +++ /dev/null | |||
@@ -1,689 +0,0 @@ | |||
1 | /* fmv18x.c: A network device driver for the Fujitsu FMV-181/182/183/184. | ||
2 | |||
3 | Original: at1700.c (1993-94 by Donald Becker). | ||
4 | Copyright 1993 United States Government as represented by the | ||
5 | Director, National Security Agency. | ||
6 | The author may be reached as becker@scyld.com, or C/O | ||
7 | Scyld Computing Corporation | ||
8 | 410 Severn Ave., Suite 210 | ||
9 | Annapolis MD 21403 | ||
10 | |||
11 | Modified by Yutaka TAMIYA (tamy@flab.fujitsu.co.jp) | ||
12 | Copyright 1994 Fujitsu Laboratories Ltd. | ||
13 | Special thanks to: | ||
14 | Masayoshi UTAKA (utaka@ace.yk.fujitsu.co.jp) | ||
15 | for testing this driver. | ||
16 | H. NEGISHI (agy, negishi@sun45.psd.cs.fujitsu.co.jp) | ||
17 | for suggestion of some program modification. | ||
18 | Masahiro SEKIGUCHI <seki@sysrap.cs.fujitsu.co.jp> | ||
19 | for suggestion of some program modification. | ||
20 | Kazutoshi MORIOKA (morioka@aurora.oaks.cs.fujitsu.co.jp) | ||
21 | for testing this driver. | ||
22 | |||
23 | This software may be used and distributed according to the terms | ||
24 | of the GNU General Public License, incorporated herein by reference. | ||
25 | |||
26 | This is a device driver for the Fujitsu FMV-181/182/183/184, which | ||
27 | is a straight-forward Fujitsu MB86965 implementation. | ||
28 | |||
29 | Sources: | ||
30 | at1700.c | ||
31 | The Fujitsu MB86965 datasheet. | ||
32 | The Fujitsu FMV-181/182 user's guide | ||
33 | */ | ||
34 | |||
35 | static const char version[] = | ||
36 | "fmv18x.c:v2.2.0 09/24/98 Yutaka TAMIYA (tamy@flab.fujitsu.co.jp)\n"; | ||
37 | |||
38 | #include <linux/module.h> | ||
39 | #include <linux/kernel.h> | ||
40 | #include <linux/types.h> | ||
41 | #include <linux/fcntl.h> | ||
42 | #include <linux/interrupt.h> | ||
43 | #include <linux/ioport.h> | ||
44 | #include <linux/in.h> | ||
45 | #include <linux/slab.h> | ||
46 | #include <linux/string.h> | ||
47 | #include <linux/init.h> | ||
48 | #include <linux/errno.h> | ||
49 | #include <linux/spinlock.h> | ||
50 | #include <linux/netdevice.h> | ||
51 | #include <linux/etherdevice.h> | ||
52 | #include <linux/skbuff.h> | ||
53 | #include <linux/delay.h> | ||
54 | #include <linux/bitops.h> | ||
55 | |||
56 | #include <asm/system.h> | ||
57 | #include <asm/io.h> | ||
58 | #include <asm/dma.h> | ||
59 | |||
60 | #define DRV_NAME "fmv18x" | ||
61 | |||
62 | static unsigned fmv18x_probe_list[] __initdata = { | ||
63 | 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x300, 0x340, 0 | ||
64 | }; | ||
65 | |||
66 | /* use 0 for production, 1 for verification, >2 for debug */ | ||
67 | #ifndef NET_DEBUG | ||
68 | #define NET_DEBUG 1 | ||
69 | #endif | ||
70 | static unsigned int net_debug = NET_DEBUG; | ||
71 | |||
72 | typedef unsigned char uchar; | ||
73 | |||
74 | /* Information that need to be kept for each board. */ | ||
75 | struct net_local { | ||
76 | struct net_device_stats stats; | ||
77 | long open_time; /* Useless example local info. */ | ||
78 | uint tx_started:1; /* Number of packet on the Tx queue. */ | ||
79 | uint tx_queue_ready:1; /* Tx queue is ready to be sent. */ | ||
80 | uint rx_started:1; /* Packets are Rxing. */ | ||
81 | uchar tx_queue; /* Number of packet on the Tx queue. */ | ||
82 | ushort tx_queue_len; /* Current length of the Tx queue. */ | ||
83 | spinlock_t lock; | ||
84 | }; | ||
85 | |||
86 | |||
87 | /* Offsets from the base address. */ | ||
88 | #define STATUS 0 | ||
89 | #define TX_STATUS 0 | ||
90 | #define RX_STATUS 1 | ||
91 | #define TX_INTR 2 /* Bit-mapped interrupt enable registers. */ | ||
92 | #define RX_INTR 3 | ||
93 | #define TX_MODE 4 | ||
94 | #define RX_MODE 5 | ||
95 | #define CONFIG_0 6 /* Misc. configuration settings. */ | ||
96 | #define CONFIG_1 7 | ||
97 | /* Run-time register bank 2 definitions. */ | ||
98 | #define DATAPORT 8 /* Word-wide DMA or programmed-I/O dataport. */ | ||
99 | #define TX_START 10 | ||
100 | #define COL16CNTL 11 /* Controll Reg for 16 collisions */ | ||
101 | #define MODE13 13 | ||
102 | /* Fujitsu FMV-18x Card Configuration */ | ||
103 | #define FJ_STATUS0 0x10 | ||
104 | #define FJ_STATUS1 0x11 | ||
105 | #define FJ_CONFIG0 0x12 | ||
106 | #define FJ_CONFIG1 0x13 | ||
107 | #define FJ_MACADDR 0x14 /* 0x14 - 0x19 */ | ||
108 | #define FJ_BUFCNTL 0x1A | ||
109 | #define FJ_BUFDATA 0x1C | ||
110 | #define FMV18X_IO_EXTENT 32 | ||
111 | |||
112 | /* Index to functions, as function prototypes. */ | ||
113 | |||
114 | static int fmv18x_probe1(struct net_device *dev, short ioaddr); | ||
115 | static int net_open(struct net_device *dev); | ||
116 | static int net_send_packet(struct sk_buff *skb, struct net_device *dev); | ||
117 | static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs *regs); | ||
118 | static void net_rx(struct net_device *dev); | ||
119 | static void net_timeout(struct net_device *dev); | ||
120 | static int net_close(struct net_device *dev); | ||
121 | static struct net_device_stats *net_get_stats(struct net_device *dev); | ||
122 | static void set_multicast_list(struct net_device *dev); | ||
123 | |||
124 | |||
125 | /* Check for a network adaptor of this type, and return '0' iff one exists. | ||
126 | If dev->base_addr == 0, probe all likely locations. | ||
127 | If dev->base_addr == 1, always return failure. | ||
128 | If dev->base_addr == 2, allocate space for the device and return success | ||
129 | (detachable devices only). | ||
130 | */ | ||
131 | |||
132 | static int io = 0x220; | ||
133 | static int irq; | ||
134 | |||
135 | struct net_device * __init fmv18x_probe(int unit) | ||
136 | { | ||
137 | struct net_device *dev = alloc_etherdev(sizeof(struct net_local)); | ||
138 | unsigned *port; | ||
139 | int err = 0; | ||
140 | |||
141 | if (!dev) | ||
142 | return ERR_PTR(-ENODEV); | ||
143 | |||
144 | if (unit >= 0) { | ||
145 | sprintf(dev->name, "eth%d", unit); | ||
146 | netdev_boot_setup_check(dev); | ||
147 | io = dev->base_addr; | ||
148 | irq = dev->irq; | ||
149 | } | ||
150 | |||
151 | SET_MODULE_OWNER(dev); | ||
152 | |||
153 | if (io > 0x1ff) { /* Check a single specified location. */ | ||
154 | err = fmv18x_probe1(dev, io); | ||
155 | } else if (io != 0) { /* Don't probe at all. */ | ||
156 | err = -ENXIO; | ||
157 | } else { | ||
158 | for (port = fmv18x_probe_list; *port; port++) | ||
159 | if (fmv18x_probe1(dev, *port) == 0) | ||
160 | break; | ||
161 | if (!*port) | ||
162 | err = -ENODEV; | ||
163 | } | ||
164 | if (err) | ||
165 | goto out; | ||
166 | err = register_netdev(dev); | ||
167 | if (err) | ||
168 | goto out1; | ||
169 | return dev; | ||
170 | out1: | ||
171 | free_irq(dev->irq, dev); | ||
172 | release_region(dev->base_addr, FMV18X_IO_EXTENT); | ||
173 | out: | ||
174 | free_netdev(dev); | ||
175 | return ERR_PTR(err); | ||
176 | } | ||
177 | |||
178 | /* The Fujitsu datasheet suggests that the NIC be probed for by checking its | ||
179 | "signature", the default bit pattern after a reset. This *doesn't* work -- | ||
180 | there is no way to reset the bus interface without a complete power-cycle! | ||
181 | |||
182 | It turns out that ATI came to the same conclusion I did: the only thing | ||
183 | that can be done is checking a few bits and then diving right into MAC | ||
184 | address check. */ | ||
185 | |||
186 | static int __init fmv18x_probe1(struct net_device *dev, short ioaddr) | ||
187 | { | ||
188 | char irqmap[4] = {3, 7, 10, 15}; | ||
189 | char irqmap_pnp[8] = {3, 4, 5, 7, 9, 10, 11, 15}; | ||
190 | unsigned int i, retval; | ||
191 | struct net_local *lp; | ||
192 | |||
193 | /* Resetting the chip doesn't reset the ISA interface, so don't bother. | ||
194 | That means we have to be careful with the register values we probe for. | ||
195 | */ | ||
196 | |||
197 | if (!request_region(ioaddr, FMV18X_IO_EXTENT, DRV_NAME)) | ||
198 | return -EBUSY; | ||
199 | |||
200 | dev->irq = irq; | ||
201 | dev->base_addr = ioaddr; | ||
202 | |||
203 | /* Check I/O address configuration and Fujitsu vendor code */ | ||
204 | if (inb(ioaddr+FJ_MACADDR ) != 0x00 | ||
205 | || inb(ioaddr+FJ_MACADDR+1) != 0x00 | ||
206 | || inb(ioaddr+FJ_MACADDR+2) != 0x0e) { | ||
207 | retval = -ENODEV; | ||
208 | goto out; | ||
209 | } | ||
210 | |||
211 | /* Check PnP mode for FMV-183/184/183A/184A. */ | ||
212 | /* This PnP routine is very poor. IO and IRQ should be known. */ | ||
213 | if (inb(ioaddr + FJ_STATUS1) & 0x20) { | ||
214 | for (i = 0; i < 8; i++) { | ||
215 | if (dev->irq == irqmap_pnp[i]) | ||
216 | break; | ||
217 | } | ||
218 | if (i == 8) { | ||
219 | retval = -ENODEV; | ||
220 | goto out; | ||
221 | } | ||
222 | } else { | ||
223 | if (fmv18x_probe_list[inb(ioaddr + FJ_CONFIG0) & 0x07] != ioaddr) | ||
224 | return -ENODEV; | ||
225 | dev->irq = irqmap[(inb(ioaddr + FJ_CONFIG0)>>6) & 0x03]; | ||
226 | } | ||
227 | |||
228 | /* Snarf the interrupt vector now. */ | ||
229 | retval = request_irq(dev->irq, &net_interrupt, 0, DRV_NAME, dev); | ||
230 | if (retval) { | ||
231 | printk ("FMV-18x found at %#3x, but it's unusable due to a conflict on" | ||
232 | "IRQ %d.\n", ioaddr, dev->irq); | ||
233 | goto out; | ||
234 | } | ||
235 | |||
236 | printk("%s: FMV-18x found at %#3x, IRQ %d, address ", dev->name, | ||
237 | ioaddr, dev->irq); | ||
238 | |||
239 | for(i = 0; i < 6; i++) { | ||
240 | unsigned char val = inb(ioaddr + FJ_MACADDR + i); | ||
241 | printk("%02x", val); | ||
242 | dev->dev_addr[i] = val; | ||
243 | } | ||
244 | |||
245 | /* "FJ_STATUS0" 12 bit 0x0400 means use regular 100 ohm 10baseT signals, | ||
246 | rather than 150 ohm shielded twisted pair compensation. | ||
247 | 0x0000 == auto-sense the interface | ||
248 | 0x0800 == use TP interface | ||
249 | 0x1800 == use coax interface | ||
250 | */ | ||
251 | { | ||
252 | const char *porttype[] = {"auto-sense", "10baseT", "auto-sense", "10base2/5"}; | ||
253 | ushort setup_value = inb(ioaddr + FJ_STATUS0); | ||
254 | |||
255 | switch( setup_value & 0x07 ){ | ||
256 | case 0x01 /* 10base5 */: | ||
257 | case 0x02 /* 10base2 */: dev->if_port = 0x18; break; | ||
258 | case 0x04 /* 10baseT */: dev->if_port = 0x08; break; | ||
259 | default /* auto-sense*/: dev->if_port = 0x00; break; | ||
260 | } | ||
261 | printk(" %s interface.\n", porttype[(dev->if_port>>3) & 3]); | ||
262 | } | ||
263 | |||
264 | /* Initialize LAN Controller and LAN Card */ | ||
265 | outb(0xda, ioaddr + CONFIG_0); /* Initialize LAN Controller */ | ||
266 | outb(0x00, ioaddr + CONFIG_1); /* Stand by mode */ | ||
267 | outb(0x00, ioaddr + FJ_CONFIG1); /* Disable IRQ of LAN Card */ | ||
268 | outb(0x00, ioaddr + FJ_BUFCNTL); /* Reset ? I'm not sure (TAMIYA) */ | ||
269 | |||
270 | /* wait for a while */ | ||
271 | udelay(200); | ||
272 | |||
273 | /* Set the station address in bank zero. */ | ||
274 | outb(0x00, ioaddr + CONFIG_1); | ||
275 | for (i = 0; i < 6; i++) | ||
276 | outb(dev->dev_addr[i], ioaddr + 8 + i); | ||
277 | |||
278 | /* Switch to bank 1 and set the multicast table to accept none. */ | ||
279 | outb(0x04, ioaddr + CONFIG_1); | ||
280 | for (i = 0; i < 8; i++) | ||
281 | outb(0x00, ioaddr + 8 + i); | ||
282 | |||
283 | /* Switch to bank 2 and lock our I/O address. */ | ||
284 | outb(0x08, ioaddr + CONFIG_1); | ||
285 | outb(dev->if_port, ioaddr + MODE13); | ||
286 | outb(0x00, ioaddr + COL16CNTL); | ||
287 | |||
288 | if (net_debug) | ||
289 | printk(version); | ||
290 | |||
291 | /* Initialize the device structure. */ | ||
292 | dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); | ||
293 | if (!dev->priv) { | ||
294 | retval = -ENOMEM; | ||
295 | goto out_irq; | ||
296 | } | ||
297 | memset(dev->priv, 0, sizeof(struct net_local)); | ||
298 | lp = dev->priv; | ||
299 | spin_lock_init(&lp->lock); | ||
300 | |||
301 | dev->open = net_open; | ||
302 | dev->stop = net_close; | ||
303 | dev->hard_start_xmit = net_send_packet; | ||
304 | dev->tx_timeout = net_timeout; | ||
305 | dev->watchdog_timeo = HZ/10; | ||
306 | dev->get_stats = net_get_stats; | ||
307 | dev->set_multicast_list = set_multicast_list; | ||
308 | return 0; | ||
309 | |||
310 | out_irq: | ||
311 | free_irq(dev->irq, dev); | ||
312 | out: | ||
313 | release_region(ioaddr, FMV18X_IO_EXTENT); | ||
314 | return retval; | ||
315 | } | ||
316 | |||
317 | |||
318 | static int net_open(struct net_device *dev) | ||
319 | { | ||
320 | struct net_local *lp = dev->priv; | ||
321 | int ioaddr = dev->base_addr; | ||
322 | |||
323 | /* Set the configuration register 0 to 32K 100ns. byte-wide memory, | ||
324 | 16 bit bus access, and two 4K Tx, enable the Rx and Tx. */ | ||
325 | outb(0x5a, ioaddr + CONFIG_0); | ||
326 | |||
327 | /* Powerup and switch to register bank 2 for the run-time registers. */ | ||
328 | outb(0xe8, ioaddr + CONFIG_1); | ||
329 | |||
330 | lp->tx_started = 0; | ||
331 | lp->tx_queue_ready = 1; | ||
332 | lp->rx_started = 0; | ||
333 | lp->tx_queue = 0; | ||
334 | lp->tx_queue_len = 0; | ||
335 | |||
336 | /* Clear Tx and Rx Status */ | ||
337 | outb(0xff, ioaddr + TX_STATUS); | ||
338 | outb(0xff, ioaddr + RX_STATUS); | ||
339 | lp->open_time = jiffies; | ||
340 | |||
341 | netif_start_queue(dev); | ||
342 | |||
343 | /* Enable the IRQ of the LAN Card */ | ||
344 | outb(0x80, ioaddr + FJ_CONFIG1); | ||
345 | |||
346 | /* Enable both Tx and Rx interrupts */ | ||
347 | outw(0x8182, ioaddr+TX_INTR); | ||
348 | |||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | static void net_timeout(struct net_device *dev) | ||
353 | { | ||
354 | struct net_local *lp = dev->priv; | ||
355 | int ioaddr = dev->base_addr; | ||
356 | unsigned long flags; | ||
357 | |||
358 | |||
359 | printk(KERN_WARNING "%s: transmit timed out with status %04x, %s?\n", dev->name, | ||
360 | htons(inw(ioaddr + TX_STATUS)), | ||
361 | inb(ioaddr + TX_STATUS) & 0x80 | ||
362 | ? "IRQ conflict" : "network cable problem"); | ||
363 | printk(KERN_WARNING "%s: timeout registers: %04x %04x %04x %04x %04x %04x %04x %04x.\n", | ||
364 | dev->name, htons(inw(ioaddr + 0)), | ||
365 | htons(inw(ioaddr + 2)), htons(inw(ioaddr + 4)), | ||
366 | htons(inw(ioaddr + 6)), htons(inw(ioaddr + 8)), | ||
367 | htons(inw(ioaddr +10)), htons(inw(ioaddr +12)), | ||
368 | htons(inw(ioaddr +14))); | ||
369 | printk(KERN_WARNING "eth card: %04x %04x\n", | ||
370 | htons(inw(ioaddr+FJ_STATUS0)), | ||
371 | htons(inw(ioaddr+FJ_CONFIG0))); | ||
372 | lp->stats.tx_errors++; | ||
373 | /* ToDo: We should try to restart the adaptor... */ | ||
374 | spin_lock_irqsave(&lp->lock, flags); | ||
375 | |||
376 | /* Initialize LAN Controller and LAN Card */ | ||
377 | outb(0xda, ioaddr + CONFIG_0); /* Initialize LAN Controller */ | ||
378 | outb(0x00, ioaddr + CONFIG_1); /* Stand by mode */ | ||
379 | outb(0x00, ioaddr + FJ_CONFIG1); /* Disable IRQ of LAN Card */ | ||
380 | outb(0x00, ioaddr + FJ_BUFCNTL); /* Reset ? I'm not sure */ | ||
381 | net_open(dev); | ||
382 | spin_unlock_irqrestore(&lp->lock, flags); | ||
383 | |||
384 | netif_wake_queue(dev); | ||
385 | } | ||
386 | |||
387 | static int net_send_packet(struct sk_buff *skb, struct net_device *dev) | ||
388 | { | ||
389 | struct net_local *lp = dev->priv; | ||
390 | int ioaddr = dev->base_addr; | ||
391 | short length = skb->len; | ||
392 | unsigned char *buf; | ||
393 | unsigned long flags; | ||
394 | |||
395 | /* Block a transmit from overlapping. */ | ||
396 | |||
397 | if (length > ETH_FRAME_LEN) { | ||
398 | if (net_debug) | ||
399 | printk("%s: Attempting to send a large packet (%d bytes).\n", | ||
400 | dev->name, length); | ||
401 | return 1; | ||
402 | } | ||
403 | |||
404 | if (length < ETH_ZLEN) { | ||
405 | skb = skb_padto(skb, ETH_ZLEN); | ||
406 | if (skb == NULL) | ||
407 | return 0; | ||
408 | length = ETH_ZLEN; | ||
409 | } | ||
410 | buf = skb->data; | ||
411 | |||
412 | if (net_debug > 4) | ||
413 | printk("%s: Transmitting a packet of length %lu.\n", dev->name, | ||
414 | (unsigned long)skb->len); | ||
415 | /* We may not start transmitting unless we finish transferring | ||
416 | a packet into the Tx queue. During executing the following | ||
417 | codes we possibly catch a Tx interrupt. Thus we flag off | ||
418 | tx_queue_ready, so that we prevent the interrupt routine | ||
419 | (net_interrupt) to start transmitting. */ | ||
420 | spin_lock_irqsave(&lp->lock, flags); | ||
421 | lp->tx_queue_ready = 0; | ||
422 | { | ||
423 | outw(length, ioaddr + DATAPORT); | ||
424 | outsw(ioaddr + DATAPORT, buf, (length + 1) >> 1); | ||
425 | lp->tx_queue++; | ||
426 | lp->tx_queue_len += length + 2; | ||
427 | } | ||
428 | lp->tx_queue_ready = 1; | ||
429 | spin_unlock_irqrestore(&lp->lock, flags); | ||
430 | |||
431 | if (lp->tx_started == 0) { | ||
432 | /* If the Tx is idle, always trigger a transmit. */ | ||
433 | outb(0x80 | lp->tx_queue, ioaddr + TX_START); | ||
434 | lp->tx_queue = 0; | ||
435 | lp->tx_queue_len = 0; | ||
436 | dev->trans_start = jiffies; | ||
437 | lp->tx_started = 1; | ||
438 | } else if (lp->tx_queue_len >= 4096 - 1502) /* No room for a packet */ | ||
439 | netif_stop_queue(dev); | ||
440 | |||
441 | dev_kfree_skb(skb); | ||
442 | return 0; | ||
443 | } | ||
444 | |||
445 | /* The typical workload of the driver: | ||
446 | Handle the network interface interrupts. */ | ||
447 | static irqreturn_t | ||
448 | net_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
449 | { | ||
450 | struct net_device *dev = dev_id; | ||
451 | struct net_local *lp; | ||
452 | int ioaddr, status; | ||
453 | |||
454 | ioaddr = dev->base_addr; | ||
455 | lp = dev->priv; | ||
456 | status = inw(ioaddr + TX_STATUS); | ||
457 | outw(status, ioaddr + TX_STATUS); | ||
458 | |||
459 | if (net_debug > 4) | ||
460 | printk("%s: Interrupt with status %04x.\n", dev->name, status); | ||
461 | if (lp->rx_started == 0 && | ||
462 | (status & 0xff00 || (inb(ioaddr + RX_MODE) & 0x40) == 0)) { | ||
463 | /* Got a packet(s). | ||
464 | We cannot execute net_rx more than once at the same time for | ||
465 | the same device. During executing net_rx, we possibly catch a | ||
466 | Tx interrupt. Thus we flag on rx_started, so that we prevent | ||
467 | the interrupt routine (net_interrupt) to dive into net_rx | ||
468 | again. */ | ||
469 | lp->rx_started = 1; | ||
470 | outb(0x00, ioaddr + RX_INTR); /* Disable RX intr. */ | ||
471 | net_rx(dev); | ||
472 | outb(0x81, ioaddr + RX_INTR); /* Enable RX intr. */ | ||
473 | lp->rx_started = 0; | ||
474 | } | ||
475 | if (status & 0x00ff) { | ||
476 | if (status & 0x02) { | ||
477 | /* More than 16 collisions occurred */ | ||
478 | if (net_debug > 4) | ||
479 | printk("%s: 16 Collision occur during Txing.\n", dev->name); | ||
480 | /* Cancel sending a packet. */ | ||
481 | outb(0x03, ioaddr + COL16CNTL); | ||
482 | lp->stats.collisions++; | ||
483 | } | ||
484 | if (status & 0x82) { | ||
485 | spin_lock(&lp->lock); | ||
486 | lp->stats.tx_packets++; | ||
487 | if (lp->tx_queue && lp->tx_queue_ready) { | ||
488 | outb(0x80 | lp->tx_queue, ioaddr + TX_START); | ||
489 | lp->tx_queue = 0; | ||
490 | lp->tx_queue_len = 0; | ||
491 | dev->trans_start = jiffies; | ||
492 | netif_wake_queue(dev); /* Inform upper layers. */ | ||
493 | } else { | ||
494 | lp->tx_started = 0; | ||
495 | netif_wake_queue(dev); /* Inform upper layers. */ | ||
496 | } | ||
497 | spin_unlock(&lp->lock); | ||
498 | } | ||
499 | } | ||
500 | return IRQ_RETVAL(status); | ||
501 | } | ||
502 | |||
503 | /* We have a good packet(s), get it/them out of the buffers. */ | ||
504 | static void net_rx(struct net_device *dev) | ||
505 | { | ||
506 | struct net_local *lp = dev->priv; | ||
507 | int ioaddr = dev->base_addr; | ||
508 | int boguscount = 5; | ||
509 | |||
510 | while ((inb(ioaddr + RX_MODE) & 0x40) == 0) { | ||
511 | /* Clear PKT_RDY bit: by agy 19940922 */ | ||
512 | /* outb(0x80, ioaddr + RX_STATUS); */ | ||
513 | ushort status = inw(ioaddr + DATAPORT); | ||
514 | |||
515 | if (net_debug > 4) | ||
516 | printk("%s: Rxing packet mode %02x status %04x.\n", | ||
517 | dev->name, inb(ioaddr + RX_MODE), status); | ||
518 | #ifndef final_version | ||
519 | if (status == 0) { | ||
520 | outb(0x05, ioaddr + 14); | ||
521 | break; | ||
522 | } | ||
523 | #endif | ||
524 | |||
525 | if ((status & 0xF0) != 0x20) { /* There was an error. */ | ||
526 | lp->stats.rx_errors++; | ||
527 | if (status & 0x08) lp->stats.rx_length_errors++; | ||
528 | if (status & 0x04) lp->stats.rx_frame_errors++; | ||
529 | if (status & 0x02) lp->stats.rx_crc_errors++; | ||
530 | if (status & 0x01) lp->stats.rx_over_errors++; | ||
531 | } else { | ||
532 | ushort pkt_len = inw(ioaddr + DATAPORT); | ||
533 | /* Malloc up new buffer. */ | ||
534 | struct sk_buff *skb; | ||
535 | |||
536 | if (pkt_len > 1550) { | ||
537 | printk("%s: The FMV-18x claimed a very large packet, size %d.\n", | ||
538 | dev->name, pkt_len); | ||
539 | outb(0x05, ioaddr + 14); | ||
540 | lp->stats.rx_errors++; | ||
541 | break; | ||
542 | } | ||
543 | skb = dev_alloc_skb(pkt_len+3); | ||
544 | if (skb == NULL) { | ||
545 | printk("%s: Memory squeeze, dropping packet (len %d).\n", | ||
546 | dev->name, pkt_len); | ||
547 | outb(0x05, ioaddr + 14); | ||
548 | lp->stats.rx_dropped++; | ||
549 | break; | ||
550 | } | ||
551 | skb->dev = dev; | ||
552 | skb_reserve(skb,2); | ||
553 | |||
554 | insw(ioaddr + DATAPORT, skb_put(skb,pkt_len), (pkt_len + 1) >> 1); | ||
555 | |||
556 | if (net_debug > 5) { | ||
557 | int i; | ||
558 | printk("%s: Rxed packet of length %d: ", dev->name, pkt_len); | ||
559 | for (i = 0; i < 14; i++) | ||
560 | printk(" %02x", skb->data[i]); | ||
561 | printk(".\n"); | ||
562 | } | ||
563 | |||
564 | skb->protocol=eth_type_trans(skb, dev); | ||
565 | netif_rx(skb); | ||
566 | dev->last_rx = jiffies; | ||
567 | lp->stats.rx_packets++; | ||
568 | lp->stats.rx_bytes += pkt_len; | ||
569 | } | ||
570 | if (--boguscount <= 0) | ||
571 | break; | ||
572 | } | ||
573 | |||
574 | /* If any worth-while packets have been received, dev_rint() | ||
575 | has done a mark_bh(NET_BH) for us and will work on them | ||
576 | when we get to the bottom-half routine. */ | ||
577 | { | ||
578 | int i; | ||
579 | for (i = 0; i < 20; i++) { | ||
580 | if ((inb(ioaddr + RX_MODE) & 0x40) == 0x40) | ||
581 | break; | ||
582 | (void)inw(ioaddr + DATAPORT); /* dummy status read */ | ||
583 | outb(0x05, ioaddr + 14); | ||
584 | } | ||
585 | |||
586 | if (net_debug > 5 && i > 0) | ||
587 | printk("%s: Exint Rx packet with mode %02x after %d ticks.\n", | ||
588 | dev->name, inb(ioaddr + RX_MODE), i); | ||
589 | } | ||
590 | |||
591 | return; | ||
592 | } | ||
593 | |||
594 | /* The inverse routine to net_open(). */ | ||
595 | static int net_close(struct net_device *dev) | ||
596 | { | ||
597 | int ioaddr = dev->base_addr; | ||
598 | |||
599 | ((struct net_local *)dev->priv)->open_time = 0; | ||
600 | |||
601 | netif_stop_queue(dev); | ||
602 | |||
603 | /* Set configuration register 0 to disable Tx and Rx. */ | ||
604 | outb(0xda, ioaddr + CONFIG_0); | ||
605 | |||
606 | /* Update the statistics -- ToDo. */ | ||
607 | |||
608 | /* Power-down the chip. Green, green, green! */ | ||
609 | outb(0x00, ioaddr + CONFIG_1); | ||
610 | |||
611 | /* Set the ethernet adaptor disable IRQ */ | ||
612 | outb(0x00, ioaddr + FJ_CONFIG1); | ||
613 | |||
614 | return 0; | ||
615 | } | ||
616 | |||
617 | /* Get the current statistics. This may be called with the card open or | ||
618 | closed. */ | ||
619 | static struct net_device_stats *net_get_stats(struct net_device *dev) | ||
620 | { | ||
621 | struct net_local *lp = dev->priv; | ||
622 | return &lp->stats; | ||
623 | } | ||
624 | |||
625 | /* Set or clear the multicast filter for this adaptor. | ||
626 | num_addrs == -1 Promiscuous mode, receive all packets | ||
627 | num_addrs == 0 Normal mode, clear multicast list | ||
628 | num_addrs > 0 Multicast mode, receive normal and MC packets, and do | ||
629 | best-effort filtering. | ||
630 | */ | ||
631 | |||
632 | static void set_multicast_list(struct net_device *dev) | ||
633 | { | ||
634 | short ioaddr = dev->base_addr; | ||
635 | if (dev->mc_count || dev->flags&(IFF_PROMISC|IFF_ALLMULTI)) | ||
636 | { | ||
637 | /* | ||
638 | * We must make the kernel realise we had to move | ||
639 | * into promisc mode or we start all out war on | ||
640 | * the cable. - AC | ||
641 | */ | ||
642 | dev->flags|=IFF_PROMISC; | ||
643 | |||
644 | outb(3, ioaddr + RX_MODE); /* Enable promiscuous mode */ | ||
645 | } | ||
646 | else | ||
647 | outb(2, ioaddr + RX_MODE); /* Disable promiscuous, use normal mode */ | ||
648 | } | ||
649 | |||
650 | #ifdef MODULE | ||
651 | static struct net_device *dev_fmv18x; | ||
652 | |||
653 | MODULE_PARM(io, "i"); | ||
654 | MODULE_PARM(irq, "i"); | ||
655 | MODULE_PARM(net_debug, "i"); | ||
656 | MODULE_PARM_DESC(io, "FMV-18X I/O address"); | ||
657 | MODULE_PARM_DESC(irq, "FMV-18X IRQ number"); | ||
658 | MODULE_PARM_DESC(net_debug, "FMV-18X debug level (0-1,5-6)"); | ||
659 | MODULE_LICENSE("GPL"); | ||
660 | |||
661 | int init_module(void) | ||
662 | { | ||
663 | if (io == 0) | ||
664 | printk("fmv18x: You should not use auto-probing with insmod!\n"); | ||
665 | dev_fmv18x = fmv18x_probe(-1); | ||
666 | if (IS_ERR(dev_fmv18x)) | ||
667 | return PTR_ERR(dev_fmv18x); | ||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | void | ||
672 | cleanup_module(void) | ||
673 | { | ||
674 | unregister_netdev(dev_fmv18x); | ||
675 | free_irq(dev_fmv18x->irq, dev_fmv18x); | ||
676 | release_region(dev_fmv18x->base_addr, FMV18X_IO_EXTENT); | ||
677 | free_netdev(dev_fmv18x); | ||
678 | } | ||
679 | #endif /* MODULE */ | ||
680 | |||
681 | /* | ||
682 | * Local variables: | ||
683 | * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c fmv18x.c" | ||
684 | * version-control: t | ||
685 | * kept-new-versions: 5 | ||
686 | * tab-width: 4 | ||
687 | * c-indent-level: 4 | ||
688 | * End: | ||
689 | */ | ||
diff --git a/drivers/net/sk_g16.c b/drivers/net/sk_g16.c deleted file mode 100644 index 134ae0e6495b..000000000000 --- a/drivers/net/sk_g16.c +++ /dev/null | |||
@@ -1,2066 +0,0 @@ | |||
1 | /*- | ||
2 | * Copyright (C) 1994 by PJD Weichmann & SWS Bern, Switzerland | ||
3 | * | ||
4 | * This software may be used and distributed according to the terms | ||
5 | * of the GNU General Public License, incorporated herein by reference. | ||
6 | * | ||
7 | * Module : sk_g16.c | ||
8 | * | ||
9 | * Version : $Revision: 1.1 $ | ||
10 | * | ||
11 | * Author : Patrick J.D. Weichmann | ||
12 | * | ||
13 | * Date Created : 94/05/26 | ||
14 | * Last Updated : $Date: 1994/06/30 16:25:15 $ | ||
15 | * | ||
16 | * Description : Schneider & Koch G16 Ethernet Device Driver for | ||
17 | * Linux Kernel >= 1.1.22 | ||
18 | * Update History : | ||
19 | * Paul Gortmaker, 03/97: Fix for v2.1.x to use read{b,w} | ||
20 | * write{b,w} and memcpy -> memcpy_{to,from}io | ||
21 | * | ||
22 | * Jeff Garzik, 06/2000, Modularize | ||
23 | * | ||
24 | -*/ | ||
25 | |||
26 | static const char rcsid[] = "$Id: sk_g16.c,v 1.1 1994/06/30 16:25:15 root Exp $"; | ||
27 | |||
28 | /* | ||
29 | * The Schneider & Koch (SK) G16 Network device driver is based | ||
30 | * on the 'ni6510' driver from Michael Hipp which can be found at | ||
31 | * ftp://sunsite.unc.edu/pub/Linux/system/Network/drivers/nidrivers.tar.gz | ||
32 | * | ||
33 | * Sources: 1) ni6510.c by M. Hipp | ||
34 | * 2) depca.c by D.C. Davies | ||
35 | * 3) skeleton.c by D. Becker | ||
36 | * 4) Am7990 Local Area Network Controller for Ethernet (LANCE), | ||
37 | * AMD, Pub. #05698, June 1989 | ||
38 | * | ||
39 | * Many Thanks for helping me to get things working to: | ||
40 | * | ||
41 | * A. Cox (A.Cox@swansea.ac.uk) | ||
42 | * M. Hipp (mhipp@student.uni-tuebingen.de) | ||
43 | * R. Bolz (Schneider & Koch, Germany) | ||
44 | * | ||
45 | * To Do: | ||
46 | * - Support of SK_G8 and other SK Network Cards. | ||
47 | * - Autoset memory mapped RAM. Check for free memory and then | ||
48 | * configure RAM correctly. | ||
49 | * - SK_close should really set card in to initial state. | ||
50 | * - Test if IRQ 3 is not switched off. Use autoirq() functionality. | ||
51 | * (as in /drivers/net/skeleton.c) | ||
52 | * - Implement Multicast addressing. At minimum something like | ||
53 | * in depca.c. | ||
54 | * - Redo the statistics part. | ||
55 | * - Try to find out if the board is in 8 Bit or 16 Bit slot. | ||
56 | * If in 8 Bit mode don't use IRQ 11. | ||
57 | * - (Try to make it slightly faster.) | ||
58 | * - Power management support | ||
59 | */ | ||
60 | |||
61 | #include <linux/module.h> | ||
62 | #include <linux/kernel.h> | ||
63 | #include <linux/fcntl.h> | ||
64 | #include <linux/ioport.h> | ||
65 | #include <linux/interrupt.h> | ||
66 | #include <linux/slab.h> | ||
67 | #include <linux/string.h> | ||
68 | #include <linux/delay.h> | ||
69 | #include <linux/errno.h> | ||
70 | #include <linux/init.h> | ||
71 | #include <linux/spinlock.h> | ||
72 | #include <linux/netdevice.h> | ||
73 | #include <linux/etherdevice.h> | ||
74 | #include <linux/skbuff.h> | ||
75 | #include <linux/bitops.h> | ||
76 | |||
77 | #include <asm/system.h> | ||
78 | #include <asm/io.h> | ||
79 | |||
80 | #include "sk_g16.h" | ||
81 | |||
82 | /* | ||
83 | * Schneider & Koch Card Definitions | ||
84 | * ================================= | ||
85 | */ | ||
86 | |||
87 | #define SK_NAME "SK_G16" | ||
88 | |||
89 | /* | ||
90 | * SK_G16 Configuration | ||
91 | * -------------------- | ||
92 | */ | ||
93 | |||
94 | /* | ||
95 | * Abbreviations | ||
96 | * ------------- | ||
97 | * | ||
98 | * RAM - used for the 16KB shared memory | ||
99 | * Boot_ROM, ROM - are used for referencing the BootEPROM | ||
100 | * | ||
101 | * SK_BOOT_ROM and SK_ADDR are symbolic constants used to configure | ||
102 | * the behaviour of the driver and the SK_G16. | ||
103 | * | ||
104 | * ! See sk_g16.install on how to install and configure the driver ! | ||
105 | * | ||
106 | * SK_BOOT_ROM defines if the Boot_ROM should be switched off or not. | ||
107 | * | ||
108 | * SK_ADDR defines the address where the RAM will be mapped into the real | ||
109 | * host memory. | ||
110 | * valid addresses are from 0xa0000 to 0xfc000 in 16Kbyte steps. | ||
111 | */ | ||
112 | |||
113 | #define SK_BOOT_ROM 1 /* 1=BootROM on 0=off */ | ||
114 | |||
115 | #define SK_ADDR 0xcc000 | ||
116 | |||
117 | /* | ||
118 | * In POS3 are bits A14-A19 of the address bus. These bits can be set | ||
119 | * to choose the RAM address. That's why we only can choose the RAM address | ||
120 | * in 16KB steps. | ||
121 | */ | ||
122 | |||
123 | #define POS_ADDR (rom_addr>>14) /* Do not change this line */ | ||
124 | |||
125 | /* | ||
126 | * SK_G16 I/O PORT's + IRQ's + Boot_ROM locations | ||
127 | * ---------------------------------------------- | ||
128 | */ | ||
129 | |||
130 | /* | ||
131 | * As nearly every card has also SK_G16 a specified I/O Port region and | ||
132 | * only a few possible IRQ's. | ||
133 | * In the Installation Guide from Schneider & Koch is listed a possible | ||
134 | * Interrupt IRQ2. IRQ2 is always IRQ9 in boards with two cascaded interrupt | ||
135 | * controllers. So we use in SK_IRQS IRQ9. | ||
136 | */ | ||
137 | |||
138 | /* Don't touch any of the following #defines. */ | ||
139 | |||
140 | #define SK_IO_PORTS { 0x100, 0x180, 0x208, 0x220, 0x288, 0x320, 0x328, 0x390, 0 } | ||
141 | |||
142 | #define SK_IRQS { 3, 5, 9, 11, 0 } | ||
143 | |||
144 | #define SK_BOOT_ROM_LOCATIONS { 0xc0000, 0xc4000, 0xc8000, 0xcc000, 0xd0000, 0xd4000, 0xd8000, 0xdc000, 0 } | ||
145 | |||
146 | #define SK_BOOT_ROM_ID { 0x55, 0xaa, 0x10, 0x50, 0x06, 0x33 } | ||
147 | |||
148 | /* | ||
149 | * SK_G16 POS REGISTERS | ||
150 | * -------------------- | ||
151 | */ | ||
152 | |||
153 | /* | ||
154 | * SK_G16 has a Programmable Option Select (POS) Register. | ||
155 | * The POS is composed of 8 separate registers (POS0-7) which | ||
156 | * are I/O mapped on an address set by the W1 switch. | ||
157 | * | ||
158 | */ | ||
159 | |||
160 | #define SK_POS_SIZE 8 /* 8 I/O Ports are used by SK_G16 */ | ||
161 | |||
162 | #define SK_POS0 ioaddr /* Card-ID Low (R) */ | ||
163 | #define SK_POS1 ioaddr+1 /* Card-ID High (R) */ | ||
164 | #define SK_POS2 ioaddr+2 /* Card-Enable, Boot-ROM Disable (RW) */ | ||
165 | #define SK_POS3 ioaddr+3 /* Base address of RAM */ | ||
166 | #define SK_POS4 ioaddr+4 /* IRQ */ | ||
167 | |||
168 | /* POS5 - POS7 are unused */ | ||
169 | |||
170 | /* | ||
171 | * SK_G16 MAC PREFIX | ||
172 | * ----------------- | ||
173 | */ | ||
174 | |||
175 | /* | ||
176 | * Scheider & Koch manufacturer code (00:00:a5). | ||
177 | * This must be checked, that we are sure it is a SK card. | ||
178 | */ | ||
179 | |||
180 | #define SK_MAC0 0x00 | ||
181 | #define SK_MAC1 0x00 | ||
182 | #define SK_MAC2 0x5a | ||
183 | |||
184 | /* | ||
185 | * SK_G16 ID | ||
186 | * --------- | ||
187 | */ | ||
188 | |||
189 | /* | ||
190 | * If POS0,POS1 contain the following ID, then we know | ||
191 | * at which I/O Port Address we are. | ||
192 | */ | ||
193 | |||
194 | #define SK_IDLOW 0xfd | ||
195 | #define SK_IDHIGH 0x6a | ||
196 | |||
197 | |||
198 | /* | ||
199 | * LANCE POS Bit definitions | ||
200 | * ------------------------- | ||
201 | */ | ||
202 | |||
203 | #define SK_ROM_RAM_ON (POS2_CARD) | ||
204 | #define SK_ROM_RAM_OFF (POS2_EPROM) | ||
205 | #define SK_ROM_ON (inb(SK_POS2) & POS2_CARD) | ||
206 | #define SK_ROM_OFF (inb(SK_POS2) | POS2_EPROM) | ||
207 | #define SK_RAM_ON (inb(SK_POS2) | POS2_CARD) | ||
208 | #define SK_RAM_OFF (inb(SK_POS2) & POS2_EPROM) | ||
209 | |||
210 | #define POS2_CARD 0x0001 /* 1 = SK_G16 on 0 = off */ | ||
211 | #define POS2_EPROM 0x0002 /* 1 = Boot EPROM off 0 = on */ | ||
212 | |||
213 | /* | ||
214 | * SK_G16 Memory mapped Registers | ||
215 | * ------------------------------ | ||
216 | * | ||
217 | */ | ||
218 | |||
219 | #define SK_IOREG (&board->ioreg) /* LANCE data registers. */ | ||
220 | #define SK_PORT (&board->port) /* Control, Status register */ | ||
221 | #define SK_IOCOM (&board->iocom) /* I/O Command */ | ||
222 | |||
223 | /* | ||
224 | * SK_G16 Status/Control Register bits | ||
225 | * ----------------------------------- | ||
226 | * | ||
227 | * (C) Controlreg (S) Statusreg | ||
228 | */ | ||
229 | |||
230 | /* | ||
231 | * Register transfer: 0 = no transfer | ||
232 | * 1 = transferring data between LANCE and I/O reg | ||
233 | */ | ||
234 | #define SK_IORUN 0x20 | ||
235 | |||
236 | /* | ||
237 | * LANCE interrupt: 0 = LANCE interrupt occurred | ||
238 | * 1 = no LANCE interrupt occurred | ||
239 | */ | ||
240 | #define SK_IRQ 0x10 | ||
241 | |||
242 | #define SK_RESET 0x08 /* Reset SK_CARD: 0 = RESET 1 = normal */ | ||
243 | #define SK_RW 0x02 /* 0 = write to 1 = read from */ | ||
244 | #define SK_ADR 0x01 /* 0 = REG DataPort 1 = RAP Reg addr port */ | ||
245 | |||
246 | |||
247 | #define SK_RREG SK_RW /* Transferdirection to read from lance */ | ||
248 | #define SK_WREG 0 /* Transferdirection to write to lance */ | ||
249 | #define SK_RAP SK_ADR /* Destination Register RAP */ | ||
250 | #define SK_RDATA 0 /* Destination Register REG DataPort */ | ||
251 | |||
252 | /* | ||
253 | * SK_G16 I/O Command | ||
254 | * ------------------ | ||
255 | */ | ||
256 | |||
257 | /* | ||
258 | * Any bitcombination sets the internal I/O bit (transfer will start) | ||
259 | * when written to I/O Command | ||
260 | */ | ||
261 | |||
262 | #define SK_DOIO 0x80 /* Do Transfer */ | ||
263 | |||
264 | /* | ||
265 | * LANCE RAP (Register Address Port). | ||
266 | * --------------------------------- | ||
267 | */ | ||
268 | |||
269 | /* | ||
270 | * The LANCE internal registers are selected through the RAP. | ||
271 | * The Registers are: | ||
272 | * | ||
273 | * CSR0 - Status and Control flags | ||
274 | * CSR1 - Low order bits of initialize block (bits 15:00) | ||
275 | * CSR2 - High order bits of initialize block (bits 07:00, 15:08 are reserved) | ||
276 | * CSR3 - Allows redefinition of the Bus Master Interface. | ||
277 | * This register must be set to 0x0002, which means BSWAP = 0, | ||
278 | * ACON = 1, BCON = 0; | ||
279 | * | ||
280 | */ | ||
281 | |||
282 | #define CSR0 0x00 | ||
283 | #define CSR1 0x01 | ||
284 | #define CSR2 0x02 | ||
285 | #define CSR3 0x03 | ||
286 | |||
287 | /* | ||
288 | * General Definitions | ||
289 | * =================== | ||
290 | */ | ||
291 | |||
292 | /* | ||
293 | * Set the number of Tx and Rx buffers, using Log_2(# buffers). | ||
294 | * We have 16KB RAM which can be accessed by the LANCE. In the | ||
295 | * memory are not only the buffers but also the ring descriptors and | ||
296 | * the initialize block. | ||
297 | * Don't change anything unless you really know what you do. | ||
298 | */ | ||
299 | |||
300 | #define LC_LOG_TX_BUFFERS 1 /* (2 == 2^^1) 2 Transmit buffers */ | ||
301 | #define LC_LOG_RX_BUFFERS 3 /* (8 == 2^^3) 8 Receive buffers */ | ||
302 | |||
303 | /* Descriptor ring sizes */ | ||
304 | |||
305 | #define TMDNUM (1 << (LC_LOG_TX_BUFFERS)) /* 2 Transmit descriptor rings */ | ||
306 | #define RMDNUM (1 << (LC_LOG_RX_BUFFERS)) /* 8 Receive Buffers */ | ||
307 | |||
308 | /* Define Mask for setting RMD, TMD length in the LANCE init_block */ | ||
309 | |||
310 | #define TMDNUMMASK (LC_LOG_TX_BUFFERS << 29) | ||
311 | #define RMDNUMMASK (LC_LOG_RX_BUFFERS << 29) | ||
312 | |||
313 | /* | ||
314 | * Data Buffer size is set to maximum packet length. | ||
315 | */ | ||
316 | |||
317 | #define PKT_BUF_SZ 1518 | ||
318 | |||
319 | /* | ||
320 | * The number of low I/O ports used by the ethercard. | ||
321 | */ | ||
322 | |||
323 | #define ETHERCARD_TOTAL_SIZE SK_POS_SIZE | ||
324 | |||
325 | /* | ||
326 | * SK_DEBUG | ||
327 | * | ||
328 | * Here you can choose what level of debugging wanted. | ||
329 | * | ||
330 | * If SK_DEBUG and SK_DEBUG2 are undefined, then only the | ||
331 | * necessary messages will be printed. | ||
332 | * | ||
333 | * If SK_DEBUG is defined, there will be many debugging prints | ||
334 | * which can help to find some mistakes in configuration or even | ||
335 | * in the driver code. | ||
336 | * | ||
337 | * If SK_DEBUG2 is defined, many many messages will be printed | ||
338 | * which normally you don't need. I used this to check the interrupt | ||
339 | * routine. | ||
340 | * | ||
341 | * (If you define only SK_DEBUG2 then only the messages for | ||
342 | * checking interrupts will be printed!) | ||
343 | * | ||
344 | * Normal way of live is: | ||
345 | * | ||
346 | * For the whole thing get going let both symbolic constants | ||
347 | * undefined. If you face any problems and you know what's going | ||
348 | * on (you know something about the card and you can interpret some | ||
349 | * hex LANCE register output) then define SK_DEBUG | ||
350 | * | ||
351 | */ | ||
352 | |||
353 | #undef SK_DEBUG /* debugging */ | ||
354 | #undef SK_DEBUG2 /* debugging with more verbose report */ | ||
355 | |||
356 | #ifdef SK_DEBUG | ||
357 | #define PRINTK(x) printk x | ||
358 | #else | ||
359 | #define PRINTK(x) /**/ | ||
360 | #endif | ||
361 | |||
362 | #ifdef SK_DEBUG2 | ||
363 | #define PRINTK2(x) printk x | ||
364 | #else | ||
365 | #define PRINTK2(x) /**/ | ||
366 | #endif | ||
367 | |||
368 | /* | ||
369 | * SK_G16 RAM | ||
370 | * | ||
371 | * The components are memory mapped and can be set in a region from | ||
372 | * 0x00000 through 0xfc000 in 16KB steps. | ||
373 | * | ||
374 | * The Network components are: dual ported RAM, Prom, I/O Reg, Status-, | ||
375 | * Controlregister and I/O Command. | ||
376 | * | ||
377 | * dual ported RAM: This is the only memory region which the LANCE chip | ||
378 | * has access to. From the Lance it is addressed from 0x0000 to | ||
379 | * 0x3fbf. The host accesses it normally. | ||
380 | * | ||
381 | * PROM: The PROM obtains the ETHERNET-MAC-Address. It is realised as a | ||
382 | * 8-Bit PROM, this means only the 16 even addresses are used of the | ||
383 | * 32 Byte Address region. Access to an odd address results in invalid | ||
384 | * data. | ||
385 | * | ||
386 | * LANCE I/O Reg: The I/O Reg is build of 4 single Registers, Low-Byte Write, | ||
387 | * Hi-Byte Write, Low-Byte Read, Hi-Byte Read. | ||
388 | * Transfer from or to the LANCE is always in 16Bit so Low and High | ||
389 | * registers are always relevant. | ||
390 | * | ||
391 | * The Data from the Readregister is not the data in the Writeregister!! | ||
392 | * | ||
393 | * Port: Status- and Controlregister. | ||
394 | * Two different registers which share the same address, Status is | ||
395 | * read-only, Control is write-only. | ||
396 | * | ||
397 | * I/O Command: | ||
398 | * Any bitcombination written in here starts the transmission between | ||
399 | * Host and LANCE. | ||
400 | */ | ||
401 | |||
402 | typedef struct | ||
403 | { | ||
404 | unsigned char ram[0x3fc0]; /* 16KB dual ported ram */ | ||
405 | unsigned char rom[0x0020]; /* 32Byte PROM containing 6Byte MAC */ | ||
406 | unsigned char res1[0x0010]; /* reserved */ | ||
407 | unsigned volatile short ioreg;/* LANCE I/O Register */ | ||
408 | unsigned volatile char port; /* Statusregister and Controlregister */ | ||
409 | unsigned char iocom; /* I/O Command Register */ | ||
410 | } SK_RAM; | ||
411 | |||
412 | /* struct */ | ||
413 | |||
414 | /* | ||
415 | * This is the structure for the dual ported ram. We | ||
416 | * have exactly 16 320 Bytes. In here there must be: | ||
417 | * | ||
418 | * - Initialize Block (starting at a word boundary) | ||
419 | * - Receive and Transmit Descriptor Rings (quadword boundary) | ||
420 | * - Data Buffers (arbitrary boundary) | ||
421 | * | ||
422 | * This is because LANCE has on SK_G16 only access to the dual ported | ||
423 | * RAM and nowhere else. | ||
424 | */ | ||
425 | |||
426 | struct SK_ram | ||
427 | { | ||
428 | struct init_block ib; | ||
429 | struct tmd tmde[TMDNUM]; | ||
430 | struct rmd rmde[RMDNUM]; | ||
431 | char tmdbuf[TMDNUM][PKT_BUF_SZ]; | ||
432 | char rmdbuf[RMDNUM][PKT_BUF_SZ]; | ||
433 | }; | ||
434 | |||
435 | /* | ||
436 | * Structure where all necessary information is for ring buffer | ||
437 | * management and statistics. | ||
438 | */ | ||
439 | |||
440 | struct priv | ||
441 | { | ||
442 | struct SK_ram *ram; /* dual ported ram structure */ | ||
443 | struct rmd *rmdhead; /* start of receive ring descriptors */ | ||
444 | struct tmd *tmdhead; /* start of transmit ring descriptors */ | ||
445 | int rmdnum; /* actual used ring descriptor */ | ||
446 | int tmdnum; /* actual transmit descriptor for transmitting data */ | ||
447 | int tmdlast; /* last sent descriptor used for error handling, etc */ | ||
448 | void *rmdbufs[RMDNUM]; /* pointer to the receive buffers */ | ||
449 | void *tmdbufs[TMDNUM]; /* pointer to the transmit buffers */ | ||
450 | struct net_device_stats stats; /* Device driver statistics */ | ||
451 | }; | ||
452 | |||
453 | /* global variable declaration */ | ||
454 | |||
455 | /* IRQ map used to reserve a IRQ (see SK_open()) */ | ||
456 | |||
457 | /* static variables */ | ||
458 | |||
459 | static SK_RAM *board; /* pointer to our memory mapped board components */ | ||
460 | static DEFINE_SPINLOCK(SK_lock); | ||
461 | |||
462 | /* Macros */ | ||
463 | |||
464 | |||
465 | /* Function Prototypes */ | ||
466 | |||
467 | /* | ||
468 | * Device Driver functions | ||
469 | * ----------------------- | ||
470 | * See for short explanation of each function its definitions header. | ||
471 | */ | ||
472 | |||
473 | static int SK_probe(struct net_device *dev, short ioaddr); | ||
474 | |||
475 | static void SK_timeout(struct net_device *dev); | ||
476 | static int SK_open(struct net_device *dev); | ||
477 | static int SK_send_packet(struct sk_buff *skb, struct net_device *dev); | ||
478 | static irqreturn_t SK_interrupt(int irq, void *dev_id, struct pt_regs * regs); | ||
479 | static void SK_rxintr(struct net_device *dev); | ||
480 | static void SK_txintr(struct net_device *dev); | ||
481 | static int SK_close(struct net_device *dev); | ||
482 | |||
483 | static struct net_device_stats *SK_get_stats(struct net_device *dev); | ||
484 | |||
485 | unsigned int SK_rom_addr(void); | ||
486 | |||
487 | static void set_multicast_list(struct net_device *dev); | ||
488 | |||
489 | /* | ||
490 | * LANCE Functions | ||
491 | * --------------- | ||
492 | */ | ||
493 | |||
494 | static int SK_lance_init(struct net_device *dev, unsigned short mode); | ||
495 | void SK_reset_board(void); | ||
496 | void SK_set_RAP(int reg_number); | ||
497 | int SK_read_reg(int reg_number); | ||
498 | int SK_rread_reg(void); | ||
499 | void SK_write_reg(int reg_number, int value); | ||
500 | |||
501 | /* | ||
502 | * Debugging functions | ||
503 | * ------------------- | ||
504 | */ | ||
505 | |||
506 | void SK_print_pos(struct net_device *dev, char *text); | ||
507 | void SK_print_dev(struct net_device *dev, char *text); | ||
508 | void SK_print_ram(struct net_device *dev); | ||
509 | |||
510 | |||
511 | /*- | ||
512 | * Function : SK_init | ||
513 | * Author : Patrick J.D. Weichmann | ||
514 | * Date Created : 94/05/26 | ||
515 | * | ||
516 | * Description : Check for a SK_G16 network adaptor and initialize it. | ||
517 | * This function gets called by dev_init which initializes | ||
518 | * all Network devices. | ||
519 | * | ||
520 | * Parameters : I : struct net_device *dev - structure preconfigured | ||
521 | * from Space.c | ||
522 | * Return Value : 0 = Driver Found and initialized | ||
523 | * Errors : ENODEV - no device found | ||
524 | * ENXIO - not probed | ||
525 | * Globals : None | ||
526 | * Update History : | ||
527 | * YY/MM/DD uid Description | ||
528 | -*/ | ||
529 | |||
530 | static int io; /* 0 == probe */ | ||
531 | |||
532 | /* | ||
533 | * Check for a network adaptor of this type, and return '0' if one exists. | ||
534 | * If dev->base_addr == 0, probe all likely locations. | ||
535 | * If dev->base_addr == 1, always return failure. | ||
536 | */ | ||
537 | |||
538 | struct net_device * __init SK_init(int unit) | ||
539 | { | ||
540 | int *port, ports[] = SK_IO_PORTS; /* SK_G16 supported ports */ | ||
541 | static unsigned version_printed; | ||
542 | struct net_device *dev = alloc_etherdev(sizeof(struct priv)); | ||
543 | int err = -ENODEV; | ||
544 | |||
545 | if (!dev) | ||
546 | return ERR_PTR(-ENOMEM); | ||
547 | |||
548 | if (unit >= 0) { | ||
549 | sprintf(dev->name, "eth%d", unit); | ||
550 | netdev_boot_setup_check(dev); | ||
551 | io = dev->base_addr; | ||
552 | } | ||
553 | |||
554 | if (version_printed++ == 0) | ||
555 | PRINTK(("%s: %s", SK_NAME, rcsid)); | ||
556 | |||
557 | if (io > 0xff) { /* Check a single specified address */ | ||
558 | err = -EBUSY; | ||
559 | /* Check if on specified address is a SK_G16 */ | ||
560 | if (request_region(io, ETHERCARD_TOTAL_SIZE, "sk_g16")) { | ||
561 | err = SK_probe(dev, io); | ||
562 | if (!err) | ||
563 | goto got_it; | ||
564 | release_region(io, ETHERCARD_TOTAL_SIZE); | ||
565 | } | ||
566 | } else if (io > 0) { /* Don't probe at all */ | ||
567 | err = -ENXIO; | ||
568 | } else { | ||
569 | /* Autoprobe base_addr */ | ||
570 | for (port = &ports[0]; *port; port++) { | ||
571 | io = *port; | ||
572 | |||
573 | /* Check if I/O Port region is used by another board */ | ||
574 | if (!request_region(io, ETHERCARD_TOTAL_SIZE, "sk_g16")) | ||
575 | continue; /* Try next Port address */ | ||
576 | |||
577 | /* Check if at ioaddr is a SK_G16 */ | ||
578 | if (SK_probe(dev, io) == 0) | ||
579 | goto got_it; | ||
580 | |||
581 | release_region(io, ETHERCARD_TOTAL_SIZE); | ||
582 | } | ||
583 | } | ||
584 | err_out: | ||
585 | free_netdev(dev); | ||
586 | return ERR_PTR(err); | ||
587 | |||
588 | got_it: | ||
589 | err = register_netdev(dev); | ||
590 | if (err) { | ||
591 | release_region(dev->base_addr, ETHERCARD_TOTAL_SIZE); | ||
592 | goto err_out; | ||
593 | } | ||
594 | return dev; | ||
595 | |||
596 | } /* End of SK_init */ | ||
597 | |||
598 | |||
599 | MODULE_AUTHOR("Patrick J.D. Weichmann"); | ||
600 | MODULE_DESCRIPTION("Schneider & Koch G16 Ethernet Device Driver"); | ||
601 | MODULE_LICENSE("GPL"); | ||
602 | MODULE_PARM(io, "i"); | ||
603 | MODULE_PARM_DESC(io, "0 to probe common ports (unsafe), or the I/O base of the board"); | ||
604 | |||
605 | |||
606 | #ifdef MODULE | ||
607 | |||
608 | static struct net_device *SK_dev; | ||
609 | |||
610 | static int __init SK_init_module (void) | ||
611 | { | ||
612 | SK_dev = SK_init(-1); | ||
613 | return IS_ERR(SK_dev) ? PTR_ERR(SK_dev) : 0; | ||
614 | } | ||
615 | |||
616 | static void __exit SK_cleanup_module (void) | ||
617 | { | ||
618 | unregister_netdev(SK_dev); | ||
619 | release_region(SK_dev->base_addr, ETHERCARD_TOTAL_SIZE); | ||
620 | free_netdev(SK_dev); | ||
621 | } | ||
622 | |||
623 | module_init(SK_init_module); | ||
624 | module_exit(SK_cleanup_module); | ||
625 | #endif | ||
626 | |||
627 | |||
628 | /*- | ||
629 | * Function : SK_probe | ||
630 | * Author : Patrick J.D. Weichmann | ||
631 | * Date Created : 94/05/26 | ||
632 | * | ||
633 | * Description : This function is called by SK_init and | ||
634 | * does the main part of initialization. | ||
635 | * | ||
636 | * Parameters : I : struct net_device *dev - SK_G16 device structure | ||
637 | * I : short ioaddr - I/O Port address where POS is. | ||
638 | * Return Value : 0 = Initialization done | ||
639 | * Errors : ENODEV - No SK_G16 found | ||
640 | * -1 - Configuration problem | ||
641 | * Globals : board - pointer to SK_RAM | ||
642 | * Update History : | ||
643 | * YY/MM/DD uid Description | ||
644 | * 94/06/30 pwe SK_ADDR now checked and at the correct place | ||
645 | -*/ | ||
646 | |||
647 | int __init SK_probe(struct net_device *dev, short ioaddr) | ||
648 | { | ||
649 | int i,j; /* Counters */ | ||
650 | int sk_addr_flag = 0; /* SK ADDR correct? 1 - no, 0 - yes */ | ||
651 | unsigned int rom_addr; /* used to store RAM address used for POS_ADDR */ | ||
652 | |||
653 | struct priv *p = netdev_priv(dev); /* SK_G16 private structure */ | ||
654 | |||
655 | if (inb(SK_POS0) != SK_IDLOW || inb(SK_POS1) != SK_IDHIGH) | ||
656 | return -ENODEV; | ||
657 | dev->base_addr = ioaddr; | ||
658 | |||
659 | if (SK_ADDR & 0x3fff || SK_ADDR < 0xa0000) | ||
660 | { | ||
661 | |||
662 | sk_addr_flag = 1; | ||
663 | |||
664 | /* | ||
665 | * Now here we could use a routine which searches for a free | ||
666 | * place in the ram and set SK_ADDR if found. TODO. | ||
667 | */ | ||
668 | } | ||
669 | |||
670 | if (SK_BOOT_ROM) /* Shall we keep Boot_ROM on ? */ | ||
671 | { | ||
672 | PRINTK(("## %s: SK_BOOT_ROM is set.\n", SK_NAME)); | ||
673 | |||
674 | rom_addr = SK_rom_addr(); | ||
675 | |||
676 | if (rom_addr == 0) /* No Boot_ROM found */ | ||
677 | { | ||
678 | if (sk_addr_flag) /* No or Invalid SK_ADDR is defined */ | ||
679 | { | ||
680 | printk("%s: SK_ADDR %#08x is not valid. Check configuration.\n", | ||
681 | dev->name, SK_ADDR); | ||
682 | return -1; | ||
683 | } | ||
684 | |||
685 | rom_addr = SK_ADDR; /* assign predefined address */ | ||
686 | |||
687 | PRINTK(("## %s: NO Bootrom found \n", SK_NAME)); | ||
688 | |||
689 | outb(SK_ROM_RAM_OFF, SK_POS2); /* Boot_ROM + RAM off */ | ||
690 | outb(POS_ADDR, SK_POS3); /* Set RAM address */ | ||
691 | outb(SK_RAM_ON, SK_POS2); /* enable RAM */ | ||
692 | } | ||
693 | else if (rom_addr == SK_ADDR) | ||
694 | { | ||
695 | printk("%s: RAM + ROM are set to the same address %#08x\n" | ||
696 | " Check configuration. Now switching off Boot_ROM\n", | ||
697 | SK_NAME, rom_addr); | ||
698 | |||
699 | outb(SK_ROM_RAM_OFF, SK_POS2); /* Boot_ROM + RAM off*/ | ||
700 | outb(POS_ADDR, SK_POS3); /* Set RAM address */ | ||
701 | outb(SK_RAM_ON, SK_POS2); /* enable RAM */ | ||
702 | } | ||
703 | else | ||
704 | { | ||
705 | PRINTK(("## %s: Found ROM at %#08x\n", SK_NAME, rom_addr)); | ||
706 | PRINTK(("## %s: Keeping Boot_ROM on\n", SK_NAME)); | ||
707 | |||
708 | if (sk_addr_flag) /* No or Invalid SK_ADDR is defined */ | ||
709 | { | ||
710 | printk("%s: SK_ADDR %#08x is not valid. Check configuration.\n", | ||
711 | dev->name, SK_ADDR); | ||
712 | return -1; | ||
713 | } | ||
714 | |||
715 | rom_addr = SK_ADDR; | ||
716 | |||
717 | outb(SK_ROM_RAM_OFF, SK_POS2); /* Boot_ROM + RAM off */ | ||
718 | outb(POS_ADDR, SK_POS3); /* Set RAM address */ | ||
719 | outb(SK_ROM_RAM_ON, SK_POS2); /* RAM on, BOOT_ROM on */ | ||
720 | } | ||
721 | } | ||
722 | else /* Don't keep Boot_ROM */ | ||
723 | { | ||
724 | PRINTK(("## %s: SK_BOOT_ROM is not set.\n", SK_NAME)); | ||
725 | |||
726 | if (sk_addr_flag) /* No or Invalid SK_ADDR is defined */ | ||
727 | { | ||
728 | printk("%s: SK_ADDR %#08x is not valid. Check configuration.\n", | ||
729 | dev->name, SK_ADDR); | ||
730 | return -1; | ||
731 | } | ||
732 | |||
733 | rom_addr = SK_rom_addr(); /* Try to find a Boot_ROM */ | ||
734 | |||
735 | /* IF we find a Boot_ROM disable it */ | ||
736 | |||
737 | outb(SK_ROM_RAM_OFF, SK_POS2); /* Boot_ROM + RAM off */ | ||
738 | |||
739 | /* We found a Boot_ROM and it's gone. Set RAM address on | ||
740 | * Boot_ROM address. | ||
741 | */ | ||
742 | |||
743 | if (rom_addr) | ||
744 | { | ||
745 | printk("%s: We found Boot_ROM at %#08x. Now setting RAM on" | ||
746 | "that address\n", SK_NAME, rom_addr); | ||
747 | |||
748 | outb(POS_ADDR, SK_POS3); /* Set RAM on Boot_ROM address */ | ||
749 | } | ||
750 | else /* We did not find a Boot_ROM, use predefined SK_ADDR for ram */ | ||
751 | { | ||
752 | if (sk_addr_flag) /* No or Invalid SK_ADDR is defined */ | ||
753 | { | ||
754 | printk("%s: SK_ADDR %#08x is not valid. Check configuration.\n", | ||
755 | dev->name, SK_ADDR); | ||
756 | return -1; | ||
757 | } | ||
758 | |||
759 | rom_addr = SK_ADDR; | ||
760 | |||
761 | outb(POS_ADDR, SK_POS3); /* Set RAM address */ | ||
762 | } | ||
763 | outb(SK_RAM_ON, SK_POS2); /* enable RAM */ | ||
764 | } | ||
765 | |||
766 | #ifdef SK_DEBUG | ||
767 | SK_print_pos(dev, "POS registers after ROM, RAM config"); | ||
768 | #endif | ||
769 | |||
770 | board = (SK_RAM *) isa_bus_to_virt(rom_addr); | ||
771 | |||
772 | /* Read in station address */ | ||
773 | for (i = 0, j = 0; i < ETH_ALEN; i++, j+=2) | ||
774 | { | ||
775 | dev->dev_addr[i] = readb(board->rom+j); | ||
776 | } | ||
777 | |||
778 | /* Check for manufacturer code */ | ||
779 | if (!(dev->dev_addr[0] == SK_MAC0 && | ||
780 | dev->dev_addr[1] == SK_MAC1 && | ||
781 | dev->dev_addr[2] == SK_MAC2) ) | ||
782 | { | ||
783 | PRINTK(("## %s: We did not find SK_G16 at RAM location.\n", | ||
784 | SK_NAME)); | ||
785 | return -ENODEV; /* NO SK_G16 found */ | ||
786 | } | ||
787 | |||
788 | printk("%s: %s found at %#3x, HW addr: %#04x:%02x:%02x:%02x:%02x:%02x\n", | ||
789 | dev->name, | ||
790 | "Schneider & Koch Netcard", | ||
791 | (unsigned int) dev->base_addr, | ||
792 | dev->dev_addr[0], | ||
793 | dev->dev_addr[1], | ||
794 | dev->dev_addr[2], | ||
795 | dev->dev_addr[3], | ||
796 | dev->dev_addr[4], | ||
797 | dev->dev_addr[5]); | ||
798 | |||
799 | memset((char *) dev->priv, 0, sizeof(struct priv)); /* clear memory */ | ||
800 | |||
801 | /* Assign our Device Driver functions */ | ||
802 | |||
803 | dev->open = SK_open; | ||
804 | dev->stop = SK_close; | ||
805 | dev->hard_start_xmit = SK_send_packet; | ||
806 | dev->get_stats = SK_get_stats; | ||
807 | dev->set_multicast_list = set_multicast_list; | ||
808 | dev->tx_timeout = SK_timeout; | ||
809 | dev->watchdog_timeo = HZ/7; | ||
810 | |||
811 | |||
812 | dev->flags &= ~IFF_MULTICAST; | ||
813 | |||
814 | /* Initialize private structure */ | ||
815 | |||
816 | p->ram = (struct SK_ram *) rom_addr; /* Set dual ported RAM addr */ | ||
817 | p->tmdhead = &(p->ram)->tmde[0]; /* Set TMD head */ | ||
818 | p->rmdhead = &(p->ram)->rmde[0]; /* Set RMD head */ | ||
819 | |||
820 | /* Initialize buffer pointers */ | ||
821 | |||
822 | for (i = 0; i < TMDNUM; i++) | ||
823 | { | ||
824 | p->tmdbufs[i] = &(p->ram)->tmdbuf[i]; | ||
825 | } | ||
826 | |||
827 | for (i = 0; i < RMDNUM; i++) | ||
828 | { | ||
829 | p->rmdbufs[i] = &(p->ram)->rmdbuf[i]; | ||
830 | } | ||
831 | |||
832 | #ifdef SK_DEBUG | ||
833 | SK_print_pos(dev, "End of SK_probe"); | ||
834 | SK_print_ram(dev); | ||
835 | #endif | ||
836 | return 0; /* Initialization done */ | ||
837 | } /* End of SK_probe() */ | ||
838 | |||
839 | |||
840 | /*- | ||
841 | * Function : SK_open | ||
842 | * Author : Patrick J.D. Weichmann | ||
843 | * Date Created : 94/05/26 | ||
844 | * | ||
845 | * Description : This function is called sometimes after booting | ||
846 | * when ifconfig program is run. | ||
847 | * | ||
848 | * This function requests an IRQ, sets the correct | ||
849 | * IRQ in the card. Then calls SK_lance_init() to | ||
850 | * init and start the LANCE chip. Then if everything is | ||
851 | * ok returns with 0 (OK), which means SK_G16 is now | ||
852 | * opened and operational. | ||
853 | * | ||
854 | * (Called by dev_open() /net/inet/dev.c) | ||
855 | * | ||
856 | * Parameters : I : struct net_device *dev - SK_G16 device structure | ||
857 | * Return Value : 0 - Device opened | ||
858 | * Errors : -EAGAIN - Open failed | ||
859 | * Side Effects : None | ||
860 | * Update History : | ||
861 | * YY/MM/DD uid Description | ||
862 | -*/ | ||
863 | |||
864 | static int SK_open(struct net_device *dev) | ||
865 | { | ||
866 | int i = 0; | ||
867 | int irqval = 0; | ||
868 | int ioaddr = dev->base_addr; | ||
869 | |||
870 | int irqtab[] = SK_IRQS; | ||
871 | |||
872 | struct priv *p = netdev_priv(dev); | ||
873 | |||
874 | PRINTK(("## %s: At beginning of SK_open(). CSR0: %#06x\n", | ||
875 | SK_NAME, SK_read_reg(CSR0))); | ||
876 | |||
877 | if (dev->irq == 0) /* Autoirq */ | ||
878 | { | ||
879 | i = 0; | ||
880 | |||
881 | /* | ||
882 | * Check if one IRQ out of SK_IRQS is free and install | ||
883 | * interrupt handler. | ||
884 | * Most done by request_irq(). | ||
885 | * irqval: 0 - interrupt handler installed for IRQ irqtab[i] | ||
886 | * -EBUSY - interrupt busy | ||
887 | * -EINVAL - irq > 15 or handler = NULL | ||
888 | */ | ||
889 | |||
890 | do | ||
891 | { | ||
892 | irqval = request_irq(irqtab[i], &SK_interrupt, 0, "sk_g16", dev); | ||
893 | i++; | ||
894 | } while (irqval && irqtab[i]); | ||
895 | |||
896 | if (irqval) /* We tried every possible IRQ but no success */ | ||
897 | { | ||
898 | printk("%s: unable to get an IRQ\n", dev->name); | ||
899 | return -EAGAIN; | ||
900 | } | ||
901 | |||
902 | dev->irq = irqtab[--i]; | ||
903 | |||
904 | outb(i<<2, SK_POS4); /* Set Card on probed IRQ */ | ||
905 | |||
906 | } | ||
907 | else if (dev->irq == 2) /* IRQ2 is always IRQ9 */ | ||
908 | { | ||
909 | if (request_irq(9, &SK_interrupt, 0, "sk_g16", dev)) | ||
910 | { | ||
911 | printk("%s: unable to get IRQ 9\n", dev->name); | ||
912 | return -EAGAIN; | ||
913 | } | ||
914 | dev->irq = 9; | ||
915 | |||
916 | /* | ||
917 | * Now we set card on IRQ2. | ||
918 | * This can be confusing, but remember that IRQ2 on the network | ||
919 | * card is in reality IRQ9 | ||
920 | */ | ||
921 | outb(0x08, SK_POS4); /* set card to IRQ2 */ | ||
922 | |||
923 | } | ||
924 | else /* Check IRQ as defined in Space.c */ | ||
925 | { | ||
926 | int i = 0; | ||
927 | |||
928 | /* check if IRQ free and valid. Then install Interrupt handler */ | ||
929 | |||
930 | if (request_irq(dev->irq, &SK_interrupt, 0, "sk_g16", dev)) | ||
931 | { | ||
932 | printk("%s: unable to get selected IRQ\n", dev->name); | ||
933 | return -EAGAIN; | ||
934 | } | ||
935 | |||
936 | switch(dev->irq) | ||
937 | { | ||
938 | case 3: i = 0; | ||
939 | break; | ||
940 | case 5: i = 1; | ||
941 | break; | ||
942 | case 2: i = 2; | ||
943 | break; | ||
944 | case 11:i = 3; | ||
945 | break; | ||
946 | default: | ||
947 | printk("%s: Preselected IRQ %d is invalid for %s boards", | ||
948 | dev->name, | ||
949 | dev->irq, | ||
950 | SK_NAME); | ||
951 | return -EAGAIN; | ||
952 | } | ||
953 | |||
954 | outb(i<<2, SK_POS4); /* Set IRQ on card */ | ||
955 | } | ||
956 | |||
957 | printk("%s: Schneider & Koch G16 at %#3x, IRQ %d, shared mem at %#08x\n", | ||
958 | dev->name, (unsigned int)dev->base_addr, | ||
959 | (int) dev->irq, (unsigned int) p->ram); | ||
960 | |||
961 | if (!(i = SK_lance_init(dev, 0))) /* LANCE init OK? */ | ||
962 | { | ||
963 | netif_start_queue(dev); | ||
964 | |||
965 | #ifdef SK_DEBUG | ||
966 | |||
967 | /* | ||
968 | * This debug block tries to stop LANCE, | ||
969 | * reinit LANCE with transmitter and receiver disabled, | ||
970 | * then stop again and reinit with NORMAL_MODE | ||
971 | */ | ||
972 | |||
973 | printk("## %s: After lance init. CSR0: %#06x\n", | ||
974 | SK_NAME, SK_read_reg(CSR0)); | ||
975 | SK_write_reg(CSR0, CSR0_STOP); | ||
976 | printk("## %s: LANCE stopped. CSR0: %#06x\n", | ||
977 | SK_NAME, SK_read_reg(CSR0)); | ||
978 | SK_lance_init(dev, MODE_DTX | MODE_DRX); | ||
979 | printk("## %s: Reinit with DTX + DRX off. CSR0: %#06x\n", | ||
980 | SK_NAME, SK_read_reg(CSR0)); | ||
981 | SK_write_reg(CSR0, CSR0_STOP); | ||
982 | printk("## %s: LANCE stopped. CSR0: %#06x\n", | ||
983 | SK_NAME, SK_read_reg(CSR0)); | ||
984 | SK_lance_init(dev, MODE_NORMAL); | ||
985 | printk("## %s: LANCE back to normal mode. CSR0: %#06x\n", | ||
986 | SK_NAME, SK_read_reg(CSR0)); | ||
987 | SK_print_pos(dev, "POS regs before returning OK"); | ||
988 | |||
989 | #endif /* SK_DEBUG */ | ||
990 | |||
991 | return 0; /* SK_open() is successful */ | ||
992 | } | ||
993 | else /* LANCE init failed */ | ||
994 | { | ||
995 | |||
996 | PRINTK(("## %s: LANCE init failed: CSR0: %#06x\n", | ||
997 | SK_NAME, SK_read_reg(CSR0))); | ||
998 | |||
999 | return -EAGAIN; | ||
1000 | } | ||
1001 | |||
1002 | } /* End of SK_open() */ | ||
1003 | |||
1004 | |||
1005 | /*- | ||
1006 | * Function : SK_lance_init | ||
1007 | * Author : Patrick J.D. Weichmann | ||
1008 | * Date Created : 94/05/26 | ||
1009 | * | ||
1010 | * Description : Reset LANCE chip, fill RMD, TMD structures with | ||
1011 | * start values and Start LANCE. | ||
1012 | * | ||
1013 | * Parameters : I : struct net_device *dev - SK_G16 device structure | ||
1014 | * I : int mode - put LANCE into "mode" see data-sheet for | ||
1015 | * more info. | ||
1016 | * Return Value : 0 - Init done | ||
1017 | * Errors : -1 - Init failed | ||
1018 | * Update History : | ||
1019 | * YY/MM/DD uid Description | ||
1020 | -*/ | ||
1021 | |||
1022 | static int SK_lance_init(struct net_device *dev, unsigned short mode) | ||
1023 | { | ||
1024 | int i; | ||
1025 | unsigned long flags; | ||
1026 | struct priv *p = netdev_priv(dev); | ||
1027 | struct tmd *tmdp; | ||
1028 | struct rmd *rmdp; | ||
1029 | |||
1030 | PRINTK(("## %s: At beginning of LANCE init. CSR0: %#06x\n", | ||
1031 | SK_NAME, SK_read_reg(CSR0))); | ||
1032 | |||
1033 | /* Reset LANCE */ | ||
1034 | SK_reset_board(); | ||
1035 | |||
1036 | /* Initialize TMD's with start values */ | ||
1037 | p->tmdnum = 0; /* First descriptor for transmitting */ | ||
1038 | p->tmdlast = 0; /* First descriptor for reading stats */ | ||
1039 | |||
1040 | for (i = 0; i < TMDNUM; i++) /* Init all TMD's */ | ||
1041 | { | ||
1042 | tmdp = p->tmdhead + i; | ||
1043 | |||
1044 | writel((unsigned long) p->tmdbufs[i], tmdp->u.buffer); /* assign buffer */ | ||
1045 | |||
1046 | /* Mark TMD as start and end of packet */ | ||
1047 | writeb(TX_STP | TX_ENP, &tmdp->u.s.status); | ||
1048 | } | ||
1049 | |||
1050 | |||
1051 | /* Initialize RMD's with start values */ | ||
1052 | |||
1053 | p->rmdnum = 0; /* First RMD which will be used */ | ||
1054 | |||
1055 | for (i = 0; i < RMDNUM; i++) /* Init all RMD's */ | ||
1056 | { | ||
1057 | rmdp = p->rmdhead + i; | ||
1058 | |||
1059 | |||
1060 | writel((unsigned long) p->rmdbufs[i], rmdp->u.buffer); /* assign buffer */ | ||
1061 | |||
1062 | /* | ||
1063 | * LANCE must be owner at beginning so that he can fill in | ||
1064 | * receiving packets, set status and release RMD | ||
1065 | */ | ||
1066 | |||
1067 | writeb(RX_OWN, &rmdp->u.s.status); | ||
1068 | |||
1069 | writew(-PKT_BUF_SZ, &rmdp->blen); /* Buffer Size (two's complement) */ | ||
1070 | |||
1071 | writeb(0, &rmdp->mlen); /* init message length */ | ||
1072 | |||
1073 | } | ||
1074 | |||
1075 | /* Fill LANCE Initialize Block */ | ||
1076 | |||
1077 | writew(mode, (&((p->ram)->ib.mode))); /* Set operation mode */ | ||
1078 | |||
1079 | for (i = 0; i < ETH_ALEN; i++) /* Set physical address */ | ||
1080 | { | ||
1081 | writeb(dev->dev_addr[i], (&((p->ram)->ib.paddr[i]))); | ||
1082 | } | ||
1083 | |||
1084 | for (i = 0; i < 8; i++) /* Set multicast, logical address */ | ||
1085 | { | ||
1086 | writeb(0, (&((p->ram)->ib.laddr[i]))); /* We do not use logical addressing */ | ||
1087 | } | ||
1088 | |||
1089 | /* Set ring descriptor pointers and set number of descriptors */ | ||
1090 | |||
1091 | writel((int)p->rmdhead | RMDNUMMASK, (&((p->ram)->ib.rdrp))); | ||
1092 | writel((int)p->tmdhead | TMDNUMMASK, (&((p->ram)->ib.tdrp))); | ||
1093 | |||
1094 | /* Prepare LANCE Control and Status Registers */ | ||
1095 | |||
1096 | spin_lock_irqsave(&SK_lock, flags); | ||
1097 | |||
1098 | SK_write_reg(CSR3, CSR3_ACON); /* Ale Control !!!THIS MUST BE SET!!!! */ | ||
1099 | |||
1100 | /* | ||
1101 | * LANCE addresses the RAM from 0x0000 to 0x3fbf and has no access to | ||
1102 | * PC Memory locations. | ||
1103 | * | ||
1104 | * In structure SK_ram is defined that the first thing in ram | ||
1105 | * is the initialization block. So his address is for LANCE always | ||
1106 | * 0x0000 | ||
1107 | * | ||
1108 | * CSR1 contains low order bits 15:0 of initialization block address | ||
1109 | * CSR2 is built of: | ||
1110 | * 7:0 High order bits 23:16 of initialization block address | ||
1111 | * 15:8 reserved, must be 0 | ||
1112 | */ | ||
1113 | |||
1114 | /* Set initialization block address (must be on word boundary) */ | ||
1115 | SK_write_reg(CSR1, 0); /* Set low order bits 15:0 */ | ||
1116 | SK_write_reg(CSR2, 0); /* Set high order bits 23:16 */ | ||
1117 | |||
1118 | |||
1119 | PRINTK(("## %s: After setting CSR1-3. CSR0: %#06x\n", | ||
1120 | SK_NAME, SK_read_reg(CSR0))); | ||
1121 | |||
1122 | /* Initialize LANCE */ | ||
1123 | |||
1124 | /* | ||
1125 | * INIT = Initialize, when set, causes the LANCE to begin the | ||
1126 | * initialization procedure and access the Init Block. | ||
1127 | */ | ||
1128 | |||
1129 | SK_write_reg(CSR0, CSR0_INIT); | ||
1130 | |||
1131 | spin_unlock_irqrestore(&SK_lock, flags); | ||
1132 | |||
1133 | /* Wait until LANCE finished initialization */ | ||
1134 | |||
1135 | SK_set_RAP(CSR0); /* Register Address Pointer to CSR0 */ | ||
1136 | |||
1137 | for (i = 0; (i < 100) && !(SK_rread_reg() & CSR0_IDON); i++) | ||
1138 | ; /* Wait until init done or go ahead if problems (i>=100) */ | ||
1139 | |||
1140 | if (i >= 100) /* Something is wrong ! */ | ||
1141 | { | ||
1142 | printk("%s: can't init am7990, status: %04x " | ||
1143 | "init_block: %#08x\n", | ||
1144 | dev->name, (int) SK_read_reg(CSR0), | ||
1145 | (unsigned int) &(p->ram)->ib); | ||
1146 | |||
1147 | #ifdef SK_DEBUG | ||
1148 | SK_print_pos(dev, "LANCE INIT failed"); | ||
1149 | SK_print_dev(dev,"Device Structure:"); | ||
1150 | #endif | ||
1151 | |||
1152 | return -1; /* LANCE init failed */ | ||
1153 | } | ||
1154 | |||
1155 | PRINTK(("## %s: init done after %d ticks\n", SK_NAME, i)); | ||
1156 | |||
1157 | /* Clear Initialize done, enable Interrupts, start LANCE */ | ||
1158 | |||
1159 | SK_write_reg(CSR0, CSR0_IDON | CSR0_INEA | CSR0_STRT); | ||
1160 | |||
1161 | PRINTK(("## %s: LANCE started. CSR0: %#06x\n", SK_NAME, | ||
1162 | SK_read_reg(CSR0))); | ||
1163 | |||
1164 | return 0; /* LANCE is up and running */ | ||
1165 | |||
1166 | } /* End of SK_lance_init() */ | ||
1167 | |||
1168 | |||
1169 | |||
1170 | /*- | ||
1171 | * Function : SK_send_packet | ||
1172 | * Author : Patrick J.D. Weichmann | ||
1173 | * Date Created : 94/05/27 | ||
1174 | * | ||
1175 | * Description : Writes an socket buffer into a transmit descriptor | ||
1176 | * and starts transmission. | ||
1177 | * | ||
1178 | * Parameters : I : struct sk_buff *skb - packet to transfer | ||
1179 | * I : struct net_device *dev - SK_G16 device structure | ||
1180 | * Return Value : 0 - OK | ||
1181 | * 1 - Could not transmit (dev_queue_xmit will queue it) | ||
1182 | * and try to sent it later | ||
1183 | * Globals : None | ||
1184 | * Side Effects : None | ||
1185 | * Update History : | ||
1186 | * YY/MM/DD uid Description | ||
1187 | -*/ | ||
1188 | |||
1189 | static void SK_timeout(struct net_device *dev) | ||
1190 | { | ||
1191 | printk(KERN_WARNING "%s: xmitter timed out, try to restart!\n", dev->name); | ||
1192 | SK_lance_init(dev, MODE_NORMAL); /* Reinit LANCE */ | ||
1193 | netif_wake_queue(dev); /* Clear Transmitter flag */ | ||
1194 | dev->trans_start = jiffies; /* Mark Start of transmission */ | ||
1195 | } | ||
1196 | |||
1197 | static int SK_send_packet(struct sk_buff *skb, struct net_device *dev) | ||
1198 | { | ||
1199 | struct priv *p = netdev_priv(dev); | ||
1200 | struct tmd *tmdp; | ||
1201 | static char pad[64]; | ||
1202 | |||
1203 | PRINTK2(("## %s: SK_send_packet() called, CSR0 %#04x.\n", | ||
1204 | SK_NAME, SK_read_reg(CSR0))); | ||
1205 | |||
1206 | |||
1207 | /* | ||
1208 | * Block a timer-based transmit from overlapping. | ||
1209 | * This means check if we are already in. | ||
1210 | */ | ||
1211 | |||
1212 | netif_stop_queue (dev); | ||
1213 | |||
1214 | { | ||
1215 | |||
1216 | /* Evaluate Packet length */ | ||
1217 | short len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; | ||
1218 | |||
1219 | tmdp = p->tmdhead + p->tmdnum; /* Which descriptor for transmitting */ | ||
1220 | |||
1221 | /* Fill in Transmit Message Descriptor */ | ||
1222 | |||
1223 | /* Copy data into dual ported ram */ | ||
1224 | |||
1225 | memcpy_toio((tmdp->u.buffer & 0x00ffffff), skb->data, skb->len); | ||
1226 | if (len != skb->len) | ||
1227 | memcpy_toio((tmdp->u.buffer & 0x00ffffff) + skb->len, pad, len-skb->len); | ||
1228 | |||
1229 | writew(-len, &tmdp->blen); /* set length to transmit */ | ||
1230 | |||
1231 | /* | ||
1232 | * Packet start and end is always set because we use the maximum | ||
1233 | * packet length as buffer length. | ||
1234 | * Relinquish ownership to LANCE | ||
1235 | */ | ||
1236 | |||
1237 | writeb(TX_OWN | TX_STP | TX_ENP, &tmdp->u.s.status); | ||
1238 | |||
1239 | /* Start Demand Transmission */ | ||
1240 | SK_write_reg(CSR0, CSR0_TDMD | CSR0_INEA); | ||
1241 | |||
1242 | dev->trans_start = jiffies; /* Mark start of transmission */ | ||
1243 | |||
1244 | /* Set pointer to next transmit buffer */ | ||
1245 | p->tmdnum++; | ||
1246 | p->tmdnum &= TMDNUM-1; | ||
1247 | |||
1248 | /* Do we own the next transmit buffer ? */ | ||
1249 | if (! (readb(&((p->tmdhead + p->tmdnum)->u.s.status)) & TX_OWN) ) | ||
1250 | { | ||
1251 | /* | ||
1252 | * We own next buffer and are ready to transmit, so | ||
1253 | * clear busy flag | ||
1254 | */ | ||
1255 | netif_start_queue(dev); | ||
1256 | } | ||
1257 | |||
1258 | p->stats.tx_bytes += skb->len; | ||
1259 | |||
1260 | } | ||
1261 | |||
1262 | dev_kfree_skb(skb); | ||
1263 | return 0; | ||
1264 | } /* End of SK_send_packet */ | ||
1265 | |||
1266 | |||
1267 | /*- | ||
1268 | * Function : SK_interrupt | ||
1269 | * Author : Patrick J.D. Weichmann | ||
1270 | * Date Created : 94/05/27 | ||
1271 | * | ||
1272 | * Description : SK_G16 interrupt handler which checks for LANCE | ||
1273 | * Errors, handles transmit and receive interrupts | ||
1274 | * | ||
1275 | * Parameters : I : int irq, void *dev_id, struct pt_regs * regs - | ||
1276 | * Return Value : None | ||
1277 | * Errors : None | ||
1278 | * Globals : None | ||
1279 | * Side Effects : None | ||
1280 | * Update History : | ||
1281 | * YY/MM/DD uid Description | ||
1282 | -*/ | ||
1283 | |||
1284 | static irqreturn_t SK_interrupt(int irq, void *dev_id, struct pt_regs * regs) | ||
1285 | { | ||
1286 | int csr0; | ||
1287 | struct net_device *dev = dev_id; | ||
1288 | struct priv *p = netdev_priv(dev); | ||
1289 | |||
1290 | |||
1291 | PRINTK2(("## %s: SK_interrupt(). status: %#06x\n", | ||
1292 | SK_NAME, SK_read_reg(CSR0))); | ||
1293 | |||
1294 | if (dev == NULL) | ||
1295 | { | ||
1296 | printk("SK_interrupt(): IRQ %d for unknown device.\n", irq); | ||
1297 | } | ||
1298 | |||
1299 | spin_lock (&SK_lock); | ||
1300 | |||
1301 | csr0 = SK_read_reg(CSR0); /* store register for checking */ | ||
1302 | |||
1303 | /* | ||
1304 | * Acknowledge all of the current interrupt sources, disable | ||
1305 | * Interrupts (INEA = 0) | ||
1306 | */ | ||
1307 | |||
1308 | SK_write_reg(CSR0, csr0 & CSR0_CLRALL); | ||
1309 | |||
1310 | if (csr0 & CSR0_ERR) /* LANCE Error */ | ||
1311 | { | ||
1312 | printk("%s: error: %04x\n", dev->name, csr0); | ||
1313 | |||
1314 | if (csr0 & CSR0_MISS) /* No place to store packet ? */ | ||
1315 | { | ||
1316 | p->stats.rx_dropped++; | ||
1317 | } | ||
1318 | } | ||
1319 | |||
1320 | if (csr0 & CSR0_RINT) /* Receive Interrupt (packet arrived) */ | ||
1321 | { | ||
1322 | SK_rxintr(dev); | ||
1323 | } | ||
1324 | |||
1325 | if (csr0 & CSR0_TINT) /* Transmit interrupt (packet sent) */ | ||
1326 | { | ||
1327 | SK_txintr(dev); | ||
1328 | } | ||
1329 | |||
1330 | SK_write_reg(CSR0, CSR0_INEA); /* Enable Interrupts */ | ||
1331 | |||
1332 | spin_unlock (&SK_lock); | ||
1333 | return IRQ_HANDLED; | ||
1334 | } /* End of SK_interrupt() */ | ||
1335 | |||
1336 | |||
1337 | /*- | ||
1338 | * Function : SK_txintr | ||
1339 | * Author : Patrick J.D. Weichmann | ||
1340 | * Date Created : 94/05/27 | ||
1341 | * | ||
1342 | * Description : After sending a packet we check status, update | ||
1343 | * statistics and relinquish ownership of transmit | ||
1344 | * descriptor ring. | ||
1345 | * | ||
1346 | * Parameters : I : struct net_device *dev - SK_G16 device structure | ||
1347 | * Return Value : None | ||
1348 | * Errors : None | ||
1349 | * Globals : None | ||
1350 | * Update History : | ||
1351 | * YY/MM/DD uid Description | ||
1352 | -*/ | ||
1353 | |||
1354 | static void SK_txintr(struct net_device *dev) | ||
1355 | { | ||
1356 | int tmdstat; | ||
1357 | struct tmd *tmdp; | ||
1358 | struct priv *p = netdev_priv(dev); | ||
1359 | |||
1360 | |||
1361 | PRINTK2(("## %s: SK_txintr() status: %#06x\n", | ||
1362 | SK_NAME, SK_read_reg(CSR0))); | ||
1363 | |||
1364 | tmdp = p->tmdhead + p->tmdlast; /* Which buffer we sent at last ? */ | ||
1365 | |||
1366 | /* Set next buffer */ | ||
1367 | p->tmdlast++; | ||
1368 | p->tmdlast &= TMDNUM-1; | ||
1369 | |||
1370 | tmdstat = readb(&tmdp->u.s.status); | ||
1371 | |||
1372 | /* | ||
1373 | * We check status of transmitted packet. | ||
1374 | * see LANCE data-sheet for error explanation | ||
1375 | */ | ||
1376 | if (tmdstat & TX_ERR) /* Error occurred */ | ||
1377 | { | ||
1378 | int stat2 = readw(&tmdp->status2); | ||
1379 | |||
1380 | printk("%s: TX error: %04x %04x\n", dev->name, tmdstat, stat2); | ||
1381 | |||
1382 | if (stat2 & TX_TDR) /* TDR problems? */ | ||
1383 | { | ||
1384 | printk("%s: tdr-problems \n", dev->name); | ||
1385 | } | ||
1386 | |||
1387 | if (stat2 & TX_RTRY) /* Failed in 16 attempts to transmit ? */ | ||
1388 | p->stats.tx_aborted_errors++; | ||
1389 | if (stat2 & TX_LCOL) /* Late collision ? */ | ||
1390 | p->stats.tx_window_errors++; | ||
1391 | if (stat2 & TX_LCAR) /* Loss of Carrier ? */ | ||
1392 | p->stats.tx_carrier_errors++; | ||
1393 | if (stat2 & TX_UFLO) /* Underflow error ? */ | ||
1394 | { | ||
1395 | p->stats.tx_fifo_errors++; | ||
1396 | |||
1397 | /* | ||
1398 | * If UFLO error occurs it will turn transmitter of. | ||
1399 | * So we must reinit LANCE | ||
1400 | */ | ||
1401 | |||
1402 | SK_lance_init(dev, MODE_NORMAL); | ||
1403 | } | ||
1404 | |||
1405 | p->stats.tx_errors++; | ||
1406 | |||
1407 | writew(0, &tmdp->status2); /* Clear error flags */ | ||
1408 | } | ||
1409 | else if (tmdstat & TX_MORE) /* Collisions occurred ? */ | ||
1410 | { | ||
1411 | /* | ||
1412 | * Here I have a problem. | ||
1413 | * I only know that there must be one or up to 15 collisions. | ||
1414 | * That's why TX_MORE is set, because after 16 attempts TX_RTRY | ||
1415 | * will be set which means couldn't send packet aborted transfer. | ||
1416 | * | ||
1417 | * First I did not have this in but then I thought at minimum | ||
1418 | * we see that something was not ok. | ||
1419 | * If anyone knows something better than this to handle this | ||
1420 | * please report it. | ||
1421 | */ | ||
1422 | |||
1423 | p->stats.collisions++; | ||
1424 | } | ||
1425 | else /* Packet sent without any problems */ | ||
1426 | { | ||
1427 | p->stats.tx_packets++; | ||
1428 | } | ||
1429 | |||
1430 | /* | ||
1431 | * We mark transmitter not busy anymore, because now we have a free | ||
1432 | * transmit descriptor which can be filled by SK_send_packet and | ||
1433 | * afterwards sent by the LANCE | ||
1434 | * | ||
1435 | * The function which do handle slow IRQ parts is do_bottom_half() | ||
1436 | * which runs at normal kernel priority, that means all interrupt are | ||
1437 | * enabled. (see kernel/irq.c) | ||
1438 | * | ||
1439 | * net_bh does something like this: | ||
1440 | * - check if already in net_bh | ||
1441 | * - try to transmit something from the send queue | ||
1442 | * - if something is in the receive queue send it up to higher | ||
1443 | * levels if it is a known protocol | ||
1444 | * - try to transmit something from the send queue | ||
1445 | */ | ||
1446 | |||
1447 | netif_wake_queue(dev); | ||
1448 | |||
1449 | } /* End of SK_txintr() */ | ||
1450 | |||
1451 | |||
1452 | /*- | ||
1453 | * Function : SK_rxintr | ||
1454 | * Author : Patrick J.D. Weichmann | ||
1455 | * Date Created : 94/05/27 | ||
1456 | * | ||
1457 | * Description : Buffer sent, check for errors, relinquish ownership | ||
1458 | * of the receive message descriptor. | ||
1459 | * | ||
1460 | * Parameters : I : SK_G16 device structure | ||
1461 | * Return Value : None | ||
1462 | * Globals : None | ||
1463 | * Update History : | ||
1464 | * YY/MM/DD uid Description | ||
1465 | -*/ | ||
1466 | |||
1467 | static void SK_rxintr(struct net_device *dev) | ||
1468 | { | ||
1469 | |||
1470 | struct rmd *rmdp; | ||
1471 | int rmdstat; | ||
1472 | struct priv *p = netdev_priv(dev); | ||
1473 | |||
1474 | PRINTK2(("## %s: SK_rxintr(). CSR0: %#06x\n", | ||
1475 | SK_NAME, SK_read_reg(CSR0))); | ||
1476 | |||
1477 | rmdp = p->rmdhead + p->rmdnum; | ||
1478 | |||
1479 | /* As long as we own the next entry, check status and send | ||
1480 | * it up to higher layer | ||
1481 | */ | ||
1482 | |||
1483 | while (!( (rmdstat = readb(&rmdp->u.s.status)) & RX_OWN)) | ||
1484 | { | ||
1485 | /* | ||
1486 | * Start and end of packet must be set, because we use | ||
1487 | * the ethernet maximum packet length (1518) as buffer size. | ||
1488 | * | ||
1489 | * Because our buffers are at maximum OFLO and BUFF errors are | ||
1490 | * not to be concerned (see Data sheet) | ||
1491 | */ | ||
1492 | |||
1493 | if ((rmdstat & (RX_STP | RX_ENP)) != (RX_STP | RX_ENP)) | ||
1494 | { | ||
1495 | /* Start of a frame > 1518 Bytes ? */ | ||
1496 | |||
1497 | if (rmdstat & RX_STP) | ||
1498 | { | ||
1499 | p->stats.rx_errors++; /* bad packet received */ | ||
1500 | p->stats.rx_length_errors++; /* packet too long */ | ||
1501 | |||
1502 | printk("%s: packet too long\n", dev->name); | ||
1503 | } | ||
1504 | |||
1505 | /* | ||
1506 | * All other packets will be ignored until a new frame with | ||
1507 | * start (RX_STP) set follows. | ||
1508 | * | ||
1509 | * What we do is just give descriptor free for new incoming | ||
1510 | * packets. | ||
1511 | */ | ||
1512 | |||
1513 | writeb(RX_OWN, &rmdp->u.s.status); /* Relinquish ownership to LANCE */ | ||
1514 | |||
1515 | } | ||
1516 | else if (rmdstat & RX_ERR) /* Receive Error ? */ | ||
1517 | { | ||
1518 | printk("%s: RX error: %04x\n", dev->name, (int) rmdstat); | ||
1519 | |||
1520 | p->stats.rx_errors++; | ||
1521 | |||
1522 | if (rmdstat & RX_FRAM) p->stats.rx_frame_errors++; | ||
1523 | if (rmdstat & RX_CRC) p->stats.rx_crc_errors++; | ||
1524 | |||
1525 | writeb(RX_OWN, &rmdp->u.s.status); /* Relinquish ownership to LANCE */ | ||
1526 | |||
1527 | } | ||
1528 | else /* We have a packet which can be queued for the upper layers */ | ||
1529 | { | ||
1530 | |||
1531 | int len = readw(&rmdp->mlen) & 0x0fff; /* extract message length from receive buffer */ | ||
1532 | struct sk_buff *skb; | ||
1533 | |||
1534 | skb = dev_alloc_skb(len+2); /* allocate socket buffer */ | ||
1535 | |||
1536 | if (skb == NULL) /* Could not get mem ? */ | ||
1537 | { | ||
1538 | |||
1539 | /* | ||
1540 | * Couldn't allocate sk_buffer so we give descriptor back | ||
1541 | * to Lance, update statistics and go ahead. | ||
1542 | */ | ||
1543 | |||
1544 | writeb(RX_OWN, &rmdp->u.s.status); /* Relinquish ownership to LANCE */ | ||
1545 | printk("%s: Couldn't allocate sk_buff, deferring packet.\n", | ||
1546 | dev->name); | ||
1547 | p->stats.rx_dropped++; | ||
1548 | |||
1549 | break; /* Jump out */ | ||
1550 | } | ||
1551 | |||
1552 | /* Prepare sk_buff to queue for upper layers */ | ||
1553 | |||
1554 | skb->dev = dev; | ||
1555 | skb_reserve(skb,2); /* Align IP header on 16 byte boundary */ | ||
1556 | |||
1557 | /* | ||
1558 | * Copy data out of our receive descriptor into sk_buff. | ||
1559 | * | ||
1560 | * (rmdp->u.buffer & 0x00ffffff) -> get address of buffer and | ||
1561 | * ignore status fields) | ||
1562 | */ | ||
1563 | |||
1564 | memcpy_fromio(skb_put(skb,len), (rmdp->u.buffer & 0x00ffffff), len); | ||
1565 | |||
1566 | |||
1567 | /* | ||
1568 | * Notify the upper protocol layers that there is another packet | ||
1569 | * to handle | ||
1570 | * | ||
1571 | * netif_rx() always succeeds. see /net/inet/dev.c for more. | ||
1572 | */ | ||
1573 | |||
1574 | skb->protocol=eth_type_trans(skb,dev); | ||
1575 | netif_rx(skb); /* queue packet and mark it for processing */ | ||
1576 | |||
1577 | /* | ||
1578 | * Packet is queued and marked for processing so we | ||
1579 | * free our descriptor and update statistics | ||
1580 | */ | ||
1581 | |||
1582 | writeb(RX_OWN, &rmdp->u.s.status); | ||
1583 | dev->last_rx = jiffies; | ||
1584 | p->stats.rx_packets++; | ||
1585 | p->stats.rx_bytes += len; | ||
1586 | |||
1587 | |||
1588 | p->rmdnum++; | ||
1589 | p->rmdnum %= RMDNUM; | ||
1590 | |||
1591 | rmdp = p->rmdhead + p->rmdnum; | ||
1592 | } | ||
1593 | } | ||
1594 | } /* End of SK_rxintr() */ | ||
1595 | |||
1596 | |||
1597 | /*- | ||
1598 | * Function : SK_close | ||
1599 | * Author : Patrick J.D. Weichmann | ||
1600 | * Date Created : 94/05/26 | ||
1601 | * | ||
1602 | * Description : close gets called from dev_close() and should | ||
1603 | * deinstall the card (free_irq, mem etc). | ||
1604 | * | ||
1605 | * Parameters : I : struct net_device *dev - our device structure | ||
1606 | * Return Value : 0 - closed device driver | ||
1607 | * Errors : None | ||
1608 | * Globals : None | ||
1609 | * Update History : | ||
1610 | * YY/MM/DD uid Description | ||
1611 | -*/ | ||
1612 | |||
1613 | /* I have tried to set BOOT_ROM on and RAM off but then, after a 'ifconfig | ||
1614 | * down' the system stops. So I don't shut set card to init state. | ||
1615 | */ | ||
1616 | |||
1617 | static int SK_close(struct net_device *dev) | ||
1618 | { | ||
1619 | |||
1620 | PRINTK(("## %s: SK_close(). CSR0: %#06x\n", | ||
1621 | SK_NAME, SK_read_reg(CSR0))); | ||
1622 | |||
1623 | netif_stop_queue(dev); /* Transmitter busy */ | ||
1624 | |||
1625 | printk("%s: Shutting %s down CSR0 %#06x\n", dev->name, SK_NAME, | ||
1626 | (int) SK_read_reg(CSR0)); | ||
1627 | |||
1628 | SK_write_reg(CSR0, CSR0_STOP); /* STOP the LANCE */ | ||
1629 | |||
1630 | free_irq(dev->irq, dev); /* Free IRQ */ | ||
1631 | |||
1632 | return 0; /* always succeed */ | ||
1633 | |||
1634 | } /* End of SK_close() */ | ||
1635 | |||
1636 | |||
1637 | /*- | ||
1638 | * Function : SK_get_stats | ||
1639 | * Author : Patrick J.D. Weichmann | ||
1640 | * Date Created : 94/05/26 | ||
1641 | * | ||
1642 | * Description : Return current status structure to upper layers. | ||
1643 | * It is called by sprintf_stats (dev.c). | ||
1644 | * | ||
1645 | * Parameters : I : struct net_device *dev - our device structure | ||
1646 | * Return Value : struct net_device_stats * - our current statistics | ||
1647 | * Errors : None | ||
1648 | * Side Effects : None | ||
1649 | * Update History : | ||
1650 | * YY/MM/DD uid Description | ||
1651 | -*/ | ||
1652 | |||
1653 | static struct net_device_stats *SK_get_stats(struct net_device *dev) | ||
1654 | { | ||
1655 | |||
1656 | struct priv *p = netdev_priv(dev); | ||
1657 | |||
1658 | PRINTK(("## %s: SK_get_stats(). CSR0: %#06x\n", | ||
1659 | SK_NAME, SK_read_reg(CSR0))); | ||
1660 | |||
1661 | return &p->stats; /* Return Device status */ | ||
1662 | |||
1663 | } /* End of SK_get_stats() */ | ||
1664 | |||
1665 | |||
1666 | /*- | ||
1667 | * Function : set_multicast_list | ||
1668 | * Author : Patrick J.D. Weichmann | ||
1669 | * Date Created : 94/05/26 | ||
1670 | * | ||
1671 | * Description : This function gets called when a program performs | ||
1672 | * a SIOCSIFFLAGS call. Ifconfig does this if you call | ||
1673 | * 'ifconfig [-]allmulti' which enables or disables the | ||
1674 | * Promiscuous mode. | ||
1675 | * Promiscuous mode is when the Network card accepts all | ||
1676 | * packets, not only the packets which match our MAC | ||
1677 | * Address. It is useful for writing a network monitor, | ||
1678 | * but it is also a security problem. You have to remember | ||
1679 | * that all information on the net is not encrypted. | ||
1680 | * | ||
1681 | * Parameters : I : struct net_device *dev - SK_G16 device Structure | ||
1682 | * Return Value : None | ||
1683 | * Errors : None | ||
1684 | * Globals : None | ||
1685 | * Update History : | ||
1686 | * YY/MM/DD uid Description | ||
1687 | * 95/10/18 ACox New multicast calling scheme | ||
1688 | -*/ | ||
1689 | |||
1690 | |||
1691 | /* Set or clear the multicast filter for SK_G16. | ||
1692 | */ | ||
1693 | |||
1694 | static void set_multicast_list(struct net_device *dev) | ||
1695 | { | ||
1696 | |||
1697 | if (dev->flags&IFF_PROMISC) | ||
1698 | { | ||
1699 | /* Reinitialize LANCE with MODE_PROM set */ | ||
1700 | SK_lance_init(dev, MODE_PROM); | ||
1701 | } | ||
1702 | else if (dev->mc_count==0 && !(dev->flags&IFF_ALLMULTI)) | ||
1703 | { | ||
1704 | /* Reinitialize LANCE without MODE_PROM */ | ||
1705 | SK_lance_init(dev, MODE_NORMAL); | ||
1706 | } | ||
1707 | else | ||
1708 | { | ||
1709 | /* Multicast with logical address filter on */ | ||
1710 | /* Reinitialize LANCE without MODE_PROM */ | ||
1711 | SK_lance_init(dev, MODE_NORMAL); | ||
1712 | |||
1713 | /* Not implemented yet. */ | ||
1714 | } | ||
1715 | } /* End of set_multicast_list() */ | ||
1716 | |||
1717 | |||
1718 | |||
1719 | /*- | ||
1720 | * Function : SK_rom_addr | ||
1721 | * Author : Patrick J.D. Weichmann | ||
1722 | * Date Created : 94/06/01 | ||
1723 | * | ||
1724 | * Description : Try to find a Boot_ROM at all possible locations | ||
1725 | * | ||
1726 | * Parameters : None | ||
1727 | * Return Value : Address where Boot_ROM is | ||
1728 | * Errors : 0 - Did not find Boot_ROM | ||
1729 | * Globals : None | ||
1730 | * Update History : | ||
1731 | * YY/MM/DD uid Description | ||
1732 | -*/ | ||
1733 | |||
1734 | unsigned int __init SK_rom_addr(void) | ||
1735 | { | ||
1736 | int i,j; | ||
1737 | int rom_found = 0; | ||
1738 | unsigned int rom_location[] = SK_BOOT_ROM_LOCATIONS; | ||
1739 | unsigned char rom_id[] = SK_BOOT_ROM_ID; | ||
1740 | unsigned char test_byte; | ||
1741 | |||
1742 | /* Autodetect Boot_ROM */ | ||
1743 | PRINTK(("## %s: Autodetection of Boot_ROM\n", SK_NAME)); | ||
1744 | |||
1745 | for (i = 0; (rom_location[i] != 0) && (rom_found == 0); i++) | ||
1746 | { | ||
1747 | |||
1748 | PRINTK(("## Trying ROM location %#08x", rom_location[i])); | ||
1749 | |||
1750 | rom_found = 1; | ||
1751 | for (j = 0; j < 6; j++) | ||
1752 | { | ||
1753 | test_byte = readb(rom_location[i]+j); | ||
1754 | PRINTK((" %02x ", *test_byte)); | ||
1755 | |||
1756 | if(test_byte != rom_id[j]) | ||
1757 | { | ||
1758 | rom_found = 0; | ||
1759 | } | ||
1760 | } | ||
1761 | PRINTK(("\n")); | ||
1762 | } | ||
1763 | |||
1764 | if (rom_found == 1) | ||
1765 | { | ||
1766 | PRINTK(("## %s: Boot_ROM found at %#08x\n", | ||
1767 | SK_NAME, rom_location[(i-1)])); | ||
1768 | |||
1769 | return (rom_location[--i]); | ||
1770 | } | ||
1771 | else | ||
1772 | { | ||
1773 | PRINTK(("%s: No Boot_ROM found\n", SK_NAME)); | ||
1774 | return 0; | ||
1775 | } | ||
1776 | } /* End of SK_rom_addr() */ | ||
1777 | |||
1778 | |||
1779 | |||
1780 | /* LANCE access functions | ||
1781 | * | ||
1782 | * ! CSR1-3 can only be accessed when in CSR0 the STOP bit is set ! | ||
1783 | */ | ||
1784 | |||
1785 | |||
1786 | /*- | ||
1787 | * Function : SK_reset_board | ||
1788 | * | ||
1789 | * Author : Patrick J.D. Weichmann | ||
1790 | * | ||
1791 | * Date Created : 94/05/25 | ||
1792 | * | ||
1793 | * Description : This function resets SK_G16 and all components, but | ||
1794 | * POS registers are not changed | ||
1795 | * | ||
1796 | * Parameters : None | ||
1797 | * Return Value : None | ||
1798 | * Errors : None | ||
1799 | * Globals : SK_RAM *board - SK_RAM structure pointer | ||
1800 | * | ||
1801 | * Update History : | ||
1802 | * YY/MM/DD uid Description | ||
1803 | -*/ | ||
1804 | |||
1805 | void SK_reset_board(void) | ||
1806 | { | ||
1807 | writeb(0x00, SK_PORT); /* Reset active */ | ||
1808 | mdelay(5); /* Delay min 5ms */ | ||
1809 | writeb(SK_RESET, SK_PORT); /* Set back to normal operation */ | ||
1810 | |||
1811 | } /* End of SK_reset_board() */ | ||
1812 | |||
1813 | |||
1814 | /*- | ||
1815 | * Function : SK_set_RAP | ||
1816 | * Author : Patrick J.D. Weichmann | ||
1817 | * Date Created : 94/05/25 | ||
1818 | * | ||
1819 | * Description : Set LANCE Register Address Port to register | ||
1820 | * for later data transfer. | ||
1821 | * | ||
1822 | * Parameters : I : reg_number - which CSR to read/write from/to | ||
1823 | * Return Value : None | ||
1824 | * Errors : None | ||
1825 | * Globals : SK_RAM *board - SK_RAM structure pointer | ||
1826 | * Update History : | ||
1827 | * YY/MM/DD uid Description | ||
1828 | -*/ | ||
1829 | |||
1830 | void SK_set_RAP(int reg_number) | ||
1831 | { | ||
1832 | writew(reg_number, SK_IOREG); | ||
1833 | writeb(SK_RESET | SK_RAP | SK_WREG, SK_PORT); | ||
1834 | writeb(SK_DOIO, SK_IOCOM); | ||
1835 | |||
1836 | while (readb(SK_PORT) & SK_IORUN) | ||
1837 | barrier(); | ||
1838 | } /* End of SK_set_RAP() */ | ||
1839 | |||
1840 | |||
1841 | /*- | ||
1842 | * Function : SK_read_reg | ||
1843 | * Author : Patrick J.D. Weichmann | ||
1844 | * Date Created : 94/05/25 | ||
1845 | * | ||
1846 | * Description : Set RAP and read data from a LANCE CSR register | ||
1847 | * | ||
1848 | * Parameters : I : reg_number - which CSR to read from | ||
1849 | * Return Value : Register contents | ||
1850 | * Errors : None | ||
1851 | * Globals : SK_RAM *board - SK_RAM structure pointer | ||
1852 | * Update History : | ||
1853 | * YY/MM/DD uid Description | ||
1854 | -*/ | ||
1855 | |||
1856 | int SK_read_reg(int reg_number) | ||
1857 | { | ||
1858 | SK_set_RAP(reg_number); | ||
1859 | |||
1860 | writeb(SK_RESET | SK_RDATA | SK_RREG, SK_PORT); | ||
1861 | writeb(SK_DOIO, SK_IOCOM); | ||
1862 | |||
1863 | while (readb(SK_PORT) & SK_IORUN) | ||
1864 | barrier(); | ||
1865 | return (readw(SK_IOREG)); | ||
1866 | |||
1867 | } /* End of SK_read_reg() */ | ||
1868 | |||
1869 | |||
1870 | /*- | ||
1871 | * Function : SK_rread_reg | ||
1872 | * Author : Patrick J.D. Weichmann | ||
1873 | * Date Created : 94/05/28 | ||
1874 | * | ||
1875 | * Description : Read data from preseted register. | ||
1876 | * This function requires that you know which | ||
1877 | * Register is actually set. Be aware that CSR1-3 | ||
1878 | * can only be accessed when in CSR0 STOP is set. | ||
1879 | * | ||
1880 | * Return Value : Register contents | ||
1881 | * Errors : None | ||
1882 | * Globals : SK_RAM *board - SK_RAM structure pointer | ||
1883 | * Update History : | ||
1884 | * YY/MM/DD uid Description | ||
1885 | -*/ | ||
1886 | |||
1887 | int SK_rread_reg(void) | ||
1888 | { | ||
1889 | writeb(SK_RESET | SK_RDATA | SK_RREG, SK_PORT); | ||
1890 | |||
1891 | writeb(SK_DOIO, SK_IOCOM); | ||
1892 | |||
1893 | while (readb(SK_PORT) & SK_IORUN) | ||
1894 | barrier(); | ||
1895 | return (readw(SK_IOREG)); | ||
1896 | |||
1897 | } /* End of SK_rread_reg() */ | ||
1898 | |||
1899 | |||
1900 | /*- | ||
1901 | * Function : SK_write_reg | ||
1902 | * Author : Patrick J.D. Weichmann | ||
1903 | * Date Created : 94/05/25 | ||
1904 | * | ||
1905 | * Description : This function sets the RAP then fills in the | ||
1906 | * LANCE I/O Reg and starts Transfer to LANCE. | ||
1907 | * It waits until transfer has ended which is max. 7 ms | ||
1908 | * and then it returns. | ||
1909 | * | ||
1910 | * Parameters : I : reg_number - which CSR to write to | ||
1911 | * I : value - what value to fill into register | ||
1912 | * Return Value : None | ||
1913 | * Errors : None | ||
1914 | * Globals : SK_RAM *board - SK_RAM structure pointer | ||
1915 | * Update History : | ||
1916 | * YY/MM/DD uid Description | ||
1917 | -*/ | ||
1918 | |||
1919 | void SK_write_reg(int reg_number, int value) | ||
1920 | { | ||
1921 | SK_set_RAP(reg_number); | ||
1922 | |||
1923 | writew(value, SK_IOREG); | ||
1924 | writeb(SK_RESET | SK_RDATA | SK_WREG, SK_PORT); | ||
1925 | writeb(SK_DOIO, SK_IOCOM); | ||
1926 | |||
1927 | while (readb(SK_PORT) & SK_IORUN) | ||
1928 | barrier(); | ||
1929 | } /* End of SK_write_reg */ | ||
1930 | |||
1931 | |||
1932 | |||
1933 | /* | ||
1934 | * Debugging functions | ||
1935 | * ------------------- | ||
1936 | */ | ||
1937 | |||
1938 | /*- | ||
1939 | * Function : SK_print_pos | ||
1940 | * Author : Patrick J.D. Weichmann | ||
1941 | * Date Created : 94/05/25 | ||
1942 | * | ||
1943 | * Description : This function prints out the 4 POS (Programmable | ||
1944 | * Option Select) Registers. Used mainly to debug operation. | ||
1945 | * | ||
1946 | * Parameters : I : struct net_device *dev - SK_G16 device structure | ||
1947 | * I : char * - Text which will be printed as title | ||
1948 | * Return Value : None | ||
1949 | * Errors : None | ||
1950 | * Update History : | ||
1951 | * YY/MM/DD uid Description | ||
1952 | -*/ | ||
1953 | |||
1954 | void SK_print_pos(struct net_device *dev, char *text) | ||
1955 | { | ||
1956 | int ioaddr = dev->base_addr; | ||
1957 | |||
1958 | unsigned char pos0 = inb(SK_POS0), | ||
1959 | pos1 = inb(SK_POS1), | ||
1960 | pos2 = inb(SK_POS2), | ||
1961 | pos3 = inb(SK_POS3), | ||
1962 | pos4 = inb(SK_POS4); | ||
1963 | |||
1964 | |||
1965 | printk("## %s: %s.\n" | ||
1966 | "## pos0=%#4x pos1=%#4x pos2=%#04x pos3=%#08x pos4=%#04x\n", | ||
1967 | SK_NAME, text, pos0, pos1, pos2, (pos3<<14), pos4); | ||
1968 | |||
1969 | } /* End of SK_print_pos() */ | ||
1970 | |||
1971 | |||
1972 | |||
1973 | /*- | ||
1974 | * Function : SK_print_dev | ||
1975 | * Author : Patrick J.D. Weichmann | ||
1976 | * Date Created : 94/05/25 | ||
1977 | * | ||
1978 | * Description : This function simply prints out the important fields | ||
1979 | * of the device structure. | ||
1980 | * | ||
1981 | * Parameters : I : struct net_device *dev - SK_G16 device structure | ||
1982 | * I : char *text - Title for printing | ||
1983 | * Return Value : None | ||
1984 | * Errors : None | ||
1985 | * Update History : | ||
1986 | * YY/MM/DD uid Description | ||
1987 | -*/ | ||
1988 | |||
1989 | void SK_print_dev(struct net_device *dev, char *text) | ||
1990 | { | ||
1991 | if (dev == NULL) | ||
1992 | { | ||
1993 | printk("## %s: Device Structure. %s\n", SK_NAME, text); | ||
1994 | printk("## DEVICE == NULL\n"); | ||
1995 | } | ||
1996 | else | ||
1997 | { | ||
1998 | printk("## %s: Device Structure. %s\n", SK_NAME, text); | ||
1999 | printk("## Device Name: %s Base Address: %#06lx IRQ: %d\n", | ||
2000 | dev->name, dev->base_addr, dev->irq); | ||
2001 | |||
2002 | printk("## next device: %#08x init function: %#08x\n", | ||
2003 | (int) dev->next, (int) dev->init); | ||
2004 | } | ||
2005 | |||
2006 | } /* End of SK_print_dev() */ | ||
2007 | |||
2008 | |||
2009 | |||
2010 | /*- | ||
2011 | * Function : SK_print_ram | ||
2012 | * Author : Patrick J.D. Weichmann | ||
2013 | * Date Created : 94/06/02 | ||
2014 | * | ||
2015 | * Description : This function is used to check how are things set up | ||
2016 | * in the 16KB RAM. Also the pointers to the receive and | ||
2017 | * transmit descriptor rings and rx and tx buffers locations. | ||
2018 | * It contains a minor bug in printing, but has no effect to the values | ||
2019 | * only newlines are not correct. | ||
2020 | * | ||
2021 | * Parameters : I : struct net_device *dev - SK_G16 device structure | ||
2022 | * Return Value : None | ||
2023 | * Errors : None | ||
2024 | * Globals : None | ||
2025 | * Update History : | ||
2026 | * YY/MM/DD uid Description | ||
2027 | -*/ | ||
2028 | |||
2029 | void __init SK_print_ram(struct net_device *dev) | ||
2030 | { | ||
2031 | |||
2032 | int i; | ||
2033 | struct priv *p = netdev_priv(dev); | ||
2034 | |||
2035 | printk("## %s: RAM Details.\n" | ||
2036 | "## RAM at %#08x tmdhead: %#08x rmdhead: %#08x initblock: %#08x\n", | ||
2037 | SK_NAME, | ||
2038 | (unsigned int) p->ram, | ||
2039 | (unsigned int) p->tmdhead, | ||
2040 | (unsigned int) p->rmdhead, | ||
2041 | (unsigned int) &(p->ram)->ib); | ||
2042 | |||
2043 | printk("## "); | ||
2044 | |||
2045 | for(i = 0; i < TMDNUM; i++) | ||
2046 | { | ||
2047 | if (!(i % 3)) /* Every third line do a newline */ | ||
2048 | { | ||
2049 | printk("\n## "); | ||
2050 | } | ||
2051 | printk("tmdbufs%d: %#08x ", (i+1), (int) p->tmdbufs[i]); | ||
2052 | } | ||
2053 | printk("## "); | ||
2054 | |||
2055 | for(i = 0; i < RMDNUM; i++) | ||
2056 | { | ||
2057 | if (!(i % 3)) /* Every third line do a newline */ | ||
2058 | { | ||
2059 | printk("\n## "); | ||
2060 | } | ||
2061 | printk("rmdbufs%d: %#08x ", (i+1), (int) p->rmdbufs[i]); | ||
2062 | } | ||
2063 | printk("\n"); | ||
2064 | |||
2065 | } /* End of SK_print_ram() */ | ||
2066 | |||
diff --git a/drivers/net/sk_g16.h b/drivers/net/sk_g16.h deleted file mode 100644 index 0a5dc0908a04..000000000000 --- a/drivers/net/sk_g16.h +++ /dev/null | |||
@@ -1,165 +0,0 @@ | |||
1 | /*- | ||
2 | * | ||
3 | * This software may be used and distributed according to the terms | ||
4 | * of the GNU General Public License, incorporated herein by reference. | ||
5 | * | ||
6 | * Module : sk_g16.h | ||
7 | * Version : $Revision$ | ||
8 | * | ||
9 | * Author : M.Hipp (mhipp@student.uni-tuebingen.de) | ||
10 | * changes by : Patrick J.D. Weichmann | ||
11 | * | ||
12 | * Date Created : 94/05/25 | ||
13 | * | ||
14 | * Description : In here are all necessary definitions of | ||
15 | * the am7990 (LANCE) chip used for writing a | ||
16 | * network device driver which uses this chip | ||
17 | * | ||
18 | * $Log$ | ||
19 | -*/ | ||
20 | |||
21 | #ifndef SK_G16_H | ||
22 | |||
23 | #define SK_G16_H | ||
24 | |||
25 | |||
26 | /* | ||
27 | * Control and Status Register 0 (CSR0) bit definitions | ||
28 | * | ||
29 | * (R=Readable) (W=Writeable) (S=Set on write) (C-Clear on write) | ||
30 | * | ||
31 | */ | ||
32 | |||
33 | #define CSR0_ERR 0x8000 /* Error summary (R) */ | ||
34 | #define CSR0_BABL 0x4000 /* Babble transmitter timeout error (RC) */ | ||
35 | #define CSR0_CERR 0x2000 /* Collision Error (RC) */ | ||
36 | #define CSR0_MISS 0x1000 /* Missed packet (RC) */ | ||
37 | #define CSR0_MERR 0x0800 /* Memory Error (RC) */ | ||
38 | #define CSR0_RINT 0x0400 /* Receiver Interrupt (RC) */ | ||
39 | #define CSR0_TINT 0x0200 /* Transmit Interrupt (RC) */ | ||
40 | #define CSR0_IDON 0x0100 /* Initialization Done (RC) */ | ||
41 | #define CSR0_INTR 0x0080 /* Interrupt Flag (R) */ | ||
42 | #define CSR0_INEA 0x0040 /* Interrupt Enable (RW) */ | ||
43 | #define CSR0_RXON 0x0020 /* Receiver on (R) */ | ||
44 | #define CSR0_TXON 0x0010 /* Transmitter on (R) */ | ||
45 | #define CSR0_TDMD 0x0008 /* Transmit Demand (RS) */ | ||
46 | #define CSR0_STOP 0x0004 /* Stop (RS) */ | ||
47 | #define CSR0_STRT 0x0002 /* Start (RS) */ | ||
48 | #define CSR0_INIT 0x0001 /* Initialize (RS) */ | ||
49 | |||
50 | #define CSR0_CLRALL 0x7f00 /* mask for all clearable bits */ | ||
51 | |||
52 | /* | ||
53 | * Control and Status Register 3 (CSR3) bit definitions | ||
54 | * | ||
55 | */ | ||
56 | |||
57 | #define CSR3_BSWAP 0x0004 /* Byte Swap (RW) */ | ||
58 | #define CSR3_ACON 0x0002 /* ALE Control (RW) */ | ||
59 | #define CSR3_BCON 0x0001 /* Byte Control (RW) */ | ||
60 | |||
61 | /* | ||
62 | * Initialization Block Mode operation Bit Definitions. | ||
63 | */ | ||
64 | |||
65 | #define MODE_PROM 0x8000 /* Promiscuous Mode */ | ||
66 | #define MODE_INTL 0x0040 /* Internal Loopback */ | ||
67 | #define MODE_DRTY 0x0020 /* Disable Retry */ | ||
68 | #define MODE_COLL 0x0010 /* Force Collision */ | ||
69 | #define MODE_DTCR 0x0008 /* Disable Transmit CRC) */ | ||
70 | #define MODE_LOOP 0x0004 /* Loopback */ | ||
71 | #define MODE_DTX 0x0002 /* Disable the Transmitter */ | ||
72 | #define MODE_DRX 0x0001 /* Disable the Receiver */ | ||
73 | |||
74 | #define MODE_NORMAL 0x0000 /* Normal operation mode */ | ||
75 | |||
76 | /* | ||
77 | * Receive message descriptor status bit definitions. | ||
78 | */ | ||
79 | |||
80 | #define RX_OWN 0x80 /* Owner bit 0 = host, 1 = lance */ | ||
81 | #define RX_ERR 0x40 /* Error Summary */ | ||
82 | #define RX_FRAM 0x20 /* Framing Error */ | ||
83 | #define RX_OFLO 0x10 /* Overflow Error */ | ||
84 | #define RX_CRC 0x08 /* CRC Error */ | ||
85 | #define RX_BUFF 0x04 /* Buffer Error */ | ||
86 | #define RX_STP 0x02 /* Start of Packet */ | ||
87 | #define RX_ENP 0x01 /* End of Packet */ | ||
88 | |||
89 | |||
90 | /* | ||
91 | * Transmit message descriptor status bit definitions. | ||
92 | */ | ||
93 | |||
94 | #define TX_OWN 0x80 /* Owner bit 0 = host, 1 = lance */ | ||
95 | #define TX_ERR 0x40 /* Error Summary */ | ||
96 | #define TX_MORE 0x10 /* More the 1 retry needed to Xmit */ | ||
97 | #define TX_ONE 0x08 /* One retry needed to Xmit */ | ||
98 | #define TX_DEF 0x04 /* Deferred */ | ||
99 | #define TX_STP 0x02 /* Start of Packet */ | ||
100 | #define TX_ENP 0x01 /* End of Packet */ | ||
101 | |||
102 | /* | ||
103 | * Transmit status (2) (valid if TX_ERR == 1) | ||
104 | */ | ||
105 | |||
106 | #define TX_BUFF 0x8000 /* Buffering error (no ENP) */ | ||
107 | #define TX_UFLO 0x4000 /* Underflow (late memory) */ | ||
108 | #define TX_LCOL 0x1000 /* Late collision */ | ||
109 | #define TX_LCAR 0x0400 /* Loss of Carrier */ | ||
110 | #define TX_RTRY 0x0200 /* Failed after 16 retransmissions */ | ||
111 | #define TX_TDR 0x003f /* Time-domain-reflectometer-value */ | ||
112 | |||
113 | |||
114 | /* | ||
115 | * Structures used for Communication with the LANCE | ||
116 | */ | ||
117 | |||
118 | /* LANCE Initialize Block */ | ||
119 | |||
120 | struct init_block | ||
121 | { | ||
122 | unsigned short mode; /* Mode Register */ | ||
123 | unsigned char paddr[6]; /* Physical Address (MAC) */ | ||
124 | unsigned char laddr[8]; /* Logical Filter Address (not used) */ | ||
125 | unsigned int rdrp; /* Receive Descriptor Ring pointer */ | ||
126 | unsigned int tdrp; /* Transmit Descriptor Ring pointer */ | ||
127 | }; | ||
128 | |||
129 | |||
130 | /* Receive Message Descriptor Entry */ | ||
131 | |||
132 | struct rmd | ||
133 | { | ||
134 | union | ||
135 | { | ||
136 | unsigned long buffer; /* Address of buffer */ | ||
137 | struct | ||
138 | { | ||
139 | unsigned char unused[3]; | ||
140 | unsigned volatile char status; /* Status Bits */ | ||
141 | } s; | ||
142 | } u; | ||
143 | volatile short blen; /* Buffer Length (two's complement) */ | ||
144 | unsigned short mlen; /* Message Byte Count */ | ||
145 | }; | ||
146 | |||
147 | |||
148 | /* Transmit Message Descriptor Entry */ | ||
149 | |||
150 | struct tmd | ||
151 | { | ||
152 | union | ||
153 | { | ||
154 | unsigned long buffer; /* Address of buffer */ | ||
155 | struct | ||
156 | { | ||
157 | unsigned char unused[3]; | ||
158 | unsigned volatile char status; /* Status Bits */ | ||
159 | } s; | ||
160 | } u; | ||
161 | unsigned short blen; /* Buffer Length (two's complement) */ | ||
162 | unsigned volatile short status2; /* Error Status Bits */ | ||
163 | }; | ||
164 | |||
165 | #endif /* End of SK_G16_H */ | ||