summaryrefslogtreecommitdiffstats
path: root/drivers/net/macsonic.c
blob: 2e0984869c71c1a2cc8a3767dda354f9b5bca5ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
/*
 * macsonic.c
 *
 * (C) 1998 Alan Cox
 *
 * Debugging Andreas Ehliar, Michael Schmitz
 *
 * Based on code
 * (C) 1996 by Thomas Bogendoerfer (tsbogend@bigbug.franken.de)
 * 
 * This driver is based on work from Andreas Busse, but most of
 * the code is rewritten.
 * 
 * (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de)
 *
 * A driver for the Mac onboard Sonic ethernet chip.
 *
 * 98/12/21 MSch: judged from tests on Q800, it's basically working, 
 *		  but eating up both receive and transmit resources
 *		  and duplicating packets. Needs more testing.
 *
 * 99/01/03 MSch: upgraded to version 0.92 of the core driver, fixed.
 */

#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/ctype.h>
#include <linux/fcntl.h>
#include <linux/interrupt.h>
#include <linux/ptrace.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/in.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/nubus.h>
#include <asm/bootinfo.h>
#include <asm/system.h>
#include <asm/bitops.h>
#include <asm/pgtable.h>
#include <asm/segment.h>
#include <asm/io.h>
#include <asm/hwtest.h>
#include <asm/dma.h>
#include <asm/macintosh.h>
#include <asm/macints.h>
#include <asm/mac_via.h>

#include <linux/errno.h>

#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/module.h>

#define SREGS_PAD(n)    u16 n;

#include "sonic.h"

static int sonic_debug;
static int sonic_version_printed;

extern int macsonic_probe(struct net_device* dev);
extern int mac_onboard_sonic_probe(struct net_device* dev);
extern int mac_nubus_sonic_probe(struct net_device* dev);

/* For onboard SONIC */
#define ONBOARD_SONIC_REGISTERS	0x50F0A000
#define ONBOARD_SONIC_PROM_BASE	0x50f08000

enum macsonic_type {
	MACSONIC_DUODOCK,
	MACSONIC_APPLE,
	MACSONIC_APPLE16,
	MACSONIC_DAYNA,
	MACSONIC_DAYNALINK
};

/* For the built-in SONIC in the Duo Dock */
#define DUODOCK_SONIC_REGISTERS 0xe10000
#define DUODOCK_SONIC_PROM_BASE 0xe12000

/* For Apple-style NuBus SONIC */
#define APPLE_SONIC_REGISTERS	0
#define APPLE_SONIC_PROM_BASE	0x40000

/* Daynalink LC SONIC */
#define DAYNALINK_PROM_BASE 0x400000

/* For Dayna-style NuBus SONIC (haven't seen one yet) */
#define DAYNA_SONIC_REGISTERS   0x180000
/* This is what OpenBSD says.  However, this is definitely in NuBus
   ROM space so we should be able to get it by walking the NuBus
   resource directories */
#define DAYNA_SONIC_MAC_ADDR	0xffe004

#define SONIC_READ_PROM(addr) readb(prom_addr+addr)

int __init macsonic_probe(struct net_device* dev)
{
	int rv;

	/* This will catch fatal stuff like -ENOMEM as well as success */
	if ((rv = mac_onboard_sonic_probe(dev)) != -ENODEV)
		return rv;
	return mac_nubus_sonic_probe(dev);
}

/*
 * For reversing the PROM address
 */

static unsigned char nibbletab[] = {0, 8, 4, 12, 2, 10, 6, 14,
				    1, 9, 5, 13, 3, 11, 7, 15};

static inline void bit_reverse_addr(unsigned char addr[6])
{
	int i;

	for(i = 0; i < 6; i++)
		addr[i] = ((nibbletab[addr[i] & 0xf] << 4) | 
			   nibbletab[(addr[i] >> 4) &0xf]);
}

int __init macsonic_init(struct net_device* dev)
{
	struct sonic_local* lp = (struct sonic_local *)dev->priv;
	int i;

	/* Allocate the entire chunk of memory for the descriptors.
           Note that this cannot cross a 64K boundary. */
	for (i = 0; i < 20; i++) {
		unsigned long desc_base, desc_top;
		if ((lp->sonic_desc = 
		     kmalloc(SIZEOF_SONIC_DESC
			     * SONIC_BUS_SCALE(lp->dma_bitmode), GFP_DMA)) == NULL) {
			printk(KERN_ERR "%s: couldn't allocate descriptor buffers\n", dev->name);
		}
		desc_base = (unsigned long) lp->sonic_desc;
		desc_top = desc_base + SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode);
		if ((desc_top & 0xffff) >= (desc_base & 0xffff))
			break;
		/* Hmm. try again (FIXME: does this actually work?) */
		kfree(lp->sonic_desc);
		printk(KERN_DEBUG
		       "%s: didn't get continguous chunk [%08lx - %08lx], trying again\n",
		       dev->name, desc_base, desc_top);
	}

	if (lp->sonic_desc == NULL) {
		printk(KERN_ERR "%s: tried 20 times to allocate descriptor buffers, giving up.\n",
		       dev->name);
		return -ENOMEM;
	}		       

	/* Now set up the pointers to point to the appropriate places */
	lp->cda = lp->sonic_desc;
	lp->tda = lp->cda + (SIZEOF_SONIC_CDA * SONIC_BUS_SCALE(lp->dma_bitmode));
	lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
			     * SONIC_BUS_SCALE(lp->dma_bitmode));
	lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
			     * SONIC_BUS_SCALE(lp->dma_bitmode));

	/* FIXME, maybe we should use skbs */
	if ((lp->rba = (char *)
	     kmalloc(SONIC_NUM_RRS * SONIC_RBSIZE, GFP_DMA)) == NULL) {
		printk(KERN_ERR "%s: couldn't allocate receive buffers\n", dev->name);
		return -ENOMEM;
	}

	{
		int rs, ds;

		/* almost always 12*4096, but let's not take chances */
		rs = ((SONIC_NUM_RRS * SONIC_RBSIZE + 4095) / 4096) * 4096;
		/* almost always under a page, but let's not take chances */
		ds = ((SIZEOF_SONIC_DESC + 4095) / 4096) * 4096;
		kernel_set_cachemode(lp->rba, rs, IOMAP_NOCACHE_SER);
		kernel_set_cachemode(lp->sonic_desc, ds, IOMAP_NOCACHE_SER);
	}
	
#if 0
	flush_cache_all();
#endif

	dev->open = sonic_open;
	dev->stop = sonic_close;
	dev->hard_start_xmit = sonic_send_packet;
	dev->get_stats = sonic_get_stats;
	dev->set_multicast_list = &sonic_multicast_list;

	/*
	 * clear tally counter
	 */
	sonic_write(dev, SONIC_CRCT, 0xffff);
	sonic_write(dev, SONIC_FAET, 0xffff);
	sonic_write(dev, SONIC_MPT, 0xffff);

	/* Fill in the fields of the device structure with ethernet values. */
	ether_setup(dev);
	return 0;
}

int __init mac_onboard_sonic_ethernet_addr(struct net_device* dev)
{
	const int prom_addr = ONBOARD_SONIC_PROM_BASE;
	int i;

	/* On NuBus boards we can sometimes look in the ROM resources.
	   No such luck for comm-slot/onboard. */
	for(i = 0; i < 6; i++)
		dev->dev_addr[i] = SONIC_READ_PROM(i);

	/* Most of the time, the address is bit-reversed.  The NetBSD
	   source has a rather long and detailed historical account of
	   why this is so. */
	if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
	    memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
	    memcmp(dev->dev_addr, "\x00\x05\x02", 3))
		bit_reverse_addr(dev->dev_addr);
	else
		return 0;

	/* If we still have what seems to be a bogus address, we'll
           look in the CAM.  The top entry should be ours. */
	/* Danger! This only works if MacOS has already initialized
           the card... */
	if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
	    memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
	    memcmp(dev->dev_addr, "\x00\x05\x02", 3))
	{
		unsigned short val;

		printk(KERN_INFO "macsonic: PROM seems to be wrong, trying CAM entry 15\n");
		
		sonic_write(dev, SONIC_CMD, SONIC_CR_RST);
		sonic_write(dev, SONIC_CEP, 15);

		val = sonic_read(dev, SONIC_CAP2);
		dev->dev_addr[5] = val >> 8;
		dev->dev_addr[4] = val & 0xff;
		val = sonic_read(dev, SONIC_CAP1);
		dev->dev_addr[3] = val >> 8;
		dev->dev_addr[2] = val & 0xff;
		val = sonic_read(dev, SONIC_CAP0);
		dev->dev_addr[1] = val >> 8;
		dev->dev_addr[0] = val & 0xff;
		
		printk(KERN_INFO "HW Address from CAM 15: ");
		for (i = 0; i < 6; i++) {
			printk("%2.2x", dev->dev_addr[i]);
			if (i < 5)
				printk(":");
		}
		printk("\n");
	} else return 0;

	if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
	    memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
	    memcmp(dev->dev_addr, "\x00\x05\x02", 3))
	{
		/*
		 * Still nonsense ... messed up someplace!
		 */
		printk(KERN_ERR "macsonic: ERROR (INVALID MAC)\n");
		return -EIO;
	} else return 0;
}

int __init mac_onboard_sonic_probe(struct net_device* dev)
{
	/* Bwahahaha */
	static int once_is_more_than_enough;
	struct sonic_local* lp;
	int i;
	
	if (once_is_more_than_enough)
		return -ENODEV;
	once_is_more_than_enough = 1;

	if (!MACH_IS_MAC)
		return -ENODEV;

	printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");

	if (macintosh_config->ether_type != MAC_ETHER_SONIC)
	{
		printk("none.\n");
		return -ENODEV;
	}

	/* Bogus probing, on the models which may or may not have
	   Ethernet (BTW, the Ethernet *is* always at the same
	   address, and nothing else lives there, at least if Apple's
	   documentation is to be believed) */
	if (macintosh_config->ident == MAC_MODEL_Q630 ||
	    macintosh_config->ident == MAC_MODEL_P588 ||
	    macintosh_config->ident == MAC_MODEL_C610) {
		unsigned long flags;
		int card_present;

		save_flags(flags);
		cli();
		card_present = hwreg_present((void*)ONBOARD_SONIC_REGISTERS);
		restore_flags(flags);

		if (!card_present) {
			printk("none.\n");
			return -ENODEV;
		}
	}

	printk("yes\n");	

	if (dev) {
		dev = init_etherdev(dev, sizeof(struct sonic_local));
		if (!dev)
			return -ENOMEM;
		/* methinks this will always be true but better safe than sorry */
		if (dev->priv == NULL) {
			dev->priv = kmalloc(sizeof(struct sonic_local), GFP_KERNEL);
			if (!dev->priv) /* FIXME: kfree dev if necessary */
				return -ENOMEM;
		}
	} else {
		dev = init_etherdev(NULL, sizeof(struct sonic_local));
	}

	if (dev == NULL)
		return -ENOMEM;

	lp = (struct sonic_local*) dev->priv;
	memset(lp, 0, sizeof(struct sonic_local));
	/* Danger!  My arms are flailing wildly!  You *must* set this
           before using sonic_read() */

	dev->base_addr = ONBOARD_SONIC_REGISTERS;
	if (via_alt_mapping)
		dev->irq = IRQ_AUTO_3;
	else
		dev->irq = IRQ_NUBUS_9;

	if (!sonic_version_printed) {
		printk(KERN_INFO "%s", version);
		sonic_version_printed = 1;
	}
	printk(KERN_INFO "%s: onboard / comm-slot SONIC at 0x%08lx\n",
	       dev->name, dev->base_addr);

	/* Now do a song and dance routine in an attempt to determine
           the bus width */

	/* The PowerBook's SONIC is 16 bit always. */
	if (macintosh_config->ident == MAC_MODEL_PB520) {
		lp->reg_offset = 0;
		lp->dma_bitmode = 0;
	} else {
		/* Some of the comm-slot cards are 16 bit.  But some
                   of them are not.  The 32-bit cards use offset 2 and
                   pad with zeroes or sometimes ones (I think...)
                   Therefore, if we try offset 0 and get a silicon
                   revision of 0, we assume 16 bit. */
		int sr;

		/* Technically this is not necessary since we zeroed
                   it above */
		lp->reg_offset = 0;
		lp->dma_bitmode = 0;
		sr = sonic_read(dev, SONIC_SR);
		if (sr == 0 || sr == 0xffff) {
			lp->reg_offset = 2;
			/* 83932 is 0x0004, 83934 is 0x0100 or 0x0101 */
			sr = sonic_read(dev, SONIC_SR);
			lp->dma_bitmode = 1;
			
		}
		printk(KERN_INFO
		       "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
		       dev->name, sr, lp->dma_bitmode?32:16, lp->reg_offset);
	}


	/* Software reset, then initialize control registers. */
	sonic_write(dev, SONIC_CMD, SONIC_CR_RST);
	sonic_write(dev, SONIC_DCR, SONIC_DCR_BMS |
		    SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_EXBUS |
		    (lp->dma_bitmode ? SONIC_DCR_DW : 0));
	/* This *must* be written back to in order to restore the
           extended programmable output bits */
	sonic_write(dev, SONIC_DCR2, 0);

	/* Clear *and* disable interrupts to be on the safe side */
	sonic_write(dev, SONIC_ISR,0x7fff);
	sonic_write(dev, SONIC_IMR,0);

	/* Now look for the MAC address. */
	if (mac_onboard_sonic_ethernet_addr(dev) != 0)
		return -ENODEV;

	printk(KERN_INFO "MAC ");
	for (i = 0; i < 6; i++) {
		printk("%2.2x", dev->dev_addr[i]);
		if (i < 5)
			printk(":");
	}

	printk(" IRQ %d\n", dev->irq);

	/* Shared init code */
	return macsonic_init(dev);
}

int __init mac_nubus_sonic_ethernet_addr(struct net_device* dev,
					 unsigned long prom_addr,
					 int id)
{
	int i;
	for(i = 0; i < 6; i++)
		dev->dev_addr[i] = SONIC_READ_PROM(i);
	/* For now we are going to assume that they're all bit-reversed */
	bit_reverse_addr(dev->dev_addr);

	return 0;
}

int __init macsonic_ident(struct nubus_dev* ndev)
{
	if (ndev->dr_hw == NUBUS_DRHW_ASANTE_LC && 
	    ndev->dr_sw == NUBUS_DRSW_SONIC_LC)
		return MACSONIC_DAYNALINK;
	if (ndev->dr_hw == NUBUS_DRHW_SONIC &&
	    ndev->dr_sw == NUBUS_DRSW_APPLE) {
		/* There has to be a better way to do this... */
		if (strstr(ndev->board->name, "DuoDock"))
			return MACSONIC_DUODOCK;
		else
			return MACSONIC_APPLE;
	}
	return -1;
}

int __init mac_nubus_sonic_probe(struct net_device* dev)
{
	static int slots;
	struct nubus_dev* ndev = NULL;
	struct sonic_local* lp;
	unsigned long base_addr, prom_addr;
	u16 sonic_dcr;
	int id;
	int i;
	int reg_offset, dma_bitmode;

	/* Find the first SONIC that hasn't been initialized already */
	while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK,
				       NUBUS_TYPE_ETHERNET, ndev)) != NULL)
	{
		/* Have we seen it already? */
		if (slots & (1<<ndev->board->slot))
			continue;
		slots |= 1<<ndev->board->slot;

		/* Is it one of ours? */
		if ((id = macsonic_ident(ndev)) != -1)
			break;
	}

	if (ndev == NULL)
		return -ENODEV;

	switch (id) {
	case MACSONIC_DUODOCK:
		base_addr = ndev->board->slot_addr + DUODOCK_SONIC_REGISTERS;
		prom_addr = ndev->board->slot_addr + DUODOCK_SONIC_PROM_BASE;
		sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1
			| SONIC_DCR_TFT0;
		reg_offset = 2;
		dma_bitmode = 1;
		break;
	case MACSONIC_APPLE:
		base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
		prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
		sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0;
		reg_offset = 0;
		dma_bitmode = 1;
		break;
	case MACSONIC_APPLE16:
		base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
		prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
		sonic_dcr = SONIC_DCR_EXBUS
 			| SONIC_DCR_RFT1 | SONIC_DCR_TFT0
			| SONIC_DCR_PO1 | SONIC_DCR_BMS; 
		reg_offset = 0;
		dma_bitmode = 0;
		break;
	case MACSONIC_DAYNALINK:
		base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
		prom_addr = ndev->board->slot_addr + DAYNALINK_PROM_BASE;
		sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0
			| SONIC_DCR_PO1 | SONIC_DCR_BMS; 
		reg_offset = 0;
		dma_bitmode = 0;
		break;
	case MACSONIC_DAYNA:
		base_addr = ndev->board->slot_addr + DAYNA_SONIC_REGISTERS;
		prom_addr = ndev->board->slot_addr + DAYNA_SONIC_MAC_ADDR;
		sonic_dcr = SONIC_DCR_BMS
			| SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1;
		reg_offset = 0;
		dma_bitmode = 0;
		break;
	default:
		printk(KERN_ERR "macsonic: WTF, id is %d\n", id);
		return -ENODEV;
	}

	if (dev) {
		dev = init_etherdev(dev, sizeof(struct sonic_local));
		/* methinks this will always be true but better safe than sorry */
		if (dev->priv == NULL)
			dev->priv = kmalloc(sizeof(struct sonic_local), GFP_KERNEL);
	} else {
		dev = init_etherdev(NULL, sizeof(struct sonic_local));
	}

	if (dev == NULL)
		return -ENOMEM;

	lp = (struct sonic_local*) dev->priv;
	memset(lp, 0, sizeof(struct sonic_local));
	/* Danger!  My arms are flailing wildly!  You *must* set this
           before using sonic_read() */
	lp->reg_offset = reg_offset;
	lp->dma_bitmode = dma_bitmode;
	dev->base_addr = base_addr;
	dev->irq = SLOT2IRQ(ndev->board->slot);

	if (!sonic_version_printed) {
		printk(KERN_INFO "%s", version);
		sonic_version_printed = 1;
	}
	printk(KERN_INFO "%s: %s in slot %X\n",
	       dev->name, ndev->board->name, ndev->board->slot);
	printk(KERN_INFO "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
	       dev->name, sonic_read(dev, SONIC_SR), dma_bitmode?32:16, reg_offset);

	/* Software reset, then initialize control registers. */
	sonic_write(dev, SONIC_CMD, SONIC_CR_RST);
	sonic_write(dev, SONIC_DCR, sonic_dcr
		    | (dma_bitmode ? SONIC_DCR_DW : 0));

	/* Clear *and* disable interrupts to be on the safe side */
	sonic_write(dev, SONIC_ISR,0x7fff);
	sonic_write(dev, SONIC_IMR,0);

	/* Now look for the MAC address. */
	if (mac_nubus_sonic_ethernet_addr(dev, prom_addr, id) != 0)
		return -ENODEV;

	printk(KERN_INFO "MAC ");
	for (i = 0; i < 6; i++) {
		printk("%2.2x", dev->dev_addr[i]);
		if (i < 5)
			printk(":");
	}
	printk(" IRQ %d\n", dev->irq);

	/* Shared init code */
	return macsonic_init(dev);
}

#ifdef MODULE
static char namespace[16] = "";
static struct net_device dev_macsonic;

MODULE_PARM(sonic_debug, "i");

EXPORT_NO_SYMBOLS;

int
init_module(void)
{
        dev_macsonic.name = namespace;
        dev_macsonic.init = macsonic_probe;

        if (register_netdev(&dev_macsonic) != 0) {
                printk(KERN_WARNING "macsonic.c: No card found\n");
                return -ENXIO;
        }
	return 0;
}

void
cleanup_module(void)
{
        if (dev_macsonic.priv != NULL) {
                unregister_netdev(&dev_macsonic);
                kfree(dev_macsonic.priv);
                dev_macsonic.priv = NULL;
        }
}
#endif /* MODULE */


#define vdma_alloc(foo, bar) ((u32)foo)
#define vdma_free(baz)
#define sonic_chiptomem(bat) (bat)
#define PHYSADDR(quux) (quux)

#include "sonic.c"

/*
 * Local variables:
 *  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"
 *  version-control: t
 *  kept-new-versions: 5
 *  c-indent-level: 8
 *  tab-width: 8
 * End:
 *
 */