com90xx.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. /*
  2. * Linux ARCnet driver - COM90xx chipset (memory-mapped buffers)
  3. *
  4. * Written 1994-1999 by Avery Pennarun.
  5. * Written 1999 by Martin Mares <mj@ucw.cz>.
  6. * Derived from skeleton.c by Donald Becker.
  7. *
  8. * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
  9. * for sponsoring the further development of this driver.
  10. *
  11. * **********************
  12. *
  13. * The original copyright of skeleton.c was as follows:
  14. *
  15. * skeleton.c Written 1993 by Donald Becker.
  16. * Copyright 1993 United States Government as represented by the
  17. * Director, National Security Agency. This software may only be used
  18. * and distributed according to the terms of the GNU General Public License as
  19. * modified by SRC, incorporated herein by reference.
  20. *
  21. * **********************
  22. *
  23. * For more details, see drivers/net/arcnet.c
  24. *
  25. * **********************
  26. */
  27. #include <linux/module.h>
  28. #include <linux/moduleparam.h>
  29. #include <linux/init.h>
  30. #include <linux/interrupt.h>
  31. #include <linux/ioport.h>
  32. #include <linux/delay.h>
  33. #include <linux/netdevice.h>
  34. #include <linux/slab.h>
  35. #include <asm/io.h>
  36. #include <linux/arcdevice.h>
  37. #define VERSION "arcnet: COM90xx chipset support\n"
  38. /* Define this to speed up the autoprobe by assuming if only one io port and
  39. * shmem are left in the list at Stage 5, they must correspond to each
  40. * other.
  41. *
  42. * This is undefined by default because it might not always be true, and the
  43. * extra check makes the autoprobe even more careful. Speed demons can turn
  44. * it on - I think it should be fine if you only have one ARCnet card
  45. * installed.
  46. *
  47. * If no ARCnet cards are installed, this delay never happens anyway and thus
  48. * the option has no effect.
  49. */
  50. #undef FAST_PROBE
  51. /* Internal function declarations */
  52. static int com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *);
  53. static void com90xx_command(struct net_device *dev, int command);
  54. static int com90xx_status(struct net_device *dev);
  55. static void com90xx_setmask(struct net_device *dev, int mask);
  56. static int com90xx_reset(struct net_device *dev, int really_reset);
  57. static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
  58. void *buf, int count);
  59. static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offset,
  60. void *buf, int count);
  61. /* Known ARCnet cards */
  62. static struct net_device *cards[16];
  63. static int numcards;
  64. /* Handy defines for ARCnet specific stuff */
  65. /* The number of low I/O ports used by the card */
  66. #define ARCNET_TOTAL_SIZE 16
  67. /* Amount of I/O memory used by the card */
  68. #define BUFFER_SIZE (512)
  69. #define MIRROR_SIZE (BUFFER_SIZE*4)
  70. /* COM 9026 controller chip --> ARCnet register addresses */
  71. #define _INTMASK (ioaddr+0) /* writable */
  72. #define _STATUS (ioaddr+0) /* readable */
  73. #define _COMMAND (ioaddr+1) /* writable, returns random vals on read (?) */
  74. #define _CONFIG (ioaddr+2) /* Configuration register */
  75. #define _RESET (ioaddr+8) /* software reset (on read) */
  76. #define _MEMDATA (ioaddr+12) /* Data port for IO-mapped memory */
  77. #define _ADDR_HI (ioaddr+15) /* Control registers for said */
  78. #define _ADDR_LO (ioaddr+14)
  79. #undef ASTATUS
  80. #undef ACOMMAND
  81. #undef AINTMASK
  82. #define ASTATUS() inb(_STATUS)
  83. #define ACOMMAND(cmd) outb((cmd),_COMMAND)
  84. #define AINTMASK(msk) outb((msk),_INTMASK)
  85. static int com90xx_skip_probe __initdata = 0;
  86. /* Module parameters */
  87. static int io; /* use the insmod io= irq= shmem= options */
  88. static int irq;
  89. static int shmem;
  90. static char device[9]; /* use eg. device=arc1 to change name */
  91. module_param(io, int, 0);
  92. module_param(irq, int, 0);
  93. module_param(shmem, int, 0);
  94. module_param_string(device, device, sizeof(device), 0);
  95. static void __init com90xx_probe(void)
  96. {
  97. int count, status, ioaddr, numprint, airq, openparen = 0;
  98. unsigned long airqmask;
  99. int ports[(0x3f0 - 0x200) / 16 + 1] =
  100. {0};
  101. unsigned long *shmems;
  102. void __iomem **iomem;
  103. int numports, numshmems, *port;
  104. u_long *p;
  105. int index;
  106. if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
  107. return;
  108. shmems = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(unsigned long),
  109. GFP_KERNEL);
  110. if (!shmems)
  111. return;
  112. iomem = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(void __iomem *),
  113. GFP_KERNEL);
  114. if (!iomem) {
  115. kfree(shmems);
  116. return;
  117. }
  118. BUGLVL(D_NORMAL) printk(VERSION);
  119. /* set up the arrays where we'll store the possible probe addresses */
  120. numports = numshmems = 0;
  121. if (io)
  122. ports[numports++] = io;
  123. else
  124. for (count = 0x200; count <= 0x3f0; count += 16)
  125. ports[numports++] = count;
  126. if (shmem)
  127. shmems[numshmems++] = shmem;
  128. else
  129. for (count = 0xA0000; count <= 0xFF800; count += 2048)
  130. shmems[numshmems++] = count;
  131. /* Stage 1: abandon any reserved ports, or ones with status==0xFF
  132. * (empty), and reset any others by reading the reset port.
  133. */
  134. numprint = -1;
  135. for (port = &ports[0]; port - ports < numports; port++) {
  136. numprint++;
  137. numprint %= 8;
  138. if (!numprint) {
  139. BUGMSG2(D_INIT, "\n");
  140. BUGMSG2(D_INIT, "S1: ");
  141. }
  142. BUGMSG2(D_INIT, "%Xh ", *port);
  143. ioaddr = *port;
  144. if (!request_region(*port, ARCNET_TOTAL_SIZE, "arcnet (90xx)")) {
  145. BUGMSG2(D_INIT_REASONS, "(request_region)\n");
  146. BUGMSG2(D_INIT_REASONS, "S1: ");
  147. BUGLVL(D_INIT_REASONS) numprint = 0;
  148. *port-- = ports[--numports];
  149. continue;
  150. }
  151. if (ASTATUS() == 0xFF) {
  152. BUGMSG2(D_INIT_REASONS, "(empty)\n");
  153. BUGMSG2(D_INIT_REASONS, "S1: ");
  154. BUGLVL(D_INIT_REASONS) numprint = 0;
  155. release_region(*port, ARCNET_TOTAL_SIZE);
  156. *port-- = ports[--numports];
  157. continue;
  158. }
  159. inb(_RESET); /* begin resetting card */
  160. BUGMSG2(D_INIT_REASONS, "\n");
  161. BUGMSG2(D_INIT_REASONS, "S1: ");
  162. BUGLVL(D_INIT_REASONS) numprint = 0;
  163. }
  164. BUGMSG2(D_INIT, "\n");
  165. if (!numports) {
  166. BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n");
  167. kfree(shmems);
  168. kfree(iomem);
  169. return;
  170. }
  171. /* Stage 2: we have now reset any possible ARCnet cards, so we can't
  172. * do anything until they finish. If D_INIT, print the list of
  173. * cards that are left.
  174. */
  175. numprint = -1;
  176. for (port = &ports[0]; port < ports + numports; port++) {
  177. numprint++;
  178. numprint %= 8;
  179. if (!numprint) {
  180. BUGMSG2(D_INIT, "\n");
  181. BUGMSG2(D_INIT, "S2: ");
  182. }
  183. BUGMSG2(D_INIT, "%Xh ", *port);
  184. }
  185. BUGMSG2(D_INIT, "\n");
  186. mdelay(RESETtime);
  187. /* Stage 3: abandon any shmem addresses that don't have the signature
  188. * 0xD1 byte in the right place, or are read-only.
  189. */
  190. numprint = -1;
  191. for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) {
  192. void __iomem *base;
  193. numprint++;
  194. numprint %= 8;
  195. if (!numprint) {
  196. BUGMSG2(D_INIT, "\n");
  197. BUGMSG2(D_INIT, "S3: ");
  198. }
  199. BUGMSG2(D_INIT, "%lXh ", *p);
  200. if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) {
  201. BUGMSG2(D_INIT_REASONS, "(request_mem_region)\n");
  202. BUGMSG2(D_INIT_REASONS, "Stage 3: ");
  203. BUGLVL(D_INIT_REASONS) numprint = 0;
  204. goto out;
  205. }
  206. base = ioremap(*p, MIRROR_SIZE);
  207. if (!base) {
  208. BUGMSG2(D_INIT_REASONS, "(ioremap)\n");
  209. BUGMSG2(D_INIT_REASONS, "Stage 3: ");
  210. BUGLVL(D_INIT_REASONS) numprint = 0;
  211. goto out1;
  212. }
  213. if (readb(base) != TESTvalue) {
  214. BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
  215. readb(base), TESTvalue);
  216. BUGMSG2(D_INIT_REASONS, "S3: ");
  217. BUGLVL(D_INIT_REASONS) numprint = 0;
  218. goto out2;
  219. }
  220. /* By writing 0x42 to the TESTvalue location, we also make
  221. * sure no "mirror" shmem areas show up - if they occur
  222. * in another pass through this loop, they will be discarded
  223. * because *cptr != TESTvalue.
  224. */
  225. writeb(0x42, base);
  226. if (readb(base) != 0x42) {
  227. BUGMSG2(D_INIT_REASONS, "(read only)\n");
  228. BUGMSG2(D_INIT_REASONS, "S3: ");
  229. goto out2;
  230. }
  231. BUGMSG2(D_INIT_REASONS, "\n");
  232. BUGMSG2(D_INIT_REASONS, "S3: ");
  233. BUGLVL(D_INIT_REASONS) numprint = 0;
  234. iomem[index] = base;
  235. continue;
  236. out2:
  237. iounmap(base);
  238. out1:
  239. release_mem_region(*p, MIRROR_SIZE);
  240. out:
  241. *p-- = shmems[--numshmems];
  242. index--;
  243. }
  244. BUGMSG2(D_INIT, "\n");
  245. if (!numshmems) {
  246. BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n");
  247. for (port = &ports[0]; port < ports + numports; port++)
  248. release_region(*port, ARCNET_TOTAL_SIZE);
  249. kfree(shmems);
  250. kfree(iomem);
  251. return;
  252. }
  253. /* Stage 4: something of a dummy, to report the shmems that are
  254. * still possible after stage 3.
  255. */
  256. numprint = -1;
  257. for (p = &shmems[0]; p < shmems + numshmems; p++) {
  258. numprint++;
  259. numprint %= 8;
  260. if (!numprint) {
  261. BUGMSG2(D_INIT, "\n");
  262. BUGMSG2(D_INIT, "S4: ");
  263. }
  264. BUGMSG2(D_INIT, "%lXh ", *p);
  265. }
  266. BUGMSG2(D_INIT, "\n");
  267. /* Stage 5: for any ports that have the correct status, can disable
  268. * the RESET flag, and (if no irq is given) generate an autoirq,
  269. * register an ARCnet device.
  270. *
  271. * Currently, we can only register one device per probe, so quit
  272. * after the first one is found.
  273. */
  274. numprint = -1;
  275. for (port = &ports[0]; port < ports + numports; port++) {
  276. int found = 0;
  277. numprint++;
  278. numprint %= 8;
  279. if (!numprint) {
  280. BUGMSG2(D_INIT, "\n");
  281. BUGMSG2(D_INIT, "S5: ");
  282. }
  283. BUGMSG2(D_INIT, "%Xh ", *port);
  284. ioaddr = *port;
  285. status = ASTATUS();
  286. if ((status & 0x9D)
  287. != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
  288. BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status);
  289. BUGMSG2(D_INIT_REASONS, "S5: ");
  290. BUGLVL(D_INIT_REASONS) numprint = 0;
  291. release_region(*port, ARCNET_TOTAL_SIZE);
  292. *port-- = ports[--numports];
  293. continue;
  294. }
  295. ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
  296. status = ASTATUS();
  297. if (status & RESETflag) {
  298. BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
  299. status);
  300. BUGMSG2(D_INIT_REASONS, "S5: ");
  301. BUGLVL(D_INIT_REASONS) numprint = 0;
  302. release_region(*port, ARCNET_TOTAL_SIZE);
  303. *port-- = ports[--numports];
  304. continue;
  305. }
  306. /* skip this completely if an IRQ was given, because maybe
  307. * we're on a machine that locks during autoirq!
  308. */
  309. if (!irq) {
  310. /* if we do this, we're sure to get an IRQ since the
  311. * card has just reset and the NORXflag is on until
  312. * we tell it to start receiving.
  313. */
  314. airqmask = probe_irq_on();
  315. AINTMASK(NORXflag);
  316. udelay(1);
  317. AINTMASK(0);
  318. airq = probe_irq_off(airqmask);
  319. if (airq <= 0) {
  320. BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq);
  321. BUGMSG2(D_INIT_REASONS, "S5: ");
  322. BUGLVL(D_INIT_REASONS) numprint = 0;
  323. release_region(*port, ARCNET_TOTAL_SIZE);
  324. *port-- = ports[--numports];
  325. continue;
  326. }
  327. } else {
  328. airq = irq;
  329. }
  330. BUGMSG2(D_INIT, "(%d,", airq);
  331. openparen = 1;
  332. /* Everything seems okay. But which shmem, if any, puts
  333. * back its signature byte when the card is reset?
  334. *
  335. * If there are multiple cards installed, there might be
  336. * multiple shmems still in the list.
  337. */
  338. #ifdef FAST_PROBE
  339. if (numports > 1 || numshmems > 1) {
  340. inb(_RESET);
  341. mdelay(RESETtime);
  342. } else {
  343. /* just one shmem and port, assume they match */
  344. writeb(TESTvalue, iomem[0]);
  345. }
  346. #else
  347. inb(_RESET);
  348. mdelay(RESETtime);
  349. #endif
  350. for (index = 0; index < numshmems; index++) {
  351. u_long ptr = shmems[index];
  352. void __iomem *base = iomem[index];
  353. if (readb(base) == TESTvalue) { /* found one */
  354. BUGMSG2(D_INIT, "%lXh)\n", *p);
  355. openparen = 0;
  356. /* register the card */
  357. if (com90xx_found(*port, airq, ptr, base) == 0)
  358. found = 1;
  359. numprint = -1;
  360. /* remove shmem from the list */
  361. shmems[index] = shmems[--numshmems];
  362. iomem[index] = iomem[numshmems];
  363. break; /* go to the next I/O port */
  364. } else {
  365. BUGMSG2(D_INIT_REASONS, "%Xh-", readb(base));
  366. }
  367. }
  368. if (openparen) {
  369. BUGLVL(D_INIT) printk("no matching shmem)\n");
  370. BUGLVL(D_INIT_REASONS) printk("S5: ");
  371. BUGLVL(D_INIT_REASONS) numprint = 0;
  372. }
  373. if (!found)
  374. release_region(*port, ARCNET_TOTAL_SIZE);
  375. *port-- = ports[--numports];
  376. }
  377. BUGLVL(D_INIT_REASONS) printk("\n");
  378. /* Now put back TESTvalue on all leftover shmems. */
  379. for (index = 0; index < numshmems; index++) {
  380. writeb(TESTvalue, iomem[index]);
  381. iounmap(iomem[index]);
  382. release_mem_region(shmems[index], MIRROR_SIZE);
  383. }
  384. kfree(shmems);
  385. kfree(iomem);
  386. }
  387. static int check_mirror(unsigned long addr, size_t size)
  388. {
  389. void __iomem *p;
  390. int res = -1;
  391. if (!request_mem_region(addr, size, "arcnet (90xx)"))
  392. return -1;
  393. p = ioremap(addr, size);
  394. if (p) {
  395. if (readb(p) == TESTvalue)
  396. res = 1;
  397. else
  398. res = 0;
  399. iounmap(p);
  400. }
  401. release_mem_region(addr, size);
  402. return res;
  403. }
  404. /* Set up the struct net_device associated with this card. Called after
  405. * probing succeeds.
  406. */
  407. static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *p)
  408. {
  409. struct net_device *dev = NULL;
  410. struct arcnet_local *lp;
  411. u_long first_mirror, last_mirror;
  412. int mirror_size;
  413. /* allocate struct net_device */
  414. dev = alloc_arcdev(device);
  415. if (!dev) {
  416. BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n");
  417. iounmap(p);
  418. release_mem_region(shmem, MIRROR_SIZE);
  419. return -ENOMEM;
  420. }
  421. lp = netdev_priv(dev);
  422. /* find the real shared memory start/end points, including mirrors */
  423. /* guess the actual size of one "memory mirror" - the number of
  424. * bytes between copies of the shared memory. On most cards, it's
  425. * 2k (or there are no mirrors at all) but on some, it's 4k.
  426. */
  427. mirror_size = MIRROR_SIZE;
  428. if (readb(p) == TESTvalue &&
  429. check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
  430. check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
  431. mirror_size = 2 * MIRROR_SIZE;
  432. first_mirror = shmem - mirror_size;
  433. while (check_mirror(first_mirror, mirror_size) == 1)
  434. first_mirror -= mirror_size;
  435. first_mirror += mirror_size;
  436. last_mirror = shmem + mirror_size;
  437. while (check_mirror(last_mirror, mirror_size) == 1)
  438. last_mirror += mirror_size;
  439. last_mirror -= mirror_size;
  440. dev->mem_start = first_mirror;
  441. dev->mem_end = last_mirror + MIRROR_SIZE - 1;
  442. iounmap(p);
  443. release_mem_region(shmem, MIRROR_SIZE);
  444. if (!request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)"))
  445. goto err_free_dev;
  446. /* reserve the irq */
  447. if (request_irq(airq, arcnet_interrupt, 0, "arcnet (90xx)", dev)) {
  448. BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", airq);
  449. goto err_release_mem;
  450. }
  451. dev->irq = airq;
  452. /* Initialize the rest of the device structure. */
  453. lp->card_name = "COM90xx";
  454. lp->hw.command = com90xx_command;
  455. lp->hw.status = com90xx_status;
  456. lp->hw.intmask = com90xx_setmask;
  457. lp->hw.reset = com90xx_reset;
  458. lp->hw.owner = THIS_MODULE;
  459. lp->hw.copy_to_card = com90xx_copy_to_card;
  460. lp->hw.copy_from_card = com90xx_copy_from_card;
  461. lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1);
  462. if (!lp->mem_start) {
  463. BUGMSG(D_NORMAL, "Can't remap device memory!\n");
  464. goto err_free_irq;
  465. }
  466. /* get and check the station ID from offset 1 in shmem */
  467. dev->dev_addr[0] = readb(lp->mem_start + 1);
  468. dev->base_addr = ioaddr;
  469. BUGMSG(D_NORMAL, "COM90xx station %02Xh found at %03lXh, IRQ %d, "
  470. "ShMem %lXh (%ld*%xh).\n",
  471. dev->dev_addr[0],
  472. dev->base_addr, dev->irq, dev->mem_start,
  473. (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size);
  474. if (register_netdev(dev))
  475. goto err_unmap;
  476. cards[numcards++] = dev;
  477. return 0;
  478. err_unmap:
  479. iounmap(lp->mem_start);
  480. err_free_irq:
  481. free_irq(dev->irq, dev);
  482. err_release_mem:
  483. release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
  484. err_free_dev:
  485. free_netdev(dev);
  486. return -EIO;
  487. }
  488. static void com90xx_command(struct net_device *dev, int cmd)
  489. {
  490. short ioaddr = dev->base_addr;
  491. ACOMMAND(cmd);
  492. }
  493. static int com90xx_status(struct net_device *dev)
  494. {
  495. short ioaddr = dev->base_addr;
  496. return ASTATUS();
  497. }
  498. static void com90xx_setmask(struct net_device *dev, int mask)
  499. {
  500. short ioaddr = dev->base_addr;
  501. AINTMASK(mask);
  502. }
  503. /*
  504. * Do a hardware reset on the card, and set up necessary registers.
  505. *
  506. * This should be called as little as possible, because it disrupts the
  507. * token on the network (causes a RECON) and requires a significant delay.
  508. *
  509. * However, it does make sure the card is in a defined state.
  510. */
  511. static int com90xx_reset(struct net_device *dev, int really_reset)
  512. {
  513. struct arcnet_local *lp = netdev_priv(dev);
  514. short ioaddr = dev->base_addr;
  515. BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", ASTATUS());
  516. if (really_reset) {
  517. /* reset the card */
  518. inb(_RESET);
  519. mdelay(RESETtime);
  520. }
  521. ACOMMAND(CFLAGScmd | RESETclear); /* clear flags & end reset */
  522. ACOMMAND(CFLAGScmd | CONFIGclear);
  523. /* don't do this until we verify that it doesn't hurt older cards! */
  524. /* outb(inb(_CONFIG) | ENABLE16flag, _CONFIG); */
  525. /* verify that the ARCnet signature byte is present */
  526. if (readb(lp->mem_start) != TESTvalue) {
  527. if (really_reset)
  528. BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n");
  529. return 1;
  530. }
  531. /* enable extended (512-byte) packets */
  532. ACOMMAND(CONFIGcmd | EXTconf);
  533. /* clean out all the memory to make debugging make more sense :) */
  534. BUGLVL(D_DURING)
  535. memset_io(lp->mem_start, 0x42, 2048);
  536. /* done! return success. */
  537. return 0;
  538. }
  539. static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
  540. void *buf, int count)
  541. {
  542. struct arcnet_local *lp = netdev_priv(dev);
  543. void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
  544. TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count));
  545. }
  546. static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offset,
  547. void *buf, int count)
  548. {
  549. struct arcnet_local *lp = netdev_priv(dev);
  550. void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
  551. TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
  552. }
  553. MODULE_LICENSE("GPL");
  554. static int __init com90xx_init(void)
  555. {
  556. if (irq == 2)
  557. irq = 9;
  558. com90xx_probe();
  559. if (!numcards)
  560. return -EIO;
  561. return 0;
  562. }
  563. static void __exit com90xx_exit(void)
  564. {
  565. struct net_device *dev;
  566. struct arcnet_local *lp;
  567. int count;
  568. for (count = 0; count < numcards; count++) {
  569. dev = cards[count];
  570. lp = netdev_priv(dev);
  571. unregister_netdev(dev);
  572. free_irq(dev->irq, dev);
  573. iounmap(lp->mem_start);
  574. release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
  575. release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
  576. free_netdev(dev);
  577. }
  578. }
  579. module_init(com90xx_init);
  580. module_exit(com90xx_exit);
  581. #ifndef MODULE
  582. static int __init com90xx_setup(char *s)
  583. {
  584. int ints[8];
  585. s = get_options(s, 8, ints);
  586. if (!ints[0] && !*s) {
  587. printk("com90xx: Disabled.\n");
  588. return 1;
  589. }
  590. switch (ints[0]) {
  591. default: /* ERROR */
  592. printk("com90xx: Too many arguments.\n");
  593. case 3: /* Mem address */
  594. shmem = ints[3];
  595. case 2: /* IRQ */
  596. irq = ints[2];
  597. case 1: /* IO address */
  598. io = ints[1];
  599. }
  600. if (*s)
  601. snprintf(device, sizeof(device), "%s", s);
  602. return 1;
  603. }
  604. __setup("com90xx=", com90xx_setup);
  605. #endif