xref: /OK3568_Linux_fs/kernel/drivers/net/arcnet/com90xx.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Linux ARCnet driver - COM90xx chipset (memory-mapped buffers)
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Written 1994-1999 by Avery Pennarun.
5*4882a593Smuzhiyun  * Written 1999 by Martin Mares <mj@ucw.cz>.
6*4882a593Smuzhiyun  * Derived from skeleton.c by Donald Becker.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
9*4882a593Smuzhiyun  *  for sponsoring the further development of this driver.
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * **********************
12*4882a593Smuzhiyun  *
13*4882a593Smuzhiyun  * The original copyright of skeleton.c was as follows:
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * skeleton.c Written 1993 by Donald Becker.
16*4882a593Smuzhiyun  * Copyright 1993 United States Government as represented by the
17*4882a593Smuzhiyun  * Director, National Security Agency.  This software may only be used
18*4882a593Smuzhiyun  * and distributed according to the terms of the GNU General Public License as
19*4882a593Smuzhiyun  * modified by SRC, incorporated herein by reference.
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  * **********************
22*4882a593Smuzhiyun  *
23*4882a593Smuzhiyun  * For more details, see drivers/net/arcnet.c
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  * **********************
26*4882a593Smuzhiyun  */
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #include <linux/module.h>
31*4882a593Smuzhiyun #include <linux/moduleparam.h>
32*4882a593Smuzhiyun #include <linux/init.h>
33*4882a593Smuzhiyun #include <linux/interrupt.h>
34*4882a593Smuzhiyun #include <linux/ioport.h>
35*4882a593Smuzhiyun #include <linux/delay.h>
36*4882a593Smuzhiyun #include <linux/netdevice.h>
37*4882a593Smuzhiyun #include <linux/slab.h>
38*4882a593Smuzhiyun #include <linux/io.h>
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun #include "arcdevice.h"
41*4882a593Smuzhiyun #include "com9026.h"
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /* Define this to speed up the autoprobe by assuming if only one io port and
44*4882a593Smuzhiyun  * shmem are left in the list at Stage 5, they must correspond to each
45*4882a593Smuzhiyun  * other.
46*4882a593Smuzhiyun  *
47*4882a593Smuzhiyun  * This is undefined by default because it might not always be true, and the
48*4882a593Smuzhiyun  * extra check makes the autoprobe even more careful.  Speed demons can turn
49*4882a593Smuzhiyun  * it on - I think it should be fine if you only have one ARCnet card
50*4882a593Smuzhiyun  * installed.
51*4882a593Smuzhiyun  *
52*4882a593Smuzhiyun  * If no ARCnet cards are installed, this delay never happens anyway and thus
53*4882a593Smuzhiyun  * the option has no effect.
54*4882a593Smuzhiyun  */
55*4882a593Smuzhiyun #undef FAST_PROBE
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun /* Internal function declarations */
58*4882a593Smuzhiyun static int com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *);
59*4882a593Smuzhiyun static void com90xx_command(struct net_device *dev, int command);
60*4882a593Smuzhiyun static int com90xx_status(struct net_device *dev);
61*4882a593Smuzhiyun static void com90xx_setmask(struct net_device *dev, int mask);
62*4882a593Smuzhiyun static int com90xx_reset(struct net_device *dev, int really_reset);
63*4882a593Smuzhiyun static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
64*4882a593Smuzhiyun 				 void *buf, int count);
65*4882a593Smuzhiyun static void com90xx_copy_from_card(struct net_device *dev, int bufnum,
66*4882a593Smuzhiyun 				   int offset, void *buf, int count);
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun /* Known ARCnet cards */
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun static struct net_device *cards[16];
71*4882a593Smuzhiyun static int numcards;
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun /* Handy defines for ARCnet specific stuff */
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun /* The number of low I/O ports used by the card */
76*4882a593Smuzhiyun #define ARCNET_TOTAL_SIZE	16
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun /* Amount of I/O memory used by the card */
79*4882a593Smuzhiyun #define BUFFER_SIZE (512)
80*4882a593Smuzhiyun #define MIRROR_SIZE (BUFFER_SIZE * 4)
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun static int com90xx_skip_probe __initdata = 0;
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun /* Module parameters */
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun static int io;			/* use the insmod io= irq= shmem= options */
87*4882a593Smuzhiyun static int irq;
88*4882a593Smuzhiyun static int shmem;
89*4882a593Smuzhiyun static char device[9];		/* use eg. device=arc1 to change name */
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun module_param_hw(io, int, ioport, 0);
92*4882a593Smuzhiyun module_param_hw(irq, int, irq, 0);
93*4882a593Smuzhiyun module_param(shmem, int, 0);
94*4882a593Smuzhiyun module_param_string(device, device, sizeof(device), 0);
95*4882a593Smuzhiyun 
com90xx_probe(void)96*4882a593Smuzhiyun static void __init com90xx_probe(void)
97*4882a593Smuzhiyun {
98*4882a593Smuzhiyun 	int count, status, ioaddr, numprint, airq, openparen = 0;
99*4882a593Smuzhiyun 	unsigned long airqmask;
100*4882a593Smuzhiyun 	int ports[(0x3f0 - 0x200) / 16 + 1] = {	0 };
101*4882a593Smuzhiyun 	unsigned long *shmems;
102*4882a593Smuzhiyun 	void __iomem **iomem;
103*4882a593Smuzhiyun 	int numports, numshmems, *port;
104*4882a593Smuzhiyun 	u_long *p;
105*4882a593Smuzhiyun 	int index;
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun 	if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
108*4882a593Smuzhiyun 		return;
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun 	shmems = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(unsigned long),
111*4882a593Smuzhiyun 			 GFP_KERNEL);
112*4882a593Smuzhiyun 	if (!shmems)
113*4882a593Smuzhiyun 		return;
114*4882a593Smuzhiyun 	iomem = kzalloc(((0x100000 - 0xa0000) / 0x800) * sizeof(void __iomem *),
115*4882a593Smuzhiyun 			GFP_KERNEL);
116*4882a593Smuzhiyun 	if (!iomem) {
117*4882a593Smuzhiyun 		kfree(shmems);
118*4882a593Smuzhiyun 		return;
119*4882a593Smuzhiyun 	}
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun 	if (BUGLVL(D_NORMAL))
122*4882a593Smuzhiyun 		pr_info("%s\n", "COM90xx chipset support");
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun 	/* set up the arrays where we'll store the possible probe addresses */
125*4882a593Smuzhiyun 	numports = numshmems = 0;
126*4882a593Smuzhiyun 	if (io)
127*4882a593Smuzhiyun 		ports[numports++] = io;
128*4882a593Smuzhiyun 	else
129*4882a593Smuzhiyun 		for (count = 0x200; count <= 0x3f0; count += 16)
130*4882a593Smuzhiyun 			ports[numports++] = count;
131*4882a593Smuzhiyun 	if (shmem)
132*4882a593Smuzhiyun 		shmems[numshmems++] = shmem;
133*4882a593Smuzhiyun 	else
134*4882a593Smuzhiyun 		for (count = 0xA0000; count <= 0xFF800; count += 2048)
135*4882a593Smuzhiyun 			shmems[numshmems++] = count;
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun 	/* Stage 1: abandon any reserved ports, or ones with status==0xFF
138*4882a593Smuzhiyun 	 * (empty), and reset any others by reading the reset port.
139*4882a593Smuzhiyun 	 */
140*4882a593Smuzhiyun 	numprint = -1;
141*4882a593Smuzhiyun 	for (port = &ports[0]; port - ports < numports; port++) {
142*4882a593Smuzhiyun 		numprint++;
143*4882a593Smuzhiyun 		numprint %= 8;
144*4882a593Smuzhiyun 		if (!numprint) {
145*4882a593Smuzhiyun 			arc_cont(D_INIT, "\n");
146*4882a593Smuzhiyun 			arc_cont(D_INIT, "S1: ");
147*4882a593Smuzhiyun 		}
148*4882a593Smuzhiyun 		arc_cont(D_INIT, "%Xh ", *port);
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun 		ioaddr = *port;
151*4882a593Smuzhiyun 
152*4882a593Smuzhiyun 		if (!request_region(*port, ARCNET_TOTAL_SIZE,
153*4882a593Smuzhiyun 				    "arcnet (90xx)")) {
154*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "(request_region)\n");
155*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "S1: ");
156*4882a593Smuzhiyun 			if (BUGLVL(D_INIT_REASONS))
157*4882a593Smuzhiyun 				numprint = 0;
158*4882a593Smuzhiyun 			*port-- = ports[--numports];
159*4882a593Smuzhiyun 			continue;
160*4882a593Smuzhiyun 		}
161*4882a593Smuzhiyun 		if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
162*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "(empty)\n");
163*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "S1: ");
164*4882a593Smuzhiyun 			if (BUGLVL(D_INIT_REASONS))
165*4882a593Smuzhiyun 				numprint = 0;
166*4882a593Smuzhiyun 			release_region(*port, ARCNET_TOTAL_SIZE);
167*4882a593Smuzhiyun 			*port-- = ports[--numports];
168*4882a593Smuzhiyun 			continue;
169*4882a593Smuzhiyun 		}
170*4882a593Smuzhiyun 		/* begin resetting card */
171*4882a593Smuzhiyun 		arcnet_inb(ioaddr, COM9026_REG_R_RESET);
172*4882a593Smuzhiyun 
173*4882a593Smuzhiyun 		arc_cont(D_INIT_REASONS, "\n");
174*4882a593Smuzhiyun 		arc_cont(D_INIT_REASONS, "S1: ");
175*4882a593Smuzhiyun 		if (BUGLVL(D_INIT_REASONS))
176*4882a593Smuzhiyun 			numprint = 0;
177*4882a593Smuzhiyun 	}
178*4882a593Smuzhiyun 	arc_cont(D_INIT, "\n");
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun 	if (!numports) {
181*4882a593Smuzhiyun 		arc_cont(D_NORMAL, "S1: No ARCnet cards found.\n");
182*4882a593Smuzhiyun 		kfree(shmems);
183*4882a593Smuzhiyun 		kfree(iomem);
184*4882a593Smuzhiyun 		return;
185*4882a593Smuzhiyun 	}
186*4882a593Smuzhiyun 	/* Stage 2: we have now reset any possible ARCnet cards, so we can't
187*4882a593Smuzhiyun 	 * do anything until they finish.  If D_INIT, print the list of
188*4882a593Smuzhiyun 	 * cards that are left.
189*4882a593Smuzhiyun 	 */
190*4882a593Smuzhiyun 	numprint = -1;
191*4882a593Smuzhiyun 	for (port = &ports[0]; port < ports + numports; port++) {
192*4882a593Smuzhiyun 		numprint++;
193*4882a593Smuzhiyun 		numprint %= 8;
194*4882a593Smuzhiyun 		if (!numprint) {
195*4882a593Smuzhiyun 			arc_cont(D_INIT, "\n");
196*4882a593Smuzhiyun 			arc_cont(D_INIT, "S2: ");
197*4882a593Smuzhiyun 		}
198*4882a593Smuzhiyun 		arc_cont(D_INIT, "%Xh ", *port);
199*4882a593Smuzhiyun 	}
200*4882a593Smuzhiyun 	arc_cont(D_INIT, "\n");
201*4882a593Smuzhiyun 	mdelay(RESETtime);
202*4882a593Smuzhiyun 
203*4882a593Smuzhiyun 	/* Stage 3: abandon any shmem addresses that don't have the signature
204*4882a593Smuzhiyun 	 * 0xD1 byte in the right place, or are read-only.
205*4882a593Smuzhiyun 	 */
206*4882a593Smuzhiyun 	numprint = -1;
207*4882a593Smuzhiyun 	for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) {
208*4882a593Smuzhiyun 		void __iomem *base;
209*4882a593Smuzhiyun 
210*4882a593Smuzhiyun 		numprint++;
211*4882a593Smuzhiyun 		numprint %= 8;
212*4882a593Smuzhiyun 		if (!numprint) {
213*4882a593Smuzhiyun 			arc_cont(D_INIT, "\n");
214*4882a593Smuzhiyun 			arc_cont(D_INIT, "S3: ");
215*4882a593Smuzhiyun 		}
216*4882a593Smuzhiyun 		arc_cont(D_INIT, "%lXh ", *p);
217*4882a593Smuzhiyun 
218*4882a593Smuzhiyun 		if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) {
219*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "(request_mem_region)\n");
220*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "Stage 3: ");
221*4882a593Smuzhiyun 			if (BUGLVL(D_INIT_REASONS))
222*4882a593Smuzhiyun 				numprint = 0;
223*4882a593Smuzhiyun 			goto out;
224*4882a593Smuzhiyun 		}
225*4882a593Smuzhiyun 		base = ioremap(*p, MIRROR_SIZE);
226*4882a593Smuzhiyun 		if (!base) {
227*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "(ioremap)\n");
228*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "Stage 3: ");
229*4882a593Smuzhiyun 			if (BUGLVL(D_INIT_REASONS))
230*4882a593Smuzhiyun 				numprint = 0;
231*4882a593Smuzhiyun 			goto out1;
232*4882a593Smuzhiyun 		}
233*4882a593Smuzhiyun 		if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
234*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
235*4882a593Smuzhiyun 				 arcnet_readb(base, COM9026_REG_R_STATUS),
236*4882a593Smuzhiyun 				 TESTvalue);
237*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "S3: ");
238*4882a593Smuzhiyun 			if (BUGLVL(D_INIT_REASONS))
239*4882a593Smuzhiyun 				numprint = 0;
240*4882a593Smuzhiyun 			goto out2;
241*4882a593Smuzhiyun 		}
242*4882a593Smuzhiyun 		/* By writing 0x42 to the TESTvalue location, we also make
243*4882a593Smuzhiyun 		 * sure no "mirror" shmem areas show up - if they occur
244*4882a593Smuzhiyun 		 * in another pass through this loop, they will be discarded
245*4882a593Smuzhiyun 		 * because *cptr != TESTvalue.
246*4882a593Smuzhiyun 		 */
247*4882a593Smuzhiyun 		arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
248*4882a593Smuzhiyun 		if (arcnet_readb(base, COM9026_REG_R_STATUS) != 0x42) {
249*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "(read only)\n");
250*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "S3: ");
251*4882a593Smuzhiyun 			goto out2;
252*4882a593Smuzhiyun 		}
253*4882a593Smuzhiyun 		arc_cont(D_INIT_REASONS, "\n");
254*4882a593Smuzhiyun 		arc_cont(D_INIT_REASONS, "S3: ");
255*4882a593Smuzhiyun 		if (BUGLVL(D_INIT_REASONS))
256*4882a593Smuzhiyun 			numprint = 0;
257*4882a593Smuzhiyun 		iomem[index] = base;
258*4882a593Smuzhiyun 		continue;
259*4882a593Smuzhiyun 	out2:
260*4882a593Smuzhiyun 		iounmap(base);
261*4882a593Smuzhiyun 	out1:
262*4882a593Smuzhiyun 		release_mem_region(*p, MIRROR_SIZE);
263*4882a593Smuzhiyun 	out:
264*4882a593Smuzhiyun 		*p-- = shmems[--numshmems];
265*4882a593Smuzhiyun 		index--;
266*4882a593Smuzhiyun 	}
267*4882a593Smuzhiyun 	arc_cont(D_INIT, "\n");
268*4882a593Smuzhiyun 
269*4882a593Smuzhiyun 	if (!numshmems) {
270*4882a593Smuzhiyun 		arc_cont(D_NORMAL, "S3: No ARCnet cards found.\n");
271*4882a593Smuzhiyun 		for (port = &ports[0]; port < ports + numports; port++)
272*4882a593Smuzhiyun 			release_region(*port, ARCNET_TOTAL_SIZE);
273*4882a593Smuzhiyun 		kfree(shmems);
274*4882a593Smuzhiyun 		kfree(iomem);
275*4882a593Smuzhiyun 		return;
276*4882a593Smuzhiyun 	}
277*4882a593Smuzhiyun 	/* Stage 4: something of a dummy, to report the shmems that are
278*4882a593Smuzhiyun 	 * still possible after stage 3.
279*4882a593Smuzhiyun 	 */
280*4882a593Smuzhiyun 	numprint = -1;
281*4882a593Smuzhiyun 	for (p = &shmems[0]; p < shmems + numshmems; p++) {
282*4882a593Smuzhiyun 		numprint++;
283*4882a593Smuzhiyun 		numprint %= 8;
284*4882a593Smuzhiyun 		if (!numprint) {
285*4882a593Smuzhiyun 			arc_cont(D_INIT, "\n");
286*4882a593Smuzhiyun 			arc_cont(D_INIT, "S4: ");
287*4882a593Smuzhiyun 		}
288*4882a593Smuzhiyun 		arc_cont(D_INIT, "%lXh ", *p);
289*4882a593Smuzhiyun 	}
290*4882a593Smuzhiyun 	arc_cont(D_INIT, "\n");
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun 	/* Stage 5: for any ports that have the correct status, can disable
293*4882a593Smuzhiyun 	 * the RESET flag, and (if no irq is given) generate an autoirq,
294*4882a593Smuzhiyun 	 * register an ARCnet device.
295*4882a593Smuzhiyun 	 *
296*4882a593Smuzhiyun 	 * Currently, we can only register one device per probe, so quit
297*4882a593Smuzhiyun 	 * after the first one is found.
298*4882a593Smuzhiyun 	 */
299*4882a593Smuzhiyun 	numprint = -1;
300*4882a593Smuzhiyun 	for (port = &ports[0]; port < ports + numports; port++) {
301*4882a593Smuzhiyun 		int found = 0;
302*4882a593Smuzhiyun 
303*4882a593Smuzhiyun 		numprint++;
304*4882a593Smuzhiyun 		numprint %= 8;
305*4882a593Smuzhiyun 		if (!numprint) {
306*4882a593Smuzhiyun 			arc_cont(D_INIT, "\n");
307*4882a593Smuzhiyun 			arc_cont(D_INIT, "S5: ");
308*4882a593Smuzhiyun 		}
309*4882a593Smuzhiyun 		arc_cont(D_INIT, "%Xh ", *port);
310*4882a593Smuzhiyun 
311*4882a593Smuzhiyun 		ioaddr = *port;
312*4882a593Smuzhiyun 		status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun 		if ((status & 0x9D)
315*4882a593Smuzhiyun 		    != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
316*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "(status=%Xh)\n", status);
317*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "S5: ");
318*4882a593Smuzhiyun 			if (BUGLVL(D_INIT_REASONS))
319*4882a593Smuzhiyun 				numprint = 0;
320*4882a593Smuzhiyun 			release_region(*port, ARCNET_TOTAL_SIZE);
321*4882a593Smuzhiyun 			*port-- = ports[--numports];
322*4882a593Smuzhiyun 			continue;
323*4882a593Smuzhiyun 		}
324*4882a593Smuzhiyun 		arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
325*4882a593Smuzhiyun 			    ioaddr, COM9026_REG_W_COMMAND);
326*4882a593Smuzhiyun 		status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
327*4882a593Smuzhiyun 		if (status & RESETflag) {
328*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
329*4882a593Smuzhiyun 				 status);
330*4882a593Smuzhiyun 			arc_cont(D_INIT_REASONS, "S5: ");
331*4882a593Smuzhiyun 			if (BUGLVL(D_INIT_REASONS))
332*4882a593Smuzhiyun 				numprint = 0;
333*4882a593Smuzhiyun 			release_region(*port, ARCNET_TOTAL_SIZE);
334*4882a593Smuzhiyun 			*port-- = ports[--numports];
335*4882a593Smuzhiyun 			continue;
336*4882a593Smuzhiyun 		}
337*4882a593Smuzhiyun 		/* skip this completely if an IRQ was given, because maybe
338*4882a593Smuzhiyun 		 * we're on a machine that locks during autoirq!
339*4882a593Smuzhiyun 		 */
340*4882a593Smuzhiyun 		if (!irq) {
341*4882a593Smuzhiyun 			/* if we do this, we're sure to get an IRQ since the
342*4882a593Smuzhiyun 			 * card has just reset and the NORXflag is on until
343*4882a593Smuzhiyun 			 * we tell it to start receiving.
344*4882a593Smuzhiyun 			 */
345*4882a593Smuzhiyun 			airqmask = probe_irq_on();
346*4882a593Smuzhiyun 			arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
347*4882a593Smuzhiyun 			udelay(1);
348*4882a593Smuzhiyun 			arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
349*4882a593Smuzhiyun 			airq = probe_irq_off(airqmask);
350*4882a593Smuzhiyun 
351*4882a593Smuzhiyun 			if (airq <= 0) {
352*4882a593Smuzhiyun 				arc_cont(D_INIT_REASONS, "(airq=%d)\n", airq);
353*4882a593Smuzhiyun 				arc_cont(D_INIT_REASONS, "S5: ");
354*4882a593Smuzhiyun 				if (BUGLVL(D_INIT_REASONS))
355*4882a593Smuzhiyun 					numprint = 0;
356*4882a593Smuzhiyun 				release_region(*port, ARCNET_TOTAL_SIZE);
357*4882a593Smuzhiyun 				*port-- = ports[--numports];
358*4882a593Smuzhiyun 				continue;
359*4882a593Smuzhiyun 			}
360*4882a593Smuzhiyun 		} else {
361*4882a593Smuzhiyun 			airq = irq;
362*4882a593Smuzhiyun 		}
363*4882a593Smuzhiyun 
364*4882a593Smuzhiyun 		arc_cont(D_INIT, "(%d,", airq);
365*4882a593Smuzhiyun 		openparen = 1;
366*4882a593Smuzhiyun 
367*4882a593Smuzhiyun 		/* Everything seems okay.  But which shmem, if any, puts
368*4882a593Smuzhiyun 		 * back its signature byte when the card is reset?
369*4882a593Smuzhiyun 		 *
370*4882a593Smuzhiyun 		 * If there are multiple cards installed, there might be
371*4882a593Smuzhiyun 		 * multiple shmems still in the list.
372*4882a593Smuzhiyun 		 */
373*4882a593Smuzhiyun #ifdef FAST_PROBE
374*4882a593Smuzhiyun 		if (numports > 1 || numshmems > 1) {
375*4882a593Smuzhiyun 			arcnet_inb(ioaddr, COM9026_REG_R_RESET);
376*4882a593Smuzhiyun 			mdelay(RESETtime);
377*4882a593Smuzhiyun 		} else {
378*4882a593Smuzhiyun 			/* just one shmem and port, assume they match */
379*4882a593Smuzhiyun 			arcnet_writeb(TESTvalue, iomem[0],
380*4882a593Smuzhiyun 				      COM9026_REG_W_INTMASK);
381*4882a593Smuzhiyun 		}
382*4882a593Smuzhiyun #else
383*4882a593Smuzhiyun 		arcnet_inb(ioaddr, COM9026_REG_R_RESET);
384*4882a593Smuzhiyun 		mdelay(RESETtime);
385*4882a593Smuzhiyun #endif
386*4882a593Smuzhiyun 
387*4882a593Smuzhiyun 		for (index = 0; index < numshmems; index++) {
388*4882a593Smuzhiyun 			u_long ptr = shmems[index];
389*4882a593Smuzhiyun 			void __iomem *base = iomem[index];
390*4882a593Smuzhiyun 
391*4882a593Smuzhiyun 			if (arcnet_readb(base, COM9026_REG_R_STATUS) == TESTvalue) {	/* found one */
392*4882a593Smuzhiyun 				arc_cont(D_INIT, "%lXh)\n", *p);
393*4882a593Smuzhiyun 				openparen = 0;
394*4882a593Smuzhiyun 
395*4882a593Smuzhiyun 				/* register the card */
396*4882a593Smuzhiyun 				if (com90xx_found(*port, airq, ptr, base) == 0)
397*4882a593Smuzhiyun 					found = 1;
398*4882a593Smuzhiyun 				numprint = -1;
399*4882a593Smuzhiyun 
400*4882a593Smuzhiyun 				/* remove shmem from the list */
401*4882a593Smuzhiyun 				shmems[index] = shmems[--numshmems];
402*4882a593Smuzhiyun 				iomem[index] = iomem[numshmems];
403*4882a593Smuzhiyun 				break;	/* go to the next I/O port */
404*4882a593Smuzhiyun 			} else {
405*4882a593Smuzhiyun 				arc_cont(D_INIT_REASONS, "%Xh-",
406*4882a593Smuzhiyun 					 arcnet_readb(base, COM9026_REG_R_STATUS));
407*4882a593Smuzhiyun 			}
408*4882a593Smuzhiyun 		}
409*4882a593Smuzhiyun 
410*4882a593Smuzhiyun 		if (openparen) {
411*4882a593Smuzhiyun 			if (BUGLVL(D_INIT))
412*4882a593Smuzhiyun 				pr_cont("no matching shmem)\n");
413*4882a593Smuzhiyun 			if (BUGLVL(D_INIT_REASONS)) {
414*4882a593Smuzhiyun 				pr_cont("S5: ");
415*4882a593Smuzhiyun 				numprint = 0;
416*4882a593Smuzhiyun 			}
417*4882a593Smuzhiyun 		}
418*4882a593Smuzhiyun 		if (!found)
419*4882a593Smuzhiyun 			release_region(*port, ARCNET_TOTAL_SIZE);
420*4882a593Smuzhiyun 		*port-- = ports[--numports];
421*4882a593Smuzhiyun 	}
422*4882a593Smuzhiyun 
423*4882a593Smuzhiyun 	if (BUGLVL(D_INIT_REASONS))
424*4882a593Smuzhiyun 		pr_cont("\n");
425*4882a593Smuzhiyun 
426*4882a593Smuzhiyun 	/* Now put back TESTvalue on all leftover shmems. */
427*4882a593Smuzhiyun 	for (index = 0; index < numshmems; index++) {
428*4882a593Smuzhiyun 		arcnet_writeb(TESTvalue, iomem[index], COM9026_REG_W_INTMASK);
429*4882a593Smuzhiyun 		iounmap(iomem[index]);
430*4882a593Smuzhiyun 		release_mem_region(shmems[index], MIRROR_SIZE);
431*4882a593Smuzhiyun 	}
432*4882a593Smuzhiyun 	kfree(shmems);
433*4882a593Smuzhiyun 	kfree(iomem);
434*4882a593Smuzhiyun }
435*4882a593Smuzhiyun 
check_mirror(unsigned long addr,size_t size)436*4882a593Smuzhiyun static int __init check_mirror(unsigned long addr, size_t size)
437*4882a593Smuzhiyun {
438*4882a593Smuzhiyun 	void __iomem *p;
439*4882a593Smuzhiyun 	int res = -1;
440*4882a593Smuzhiyun 
441*4882a593Smuzhiyun 	if (!request_mem_region(addr, size, "arcnet (90xx)"))
442*4882a593Smuzhiyun 		return -1;
443*4882a593Smuzhiyun 
444*4882a593Smuzhiyun 	p = ioremap(addr, size);
445*4882a593Smuzhiyun 	if (p) {
446*4882a593Smuzhiyun 		if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
447*4882a593Smuzhiyun 			res = 1;
448*4882a593Smuzhiyun 		else
449*4882a593Smuzhiyun 			res = 0;
450*4882a593Smuzhiyun 		iounmap(p);
451*4882a593Smuzhiyun 	}
452*4882a593Smuzhiyun 
453*4882a593Smuzhiyun 	release_mem_region(addr, size);
454*4882a593Smuzhiyun 	return res;
455*4882a593Smuzhiyun }
456*4882a593Smuzhiyun 
457*4882a593Smuzhiyun /* Set up the struct net_device associated with this card.  Called after
458*4882a593Smuzhiyun  * probing succeeds.
459*4882a593Smuzhiyun  */
com90xx_found(int ioaddr,int airq,u_long shmem,void __iomem * p)460*4882a593Smuzhiyun static int __init com90xx_found(int ioaddr, int airq, u_long shmem,
461*4882a593Smuzhiyun 				void __iomem *p)
462*4882a593Smuzhiyun {
463*4882a593Smuzhiyun 	struct net_device *dev = NULL;
464*4882a593Smuzhiyun 	struct arcnet_local *lp;
465*4882a593Smuzhiyun 	u_long first_mirror, last_mirror;
466*4882a593Smuzhiyun 	int mirror_size;
467*4882a593Smuzhiyun 
468*4882a593Smuzhiyun 	/* allocate struct net_device */
469*4882a593Smuzhiyun 	dev = alloc_arcdev(device);
470*4882a593Smuzhiyun 	if (!dev) {
471*4882a593Smuzhiyun 		arc_cont(D_NORMAL, "com90xx: Can't allocate device!\n");
472*4882a593Smuzhiyun 		iounmap(p);
473*4882a593Smuzhiyun 		release_mem_region(shmem, MIRROR_SIZE);
474*4882a593Smuzhiyun 		return -ENOMEM;
475*4882a593Smuzhiyun 	}
476*4882a593Smuzhiyun 	lp = netdev_priv(dev);
477*4882a593Smuzhiyun 	/* find the real shared memory start/end points, including mirrors */
478*4882a593Smuzhiyun 
479*4882a593Smuzhiyun 	/* guess the actual size of one "memory mirror" - the number of
480*4882a593Smuzhiyun 	 * bytes between copies of the shared memory.  On most cards, it's
481*4882a593Smuzhiyun 	 * 2k (or there are no mirrors at all) but on some, it's 4k.
482*4882a593Smuzhiyun 	 */
483*4882a593Smuzhiyun 	mirror_size = MIRROR_SIZE;
484*4882a593Smuzhiyun 	if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue &&
485*4882a593Smuzhiyun 	    check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
486*4882a593Smuzhiyun 	    check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
487*4882a593Smuzhiyun 		mirror_size = 2 * MIRROR_SIZE;
488*4882a593Smuzhiyun 
489*4882a593Smuzhiyun 	first_mirror = shmem - mirror_size;
490*4882a593Smuzhiyun 	while (check_mirror(first_mirror, mirror_size) == 1)
491*4882a593Smuzhiyun 		first_mirror -= mirror_size;
492*4882a593Smuzhiyun 	first_mirror += mirror_size;
493*4882a593Smuzhiyun 
494*4882a593Smuzhiyun 	last_mirror = shmem + mirror_size;
495*4882a593Smuzhiyun 	while (check_mirror(last_mirror, mirror_size) == 1)
496*4882a593Smuzhiyun 		last_mirror += mirror_size;
497*4882a593Smuzhiyun 	last_mirror -= mirror_size;
498*4882a593Smuzhiyun 
499*4882a593Smuzhiyun 	dev->mem_start = first_mirror;
500*4882a593Smuzhiyun 	dev->mem_end = last_mirror + MIRROR_SIZE - 1;
501*4882a593Smuzhiyun 
502*4882a593Smuzhiyun 	iounmap(p);
503*4882a593Smuzhiyun 	release_mem_region(shmem, MIRROR_SIZE);
504*4882a593Smuzhiyun 
505*4882a593Smuzhiyun 	if (!request_mem_region(dev->mem_start,
506*4882a593Smuzhiyun 				dev->mem_end - dev->mem_start + 1,
507*4882a593Smuzhiyun 				"arcnet (90xx)"))
508*4882a593Smuzhiyun 		goto err_free_dev;
509*4882a593Smuzhiyun 
510*4882a593Smuzhiyun 	/* reserve the irq */
511*4882a593Smuzhiyun 	if (request_irq(airq, arcnet_interrupt, 0, "arcnet (90xx)", dev)) {
512*4882a593Smuzhiyun 		arc_printk(D_NORMAL, dev, "Can't get IRQ %d!\n", airq);
513*4882a593Smuzhiyun 		goto err_release_mem;
514*4882a593Smuzhiyun 	}
515*4882a593Smuzhiyun 	dev->irq = airq;
516*4882a593Smuzhiyun 
517*4882a593Smuzhiyun 	/* Initialize the rest of the device structure. */
518*4882a593Smuzhiyun 	lp->card_name = "COM90xx";
519*4882a593Smuzhiyun 	lp->hw.command = com90xx_command;
520*4882a593Smuzhiyun 	lp->hw.status = com90xx_status;
521*4882a593Smuzhiyun 	lp->hw.intmask = com90xx_setmask;
522*4882a593Smuzhiyun 	lp->hw.reset = com90xx_reset;
523*4882a593Smuzhiyun 	lp->hw.owner = THIS_MODULE;
524*4882a593Smuzhiyun 	lp->hw.copy_to_card = com90xx_copy_to_card;
525*4882a593Smuzhiyun 	lp->hw.copy_from_card = com90xx_copy_from_card;
526*4882a593Smuzhiyun 	lp->mem_start = ioremap(dev->mem_start,
527*4882a593Smuzhiyun 				dev->mem_end - dev->mem_start + 1);
528*4882a593Smuzhiyun 	if (!lp->mem_start) {
529*4882a593Smuzhiyun 		arc_printk(D_NORMAL, dev, "Can't remap device memory!\n");
530*4882a593Smuzhiyun 		goto err_free_irq;
531*4882a593Smuzhiyun 	}
532*4882a593Smuzhiyun 
533*4882a593Smuzhiyun 	/* get and check the station ID from offset 1 in shmem */
534*4882a593Smuzhiyun 	dev->dev_addr[0] = arcnet_readb(lp->mem_start, COM9026_REG_R_STATION);
535*4882a593Smuzhiyun 
536*4882a593Smuzhiyun 	dev->base_addr = ioaddr;
537*4882a593Smuzhiyun 
538*4882a593Smuzhiyun 	arc_printk(D_NORMAL, dev, "COM90xx station %02Xh found at %03lXh, IRQ %d, ShMem %lXh (%ld*%xh).\n",
539*4882a593Smuzhiyun 		   dev->dev_addr[0],
540*4882a593Smuzhiyun 		   dev->base_addr, dev->irq, dev->mem_start,
541*4882a593Smuzhiyun 		   (dev->mem_end - dev->mem_start + 1) / mirror_size,
542*4882a593Smuzhiyun 		   mirror_size);
543*4882a593Smuzhiyun 
544*4882a593Smuzhiyun 	if (register_netdev(dev))
545*4882a593Smuzhiyun 		goto err_unmap;
546*4882a593Smuzhiyun 
547*4882a593Smuzhiyun 	cards[numcards++] = dev;
548*4882a593Smuzhiyun 	return 0;
549*4882a593Smuzhiyun 
550*4882a593Smuzhiyun err_unmap:
551*4882a593Smuzhiyun 	iounmap(lp->mem_start);
552*4882a593Smuzhiyun err_free_irq:
553*4882a593Smuzhiyun 	free_irq(dev->irq, dev);
554*4882a593Smuzhiyun err_release_mem:
555*4882a593Smuzhiyun 	release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
556*4882a593Smuzhiyun err_free_dev:
557*4882a593Smuzhiyun 	free_arcdev(dev);
558*4882a593Smuzhiyun 	return -EIO;
559*4882a593Smuzhiyun }
560*4882a593Smuzhiyun 
com90xx_command(struct net_device * dev,int cmd)561*4882a593Smuzhiyun static void com90xx_command(struct net_device *dev, int cmd)
562*4882a593Smuzhiyun {
563*4882a593Smuzhiyun 	short ioaddr = dev->base_addr;
564*4882a593Smuzhiyun 
565*4882a593Smuzhiyun 	arcnet_outb(cmd, ioaddr, COM9026_REG_W_COMMAND);
566*4882a593Smuzhiyun }
567*4882a593Smuzhiyun 
com90xx_status(struct net_device * dev)568*4882a593Smuzhiyun static int com90xx_status(struct net_device *dev)
569*4882a593Smuzhiyun {
570*4882a593Smuzhiyun 	short ioaddr = dev->base_addr;
571*4882a593Smuzhiyun 
572*4882a593Smuzhiyun 	return arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
573*4882a593Smuzhiyun }
574*4882a593Smuzhiyun 
com90xx_setmask(struct net_device * dev,int mask)575*4882a593Smuzhiyun static void com90xx_setmask(struct net_device *dev, int mask)
576*4882a593Smuzhiyun {
577*4882a593Smuzhiyun 	short ioaddr = dev->base_addr;
578*4882a593Smuzhiyun 
579*4882a593Smuzhiyun 	arcnet_outb(mask, ioaddr, COM9026_REG_W_INTMASK);
580*4882a593Smuzhiyun }
581*4882a593Smuzhiyun 
582*4882a593Smuzhiyun /* Do a hardware reset on the card, and set up necessary registers.
583*4882a593Smuzhiyun  *
584*4882a593Smuzhiyun  * This should be called as little as possible, because it disrupts the
585*4882a593Smuzhiyun  * token on the network (causes a RECON) and requires a significant delay.
586*4882a593Smuzhiyun  *
587*4882a593Smuzhiyun  * However, it does make sure the card is in a defined state.
588*4882a593Smuzhiyun  */
com90xx_reset(struct net_device * dev,int really_reset)589*4882a593Smuzhiyun static int com90xx_reset(struct net_device *dev, int really_reset)
590*4882a593Smuzhiyun {
591*4882a593Smuzhiyun 	struct arcnet_local *lp = netdev_priv(dev);
592*4882a593Smuzhiyun 	short ioaddr = dev->base_addr;
593*4882a593Smuzhiyun 
594*4882a593Smuzhiyun 	arc_printk(D_INIT, dev, "Resetting (status=%02Xh)\n",
595*4882a593Smuzhiyun 		   arcnet_inb(ioaddr, COM9026_REG_R_STATUS));
596*4882a593Smuzhiyun 
597*4882a593Smuzhiyun 	if (really_reset) {
598*4882a593Smuzhiyun 		/* reset the card */
599*4882a593Smuzhiyun 		arcnet_inb(ioaddr, COM9026_REG_R_RESET);
600*4882a593Smuzhiyun 		mdelay(RESETtime);
601*4882a593Smuzhiyun 	}
602*4882a593Smuzhiyun 	/* clear flags & end reset */
603*4882a593Smuzhiyun 	arcnet_outb(CFLAGScmd | RESETclear, ioaddr, COM9026_REG_W_COMMAND);
604*4882a593Smuzhiyun 	arcnet_outb(CFLAGScmd | CONFIGclear, ioaddr, COM9026_REG_W_COMMAND);
605*4882a593Smuzhiyun 
606*4882a593Smuzhiyun #if 0
607*4882a593Smuzhiyun 	/* don't do this until we verify that it doesn't hurt older cards! */
608*4882a593Smuzhiyun 	arcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) | ENABLE16flag,
609*4882a593Smuzhiyun 		    ioaddr, COM9026_REG_RW_CONFIG);
610*4882a593Smuzhiyun #endif
611*4882a593Smuzhiyun 
612*4882a593Smuzhiyun 	/* verify that the ARCnet signature byte is present */
613*4882a593Smuzhiyun 	if (arcnet_readb(lp->mem_start, COM9026_REG_R_STATUS) != TESTvalue) {
614*4882a593Smuzhiyun 		if (really_reset)
615*4882a593Smuzhiyun 			arc_printk(D_NORMAL, dev, "reset failed: TESTvalue not present.\n");
616*4882a593Smuzhiyun 		return 1;
617*4882a593Smuzhiyun 	}
618*4882a593Smuzhiyun 	/* enable extended (512-byte) packets */
619*4882a593Smuzhiyun 	arcnet_outb(CONFIGcmd | EXTconf, ioaddr, COM9026_REG_W_COMMAND);
620*4882a593Smuzhiyun 
621*4882a593Smuzhiyun 	/* clean out all the memory to make debugging make more sense :) */
622*4882a593Smuzhiyun 	if (BUGLVL(D_DURING))
623*4882a593Smuzhiyun 		memset_io(lp->mem_start, 0x42, 2048);
624*4882a593Smuzhiyun 
625*4882a593Smuzhiyun 	/* done!  return success. */
626*4882a593Smuzhiyun 	return 0;
627*4882a593Smuzhiyun }
628*4882a593Smuzhiyun 
com90xx_copy_to_card(struct net_device * dev,int bufnum,int offset,void * buf,int count)629*4882a593Smuzhiyun static void com90xx_copy_to_card(struct net_device *dev, int bufnum,
630*4882a593Smuzhiyun 				 int offset, void *buf, int count)
631*4882a593Smuzhiyun {
632*4882a593Smuzhiyun 	struct arcnet_local *lp = netdev_priv(dev);
633*4882a593Smuzhiyun 	void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
634*4882a593Smuzhiyun 
635*4882a593Smuzhiyun 	TIME(dev, "memcpy_toio", count, memcpy_toio(memaddr, buf, count));
636*4882a593Smuzhiyun }
637*4882a593Smuzhiyun 
com90xx_copy_from_card(struct net_device * dev,int bufnum,int offset,void * buf,int count)638*4882a593Smuzhiyun static void com90xx_copy_from_card(struct net_device *dev, int bufnum,
639*4882a593Smuzhiyun 				   int offset, void *buf, int count)
640*4882a593Smuzhiyun {
641*4882a593Smuzhiyun 	struct arcnet_local *lp = netdev_priv(dev);
642*4882a593Smuzhiyun 	void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
643*4882a593Smuzhiyun 
644*4882a593Smuzhiyun 	TIME(dev, "memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
645*4882a593Smuzhiyun }
646*4882a593Smuzhiyun 
647*4882a593Smuzhiyun MODULE_LICENSE("GPL");
648*4882a593Smuzhiyun 
com90xx_init(void)649*4882a593Smuzhiyun static int __init com90xx_init(void)
650*4882a593Smuzhiyun {
651*4882a593Smuzhiyun 	if (irq == 2)
652*4882a593Smuzhiyun 		irq = 9;
653*4882a593Smuzhiyun 	com90xx_probe();
654*4882a593Smuzhiyun 	if (!numcards)
655*4882a593Smuzhiyun 		return -EIO;
656*4882a593Smuzhiyun 	return 0;
657*4882a593Smuzhiyun }
658*4882a593Smuzhiyun 
com90xx_exit(void)659*4882a593Smuzhiyun static void __exit com90xx_exit(void)
660*4882a593Smuzhiyun {
661*4882a593Smuzhiyun 	struct net_device *dev;
662*4882a593Smuzhiyun 	struct arcnet_local *lp;
663*4882a593Smuzhiyun 	int count;
664*4882a593Smuzhiyun 
665*4882a593Smuzhiyun 	for (count = 0; count < numcards; count++) {
666*4882a593Smuzhiyun 		dev = cards[count];
667*4882a593Smuzhiyun 		lp = netdev_priv(dev);
668*4882a593Smuzhiyun 
669*4882a593Smuzhiyun 		unregister_netdev(dev);
670*4882a593Smuzhiyun 		free_irq(dev->irq, dev);
671*4882a593Smuzhiyun 		iounmap(lp->mem_start);
672*4882a593Smuzhiyun 		release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
673*4882a593Smuzhiyun 		release_mem_region(dev->mem_start,
674*4882a593Smuzhiyun 				   dev->mem_end - dev->mem_start + 1);
675*4882a593Smuzhiyun 		free_arcdev(dev);
676*4882a593Smuzhiyun 	}
677*4882a593Smuzhiyun }
678*4882a593Smuzhiyun 
679*4882a593Smuzhiyun module_init(com90xx_init);
680*4882a593Smuzhiyun module_exit(com90xx_exit);
681*4882a593Smuzhiyun 
682*4882a593Smuzhiyun #ifndef MODULE
com90xx_setup(char * s)683*4882a593Smuzhiyun static int __init com90xx_setup(char *s)
684*4882a593Smuzhiyun {
685*4882a593Smuzhiyun 	int ints[8];
686*4882a593Smuzhiyun 
687*4882a593Smuzhiyun 	s = get_options(s, 8, ints);
688*4882a593Smuzhiyun 	if (!ints[0] && !*s) {
689*4882a593Smuzhiyun 		pr_notice("Disabled\n");
690*4882a593Smuzhiyun 		return 1;
691*4882a593Smuzhiyun 	}
692*4882a593Smuzhiyun 
693*4882a593Smuzhiyun 	switch (ints[0]) {
694*4882a593Smuzhiyun 	default:		/* ERROR */
695*4882a593Smuzhiyun 		pr_err("Too many arguments\n");
696*4882a593Smuzhiyun 		fallthrough;
697*4882a593Smuzhiyun 	case 3:		/* Mem address */
698*4882a593Smuzhiyun 		shmem = ints[3];
699*4882a593Smuzhiyun 		fallthrough;
700*4882a593Smuzhiyun 	case 2:		/* IRQ */
701*4882a593Smuzhiyun 		irq = ints[2];
702*4882a593Smuzhiyun 		fallthrough;
703*4882a593Smuzhiyun 	case 1:		/* IO address */
704*4882a593Smuzhiyun 		io = ints[1];
705*4882a593Smuzhiyun 	}
706*4882a593Smuzhiyun 
707*4882a593Smuzhiyun 	if (*s)
708*4882a593Smuzhiyun 		snprintf(device, sizeof(device), "%s", s);
709*4882a593Smuzhiyun 
710*4882a593Smuzhiyun 	return 1;
711*4882a593Smuzhiyun }
712*4882a593Smuzhiyun 
713*4882a593Smuzhiyun __setup("com90xx=", com90xx_setup);
714*4882a593Smuzhiyun #endif
715