/drivers/net/ethernet/natsemi/macsonic.c

http://github.com/mirrors/linux · C · 638 lines · 430 code · 101 blank · 107 comment · 75 complexity · e5dce86b58ab9a19a858a42d63e60101 MD5 · raw file

  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * macsonic.c
  4. *
  5. * (C) 2005 Finn Thain
  6. *
  7. * Converted to DMA API, converted to unified driver model, made it work as
  8. * a module again, and from the mac68k project, introduced more 32-bit cards
  9. * and dhd's support for 16-bit cards.
  10. *
  11. * (C) 1998 Alan Cox
  12. *
  13. * Debugging Andreas Ehliar, Michael Schmitz
  14. *
  15. * Based on code
  16. * (C) 1996 by Thomas Bogendoerfer (tsbogend@bigbug.franken.de)
  17. *
  18. * This driver is based on work from Andreas Busse, but most of
  19. * the code is rewritten.
  20. *
  21. * (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de)
  22. *
  23. * A driver for the Mac onboard Sonic ethernet chip.
  24. *
  25. * 98/12/21 MSch: judged from tests on Q800, it's basically working,
  26. * but eating up both receive and transmit resources
  27. * and duplicating packets. Needs more testing.
  28. *
  29. * 99/01/03 MSch: upgraded to version 0.92 of the core driver, fixed.
  30. *
  31. * 00/10/31 sammy@oh.verio.com: Updated driver for 2.4 kernels, fixed problems
  32. * on centris.
  33. */
  34. #include <linux/kernel.h>
  35. #include <linux/module.h>
  36. #include <linux/types.h>
  37. #include <linux/fcntl.h>
  38. #include <linux/gfp.h>
  39. #include <linux/interrupt.h>
  40. #include <linux/ioport.h>
  41. #include <linux/in.h>
  42. #include <linux/string.h>
  43. #include <linux/delay.h>
  44. #include <linux/nubus.h>
  45. #include <linux/errno.h>
  46. #include <linux/netdevice.h>
  47. #include <linux/etherdevice.h>
  48. #include <linux/skbuff.h>
  49. #include <linux/platform_device.h>
  50. #include <linux/dma-mapping.h>
  51. #include <linux/bitrev.h>
  52. #include <linux/slab.h>
  53. #include <asm/pgtable.h>
  54. #include <asm/io.h>
  55. #include <asm/hwtest.h>
  56. #include <asm/dma.h>
  57. #include <asm/macintosh.h>
  58. #include <asm/macints.h>
  59. #include <asm/mac_via.h>
  60. #include "sonic.h"
  61. /* These should basically be bus-size and endian independent (since
  62. the SONIC is at least smart enough that it uses the same endianness
  63. as the host, unlike certain less enlightened Macintosh NICs) */
  64. #define SONIC_READ(reg) (nubus_readw(dev->base_addr + (reg * 4) \
  65. + lp->reg_offset))
  66. #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
  67. + lp->reg_offset))
  68. /* For onboard SONIC */
  69. #define ONBOARD_SONIC_REGISTERS 0x50F0A000
  70. #define ONBOARD_SONIC_PROM_BASE 0x50f08000
  71. enum macsonic_type {
  72. MACSONIC_DUODOCK,
  73. MACSONIC_APPLE,
  74. MACSONIC_APPLE16,
  75. MACSONIC_DAYNA,
  76. MACSONIC_DAYNALINK
  77. };
  78. /* For the built-in SONIC in the Duo Dock */
  79. #define DUODOCK_SONIC_REGISTERS 0xe10000
  80. #define DUODOCK_SONIC_PROM_BASE 0xe12000
  81. /* For Apple-style NuBus SONIC */
  82. #define APPLE_SONIC_REGISTERS 0
  83. #define APPLE_SONIC_PROM_BASE 0x40000
  84. /* Daynalink LC SONIC */
  85. #define DAYNALINK_PROM_BASE 0x400000
  86. /* For Dayna-style NuBus SONIC (haven't seen one yet) */
  87. #define DAYNA_SONIC_REGISTERS 0x180000
  88. /* This is what OpenBSD says. However, this is definitely in NuBus
  89. ROM space so we should be able to get it by walking the NuBus
  90. resource directories */
  91. #define DAYNA_SONIC_MAC_ADDR 0xffe004
  92. #define SONIC_READ_PROM(addr) nubus_readb(prom_addr+addr)
  93. /*
  94. * For reversing the PROM address
  95. */
  96. static inline void bit_reverse_addr(unsigned char addr[6])
  97. {
  98. int i;
  99. for(i = 0; i < 6; i++)
  100. addr[i] = bitrev8(addr[i]);
  101. }
  102. static int macsonic_open(struct net_device* dev)
  103. {
  104. int retval;
  105. retval = request_irq(dev->irq, sonic_interrupt, 0, "sonic", dev);
  106. if (retval) {
  107. printk(KERN_ERR "%s: unable to get IRQ %d.\n",
  108. dev->name, dev->irq);
  109. goto err;
  110. }
  111. /* Under the A/UX interrupt scheme, the onboard SONIC interrupt gets
  112. * moved from level 2 to level 3. Unfortunately we still get some
  113. * level 2 interrupts so register the handler for both.
  114. */
  115. if (dev->irq == IRQ_AUTO_3) {
  116. retval = request_irq(IRQ_NUBUS_9, sonic_interrupt, 0,
  117. "sonic", dev);
  118. if (retval) {
  119. printk(KERN_ERR "%s: unable to get IRQ %d.\n",
  120. dev->name, IRQ_NUBUS_9);
  121. goto err_irq;
  122. }
  123. }
  124. retval = sonic_open(dev);
  125. if (retval)
  126. goto err_irq_nubus;
  127. return 0;
  128. err_irq_nubus:
  129. if (dev->irq == IRQ_AUTO_3)
  130. free_irq(IRQ_NUBUS_9, dev);
  131. err_irq:
  132. free_irq(dev->irq, dev);
  133. err:
  134. return retval;
  135. }
  136. static int macsonic_close(struct net_device* dev)
  137. {
  138. int err;
  139. err = sonic_close(dev);
  140. free_irq(dev->irq, dev);
  141. if (dev->irq == IRQ_AUTO_3)
  142. free_irq(IRQ_NUBUS_9, dev);
  143. return err;
  144. }
  145. static const struct net_device_ops macsonic_netdev_ops = {
  146. .ndo_open = macsonic_open,
  147. .ndo_stop = macsonic_close,
  148. .ndo_start_xmit = sonic_send_packet,
  149. .ndo_set_rx_mode = sonic_multicast_list,
  150. .ndo_tx_timeout = sonic_tx_timeout,
  151. .ndo_get_stats = sonic_get_stats,
  152. .ndo_validate_addr = eth_validate_addr,
  153. .ndo_set_mac_address = eth_mac_addr,
  154. };
  155. static int macsonic_init(struct net_device *dev)
  156. {
  157. struct sonic_local* lp = netdev_priv(dev);
  158. int err = sonic_alloc_descriptors(dev);
  159. if (err)
  160. return err;
  161. dev->netdev_ops = &macsonic_netdev_ops;
  162. dev->watchdog_timeo = TX_TIMEOUT;
  163. /*
  164. * clear tally counter
  165. */
  166. SONIC_WRITE(SONIC_CRCT, 0xffff);
  167. SONIC_WRITE(SONIC_FAET, 0xffff);
  168. SONIC_WRITE(SONIC_MPT, 0xffff);
  169. return 0;
  170. }
  171. #define INVALID_MAC(mac) (memcmp(mac, "\x08\x00\x07", 3) && \
  172. memcmp(mac, "\x00\xA0\x40", 3) && \
  173. memcmp(mac, "\x00\x80\x19", 3) && \
  174. memcmp(mac, "\x00\x05\x02", 3))
  175. static void mac_onboard_sonic_ethernet_addr(struct net_device *dev)
  176. {
  177. struct sonic_local *lp = netdev_priv(dev);
  178. const int prom_addr = ONBOARD_SONIC_PROM_BASE;
  179. unsigned short val;
  180. /*
  181. * On NuBus boards we can sometimes look in the ROM resources.
  182. * No such luck for comm-slot/onboard.
  183. * On the PowerBook 520, the PROM base address is a mystery.
  184. */
  185. if (hwreg_present((void *)prom_addr)) {
  186. int i;
  187. for (i = 0; i < 6; i++)
  188. dev->dev_addr[i] = SONIC_READ_PROM(i);
  189. if (!INVALID_MAC(dev->dev_addr))
  190. return;
  191. /*
  192. * Most of the time, the address is bit-reversed. The NetBSD
  193. * source has a rather long and detailed historical account of
  194. * why this is so.
  195. */
  196. bit_reverse_addr(dev->dev_addr);
  197. if (!INVALID_MAC(dev->dev_addr))
  198. return;
  199. /*
  200. * If we still have what seems to be a bogus address, we'll
  201. * look in the CAM. The top entry should be ours.
  202. */
  203. printk(KERN_WARNING "macsonic: MAC address in PROM seems "
  204. "to be invalid, trying CAM\n");
  205. } else {
  206. printk(KERN_WARNING "macsonic: cannot read MAC address from "
  207. "PROM, trying CAM\n");
  208. }
  209. /* This only works if MacOS has already initialized the card. */
  210. SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
  211. SONIC_WRITE(SONIC_CEP, 15);
  212. val = SONIC_READ(SONIC_CAP2);
  213. dev->dev_addr[5] = val >> 8;
  214. dev->dev_addr[4] = val & 0xff;
  215. val = SONIC_READ(SONIC_CAP1);
  216. dev->dev_addr[3] = val >> 8;
  217. dev->dev_addr[2] = val & 0xff;
  218. val = SONIC_READ(SONIC_CAP0);
  219. dev->dev_addr[1] = val >> 8;
  220. dev->dev_addr[0] = val & 0xff;
  221. if (!INVALID_MAC(dev->dev_addr))
  222. return;
  223. /* Still nonsense ... messed up someplace! */
  224. printk(KERN_WARNING "macsonic: MAC address in CAM entry 15 "
  225. "seems invalid, will use a random MAC\n");
  226. eth_hw_addr_random(dev);
  227. }
  228. static int mac_onboard_sonic_probe(struct net_device *dev)
  229. {
  230. struct sonic_local* lp = netdev_priv(dev);
  231. int sr;
  232. bool commslot = macintosh_config->expansion_type == MAC_EXP_PDS_COMM;
  233. /* Bogus probing, on the models which may or may not have
  234. Ethernet (BTW, the Ethernet *is* always at the same
  235. address, and nothing else lives there, at least if Apple's
  236. documentation is to be believed) */
  237. if (commslot || macintosh_config->ident == MAC_MODEL_C610) {
  238. int card_present;
  239. card_present = hwreg_present((void*)ONBOARD_SONIC_REGISTERS);
  240. if (!card_present) {
  241. pr_info("Onboard/comm-slot SONIC not found\n");
  242. return -ENODEV;
  243. }
  244. }
  245. /* Danger! My arms are flailing wildly! You *must* set lp->reg_offset
  246. * and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
  247. dev->base_addr = ONBOARD_SONIC_REGISTERS;
  248. if (via_alt_mapping)
  249. dev->irq = IRQ_AUTO_3;
  250. else
  251. dev->irq = IRQ_NUBUS_9;
  252. /* The PowerBook's SONIC is 16 bit always. */
  253. if (macintosh_config->ident == MAC_MODEL_PB520) {
  254. lp->reg_offset = 0;
  255. lp->dma_bitmode = SONIC_BITMODE16;
  256. } else if (commslot) {
  257. /* Some of the comm-slot cards are 16 bit. But some
  258. of them are not. The 32-bit cards use offset 2 and
  259. have known revisions, we try reading the revision
  260. register at offset 2, if we don't get a known revision
  261. we assume 16 bit at offset 0. */
  262. lp->reg_offset = 2;
  263. lp->dma_bitmode = SONIC_BITMODE16;
  264. sr = SONIC_READ(SONIC_SR);
  265. if (sr == 0x0004 || sr == 0x0006 || sr == 0x0100 || sr == 0x0101)
  266. /* 83932 is 0x0004 or 0x0006, 83934 is 0x0100 or 0x0101 */
  267. lp->dma_bitmode = SONIC_BITMODE32;
  268. else {
  269. lp->dma_bitmode = SONIC_BITMODE16;
  270. lp->reg_offset = 0;
  271. }
  272. } else {
  273. /* All onboard cards are at offset 2 with 32 bit DMA. */
  274. lp->reg_offset = 2;
  275. lp->dma_bitmode = SONIC_BITMODE32;
  276. }
  277. pr_info("Onboard/comm-slot SONIC, revision 0x%04x, %d bit DMA, register offset %d\n",
  278. SONIC_READ(SONIC_SR), lp->dma_bitmode ? 32 : 16,
  279. lp->reg_offset);
  280. /* This is sometimes useful to find out how MacOS configured the card */
  281. pr_debug("%s: DCR=0x%04x, DCR2=0x%04x\n", __func__,
  282. SONIC_READ(SONIC_DCR) & 0xffff,
  283. SONIC_READ(SONIC_DCR2) & 0xffff);
  284. /* Software reset, then initialize control registers. */
  285. SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
  286. SONIC_WRITE(SONIC_DCR, SONIC_DCR_EXBUS | SONIC_DCR_BMS |
  287. SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
  288. (lp->dma_bitmode ? SONIC_DCR_DW : 0));
  289. /* This *must* be written back to in order to restore the
  290. * extended programmable output bits, as it may not have been
  291. * initialised since the hardware reset. */
  292. SONIC_WRITE(SONIC_DCR2, 0);
  293. /* Clear *and* disable interrupts to be on the safe side */
  294. SONIC_WRITE(SONIC_IMR, 0);
  295. SONIC_WRITE(SONIC_ISR, 0x7fff);
  296. /* Now look for the MAC address. */
  297. mac_onboard_sonic_ethernet_addr(dev);
  298. pr_info("SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
  299. dev->base_addr, dev->dev_addr, dev->irq);
  300. /* Shared init code */
  301. return macsonic_init(dev);
  302. }
  303. static int mac_sonic_nubus_ethernet_addr(struct net_device *dev,
  304. unsigned long prom_addr, int id)
  305. {
  306. int i;
  307. for(i = 0; i < 6; i++)
  308. dev->dev_addr[i] = SONIC_READ_PROM(i);
  309. /* Some of the addresses are bit-reversed */
  310. if (id != MACSONIC_DAYNA)
  311. bit_reverse_addr(dev->dev_addr);
  312. return 0;
  313. }
  314. static int macsonic_ident(struct nubus_rsrc *fres)
  315. {
  316. if (fres->dr_hw == NUBUS_DRHW_ASANTE_LC &&
  317. fres->dr_sw == NUBUS_DRSW_SONIC_LC)
  318. return MACSONIC_DAYNALINK;
  319. if (fres->dr_hw == NUBUS_DRHW_SONIC &&
  320. fres->dr_sw == NUBUS_DRSW_APPLE) {
  321. /* There has to be a better way to do this... */
  322. if (strstr(fres->board->name, "DuoDock"))
  323. return MACSONIC_DUODOCK;
  324. else
  325. return MACSONIC_APPLE;
  326. }
  327. if (fres->dr_hw == NUBUS_DRHW_SMC9194 &&
  328. fres->dr_sw == NUBUS_DRSW_DAYNA)
  329. return MACSONIC_DAYNA;
  330. if (fres->dr_hw == NUBUS_DRHW_APPLE_SONIC_LC &&
  331. fres->dr_sw == 0) { /* huh? */
  332. return MACSONIC_APPLE16;
  333. }
  334. return -1;
  335. }
  336. static int mac_sonic_nubus_probe_board(struct nubus_board *board, int id,
  337. struct net_device *dev)
  338. {
  339. struct sonic_local* lp = netdev_priv(dev);
  340. unsigned long base_addr, prom_addr;
  341. u16 sonic_dcr;
  342. int reg_offset, dma_bitmode;
  343. switch (id) {
  344. case MACSONIC_DUODOCK:
  345. base_addr = board->slot_addr + DUODOCK_SONIC_REGISTERS;
  346. prom_addr = board->slot_addr + DUODOCK_SONIC_PROM_BASE;
  347. sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1 |
  348. SONIC_DCR_TFT0;
  349. reg_offset = 2;
  350. dma_bitmode = SONIC_BITMODE32;
  351. break;
  352. case MACSONIC_APPLE:
  353. base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
  354. prom_addr = board->slot_addr + APPLE_SONIC_PROM_BASE;
  355. sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0;
  356. reg_offset = 0;
  357. dma_bitmode = SONIC_BITMODE32;
  358. break;
  359. case MACSONIC_APPLE16:
  360. base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
  361. prom_addr = board->slot_addr + APPLE_SONIC_PROM_BASE;
  362. sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
  363. SONIC_DCR_PO1 | SONIC_DCR_BMS;
  364. reg_offset = 0;
  365. dma_bitmode = SONIC_BITMODE16;
  366. break;
  367. case MACSONIC_DAYNALINK:
  368. base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
  369. prom_addr = board->slot_addr + DAYNALINK_PROM_BASE;
  370. sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
  371. SONIC_DCR_PO1 | SONIC_DCR_BMS;
  372. reg_offset = 0;
  373. dma_bitmode = SONIC_BITMODE16;
  374. break;
  375. case MACSONIC_DAYNA:
  376. base_addr = board->slot_addr + DAYNA_SONIC_REGISTERS;
  377. prom_addr = board->slot_addr + DAYNA_SONIC_MAC_ADDR;
  378. sonic_dcr = SONIC_DCR_BMS |
  379. SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1;
  380. reg_offset = 0;
  381. dma_bitmode = SONIC_BITMODE16;
  382. break;
  383. default:
  384. printk(KERN_ERR "macsonic: WTF, id is %d\n", id);
  385. return -ENODEV;
  386. }
  387. /* Danger! My arms are flailing wildly! You *must* set lp->reg_offset
  388. * and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
  389. dev->base_addr = base_addr;
  390. lp->reg_offset = reg_offset;
  391. lp->dma_bitmode = dma_bitmode;
  392. dev->irq = SLOT2IRQ(board->slot);
  393. dev_info(&board->dev, "%s, revision 0x%04x, %d bit DMA, register offset %d\n",
  394. board->name, SONIC_READ(SONIC_SR),
  395. lp->dma_bitmode ? 32 : 16, lp->reg_offset);
  396. /* This is sometimes useful to find out how MacOS configured the card */
  397. dev_dbg(&board->dev, "%s: DCR=0x%04x, DCR2=0x%04x\n", __func__,
  398. SONIC_READ(SONIC_DCR) & 0xffff,
  399. SONIC_READ(SONIC_DCR2) & 0xffff);
  400. /* Software reset, then initialize control registers. */
  401. SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
  402. SONIC_WRITE(SONIC_DCR, sonic_dcr | (dma_bitmode ? SONIC_DCR_DW : 0));
  403. /* This *must* be written back to in order to restore the
  404. * extended programmable output bits, since it may not have been
  405. * initialised since the hardware reset. */
  406. SONIC_WRITE(SONIC_DCR2, 0);
  407. /* Clear *and* disable interrupts to be on the safe side */
  408. SONIC_WRITE(SONIC_IMR, 0);
  409. SONIC_WRITE(SONIC_ISR, 0x7fff);
  410. /* Now look for the MAC address. */
  411. if (mac_sonic_nubus_ethernet_addr(dev, prom_addr, id) != 0)
  412. return -ENODEV;
  413. dev_info(&board->dev, "SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
  414. dev->base_addr, dev->dev_addr, dev->irq);
  415. /* Shared init code */
  416. return macsonic_init(dev);
  417. }
  418. static int mac_sonic_platform_probe(struct platform_device *pdev)
  419. {
  420. struct net_device *dev;
  421. struct sonic_local *lp;
  422. int err;
  423. dev = alloc_etherdev(sizeof(struct sonic_local));
  424. if (!dev)
  425. return -ENOMEM;
  426. lp = netdev_priv(dev);
  427. lp->device = &pdev->dev;
  428. SET_NETDEV_DEV(dev, &pdev->dev);
  429. platform_set_drvdata(pdev, dev);
  430. err = mac_onboard_sonic_probe(dev);
  431. if (err)
  432. goto out;
  433. sonic_msg_init(dev);
  434. err = register_netdev(dev);
  435. if (err)
  436. goto out;
  437. return 0;
  438. out:
  439. free_netdev(dev);
  440. return err;
  441. }
  442. MODULE_DESCRIPTION("Macintosh SONIC ethernet driver");
  443. MODULE_ALIAS("platform:macsonic");
  444. #include "sonic.c"
  445. static int mac_sonic_platform_remove(struct platform_device *pdev)
  446. {
  447. struct net_device *dev = platform_get_drvdata(pdev);
  448. struct sonic_local* lp = netdev_priv(dev);
  449. unregister_netdev(dev);
  450. dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
  451. lp->descriptors, lp->descriptors_laddr);
  452. free_netdev(dev);
  453. return 0;
  454. }
  455. static struct platform_driver mac_sonic_platform_driver = {
  456. .probe = mac_sonic_platform_probe,
  457. .remove = mac_sonic_platform_remove,
  458. .driver = {
  459. .name = "macsonic",
  460. },
  461. };
  462. static int mac_sonic_nubus_probe(struct nubus_board *board)
  463. {
  464. struct net_device *ndev;
  465. struct sonic_local *lp;
  466. struct nubus_rsrc *fres;
  467. int id = -1;
  468. int err;
  469. /* The platform driver will handle a PDS or Comm Slot card (even if
  470. * it has a pseudoslot declaration ROM).
  471. */
  472. if (macintosh_config->expansion_type == MAC_EXP_PDS_COMM)
  473. return -ENODEV;
  474. for_each_board_func_rsrc(board, fres) {
  475. if (fres->category != NUBUS_CAT_NETWORK ||
  476. fres->type != NUBUS_TYPE_ETHERNET)
  477. continue;
  478. id = macsonic_ident(fres);
  479. if (id != -1)
  480. break;
  481. }
  482. if (!fres)
  483. return -ENODEV;
  484. ndev = alloc_etherdev(sizeof(struct sonic_local));
  485. if (!ndev)
  486. return -ENOMEM;
  487. lp = netdev_priv(ndev);
  488. lp->device = &board->dev;
  489. SET_NETDEV_DEV(ndev, &board->dev);
  490. err = mac_sonic_nubus_probe_board(board, id, ndev);
  491. if (err)
  492. goto out;
  493. sonic_msg_init(ndev);
  494. err = register_netdev(ndev);
  495. if (err)
  496. goto out;
  497. nubus_set_drvdata(board, ndev);
  498. return 0;
  499. out:
  500. free_netdev(ndev);
  501. return err;
  502. }
  503. static int mac_sonic_nubus_remove(struct nubus_board *board)
  504. {
  505. struct net_device *ndev = nubus_get_drvdata(board);
  506. struct sonic_local *lp = netdev_priv(ndev);
  507. unregister_netdev(ndev);
  508. dma_free_coherent(lp->device,
  509. SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
  510. lp->descriptors, lp->descriptors_laddr);
  511. free_netdev(ndev);
  512. return 0;
  513. }
  514. static struct nubus_driver mac_sonic_nubus_driver = {
  515. .probe = mac_sonic_nubus_probe,
  516. .remove = mac_sonic_nubus_remove,
  517. .driver = {
  518. .name = "macsonic-nubus",
  519. .owner = THIS_MODULE,
  520. },
  521. };
  522. static int perr, nerr;
  523. static int __init mac_sonic_init(void)
  524. {
  525. perr = platform_driver_register(&mac_sonic_platform_driver);
  526. nerr = nubus_driver_register(&mac_sonic_nubus_driver);
  527. return 0;
  528. }
  529. module_init(mac_sonic_init);
  530. static void __exit mac_sonic_exit(void)
  531. {
  532. if (!perr)
  533. platform_driver_unregister(&mac_sonic_platform_driver);
  534. if (!nerr)
  535. nubus_driver_unregister(&mac_sonic_nubus_driver);
  536. }
  537. module_exit(mac_sonic_exit);