1 /*
2 * macsonic.c
3 *
4 * (C) 1998 Alan Cox
5 *
6 * Debugging Andreas Ehliar, Michael Schmitz
7 *
8 * Based on code
9 * (C) 1996 by Thomas Bogendoerfer (tsbogend@bigbug.franken.de)
10 *
11 * This driver is based on work from Andreas Busse, but most of
12 * the code is rewritten.
13 *
14 * (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de)
15 *
16 * A driver for the Mac onboard Sonic ethernet chip.
17 *
18 * 98/12/21 MSch: judged from tests on Q800, it's basically working,
19 * but eating up both receive and transmit resources
20 * and duplicating packets. Needs more testing.
21 *
22 * 99/01/03 MSch: upgraded to version 0.92 of the core driver, fixed.
23 *
24 * 00/10/31 sammy@sammy.net: Updated driver for 2.4 kernels, fixed problems
25 * on centris.
26 */
27
28 #include <linux/kernel.h>
29 #include <linux/sched.h>
30 #include <linux/types.h>
31 #include <linux/ctype.h>
32 #include <linux/fcntl.h>
33 #include <linux/interrupt.h>
34 #include <linux/ptrace.h>
35 #include <linux/init.h>
36 #include <linux/ioport.h>
37 #include <linux/in.h>
38 #include <linux/slab.h>
39 #include <linux/string.h>
40 #include <linux/delay.h>
41 #include <linux/nubus.h>
42 #include <asm/bootinfo.h>
43 #include <asm/system.h>
44 #include <asm/bitops.h>
45 #include <asm/pgtable.h>
46 #include <asm/segment.h>
47 #include <asm/io.h>
48 #include <asm/hwtest.h>
49 #include <asm/dma.h>
50 #include <asm/macintosh.h>
51 #include <asm/macints.h>
52 #include <asm/mac_via.h>
53 #include <asm/pgalloc.h>
54
55 #include <linux/errno.h>
56
57 #include <linux/netdevice.h>
58 #include <linux/etherdevice.h>
59 #include <linux/skbuff.h>
60 #include <linux/module.h>
61
62 #define SREGS_PAD(n) u16 n;
63
64 #include "sonic.h"
65
66 #define SONIC_READ(reg) \
67 nubus_readl(base_addr+(reg))
68 #define SONIC_WRITE(reg,val) \
69 nubus_writel((val), base_addr+(reg))
70 #define sonic_read(dev, reg) \
71 nubus_readl((dev)->base_addr+(reg))
72 #define sonic_write(dev, reg, val) \
73 nubus_writel((val), (dev)->base_addr+(reg))
74
75
76 static int sonic_debug;
77 static int sonic_version_printed;
78
79 static int reg_offset;
80
81 extern int macsonic_probe(struct net_device* dev);
82 extern int mac_onboard_sonic_probe(struct net_device* dev);
83 extern int mac_nubus_sonic_probe(struct net_device* dev);
84
85 /* For onboard SONIC */
86 #define ONBOARD_SONIC_REGISTERS 0x50F0A000
87 #define ONBOARD_SONIC_PROM_BASE 0x50f08000
88
89 enum macsonic_type {
90 MACSONIC_DUODOCK,
91 MACSONIC_APPLE,
92 MACSONIC_APPLE16,
93 MACSONIC_DAYNA,
94 MACSONIC_DAYNALINK
95 };
96
97 /* For the built-in SONIC in the Duo Dock */
98 #define DUODOCK_SONIC_REGISTERS 0xe10000
99 #define DUODOCK_SONIC_PROM_BASE 0xe12000
100
101 /* For Apple-style NuBus SONIC */
102 #define APPLE_SONIC_REGISTERS 0
103 #define APPLE_SONIC_PROM_BASE 0x40000
104
105 /* Daynalink LC SONIC */
106 #define DAYNALINK_PROM_BASE 0x400000
107
108 /* For Dayna-style NuBus SONIC (haven't seen one yet) */
109 #define DAYNA_SONIC_REGISTERS 0x180000
110 /* This is what OpenBSD says. However, this is definitely in NuBus
111 ROM space so we should be able to get it by walking the NuBus
112 resource directories */
113 #define DAYNA_SONIC_MAC_ADDR 0xffe004
114
115 #define SONIC_READ_PROM(addr) nubus_readb(prom_addr+addr)
116
macsonic_probe(struct net_device * dev)117 int __init macsonic_probe(struct net_device* dev)
118 {
119 int rv;
120
121 /* This will catch fatal stuff like -ENOMEM as well as success */
122 if ((rv = mac_onboard_sonic_probe(dev)) != -ENODEV)
123 return rv;
124 return mac_nubus_sonic_probe(dev);
125 }
126
127 /*
128 * For reversing the PROM address
129 */
130
131 static unsigned char nibbletab[] = {0, 8, 4, 12, 2, 10, 6, 14,
132 1, 9, 5, 13, 3, 11, 7, 15};
133
bit_reverse_addr(unsigned char addr[6])134 static inline void bit_reverse_addr(unsigned char addr[6])
135 {
136 int i;
137
138 for(i = 0; i < 6; i++)
139 addr[i] = ((nibbletab[addr[i] & 0xf] << 4) |
140 nibbletab[(addr[i] >> 4) &0xf]);
141 }
142
macsonic_init(struct net_device * dev)143 int __init macsonic_init(struct net_device* dev)
144 {
145 struct sonic_local* lp = NULL;
146 int i;
147
148 /* Allocate the entire chunk of memory for the descriptors.
149 Note that this cannot cross a 64K boundary. */
150 for (i = 0; i < 20; i++) {
151 unsigned long desc_base, desc_top;
152 if((lp = kmalloc(sizeof(struct sonic_local), GFP_KERNEL | GFP_DMA)) == NULL) {
153 printk(KERN_ERR "%s: couldn't allocate descriptor buffers\n", dev->name);
154 return -ENOMEM;
155 }
156
157 desc_base = (unsigned long) lp;
158 desc_top = desc_base + sizeof(struct sonic_local);
159 if ((desc_top & 0xffff) >= (desc_base & 0xffff))
160 break;
161 /* Hmm. try again (FIXME: does this actually work?) */
162 kfree(lp);
163 printk(KERN_DEBUG
164 "%s: didn't get continguous chunk [%08lx - %08lx], trying again\n",
165 dev->name, desc_base, desc_top);
166 }
167
168 if (lp == NULL) {
169 printk(KERN_ERR "%s: tried 20 times to allocate descriptor buffers, giving up.\n",
170 dev->name);
171 return -ENOMEM;
172 }
173
174 dev->priv = lp;
175
176 #if 0
177 /* this code is only here as a curiousity... mainly, where the
178 fuck did SONIC_BUS_SCALE come from, and what was it supposed
179 to do? the normal allocation works great for 32 bit stuffs.. */
180
181 /* Now set up the pointers to point to the appropriate places */
182 lp->cda = lp->sonic_desc;
183 lp->tda = lp->cda + (SIZEOF_SONIC_CDA * SONIC_BUS_SCALE(lp->dma_bitmode));
184 lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
185 * SONIC_BUS_SCALE(lp->dma_bitmode));
186 lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
187 * SONIC_BUS_SCALE(lp->dma_bitmode));
188
189 #endif
190
191 memset(lp, 0, sizeof(struct sonic_local));
192
193 lp->cda_laddr = (unsigned int)&(lp->cda);
194 lp->tda_laddr = (unsigned int)lp->tda;
195 lp->rra_laddr = (unsigned int)lp->rra;
196 lp->rda_laddr = (unsigned int)lp->rda;
197
198 /* FIXME, maybe we should use skbs */
199 if ((lp->rba = (char *)
200 kmalloc(SONIC_NUM_RRS * SONIC_RBSIZE, GFP_KERNEL | GFP_DMA)) == NULL) {
201 printk(KERN_ERR "%s: couldn't allocate receive buffers\n", dev->name);
202 kfree(lp);
203 return -ENOMEM;
204 }
205
206 lp->rba_laddr = (unsigned int)lp->rba;
207
208 {
209 int rs, ds;
210
211 /* almost always 12*4096, but let's not take chances */
212 rs = ((SONIC_NUM_RRS * SONIC_RBSIZE + 4095) / 4096) * 4096;
213 /* almost always under a page, but let's not take chances */
214 ds = ((sizeof(struct sonic_local) + 4095) / 4096) * 4096;
215 kernel_set_cachemode(lp->rba, rs, IOMAP_NOCACHE_SER);
216 kernel_set_cachemode(lp, ds, IOMAP_NOCACHE_SER);
217 }
218
219 #if 0
220 flush_cache_all();
221 #endif
222
223 dev->open = sonic_open;
224 dev->stop = sonic_close;
225 dev->hard_start_xmit = sonic_send_packet;
226 dev->get_stats = sonic_get_stats;
227 dev->set_multicast_list = &sonic_multicast_list;
228
229 /*
230 * clear tally counter
231 */
232 sonic_write(dev, SONIC_CRCT, 0xffff);
233 sonic_write(dev, SONIC_FAET, 0xffff);
234 sonic_write(dev, SONIC_MPT, 0xffff);
235
236 /* Fill in the fields of the device structure with ethernet values. */
237 ether_setup(dev);
238 return 0;
239 }
240
mac_onboard_sonic_ethernet_addr(struct net_device * dev)241 int __init mac_onboard_sonic_ethernet_addr(struct net_device* dev)
242 {
243 const int prom_addr = ONBOARD_SONIC_PROM_BASE;
244 int i;
245
246 /* On NuBus boards we can sometimes look in the ROM resources.
247 No such luck for comm-slot/onboard. */
248 for(i = 0; i < 6; i++)
249 dev->dev_addr[i] = SONIC_READ_PROM(i);
250
251 /* Most of the time, the address is bit-reversed. The NetBSD
252 source has a rather long and detailed historical account of
253 why this is so. */
254 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
255 memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
256 memcmp(dev->dev_addr, "\x00\x05\x02", 3))
257 bit_reverse_addr(dev->dev_addr);
258 else
259 return 0;
260
261 /* If we still have what seems to be a bogus address, we'll
262 look in the CAM. The top entry should be ours. */
263 /* Danger! This only works if MacOS has already initialized
264 the card... */
265 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
266 memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
267 memcmp(dev->dev_addr, "\x00\x05\x02", 3))
268 {
269 unsigned short val;
270
271 printk(KERN_INFO "macsonic: PROM seems to be wrong, trying CAM entry 15\n");
272
273 sonic_write(dev, SONIC_CMD, SONIC_CR_RST);
274 sonic_write(dev, SONIC_CEP, 15);
275
276 val = sonic_read(dev, SONIC_CAP2);
277 dev->dev_addr[5] = val >> 8;
278 dev->dev_addr[4] = val & 0xff;
279 val = sonic_read(dev, SONIC_CAP1);
280 dev->dev_addr[3] = val >> 8;
281 dev->dev_addr[2] = val & 0xff;
282 val = sonic_read(dev, SONIC_CAP0);
283 dev->dev_addr[1] = val >> 8;
284 dev->dev_addr[0] = val & 0xff;
285
286 printk(KERN_INFO "HW Address from CAM 15: ");
287 for (i = 0; i < 6; i++) {
288 printk("%2.2x", dev->dev_addr[i]);
289 if (i < 5)
290 printk(":");
291 }
292 printk("\n");
293 } else return 0;
294
295 if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
296 memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
297 memcmp(dev->dev_addr, "\x00\x05\x02", 3))
298 {
299 /*
300 * Still nonsense ... messed up someplace!
301 */
302 printk(KERN_ERR "macsonic: ERROR (INVALID MAC)\n");
303 return -EIO;
304 } else return 0;
305 }
306
mac_onboard_sonic_probe(struct net_device * dev)307 int __init mac_onboard_sonic_probe(struct net_device* dev)
308 {
309 /* Bwahahaha */
310 static int once_is_more_than_enough;
311 int i;
312 int dma_bitmode;
313
314 if (once_is_more_than_enough)
315 return -ENODEV;
316 once_is_more_than_enough = 1;
317
318 if (!MACH_IS_MAC)
319 return -ENODEV;
320
321 printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
322
323 if (macintosh_config->ether_type != MAC_ETHER_SONIC)
324 {
325 printk("none.\n");
326 return -ENODEV;
327 }
328
329 /* Bogus probing, on the models which may or may not have
330 Ethernet (BTW, the Ethernet *is* always at the same
331 address, and nothing else lives there, at least if Apple's
332 documentation is to be believed) */
333 if (macintosh_config->ident == MAC_MODEL_Q630 ||
334 macintosh_config->ident == MAC_MODEL_P588 ||
335 macintosh_config->ident == MAC_MODEL_C610) {
336 unsigned long flags;
337 int card_present;
338
339 save_flags(flags);
340 cli();
341 card_present = hwreg_present((void*)ONBOARD_SONIC_REGISTERS);
342 restore_flags(flags);
343
344 if (!card_present) {
345 printk("none.\n");
346 return -ENODEV;
347 }
348 }
349
350 printk("yes\n");
351
352 if (dev) {
353 dev = init_etherdev(dev, sizeof(struct sonic_local));
354 if (!dev)
355 return -ENOMEM;
356 /* methinks this will always be true but better safe than sorry */
357 if (dev->priv == NULL) {
358 dev->priv = kmalloc(sizeof(struct sonic_local), GFP_KERNEL);
359 if (!dev->priv)
360 return -ENOMEM;
361 }
362 } else {
363 dev = init_etherdev(NULL, sizeof(struct sonic_local));
364 }
365
366 if (dev == NULL)
367 return -ENOMEM;
368
369 if(dev->priv) {
370 printk("%s: warning! sonic entering with priv already allocated!\n",
371 dev->name);
372 printk("%s: discarding, will attempt to reallocate\n", dev->name);
373 dev->priv = NULL;
374 }
375
376 /* Danger! My arms are flailing wildly! You *must* set this
377 before using sonic_read() */
378
379 dev->base_addr = ONBOARD_SONIC_REGISTERS;
380 if (via_alt_mapping)
381 dev->irq = IRQ_AUTO_3;
382 else
383 dev->irq = IRQ_NUBUS_9;
384
385 if (!sonic_version_printed) {
386 printk(KERN_INFO "%s", version);
387 sonic_version_printed = 1;
388 }
389 printk(KERN_INFO "%s: onboard / comm-slot SONIC at 0x%08lx\n",
390 dev->name, dev->base_addr);
391
392 /* Now do a song and dance routine in an attempt to determine
393 the bus width */
394
395 /* The PowerBook's SONIC is 16 bit always. */
396 if (macintosh_config->ident == MAC_MODEL_PB520) {
397 reg_offset = 0;
398 dma_bitmode = 0;
399 } else if (macintosh_config->ident == MAC_MODEL_C610) {
400 reg_offset = 0;
401 dma_bitmode = 1;
402 } else {
403 /* Some of the comm-slot cards are 16 bit. But some
404 of them are not. The 32-bit cards use offset 2 and
405 pad with zeroes or sometimes ones (I think...)
406 Therefore, if we try offset 0 and get a silicon
407 revision of 0, we assume 16 bit. */
408 int sr;
409
410 /* Technically this is not necessary since we zeroed
411 it above */
412 reg_offset = 0;
413 dma_bitmode = 0;
414 sr = sonic_read(dev, SONIC_SR);
415 if (sr == 0 || sr == 0xffff) {
416 reg_offset = 2;
417 /* 83932 is 0x0004, 83934 is 0x0100 or 0x0101 */
418 sr = sonic_read(dev, SONIC_SR);
419 dma_bitmode = 1;
420
421 }
422 printk(KERN_INFO
423 "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
424 dev->name, sr, dma_bitmode?32:16, reg_offset);
425 }
426
427
428 /* this carries my sincere apologies -- by the time I got to updating
429 the driver, support for "reg_offsets" appeares nowhere in the sonic
430 code, going back for over a year. Fortunately, my Mac does't seem
431 to use whatever this was.
432
433 If you know how this is supposed to be implemented, either fix it,
434 or contact me (sammy@sammy.net) to explain what it is. --Sam */
435
436 if(reg_offset) {
437 printk("%s: register offset unsupported. please fix this if you know what it is.\n", dev->name);
438 return -ENODEV;
439 }
440
441 /* Software reset, then initialize control registers. */
442 sonic_write(dev, SONIC_CMD, SONIC_CR_RST);
443 sonic_write(dev, SONIC_DCR, SONIC_DCR_BMS |
444 SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_EXBUS |
445 (dma_bitmode ? SONIC_DCR_DW : 0));
446
447 /* This *must* be written back to in order to restore the
448 extended programmable output bits */
449 sonic_write(dev, SONIC_DCR2, 0);
450
451 /* Clear *and* disable interrupts to be on the safe side */
452 sonic_write(dev, SONIC_ISR,0x7fff);
453 sonic_write(dev, SONIC_IMR,0);
454
455 /* Now look for the MAC address. */
456 if (mac_onboard_sonic_ethernet_addr(dev) != 0)
457 return -ENODEV;
458
459 printk(KERN_INFO "MAC ");
460 for (i = 0; i < 6; i++) {
461 printk("%2.2x", dev->dev_addr[i]);
462 if (i < 5)
463 printk(":");
464 }
465
466 printk(" IRQ %d\n", dev->irq);
467
468 /* Shared init code */
469 return macsonic_init(dev);
470 }
471
mac_nubus_sonic_ethernet_addr(struct net_device * dev,unsigned long prom_addr,int id)472 int __init mac_nubus_sonic_ethernet_addr(struct net_device* dev,
473 unsigned long prom_addr,
474 int id)
475 {
476 int i;
477 for(i = 0; i < 6; i++)
478 dev->dev_addr[i] = SONIC_READ_PROM(i);
479 /* For now we are going to assume that they're all bit-reversed */
480 bit_reverse_addr(dev->dev_addr);
481
482 return 0;
483 }
484
macsonic_ident(struct nubus_dev * ndev)485 int __init macsonic_ident(struct nubus_dev* ndev)
486 {
487 if (ndev->dr_hw == NUBUS_DRHW_ASANTE_LC &&
488 ndev->dr_sw == NUBUS_DRSW_SONIC_LC)
489 return MACSONIC_DAYNALINK;
490 if (ndev->dr_hw == NUBUS_DRHW_SONIC &&
491 ndev->dr_sw == NUBUS_DRSW_APPLE) {
492 /* There has to be a better way to do this... */
493 if (strstr(ndev->board->name, "DuoDock"))
494 return MACSONIC_DUODOCK;
495 else
496 return MACSONIC_APPLE;
497 }
498 return -1;
499 }
500
mac_nubus_sonic_probe(struct net_device * dev)501 int __init mac_nubus_sonic_probe(struct net_device* dev)
502 {
503 static int slots;
504 struct nubus_dev* ndev = NULL;
505 struct sonic_local* lp;
506 unsigned long base_addr, prom_addr;
507 u16 sonic_dcr;
508 int id;
509 int i;
510 int dma_bitmode;
511
512 /* Find the first SONIC that hasn't been initialized already */
513 while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK,
514 NUBUS_TYPE_ETHERNET, ndev)) != NULL)
515 {
516 /* Have we seen it already? */
517 if (slots & (1<<ndev->board->slot))
518 continue;
519 slots |= 1<<ndev->board->slot;
520
521 /* Is it one of ours? */
522 if ((id = macsonic_ident(ndev)) != -1)
523 break;
524 }
525
526 if (ndev == NULL)
527 return -ENODEV;
528
529 switch (id) {
530 case MACSONIC_DUODOCK:
531 base_addr = ndev->board->slot_addr + DUODOCK_SONIC_REGISTERS;
532 prom_addr = ndev->board->slot_addr + DUODOCK_SONIC_PROM_BASE;
533 sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1
534 | SONIC_DCR_TFT0;
535 reg_offset = 2;
536 dma_bitmode = 1;
537 break;
538 case MACSONIC_APPLE:
539 base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
540 prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
541 sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0;
542 reg_offset = 0;
543 dma_bitmode = 1;
544 break;
545 case MACSONIC_APPLE16:
546 base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
547 prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
548 sonic_dcr = SONIC_DCR_EXBUS
549 | SONIC_DCR_RFT1 | SONIC_DCR_TFT0
550 | SONIC_DCR_PO1 | SONIC_DCR_BMS;
551 reg_offset = 0;
552 dma_bitmode = 0;
553 break;
554 case MACSONIC_DAYNALINK:
555 base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
556 prom_addr = ndev->board->slot_addr + DAYNALINK_PROM_BASE;
557 sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0
558 | SONIC_DCR_PO1 | SONIC_DCR_BMS;
559 reg_offset = 0;
560 dma_bitmode = 0;
561 break;
562 case MACSONIC_DAYNA:
563 base_addr = ndev->board->slot_addr + DAYNA_SONIC_REGISTERS;
564 prom_addr = ndev->board->slot_addr + DAYNA_SONIC_MAC_ADDR;
565 sonic_dcr = SONIC_DCR_BMS
566 | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1;
567 reg_offset = 0;
568 dma_bitmode = 0;
569 break;
570 default:
571 printk(KERN_ERR "macsonic: WTF, id is %d\n", id);
572 return -ENODEV;
573 }
574
575 if (dev) {
576 dev = init_etherdev(dev, sizeof(struct sonic_local));
577 if (!dev)
578 return -ENOMEM;
579 /* methinks this will always be true but better safe than sorry */
580 if (dev->priv == NULL) {
581 dev->priv = kmalloc(sizeof(struct sonic_local), GFP_KERNEL);
582 if (!dev->priv) /* FIXME: kfree dev if necessary */
583 return -ENOMEM;
584 }
585 } else {
586 dev = init_etherdev(NULL, sizeof(struct sonic_local));
587 }
588
589 if (dev == NULL)
590 return -ENOMEM;
591
592 lp = (struct sonic_local*) dev->priv;
593 memset(lp, 0, sizeof(struct sonic_local));
594 /* Danger! My arms are flailing wildly! You *must* set this
595 before using sonic_read() */
596 dev->base_addr = base_addr;
597 dev->irq = SLOT2IRQ(ndev->board->slot);
598
599 if (!sonic_version_printed) {
600 printk(KERN_INFO "%s", version);
601 sonic_version_printed = 1;
602 }
603 printk(KERN_INFO "%s: %s in slot %X\n",
604 dev->name, ndev->board->name, ndev->board->slot);
605 printk(KERN_INFO "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
606 dev->name, sonic_read(dev, SONIC_SR), dma_bitmode?32:16, reg_offset);
607
608 if(reg_offset) {
609 printk("%s: register offset unsupported. please fix this if you know what it is.\n", dev->name);
610 return -ENODEV;
611 }
612
613 /* Software reset, then initialize control registers. */
614 sonic_write(dev, SONIC_CMD, SONIC_CR_RST);
615 sonic_write(dev, SONIC_DCR, sonic_dcr
616 | (dma_bitmode ? SONIC_DCR_DW : 0));
617
618 /* Clear *and* disable interrupts to be on the safe side */
619 sonic_write(dev, SONIC_ISR,0x7fff);
620 sonic_write(dev, SONIC_IMR,0);
621
622 /* Now look for the MAC address. */
623 if (mac_nubus_sonic_ethernet_addr(dev, prom_addr, id) != 0)
624 return -ENODEV;
625
626 printk(KERN_INFO "MAC ");
627 for (i = 0; i < 6; i++) {
628 printk("%2.2x", dev->dev_addr[i]);
629 if (i < 5)
630 printk(":");
631 }
632 printk(" IRQ %d\n", dev->irq);
633
634 /* Shared init code */
635 return macsonic_init(dev);
636 }
637
638 #ifdef MODULE
639 static struct net_device dev_macsonic;
640
641 MODULE_PARM(sonic_debug, "i");
642 MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
643
644 int
init_module(void)645 init_module(void)
646 {
647 dev_macsonic.init = macsonic_probe;
648
649 if (register_netdev(&dev_macsonic) != 0) {
650 printk(KERN_WARNING "macsonic.c: No card found\n");
651 return -ENXIO;
652 }
653 return 0;
654 }
655
656 void
cleanup_module(void)657 cleanup_module(void)
658 {
659 if (dev_macsonic.priv != NULL) {
660 unregister_netdev(&dev_macsonic);
661 kfree(dev_macsonic.priv);
662 dev_macsonic.priv = NULL;
663 }
664 }
665 #endif /* MODULE */
666
667
668 #define vdma_alloc(foo, bar) ((u32)foo)
669 #define vdma_free(baz)
670 #define sonic_chiptomem(bat) (bat)
671 #define PHYSADDR(quux) (quux)
672
673 #define sonic_request_irq request_irq
674 #define sonic_free_irq free_irq
675
676 #include "sonic.c"
677
678 /*
679 * Local variables:
680 * compile-command: "m68k-linux-gcc -D__KERNEL__ -I../../include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -fno-strength-reduce -ffixed-a2 -DMODULE -DMODVERSIONS -include ../../include/linux/modversions.h -c -o macsonic.o macsonic.c"
681 * version-control: t
682 * kept-new-versions: 5
683 * c-indent-level: 8
684 * tab-width: 8
685 * End:
686 *
687 */
688