aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2013-01-09 20:30:26 -0500
committerPaul Gortmaker <paul.gortmaker@windriver.com>2013-01-22 10:39:49 -0500
commit168e06ae26dd327df347e70b7244218ff1766a1f (patch)
tree03ce0fd097f6e0fd98227448882c8520eb3d9302
parentde8270ff4642f78ff62e9bae20e6ebf39677880c (diff)
drivers/net: delete old parallel port de600/de620 drivers
The parallel port is largely replaced by USB, and even in the day where these drivers were current, the documented speed was less than 100kB/s. Let us not pretend that anyone cares about these drivers anymore, or worse - pretend that anyone is using them on a modern kernel. As a side bonus, this is the end of legacy parallel port ethernet, so we get to drop the whole chunk relating to that in the legacy Space.c file containing the non-PCI unified probe dispatch. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--Documentation/networking/DLINK.txt203
-rw-r--r--drivers/net/Space.c13
-rw-r--r--drivers/net/ethernet/dlink/Kconfig32
-rw-r--r--drivers/net/ethernet/dlink/Makefile2
-rw-r--r--drivers/net/ethernet/dlink/de600.c529
-rw-r--r--drivers/net/ethernet/dlink/de600.h168
-rw-r--r--drivers/net/ethernet/dlink/de620.c987
-rw-r--r--drivers/net/ethernet/dlink/de620.h117
8 files changed, 2 insertions, 2049 deletions
diff --git a/Documentation/networking/DLINK.txt b/Documentation/networking/DLINK.txt
deleted file mode 100644
index 55d24433d151..000000000000
--- a/Documentation/networking/DLINK.txt
+++ /dev/null
@@ -1,203 +0,0 @@
1Released 1994-06-13
2
3
4 CONTENTS:
5
6 1. Introduction.
7 2. License.
8 3. Files in this release.
9 4. Installation.
10 5. Problems and tuning.
11 6. Using the drivers with earlier releases.
12 7. Acknowledgments.
13
14
15 1. INTRODUCTION.
16
17 This is a set of Ethernet drivers for the D-Link DE-600/DE-620
18 pocket adapters, for the parallel port on a Linux based machine.
19 Some adapter "clones" will also work. Xircom is _not_ a clone...
20 These drivers _can_ be used as loadable modules,
21 and were developed for use on Linux 1.1.13 and above.
22 For use on Linux 1.0.X, or earlier releases, see below.
23
24 I have used these drivers for NFS, ftp, telnet and X-clients on
25 remote machines. Transmissions with ftp seems to work as
26 good as can be expected (i.e. > 80k bytes/sec) from a
27 parallel port...:-) Receive speeds will be about 60-80% of this.
28 Depending on your machine, somewhat higher speeds can be achieved.
29
30 All comments/fixes to Bjorn Ekwall (bj0rn@blox.se).
31
32
33 2. LICENSE.
34
35 This program is free software; you can redistribute it
36 and/or modify it under the terms of the GNU General Public
37 License as published by the Free Software Foundation; either
38 version 2, or (at your option) any later version.
39
40 This program is distributed in the hope that it will be
41 useful, but WITHOUT ANY WARRANTY; without even the implied
42 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
43 PURPOSE. See the GNU General Public License for more
44 details.
45
46 You should have received a copy of the GNU General Public
47 License along with this program; if not, write to the Free
48 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
49 02139, USA.
50
51
52 3. FILES IN THIS RELEASE.
53
54 README.DLINK This file.
55 de600.c The Source (may it be with You :-) for the DE-600
56 de620.c ditto for the DE-620
57 de620.h Macros for de620.c
58
59 If you are upgrading from the d-link tar release, there will
60 also be a "dlink-patches" file that will patch Linux 1.1.18:
61 linux/drivers/net/Makefile
62 linux/drivers/net/CONFIG
63 linux/drivers/net/MODULES
64 linux/drivers/net/Space.c
65 linux/config.in
66 Apply the patch by:
67 "cd /usr/src; patch -p0 < linux/drivers/net/dlink-patches"
68 The old source, "linux/drivers/net/d_link.c", can be removed.
69
70
71 4. INSTALLATION.
72
73 o Get the latest net binaries, according to current net.wisdom.
74
75 o Read the NET-2 and Ethernet HOWTOs and modify your setup.
76
77 o If your parallel port has a strange address or irq,
78 modify "linux/drivers/net/CONFIG" accordingly, or adjust
79 the parameters in the "tuning" section in the sources.
80
81 If you are going to use the drivers as loadable modules, do _not_
82 enable them while doing "make config", but instead make sure that
83 the drivers are included in "linux/drivers/net/MODULES".
84
85 If you are _not_ going to use the driver(s) as loadable modules,
86 but instead have them included in the kernel, remember to enable
87 the drivers while doing "make config".
88
89 o To include networking and DE600/DE620 support in your kernel:
90 # cd /linux
91 (as modules:)
92 # make config (answer yes on CONFIG_NET and CONFIG_INET)
93 (else included in the kernel:)
94 # make config (answer yes on CONFIG _NET, _INET and _DE600 or _DE620)
95 # make clean
96 # make zImage (or whatever magic you usually do)
97
98 o I use lilo to boot multiple kernels, so that I at least
99 can have one working kernel :-). If you do too, append
100 these lines to /etc/lilo/config:
101
102 image = /linux/zImage
103 label = newlinux
104 root = /dev/hda2 (or whatever YOU have...)
105
106 # /etc/lilo/install
107
108 o Do "sync" and reboot the new kernel with a D-Link
109 DE-600/DE-620 pocket adapter connected.
110
111 o The adapter can be configured with ifconfig eth?
112 where the actual number is decided by the kernel
113 when the drivers are initialized.
114
115
116 5. "PROBLEMS" AND TUNING,
117
118 o If you see error messages from the driver, and if the traffic
119 stops on the adapter, try to do "ifconfig" and "route" once
120 more, just as in "rc.inet1". This should take care of most
121 problems, including effects from power loss, or adapters that
122 aren't connected to the printer port in some way or another.
123 You can somewhat change the behaviour by enabling/disabling
124 the macro SHUTDOWN_WHEN_LOST in the "tuning" section.
125 For the DE-600 there is another macro, CHECK_LOST_DE600,
126 that you might want to read about in the "tuning" section.
127
128 o Some machines have trouble handling the parallel port and
129 the adapter at high speed. If you experience problems:
130
131 DE-600:
132 - The adapter is not recognized at boot, i.e. an Ethernet
133 address of 00:80:c8:... is not shown, try to add another
134 "; SLOW_DOWN_IO"
135 at DE600_SLOW_DOWN in the "tuning" section. As a last resort,
136 uncomment: "#define REALLY_SLOW_IO" (see <asm/io.h> for hints).
137
138 - You experience "timeout" messages: first try to add another
139 "; SLOW_DOWN_IO"
140 at DE600_SLOW_DOWN in the "tuning" section, _then_ try to
141 increase the value (original value: 5) at
142 "if (tickssofar < 5)" near line 422.
143
144 DE-620:
145 - Your parallel port might be "sluggish". To cater for
146 this, there are the macros LOWSPEED and READ_DELAY/WRITE_DELAY
147 in the "tuning" section. Your first step should be to enable
148 LOWSPEED, and after that you can "tune" the XXX_DELAY values.
149
150 o If the adapter _is_ recognized at boot but you get messages
151 about "Network Unreachable", then the problem is probably
152 _not_ with the driver. Check your net configuration instead
153 (ifconfig and route) in "rc.inet1".
154
155 o There is some rudimentary support for debugging, look at
156 the source. Use "-DDE600_DEBUG=3" or "-DDE620_DEBUG=3"
157 when compiling, or include it in "linux/drivers/net/CONFIG".
158 IF YOU HAVE PROBLEMS YOU CAN'T SOLVE: PLEASE COMPILE THE DRIVER
159 WITH DEBUGGING ENABLED, AND SEND ME THE RESULTING OUTPUT!
160
161
162 6. USING THE DRIVERS WITH EARLIER RELEASES.
163
164 The later 1.1.X releases of the Linux kernel include some
165 changes in the networking layer (a.k.a. NET3). This affects
166 these drivers in a few places. The hints that follow are
167 _not_ tested by me, since I don't have the disk space to keep
168 all releases on-line.
169 Known needed changes to date:
170 - release patchfile: some patches will fail, but they should
171 be easy to apply "by hand", since they are trivial.
172 (Space.c: d_link_init() is now called de600_probe())
173 - de600.c: change "mark_bh(NET_BH)" to "mark_bh(INET_BH)".
174 - de620.c: (maybe) change the code around "netif_rx(skb);" to be
175 similar to the code around "dev_rint(...)" in de600.c
176
177
178 7. ACKNOWLEDGMENTS.
179
180 These drivers wouldn't have been done without the base
181 (and support) from Ross Biro, and D-Link Systems Inc.
182 The driver relies upon GPL-ed source from D-Link Systems Inc.
183 and from Russel Nelson at Crynwr Software <nelson@crynwr.com>.
184
185 Additional input also from:
186 Donald Becker <becker@super.org>, Alan Cox <A.Cox@swansea.ac.uk>
187 and Fred N. van Kempen <waltje@uWalt.NL.Mugnet.ORG>
188
189 DE-600 alpha release primary victim^H^H^H^H^H^Htester:
190 - Erik Proper <erikp@cs.kun.nl>.
191 Good input also from several users, most notably
192 - Mark Burton <markb@ordern.demon.co.uk>.
193
194 DE-620 alpha release victims^H^H^H^H^H^H^Htesters:
195 - J. Joshua Kopper <kopper@rtsg.mot.com>
196 - Olav Kvittem <Olav.Kvittem@uninett.no>
197 - Germano Caronni <caronni@nessie.cs.id.ethz.ch>
198 - Jeremy Fitzhardinge <jeremy@suite.sw.oz.au>
199
200
201 Happy hacking!
202
203 Bjorn Ekwall == bj0rn@blox.se
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index 64cd86efab96..d48712751357 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -73,9 +73,6 @@ extern struct net_device *mac89x0_probe(int unit);
73extern struct net_device *cops_probe(int unit); 73extern struct net_device *cops_probe(int unit);
74extern struct net_device *ltpc_probe(void); 74extern struct net_device *ltpc_probe(void);
75 75
76/* Detachable devices ("pocket adaptors") */
77extern struct net_device *de620_probe(int unit);
78
79/* Fibre Channel adapters */ 76/* Fibre Channel adapters */
80extern int iph5526_probe(struct net_device *dev); 77extern int iph5526_probe(struct net_device *dev);
81 78
@@ -185,13 +182,6 @@ static struct devprobe2 isa_probes[] __initdata = {
185 {NULL, 0}, 182 {NULL, 0},
186}; 183};
187 184
188static struct devprobe2 parport_probes[] __initdata = {
189#ifdef CONFIG_DE620 /* D-Link DE-620 adapter */
190 {de620_probe, 0},
191#endif
192 {NULL, 0},
193};
194
195static struct devprobe2 m68k_probes[] __initdata = { 185static struct devprobe2 m68k_probes[] __initdata = {
196#ifdef CONFIG_ATARILANCE /* Lance-based Atari ethernet boards */ 186#ifdef CONFIG_ATARILANCE /* Lance-based Atari ethernet boards */
197 {atarilance_probe, 0}, 187 {atarilance_probe, 0},
@@ -230,8 +220,7 @@ static void __init ethif_probe2(int unit)
230 return; 220 return;
231 221
232 (void)( probe_list2(unit, m68k_probes, base_addr == 0) && 222 (void)( probe_list2(unit, m68k_probes, base_addr == 0) &&
233 probe_list2(unit, isa_probes, base_addr == 0) && 223 probe_list2(unit, isa_probes, base_addr == 0));
234 probe_list2(unit, parport_probes, base_addr == 0));
235} 224}
236 225
237/* Statically configured drivers -- order matters here. */ 226/* Statically configured drivers -- order matters here. */
diff --git a/drivers/net/ethernet/dlink/Kconfig b/drivers/net/ethernet/dlink/Kconfig
index b5afe218c31b..ee26ce78e270 100644
--- a/drivers/net/ethernet/dlink/Kconfig
+++ b/drivers/net/ethernet/dlink/Kconfig
@@ -5,7 +5,7 @@
5config NET_VENDOR_DLINK 5config NET_VENDOR_DLINK
6 bool "D-Link devices" 6 bool "D-Link devices"
7 default y 7 default y
8 depends on PCI || PARPORT 8 depends on PCI
9 ---help--- 9 ---help---
10 If you have a network (Ethernet) card belonging to this class, say Y 10 If you have a network (Ethernet) card belonging to this class, say Y
11 and read the Ethernet-HOWTO, available from 11 and read the Ethernet-HOWTO, available from
@@ -18,36 +18,6 @@ config NET_VENDOR_DLINK
18 18
19if NET_VENDOR_DLINK 19if NET_VENDOR_DLINK
20 20
21config DE600
22 tristate "D-Link DE600 pocket adapter support"
23 depends on PARPORT
24 ---help---
25 This is a network (Ethernet) device which attaches to your parallel
26 port. Read <file:Documentation/networking/DLINK.txt> as well as the
27 Ethernet-HOWTO, available from
28 <http://www.tldp.org/docs.html#howto>, if you want to use
29 this. It is possible to have several devices share a single parallel
30 port and it is safe to compile the corresponding drivers into the
31 kernel.
32
33 To compile this driver as a module, choose M here: the module
34 will be called de600.
35
36config DE620
37 tristate "D-Link DE620 pocket adapter support"
38 depends on PARPORT
39 ---help---
40 This is a network (Ethernet) device which attaches to your parallel
41 port. Read <file:Documentation/networking/DLINK.txt> as well as the
42 Ethernet-HOWTO, available from
43 <http://www.tldp.org/docs.html#howto>, if you want to use
44 this. It is possible to have several devices share a single parallel
45 port and it is safe to compile the corresponding drivers into the
46 kernel.
47
48 To compile this driver as a module, choose M here: the module
49 will be called de620.
50
51config DL2K 21config DL2K
52 tristate "DL2000/TC902x-based Gigabit Ethernet support" 22 tristate "DL2000/TC902x-based Gigabit Ethernet support"
53 depends on PCI 23 depends on PCI
diff --git a/drivers/net/ethernet/dlink/Makefile b/drivers/net/ethernet/dlink/Makefile
index c705eaa4f5b2..40085f67157b 100644
--- a/drivers/net/ethernet/dlink/Makefile
+++ b/drivers/net/ethernet/dlink/Makefile
@@ -2,7 +2,5 @@
2# Makefile for the D-Link network device drivers. 2# Makefile for the D-Link network device drivers.
3# 3#
4 4
5obj-$(CONFIG_DE600) += de600.o
6obj-$(CONFIG_DE620) += de620.o
7obj-$(CONFIG_DL2K) += dl2k.o 5obj-$(CONFIG_DL2K) += dl2k.o
8obj-$(CONFIG_SUNDANCE) += sundance.o 6obj-$(CONFIG_SUNDANCE) += sundance.o
diff --git a/drivers/net/ethernet/dlink/de600.c b/drivers/net/ethernet/dlink/de600.c
deleted file mode 100644
index 414f0eea1049..000000000000
--- a/drivers/net/ethernet/dlink/de600.c
+++ /dev/null
@@ -1,529 +0,0 @@
1static const char version[] = "de600.c: $Revision: 1.41-2.5 $, Bjorn Ekwall (bj0rn@blox.se)\n";
2/*
3 * de600.c
4 *
5 * Linux driver for the D-Link DE-600 Ethernet pocket adapter.
6 *
7 * Portions (C) Copyright 1993, 1994 by Bjorn Ekwall
8 * The Author may be reached as bj0rn@blox.se
9 *
10 * Based on adapter information gathered from DE600.ASM by D-Link Inc.,
11 * as included on disk C in the v.2.11 of PC/TCP from FTP Software.
12 * For DE600.asm:
13 * Portions (C) Copyright 1990 D-Link, Inc.
14 * Copyright, 1988-1992, Russell Nelson, Crynwr Software
15 *
16 * Adapted to the sample network driver core for linux,
17 * written by: Donald Becker <becker@super.org>
18 * (Now at <becker@scyld.com>)
19 *
20 **************************************************************/
21/*
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2, or (at your option)
25 * any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *
36 **************************************************************/
37
38/* Add more time here if your adapter won't work OK: */
39#define DE600_SLOW_DOWN udelay(delay_time)
40
41#include <linux/module.h>
42#include <linux/kernel.h>
43#include <linux/types.h>
44#include <linux/fcntl.h>
45#include <linux/string.h>
46#include <linux/interrupt.h>
47#include <linux/ioport.h>
48#include <linux/in.h>
49#include <linux/errno.h>
50#include <linux/init.h>
51#include <linux/delay.h>
52#include <linux/inet.h>
53#include <linux/netdevice.h>
54#include <linux/etherdevice.h>
55#include <linux/skbuff.h>
56
57#include <asm/io.h>
58
59#include "de600.h"
60
61static bool check_lost = true;
62module_param(check_lost, bool, 0);
63MODULE_PARM_DESC(check_lost, "If set then check for unplugged de600");
64
65static unsigned int delay_time = 10;
66module_param(delay_time, int, 0);
67MODULE_PARM_DESC(delay_time, "DE-600 deley on I/O in microseconds");
68
69
70/*
71 * D-Link driver variables:
72 */
73
74static volatile int rx_page;
75
76#define TX_PAGES 2
77static volatile int tx_fifo[TX_PAGES];
78static volatile int tx_fifo_in;
79static volatile int tx_fifo_out;
80static volatile int free_tx_pages = TX_PAGES;
81static int was_down;
82static DEFINE_SPINLOCK(de600_lock);
83
84static inline u8 de600_read_status(struct net_device *dev)
85{
86 u8 status;
87
88 outb_p(STATUS, DATA_PORT);
89 status = inb(STATUS_PORT);
90 outb_p(NULL_COMMAND | HI_NIBBLE, DATA_PORT);
91
92 return status;
93}
94
95static inline u8 de600_read_byte(unsigned char type, struct net_device *dev)
96{
97 /* dev used by macros */
98 u8 lo;
99 outb_p((type), DATA_PORT);
100 lo = ((unsigned char)inb(STATUS_PORT)) >> 4;
101 outb_p((type) | HI_NIBBLE, DATA_PORT);
102 return ((unsigned char)inb(STATUS_PORT) & (unsigned char)0xf0) | lo;
103}
104
105/*
106 * Open/initialize the board. This is called (in the current kernel)
107 * after booting when 'ifconfig <dev->name> $IP_ADDR' is run (in rc.inet1).
108 *
109 * This routine should set everything up anew at each open, even
110 * registers that "should" only need to be set once at boot, so that
111 * there is a non-reboot way to recover if something goes wrong.
112 */
113
114static int de600_open(struct net_device *dev)
115{
116 unsigned long flags;
117 int ret = request_irq(DE600_IRQ, de600_interrupt, 0, dev->name, dev);
118 if (ret) {
119 printk(KERN_ERR "%s: unable to get IRQ %d\n", dev->name, DE600_IRQ);
120 return ret;
121 }
122 spin_lock_irqsave(&de600_lock, flags);
123 ret = adapter_init(dev);
124 spin_unlock_irqrestore(&de600_lock, flags);
125 return ret;
126}
127
128/*
129 * The inverse routine to de600_open().
130 */
131
132static int de600_close(struct net_device *dev)
133{
134 select_nic();
135 rx_page = 0;
136 de600_put_command(RESET);
137 de600_put_command(STOP_RESET);
138 de600_put_command(0);
139 select_prn();
140 free_irq(DE600_IRQ, dev);
141 return 0;
142}
143
144static inline void trigger_interrupt(struct net_device *dev)
145{
146 de600_put_command(FLIP_IRQ);
147 select_prn();
148 DE600_SLOW_DOWN;
149 select_nic();
150 de600_put_command(0);
151}
152
153/*
154 * Copy a buffer to the adapter transmit page memory.
155 * Start sending.
156 */
157
158static int de600_start_xmit(struct sk_buff *skb, struct net_device *dev)
159{
160 unsigned long flags;
161 int transmit_from;
162 int len;
163 int tickssofar;
164 u8 *buffer = skb->data;
165 int i;
166
167 if (free_tx_pages <= 0) { /* Do timeouts, to avoid hangs. */
168 tickssofar = jiffies - dev_trans_start(dev);
169 if (tickssofar < HZ/20)
170 return NETDEV_TX_BUSY;
171 /* else */
172 printk(KERN_WARNING "%s: transmit timed out (%d), %s?\n", dev->name, tickssofar, "network cable problem");
173 /* Restart the adapter. */
174 spin_lock_irqsave(&de600_lock, flags);
175 if (adapter_init(dev)) {
176 spin_unlock_irqrestore(&de600_lock, flags);
177 return NETDEV_TX_BUSY;
178 }
179 spin_unlock_irqrestore(&de600_lock, flags);
180 }
181
182 /* Start real output */
183 pr_debug("de600_start_xmit:len=%d, page %d/%d\n", skb->len, tx_fifo_in, free_tx_pages);
184
185 if ((len = skb->len) < RUNT)
186 len = RUNT;
187
188 spin_lock_irqsave(&de600_lock, flags);
189 select_nic();
190 tx_fifo[tx_fifo_in] = transmit_from = tx_page_adr(tx_fifo_in) - len;
191 tx_fifo_in = (tx_fifo_in + 1) % TX_PAGES; /* Next free tx page */
192
193 if(check_lost)
194 {
195 /* This costs about 40 instructions per packet... */
196 de600_setup_address(NODE_ADDRESS, RW_ADDR);
197 de600_read_byte(READ_DATA, dev);
198 if (was_down || (de600_read_byte(READ_DATA, dev) != 0xde)) {
199 if (adapter_init(dev)) {
200 spin_unlock_irqrestore(&de600_lock, flags);
201 return NETDEV_TX_BUSY;
202 }
203 }
204 }
205
206 de600_setup_address(transmit_from, RW_ADDR);
207 for (i = 0; i < skb->len ; ++i, ++buffer)
208 de600_put_byte(*buffer);
209 for (; i < len; ++i)
210 de600_put_byte(0);
211
212 if (free_tx_pages-- == TX_PAGES) { /* No transmission going on */
213 dev->trans_start = jiffies;
214 netif_start_queue(dev); /* allow more packets into adapter */
215 /* Send page and generate a faked interrupt */
216 de600_setup_address(transmit_from, TX_ADDR);
217 de600_put_command(TX_ENABLE);
218 }
219 else {
220 if (free_tx_pages)
221 netif_start_queue(dev);
222 else
223 netif_stop_queue(dev);
224 select_prn();
225 }
226 spin_unlock_irqrestore(&de600_lock, flags);
227 dev_kfree_skb(skb);
228 return NETDEV_TX_OK;
229}
230
231/*
232 * The typical workload of the driver:
233 * Handle the network interface interrupts.
234 */
235
236static irqreturn_t de600_interrupt(int irq, void *dev_id)
237{
238 struct net_device *dev = dev_id;
239 u8 irq_status;
240 int retrig = 0;
241 int boguscount = 0;
242
243 spin_lock(&de600_lock);
244
245 select_nic();
246 irq_status = de600_read_status(dev);
247
248 do {
249 pr_debug("de600_interrupt (%02X)\n", irq_status);
250
251 if (irq_status & RX_GOOD)
252 de600_rx_intr(dev);
253 else if (!(irq_status & RX_BUSY))
254 de600_put_command(RX_ENABLE);
255
256 /* Any transmission in progress? */
257 if (free_tx_pages < TX_PAGES)
258 retrig = de600_tx_intr(dev, irq_status);
259 else
260 retrig = 0;
261
262 irq_status = de600_read_status(dev);
263 } while ( (irq_status & RX_GOOD) || ((++boguscount < 100) && retrig) );
264 /*
265 * Yeah, it _looks_ like busy waiting, smells like busy waiting
266 * and I know it's not PC, but please, it will only occur once
267 * in a while and then only for a loop or so (< 1ms for sure!)
268 */
269
270 /* Enable adapter interrupts */
271 select_prn();
272 if (retrig)
273 trigger_interrupt(dev);
274 spin_unlock(&de600_lock);
275 return IRQ_HANDLED;
276}
277
278static int de600_tx_intr(struct net_device *dev, int irq_status)
279{
280 /*
281 * Returns 1 if tx still not done
282 */
283
284 /* Check if current transmission is done yet */
285 if (irq_status & TX_BUSY)
286 return 1; /* tx not done, try again */
287
288 /* else */
289 /* If last transmission OK then bump fifo index */
290 if (!(irq_status & TX_FAILED16)) {
291 tx_fifo_out = (tx_fifo_out + 1) % TX_PAGES;
292 ++free_tx_pages;
293 dev->stats.tx_packets++;
294 netif_wake_queue(dev);
295 }
296
297 /* More to send, or resend last packet? */
298 if ((free_tx_pages < TX_PAGES) || (irq_status & TX_FAILED16)) {
299 dev->trans_start = jiffies;
300 de600_setup_address(tx_fifo[tx_fifo_out], TX_ADDR);
301 de600_put_command(TX_ENABLE);
302 return 1;
303 }
304 /* else */
305
306 return 0;
307}
308
309/*
310 * We have a good packet, get it out of the adapter.
311 */
312static void de600_rx_intr(struct net_device *dev)
313{
314 struct sk_buff *skb;
315 int i;
316 int read_from;
317 int size;
318 unsigned char *buffer;
319
320 /* Get size of received packet */
321 size = de600_read_byte(RX_LEN, dev); /* low byte */
322 size += (de600_read_byte(RX_LEN, dev) << 8); /* high byte */
323 size -= 4; /* Ignore trailing 4 CRC-bytes */
324
325 /* Tell adapter where to store next incoming packet, enable receiver */
326 read_from = rx_page_adr();
327 next_rx_page();
328 de600_put_command(RX_ENABLE);
329
330 if ((size < 32) || (size > 1535)) {
331 printk(KERN_WARNING "%s: Bogus packet size %d.\n", dev->name, size);
332 if (size > 10000)
333 adapter_init(dev);
334 return;
335 }
336
337 skb = netdev_alloc_skb(dev, size + 2);
338 if (skb == NULL) {
339 printk("%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, size);
340 return;
341 }
342 /* else */
343
344 skb_reserve(skb,2); /* Align */
345
346 /* 'skb->data' points to the start of sk_buff data area. */
347 buffer = skb_put(skb,size);
348
349 /* copy the packet into the buffer */
350 de600_setup_address(read_from, RW_ADDR);
351 for (i = size; i > 0; --i, ++buffer)
352 *buffer = de600_read_byte(READ_DATA, dev);
353
354 skb->protocol=eth_type_trans(skb,dev);
355
356 netif_rx(skb);
357
358 /* update stats */
359 dev->stats.rx_packets++; /* count all receives */
360 dev->stats.rx_bytes += size; /* count all received bytes */
361
362 /*
363 * If any worth-while packets have been received, netif_rx()
364 * will work on them when we get to the tasklets.
365 */
366}
367
368static const struct net_device_ops de600_netdev_ops = {
369 .ndo_open = de600_open,
370 .ndo_stop = de600_close,
371 .ndo_start_xmit = de600_start_xmit,
372 .ndo_change_mtu = eth_change_mtu,
373 .ndo_set_mac_address = eth_mac_addr,
374 .ndo_validate_addr = eth_validate_addr,
375};
376
377
378static struct net_device * __init de600_probe(void)
379{
380 int i;
381 struct net_device *dev;
382 int err;
383
384 dev = alloc_etherdev(0);
385 if (!dev)
386 return ERR_PTR(-ENOMEM);
387
388
389 if (!request_region(DE600_IO, 3, "de600")) {
390 printk(KERN_WARNING "DE600: port 0x%x busy\n", DE600_IO);
391 err = -EBUSY;
392 goto out;
393 }
394
395 printk(KERN_INFO "%s: D-Link DE-600 pocket adapter", dev->name);
396 /* Alpha testers must have the version number to report bugs. */
397 pr_debug("%s", version);
398
399 /* probe for adapter */
400 err = -ENODEV;
401 rx_page = 0;
402 select_nic();
403 (void)de600_read_status(dev);
404 de600_put_command(RESET);
405 de600_put_command(STOP_RESET);
406 if (de600_read_status(dev) & 0xf0) {
407 printk(": not at I/O %#3x.\n", DATA_PORT);
408 goto out1;
409 }
410
411 /*
412 * Maybe we found one,
413 * have to check if it is a D-Link DE-600 adapter...
414 */
415
416 /* Get the adapter ethernet address from the ROM */
417 de600_setup_address(NODE_ADDRESS, RW_ADDR);
418 for (i = 0; i < ETH_ALEN; i++) {
419 dev->dev_addr[i] = de600_read_byte(READ_DATA, dev);
420 dev->broadcast[i] = 0xff;
421 }
422
423 /* Check magic code */
424 if ((dev->dev_addr[1] == 0xde) && (dev->dev_addr[2] == 0x15)) {
425 /* OK, install real address */
426 dev->dev_addr[0] = 0x00;
427 dev->dev_addr[1] = 0x80;
428 dev->dev_addr[2] = 0xc8;
429 dev->dev_addr[3] &= 0x0f;
430 dev->dev_addr[3] |= 0x70;
431 } else {
432 printk(" not identified in the printer port\n");
433 goto out1;
434 }
435
436 printk(", Ethernet Address: %pM\n", dev->dev_addr);
437
438 dev->netdev_ops = &de600_netdev_ops;
439
440 dev->flags&=~IFF_MULTICAST;
441
442 select_prn();
443
444 err = register_netdev(dev);
445 if (err)
446 goto out1;
447
448 return dev;
449
450out1:
451 release_region(DE600_IO, 3);
452out:
453 free_netdev(dev);
454 return ERR_PTR(err);
455}
456
457static int adapter_init(struct net_device *dev)
458{
459 int i;
460
461 select_nic();
462 rx_page = 0; /* used by RESET */
463 de600_put_command(RESET);
464 de600_put_command(STOP_RESET);
465
466 /* Check if it is still there... */
467 /* Get the some bytes of the adapter ethernet address from the ROM */
468 de600_setup_address(NODE_ADDRESS, RW_ADDR);
469 de600_read_byte(READ_DATA, dev);
470 if ((de600_read_byte(READ_DATA, dev) != 0xde) ||
471 (de600_read_byte(READ_DATA, dev) != 0x15)) {
472 /* was: if (de600_read_status(dev) & 0xf0) { */
473 printk("Something has happened to the DE-600! Please check it and do a new ifconfig!\n");
474 /* Goodbye, cruel world... */
475 dev->flags &= ~IFF_UP;
476 de600_close(dev);
477 was_down = 1;
478 netif_stop_queue(dev); /* Transmit busy... */
479 return 1; /* failed */
480 }
481
482 if (was_down) {
483 printk(KERN_INFO "%s: Thanks, I feel much better now!\n", dev->name);
484 was_down = 0;
485 }
486
487 tx_fifo_in = 0;
488 tx_fifo_out = 0;
489 free_tx_pages = TX_PAGES;
490
491
492 /* set the ether address. */
493 de600_setup_address(NODE_ADDRESS, RW_ADDR);
494 for (i = 0; i < ETH_ALEN; i++)
495 de600_put_byte(dev->dev_addr[i]);
496
497 /* where to start saving incoming packets */
498 rx_page = RX_BP | RX_BASE_PAGE;
499 de600_setup_address(MEM_4K, RW_ADDR);
500 /* Enable receiver */
501 de600_put_command(RX_ENABLE);
502 select_prn();
503
504 netif_start_queue(dev);
505
506 return 0; /* OK */
507}
508
509static struct net_device *de600_dev;
510
511static int __init de600_init(void)
512{
513 de600_dev = de600_probe();
514 if (IS_ERR(de600_dev))
515 return PTR_ERR(de600_dev);
516 return 0;
517}
518
519static void __exit de600_exit(void)
520{
521 unregister_netdev(de600_dev);
522 release_region(DE600_IO, 3);
523 free_netdev(de600_dev);
524}
525
526module_init(de600_init);
527module_exit(de600_exit);
528
529MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/dlink/de600.h b/drivers/net/ethernet/dlink/de600.h
deleted file mode 100644
index e80ecbabcf4e..000000000000
--- a/drivers/net/ethernet/dlink/de600.h
+++ /dev/null
@@ -1,168 +0,0 @@
1/**************************************************
2 * *
3 * Definition of D-Link Ethernet Pocket adapter *
4 * *
5 **************************************************/
6/*
7 * D-Link Ethernet pocket adapter ports
8 */
9/*
10 * OK, so I'm cheating, but there are an awful lot of
11 * reads and writes in order to get anything in and out
12 * of the DE-600 with 4 bits at a time in the parallel port,
13 * so every saved instruction really helps :-)
14 */
15
16#ifndef DE600_IO
17#define DE600_IO 0x378
18#endif
19
20#define DATA_PORT (DE600_IO)
21#define STATUS_PORT (DE600_IO + 1)
22#define COMMAND_PORT (DE600_IO + 2)
23
24#ifndef DE600_IRQ
25#define DE600_IRQ 7
26#endif
27/*
28 * It really should look like this, and autoprobing as well...
29 *
30#define DATA_PORT (dev->base_addr + 0)
31#define STATUS_PORT (dev->base_addr + 1)
32#define COMMAND_PORT (dev->base_addr + 2)
33#define DE600_IRQ dev->irq
34 */
35
36/*
37 * D-Link COMMAND_PORT commands
38 */
39#define SELECT_NIC 0x04 /* select Network Interface Card */
40#define SELECT_PRN 0x1c /* select Printer */
41#define NML_PRN 0xec /* normal Printer situation */
42#define IRQEN 0x10 /* enable IRQ line */
43
44/*
45 * D-Link STATUS_PORT
46 */
47#define RX_BUSY 0x80
48#define RX_GOOD 0x40
49#define TX_FAILED16 0x10
50#define TX_BUSY 0x08
51
52/*
53 * D-Link DATA_PORT commands
54 * command in low 4 bits
55 * data in high 4 bits
56 * select current data nibble with HI_NIBBLE bit
57 */
58#define WRITE_DATA 0x00 /* write memory */
59#define READ_DATA 0x01 /* read memory */
60#define STATUS 0x02 /* read status register */
61#define COMMAND 0x03 /* write command register (see COMMAND below) */
62#define NULL_COMMAND 0x04 /* null command */
63#define RX_LEN 0x05 /* read received packet length */
64#define TX_ADDR 0x06 /* set adapter transmit memory address */
65#define RW_ADDR 0x07 /* set adapter read/write memory address */
66#define HI_NIBBLE 0x08 /* read/write the high nibble of data,
67 or-ed with rest of command */
68
69/*
70 * command register, accessed through DATA_PORT with low bits = COMMAND
71 */
72#define RX_ALL 0x01 /* PROMISCUOUS */
73#define RX_BP 0x02 /* default: BROADCAST & PHYSICAL ADDRESS */
74#define RX_MBP 0x03 /* MULTICAST, BROADCAST & PHYSICAL ADDRESS */
75
76#define TX_ENABLE 0x04 /* bit 2 */
77#define RX_ENABLE 0x08 /* bit 3 */
78
79#define RESET 0x80 /* set bit 7 high */
80#define STOP_RESET 0x00 /* set bit 7 low */
81
82/*
83 * data to command register
84 * (high 4 bits in write to DATA_PORT)
85 */
86#define RX_PAGE2_SELECT 0x10 /* bit 4, only 2 pages to select */
87#define RX_BASE_PAGE 0x20 /* bit 5, always set when specifying RX_ADDR */
88#define FLIP_IRQ 0x40 /* bit 6 */
89
90/*
91 * D-Link adapter internal memory:
92 *
93 * 0-2K 1:st transmit page (send from pointer up to 2K)
94 * 2-4K 2:nd transmit page (send from pointer up to 4K)
95 *
96 * 4-6K 1:st receive page (data from 4K upwards)
97 * 6-8K 2:nd receive page (data from 6K upwards)
98 *
99 * 8K+ Adapter ROM (contains magic code and last 3 bytes of Ethernet address)
100 */
101#define MEM_2K 0x0800 /* 2048 */
102#define MEM_4K 0x1000 /* 4096 */
103#define MEM_6K 0x1800 /* 6144 */
104#define NODE_ADDRESS 0x2000 /* 8192 */
105
106#define RUNT 60 /* Too small Ethernet packet */
107
108/**************************************************
109 * *
110 * End of definition *
111 * *
112 **************************************************/
113
114/*
115 * Index to functions, as function prototypes.
116 */
117/* Routines used internally. (See "convenience macros") */
118static u8 de600_read_status(struct net_device *dev);
119static u8 de600_read_byte(unsigned char type, struct net_device *dev);
120
121/* Put in the device structure. */
122static int de600_open(struct net_device *dev);
123static int de600_close(struct net_device *dev);
124static int de600_start_xmit(struct sk_buff *skb, struct net_device *dev);
125
126/* Dispatch from interrupts. */
127static irqreturn_t de600_interrupt(int irq, void *dev_id);
128static int de600_tx_intr(struct net_device *dev, int irq_status);
129static void de600_rx_intr(struct net_device *dev);
130
131/* Initialization */
132static void trigger_interrupt(struct net_device *dev);
133static int adapter_init(struct net_device *dev);
134
135/*
136 * Convenience macros/functions for D-Link adapter
137 */
138
139#define select_prn() outb_p(SELECT_PRN, COMMAND_PORT); DE600_SLOW_DOWN
140#define select_nic() outb_p(SELECT_NIC, COMMAND_PORT); DE600_SLOW_DOWN
141
142/* Thanks for hints from Mark Burton <markb@ordern.demon.co.uk> */
143#define de600_put_byte(data) ( \
144 outb_p(((data) << 4) | WRITE_DATA , DATA_PORT), \
145 outb_p(((data) & 0xf0) | WRITE_DATA | HI_NIBBLE, DATA_PORT))
146
147/*
148 * The first two outb_p()'s below could perhaps be deleted if there
149 * would be more delay in the last two. Not certain about it yet...
150 */
151#define de600_put_command(cmd) ( \
152 outb_p(( rx_page << 4) | COMMAND , DATA_PORT), \
153 outb_p(( rx_page & 0xf0) | COMMAND | HI_NIBBLE, DATA_PORT), \
154 outb_p(((rx_page | cmd) << 4) | COMMAND , DATA_PORT), \
155 outb_p(((rx_page | cmd) & 0xf0) | COMMAND | HI_NIBBLE, DATA_PORT))
156
157#define de600_setup_address(addr,type) ( \
158 outb_p((((addr) << 4) & 0xf0) | type , DATA_PORT), \
159 outb_p(( (addr) & 0xf0) | type | HI_NIBBLE, DATA_PORT), \
160 outb_p((((addr) >> 4) & 0xf0) | type , DATA_PORT), \
161 outb_p((((addr) >> 8) & 0xf0) | type | HI_NIBBLE, DATA_PORT))
162
163#define rx_page_adr() ((rx_page & RX_PAGE2_SELECT)?(MEM_6K):(MEM_4K))
164
165/* Flip bit, only 2 pages */
166#define next_rx_page() (rx_page ^= RX_PAGE2_SELECT)
167
168#define tx_page_adr(a) (((a) + 1) * MEM_2K)
diff --git a/drivers/net/ethernet/dlink/de620.c b/drivers/net/ethernet/dlink/de620.c
deleted file mode 100644
index 2e2bc60ee811..000000000000
--- a/drivers/net/ethernet/dlink/de620.c
+++ /dev/null
@@ -1,987 +0,0 @@
1/*
2 * de620.c $Revision: 1.40 $ BETA
3 *
4 *
5 * Linux driver for the D-Link DE-620 Ethernet pocket adapter.
6 *
7 * Portions (C) Copyright 1993, 1994 by Bjorn Ekwall <bj0rn@blox.se>
8 *
9 * Based on adapter information gathered from DOS packetdriver
10 * sources from D-Link Inc: (Special thanks to Henry Ngai of D-Link.)
11 * Portions (C) Copyright D-Link SYSTEM Inc. 1991, 1992
12 * Copyright, 1988, Russell Nelson, Crynwr Software
13 *
14 * Adapted to the sample network driver core for linux,
15 * written by: Donald Becker <becker@super.org>
16 * (Now at <becker@scyld.com>)
17 *
18 * Valuable assistance from:
19 * J. Joshua Kopper <kopper@rtsg.mot.com>
20 * Olav Kvittem <Olav.Kvittem@uninett.no>
21 * Germano Caronni <caronni@nessie.cs.id.ethz.ch>
22 * Jeremy Fitzhardinge <jeremy@suite.sw.oz.au>
23 *
24 *****************************************************************************/
25/*
26 * This program is free software; you can redistribute it and/or modify
27 * it under the terms of the GNU General Public License as published by
28 * the Free Software Foundation; either version 2, or (at your option)
29 * any later version.
30 *
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
35 *
36 * You should have received a copy of the GNU General Public License
37 * along with this program; if not, write to the Free Software
38 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39 *
40 *****************************************************************************/
41static const char version[] =
42 "de620.c: $Revision: 1.40 $, Bjorn Ekwall <bj0rn@blox.se>\n";
43
44/***********************************************************************
45 *
46 * "Tuning" section.
47 *
48 * Compile-time options: (see below for descriptions)
49 * -DDE620_IO=0x378 (lpt1)
50 * -DDE620_IRQ=7 (lpt1)
51 * -DSHUTDOWN_WHEN_LOST
52 * -DCOUNT_LOOPS
53 * -DLOWSPEED
54 * -DREAD_DELAY
55 * -DWRITE_DELAY
56 */
57
58/*
59 * This driver assumes that the printer port is a "normal",
60 * dumb, uni-directional port!
61 * If your port is "fancy" in any way, please try to set it to "normal"
62 * with your BIOS setup. I have no access to machines with bi-directional
63 * ports, so I can't test such a driver :-(
64 * (Yes, I _know_ it is possible to use DE620 with bidirectional ports...)
65 *
66 * There are some clones of DE620 out there, with different names.
67 * If the current driver does not recognize a clone, try to change
68 * the following #define to:
69 *
70 * #define DE620_CLONE 1
71 */
72#define DE620_CLONE 0
73
74/*
75 * If the adapter has problems with high speeds, enable this #define
76 * otherwise full printerport speed will be attempted.
77 *
78 * You can tune the READ_DELAY/WRITE_DELAY below if you enable LOWSPEED
79 *
80#define LOWSPEED
81 */
82
83#ifndef READ_DELAY
84#define READ_DELAY 100 /* adapter internal read delay in 100ns units */
85#endif
86
87#ifndef WRITE_DELAY
88#define WRITE_DELAY 100 /* adapter internal write delay in 100ns units */
89#endif
90
91/*
92 * Enable this #define if you want the adapter to do a "ifconfig down" on
93 * itself when we have detected that something is possibly wrong with it.
94 * The default behaviour is to retry with "adapter_init()" until success.
95 * This should be used for debugging purposes only.
96 *
97#define SHUTDOWN_WHEN_LOST
98 */
99
100#ifdef LOWSPEED
101/*
102 * Enable this #define if you want to see debugging output that show how long
103 * we have to wait before the DE-620 is ready for the next read/write/command.
104 *
105#define COUNT_LOOPS
106 */
107#endif
108
109#include <linux/module.h>
110#include <linux/kernel.h>
111#include <linux/types.h>
112#include <linux/fcntl.h>
113#include <linux/string.h>
114#include <linux/interrupt.h>
115#include <linux/ioport.h>
116#include <linux/in.h>
117#include <linux/errno.h>
118#include <linux/init.h>
119#include <linux/inet.h>
120#include <linux/netdevice.h>
121#include <linux/etherdevice.h>
122#include <linux/skbuff.h>
123
124#include <asm/io.h>
125
126/* Constant definitions for the DE-620 registers, commands and bits */
127#include "de620.h"
128
129typedef unsigned char byte;
130
131/*******************************************************
132 * *
133 * Definition of D-Link DE-620 Ethernet Pocket adapter *
134 * See also "de620.h" *
135 * *
136 *******************************************************/
137#ifndef DE620_IO /* Compile-time configurable */
138#define DE620_IO 0x378
139#endif
140
141#ifndef DE620_IRQ /* Compile-time configurable */
142#define DE620_IRQ 7
143#endif
144
145#define DATA_PORT (dev->base_addr)
146#define STATUS_PORT (dev->base_addr + 1)
147#define COMMAND_PORT (dev->base_addr + 2)
148
149#define RUNT 60 /* Too small Ethernet packet */
150#define GIANT 1514 /* largest legal size packet, no fcs */
151
152/*
153 * Force media with insmod:
154 * insmod de620.o bnc=1
155 * or
156 * insmod de620.o utp=1
157 *
158 * Force io and/or irq with insmod:
159 * insmod de620.o io=0x378 irq=7
160 *
161 * Make a clone skip the Ethernet-address range check:
162 * insmod de620.o clone=1
163 */
164static int bnc;
165static int utp;
166static int io = DE620_IO;
167static int irq = DE620_IRQ;
168static int clone = DE620_CLONE;
169
170static spinlock_t de620_lock;
171
172module_param(bnc, int, 0);
173module_param(utp, int, 0);
174module_param(io, int, 0);
175module_param(irq, int, 0);
176module_param(clone, int, 0);
177MODULE_PARM_DESC(bnc, "DE-620 set BNC medium (0-1)");
178MODULE_PARM_DESC(utp, "DE-620 set UTP medium (0-1)");
179MODULE_PARM_DESC(io, "DE-620 I/O base address,required");
180MODULE_PARM_DESC(irq, "DE-620 IRQ number,required");
181MODULE_PARM_DESC(clone, "Check also for non-D-Link DE-620 clones (0-1)");
182
183/***********************************************
184 * *
185 * Index to functions, as function prototypes. *
186 * *
187 ***********************************************/
188
189/*
190 * Routines used internally. (See also "convenience macros.. below")
191 */
192
193/* Put in the device structure. */
194static int de620_open(struct net_device *);
195static int de620_close(struct net_device *);
196static void de620_set_multicast_list(struct net_device *);
197static int de620_start_xmit(struct sk_buff *, struct net_device *);
198
199/* Dispatch from interrupts. */
200static irqreturn_t de620_interrupt(int, void *);
201static int de620_rx_intr(struct net_device *);
202
203/* Initialization */
204static int adapter_init(struct net_device *);
205static int read_eeprom(struct net_device *);
206
207
208/*
209 * D-Link driver variables:
210 */
211#define SCR_DEF NIBBLEMODE |INTON | SLEEP | AUTOTX
212#define TCR_DEF RXPB /* not used: | TXSUCINT | T16INT */
213#define DE620_RX_START_PAGE 12 /* 12 pages (=3k) reserved for tx */
214#define DEF_NIC_CMD IRQEN | ICEN | DS1
215
216static volatile byte NIC_Cmd;
217static volatile byte next_rx_page;
218static byte first_rx_page;
219static byte last_rx_page;
220static byte EIPRegister;
221
222static struct nic {
223 byte NodeID[6];
224 byte RAM_Size;
225 byte Model;
226 byte Media;
227 byte SCR;
228} nic_data;
229
230/**********************************************************
231 * *
232 * Convenience macros/functions for D-Link DE-620 adapter *
233 * *
234 **********************************************************/
235#define de620_tx_buffs(dd) (inb(STATUS_PORT) & (TXBF0 | TXBF1))
236#define de620_flip_ds(dd) NIC_Cmd ^= DS0 | DS1; outb(NIC_Cmd, COMMAND_PORT);
237
238/* Check for ready-status, and return a nibble (high 4 bits) for data input */
239#ifdef COUNT_LOOPS
240static int tot_cnt;
241#endif
242static inline byte
243de620_ready(struct net_device *dev)
244{
245 byte value;
246 register short int cnt = 0;
247
248 while ((((value = inb(STATUS_PORT)) & READY) == 0) && (cnt <= 1000))
249 ++cnt;
250
251#ifdef COUNT_LOOPS
252 tot_cnt += cnt;
253#endif
254 return value & 0xf0; /* nibble */
255}
256
257static inline void
258de620_send_command(struct net_device *dev, byte cmd)
259{
260 de620_ready(dev);
261 if (cmd == W_DUMMY)
262 outb(NIC_Cmd, COMMAND_PORT);
263
264 outb(cmd, DATA_PORT);
265
266 outb(NIC_Cmd ^ CS0, COMMAND_PORT);
267 de620_ready(dev);
268 outb(NIC_Cmd, COMMAND_PORT);
269}
270
271static inline void
272de620_put_byte(struct net_device *dev, byte value)
273{
274 /* The de620_ready() makes 7 loops, on the average, on a DX2/66 */
275 de620_ready(dev);
276 outb(value, DATA_PORT);
277 de620_flip_ds(dev);
278}
279
280static inline byte
281de620_read_byte(struct net_device *dev)
282{
283 byte value;
284
285 /* The de620_ready() makes 7 loops, on the average, on a DX2/66 */
286 value = de620_ready(dev); /* High nibble */
287 de620_flip_ds(dev);
288 value |= de620_ready(dev) >> 4; /* Low nibble */
289 return value;
290}
291
292static inline void
293de620_write_block(struct net_device *dev, byte *buffer, int count, int pad)
294{
295#ifndef LOWSPEED
296 byte uflip = NIC_Cmd ^ (DS0 | DS1);
297 byte dflip = NIC_Cmd;
298#else /* LOWSPEED */
299#ifdef COUNT_LOOPS
300 int bytes = count;
301#endif /* COUNT_LOOPS */
302#endif /* LOWSPEED */
303
304#ifdef LOWSPEED
305#ifdef COUNT_LOOPS
306 tot_cnt = 0;
307#endif /* COUNT_LOOPS */
308 /* No further optimization useful, the limit is in the adapter. */
309 for ( ; count > 0; --count, ++buffer) {
310 de620_put_byte(dev,*buffer);
311 }
312 for ( count = pad ; count > 0; --count, ++buffer) {
313 de620_put_byte(dev, 0);
314 }
315 de620_send_command(dev,W_DUMMY);
316#ifdef COUNT_LOOPS
317 /* trial debug output: loops per byte in de620_ready() */
318 printk("WRITE(%d)\n", tot_cnt/((bytes?bytes:1)));
319#endif /* COUNT_LOOPS */
320#else /* not LOWSPEED */
321 for ( ; count > 0; count -=2) {
322 outb(*buffer++, DATA_PORT);
323 outb(uflip, COMMAND_PORT);
324 outb(*buffer++, DATA_PORT);
325 outb(dflip, COMMAND_PORT);
326 }
327 de620_send_command(dev,W_DUMMY);
328#endif /* LOWSPEED */
329}
330
331static inline void
332de620_read_block(struct net_device *dev, byte *data, int count)
333{
334#ifndef LOWSPEED
335 byte value;
336 byte uflip = NIC_Cmd ^ (DS0 | DS1);
337 byte dflip = NIC_Cmd;
338#else /* LOWSPEED */
339#ifdef COUNT_LOOPS
340 int bytes = count;
341
342 tot_cnt = 0;
343#endif /* COUNT_LOOPS */
344#endif /* LOWSPEED */
345
346#ifdef LOWSPEED
347 /* No further optimization useful, the limit is in the adapter. */
348 while (count-- > 0) {
349 *data++ = de620_read_byte(dev);
350 de620_flip_ds(dev);
351 }
352#ifdef COUNT_LOOPS
353 /* trial debug output: loops per byte in de620_ready() */
354 printk("READ(%d)\n", tot_cnt/(2*(bytes?bytes:1)));
355#endif /* COUNT_LOOPS */
356#else /* not LOWSPEED */
357 while (count-- > 0) {
358 value = inb(STATUS_PORT) & 0xf0; /* High nibble */
359 outb(uflip, COMMAND_PORT);
360 *data++ = value | inb(STATUS_PORT) >> 4; /* Low nibble */
361 outb(dflip , COMMAND_PORT);
362 }
363#endif /* LOWSPEED */
364}
365
366static inline void
367de620_set_delay(struct net_device *dev)
368{
369 de620_ready(dev);
370 outb(W_DFR, DATA_PORT);
371 outb(NIC_Cmd ^ CS0, COMMAND_PORT);
372
373 de620_ready(dev);
374#ifdef LOWSPEED
375 outb(WRITE_DELAY, DATA_PORT);
376#else
377 outb(0, DATA_PORT);
378#endif
379 de620_flip_ds(dev);
380
381 de620_ready(dev);
382#ifdef LOWSPEED
383 outb(READ_DELAY, DATA_PORT);
384#else
385 outb(0, DATA_PORT);
386#endif
387 de620_flip_ds(dev);
388}
389
390static inline void
391de620_set_register(struct net_device *dev, byte reg, byte value)
392{
393 de620_ready(dev);
394 outb(reg, DATA_PORT);
395 outb(NIC_Cmd ^ CS0, COMMAND_PORT);
396
397 de620_put_byte(dev, value);
398}
399
400static inline byte
401de620_get_register(struct net_device *dev, byte reg)
402{
403 byte value;
404
405 de620_send_command(dev,reg);
406 value = de620_read_byte(dev);
407 de620_send_command(dev,W_DUMMY);
408
409 return value;
410}
411
412/*********************************************************************
413 *
414 * Open/initialize the board.
415 *
416 * This routine should set everything up anew at each open, even
417 * registers that "should" only need to be set once at boot, so that
418 * there is a non-reboot way to recover if something goes wrong.
419 *
420 */
421static int de620_open(struct net_device *dev)
422{
423 int ret = request_irq(dev->irq, de620_interrupt, 0, dev->name, dev);
424 if (ret) {
425 printk (KERN_ERR "%s: unable to get IRQ %d\n", dev->name, dev->irq);
426 return ret;
427 }
428
429 if (adapter_init(dev)) {
430 ret = -EIO;
431 goto out_free_irq;
432 }
433
434 netif_start_queue(dev);
435 return 0;
436
437out_free_irq:
438 free_irq(dev->irq, dev);
439 return ret;
440}
441
442/************************************************
443 *
444 * The inverse routine to de620_open().
445 *
446 */
447
448static int de620_close(struct net_device *dev)
449{
450 netif_stop_queue(dev);
451 /* disable recv */
452 de620_set_register(dev, W_TCR, RXOFF);
453 free_irq(dev->irq, dev);
454 return 0;
455}
456
457/*********************************************
458 *
459 * Set or clear the multicast filter for this adaptor.
460 * (no real multicast implemented for the DE-620, but she can be promiscuous...)
461 *
462 */
463
464static void de620_set_multicast_list(struct net_device *dev)
465{
466 if (!netdev_mc_empty(dev) || dev->flags&(IFF_ALLMULTI|IFF_PROMISC))
467 { /* Enable promiscuous mode */
468 de620_set_register(dev, W_TCR, (TCR_DEF & ~RXPBM) | RXALL);
469 }
470 else
471 { /* Disable promiscuous mode, use normal mode */
472 de620_set_register(dev, W_TCR, TCR_DEF);
473 }
474}
475
476/*******************************************************
477 *
478 * Handle timeouts on transmit
479 */
480
481static void de620_timeout(struct net_device *dev)
482{
483 printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name, "network cable problem");
484 /* Restart the adapter. */
485 if (!adapter_init(dev)) /* maybe close it */
486 netif_wake_queue(dev);
487}
488
489/*******************************************************
490 *
491 * Copy a buffer to the adapter transmit page memory.
492 * Start sending.
493 */
494static int de620_start_xmit(struct sk_buff *skb, struct net_device *dev)
495{
496 unsigned long flags;
497 int len;
498 byte *buffer = skb->data;
499 byte using_txbuf;
500
501 using_txbuf = de620_tx_buffs(dev); /* Peek at the adapter */
502
503 netif_stop_queue(dev);
504
505
506 if ((len = skb->len) < RUNT)
507 len = RUNT;
508 if (len & 1) /* send an even number of bytes */
509 ++len;
510
511 /* Start real output */
512
513 spin_lock_irqsave(&de620_lock, flags);
514 pr_debug("de620_start_xmit: len=%d, bufs 0x%02x\n",
515 (int)skb->len, using_txbuf);
516
517 /* select a free tx buffer. if there is one... */
518 switch (using_txbuf) {
519 default: /* both are free: use TXBF0 */
520 case TXBF1: /* use TXBF0 */
521 de620_send_command(dev,W_CR | RW0);
522 using_txbuf |= TXBF0;
523 break;
524
525 case TXBF0: /* use TXBF1 */
526 de620_send_command(dev,W_CR | RW1);
527 using_txbuf |= TXBF1;
528 break;
529
530 case (TXBF0 | TXBF1): /* NONE!!! */
531 printk(KERN_WARNING "%s: No tx-buffer available!\n", dev->name);
532 spin_unlock_irqrestore(&de620_lock, flags);
533 return NETDEV_TX_BUSY;
534 }
535 de620_write_block(dev, buffer, skb->len, len-skb->len);
536
537 if(!(using_txbuf == (TXBF0 | TXBF1)))
538 netif_wake_queue(dev);
539
540 dev->stats.tx_packets++;
541 spin_unlock_irqrestore(&de620_lock, flags);
542 dev_kfree_skb (skb);
543 return NETDEV_TX_OK;
544}
545
546/*****************************************************
547 *
548 * Handle the network interface interrupts.
549 *
550 */
551static irqreturn_t
552de620_interrupt(int irq_in, void *dev_id)
553{
554 struct net_device *dev = dev_id;
555 byte irq_status;
556 int bogus_count = 0;
557 int again = 0;
558
559 spin_lock(&de620_lock);
560
561 /* Read the status register (_not_ the status port) */
562 irq_status = de620_get_register(dev, R_STS);
563
564 pr_debug("de620_interrupt (%2.2X)\n", irq_status);
565
566 if (irq_status & RXGOOD) {
567 do {
568 again = de620_rx_intr(dev);
569 pr_debug("again=%d\n", again);
570 }
571 while (again && (++bogus_count < 100));
572 }
573
574 if(de620_tx_buffs(dev) != (TXBF0 | TXBF1))
575 netif_wake_queue(dev);
576
577 spin_unlock(&de620_lock);
578 return IRQ_HANDLED;
579}
580
581/**************************************
582 *
583 * Get a packet from the adapter
584 *
585 * Send it "upstairs"
586 *
587 */
588static int de620_rx_intr(struct net_device *dev)
589{
590 struct header_buf {
591 byte status;
592 byte Rx_NextPage;
593 unsigned short Rx_ByteCount;
594 } header_buf;
595 struct sk_buff *skb;
596 int size;
597 byte *buffer;
598 byte pagelink;
599 byte curr_page;
600
601 pr_debug("de620_rx_intr: next_rx_page = %d\n", next_rx_page);
602
603 /* Tell the adapter that we are going to read data, and from where */
604 de620_send_command(dev, W_CR | RRN);
605 de620_set_register(dev, W_RSA1, next_rx_page);
606 de620_set_register(dev, W_RSA0, 0);
607
608 /* Deep breath, and away we goooooo */
609 de620_read_block(dev, (byte *)&header_buf, sizeof(struct header_buf));
610 pr_debug("page status=0x%02x, nextpage=%d, packetsize=%d\n",
611 header_buf.status, header_buf.Rx_NextPage,
612 header_buf.Rx_ByteCount);
613
614 /* Plausible page header? */
615 pagelink = header_buf.Rx_NextPage;
616 if ((pagelink < first_rx_page) || (last_rx_page < pagelink)) {
617 /* Ouch... Forget it! Skip all and start afresh... */
618 printk(KERN_WARNING "%s: Ring overrun? Restoring...\n", dev->name);
619 /* You win some, you lose some. And sometimes plenty... */
620 adapter_init(dev);
621 netif_wake_queue(dev);
622 dev->stats.rx_over_errors++;
623 return 0;
624 }
625
626 /* OK, this look good, so far. Let's see if it's consistent... */
627 /* Let's compute the start of the next packet, based on where we are */
628 pagelink = next_rx_page +
629 ((header_buf.Rx_ByteCount + (4 - 1 + 0x100)) >> 8);
630
631 /* Are we going to wrap around the page counter? */
632 if (pagelink > last_rx_page)
633 pagelink -= (last_rx_page - first_rx_page + 1);
634
635 /* Is the _computed_ next page number equal to what the adapter says? */
636 if (pagelink != header_buf.Rx_NextPage) {
637 /* Naah, we'll skip this packet. Probably bogus data as well */
638 printk(KERN_WARNING "%s: Page link out of sync! Restoring...\n", dev->name);
639 next_rx_page = header_buf.Rx_NextPage; /* at least a try... */
640 de620_send_command(dev, W_DUMMY);
641 de620_set_register(dev, W_NPRF, next_rx_page);
642 dev->stats.rx_over_errors++;
643 return 0;
644 }
645 next_rx_page = pagelink;
646
647 size = header_buf.Rx_ByteCount - 4;
648 if ((size < RUNT) || (GIANT < size)) {
649 printk(KERN_WARNING "%s: Illegal packet size: %d!\n", dev->name, size);
650 }
651 else { /* Good packet? */
652 skb = netdev_alloc_skb(dev, size + 2);
653 if (skb == NULL) { /* Yeah, but no place to put it... */
654 printk(KERN_WARNING "%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, size);
655 dev->stats.rx_dropped++;
656 }
657 else { /* Yep! Go get it! */
658 skb_reserve(skb,2); /* Align */
659 /* skb->data points to the start of sk_buff data area */
660 buffer = skb_put(skb,size);
661 /* copy the packet into the buffer */
662 de620_read_block(dev, buffer, size);
663 pr_debug("Read %d bytes\n", size);
664 skb->protocol=eth_type_trans(skb,dev);
665 netif_rx(skb); /* deliver it "upstairs" */
666 /* count all receives */
667 dev->stats.rx_packets++;
668 dev->stats.rx_bytes += size;
669 }
670 }
671
672 /* Let's peek ahead to see if we have read the last current packet */
673 /* NOTE! We're _not_ checking the 'EMPTY'-flag! This seems better... */
674 curr_page = de620_get_register(dev, R_CPR);
675 de620_set_register(dev, W_NPRF, next_rx_page);
676 pr_debug("next_rx_page=%d CPR=%d\n", next_rx_page, curr_page);
677
678 return next_rx_page != curr_page; /* That was slightly tricky... */
679}
680
681/*********************************************
682 *
683 * Reset the adapter to a known state
684 *
685 */
686static int adapter_init(struct net_device *dev)
687{
688 int i;
689 static int was_down;
690
691 if ((nic_data.Model == 3) || (nic_data.Model == 0)) { /* CT */
692 EIPRegister = NCTL0;
693 if (nic_data.Media != 1)
694 EIPRegister |= NIS0; /* not BNC */
695 }
696 else if (nic_data.Model == 2) { /* UTP */
697 EIPRegister = NCTL0 | NIS0;
698 }
699
700 if (utp)
701 EIPRegister = NCTL0 | NIS0;
702 if (bnc)
703 EIPRegister = NCTL0;
704
705 de620_send_command(dev, W_CR | RNOP | CLEAR);
706 de620_send_command(dev, W_CR | RNOP);
707
708 de620_set_register(dev, W_SCR, SCR_DEF);
709 /* disable recv to wait init */
710 de620_set_register(dev, W_TCR, RXOFF);
711
712 /* Set the node ID in the adapter */
713 for (i = 0; i < 6; ++i) { /* W_PARn = 0xaa + n */
714 de620_set_register(dev, W_PAR0 + i, dev->dev_addr[i]);
715 }
716
717 de620_set_register(dev, W_EIP, EIPRegister);
718
719 next_rx_page = first_rx_page = DE620_RX_START_PAGE;
720 if (nic_data.RAM_Size)
721 last_rx_page = nic_data.RAM_Size - 1;
722 else /* 64k RAM */
723 last_rx_page = 255;
724
725 de620_set_register(dev, W_SPR, first_rx_page); /* Start Page Register*/
726 de620_set_register(dev, W_EPR, last_rx_page); /* End Page Register */
727 de620_set_register(dev, W_CPR, first_rx_page);/*Current Page Register*/
728 de620_send_command(dev, W_NPR | first_rx_page); /* Next Page Register*/
729 de620_send_command(dev, W_DUMMY);
730 de620_set_delay(dev);
731
732 /* Final sanity check: Anybody out there? */
733 /* Let's hope some bits from the statusregister make a good check */
734#define CHECK_MASK ( 0 | TXSUC | T16 | 0 | RXCRC | RXSHORT | 0 | 0 )
735#define CHECK_OK ( 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 )
736 /* success: X 0 0 X 0 0 X X */
737 /* ignore: EEDI RXGOOD COLS LNKS*/
738
739 if (((i = de620_get_register(dev, R_STS)) & CHECK_MASK) != CHECK_OK) {
740 printk(KERN_ERR "%s: Something has happened to the DE-620! Please check it"
741#ifdef SHUTDOWN_WHEN_LOST
742 " and do a new ifconfig"
743#endif
744 "! (%02x)\n", dev->name, i);
745#ifdef SHUTDOWN_WHEN_LOST
746 /* Goodbye, cruel world... */
747 dev->flags &= ~IFF_UP;
748 de620_close(dev);
749#endif
750 was_down = 1;
751 return 1; /* failed */
752 }
753 if (was_down) {
754 printk(KERN_WARNING "%s: Thanks, I feel much better now!\n", dev->name);
755 was_down = 0;
756 }
757
758 /* All OK, go ahead... */
759 de620_set_register(dev, W_TCR, TCR_DEF);
760
761 return 0; /* all ok */
762}
763
764static const struct net_device_ops de620_netdev_ops = {
765 .ndo_open = de620_open,
766 .ndo_stop = de620_close,
767 .ndo_start_xmit = de620_start_xmit,
768 .ndo_tx_timeout = de620_timeout,
769 .ndo_set_rx_mode = de620_set_multicast_list,
770 .ndo_change_mtu = eth_change_mtu,
771 .ndo_set_mac_address = eth_mac_addr,
772 .ndo_validate_addr = eth_validate_addr,
773};
774
775/******************************************************************************
776 *
777 * Only start-up code below
778 *
779 */
780/****************************************
781 *
782 * Check if there is a DE-620 connected
783 */
784struct net_device * __init de620_probe(int unit)
785{
786 byte checkbyte = 0xa5;
787 struct net_device *dev;
788 int err = -ENOMEM;
789 int i;
790
791 dev = alloc_etherdev(0);
792 if (!dev)
793 goto out;
794
795 spin_lock_init(&de620_lock);
796
797 /*
798 * This is where the base_addr and irq gets set.
799 * Tunable at compile-time and insmod-time
800 */
801 dev->base_addr = io;
802 dev->irq = irq;
803
804 /* allow overriding parameters on command line */
805 if (unit >= 0) {
806 sprintf(dev->name, "eth%d", unit);
807 netdev_boot_setup_check(dev);
808 }
809
810 pr_debug("%s", version);
811
812 printk(KERN_INFO "D-Link DE-620 pocket adapter");
813
814 if (!request_region(dev->base_addr, 3, "de620")) {
815 printk(" io 0x%3lX, which is busy.\n", dev->base_addr);
816 err = -EBUSY;
817 goto out1;
818 }
819
820 /* Initially, configure basic nibble mode, so we can read the EEPROM */
821 NIC_Cmd = DEF_NIC_CMD;
822 de620_set_register(dev, W_EIP, EIPRegister);
823
824 /* Anybody out there? */
825 de620_set_register(dev, W_CPR, checkbyte);
826 checkbyte = de620_get_register(dev, R_CPR);
827
828 if ((checkbyte != 0xa5) || (read_eeprom(dev) != 0)) {
829 printk(" not identified in the printer port\n");
830 err = -ENODEV;
831 goto out2;
832 }
833
834 /* else, got it! */
835 dev->dev_addr[0] = nic_data.NodeID[0];
836 for (i = 1; i < ETH_ALEN; i++) {
837 dev->dev_addr[i] = nic_data.NodeID[i];
838 dev->broadcast[i] = 0xff;
839 }
840
841 printk(", Ethernet Address: %pM", dev->dev_addr);
842
843 printk(" (%dk RAM,",
844 (nic_data.RAM_Size) ? (nic_data.RAM_Size >> 2) : 64);
845
846 if (nic_data.Media == 1)
847 printk(" BNC)\n");
848 else
849 printk(" UTP)\n");
850
851 dev->netdev_ops = &de620_netdev_ops;
852 dev->watchdog_timeo = HZ*2;
853
854 /* base_addr and irq are already set, see above! */
855
856 /* dump eeprom */
857 pr_debug("\nEEPROM contents:\n"
858 "RAM_Size = 0x%02X\n"
859 "NodeID = %pM\n"
860 "Model = %d\n"
861 "Media = %d\n"
862 "SCR = 0x%02x\n", nic_data.RAM_Size, nic_data.NodeID,
863 nic_data.Model, nic_data.Media, nic_data.SCR);
864
865 err = register_netdev(dev);
866 if (err)
867 goto out2;
868 return dev;
869
870out2:
871 release_region(dev->base_addr, 3);
872out1:
873 free_netdev(dev);
874out:
875 return ERR_PTR(err);
876}
877
878/**********************************
879 *
880 * Read info from on-board EEPROM
881 *
882 * Note: Bitwise serial I/O to/from the EEPROM vi the status _register_!
883 */
884#define sendit(dev,data) de620_set_register(dev, W_EIP, data | EIPRegister);
885
886static unsigned short __init ReadAWord(struct net_device *dev, int from)
887{
888 unsigned short data;
889 int nbits;
890
891 /* cs [__~~] SET SEND STATE */
892 /* di [____] */
893 /* sck [_~~_] */
894 sendit(dev, 0); sendit(dev, 1); sendit(dev, 5); sendit(dev, 4);
895
896 /* Send the 9-bit address from where we want to read the 16-bit word */
897 for (nbits = 9; nbits > 0; --nbits, from <<= 1) {
898 if (from & 0x0100) { /* bit set? */
899 /* cs [~~~~] SEND 1 */
900 /* di [~~~~] */
901 /* sck [_~~_] */
902 sendit(dev, 6); sendit(dev, 7); sendit(dev, 7); sendit(dev, 6);
903 }
904 else {
905 /* cs [~~~~] SEND 0 */
906 /* di [____] */
907 /* sck [_~~_] */
908 sendit(dev, 4); sendit(dev, 5); sendit(dev, 5); sendit(dev, 4);
909 }
910 }
911
912 /* Shift in the 16-bit word. The bits appear serially in EEDI (=0x80) */
913 for (data = 0, nbits = 16; nbits > 0; --nbits) {
914 /* cs [~~~~] SEND 0 */
915 /* di [____] */
916 /* sck [_~~_] */
917 sendit(dev, 4); sendit(dev, 5); sendit(dev, 5); sendit(dev, 4);
918 data = (data << 1) | ((de620_get_register(dev, R_STS) & EEDI) >> 7);
919 }
920 /* cs [____] RESET SEND STATE */
921 /* di [____] */
922 /* sck [_~~_] */
923 sendit(dev, 0); sendit(dev, 1); sendit(dev, 1); sendit(dev, 0);
924
925 return data;
926}
927
928static int __init read_eeprom(struct net_device *dev)
929{
930 unsigned short wrd;
931
932 /* D-Link Ethernet addresses are in the series 00:80:c8:7X:XX:XX:XX */
933 wrd = ReadAWord(dev, 0x1aa); /* bytes 0 + 1 of NodeID */
934 if (!clone && (wrd != htons(0x0080))) /* Valid D-Link ether sequence? */
935 return -1; /* Nope, not a DE-620 */
936 nic_data.NodeID[0] = wrd & 0xff;
937 nic_data.NodeID[1] = wrd >> 8;
938
939 wrd = ReadAWord(dev, 0x1ab); /* bytes 2 + 3 of NodeID */
940 if (!clone && ((wrd & 0xff) != 0xc8)) /* Valid D-Link ether sequence? */
941 return -1; /* Nope, not a DE-620 */
942 nic_data.NodeID[2] = wrd & 0xff;
943 nic_data.NodeID[3] = wrd >> 8;
944
945 wrd = ReadAWord(dev, 0x1ac); /* bytes 4 + 5 of NodeID */
946 nic_data.NodeID[4] = wrd & 0xff;
947 nic_data.NodeID[5] = wrd >> 8;
948
949 wrd = ReadAWord(dev, 0x1ad); /* RAM size in pages (256 bytes). 0 = 64k */
950 nic_data.RAM_Size = (wrd >> 8);
951
952 wrd = ReadAWord(dev, 0x1ae); /* hardware model (CT = 3) */
953 nic_data.Model = (wrd & 0xff);
954
955 wrd = ReadAWord(dev, 0x1af); /* media (indicates BNC/UTP) */
956 nic_data.Media = (wrd & 0xff);
957
958 wrd = ReadAWord(dev, 0x1a8); /* System Configuration Register */
959 nic_data.SCR = (wrd >> 8);
960
961 return 0; /* no errors */
962}
963
964/******************************************************************************
965 *
966 * Loadable module skeleton
967 *
968 */
969#ifdef MODULE
970static struct net_device *de620_dev;
971
972int __init init_module(void)
973{
974 de620_dev = de620_probe(-1);
975 if (IS_ERR(de620_dev))
976 return PTR_ERR(de620_dev);
977 return 0;
978}
979
980void cleanup_module(void)
981{
982 unregister_netdev(de620_dev);
983 release_region(de620_dev->base_addr, 3);
984 free_netdev(de620_dev);
985}
986#endif /* MODULE */
987MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/dlink/de620.h b/drivers/net/ethernet/dlink/de620.h
deleted file mode 100644
index e8d9a88f4cb5..000000000000
--- a/drivers/net/ethernet/dlink/de620.h
+++ /dev/null
@@ -1,117 +0,0 @@
1/*********************************************************
2 * *
3 * Definition of D-Link DE-620 Ethernet Pocket adapter *
4 * *
5 *********************************************************/
6
7/* DE-620's CMD port Command */
8#define CS0 0x08 /* 1->0 command strobe */
9#define ICEN 0x04 /* 0=enable DL3520 host interface */
10#define DS0 0x02 /* 1->0 data strobe 0 */
11#define DS1 0x01 /* 1->0 data strobe 1 */
12
13#define WDIR 0x20 /* general 0=read 1=write */
14#define RDIR 0x00 /* (not 100% confirm ) */
15#define PS2WDIR 0x00 /* ps/2 mode 1=read, 0=write */
16#define PS2RDIR 0x20
17
18#define IRQEN 0x10 /* 1 = enable printer IRQ line */
19#define SELECTIN 0x08 /* 1 = select printer */
20#define INITP 0x04 /* 0 = initial printer */
21#define AUTOFEED 0x02 /* 1 = printer auto form feed */
22#define STROBE 0x01 /* 0->1 data strobe */
23
24#define RESET 0x08
25#define NIS0 0x20 /* 0 = BNC, 1 = UTP */
26#define NCTL0 0x10
27
28/* DE-620 DIC Command */
29#define W_DUMMY 0x00 /* DIC reserved command */
30#define W_CR 0x20 /* DIC write command register */
31#define W_NPR 0x40 /* DIC write Next Page Register */
32#define W_TBR 0x60 /* DIC write Tx Byte Count 1 reg */
33#define W_RSA 0x80 /* DIC write Remote Start Addr 1 */
34
35/* DE-620's STAT port bits 7-4 */
36#define EMPTY 0x80 /* 1 = receive buffer empty */
37#define INTLEVEL 0x40 /* 1 = interrupt level is high */
38#define TXBF1 0x20 /* 1 = transmit buffer 1 is in use */
39#define TXBF0 0x10 /* 1 = transmit buffer 0 is in use */
40#define READY 0x08 /* 1 = h/w ready to accept cmd/data */
41
42/* IDC 1 Command */
43#define W_RSA1 0xa0 /* write remote start address 1 */
44#define W_RSA0 0xa1 /* write remote start address 0 */
45#define W_NPRF 0xa2 /* write next page register NPR15-NPR8 */
46#define W_DFR 0xa3 /* write delay factor register */
47#define W_CPR 0xa4 /* write current page register */
48#define W_SPR 0xa5 /* write start page register */
49#define W_EPR 0xa6 /* write end page register */
50#define W_SCR 0xa7 /* write system configuration register */
51#define W_TCR 0xa8 /* write Transceiver Configuration reg */
52#define W_EIP 0xa9 /* write EEPM Interface port */
53#define W_PAR0 0xaa /* write physical address register 0 */
54#define W_PAR1 0xab /* write physical address register 1 */
55#define W_PAR2 0xac /* write physical address register 2 */
56#define W_PAR3 0xad /* write physical address register 3 */
57#define W_PAR4 0xae /* write physical address register 4 */
58#define W_PAR5 0xaf /* write physical address register 5 */
59
60/* IDC 2 Command */
61#define R_STS 0xc0 /* read status register */
62#define R_CPR 0xc1 /* read current page register */
63#define R_BPR 0xc2 /* read boundary page register */
64#define R_TDR 0xc3 /* read time domain reflectometry reg */
65
66/* STATUS Register */
67#define EEDI 0x80 /* EEPM DO pin */
68#define TXSUC 0x40 /* tx success */
69#define T16 0x20 /* tx fail 16 times */
70#define TS1 0x40 /* 0=Tx success, 1=T16 */
71#define TS0 0x20 /* 0=Tx success, 1=T16 */
72#define RXGOOD 0x10 /* rx a good packet */
73#define RXCRC 0x08 /* rx a CRC error packet */
74#define RXSHORT 0x04 /* rx a short packet */
75#define COLS 0x02 /* coaxial collision status */
76#define LNKS 0x01 /* UTP link status */
77
78/* Command Register */
79#define CLEAR 0x10 /* reset part of hardware */
80#define NOPER 0x08 /* No Operation */
81#define RNOP 0x08
82#define RRA 0x06 /* After RR then auto-advance NPR & BPR(=NPR-1) */
83#define RRN 0x04 /* Normal Remote Read mode */
84#define RW1 0x02 /* Remote Write tx buffer 1 ( page 6 - 11 ) */
85#define RW0 0x00 /* Remote Write tx buffer 0 ( page 0 - 5 ) */
86#define TXEN 0x01 /* 0->1 tx enable */
87
88/* System Configuration Register */
89#define TESTON 0x80 /* test host data transfer reliability */
90#define SLEEP 0x40 /* sleep mode */
91#if 0
92#define FASTMODE 0x04 /* fast mode for intel 82360SL fast mode */
93#define BYTEMODE 0x02 /* byte mode */
94#else
95#define FASTMODE 0x20 /* fast mode for intel 82360SL fast mode */
96#define BYTEMODE 0x10 /* byte mode */
97#endif
98#define NIBBLEMODE 0x00 /* nibble mode */
99#define IRQINV 0x08 /* turn off IRQ line inverter */
100#define IRQNML 0x00 /* turn on IRQ line inverter */
101#define INTON 0x04
102#define AUTOFFSET 0x02 /* auto shift address to TPR+12 */
103#define AUTOTX 0x01 /* auto tx when leave RW mode */
104
105/* Transceiver Configuration Register */
106#define JABBER 0x80 /* generate jabber condition */
107#define TXSUCINT 0x40 /* enable tx success interrupt */
108#define T16INT 0x20 /* enable T16 interrupt */
109#define RXERRPKT 0x10 /* accept CRC error or short packet */
110#define EXTERNALB2 0x0C /* external loopback 2 */
111#define EXTERNALB1 0x08 /* external loopback 1 */
112#define INTERNALB 0x04 /* internal loopback */
113#define NMLOPERATE 0x00 /* normal operation */
114#define RXPBM 0x03 /* rx physical, broadcast, multicast */
115#define RXPB 0x02 /* rx physical, broadcast */
116#define RXALL 0x01 /* rx all packet */
117#define RXOFF 0x00 /* rx disable */