com90xx.c 18 KB

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