mac89x0.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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/io.h>
  77. #include <asm/hwtest.h>
  78. #include <asm/macints.h>
  79. #include "cs89x0.h"
  80. static unsigned int net_debug = NET_DEBUG;
  81. /* Information that need to be kept for each board. */
  82. struct net_local {
  83. int chip_type; /* one of: CS8900, CS8920, CS8920M */
  84. char chip_revision; /* revision letter of the chip ('A'...) */
  85. int send_cmd; /* the propercommand used to send a packet. */
  86. int rx_mode;
  87. int curr_rx_cfg;
  88. int send_underrun; /* keep track of how many underruns in a row we get */
  89. struct sk_buff *skb;
  90. };
  91. /* Index to functions, as function prototypes. */
  92. #if 0
  93. extern void reset_chip(struct net_device *dev);
  94. #endif
  95. static int net_open(struct net_device *dev);
  96. static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
  97. static irqreturn_t net_interrupt(int irq, void *dev_id);
  98. static void set_multicast_list(struct net_device *dev);
  99. static void net_rx(struct net_device *dev);
  100. static int net_close(struct net_device *dev);
  101. static struct net_device_stats *net_get_stats(struct net_device *dev);
  102. static int set_mac_address(struct net_device *dev, void *addr);
  103. /* Example routines you must write ;->. */
  104. #define tx_done(dev) 1
  105. /* For reading/writing registers ISA-style */
  106. static inline int
  107. readreg_io(struct net_device *dev, int portno)
  108. {
  109. nubus_writew(swab16(portno), dev->base_addr + ADD_PORT);
  110. return swab16(nubus_readw(dev->base_addr + DATA_PORT));
  111. }
  112. static inline void
  113. writereg_io(struct net_device *dev, int portno, int value)
  114. {
  115. nubus_writew(swab16(portno), dev->base_addr + ADD_PORT);
  116. nubus_writew(swab16(value), dev->base_addr + DATA_PORT);
  117. }
  118. /* These are for reading/writing registers in shared memory */
  119. static inline int
  120. readreg(struct net_device *dev, int portno)
  121. {
  122. return swab16(nubus_readw(dev->mem_start + portno));
  123. }
  124. static inline void
  125. writereg(struct net_device *dev, int portno, int value)
  126. {
  127. nubus_writew(swab16(value), dev->mem_start + portno);
  128. }
  129. static const struct net_device_ops mac89x0_netdev_ops = {
  130. .ndo_open = net_open,
  131. .ndo_stop = net_close,
  132. .ndo_start_xmit = net_send_packet,
  133. .ndo_get_stats = net_get_stats,
  134. .ndo_set_rx_mode = set_multicast_list,
  135. .ndo_set_mac_address = set_mac_address,
  136. .ndo_validate_addr = eth_validate_addr,
  137. .ndo_change_mtu = eth_change_mtu,
  138. };
  139. /* Probe for the CS8900 card in slot E. We won't bother looking
  140. anywhere else until we have a really good reason to do so. */
  141. struct net_device * __init mac89x0_probe(int unit)
  142. {
  143. struct net_device *dev;
  144. static int once_is_enough;
  145. struct net_local *lp;
  146. static unsigned version_printed;
  147. int i, slot;
  148. unsigned rev_type = 0;
  149. unsigned long ioaddr;
  150. unsigned short sig;
  151. int err = -ENODEV;
  152. if (!MACH_IS_MAC)
  153. return ERR_PTR(-ENODEV);
  154. dev = alloc_etherdev(sizeof(struct net_local));
  155. if (!dev)
  156. return ERR_PTR(-ENOMEM);
  157. if (unit >= 0) {
  158. sprintf(dev->name, "eth%d", unit);
  159. netdev_boot_setup_check(dev);
  160. }
  161. if (once_is_enough)
  162. goto out;
  163. once_is_enough = 1;
  164. /* We might have to parameterize this later */
  165. slot = 0xE;
  166. /* Get out now if there's a real NuBus card in slot E */
  167. if (nubus_find_slot(slot, NULL) != NULL)
  168. goto out;
  169. /* The pseudo-ISA bits always live at offset 0x300 (gee,
  170. wonder why...) */
  171. ioaddr = (unsigned long)
  172. nubus_slot_addr(slot) | (((slot&0xf) << 20) + DEFAULTIOBASE);
  173. {
  174. int card_present;
  175. card_present = (hwreg_present((void *)ioaddr + 4) &&
  176. hwreg_present((void *)ioaddr + DATA_PORT));
  177. if (!card_present)
  178. goto out;
  179. }
  180. nubus_writew(0, ioaddr + ADD_PORT);
  181. sig = nubus_readw(ioaddr + DATA_PORT);
  182. if (sig != swab16(CHIP_EISA_ID_SIG))
  183. goto out;
  184. /* Initialize the net_device structure. */
  185. lp = netdev_priv(dev);
  186. /* Fill in the 'dev' fields. */
  187. dev->base_addr = ioaddr;
  188. dev->mem_start = (unsigned long)
  189. nubus_slot_addr(slot) | (((slot&0xf) << 20) + MMIOBASE);
  190. dev->mem_end = dev->mem_start + 0x1000;
  191. /* Turn on shared memory */
  192. writereg_io(dev, PP_BusCTL, MEMORY_ON);
  193. /* get the chip type */
  194. rev_type = readreg(dev, PRODUCT_ID_ADD);
  195. lp->chip_type = rev_type &~ REVISON_BITS;
  196. lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';
  197. /* Check the chip type and revision in order to set the correct send command
  198. CS8920 revision C and CS8900 revision F can use the faster send. */
  199. lp->send_cmd = TX_AFTER_381;
  200. if (lp->chip_type == CS8900 && lp->chip_revision >= 'F')
  201. lp->send_cmd = TX_NOW;
  202. if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
  203. lp->send_cmd = TX_NOW;
  204. if (net_debug && version_printed++ == 0)
  205. printk(version);
  206. printk(KERN_INFO "%s: cs89%c0%s rev %c found at %#8lx",
  207. dev->name,
  208. lp->chip_type==CS8900?'0':'2',
  209. lp->chip_type==CS8920M?"M":"",
  210. lp->chip_revision,
  211. dev->base_addr);
  212. /* Try to read the MAC address */
  213. if ((readreg(dev, PP_SelfST) & (EEPROM_PRESENT | EEPROM_OK)) == 0) {
  214. printk("\nmac89x0: No EEPROM, giving up now.\n");
  215. goto out1;
  216. } else {
  217. for (i = 0; i < ETH_ALEN; i += 2) {
  218. /* Big-endian (why??!) */
  219. unsigned short s = readreg(dev, PP_IA + i);
  220. dev->dev_addr[i] = s >> 8;
  221. dev->dev_addr[i+1] = s & 0xff;
  222. }
  223. }
  224. dev->irq = SLOT2IRQ(slot);
  225. /* print the IRQ and ethernet address. */
  226. printk(" IRQ %d ADDR %pM\n", dev->irq, dev->dev_addr);
  227. dev->netdev_ops = &mac89x0_netdev_ops;
  228. err = register_netdev(dev);
  229. if (err)
  230. goto out1;
  231. return NULL;
  232. out1:
  233. nubus_writew(0, dev->base_addr + ADD_PORT);
  234. out:
  235. free_netdev(dev);
  236. return ERR_PTR(err);
  237. }
  238. #if 0
  239. /* This is useful for something, but I don't know what yet. */
  240. void __init reset_chip(struct net_device *dev)
  241. {
  242. int reset_start_time;
  243. writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET);
  244. /* wait 30 ms */
  245. msleep_interruptible(30);
  246. /* Wait until the chip is reset */
  247. reset_start_time = jiffies;
  248. while( (readreg(dev, PP_SelfST) & INIT_DONE) == 0 && jiffies - reset_start_time < 2)
  249. ;
  250. }
  251. #endif
  252. /* Open/initialize the board. This is called (in the current kernel)
  253. sometime after booting when the 'ifconfig' program is run.
  254. This routine should set everything up anew at each open, even
  255. registers that "should" only need to be set once at boot, so that
  256. there is non-reboot way to recover if something goes wrong.
  257. */
  258. static int
  259. net_open(struct net_device *dev)
  260. {
  261. struct net_local *lp = netdev_priv(dev);
  262. int i;
  263. /* Disable the interrupt for now */
  264. writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL) & ~ENABLE_IRQ);
  265. /* Grab the interrupt */
  266. if (request_irq(dev->irq, net_interrupt, 0, "cs89x0", dev))
  267. return -EAGAIN;
  268. /* Set up the IRQ - Apparently magic */
  269. if (lp->chip_type == CS8900)
  270. writereg(dev, PP_CS8900_ISAINT, 0);
  271. else
  272. writereg(dev, PP_CS8920_ISAINT, 0);
  273. /* set the Ethernet address */
  274. for (i=0; i < ETH_ALEN/2; i++)
  275. writereg(dev, PP_IA+i*2, dev->dev_addr[i*2] | (dev->dev_addr[i*2+1] << 8));
  276. /* Turn on both receive and transmit operations */
  277. writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_RX_ON | SERIAL_TX_ON);
  278. /* Receive only error free packets addressed to this card */
  279. lp->rx_mode = 0;
  280. writereg(dev, PP_RxCTL, DEF_RX_ACCEPT);
  281. lp->curr_rx_cfg = RX_OK_ENBL | RX_CRC_ERROR_ENBL;
  282. writereg(dev, PP_RxCFG, lp->curr_rx_cfg);
  283. writereg(dev, PP_TxCFG, TX_LOST_CRS_ENBL | TX_SQE_ERROR_ENBL | TX_OK_ENBL |
  284. TX_LATE_COL_ENBL | TX_JBR_ENBL | TX_ANY_COL_ENBL | TX_16_COL_ENBL);
  285. writereg(dev, PP_BufCFG, READY_FOR_TX_ENBL | RX_MISS_COUNT_OVRFLOW_ENBL |
  286. TX_COL_COUNT_OVRFLOW_ENBL | TX_UNDERRUN_ENBL);
  287. /* now that we've got our act together, enable everything */
  288. writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL) | ENABLE_IRQ);
  289. netif_start_queue(dev);
  290. return 0;
  291. }
  292. static int
  293. net_send_packet(struct sk_buff *skb, struct net_device *dev)
  294. {
  295. struct net_local *lp = netdev_priv(dev);
  296. unsigned long flags;
  297. if (net_debug > 3)
  298. printk("%s: sent %d byte packet of type %x\n",
  299. dev->name, skb->len,
  300. (skb->data[ETH_ALEN+ETH_ALEN] << 8)
  301. | skb->data[ETH_ALEN+ETH_ALEN+1]);
  302. /* keep the upload from being interrupted, since we
  303. ask the chip to start transmitting before the
  304. whole packet has been completely uploaded. */
  305. local_irq_save(flags);
  306. netif_stop_queue(dev);
  307. /* initiate a transmit sequence */
  308. writereg(dev, PP_TxCMD, lp->send_cmd);
  309. writereg(dev, PP_TxLength, skb->len);
  310. /* Test to see if the chip has allocated memory for the packet */
  311. if ((readreg(dev, PP_BusST) & READY_FOR_TX_NOW) == 0) {
  312. /* Gasp! It hasn't. But that shouldn't happen since
  313. we're waiting for TxOk, so return 1 and requeue this packet. */
  314. local_irq_restore(flags);
  315. return NETDEV_TX_BUSY;
  316. }
  317. /* Write the contents of the packet */
  318. skb_copy_from_linear_data(skb, (void *)(dev->mem_start + PP_TxFrame),
  319. skb->len+1);
  320. local_irq_restore(flags);
  321. dev_kfree_skb (skb);
  322. return NETDEV_TX_OK;
  323. }
  324. /* The typical workload of the driver:
  325. Handle the network interface interrupts. */
  326. static irqreturn_t net_interrupt(int irq, void *dev_id)
  327. {
  328. struct net_device *dev = dev_id;
  329. struct net_local *lp;
  330. int ioaddr, status;
  331. if (dev == NULL) {
  332. printk ("net_interrupt(): irq %d for unknown device.\n", irq);
  333. return IRQ_NONE;
  334. }
  335. ioaddr = dev->base_addr;
  336. lp = netdev_priv(dev);
  337. /* we MUST read all the events out of the ISQ, otherwise we'll never
  338. get interrupted again. As a consequence, we can't have any limit
  339. on the number of times we loop in the interrupt handler. The
  340. hardware guarantees that eventually we'll run out of events. Of
  341. course, if you're on a slow machine, and packets are arriving
  342. faster than you can read them off, you're screwed. Hasta la
  343. vista, baby! */
  344. while ((status = swab16(nubus_readw(dev->base_addr + ISQ_PORT)))) {
  345. if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status);
  346. switch(status & ISQ_EVENT_MASK) {
  347. case ISQ_RECEIVER_EVENT:
  348. /* Got a packet(s). */
  349. net_rx(dev);
  350. break;
  351. case ISQ_TRANSMITTER_EVENT:
  352. dev->stats.tx_packets++;
  353. netif_wake_queue(dev);
  354. if ((status & TX_OK) == 0)
  355. dev->stats.tx_errors++;
  356. if (status & TX_LOST_CRS)
  357. dev->stats.tx_carrier_errors++;
  358. if (status & TX_SQE_ERROR)
  359. dev->stats.tx_heartbeat_errors++;
  360. if (status & TX_LATE_COL)
  361. dev->stats.tx_window_errors++;
  362. if (status & TX_16_COL)
  363. dev->stats.tx_aborted_errors++;
  364. break;
  365. case ISQ_BUFFER_EVENT:
  366. if (status & READY_FOR_TX) {
  367. /* we tried to transmit a packet earlier,
  368. but inexplicably ran out of buffers.
  369. That shouldn't happen since we only ever
  370. load one packet. Shrug. Do the right
  371. thing anyway. */
  372. netif_wake_queue(dev);
  373. }
  374. if (status & TX_UNDERRUN) {
  375. if (net_debug > 0) printk("%s: transmit underrun\n", dev->name);
  376. lp->send_underrun++;
  377. if (lp->send_underrun == 3) lp->send_cmd = TX_AFTER_381;
  378. else if (lp->send_underrun == 6) lp->send_cmd = TX_AFTER_ALL;
  379. }
  380. break;
  381. case ISQ_RX_MISS_EVENT:
  382. dev->stats.rx_missed_errors += (status >> 6);
  383. break;
  384. case ISQ_TX_COL_EVENT:
  385. dev->stats.collisions += (status >> 6);
  386. break;
  387. }
  388. }
  389. return IRQ_HANDLED;
  390. }
  391. /* We have a good packet(s), get it/them out of the buffers. */
  392. static void
  393. net_rx(struct net_device *dev)
  394. {
  395. struct sk_buff *skb;
  396. int status, length;
  397. status = readreg(dev, PP_RxStatus);
  398. if ((status & RX_OK) == 0) {
  399. dev->stats.rx_errors++;
  400. if (status & RX_RUNT)
  401. dev->stats.rx_length_errors++;
  402. if (status & RX_EXTRA_DATA)
  403. dev->stats.rx_length_errors++;
  404. if ((status & RX_CRC_ERROR) &&
  405. !(status & (RX_EXTRA_DATA|RX_RUNT)))
  406. /* per str 172 */
  407. dev->stats.rx_crc_errors++;
  408. if (status & RX_DRIBBLE)
  409. dev->stats.rx_frame_errors++;
  410. return;
  411. }
  412. length = readreg(dev, PP_RxLength);
  413. /* Malloc up new buffer. */
  414. skb = alloc_skb(length, GFP_ATOMIC);
  415. if (skb == NULL) {
  416. printk("%s: Memory squeeze, dropping packet.\n", dev->name);
  417. dev->stats.rx_dropped++;
  418. return;
  419. }
  420. skb_put(skb, length);
  421. skb_copy_to_linear_data(skb, (void *)(dev->mem_start + PP_RxFrame),
  422. length);
  423. if (net_debug > 3)printk("%s: received %d byte packet of type %x\n",
  424. dev->name, length,
  425. (skb->data[ETH_ALEN+ETH_ALEN] << 8)
  426. | skb->data[ETH_ALEN+ETH_ALEN+1]);
  427. skb->protocol=eth_type_trans(skb,dev);
  428. netif_rx(skb);
  429. dev->stats.rx_packets++;
  430. dev->stats.rx_bytes += length;
  431. }
  432. /* The inverse routine to net_open(). */
  433. static int
  434. net_close(struct net_device *dev)
  435. {
  436. writereg(dev, PP_RxCFG, 0);
  437. writereg(dev, PP_TxCFG, 0);
  438. writereg(dev, PP_BufCFG, 0);
  439. writereg(dev, PP_BusCTL, 0);
  440. netif_stop_queue(dev);
  441. free_irq(dev->irq, dev);
  442. /* Update the statistics here. */
  443. return 0;
  444. }
  445. /* Get the current statistics. This may be called with the card open or
  446. closed. */
  447. static struct net_device_stats *
  448. net_get_stats(struct net_device *dev)
  449. {
  450. unsigned long flags;
  451. local_irq_save(flags);
  452. /* Update the statistics from the device registers. */
  453. dev->stats.rx_missed_errors += (readreg(dev, PP_RxMiss) >> 6);
  454. dev->stats.collisions += (readreg(dev, PP_TxCol) >> 6);
  455. local_irq_restore(flags);
  456. return &dev->stats;
  457. }
  458. static void set_multicast_list(struct net_device *dev)
  459. {
  460. struct net_local *lp = netdev_priv(dev);
  461. if(dev->flags&IFF_PROMISC)
  462. {
  463. lp->rx_mode = RX_ALL_ACCEPT;
  464. } else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev)) {
  465. /* The multicast-accept list is initialized to accept-all, and we
  466. rely on higher-level filtering for now. */
  467. lp->rx_mode = RX_MULTCAST_ACCEPT;
  468. }
  469. else
  470. lp->rx_mode = 0;
  471. writereg(dev, PP_RxCTL, DEF_RX_ACCEPT | lp->rx_mode);
  472. /* in promiscuous mode, we accept errored packets, so we have to enable interrupts on them also */
  473. writereg(dev, PP_RxCFG, lp->curr_rx_cfg |
  474. (lp->rx_mode == RX_ALL_ACCEPT? (RX_CRC_ERROR_ENBL|RX_RUNT_ENBL|RX_EXTRA_DATA_ENBL) : 0));
  475. }
  476. static int set_mac_address(struct net_device *dev, void *addr)
  477. {
  478. struct sockaddr *saddr = addr;
  479. int i;
  480. if (!is_valid_ether_addr(saddr->sa_data))
  481. return -EADDRNOTAVAIL;
  482. memcpy(dev->dev_addr, saddr->sa_data, ETH_ALEN);
  483. printk("%s: Setting MAC address to %pM\n", dev->name, dev->dev_addr);
  484. /* set the Ethernet address */
  485. for (i=0; i < ETH_ALEN/2; i++)
  486. writereg(dev, PP_IA+i*2, dev->dev_addr[i*2] | (dev->dev_addr[i*2+1] << 8));
  487. return 0;
  488. }
  489. #ifdef MODULE
  490. static struct net_device *dev_cs89x0;
  491. static int debug;
  492. module_param(debug, int, 0);
  493. MODULE_PARM_DESC(debug, "CS89[02]0 debug level (0-5)");
  494. MODULE_LICENSE("GPL");
  495. int __init
  496. init_module(void)
  497. {
  498. net_debug = debug;
  499. dev_cs89x0 = mac89x0_probe(-1);
  500. if (IS_ERR(dev_cs89x0)) {
  501. printk(KERN_WARNING "mac89x0.c: No card found\n");
  502. return PTR_ERR(dev_cs89x0);
  503. }
  504. return 0;
  505. }
  506. void
  507. cleanup_module(void)
  508. {
  509. unregister_netdev(dev_cs89x0);
  510. nubus_writew(0, dev_cs89x0->base_addr + ADD_PORT);
  511. free_netdev(dev_cs89x0);
  512. }
  513. #endif /* MODULE */