blob: f6f3fdfe41db75551163a6570c635b48cb79f280 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* mac89x0.c: A Crystal Semiconductor CS89[02]0 driver for linux. */
2/*
3 Written 1996 by Russell Nelson, with reference to skeleton.c
4 written 1993-1994 by Donald Becker.
5
6 This software may be used and distributed according to the terms
7 of the GNU General Public License, incorporated herein by reference.
8
9 The author may be reached at nelson@crynwr.com, Crynwr
10 Software, 11 Grant St., Potsdam, NY 13676
11
12 Changelog:
13
14 Mike Cruse : mcruse@cti-ltd.com
Jeff Garzik6aa20a22006-09-13 13:24:59 -040015 : Changes for Linux 2.0 compatibility.
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 : Added dev_id parameter in net_interrupt(),
17 : request_irq() and free_irq(). Just NULL for now.
18
19 Mike Cruse : Added MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT macros
20 : in net_open() and net_close() so kerneld would know
Jeff Garzik6aa20a22006-09-13 13:24:59 -040021 : that the module is in use and wouldn't eject the
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 : driver prematurely.
23
24 Mike Cruse : Rewrote init_module() and cleanup_module using 8390.c
25 : as an example. Disabled autoprobing in init_module(),
26 : not a good thing to do to other devices while Linux
27 : is running from all accounts.
Jeff Garzik6aa20a22006-09-13 13:24:59 -040028
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 Alan Cox : Removed 1.2 support, added 2.1 extra counters.
30
31 David Huggins-Daines <dhd@debian.org>
Jeff Garzik6aa20a22006-09-13 13:24:59 -040032
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 Split this off into mac89x0.c, and gutted it of all parts which are
34 not relevant to the existing CS8900 cards on the Macintosh
35 (i.e. basically the Daynaport CS and LC cards). To be precise:
36
37 * Removed all the media-detection stuff, because these cards are
38 TP-only.
39
40 * Lobotomized the ISA interrupt bogosity, because these cards use
41 a hardwired NuBus interrupt and a magic ISAIRQ value in the card.
42
43 * Basically eliminated everything not relevant to getting the
44 cards minimally functioning on the Macintosh.
45
46 I might add that these cards are badly designed even from the Mac
47 standpoint, in that Dayna, in their infinite wisdom, used NuBus slot
48 I/O space and NuBus interrupts for these cards, but neglected to
49 provide anything even remotely resembling a NuBus ROM. Therefore we
50 have to probe for them in a brain-damaged ISA-like fashion.
51
52 Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 11/01/2001
53 check kmalloc and release the allocated memory on failure in
54 mac89x0_probe and in init_module
55 use local_irq_{save,restore}(flags) in net_get_stat, not just
56 local_irq_{dis,en}able()
57*/
58
59static char *version =
60"cs89x0.c:v1.02 11/26/96 Russell Nelson <nelson@crynwr.com>\n";
61
62/* ======================= configure the driver here ======================= */
63
64/* use 0 for production, 1 for verification, >2 for debug */
65#ifndef NET_DEBUG
66#define NET_DEBUG 0
67#endif
68
69/* ======================= end of configuration ======================= */
70
71
72/* Always include 'config.h' first in case the user wants to turn on
73 or override something. */
74#include <linux/module.h>
75
76#define PRINTK(x) printk x
77
78/*
79 Sources:
80
81 Crynwr packet driver epktisa.
82
83 Crystal Semiconductor data sheets.
84
85*/
86
87#include <linux/kernel.h>
88#include <linux/types.h>
89#include <linux/fcntl.h>
90#include <linux/interrupt.h>
91#include <linux/ioport.h>
92#include <linux/in.h>
93#include <linux/slab.h>
94#include <linux/string.h>
95#include <linux/nubus.h>
96#include <linux/errno.h>
97#include <linux/init.h>
98#include <linux/netdevice.h>
99#include <linux/etherdevice.h>
100#include <linux/skbuff.h>
101#include <linux/delay.h>
102
103#include <asm/system.h>
104#include <asm/bitops.h>
105#include <asm/io.h>
106#include <asm/hwtest.h>
107#include <asm/macints.h>
108
109#include "cs89x0.h"
110
111static unsigned int net_debug = NET_DEBUG;
112
113/* Information that need to be kept for each board. */
114struct net_local {
115 struct net_device_stats stats;
116 int chip_type; /* one of: CS8900, CS8920, CS8920M */
117 char chip_revision; /* revision letter of the chip ('A'...) */
118 int send_cmd; /* the propercommand used to send a packet. */
119 int rx_mode;
120 int curr_rx_cfg;
121 int send_underrun; /* keep track of how many underruns in a row we get */
122 struct sk_buff *skb;
123};
124
125/* Index to functions, as function prototypes. */
126
127#if 0
128extern void reset_chip(struct net_device *dev);
129#endif
130static int net_open(struct net_device *dev);
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200131static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
David Howells7d12e782006-10-05 14:55:46 +0100132static irqreturn_t net_interrupt(int irq, void *dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133static void set_multicast_list(struct net_device *dev);
134static void net_rx(struct net_device *dev);
135static int net_close(struct net_device *dev);
136static struct net_device_stats *net_get_stats(struct net_device *dev);
137static int set_mac_address(struct net_device *dev, void *addr);
138
139
140/* Example routines you must write ;->. */
141#define tx_done(dev) 1
142
143/* For reading/writing registers ISA-style */
144static inline int
145readreg_io(struct net_device *dev, int portno)
146{
147 nubus_writew(swab16(portno), dev->base_addr + ADD_PORT);
148 return swab16(nubus_readw(dev->base_addr + DATA_PORT));
149}
150
151static inline void
152writereg_io(struct net_device *dev, int portno, int value)
153{
154 nubus_writew(swab16(portno), dev->base_addr + ADD_PORT);
155 nubus_writew(swab16(value), dev->base_addr + DATA_PORT);
156}
157
158/* These are for reading/writing registers in shared memory */
159static inline int
160readreg(struct net_device *dev, int portno)
161{
162 return swab16(nubus_readw(dev->mem_start + portno));
163}
164
165static inline void
166writereg(struct net_device *dev, int portno, int value)
167{
168 nubus_writew(swab16(value), dev->mem_start + portno);
169}
170
171/* Probe for the CS8900 card in slot E. We won't bother looking
172 anywhere else until we have a really good reason to do so. */
173struct net_device * __init mac89x0_probe(int unit)
174{
175 struct net_device *dev;
176 static int once_is_enough;
177 struct net_local *lp;
178 static unsigned version_printed;
179 int i, slot;
180 unsigned rev_type = 0;
181 unsigned long ioaddr;
182 unsigned short sig;
183 int err = -ENODEV;
184
185 dev = alloc_etherdev(sizeof(struct net_local));
186 if (!dev)
187 return ERR_PTR(-ENOMEM);
188
189 if (unit >= 0) {
190 sprintf(dev->name, "eth%d", unit);
191 netdev_boot_setup_check(dev);
192 }
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 if (once_is_enough)
195 goto out;
196 once_is_enough = 1;
197
198 /* We might have to parameterize this later */
199 slot = 0xE;
200 /* Get out now if there's a real NuBus card in slot E */
201 if (nubus_find_slot(slot, NULL) != NULL)
202 goto out;
203
204 /* The pseudo-ISA bits always live at offset 0x300 (gee,
205 wonder why...) */
206 ioaddr = (unsigned long)
207 nubus_slot_addr(slot) | (((slot&0xf) << 20) + DEFAULTIOBASE);
208 {
209 unsigned long flags;
210 int card_present;
Jeff Garzik6aa20a22006-09-13 13:24:59 -0400211
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 local_irq_save(flags);
213 card_present = hwreg_present((void*) ioaddr+4)
214 && hwreg_present((void*) ioaddr + DATA_PORT);
215 local_irq_restore(flags);
216
217 if (!card_present)
218 goto out;
219 }
220
221 nubus_writew(0, ioaddr + ADD_PORT);
222 sig = nubus_readw(ioaddr + DATA_PORT);
223 if (sig != swab16(CHIP_EISA_ID_SIG))
224 goto out;
225
226 /* Initialize the net_device structure. */
227 lp = netdev_priv(dev);
228
229 /* Fill in the 'dev' fields. */
230 dev->base_addr = ioaddr;
Jeff Garzik6aa20a22006-09-13 13:24:59 -0400231 dev->mem_start = (unsigned long)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 nubus_slot_addr(slot) | (((slot&0xf) << 20) + MMIOBASE);
233 dev->mem_end = dev->mem_start + 0x1000;
234
235 /* Turn on shared memory */
236 writereg_io(dev, PP_BusCTL, MEMORY_ON);
237
238 /* get the chip type */
239 rev_type = readreg(dev, PRODUCT_ID_ADD);
240 lp->chip_type = rev_type &~ REVISON_BITS;
241 lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';
242
243 /* Check the chip type and revision in order to set the correct send command
244 CS8920 revision C and CS8900 revision F can use the faster send. */
245 lp->send_cmd = TX_AFTER_381;
246 if (lp->chip_type == CS8900 && lp->chip_revision >= 'F')
247 lp->send_cmd = TX_NOW;
248 if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
249 lp->send_cmd = TX_NOW;
250
251 if (net_debug && version_printed++ == 0)
252 printk(version);
253
254 printk(KERN_INFO "%s: cs89%c0%s rev %c found at %#8lx",
255 dev->name,
256 lp->chip_type==CS8900?'0':'2',
257 lp->chip_type==CS8920M?"M":"",
258 lp->chip_revision,
259 dev->base_addr);
260
261 /* Try to read the MAC address */
262 if ((readreg(dev, PP_SelfST) & (EEPROM_PRESENT | EEPROM_OK)) == 0) {
263 printk("\nmac89x0: No EEPROM, giving up now.\n");
264 goto out1;
265 } else {
266 for (i = 0; i < ETH_ALEN; i += 2) {
267 /* Big-endian (why??!) */
268 unsigned short s = readreg(dev, PP_IA + i);
269 dev->dev_addr[i] = s >> 8;
270 dev->dev_addr[i+1] = s & 0xff;
271 }
272 }
273
274 dev->irq = SLOT2IRQ(slot);
275 printk(" IRQ %d ADDR ", dev->irq);
276
277 /* print the ethernet address. */
278 for (i = 0; i < ETH_ALEN; i++)
279 printk("%2.2x%s", dev->dev_addr[i],
280 ((i < ETH_ALEN-1) ? ":" : ""));
281 printk("\n");
282
283 dev->open = net_open;
284 dev->stop = net_close;
285 dev->hard_start_xmit = net_send_packet;
286 dev->get_stats = net_get_stats;
287 dev->set_multicast_list = &set_multicast_list;
288 dev->set_mac_address = &set_mac_address;
289
290 err = register_netdev(dev);
291 if (err)
292 goto out1;
293 return 0;
294out1:
295 nubus_writew(0, dev->base_addr + ADD_PORT);
296out:
297 free_netdev(dev);
298 return ERR_PTR(err);
299}
300
301#if 0
302/* This is useful for something, but I don't know what yet. */
303void __init reset_chip(struct net_device *dev)
304{
305 int reset_start_time;
306
307 writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET);
308
309 /* wait 30 ms */
310 msleep_interruptible(30);
311
312 /* Wait until the chip is reset */
313 reset_start_time = jiffies;
314 while( (readreg(dev, PP_SelfST) & INIT_DONE) == 0 && jiffies - reset_start_time < 2)
315 ;
316}
317#endif
318
319/* Open/initialize the board. This is called (in the current kernel)
320 sometime after booting when the 'ifconfig' program is run.
321
322 This routine should set everything up anew at each open, even
323 registers that "should" only need to be set once at boot, so that
324 there is non-reboot way to recover if something goes wrong.
325 */
326static int
327net_open(struct net_device *dev)
328{
329 struct net_local *lp = netdev_priv(dev);
330 int i;
331
332 /* Disable the interrupt for now */
333 writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL) & ~ENABLE_IRQ);
334
335 /* Grab the interrupt */
336 if (request_irq(dev->irq, &net_interrupt, 0, "cs89x0", dev))
337 return -EAGAIN;
338
339 /* Set up the IRQ - Apparently magic */
340 if (lp->chip_type == CS8900)
341 writereg(dev, PP_CS8900_ISAINT, 0);
342 else
343 writereg(dev, PP_CS8920_ISAINT, 0);
344
345 /* set the Ethernet address */
346 for (i=0; i < ETH_ALEN/2; i++)
347 writereg(dev, PP_IA+i*2, dev->dev_addr[i*2] | (dev->dev_addr[i*2+1] << 8));
348
349 /* Turn on both receive and transmit operations */
350 writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_RX_ON | SERIAL_TX_ON);
351
352 /* Receive only error free packets addressed to this card */
353 lp->rx_mode = 0;
354 writereg(dev, PP_RxCTL, DEF_RX_ACCEPT);
355
356 lp->curr_rx_cfg = RX_OK_ENBL | RX_CRC_ERROR_ENBL;
357
358 writereg(dev, PP_RxCFG, lp->curr_rx_cfg);
359
360 writereg(dev, PP_TxCFG, TX_LOST_CRS_ENBL | TX_SQE_ERROR_ENBL | TX_OK_ENBL |
361 TX_LATE_COL_ENBL | TX_JBR_ENBL | TX_ANY_COL_ENBL | TX_16_COL_ENBL);
362
363 writereg(dev, PP_BufCFG, READY_FOR_TX_ENBL | RX_MISS_COUNT_OVRFLOW_ENBL |
364 TX_COL_COUNT_OVRFLOW_ENBL | TX_UNDERRUN_ENBL);
365
366 /* now that we've got our act together, enable everything */
367 writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL) | ENABLE_IRQ);
368 netif_start_queue(dev);
369 return 0;
370}
371
372static int
373net_send_packet(struct sk_buff *skb, struct net_device *dev)
374{
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200375 struct net_local *lp = netdev_priv(dev);
376 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200378 if (net_debug > 3)
379 printk("%s: sent %d byte packet of type %x\n",
380 dev->name, skb->len,
381 (skb->data[ETH_ALEN+ETH_ALEN] << 8)
382 | skb->data[ETH_ALEN+ETH_ALEN+1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200384 /* keep the upload from being interrupted, since we
385 ask the chip to start transmitting before the
386 whole packet has been completely uploaded. */
387 local_irq_save(flags);
388 netif_stop_queue(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200390 /* initiate a transmit sequence */
391 writereg(dev, PP_TxCMD, lp->send_cmd);
392 writereg(dev, PP_TxLength, skb->len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200394 /* Test to see if the chip has allocated memory for the packet */
395 if ((readreg(dev, PP_BusST) & READY_FOR_TX_NOW) == 0) {
396 /* Gasp! It hasn't. But that shouldn't happen since
397 we're waiting for TxOk, so return 1 and requeue this packet. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 local_irq_restore(flags);
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200399 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 }
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200401
402 /* Write the contents of the packet */
403 skb_copy_from_linear_data(skb, (void *)(dev->mem_start + PP_TxFrame),
404 skb->len+1);
405
406 local_irq_restore(flags);
407 dev->trans_start = jiffies;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 dev_kfree_skb (skb);
409
410 return 0;
411}
Jeff Garzik6aa20a22006-09-13 13:24:59 -0400412
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413/* The typical workload of the driver:
414 Handle the network interface interrupts. */
David Howells7d12e782006-10-05 14:55:46 +0100415static irqreturn_t net_interrupt(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416{
417 struct net_device *dev = dev_id;
418 struct net_local *lp;
419 int ioaddr, status;
420
421 if (dev == NULL) {
422 printk ("net_interrupt(): irq %d for unknown device.\n", irq);
423 return IRQ_NONE;
424 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425
426 ioaddr = dev->base_addr;
427 lp = netdev_priv(dev);
428
429 /* we MUST read all the events out of the ISQ, otherwise we'll never
430 get interrupted again. As a consequence, we can't have any limit
431 on the number of times we loop in the interrupt handler. The
432 hardware guarantees that eventually we'll run out of events. Of
433 course, if you're on a slow machine, and packets are arriving
434 faster than you can read them off, you're screwed. Hasta la
435 vista, baby! */
436 while ((status = swab16(nubus_readw(dev->base_addr + ISQ_PORT)))) {
437 if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status);
438 switch(status & ISQ_EVENT_MASK) {
439 case ISQ_RECEIVER_EVENT:
440 /* Got a packet(s). */
441 net_rx(dev);
442 break;
443 case ISQ_TRANSMITTER_EVENT:
444 lp->stats.tx_packets++;
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200445 netif_wake_queue(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 if ((status & TX_OK) == 0) lp->stats.tx_errors++;
447 if (status & TX_LOST_CRS) lp->stats.tx_carrier_errors++;
448 if (status & TX_SQE_ERROR) lp->stats.tx_heartbeat_errors++;
449 if (status & TX_LATE_COL) lp->stats.tx_window_errors++;
450 if (status & TX_16_COL) lp->stats.tx_aborted_errors++;
451 break;
452 case ISQ_BUFFER_EVENT:
453 if (status & READY_FOR_TX) {
454 /* we tried to transmit a packet earlier,
455 but inexplicably ran out of buffers.
456 That shouldn't happen since we only ever
457 load one packet. Shrug. Do the right
458 thing anyway. */
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200459 netif_wake_queue(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 }
461 if (status & TX_UNDERRUN) {
462 if (net_debug > 0) printk("%s: transmit underrun\n", dev->name);
463 lp->send_underrun++;
464 if (lp->send_underrun == 3) lp->send_cmd = TX_AFTER_381;
465 else if (lp->send_underrun == 6) lp->send_cmd = TX_AFTER_ALL;
466 }
467 break;
468 case ISQ_RX_MISS_EVENT:
469 lp->stats.rx_missed_errors += (status >>6);
470 break;
471 case ISQ_TX_COL_EVENT:
472 lp->stats.collisions += (status >>6);
473 break;
474 }
475 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 return IRQ_HANDLED;
477}
478
479/* We have a good packet(s), get it/them out of the buffers. */
480static void
481net_rx(struct net_device *dev)
482{
483 struct net_local *lp = netdev_priv(dev);
484 struct sk_buff *skb;
485 int status, length;
486
487 status = readreg(dev, PP_RxStatus);
488 if ((status & RX_OK) == 0) {
489 lp->stats.rx_errors++;
490 if (status & RX_RUNT) lp->stats.rx_length_errors++;
491 if (status & RX_EXTRA_DATA) lp->stats.rx_length_errors++;
492 if (status & RX_CRC_ERROR) if (!(status & (RX_EXTRA_DATA|RX_RUNT)))
493 /* per str 172 */
494 lp->stats.rx_crc_errors++;
495 if (status & RX_DRIBBLE) lp->stats.rx_frame_errors++;
496 return;
497 }
498
499 length = readreg(dev, PP_RxLength);
500 /* Malloc up new buffer. */
501 skb = alloc_skb(length, GFP_ATOMIC);
502 if (skb == NULL) {
503 printk("%s: Memory squeeze, dropping packet.\n", dev->name);
504 lp->stats.rx_dropped++;
505 return;
506 }
507 skb_put(skb, length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
Matthias Urlichs39ad2cb2007-05-01 22:32:41 +0200509 skb_copy_to_linear_data(skb, (void *)(dev->mem_start + PP_RxFrame),
510 length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511
512 if (net_debug > 3)printk("%s: received %d byte packet of type %x\n",
513 dev->name, length,
514 (skb->data[ETH_ALEN+ETH_ALEN] << 8)
515 | skb->data[ETH_ALEN+ETH_ALEN+1]);
516
517 skb->protocol=eth_type_trans(skb,dev);
518 netif_rx(skb);
519 dev->last_rx = jiffies;
520 lp->stats.rx_packets++;
521 lp->stats.rx_bytes += length;
522}
523
524/* The inverse routine to net_open(). */
525static int
526net_close(struct net_device *dev)
527{
528
529 writereg(dev, PP_RxCFG, 0);
530 writereg(dev, PP_TxCFG, 0);
531 writereg(dev, PP_BufCFG, 0);
532 writereg(dev, PP_BusCTL, 0);
533
534 netif_stop_queue(dev);
535
536 free_irq(dev->irq, dev);
537
538 /* Update the statistics here. */
539
540 return 0;
541
542}
543
544/* Get the current statistics. This may be called with the card open or
545 closed. */
546static struct net_device_stats *
547net_get_stats(struct net_device *dev)
548{
549 struct net_local *lp = netdev_priv(dev);
550 unsigned long flags;
551
552 local_irq_save(flags);
553 /* Update the statistics from the device registers. */
554 lp->stats.rx_missed_errors += (readreg(dev, PP_RxMiss) >> 6);
555 lp->stats.collisions += (readreg(dev, PP_TxCol) >> 6);
556 local_irq_restore(flags);
557
558 return &lp->stats;
559}
560
561static void set_multicast_list(struct net_device *dev)
562{
563 struct net_local *lp = netdev_priv(dev);
564
565 if(dev->flags&IFF_PROMISC)
566 {
567 lp->rx_mode = RX_ALL_ACCEPT;
568 }
569 else if((dev->flags&IFF_ALLMULTI)||dev->mc_list)
570 {
571 /* The multicast-accept list is initialized to accept-all, and we
572 rely on higher-level filtering for now. */
573 lp->rx_mode = RX_MULTCAST_ACCEPT;
Jeff Garzik6aa20a22006-09-13 13:24:59 -0400574 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 else
576 lp->rx_mode = 0;
577
578 writereg(dev, PP_RxCTL, DEF_RX_ACCEPT | lp->rx_mode);
579
580 /* in promiscuous mode, we accept errored packets, so we have to enable interrupts on them also */
581 writereg(dev, PP_RxCFG, lp->curr_rx_cfg |
582 (lp->rx_mode == RX_ALL_ACCEPT? (RX_CRC_ERROR_ENBL|RX_RUNT_ENBL|RX_EXTRA_DATA_ENBL) : 0));
583}
584
585
586static int set_mac_address(struct net_device *dev, void *addr)
587{
588 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 printk("%s: Setting MAC address to ", dev->name);
590 for (i = 0; i < 6; i++)
591 printk(" %2.2x", dev->dev_addr[i] = ((unsigned char *)addr)[i]);
592 printk(".\n");
593 /* set the Ethernet address */
594 for (i=0; i < ETH_ALEN/2; i++)
595 writereg(dev, PP_IA+i*2, dev->dev_addr[i*2] | (dev->dev_addr[i*2+1] << 8));
596
597 return 0;
598}
599
600#ifdef MODULE
601
602static struct net_device *dev_cs89x0;
603static int debug;
604
Rusty Russell8d3b33f2006-03-25 03:07:05 -0800605module_param(debug, int, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606MODULE_PARM_DESC(debug, "CS89[02]0 debug level (0-5)");
607MODULE_LICENSE("GPL");
608
Al Viro446df4c2007-07-20 04:33:48 +0100609int __init
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610init_module(void)
611{
612 net_debug = debug;
613 dev_cs89x0 = mac89x0_probe(-1);
614 if (IS_ERR(dev_cs89x0)) {
615 printk(KERN_WARNING "mac89x0.c: No card found\n");
616 return PTR_ERR(dev_cs89x0);
617 }
618 return 0;
619}
620
621void
622cleanup_module(void)
623{
624 unregister_netdev(dev_cs89x0);
625 nubus_writew(0, dev_cs89x0->base_addr + ADD_PORT);
626 free_netdev(dev_cs89x0);
627}
628#endif /* MODULE */
Jeff Garzik6aa20a22006-09-13 13:24:59 -0400629
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630/*
631 * Local variables:
632 * 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 mac89x0.o mac89x0.c"
633 * version-control: t
634 * kept-new-versions: 5
635 * c-indent-level: 8
636 * tab-width: 8
637 * End:
638 *
639 */