mac89x0.c 18 KB

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