macsonic.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /*
  2. * macsonic.c
  3. *
  4. * (C) 1998 Alan Cox
  5. *
  6. * Debugging Andreas Ehliar, Michael Schmitz
  7. *
  8. * Based on code
  9. * (C) 1996 by Thomas Bogendoerfer (tsbogend@bigbug.franken.de)
  10. *
  11. * This driver is based on work from Andreas Busse, but most of
  12. * the code is rewritten.
  13. *
  14. * (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de)
  15. *
  16. * A driver for the Mac onboard Sonic ethernet chip.
  17. *
  18. * 98/12/21 MSch: judged from tests on Q800, it's basically working,
  19. * but eating up both receive and transmit resources
  20. * and duplicating packets. Needs more testing.
  21. *
  22. * 99/01/03 MSch: upgraded to version 0.92 of the core driver, fixed.
  23. *
  24. * 00/10/31 sammy@oh.verio.com: Updated driver for 2.4 kernels, fixed problems
  25. * on centris.
  26. */
  27. #include <linux/kernel.h>
  28. #include <linux/types.h>
  29. #include <linux/ctype.h>
  30. #include <linux/fcntl.h>
  31. #include <linux/interrupt.h>
  32. #include <linux/init.h>
  33. #include <linux/ioport.h>
  34. #include <linux/in.h>
  35. #include <linux/slab.h>
  36. #include <linux/string.h>
  37. #include <linux/delay.h>
  38. #include <linux/nubus.h>
  39. #include <linux/errno.h>
  40. #include <linux/netdevice.h>
  41. #include <linux/etherdevice.h>
  42. #include <linux/skbuff.h>
  43. #include <linux/module.h>
  44. #include <linux/bitops.h>
  45. #include <asm/bootinfo.h>
  46. #include <asm/system.h>
  47. #include <asm/pgtable.h>
  48. #include <asm/io.h>
  49. #include <asm/hwtest.h>
  50. #include <asm/dma.h>
  51. #include <asm/macintosh.h>
  52. #include <asm/macints.h>
  53. #include <asm/mac_via.h>
  54. #define SREGS_PAD(n) u16 n;
  55. #include "sonic.h"
  56. #define SONIC_READ(reg) \
  57. nubus_readl(base_addr+(reg))
  58. #define SONIC_WRITE(reg,val) \
  59. nubus_writel((val), base_addr+(reg))
  60. #define sonic_read(dev, reg) \
  61. nubus_readl((dev)->base_addr+(reg))
  62. #define sonic_write(dev, reg, val) \
  63. nubus_writel((val), (dev)->base_addr+(reg))
  64. static int sonic_debug;
  65. static int sonic_version_printed;
  66. static int reg_offset;
  67. extern int mac_onboard_sonic_probe(struct net_device* dev);
  68. extern int mac_nubus_sonic_probe(struct net_device* dev);
  69. /* For onboard SONIC */
  70. #define ONBOARD_SONIC_REGISTERS 0x50F0A000
  71. #define ONBOARD_SONIC_PROM_BASE 0x50f08000
  72. enum macsonic_type {
  73. MACSONIC_DUODOCK,
  74. MACSONIC_APPLE,
  75. MACSONIC_APPLE16,
  76. MACSONIC_DAYNA,
  77. MACSONIC_DAYNALINK
  78. };
  79. /* For the built-in SONIC in the Duo Dock */
  80. #define DUODOCK_SONIC_REGISTERS 0xe10000
  81. #define DUODOCK_SONIC_PROM_BASE 0xe12000
  82. /* For Apple-style NuBus SONIC */
  83. #define APPLE_SONIC_REGISTERS 0
  84. #define APPLE_SONIC_PROM_BASE 0x40000
  85. /* Daynalink LC SONIC */
  86. #define DAYNALINK_PROM_BASE 0x400000
  87. /* For Dayna-style NuBus SONIC (haven't seen one yet) */
  88. #define DAYNA_SONIC_REGISTERS 0x180000
  89. /* This is what OpenBSD says. However, this is definitely in NuBus
  90. ROM space so we should be able to get it by walking the NuBus
  91. resource directories */
  92. #define DAYNA_SONIC_MAC_ADDR 0xffe004
  93. #define SONIC_READ_PROM(addr) nubus_readb(prom_addr+addr)
  94. struct net_device * __init macsonic_probe(int unit)
  95. {
  96. struct net_device *dev = alloc_etherdev(0);
  97. int err;
  98. if (!dev)
  99. return ERR_PTR(-ENOMEM);
  100. if (unit >= 0)
  101. sprintf(dev->name, "eth%d", unit);
  102. SET_MODULE_OWNER(dev);
  103. /* This will catch fatal stuff like -ENOMEM as well as success */
  104. err = mac_onboard_sonic_probe(dev);
  105. if (err == 0)
  106. goto found;
  107. if (err != -ENODEV)
  108. goto out;
  109. err = mac_nubus_sonic_probe(dev);
  110. if (err)
  111. goto out;
  112. found:
  113. err = register_netdev(dev);
  114. if (err)
  115. goto out1;
  116. return dev;
  117. out1:
  118. kfree(dev->priv);
  119. out:
  120. free_netdev(dev);
  121. return ERR_PTR(err);
  122. }
  123. /*
  124. * For reversing the PROM address
  125. */
  126. static unsigned char nibbletab[] = {0, 8, 4, 12, 2, 10, 6, 14,
  127. 1, 9, 5, 13, 3, 11, 7, 15};
  128. static inline void bit_reverse_addr(unsigned char addr[6])
  129. {
  130. int i;
  131. for(i = 0; i < 6; i++)
  132. addr[i] = ((nibbletab[addr[i] & 0xf] << 4) |
  133. nibbletab[(addr[i] >> 4) &0xf]);
  134. }
  135. int __init macsonic_init(struct net_device* dev)
  136. {
  137. struct sonic_local* lp = NULL;
  138. int i;
  139. /* Allocate the entire chunk of memory for the descriptors.
  140. Note that this cannot cross a 64K boundary. */
  141. for (i = 0; i < 20; i++) {
  142. unsigned long desc_base, desc_top;
  143. if((lp = kmalloc(sizeof(struct sonic_local), GFP_KERNEL | GFP_DMA)) == NULL) {
  144. printk(KERN_ERR "%s: couldn't allocate descriptor buffers\n", dev->name);
  145. return -ENOMEM;
  146. }
  147. desc_base = (unsigned long) lp;
  148. desc_top = desc_base + sizeof(struct sonic_local);
  149. if ((desc_top & 0xffff) >= (desc_base & 0xffff))
  150. break;
  151. /* Hmm. try again (FIXME: does this actually work?) */
  152. kfree(lp);
  153. printk(KERN_DEBUG
  154. "%s: didn't get continguous chunk [%08lx - %08lx], trying again\n",
  155. dev->name, desc_base, desc_top);
  156. }
  157. if (lp == NULL) {
  158. printk(KERN_ERR "%s: tried 20 times to allocate descriptor buffers, giving up.\n",
  159. dev->name);
  160. return -ENOMEM;
  161. }
  162. dev->priv = lp;
  163. #if 0
  164. /* this code is only here as a curiousity... mainly, where the
  165. fuck did SONIC_BUS_SCALE come from, and what was it supposed
  166. to do? the normal allocation works great for 32 bit stuffs.. */
  167. /* Now set up the pointers to point to the appropriate places */
  168. lp->cda = lp->sonic_desc;
  169. lp->tda = lp->cda + (SIZEOF_SONIC_CDA * SONIC_BUS_SCALE(lp->dma_bitmode));
  170. lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
  171. * SONIC_BUS_SCALE(lp->dma_bitmode));
  172. lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
  173. * SONIC_BUS_SCALE(lp->dma_bitmode));
  174. #endif
  175. memset(lp, 0, sizeof(struct sonic_local));
  176. lp->cda_laddr = (unsigned int)&(lp->cda);
  177. lp->tda_laddr = (unsigned int)lp->tda;
  178. lp->rra_laddr = (unsigned int)lp->rra;
  179. lp->rda_laddr = (unsigned int)lp->rda;
  180. /* FIXME, maybe we should use skbs */
  181. if ((lp->rba = (char *)
  182. kmalloc(SONIC_NUM_RRS * SONIC_RBSIZE, GFP_KERNEL | GFP_DMA)) == NULL) {
  183. printk(KERN_ERR "%s: couldn't allocate receive buffers\n", dev->name);
  184. dev->priv = NULL;
  185. kfree(lp);
  186. return -ENOMEM;
  187. }
  188. lp->rba_laddr = (unsigned int)lp->rba;
  189. {
  190. int rs, ds;
  191. /* almost always 12*4096, but let's not take chances */
  192. rs = ((SONIC_NUM_RRS * SONIC_RBSIZE + 4095) / 4096) * 4096;
  193. /* almost always under a page, but let's not take chances */
  194. ds = ((sizeof(struct sonic_local) + 4095) / 4096) * 4096;
  195. kernel_set_cachemode(lp->rba, rs, IOMAP_NOCACHE_SER);
  196. kernel_set_cachemode(lp, ds, IOMAP_NOCACHE_SER);
  197. }
  198. #if 0
  199. flush_cache_all();
  200. #endif
  201. dev->open = sonic_open;
  202. dev->stop = sonic_close;
  203. dev->hard_start_xmit = sonic_send_packet;
  204. dev->get_stats = sonic_get_stats;
  205. dev->set_multicast_list = &sonic_multicast_list;
  206. /*
  207. * clear tally counter
  208. */
  209. sonic_write(dev, SONIC_CRCT, 0xffff);
  210. sonic_write(dev, SONIC_FAET, 0xffff);
  211. sonic_write(dev, SONIC_MPT, 0xffff);
  212. return 0;
  213. }
  214. int __init mac_onboard_sonic_ethernet_addr(struct net_device* dev)
  215. {
  216. const int prom_addr = ONBOARD_SONIC_PROM_BASE;
  217. int i;
  218. /* On NuBus boards we can sometimes look in the ROM resources.
  219. No such luck for comm-slot/onboard. */
  220. for(i = 0; i < 6; i++)
  221. dev->dev_addr[i] = SONIC_READ_PROM(i);
  222. /* Most of the time, the address is bit-reversed. The NetBSD
  223. source has a rather long and detailed historical account of
  224. why this is so. */
  225. if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
  226. memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
  227. memcmp(dev->dev_addr, "\x00\x05\x02", 3))
  228. bit_reverse_addr(dev->dev_addr);
  229. else
  230. return 0;
  231. /* If we still have what seems to be a bogus address, we'll
  232. look in the CAM. The top entry should be ours. */
  233. /* Danger! This only works if MacOS has already initialized
  234. the card... */
  235. if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
  236. memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
  237. memcmp(dev->dev_addr, "\x00\x05\x02", 3))
  238. {
  239. unsigned short val;
  240. printk(KERN_INFO "macsonic: PROM seems to be wrong, trying CAM entry 15\n");
  241. sonic_write(dev, SONIC_CMD, SONIC_CR_RST);
  242. sonic_write(dev, SONIC_CEP, 15);
  243. val = sonic_read(dev, SONIC_CAP2);
  244. dev->dev_addr[5] = val >> 8;
  245. dev->dev_addr[4] = val & 0xff;
  246. val = sonic_read(dev, SONIC_CAP1);
  247. dev->dev_addr[3] = val >> 8;
  248. dev->dev_addr[2] = val & 0xff;
  249. val = sonic_read(dev, SONIC_CAP0);
  250. dev->dev_addr[1] = val >> 8;
  251. dev->dev_addr[0] = val & 0xff;
  252. printk(KERN_INFO "HW Address from CAM 15: ");
  253. for (i = 0; i < 6; i++) {
  254. printk("%2.2x", dev->dev_addr[i]);
  255. if (i < 5)
  256. printk(":");
  257. }
  258. printk("\n");
  259. } else return 0;
  260. if (memcmp(dev->dev_addr, "\x08\x00\x07", 3) &&
  261. memcmp(dev->dev_addr, "\x00\xA0\x40", 3) &&
  262. memcmp(dev->dev_addr, "\x00\x05\x02", 3))
  263. {
  264. /*
  265. * Still nonsense ... messed up someplace!
  266. */
  267. printk(KERN_ERR "macsonic: ERROR (INVALID MAC)\n");
  268. return -EIO;
  269. } else return 0;
  270. }
  271. int __init mac_onboard_sonic_probe(struct net_device* dev)
  272. {
  273. /* Bwahahaha */
  274. static int once_is_more_than_enough;
  275. int i;
  276. int dma_bitmode;
  277. if (once_is_more_than_enough)
  278. return -ENODEV;
  279. once_is_more_than_enough = 1;
  280. if (!MACH_IS_MAC)
  281. return -ENODEV;
  282. printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
  283. if (macintosh_config->ether_type != MAC_ETHER_SONIC)
  284. {
  285. printk("none.\n");
  286. return -ENODEV;
  287. }
  288. /* Bogus probing, on the models which may or may not have
  289. Ethernet (BTW, the Ethernet *is* always at the same
  290. address, and nothing else lives there, at least if Apple's
  291. documentation is to be believed) */
  292. if (macintosh_config->ident == MAC_MODEL_Q630 ||
  293. macintosh_config->ident == MAC_MODEL_P588 ||
  294. macintosh_config->ident == MAC_MODEL_C610) {
  295. unsigned long flags;
  296. int card_present;
  297. local_irq_save(flags);
  298. card_present = hwreg_present((void*)ONBOARD_SONIC_REGISTERS);
  299. local_irq_restore(flags);
  300. if (!card_present) {
  301. printk("none.\n");
  302. return -ENODEV;
  303. }
  304. }
  305. printk("yes\n");
  306. /* Danger! My arms are flailing wildly! You *must* set this
  307. before using sonic_read() */
  308. dev->base_addr = ONBOARD_SONIC_REGISTERS;
  309. if (via_alt_mapping)
  310. dev->irq = IRQ_AUTO_3;
  311. else
  312. dev->irq = IRQ_NUBUS_9;
  313. if (!sonic_version_printed) {
  314. printk(KERN_INFO "%s", version);
  315. sonic_version_printed = 1;
  316. }
  317. printk(KERN_INFO "%s: onboard / comm-slot SONIC at 0x%08lx\n",
  318. dev->name, dev->base_addr);
  319. /* Now do a song and dance routine in an attempt to determine
  320. the bus width */
  321. /* The PowerBook's SONIC is 16 bit always. */
  322. if (macintosh_config->ident == MAC_MODEL_PB520) {
  323. reg_offset = 0;
  324. dma_bitmode = 0;
  325. } else if (macintosh_config->ident == MAC_MODEL_C610) {
  326. reg_offset = 0;
  327. dma_bitmode = 1;
  328. } else {
  329. /* Some of the comm-slot cards are 16 bit. But some
  330. of them are not. The 32-bit cards use offset 2 and
  331. pad with zeroes or sometimes ones (I think...)
  332. Therefore, if we try offset 0 and get a silicon
  333. revision of 0, we assume 16 bit. */
  334. int sr;
  335. /* Technically this is not necessary since we zeroed
  336. it above */
  337. reg_offset = 0;
  338. dma_bitmode = 0;
  339. sr = sonic_read(dev, SONIC_SR);
  340. if (sr == 0 || sr == 0xffff) {
  341. reg_offset = 2;
  342. /* 83932 is 0x0004, 83934 is 0x0100 or 0x0101 */
  343. sr = sonic_read(dev, SONIC_SR);
  344. dma_bitmode = 1;
  345. }
  346. printk(KERN_INFO
  347. "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
  348. dev->name, sr, dma_bitmode?32:16, reg_offset);
  349. }
  350. /* this carries my sincere apologies -- by the time I got to updating
  351. the driver, support for "reg_offsets" appeares nowhere in the sonic
  352. code, going back for over a year. Fortunately, my Mac does't seem
  353. to use whatever this was.
  354. If you know how this is supposed to be implemented, either fix it,
  355. or contact me (sammy@oh.verio.com) to explain what it is. --Sam */
  356. if(reg_offset) {
  357. printk("%s: register offset unsupported. please fix this if you know what it is.\n", dev->name);
  358. return -ENODEV;
  359. }
  360. /* Software reset, then initialize control registers. */
  361. sonic_write(dev, SONIC_CMD, SONIC_CR_RST);
  362. sonic_write(dev, SONIC_DCR, SONIC_DCR_BMS |
  363. SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_EXBUS |
  364. (dma_bitmode ? SONIC_DCR_DW : 0));
  365. /* This *must* be written back to in order to restore the
  366. extended programmable output bits */
  367. sonic_write(dev, SONIC_DCR2, 0);
  368. /* Clear *and* disable interrupts to be on the safe side */
  369. sonic_write(dev, SONIC_ISR,0x7fff);
  370. sonic_write(dev, SONIC_IMR,0);
  371. /* Now look for the MAC address. */
  372. if (mac_onboard_sonic_ethernet_addr(dev) != 0)
  373. return -ENODEV;
  374. printk(KERN_INFO "MAC ");
  375. for (i = 0; i < 6; i++) {
  376. printk("%2.2x", dev->dev_addr[i]);
  377. if (i < 5)
  378. printk(":");
  379. }
  380. printk(" IRQ %d\n", dev->irq);
  381. /* Shared init code */
  382. return macsonic_init(dev);
  383. }
  384. int __init mac_nubus_sonic_ethernet_addr(struct net_device* dev,
  385. unsigned long prom_addr,
  386. int id)
  387. {
  388. int i;
  389. for(i = 0; i < 6; i++)
  390. dev->dev_addr[i] = SONIC_READ_PROM(i);
  391. /* For now we are going to assume that they're all bit-reversed */
  392. bit_reverse_addr(dev->dev_addr);
  393. return 0;
  394. }
  395. int __init macsonic_ident(struct nubus_dev* ndev)
  396. {
  397. if (ndev->dr_hw == NUBUS_DRHW_ASANTE_LC &&
  398. ndev->dr_sw == NUBUS_DRSW_SONIC_LC)
  399. return MACSONIC_DAYNALINK;
  400. if (ndev->dr_hw == NUBUS_DRHW_SONIC &&
  401. ndev->dr_sw == NUBUS_DRSW_APPLE) {
  402. /* There has to be a better way to do this... */
  403. if (strstr(ndev->board->name, "DuoDock"))
  404. return MACSONIC_DUODOCK;
  405. else
  406. return MACSONIC_APPLE;
  407. }
  408. return -1;
  409. }
  410. int __init mac_nubus_sonic_probe(struct net_device* dev)
  411. {
  412. static int slots;
  413. struct nubus_dev* ndev = NULL;
  414. unsigned long base_addr, prom_addr;
  415. u16 sonic_dcr;
  416. int id;
  417. int i;
  418. int dma_bitmode;
  419. /* Find the first SONIC that hasn't been initialized already */
  420. while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK,
  421. NUBUS_TYPE_ETHERNET, ndev)) != NULL)
  422. {
  423. /* Have we seen it already? */
  424. if (slots & (1<<ndev->board->slot))
  425. continue;
  426. slots |= 1<<ndev->board->slot;
  427. /* Is it one of ours? */
  428. if ((id = macsonic_ident(ndev)) != -1)
  429. break;
  430. }
  431. if (ndev == NULL)
  432. return -ENODEV;
  433. switch (id) {
  434. case MACSONIC_DUODOCK:
  435. base_addr = ndev->board->slot_addr + DUODOCK_SONIC_REGISTERS;
  436. prom_addr = ndev->board->slot_addr + DUODOCK_SONIC_PROM_BASE;
  437. sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1
  438. | SONIC_DCR_TFT0;
  439. reg_offset = 2;
  440. dma_bitmode = 1;
  441. break;
  442. case MACSONIC_APPLE:
  443. base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
  444. prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
  445. sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0;
  446. reg_offset = 0;
  447. dma_bitmode = 1;
  448. break;
  449. case MACSONIC_APPLE16:
  450. base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
  451. prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
  452. sonic_dcr = SONIC_DCR_EXBUS
  453. | SONIC_DCR_RFT1 | SONIC_DCR_TFT0
  454. | SONIC_DCR_PO1 | SONIC_DCR_BMS;
  455. reg_offset = 0;
  456. dma_bitmode = 0;
  457. break;
  458. case MACSONIC_DAYNALINK:
  459. base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
  460. prom_addr = ndev->board->slot_addr + DAYNALINK_PROM_BASE;
  461. sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0
  462. | SONIC_DCR_PO1 | SONIC_DCR_BMS;
  463. reg_offset = 0;
  464. dma_bitmode = 0;
  465. break;
  466. case MACSONIC_DAYNA:
  467. base_addr = ndev->board->slot_addr + DAYNA_SONIC_REGISTERS;
  468. prom_addr = ndev->board->slot_addr + DAYNA_SONIC_MAC_ADDR;
  469. sonic_dcr = SONIC_DCR_BMS
  470. | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1;
  471. reg_offset = 0;
  472. dma_bitmode = 0;
  473. break;
  474. default:
  475. printk(KERN_ERR "macsonic: WTF, id is %d\n", id);
  476. return -ENODEV;
  477. }
  478. /* Danger! My arms are flailing wildly! You *must* set this
  479. before using sonic_read() */
  480. dev->base_addr = base_addr;
  481. dev->irq = SLOT2IRQ(ndev->board->slot);
  482. if (!sonic_version_printed) {
  483. printk(KERN_INFO "%s", version);
  484. sonic_version_printed = 1;
  485. }
  486. printk(KERN_INFO "%s: %s in slot %X\n",
  487. dev->name, ndev->board->name, ndev->board->slot);
  488. printk(KERN_INFO "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
  489. dev->name, sonic_read(dev, SONIC_SR), dma_bitmode?32:16, reg_offset);
  490. if(reg_offset) {
  491. printk("%s: register offset unsupported. please fix this if you know what it is.\n", dev->name);
  492. return -ENODEV;
  493. }
  494. /* Software reset, then initialize control registers. */
  495. sonic_write(dev, SONIC_CMD, SONIC_CR_RST);
  496. sonic_write(dev, SONIC_DCR, sonic_dcr
  497. | (dma_bitmode ? SONIC_DCR_DW : 0));
  498. /* Clear *and* disable interrupts to be on the safe side */
  499. sonic_write(dev, SONIC_ISR,0x7fff);
  500. sonic_write(dev, SONIC_IMR,0);
  501. /* Now look for the MAC address. */
  502. if (mac_nubus_sonic_ethernet_addr(dev, prom_addr, id) != 0)
  503. return -ENODEV;
  504. printk(KERN_INFO "MAC ");
  505. for (i = 0; i < 6; i++) {
  506. printk("%2.2x", dev->dev_addr[i]);
  507. if (i < 5)
  508. printk(":");
  509. }
  510. printk(" IRQ %d\n", dev->irq);
  511. /* Shared init code */
  512. return macsonic_init(dev);
  513. }
  514. #ifdef MODULE
  515. static struct net_device *dev_macsonic;
  516. MODULE_PARM(sonic_debug, "i");
  517. MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
  518. int
  519. init_module(void)
  520. {
  521. dev_macsonic = macsonic_probe(-1);
  522. if (IS_ERR(dev_macsonic)) {
  523. printk(KERN_WARNING "macsonic.c: No card found\n");
  524. return PTR_ERR(dev_macsonic);
  525. }
  526. return 0;
  527. }
  528. void
  529. cleanup_module(void)
  530. {
  531. unregister_netdev(dev_macsonic);
  532. kfree(dev_macsonic->priv);
  533. free_netdev(dev_macsonic);
  534. }
  535. #endif /* MODULE */
  536. #define vdma_alloc(foo, bar) ((u32)foo)
  537. #define vdma_free(baz)
  538. #define sonic_chiptomem(bat) (bat)
  539. #define PHYSADDR(quux) (quux)
  540. #define CPHYSADDR(quux) (quux)
  541. #define sonic_request_irq request_irq
  542. #define sonic_free_irq free_irq
  543. #include "sonic.c"
  544. /*
  545. * Local variables:
  546. * 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"
  547. * version-control: t
  548. * kept-new-versions: 5
  549. * c-indent-level: 8
  550. * tab-width: 8
  551. * End:
  552. *
  553. */