1 |
199 |
simons |
/* ne.c: A general non-shared-memory NS8390 ethernet driver for linux. */
|
2 |
|
|
/*
|
3 |
|
|
Written 1992-94 by Donald Becker.
|
4 |
|
|
|
5 |
|
|
Copyright 1993 United States Government as represented by the
|
6 |
|
|
Director, National Security Agency.
|
7 |
|
|
|
8 |
|
|
This software may be used and distributed according to the terms
|
9 |
|
|
of the GNU Public License, incorporated herein by reference.
|
10 |
|
|
|
11 |
|
|
The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O
|
12 |
|
|
Center of Excellence in Space Data and Information Sciences
|
13 |
|
|
Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771
|
14 |
|
|
|
15 |
|
|
This driver should work with many programmed-I/O 8390-based ethernet
|
16 |
|
|
boards. Currently it supports the NE1000, NE2000, many clones,
|
17 |
|
|
and some Cabletron products.
|
18 |
|
|
|
19 |
|
|
Changelog:
|
20 |
|
|
|
21 |
|
|
Paul Gortmaker : use ENISR_RDC to monitor Tx PIO uploads, made
|
22 |
|
|
sanity checks and bad clone support optional.
|
23 |
|
|
Paul Gortmaker : new reset code, reset card after probe at boot.
|
24 |
|
|
Paul Gortmaker : multiple card support for module users.
|
25 |
|
|
Paul Gortmaker : Support for PCI ne2k clones, similar to lance.c
|
26 |
|
|
Paul Gortmaker : Allow users with bad cards to avoid full probe.
|
27 |
|
|
Paul Gortmaker : PCI probe changes, more PCI cards supported.
|
28 |
|
|
|
29 |
|
|
Greg Ungerer : added some coldfire addressing code.
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
/* Routines for the NatSemi-based designs (NE[12]000). */
|
33 |
|
|
|
34 |
|
|
static const char *version =
|
35 |
|
|
"ne.c:v1.10 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
#include <linux/module.h>
|
39 |
|
|
#include <linux/config.h>
|
40 |
|
|
#include <linux/kernel.h>
|
41 |
|
|
#include <linux/sched.h>
|
42 |
|
|
#include <linux/errno.h>
|
43 |
|
|
#ifdef CONFIG_PCI
|
44 |
|
|
#include <linux/pci.h>
|
45 |
|
|
#include <linux/bios32.h>
|
46 |
|
|
#endif
|
47 |
|
|
#include <asm/system.h>
|
48 |
|
|
#include <asm/io.h>
|
49 |
|
|
#include <linux/delay.h>
|
50 |
|
|
|
51 |
|
|
#include <linux/netdevice.h>
|
52 |
|
|
#include <linux/etherdevice.h>
|
53 |
|
|
#include "8390.h"
|
54 |
|
|
|
55 |
|
|
#ifdef CONFIG_COLDFIRE
|
56 |
|
|
#define COLDFIRE_NE2000_FUNCS
|
57 |
|
|
#include <asm/coldfire.h>
|
58 |
|
|
#include <asm/mcfsim.h>
|
59 |
|
|
#include <asm/mcfne.h>
|
60 |
|
|
unsigned char ne_defethaddr[] = { 0x00, 0xd0, 0xcf, 0x00, 0x00, 0x01 };
|
61 |
|
|
#endif /* CONFIG_COLDFIRE */
|
62 |
|
|
|
63 |
|
|
/* Some defines that people can play with if so inclined. */
|
64 |
|
|
|
65 |
|
|
/* Do we support clones that don't adhere to 14,15 of the SAprom ? */
|
66 |
|
|
#define SUPPORT_NE_BAD_CLONES
|
67 |
|
|
|
68 |
|
|
/* Do we perform extra sanity checks on stuff ? */
|
69 |
|
|
/* #define NE_SANITY_CHECK */
|
70 |
|
|
|
71 |
|
|
/* Do we implement the read before write bugfix ? */
|
72 |
|
|
/* #define NE_RW_BUGFIX */
|
73 |
|
|
|
74 |
|
|
/* Do we have a non std. amount of memory? (in units of 256 byte pages) */
|
75 |
|
|
/* #define PACKETBUF_MEMSIZE 0x40 */
|
76 |
|
|
|
77 |
|
|
#if defined(HAVE_DEVLIST) || !defined(MODULE)
|
78 |
|
|
/* A zero-terminated list of I/O addresses to be probed. */
|
79 |
|
|
static unsigned int netcard_portlist[] =
|
80 |
|
|
{ 0x300, 0x280, 0x320, 0x340, 0x360, 0};
|
81 |
|
|
#endif /* defined(HAVE_DEVLIST) || !defined(MODULE) */
|
82 |
|
|
|
83 |
|
|
#ifdef CONFIG_PCI
|
84 |
|
|
/* Ack! People are making PCI ne2000 clones! Oh the horror, the horror... */
|
85 |
|
|
static struct { unsigned short vendor, dev_id;}
|
86 |
|
|
pci_clone_list[] = {
|
87 |
|
|
{PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8029},
|
88 |
|
|
{PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C940},
|
89 |
|
|
{PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_RL2000},
|
90 |
|
|
{PCI_VENDOR_ID_KTI, PCI_DEVICE_ID_KTI_ET32P2},
|
91 |
|
|
{PCI_VENDOR_ID_NETVIN, PCI_DEVICE_ID_NETVIN_NV5000SC},
|
92 |
|
|
{PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C926},
|
93 |
|
|
{0,}
|
94 |
|
|
};
|
95 |
|
|
#endif
|
96 |
|
|
|
97 |
|
|
#ifdef SUPPORT_NE_BAD_CLONES
|
98 |
|
|
/* A list of bad clones that we none-the-less recognize. */
|
99 |
|
|
static struct { const char *name8, *name16; unsigned char SAprefix[4];}
|
100 |
|
|
bad_clone_list[] = {
|
101 |
|
|
{"DE100", "DE200", {0x00, 0xDE, 0x01,}},
|
102 |
|
|
{"DE120", "DE220", {0x00, 0x80, 0xc8,}},
|
103 |
|
|
{"DFI1000", "DFI2000", {'D', 'F', 'I',}}, /* Original, eh? */
|
104 |
|
|
{"EtherNext UTP8", "EtherNext UTP16", {0x00, 0x00, 0x79}},
|
105 |
|
|
{"NE1000","NE2000-invalid", {0x00, 0x00, 0xd8}}, /* Ancient real NE1000. */
|
106 |
|
|
{"NN1000", "NN2000", {0x08, 0x03, 0x08}}, /* Outlaw no-name clone. */
|
107 |
|
|
{"4-DIM8","4-DIM16", {0x00,0x00,0x4d,}}, /* Outlaw 4-Dimension cards. */
|
108 |
|
|
{"Con-Intl_8", "Con-Intl_16", {0x00, 0x00, 0x24}}, /* Connect Int'nl */
|
109 |
|
|
{"ET-100","ET-200", {0x00, 0x45, 0x54}}, /* YANG and YA clone */
|
110 |
|
|
{"COMPEX","COMPEX16",{0x00,0x80,0x48}}, /* Broken ISA Compex cards */
|
111 |
|
|
{"E-LAN100", "E-LAN200", {0x00, 0x00, 0x5d}}, /* Broken ne1000 clones */
|
112 |
|
|
{"PCM-4823", "PCM-4823", {0x00, 0xc0, 0x6c}}, /* Broken Advantech MoBo */
|
113 |
|
|
{0,}
|
114 |
|
|
};
|
115 |
|
|
#endif
|
116 |
|
|
|
117 |
|
|
/* ---- No user-serviceable parts below ---- */
|
118 |
|
|
|
119 |
|
|
#define NE_BASE (dev->base_addr)
|
120 |
|
|
#define NE_CMD 0x00
|
121 |
|
|
#define NE_DATAPORT 0x10 /* NatSemi-defined port window offset. */
|
122 |
|
|
#define NE_RESET 0x1f /* Issue a read to reset, a write to clear. */
|
123 |
|
|
#define NE_IO_EXTENT 0x20
|
124 |
|
|
|
125 |
|
|
#define NE1SM_START_PG 0x20 /* First page of TX buffer */
|
126 |
|
|
#define NE1SM_STOP_PG 0x40 /* Last page +1 of RX ring */
|
127 |
|
|
#define NESM_START_PG 0x40 /* First page of TX buffer */
|
128 |
|
|
#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */
|
129 |
|
|
|
130 |
|
|
/* Non-zero only if the current card is a PCI with BIOS-set IRQ. */
|
131 |
|
|
static unsigned char pci_irq_line = 0;
|
132 |
|
|
|
133 |
|
|
int ne_probe(struct device *dev);
|
134 |
|
|
#ifdef CONFIG_PCI
|
135 |
|
|
static int ne_probe_pci(struct device *dev);
|
136 |
|
|
#endif
|
137 |
|
|
static int ne_probe1(struct device *dev, int ioaddr);
|
138 |
|
|
|
139 |
|
|
static int ne_open(struct device *dev);
|
140 |
|
|
static int ne_close(struct device *dev);
|
141 |
|
|
|
142 |
|
|
static void ne_reset_8390(struct device *dev);
|
143 |
|
|
static void ne_get_8390_hdr(struct device *dev, struct e8390_pkt_hdr *hdr,
|
144 |
|
|
int ring_page);
|
145 |
|
|
static void ne_block_input(struct device *dev, int count,
|
146 |
|
|
struct sk_buff *skb, int ring_offset);
|
147 |
|
|
static void ne_block_output(struct device *dev, const int count,
|
148 |
|
|
const unsigned char *buf, const int start_page);
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
/* Probe for various non-shared-memory ethercards.
|
152 |
|
|
|
153 |
|
|
NEx000-clone boards have a Station Address PROM (SAPROM) in the packet
|
154 |
|
|
buffer memory space. NE2000 clones have 0x57,0x57 in bytes 0x0e,0x0f of
|
155 |
|
|
the SAPROM, while other supposed NE2000 clones must be detected by their
|
156 |
|
|
SA prefix.
|
157 |
|
|
|
158 |
|
|
Reading the SAPROM from a word-wide card with the 8390 set in byte-wide
|
159 |
|
|
mode results in doubled values, which can be detected and compensated for.
|
160 |
|
|
|
161 |
|
|
The probe is also responsible for initializing the card and filling
|
162 |
|
|
in the 'dev' and 'ei_status' structures.
|
163 |
|
|
|
164 |
|
|
We use the minimum memory size for some ethercard product lines, iff we can't
|
165 |
|
|
distinguish models. You can increase the packet buffer size by setting
|
166 |
|
|
PACKETBUF_MEMSIZE. Reported Cabletron packet buffer locations are:
|
167 |
|
|
E1010 starts at 0x100 and ends at 0x2000.
|
168 |
|
|
E1010-x starts at 0x100 and ends at 0x8000. ("-x" means "more memory")
|
169 |
|
|
E2010 starts at 0x100 and ends at 0x4000.
|
170 |
|
|
E2010-x starts at 0x100 and ends at 0xffff. */
|
171 |
|
|
|
172 |
|
|
#ifdef HAVE_DEVLIST
|
173 |
|
|
struct netdev_entry netcard_drv =
|
174 |
|
|
{"ne", ne_probe1, NE_IO_EXTENT, netcard_portlist};
|
175 |
|
|
#else
|
176 |
|
|
|
177 |
|
|
/* Note that this probe only picks up one card at a time, even for multiple
|
178 |
|
|
PCI ne2k cards. Use "ether=0,0,eth1" if you have a second PCI ne2k card.
|
179 |
|
|
This keeps things consistent regardless of the bus type of the card. */
|
180 |
|
|
|
181 |
|
|
int ne_probe(struct device *dev)
|
182 |
|
|
{
|
183 |
|
|
#ifndef MODULE
|
184 |
|
|
int i;
|
185 |
|
|
#endif /* MODULE */
|
186 |
|
|
int base_addr = dev ? dev->base_addr : 0;
|
187 |
|
|
|
188 |
|
|
#ifdef CONFIG_COLDFIRE
|
189 |
|
|
#ifdef CONFIG_NETtel
|
190 |
|
|
dev->base_addr = base_addr = NE2000_ADDR + NE2000_ISA_IO;
|
191 |
|
|
#else
|
192 |
|
|
dev->base_addr = base_addr = NE2000_ISA_IO;
|
193 |
|
|
#endif
|
194 |
|
|
dev->irq = NE2000_ISA_IRQ;
|
195 |
|
|
#if 1
|
196 |
|
|
printk("%s(%d): IO=%x irq=%d\n", __FILE__, __LINE__, dev->base_addr, dev->irq);
|
197 |
|
|
#endif
|
198 |
|
|
#endif
|
199 |
|
|
|
200 |
|
|
/* First check any supplied i/o locations. User knows best. <cough> */
|
201 |
|
|
if (base_addr > 0x1ff) /* Check a single specified location. */
|
202 |
|
|
return ne_probe1(dev, base_addr);
|
203 |
|
|
else if (base_addr != 0) /* Don't probe at all. */
|
204 |
|
|
return ENXIO;
|
205 |
|
|
|
206 |
|
|
#ifdef CONFIG_PCI
|
207 |
|
|
/* Then look for any installed PCI clones */
|
208 |
|
|
if (pcibios_present() && (ne_probe_pci(dev) == 0))
|
209 |
|
|
return 0;
|
210 |
|
|
#endif
|
211 |
|
|
|
212 |
|
|
#ifndef MODULE
|
213 |
|
|
/* Last resort. The semi-risky ISA auto-probe. */
|
214 |
|
|
for (i = 0; netcard_portlist[i]; i++) {
|
215 |
|
|
int ioaddr = netcard_portlist[i];
|
216 |
|
|
if (check_region(ioaddr, NE_IO_EXTENT))
|
217 |
|
|
continue;
|
218 |
|
|
if (ne_probe1(dev, ioaddr) == 0)
|
219 |
|
|
return 0;
|
220 |
|
|
}
|
221 |
|
|
#endif
|
222 |
|
|
|
223 |
|
|
return ENODEV;
|
224 |
|
|
}
|
225 |
|
|
#endif
|
226 |
|
|
|
227 |
|
|
#ifdef CONFIG_PCI
|
228 |
|
|
static int ne_probe_pci(struct device *dev)
|
229 |
|
|
{
|
230 |
|
|
int i;
|
231 |
|
|
|
232 |
|
|
for (i = 0; pci_clone_list[i].vendor != 0; i++) {
|
233 |
|
|
unsigned char pci_bus, pci_device_fn;
|
234 |
|
|
unsigned int pci_ioaddr;
|
235 |
|
|
u16 pci_command, new_command;
|
236 |
|
|
int pci_index;
|
237 |
|
|
|
238 |
|
|
for (pci_index = 0; pci_index < 8; pci_index++) {
|
239 |
|
|
if (pcibios_find_device (pci_clone_list[i].vendor,
|
240 |
|
|
pci_clone_list[i].dev_id, pci_index,
|
241 |
|
|
&pci_bus, &pci_device_fn) != 0)
|
242 |
|
|
break; /* No more of these type of cards */
|
243 |
|
|
pcibios_read_config_dword(pci_bus, pci_device_fn,
|
244 |
|
|
PCI_BASE_ADDRESS_0, &pci_ioaddr);
|
245 |
|
|
/* Strip the I/O address out of the returned value */
|
246 |
|
|
pci_ioaddr &= PCI_BASE_ADDRESS_IO_MASK;
|
247 |
|
|
/* Avoid already found cards from previous calls */
|
248 |
|
|
if (check_region(pci_ioaddr, NE_IO_EXTENT))
|
249 |
|
|
continue;
|
250 |
|
|
pcibios_read_config_byte(pci_bus, pci_device_fn,
|
251 |
|
|
PCI_INTERRUPT_LINE, &pci_irq_line);
|
252 |
|
|
break; /* Beauty -- got a valid card. */
|
253 |
|
|
}
|
254 |
|
|
if (pci_irq_line == 0) continue; /* Try next PCI ID */
|
255 |
|
|
printk("ne.c: PCI BIOS reports NE 2000 clone at i/o %#x, irq %d.\n",
|
256 |
|
|
pci_ioaddr, pci_irq_line);
|
257 |
|
|
|
258 |
|
|
pcibios_read_config_word(pci_bus, pci_device_fn,
|
259 |
|
|
PCI_COMMAND, &pci_command);
|
260 |
|
|
|
261 |
|
|
/* Activate the card: fix for brain-damaged Win98 BIOSes. */
|
262 |
|
|
new_command = pci_command | PCI_COMMAND_IO;
|
263 |
|
|
if (pci_command != new_command) {
|
264 |
|
|
printk(KERN_INFO " The PCI BIOS has not enabled this"
|
265 |
|
|
" NE2k clone! Updating PCI command %4.4x->%4.4x.\n",
|
266 |
|
|
pci_command, new_command);
|
267 |
|
|
pcibios_write_config_word(pci_bus, pci_device_fn,
|
268 |
|
|
PCI_COMMAND, new_command);
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
if (ne_probe1(dev, pci_ioaddr) != 0) { /* Shouldn't happen. */
|
272 |
|
|
printk(KERN_ERR "ne.c: Probe of PCI card at %#x failed.\n", pci_ioaddr);
|
273 |
|
|
pci_irq_line = 0;
|
274 |
|
|
return -ENXIO;
|
275 |
|
|
}
|
276 |
|
|
pci_irq_line = 0;
|
277 |
|
|
return 0;
|
278 |
|
|
}
|
279 |
|
|
return -ENODEV;
|
280 |
|
|
}
|
281 |
|
|
#endif /* CONFIG_PCI */
|
282 |
|
|
|
283 |
|
|
static int ne_probe1(struct device *dev, int ioaddr)
|
284 |
|
|
{
|
285 |
|
|
int i;
|
286 |
|
|
unsigned char SA_prom[32];
|
287 |
|
|
int wordlength = 2;
|
288 |
|
|
const char *name = NULL;
|
289 |
|
|
int start_page, stop_page;
|
290 |
|
|
int neX000, ctron, bad_card;
|
291 |
|
|
int reg0 = inb_p(ioaddr);
|
292 |
|
|
static unsigned version_printed = 0;
|
293 |
|
|
|
294 |
|
|
#if 1
|
295 |
|
|
printk("%s(%d): ne_probe1() ioaddr=%x\n", __FILE__, __LINE__, ioaddr);
|
296 |
|
|
#endif
|
297 |
|
|
if (reg0 == 0xFF)
|
298 |
|
|
return ENODEV;
|
299 |
|
|
|
300 |
|
|
/* Do a preliminary verification that we have a 8390. */
|
301 |
|
|
{ int regd;
|
302 |
|
|
outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD);
|
303 |
|
|
regd = inb_p(ioaddr + 0x0d);
|
304 |
|
|
outb_p(0xff, ioaddr + 0x0d);
|
305 |
|
|
outb_p(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD);
|
306 |
|
|
inb_p(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */
|
307 |
|
|
if (inb_p(ioaddr + EN0_COUNTER0) != 0) {
|
308 |
|
|
outb_p(reg0, ioaddr);
|
309 |
|
|
outb_p(regd, ioaddr + 0x0d); /* Restore the old values. */
|
310 |
|
|
return ENODEV;
|
311 |
|
|
}
|
312 |
|
|
}
|
313 |
|
|
|
314 |
|
|
/* We should have a "dev" from Space.c or the static module table. */
|
315 |
|
|
if (dev == NULL) {
|
316 |
|
|
printk(KERN_ERR "ne.c: Passed a NULL device.\n");
|
317 |
|
|
dev = init_etherdev(0, 0);
|
318 |
|
|
}
|
319 |
|
|
|
320 |
|
|
if (ei_debug && version_printed++ == 0)
|
321 |
|
|
printk(version);
|
322 |
|
|
|
323 |
|
|
printk("NE*000 ethercard probe at %#3x:", ioaddr);
|
324 |
|
|
|
325 |
|
|
/* A user with a poor card that fails to ack the reset, or that
|
326 |
|
|
does not have a valid 0x57,0x57 signature can still use this
|
327 |
|
|
without having to recompile. Specifying an i/o address along
|
328 |
|
|
with an otherwise unused dev->mem_end value of "0xBAD" will
|
329 |
|
|
cause the driver to skip these parts of the probe. */
|
330 |
|
|
|
331 |
|
|
bad_card = ((dev->base_addr != 0) && (dev->mem_end == 0xbad));
|
332 |
|
|
|
333 |
|
|
#if 0
|
334 |
|
|
/* Reset card. Who knows what dain-bramaged state it was left in. */
|
335 |
|
|
{ unsigned long reset_start_time = jiffies;
|
336 |
|
|
|
337 |
|
|
/* DON'T change these to inb_p/outb_p or reset will fail on clones. */
|
338 |
|
|
outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
|
339 |
|
|
|
340 |
|
|
while ((inb_p(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
|
341 |
|
|
if (jiffies - reset_start_time > 2*HZ/100) {
|
342 |
|
|
if (bad_card) {
|
343 |
|
|
printk(" (warning: no reset ack)");
|
344 |
|
|
break;
|
345 |
|
|
} else {
|
346 |
|
|
printk(" not found (no reset ack).\n");
|
347 |
|
|
return ENODEV;
|
348 |
|
|
}
|
349 |
|
|
}
|
350 |
|
|
|
351 |
|
|
outb_p(0xff, ioaddr + EN0_ISR); /* Ack all intr. */
|
352 |
|
|
}
|
353 |
|
|
#endif
|
354 |
|
|
|
355 |
|
|
/* Read the 16 bytes of station address PROM.
|
356 |
|
|
We must first initialize registers, similar to NS8390_init(eifdev, 0).
|
357 |
|
|
We can't reliably read the SAPROM address without this.
|
358 |
|
|
(I learned the hard way!). */
|
359 |
|
|
{
|
360 |
|
|
struct {unsigned char value, offset; } program_seq[] = {
|
361 |
|
|
{E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/
|
362 |
|
|
{0x48, EN0_DCFG}, /* Set byte-wide (0x48) access. */
|
363 |
|
|
{0x00, EN0_RCNTLO}, /* Clear the count regs. */
|
364 |
|
|
{0x00, EN0_RCNTHI},
|
365 |
|
|
{0x00, EN0_IMR}, /* Mask completion irq. */
|
366 |
|
|
{0xFF, EN0_ISR},
|
367 |
|
|
{E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */
|
368 |
|
|
{E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */
|
369 |
|
|
{32, EN0_RCNTLO},
|
370 |
|
|
{0x00, EN0_RCNTHI},
|
371 |
|
|
{0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */
|
372 |
|
|
{0x00, EN0_RSARHI},
|
373 |
|
|
{E8390_RREAD+E8390_START, E8390_CMD},
|
374 |
|
|
};
|
375 |
|
|
for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)
|
376 |
|
|
outb_p(program_seq[i].value, ioaddr + program_seq[i].offset);
|
377 |
|
|
}
|
378 |
|
|
|
379 |
|
|
for(i = 0; i < 32 /*sizeof(SA_prom)*/; i+=2) {
|
380 |
|
|
SA_prom[i] = inb(ioaddr + NE_DATAPORT);
|
381 |
|
|
SA_prom[i+1] = inb(ioaddr + NE_DATAPORT);
|
382 |
|
|
if (SA_prom[i] != SA_prom[i+1])
|
383 |
|
|
wordlength = 1;
|
384 |
|
|
}
|
385 |
|
|
|
386 |
|
|
/* At this point, wordlength *only* tells us if the SA_prom is doubled
|
387 |
|
|
up or not because some broken PCI cards don't respect the byte-wide
|
388 |
|
|
request in program_seq above, and hence don't have doubled up values.
|
389 |
|
|
These broken cards would otherwise be detected as an ne1000. */
|
390 |
|
|
|
391 |
|
|
if (wordlength == 2)
|
392 |
|
|
for (i = 0; i < 16; i++)
|
393 |
|
|
SA_prom[i] = SA_prom[i+i];
|
394 |
|
|
#ifdef CONFIG_M5307
|
395 |
|
|
{
|
396 |
|
|
outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD);
|
397 |
|
|
for(i = 0; i < 6; i++)
|
398 |
|
|
{
|
399 |
|
|
SA_prom[i] = inb(ioaddr + i + 1);
|
400 |
|
|
}
|
401 |
|
|
SA_prom[14] = SA_prom[15] = 0x57;
|
402 |
|
|
}
|
403 |
|
|
#endif /* CONFIG_M5307 */
|
404 |
|
|
#ifdef CONFIG_NETtel
|
405 |
|
|
{
|
406 |
|
|
unsigned char *ep = (unsigned char *) 0xf0006000;
|
407 |
|
|
unsigned char val;
|
408 |
|
|
/*
|
409 |
|
|
* MAC address should be in FLASH, check that it is valid.
|
410 |
|
|
* If good use it, otherwise use the default.
|
411 |
|
|
*/
|
412 |
|
|
if ((ep[0] == 0xff) && (ep[1] == 0xff) && (ep[2] == 0xff) &&
|
413 |
|
|
(ep[3] == 0xff) && (ep[4] == 0xff) && (ep[5] == 0xff))
|
414 |
|
|
ep = (unsigned char *) &ne_defethaddr[0];
|
415 |
|
|
else if ((ep[0] == 0) && (ep[1] == 0) && (ep[2] == 0) &&
|
416 |
|
|
(ep[3] == 0) && (ep[4] == 0) && (ep[5] == 0))
|
417 |
|
|
ep = (unsigned char *) &ne_defethaddr[0];
|
418 |
|
|
|
419 |
|
|
for(i = 0; i < 6; i++)
|
420 |
|
|
SA_prom[i] = ep[i];
|
421 |
|
|
SA_prom[14] = SA_prom[15] = 0x57;
|
422 |
|
|
|
423 |
|
|
#if 0
|
424 |
|
|
/*
|
425 |
|
|
* Set ethernet interface to be AUI.
|
426 |
|
|
*/
|
427 |
|
|
val = inb_p(ioaddr + EN0_RCNTHI);
|
428 |
|
|
outb_p(0x01 , (ioaddr + EN0_RCNTHI));
|
429 |
|
|
#endif
|
430 |
|
|
wordlength = 1;
|
431 |
|
|
|
432 |
|
|
/* We must set the 8390 for 8bit mode. */
|
433 |
|
|
outb_p(0x48, ioaddr + EN0_DCFG);
|
434 |
|
|
start_page = NESM_START_PG;
|
435 |
|
|
stop_page = NESM_STOP_PG;
|
436 |
|
|
}
|
437 |
|
|
#else defined(CONFIG_M5206e)
|
438 |
|
|
{
|
439 |
|
|
outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD);
|
440 |
|
|
for(i = 0; i < 6; i++)
|
441 |
|
|
{
|
442 |
|
|
SA_prom[i] = inb(ioaddr + i + 1);
|
443 |
|
|
}
|
444 |
|
|
SA_prom[14] = SA_prom[15] = 0x57;
|
445 |
|
|
}
|
446 |
|
|
#endif /* CONFIG_M5206e */
|
447 |
|
|
|
448 |
|
|
#ifndef CONFIG_COLDFIRE
|
449 |
|
|
if (pci_irq_line || ioaddr >= 0x400)
|
450 |
|
|
wordlength = 2; /* Catch broken PCI cards mentioned above. */
|
451 |
|
|
#endif
|
452 |
|
|
|
453 |
|
|
#ifndef CONFIG_NETtel
|
454 |
|
|
if (wordlength == 2) {
|
455 |
|
|
/* We must set the 8390 for word mode. */
|
456 |
|
|
outb_p(0x49, ioaddr + EN0_DCFG);
|
457 |
|
|
start_page = NESM_START_PG;
|
458 |
|
|
stop_page = NESM_STOP_PG;
|
459 |
|
|
} else {
|
460 |
|
|
start_page = NE1SM_START_PG;
|
461 |
|
|
stop_page = NE1SM_STOP_PG;
|
462 |
|
|
}
|
463 |
|
|
#endif
|
464 |
|
|
|
465 |
|
|
neX000 = (SA_prom[14] == 0x57 && SA_prom[15] == 0x57);
|
466 |
|
|
ctron = (SA_prom[0] == 0x00 && SA_prom[1] == 0x00 && SA_prom[2] == 0x1d);
|
467 |
|
|
|
468 |
|
|
/* Set up the rest of the parameters. */
|
469 |
|
|
if (neX000 || bad_card) {
|
470 |
|
|
name = (wordlength == 2) ? "NE2000" : "NE1000";
|
471 |
|
|
} else if (ctron) {
|
472 |
|
|
name = (wordlength == 2) ? "Ctron-8" : "Ctron-16";
|
473 |
|
|
start_page = 0x01;
|
474 |
|
|
stop_page = (wordlength == 2) ? 0x40 : 0x20;
|
475 |
|
|
} else {
|
476 |
|
|
#ifdef SUPPORT_NE_BAD_CLONES
|
477 |
|
|
/* Ack! Well, there might be a *bad* NE*000 clone there.
|
478 |
|
|
Check for total bogus addresses. */
|
479 |
|
|
for (i = 0; bad_clone_list[i].name8; i++) {
|
480 |
|
|
if (SA_prom[0] == bad_clone_list[i].SAprefix[0] &&
|
481 |
|
|
SA_prom[1] == bad_clone_list[i].SAprefix[1] &&
|
482 |
|
|
SA_prom[2] == bad_clone_list[i].SAprefix[2]) {
|
483 |
|
|
if (wordlength == 2) {
|
484 |
|
|
name = bad_clone_list[i].name16;
|
485 |
|
|
} else {
|
486 |
|
|
name = bad_clone_list[i].name8;
|
487 |
|
|
}
|
488 |
|
|
break;
|
489 |
|
|
}
|
490 |
|
|
}
|
491 |
|
|
if (bad_clone_list[i].name8 == NULL) {
|
492 |
|
|
printk(" not found (invalid signature %2.2x %2.2x).\n",
|
493 |
|
|
SA_prom[14], SA_prom[15]);
|
494 |
|
|
return ENXIO;
|
495 |
|
|
}
|
496 |
|
|
#else
|
497 |
|
|
printk(" not found.\n");
|
498 |
|
|
return ENXIO;
|
499 |
|
|
#endif
|
500 |
|
|
|
501 |
|
|
}
|
502 |
|
|
|
503 |
|
|
if (pci_irq_line)
|
504 |
|
|
dev->irq = pci_irq_line;
|
505 |
|
|
|
506 |
|
|
if (dev->irq < 2) {
|
507 |
|
|
autoirq_setup(0);
|
508 |
|
|
outb_p(0x50, ioaddr + EN0_IMR); /* Enable one interrupt. */
|
509 |
|
|
outb_p(0x00, ioaddr + EN0_RCNTLO);
|
510 |
|
|
outb_p(0x00, ioaddr + EN0_RCNTHI);
|
511 |
|
|
outb_p(E8390_RREAD+E8390_START, ioaddr); /* Trigger it... */
|
512 |
|
|
udelay(10000); /* wait 10ms for interrupt to propagate */
|
513 |
|
|
outb_p(0x00, ioaddr + EN0_IMR); /* Mask it again. */
|
514 |
|
|
dev->irq = autoirq_report(0);
|
515 |
|
|
if (ei_debug > 2)
|
516 |
|
|
printk(" autoirq is %d\n", dev->irq);
|
517 |
|
|
} else if (dev->irq == 2)
|
518 |
|
|
/* Fixup for users that don't know that IRQ 2 is really IRQ 9,
|
519 |
|
|
or don't know which one to set. */
|
520 |
|
|
dev->irq = 9;
|
521 |
|
|
|
522 |
|
|
if (! dev->irq) {
|
523 |
|
|
printk(" failed to detect IRQ line.\n");
|
524 |
|
|
return EAGAIN;
|
525 |
|
|
}
|
526 |
|
|
|
527 |
|
|
/* Snarf the interrupt now. There's no point in waiting since we cannot
|
528 |
|
|
share (with ISA cards) and the board will usually be enabled. */
|
529 |
|
|
{
|
530 |
|
|
#ifdef CONFIG_COLDFIRE
|
531 |
|
|
int irqval = request_irq(NE2000_IRQ_VECTOR, ei_interrupt, 0, name,NULL); ne2000_irqsetup();
|
532 |
|
|
#else
|
533 |
|
|
int irqval = request_irq(dev->irq, ei_interrupt,
|
534 |
|
|
pci_irq_line ? SA_SHIRQ : 0, name, dev);
|
535 |
|
|
#endif
|
536 |
|
|
if (irqval) {
|
537 |
|
|
printk (" unable to get IRQ %d (irqval=%d).\n", dev->irq, irqval);
|
538 |
|
|
return EAGAIN;
|
539 |
|
|
}
|
540 |
|
|
}
|
541 |
|
|
|
542 |
|
|
dev->base_addr = ioaddr;
|
543 |
|
|
|
544 |
|
|
/* Allocate dev->priv and fill in 8390 specific dev fields. */
|
545 |
|
|
if (ethdev_init(dev)) {
|
546 |
|
|
printk (" unable to get memory for dev->priv.\n");
|
547 |
|
|
free_irq(dev->irq, NULL);
|
548 |
|
|
return -ENOMEM;
|
549 |
|
|
}
|
550 |
|
|
|
551 |
|
|
request_region(ioaddr, NE_IO_EXTENT, name);
|
552 |
|
|
|
553 |
|
|
for(i = 0; i < ETHER_ADDR_LEN; i++) {
|
554 |
|
|
printk(" %2.2x", SA_prom[i]);
|
555 |
|
|
dev->dev_addr[i] = SA_prom[i];
|
556 |
|
|
}
|
557 |
|
|
|
558 |
|
|
printk("\n%s: %s found at %#x, using IRQ %d.\n",
|
559 |
|
|
dev->name, name, ioaddr, dev->irq);
|
560 |
|
|
|
561 |
|
|
ei_status.name = name;
|
562 |
|
|
ei_status.tx_start_page = start_page;
|
563 |
|
|
ei_status.stop_page = stop_page;
|
564 |
|
|
ei_status.word16 = (wordlength == 2);
|
565 |
|
|
|
566 |
|
|
ei_status.rx_start_page = start_page + TX_PAGES;
|
567 |
|
|
#ifdef PACKETBUF_MEMSIZE
|
568 |
|
|
/* Allow the packet buffer size to be overridden by know-it-alls. */
|
569 |
|
|
ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE;
|
570 |
|
|
#endif
|
571 |
|
|
|
572 |
|
|
ei_status.reset_8390 = &ne_reset_8390;
|
573 |
|
|
ei_status.block_input = &ne_block_input;
|
574 |
|
|
ei_status.block_output = &ne_block_output;
|
575 |
|
|
ei_status.get_8390_hdr = &ne_get_8390_hdr;
|
576 |
|
|
dev->open = &ne_open;
|
577 |
|
|
dev->stop = &ne_close;
|
578 |
|
|
NS8390_init(dev, 0);
|
579 |
|
|
return 0;
|
580 |
|
|
}
|
581 |
|
|
|
582 |
|
|
static int
|
583 |
|
|
ne_open(struct device *dev)
|
584 |
|
|
{
|
585 |
|
|
ei_open(dev);
|
586 |
|
|
MOD_INC_USE_COUNT;
|
587 |
|
|
return 0;
|
588 |
|
|
}
|
589 |
|
|
|
590 |
|
|
static int
|
591 |
|
|
ne_close(struct device *dev)
|
592 |
|
|
{
|
593 |
|
|
if (ei_debug > 1)
|
594 |
|
|
printk("%s: Shutting down ethercard.\n", dev->name);
|
595 |
|
|
ei_close(dev);
|
596 |
|
|
MOD_DEC_USE_COUNT;
|
597 |
|
|
return 0;
|
598 |
|
|
}
|
599 |
|
|
|
600 |
|
|
/* Hard reset the card. This used to pause for the same period that a
|
601 |
|
|
8390 reset command required, but that shouldn't be necessary. */
|
602 |
|
|
static void
|
603 |
|
|
ne_reset_8390(struct device *dev)
|
604 |
|
|
{
|
605 |
|
|
unsigned long reset_start_time = jiffies;
|
606 |
|
|
|
607 |
|
|
if (ei_debug > 1) printk("resetting the 8390 t=%ld...", jiffies);
|
608 |
|
|
|
609 |
|
|
/* DON'T change these to inb_p/outb_p or reset will fail on clones. */
|
610 |
|
|
outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET);
|
611 |
|
|
|
612 |
|
|
ei_status.txing = 0;
|
613 |
|
|
ei_status.dmaing = 0;
|
614 |
|
|
|
615 |
|
|
/* This check _should_not_ be necessary, omit eventually. */
|
616 |
|
|
while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
|
617 |
|
|
if (jiffies - reset_start_time > 2*HZ/100) {
|
618 |
|
|
printk("%s: ne_reset_8390() did not complete.\n", dev->name);
|
619 |
|
|
break;
|
620 |
|
|
}
|
621 |
|
|
outb_p(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */
|
622 |
|
|
}
|
623 |
|
|
|
624 |
|
|
/* Grab the 8390 specific header. Similar to the block_input routine, but
|
625 |
|
|
we don't need to be concerned with ring wrap as the header will be at
|
626 |
|
|
the start of a page, so we optimize accordingly. */
|
627 |
|
|
|
628 |
|
|
static void
|
629 |
|
|
ne_get_8390_hdr(struct device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
|
630 |
|
|
{
|
631 |
|
|
|
632 |
|
|
int nic_base = dev->base_addr;
|
633 |
|
|
|
634 |
|
|
/* This *shouldn't* happen. If it does, it's the last thing you'll see */
|
635 |
|
|
if (ei_status.dmaing) {
|
636 |
|
|
printk("%s: DMAing conflict in ne_get_8390_hdr "
|
637 |
|
|
"[DMAstat:%d][irqlock:%d][intr:%d].\n",
|
638 |
|
|
dev->name, ei_status.dmaing, ei_status.irqlock,
|
639 |
|
|
dev->interrupt);
|
640 |
|
|
return;
|
641 |
|
|
}
|
642 |
|
|
|
643 |
|
|
ei_status.dmaing |= 0x01;
|
644 |
|
|
outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
|
645 |
|
|
outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO);
|
646 |
|
|
outb_p(0, nic_base + EN0_RCNTHI);
|
647 |
|
|
outb_p(0, nic_base + EN0_RSARLO); /* On page boundary */
|
648 |
|
|
outb_p(ring_page, nic_base + EN0_RSARHI);
|
649 |
|
|
outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
|
650 |
|
|
|
651 |
|
|
#ifdef CONFIG_COLDFIRE
|
652 |
|
|
/*
|
653 |
|
|
* Problem is that the hdr structure contains a short.
|
654 |
|
|
* This won't come out in the correct host byte order,
|
655 |
|
|
* so we need to byte swap it here.
|
656 |
|
|
*/
|
657 |
|
|
{
|
658 |
|
|
unsigned char tmpbuf[sizeof(struct e8390_pkt_hdr)];
|
659 |
|
|
if (ei_status.word16)
|
660 |
|
|
insw(NE_BASE + NE_DATAPORT, tmpbuf, sizeof(struct e8390_pkt_hdr)>>1);
|
661 |
|
|
else
|
662 |
|
|
insb(NE_BASE + NE_DATAPORT, tmpbuf, sizeof(struct e8390_pkt_hdr));
|
663 |
|
|
hdr->status = tmpbuf[0];
|
664 |
|
|
hdr->next = tmpbuf[1];
|
665 |
|
|
hdr->count = (tmpbuf[3] << 8) | tmpbuf[2];
|
666 |
|
|
}
|
667 |
|
|
#else
|
668 |
|
|
if (ei_status.word16)
|
669 |
|
|
insw(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1);
|
670 |
|
|
else
|
671 |
|
|
insb(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr));
|
672 |
|
|
#endif
|
673 |
|
|
|
674 |
|
|
outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
|
675 |
|
|
ei_status.dmaing &= ~0x01;
|
676 |
|
|
}
|
677 |
|
|
|
678 |
|
|
/* Block input and output, similar to the Crynwr packet driver. If you
|
679 |
|
|
are porting to a new ethercard, look at the packet driver source for hints.
|
680 |
|
|
The NEx000 doesn't share the on-board packet memory -- you have to put
|
681 |
|
|
the packet out through the "remote DMA" dataport using outb. */
|
682 |
|
|
|
683 |
|
|
static void
|
684 |
|
|
ne_block_input(struct device *dev, int count, struct sk_buff *skb, int ring_offset)
|
685 |
|
|
{
|
686 |
|
|
#ifdef NE_SANITY_CHECK
|
687 |
|
|
int xfer_count = count;
|
688 |
|
|
#endif
|
689 |
|
|
int nic_base = dev->base_addr;
|
690 |
|
|
char *buf = skb->data;
|
691 |
|
|
|
692 |
|
|
/* This *shouldn't* happen. If it does, it's the last thing you'll see */
|
693 |
|
|
if (ei_status.dmaing) {
|
694 |
|
|
printk("%s: DMAing conflict in ne_block_input "
|
695 |
|
|
"[DMAstat:%d][irqlock:%d][intr:%d].\n",
|
696 |
|
|
dev->name, ei_status.dmaing, ei_status.irqlock,
|
697 |
|
|
dev->interrupt);
|
698 |
|
|
return;
|
699 |
|
|
}
|
700 |
|
|
ei_status.dmaing |= 0x01;
|
701 |
|
|
outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
|
702 |
|
|
outb_p(count & 0xff, nic_base + EN0_RCNTLO);
|
703 |
|
|
outb_p(count >> 8, nic_base + EN0_RCNTHI);
|
704 |
|
|
outb_p(ring_offset & 0xff, nic_base + EN0_RSARLO);
|
705 |
|
|
outb_p(ring_offset >> 8, nic_base + EN0_RSARHI);
|
706 |
|
|
outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
|
707 |
|
|
if (ei_status.word16) {
|
708 |
|
|
insw(NE_BASE + NE_DATAPORT,buf,count>>1);
|
709 |
|
|
if (count & 0x01) {
|
710 |
|
|
buf[count-1] = inb(NE_BASE + NE_DATAPORT);
|
711 |
|
|
#ifdef NE_SANITY_CHECK
|
712 |
|
|
xfer_count++;
|
713 |
|
|
#endif
|
714 |
|
|
}
|
715 |
|
|
} else {
|
716 |
|
|
insb(NE_BASE + NE_DATAPORT, buf, count);
|
717 |
|
|
}
|
718 |
|
|
|
719 |
|
|
#ifdef NE_SANITY_CHECK
|
720 |
|
|
/* This was for the ALPHA version only, but enough people have
|
721 |
|
|
been encountering problems so it is still here. If you see
|
722 |
|
|
this message you either 1) have a slightly incompatible clone
|
723 |
|
|
or 2) have noise/speed problems with your bus. */
|
724 |
|
|
if (ei_debug > 1) { /* DMA termination address check... */
|
725 |
|
|
int addr, tries = 20;
|
726 |
|
|
do {
|
727 |
|
|
/* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here
|
728 |
|
|
-- it's broken for Rx on some cards! */
|
729 |
|
|
int high = inb_p(nic_base + EN0_RSARHI);
|
730 |
|
|
int low = inb_p(nic_base + EN0_RSARLO);
|
731 |
|
|
addr = (high << 8) + low;
|
732 |
|
|
if (((ring_offset + xfer_count) & 0xff) == low)
|
733 |
|
|
break;
|
734 |
|
|
} while (--tries > 0);
|
735 |
|
|
if (tries <= 0)
|
736 |
|
|
printk("%s: RX transfer address mismatch,"
|
737 |
|
|
"%#4.4x (expected) vs. %#4.4x (actual).\n",
|
738 |
|
|
dev->name, ring_offset + xfer_count, addr);
|
739 |
|
|
}
|
740 |
|
|
#endif
|
741 |
|
|
outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
|
742 |
|
|
ei_status.dmaing &= ~0x01;
|
743 |
|
|
}
|
744 |
|
|
|
745 |
|
|
static void
|
746 |
|
|
ne_block_output(struct device *dev, int count,
|
747 |
|
|
const unsigned char *buf, const int start_page)
|
748 |
|
|
{
|
749 |
|
|
int nic_base = NE_BASE;
|
750 |
|
|
unsigned long dma_start;
|
751 |
|
|
#ifdef NE_SANITY_CHECK
|
752 |
|
|
int retries = 0;
|
753 |
|
|
#endif
|
754 |
|
|
|
755 |
|
|
/* Round the count up for word writes. Do we need to do this?
|
756 |
|
|
What effect will an odd byte count have on the 8390?
|
757 |
|
|
I should check someday. */
|
758 |
|
|
if (ei_status.word16 && (count & 0x01))
|
759 |
|
|
count++;
|
760 |
|
|
|
761 |
|
|
/* This *shouldn't* happen. If it does, it's the last thing you'll see */
|
762 |
|
|
if (ei_status.dmaing) {
|
763 |
|
|
printk("%s: DMAing conflict in ne_block_output."
|
764 |
|
|
"[DMAstat:%d][irqlock:%d][intr:%d]\n",
|
765 |
|
|
dev->name, ei_status.dmaing, ei_status.irqlock,
|
766 |
|
|
dev->interrupt);
|
767 |
|
|
return;
|
768 |
|
|
}
|
769 |
|
|
ei_status.dmaing |= 0x01;
|
770 |
|
|
/* We should already be in page 0, but to be safe... */
|
771 |
|
|
outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD);
|
772 |
|
|
|
773 |
|
|
#ifdef NE_SANITY_CHECK
|
774 |
|
|
retry:
|
775 |
|
|
#endif
|
776 |
|
|
|
777 |
|
|
#ifdef NE8390_RW_BUGFIX
|
778 |
|
|
/* Handle the read-before-write bug the same way as the
|
779 |
|
|
Crynwr packet driver -- the NatSemi method doesn't work.
|
780 |
|
|
Actually this doesn't always work either, but if you have
|
781 |
|
|
problems with your NEx000 this is better than nothing! */
|
782 |
|
|
outb_p(0x42, nic_base + EN0_RCNTLO);
|
783 |
|
|
outb_p(0x00, nic_base + EN0_RCNTHI);
|
784 |
|
|
outb_p(0x42, nic_base + EN0_RSARLO);
|
785 |
|
|
outb_p(0x00, nic_base + EN0_RSARHI);
|
786 |
|
|
outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
|
787 |
|
|
/* Make certain that the dummy read has occurred. */
|
788 |
|
|
udelay(6);
|
789 |
|
|
#endif
|
790 |
|
|
|
791 |
|
|
outb_p(ENISR_RDC, nic_base + EN0_ISR);
|
792 |
|
|
|
793 |
|
|
/* Now the normal output. */
|
794 |
|
|
outb_p(count & 0xff, nic_base + EN0_RCNTLO);
|
795 |
|
|
outb_p(count >> 8, nic_base + EN0_RCNTHI);
|
796 |
|
|
outb_p(0x00, nic_base + EN0_RSARLO);
|
797 |
|
|
outb_p(start_page, nic_base + EN0_RSARHI);
|
798 |
|
|
|
799 |
|
|
outb_p(E8390_RWRITE+E8390_START, nic_base + NE_CMD);
|
800 |
|
|
if (ei_status.word16) {
|
801 |
|
|
outsw(NE_BASE + NE_DATAPORT, buf, count>>1);
|
802 |
|
|
} else {
|
803 |
|
|
outsb(NE_BASE + NE_DATAPORT, buf, count);
|
804 |
|
|
}
|
805 |
|
|
|
806 |
|
|
dma_start = jiffies;
|
807 |
|
|
|
808 |
|
|
#ifdef NE_SANITY_CHECK
|
809 |
|
|
/* This was for the ALPHA version only, but enough people have
|
810 |
|
|
been encountering problems so it is still here. */
|
811 |
|
|
if (ei_debug > 1) { /* DMA termination address check... */
|
812 |
|
|
int addr, tries = 20;
|
813 |
|
|
do {
|
814 |
|
|
int high = inb_p(nic_base + EN0_RSARHI);
|
815 |
|
|
int low = inb_p(nic_base + EN0_RSARLO);
|
816 |
|
|
addr = (high << 8) + low;
|
817 |
|
|
if ((start_page << 8) + count == addr)
|
818 |
|
|
break;
|
819 |
|
|
} while (--tries > 0);
|
820 |
|
|
if (tries <= 0) {
|
821 |
|
|
printk("%s: Tx packet transfer address mismatch,"
|
822 |
|
|
"%#4.4x (expected) vs. %#4.4x (actual).\n",
|
823 |
|
|
dev->name, (start_page << 8) + count, addr);
|
824 |
|
|
if (retries++ == 0)
|
825 |
|
|
goto retry;
|
826 |
|
|
}
|
827 |
|
|
}
|
828 |
|
|
#endif
|
829 |
|
|
|
830 |
|
|
while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
|
831 |
|
|
if (jiffies - dma_start > 2*HZ/100) { /* 20ms */
|
832 |
|
|
printk("%s: timeout waiting for Tx RDC.\n", dev->name);
|
833 |
|
|
ne_reset_8390(dev);
|
834 |
|
|
NS8390_init(dev,1);
|
835 |
|
|
break;
|
836 |
|
|
}
|
837 |
|
|
|
838 |
|
|
outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
|
839 |
|
|
ei_status.dmaing &= ~0x01;
|
840 |
|
|
return;
|
841 |
|
|
}
|
842 |
|
|
|
843 |
|
|
|
844 |
|
|
#ifdef MODULE
|
845 |
|
|
#define MAX_NE_CARDS 4 /* Max number of NE cards per module */
|
846 |
|
|
#define NAMELEN 8 /* # of chars for storing dev->name */
|
847 |
|
|
static char namelist[NAMELEN * MAX_NE_CARDS] = { 0, };
|
848 |
|
|
static struct device dev_ne[MAX_NE_CARDS] = {
|
849 |
|
|
{
|
850 |
|
|
NULL, /* assign a chunk of namelist[] below */
|
851 |
|
|
0, 0, 0, 0,
|
852 |
|
|
0, 0,
|
853 |
|
|
0, 0, 0, NULL, NULL
|
854 |
|
|
},
|
855 |
|
|
};
|
856 |
|
|
|
857 |
|
|
static int io[MAX_NE_CARDS] = { 0, };
|
858 |
|
|
static int irq[MAX_NE_CARDS] = { 0, };
|
859 |
|
|
static int bad[MAX_NE_CARDS] = { 0, };
|
860 |
|
|
|
861 |
|
|
/* This is set up so that no autoprobe takes place. We can't guarantee
|
862 |
|
|
that the ne2k probe is the last 8390 based probe to take place (as it
|
863 |
|
|
is at boot) and so the probe will get confused by any other 8390 cards.
|
864 |
|
|
ISA device autoprobes on a running machine are not recommended anyway. */
|
865 |
|
|
|
866 |
|
|
int
|
867 |
|
|
init_module(void)
|
868 |
|
|
{
|
869 |
|
|
int this_dev, found = 0;
|
870 |
|
|
|
871 |
|
|
for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
|
872 |
|
|
struct device *dev = &dev_ne[this_dev];
|
873 |
|
|
dev->name = namelist+(NAMELEN*this_dev);
|
874 |
|
|
dev->irq = irq[this_dev];
|
875 |
|
|
dev->base_addr = io[this_dev];
|
876 |
|
|
dev->init = ne_probe;
|
877 |
|
|
dev->mem_end = bad[this_dev];
|
878 |
|
|
if (register_netdev(dev) == 0) {
|
879 |
|
|
found++;
|
880 |
|
|
continue;
|
881 |
|
|
}
|
882 |
|
|
if (found != 0) /* Got at least one. */
|
883 |
|
|
return 0;
|
884 |
|
|
if (io[this_dev] != 0)
|
885 |
|
|
printk(KERN_WARNING "ne.c: No NE*000 card found at i/o = %#x\n", io[this_dev]);
|
886 |
|
|
else
|
887 |
|
|
printk(KERN_NOTICE "ne.c: No PCI cards found. Use \"io=0xNNN\" value(s) for ISA cards.\n");
|
888 |
|
|
return -ENXIO;
|
889 |
|
|
}
|
890 |
|
|
|
891 |
|
|
return 0;
|
892 |
|
|
}
|
893 |
|
|
|
894 |
|
|
void
|
895 |
|
|
cleanup_module(void)
|
896 |
|
|
{
|
897 |
|
|
int this_dev;
|
898 |
|
|
|
899 |
|
|
for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
|
900 |
|
|
struct device *dev = &dev_ne[this_dev];
|
901 |
|
|
if (dev->priv != NULL) {
|
902 |
|
|
kfree(dev->priv);
|
903 |
|
|
dev->priv = NULL;
|
904 |
|
|
free_irq(dev->irq, dev);
|
905 |
|
|
irq2dev_map[dev->irq] = NULL;
|
906 |
|
|
release_region(dev->base_addr, NE_IO_EXTENT);
|
907 |
|
|
unregister_netdev(dev);
|
908 |
|
|
}
|
909 |
|
|
}
|
910 |
|
|
}
|
911 |
|
|
#endif /* MODULE */
|
912 |
|
|
|
913 |
|
|
/*
|
914 |
|
|
* Local variables:
|
915 |
|
|
* compile-command: "gcc -DKERNEL -Wall -O6 -fomit-frame-pointer -I/usr/src/linux/net/tcp -c ne.c"
|
916 |
|
|
* version-control: t
|
917 |
|
|
* kept-new-versions: 5
|
918 |
|
|
* End:
|
919 |
|
|
*/
|