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