aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/arcnet
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/arcnet')
-rw-r--r--drivers/net/arcnet/arc-rimi.c68
-rw-r--r--drivers/net/arcnet/com90xx.c132
2 files changed, 143 insertions, 57 deletions
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 38c3f033f739..8c8d6c453c45 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -97,25 +97,44 @@ static int __init arcrimi_probe(struct net_device *dev)
97 "must specify the shmem and irq!\n"); 97 "must specify the shmem and irq!\n");
98 return -ENODEV; 98 return -ENODEV;
99 } 99 }
100 if (dev->dev_addr[0] == 0) {
101 BUGMSG(D_NORMAL, "You need to specify your card's station "
102 "ID!\n");
103 return -ENODEV;
104 }
100 /* 105 /*
101 * Grab the memory region at mem_start for BUFFER_SIZE bytes. 106 * Grab the memory region at mem_start for MIRROR_SIZE bytes.
102 * Later in arcrimi_found() the real size will be determined 107 * Later in arcrimi_found() the real size will be determined
103 * and this reserve will be released and the correct size 108 * and this reserve will be released and the correct size
104 * will be taken. 109 * will be taken.
105 */ 110 */
106 if (!request_mem_region(dev->mem_start, BUFFER_SIZE, "arcnet (90xx)")) { 111 if (!request_mem_region(dev->mem_start, MIRROR_SIZE, "arcnet (90xx)")) {
107 BUGMSG(D_NORMAL, "Card memory already allocated\n"); 112 BUGMSG(D_NORMAL, "Card memory already allocated\n");
108 return -ENODEV; 113 return -ENODEV;
109 } 114 }
110 if (dev->dev_addr[0] == 0) {
111 release_mem_region(dev->mem_start, BUFFER_SIZE);
112 BUGMSG(D_NORMAL, "You need to specify your card's station "
113 "ID!\n");
114 return -ENODEV;
115 }
116 return arcrimi_found(dev); 115 return arcrimi_found(dev);
117} 116}
118 117
118static int check_mirror(unsigned long addr, size_t size)
119{
120 void __iomem *p;
121 int res = -1;
122
123 if (!request_mem_region(addr, size, "arcnet (90xx)"))
124 return -1;
125
126 p = ioremap(addr, size);
127 if (p) {
128 if (readb(p) == TESTvalue)
129 res = 1;
130 else
131 res = 0;
132 iounmap(p);
133 }
134
135 release_mem_region(addr, size);
136 return res;
137}
119 138
120/* 139/*
121 * Set up the struct net_device associated with this card. Called after 140 * Set up the struct net_device associated with this card. Called after
@@ -125,19 +144,28 @@ static int __init arcrimi_found(struct net_device *dev)
125{ 144{
126 struct arcnet_local *lp; 145 struct arcnet_local *lp;
127 unsigned long first_mirror, last_mirror, shmem; 146 unsigned long first_mirror, last_mirror, shmem;
147 void __iomem *p;
128 int mirror_size; 148 int mirror_size;
129 int err; 149 int err;
130 150
151 p = ioremap(dev->mem_start, MIRROR_SIZE);
152 if (!p) {
153 release_mem_region(dev->mem_start, MIRROR_SIZE);
154 BUGMSG(D_NORMAL, "Can't ioremap\n");
155 return -ENODEV;
156 }
157
131 /* reserve the irq */ 158 /* reserve the irq */
132 if (request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet (RIM I)", dev)) { 159 if (request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet (RIM I)", dev)) {
133 release_mem_region(dev->mem_start, BUFFER_SIZE); 160 iounmap(p);
161 release_mem_region(dev->mem_start, MIRROR_SIZE);
134 BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq); 162 BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
135 return -ENODEV; 163 return -ENODEV;
136 } 164 }
137 165
138 shmem = dev->mem_start; 166 shmem = dev->mem_start;
139 isa_writeb(TESTvalue, shmem); 167 writeb(TESTvalue, p);
140 isa_writeb(dev->dev_addr[0], shmem + 1); /* actually the node ID */ 168 writeb(dev->dev_addr[0], p + 1); /* actually the node ID */
141 169
142 /* find the real shared memory start/end points, including mirrors */ 170 /* find the real shared memory start/end points, including mirrors */
143 171
@@ -146,17 +174,18 @@ static int __init arcrimi_found(struct net_device *dev)
146 * 2k (or there are no mirrors at all) but on some, it's 4k. 174 * 2k (or there are no mirrors at all) but on some, it's 4k.
147 */ 175 */
148 mirror_size = MIRROR_SIZE; 176 mirror_size = MIRROR_SIZE;
149 if (isa_readb(shmem) == TESTvalue 177 if (readb(p) == TESTvalue
150 && isa_readb(shmem - mirror_size) != TESTvalue 178 && check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0
151 && isa_readb(shmem - 2 * mirror_size) == TESTvalue) 179 && check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
152 mirror_size *= 2; 180 mirror_size = 2 * MIRROR_SIZE;
153 181
154 first_mirror = last_mirror = shmem; 182 first_mirror = shmem - mirror_size;
155 while (isa_readb(first_mirror) == TESTvalue) 183 while (check_mirror(first_mirror, mirror_size) == 1)
156 first_mirror -= mirror_size; 184 first_mirror -= mirror_size;
157 first_mirror += mirror_size; 185 first_mirror += mirror_size;
158 186
159 while (isa_readb(last_mirror) == TESTvalue) 187 last_mirror = shmem + mirror_size;
188 while (check_mirror(last_mirror, mirror_size) == 1)
160 last_mirror += mirror_size; 189 last_mirror += mirror_size;
161 last_mirror -= mirror_size; 190 last_mirror -= mirror_size;
162 191
@@ -181,7 +210,8 @@ static int __init arcrimi_found(struct net_device *dev)
181 * with the correct size. There is a VERY slim chance this could 210 * with the correct size. There is a VERY slim chance this could
182 * fail. 211 * fail.
183 */ 212 */
184 release_mem_region(shmem, BUFFER_SIZE); 213 iounmap(p);
214 release_mem_region(shmem, MIRROR_SIZE);
185 if (!request_mem_region(dev->mem_start, 215 if (!request_mem_region(dev->mem_start,
186 dev->mem_end - dev->mem_start + 1, 216 dev->mem_end - dev->mem_start + 1,
187 "arcnet (90xx)")) { 217 "arcnet (90xx)")) {
diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index 6c2c9b9ac6db..43150b2bd13f 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -53,7 +53,7 @@
53 53
54 54
55/* Internal function declarations */ 55/* Internal function declarations */
56static int com90xx_found(int ioaddr, int airq, u_long shmem); 56static int com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *);
57static void com90xx_command(struct net_device *dev, int command); 57static void com90xx_command(struct net_device *dev, int command);
58static int com90xx_status(struct net_device *dev); 58static int com90xx_status(struct net_device *dev);
59static void com90xx_setmask(struct net_device *dev, int mask); 59static void com90xx_setmask(struct net_device *dev, int mask);
@@ -116,14 +116,26 @@ static void __init com90xx_probe(void)
116 unsigned long airqmask; 116 unsigned long airqmask;
117 int ports[(0x3f0 - 0x200) / 16 + 1] = 117 int ports[(0x3f0 - 0x200) / 16 + 1] =
118 {0}; 118 {0};
119 u_long shmems[(0xFF800 - 0xA0000) / 2048 + 1] = 119 unsigned long *shmems;
120 {0}; 120 void __iomem **iomem;
121 int numports, numshmems, *port; 121 int numports, numshmems, *port;
122 u_long *p; 122 u_long *p;
123 int index;
123 124
124 if (!io && !irq && !shmem && !*device && com90xx_skip_probe) 125 if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
125 return; 126 return;
126 127
128 shmems = kzalloc(((0x10000-0xa0000) / 0x800) * sizeof(unsigned long),
129 GFP_KERNEL);
130 if (!shmems)
131 return;
132 iomem = kzalloc(((0x10000-0xa0000) / 0x800) * sizeof(void __iomem *),
133 GFP_KERNEL);
134 if (!iomem) {
135 kfree(shmems);
136 return;
137 }
138
127 BUGLVL(D_NORMAL) printk(VERSION); 139 BUGLVL(D_NORMAL) printk(VERSION);
128 140
129 /* set up the arrays where we'll store the possible probe addresses */ 141 /* set up the arrays where we'll store the possible probe addresses */
@@ -179,6 +191,8 @@ static void __init com90xx_probe(void)
179 191
180 if (!numports) { 192 if (!numports) {
181 BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n"); 193 BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n");
194 kfree(shmems);
195 kfree(iomem);
182 return; 196 return;
183 } 197 }
184 /* Stage 2: we have now reset any possible ARCnet cards, so we can't 198 /* Stage 2: we have now reset any possible ARCnet cards, so we can't
@@ -202,8 +216,8 @@ static void __init com90xx_probe(void)
202 * 0xD1 byte in the right place, or are read-only. 216 * 0xD1 byte in the right place, or are read-only.
203 */ 217 */
204 numprint = -1; 218 numprint = -1;
205 for (p = &shmems[0]; p < shmems + numshmems; p++) { 219 for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) {
206 u_long ptr = *p; 220 void __iomem *base;
207 221
208 numprint++; 222 numprint++;
209 numprint %= 8; 223 numprint %= 8;
@@ -213,38 +227,49 @@ static void __init com90xx_probe(void)
213 } 227 }
214 BUGMSG2(D_INIT, "%lXh ", *p); 228 BUGMSG2(D_INIT, "%lXh ", *p);
215 229
216 if (!request_mem_region(*p, BUFFER_SIZE, "arcnet (90xx)")) { 230 if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) {
217 BUGMSG2(D_INIT_REASONS, "(request_mem_region)\n"); 231 BUGMSG2(D_INIT_REASONS, "(request_mem_region)\n");
218 BUGMSG2(D_INIT_REASONS, "Stage 3: "); 232 BUGMSG2(D_INIT_REASONS, "Stage 3: ");
219 BUGLVL(D_INIT_REASONS) numprint = 0; 233 BUGLVL(D_INIT_REASONS) numprint = 0;
220 *p-- = shmems[--numshmems]; 234 goto out;
221 continue; 235 }
236 base = ioremap(*p, MIRROR_SIZE);
237 if (!base) {
238 BUGMSG2(D_INIT_REASONS, "(ioremap)\n");
239 BUGMSG2(D_INIT_REASONS, "Stage 3: ");
240 BUGLVL(D_INIT_REASONS) numprint = 0;
241 goto out1;
222 } 242 }
223 if (isa_readb(ptr) != TESTvalue) { 243 if (readb(base) != TESTvalue) {
224 BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n", 244 BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
225 isa_readb(ptr), TESTvalue); 245 readb(base), TESTvalue);
226 BUGMSG2(D_INIT_REASONS, "S3: "); 246 BUGMSG2(D_INIT_REASONS, "S3: ");
227 BUGLVL(D_INIT_REASONS) numprint = 0; 247 BUGLVL(D_INIT_REASONS) numprint = 0;
228 release_mem_region(*p, BUFFER_SIZE); 248 goto out2;
229 *p-- = shmems[--numshmems];
230 continue;
231 } 249 }
232 /* By writing 0x42 to the TESTvalue location, we also make 250 /* By writing 0x42 to the TESTvalue location, we also make
233 * sure no "mirror" shmem areas show up - if they occur 251 * sure no "mirror" shmem areas show up - if they occur
234 * in another pass through this loop, they will be discarded 252 * in another pass through this loop, they will be discarded
235 * because *cptr != TESTvalue. 253 * because *cptr != TESTvalue.
236 */ 254 */
237 isa_writeb(0x42, ptr); 255 writeb(0x42, base);
238 if (isa_readb(ptr) != 0x42) { 256 if (readb(base) != 0x42) {
239 BUGMSG2(D_INIT_REASONS, "(read only)\n"); 257 BUGMSG2(D_INIT_REASONS, "(read only)\n");
240 BUGMSG2(D_INIT_REASONS, "S3: "); 258 BUGMSG2(D_INIT_REASONS, "S3: ");
241 release_mem_region(*p, BUFFER_SIZE); 259 goto out2;
242 *p-- = shmems[--numshmems];
243 continue;
244 } 260 }
245 BUGMSG2(D_INIT_REASONS, "\n"); 261 BUGMSG2(D_INIT_REASONS, "\n");
246 BUGMSG2(D_INIT_REASONS, "S3: "); 262 BUGMSG2(D_INIT_REASONS, "S3: ");
247 BUGLVL(D_INIT_REASONS) numprint = 0; 263 BUGLVL(D_INIT_REASONS) numprint = 0;
264 iomem[index] = base;
265 continue;
266 out2:
267 iounmap(base);
268 out1:
269 release_mem_region(*p, MIRROR_SIZE);
270 out:
271 *p-- = shmems[--numshmems];
272 index--;
248 } 273 }
249 BUGMSG2(D_INIT, "\n"); 274 BUGMSG2(D_INIT, "\n");
250 275
@@ -252,6 +277,8 @@ static void __init com90xx_probe(void)
252 BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n"); 277 BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n");
253 for (port = &ports[0]; port < ports + numports; port++) 278 for (port = &ports[0]; port < ports + numports; port++)
254 release_region(*port, ARCNET_TOTAL_SIZE); 279 release_region(*port, ARCNET_TOTAL_SIZE);
280 kfree(shmems);
281 kfree(iomem);
255 return; 282 return;
256 } 283 }
257 /* Stage 4: something of a dummy, to report the shmems that are 284 /* Stage 4: something of a dummy, to report the shmems that are
@@ -351,30 +378,32 @@ static void __init com90xx_probe(void)
351 mdelay(RESETtime); 378 mdelay(RESETtime);
352 } else { 379 } else {
353 /* just one shmem and port, assume they match */ 380 /* just one shmem and port, assume they match */
354 isa_writeb(TESTvalue, shmems[0]); 381 writeb(TESTvalue, iomem[0]);
355 } 382 }
356#else 383#else
357 inb(_RESET); 384 inb(_RESET);
358 mdelay(RESETtime); 385 mdelay(RESETtime);
359#endif 386#endif
360 387
361 for (p = &shmems[0]; p < shmems + numshmems; p++) { 388 for (index = 0; index < numshmems; index++) {
362 u_long ptr = *p; 389 u_long ptr = shmems[index];
390 void __iomem *base = iomem[index];
363 391
364 if (isa_readb(ptr) == TESTvalue) { /* found one */ 392 if (readb(base) == TESTvalue) { /* found one */
365 BUGMSG2(D_INIT, "%lXh)\n", *p); 393 BUGMSG2(D_INIT, "%lXh)\n", *p);
366 openparen = 0; 394 openparen = 0;
367 395
368 /* register the card */ 396 /* register the card */
369 if (com90xx_found(*port, airq, *p) == 0) 397 if (com90xx_found(*port, airq, ptr, base) == 0)
370 found = 1; 398 found = 1;
371 numprint = -1; 399 numprint = -1;
372 400
373 /* remove shmem from the list */ 401 /* remove shmem from the list */
374 *p = shmems[--numshmems]; 402 shmems[index] = shmems[--numshmems];
403 iomem[index] = iomem[numshmems];
375 break; /* go to the next I/O port */ 404 break; /* go to the next I/O port */
376 } else { 405 } else {
377 BUGMSG2(D_INIT_REASONS, "%Xh-", isa_readb(ptr)); 406 BUGMSG2(D_INIT_REASONS, "%Xh-", readb(base));
378 } 407 }
379 } 408 }
380 409
@@ -391,17 +420,40 @@ static void __init com90xx_probe(void)
391 BUGLVL(D_INIT_REASONS) printk("\n"); 420 BUGLVL(D_INIT_REASONS) printk("\n");
392 421
393 /* Now put back TESTvalue on all leftover shmems. */ 422 /* Now put back TESTvalue on all leftover shmems. */
394 for (p = &shmems[0]; p < shmems + numshmems; p++) { 423 for (index = 0; index < numshmems; index++) {
395 isa_writeb(TESTvalue, *p); 424 writeb(TESTvalue, iomem[index]);
396 release_mem_region(*p, BUFFER_SIZE); 425 iounmap(iomem[index]);
426 release_mem_region(shmems[index], MIRROR_SIZE);
397 } 427 }
428 kfree(shmems);
429 kfree(iomem);
398} 430}
399 431
432static int check_mirror(unsigned long addr, size_t size)
433{
434 void __iomem *p;
435 int res = -1;
436
437 if (!request_mem_region(addr, size, "arcnet (90xx)"))
438 return -1;
439
440 p = ioremap(addr, size);
441 if (p) {
442 if (readb(p) == TESTvalue)
443 res = 1;
444 else
445 res = 0;
446 iounmap(p);
447 }
448
449 release_mem_region(addr, size);
450 return res;
451}
400 452
401/* Set up the struct net_device associated with this card. Called after 453/* Set up the struct net_device associated with this card. Called after
402 * probing succeeds. 454 * probing succeeds.
403 */ 455 */
404static int __init com90xx_found(int ioaddr, int airq, u_long shmem) 456static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *p)
405{ 457{
406 struct net_device *dev = NULL; 458 struct net_device *dev = NULL;
407 struct arcnet_local *lp; 459 struct arcnet_local *lp;
@@ -412,7 +464,8 @@ static int __init com90xx_found(int ioaddr, int airq, u_long shmem)
412 dev = alloc_arcdev(device); 464 dev = alloc_arcdev(device);
413 if (!dev) { 465 if (!dev) {
414 BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n"); 466 BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n");
415 release_mem_region(shmem, BUFFER_SIZE); 467 iounmap(p);
468 release_mem_region(shmem, MIRROR_SIZE);
416 return -ENOMEM; 469 return -ENOMEM;
417 } 470 }
418 lp = dev->priv; 471 lp = dev->priv;
@@ -423,24 +476,27 @@ static int __init com90xx_found(int ioaddr, int airq, u_long shmem)
423 * 2k (or there are no mirrors at all) but on some, it's 4k. 476 * 2k (or there are no mirrors at all) but on some, it's 4k.
424 */ 477 */
425 mirror_size = MIRROR_SIZE; 478 mirror_size = MIRROR_SIZE;
426 if (isa_readb(shmem) == TESTvalue 479 if (readb(p) == TESTvalue &&
427 && isa_readb(shmem - mirror_size) != TESTvalue 480 check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
428 && isa_readb(shmem - 2 * mirror_size) == TESTvalue) 481 check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
429 mirror_size *= 2; 482 mirror_size = 2 * MIRROR_SIZE;
430 483
431 first_mirror = last_mirror = shmem; 484 first_mirror = shmem - mirror_size;
432 while (isa_readb(first_mirror) == TESTvalue) 485 while (check_mirror(first_mirror, mirror_size) == 1)
433 first_mirror -= mirror_size; 486 first_mirror -= mirror_size;
434 first_mirror += mirror_size; 487 first_mirror += mirror_size;
435 488
436 while (isa_readb(last_mirror) == TESTvalue) 489 last_mirror = shmem + mirror_size;
490 while (check_mirror(last_mirror, mirror_size) == 1)
437 last_mirror += mirror_size; 491 last_mirror += mirror_size;
438 last_mirror -= mirror_size; 492 last_mirror -= mirror_size;
439 493
440 dev->mem_start = first_mirror; 494 dev->mem_start = first_mirror;
441 dev->mem_end = last_mirror + MIRROR_SIZE - 1; 495 dev->mem_end = last_mirror + MIRROR_SIZE - 1;
442 496
443 release_mem_region(shmem, BUFFER_SIZE); 497 iounmap(p);
498 release_mem_region(shmem, MIRROR_SIZE);
499
444 if (!request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)")) 500 if (!request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)"))
445 goto err_free_dev; 501 goto err_free_dev;
446 502