fmvj18x_cs.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. /*======================================================================
  2. fmvj18x_cs.c 2.8 2002/03/23
  3. A fmvj18x (and its compatibles) PCMCIA client driver
  4. Contributed by Shingo Fujimoto, shingo@flab.fujitsu.co.jp
  5. TDK LAK-CD021 and CONTEC C-NET(PC)C support added by
  6. Nobuhiro Katayama, kata-n@po.iijnet.or.jp
  7. The PCMCIA client code is based on code written by David Hinds.
  8. Network code is based on the "FMV-18x driver" by Yutaka TAMIYA
  9. but is actually largely Donald Becker's AT1700 driver, which
  10. carries the following attribution:
  11. Written 1993-94 by Donald Becker.
  12. Copyright 1993 United States Government as represented by the
  13. Director, National Security Agency.
  14. This software may be used and distributed according to the terms
  15. of the GNU General Public License, incorporated herein by reference.
  16. The author may be reached as becker@scyld.com, or C/O
  17. Scyld Computing Corporation
  18. 410 Severn Ave., Suite 210
  19. Annapolis MD 21403
  20. ======================================================================*/
  21. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  22. #define DRV_NAME "fmvj18x_cs"
  23. #define DRV_VERSION "2.9"
  24. #include <linux/module.h>
  25. #include <linux/kernel.h>
  26. #include <linux/ptrace.h>
  27. #include <linux/slab.h>
  28. #include <linux/string.h>
  29. #include <linux/timer.h>
  30. #include <linux/interrupt.h>
  31. #include <linux/in.h>
  32. #include <linux/delay.h>
  33. #include <linux/ethtool.h>
  34. #include <linux/netdevice.h>
  35. #include <linux/etherdevice.h>
  36. #include <linux/skbuff.h>
  37. #include <linux/if_arp.h>
  38. #include <linux/ioport.h>
  39. #include <linux/crc32.h>
  40. #include <pcmcia/cistpl.h>
  41. #include <pcmcia/ciscode.h>
  42. #include <pcmcia/ds.h>
  43. #include <linux/uaccess.h>
  44. #include <asm/io.h>
  45. /*====================================================================*/
  46. /* Module parameters */
  47. MODULE_DESCRIPTION("fmvj18x and compatible PCMCIA ethernet driver");
  48. MODULE_LICENSE("GPL");
  49. #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0)
  50. /* SRAM configuration */
  51. /* 0:4KB*2 TX buffer else:8KB*2 TX buffer */
  52. INT_MODULE_PARM(sram_config, 0);
  53. /*====================================================================*/
  54. /*
  55. PCMCIA event handlers
  56. */
  57. static int fmvj18x_config(struct pcmcia_device *link);
  58. static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id);
  59. static int fmvj18x_setup_mfc(struct pcmcia_device *link);
  60. static void fmvj18x_release(struct pcmcia_device *link);
  61. static void fmvj18x_detach(struct pcmcia_device *p_dev);
  62. /*
  63. LAN controller(MBH86960A) specific routines
  64. */
  65. static int fjn_config(struct net_device *dev, struct ifmap *map);
  66. static int fjn_open(struct net_device *dev);
  67. static int fjn_close(struct net_device *dev);
  68. static netdev_tx_t fjn_start_xmit(struct sk_buff *skb,
  69. struct net_device *dev);
  70. static irqreturn_t fjn_interrupt(int irq, void *dev_id);
  71. static void fjn_rx(struct net_device *dev);
  72. static void fjn_reset(struct net_device *dev);
  73. static void set_rx_mode(struct net_device *dev);
  74. static void fjn_tx_timeout(struct net_device *dev);
  75. static const struct ethtool_ops netdev_ethtool_ops;
  76. /*
  77. card type
  78. */
  79. enum cardtype { MBH10302, MBH10304, TDK, CONTEC, LA501, UNGERMANN,
  80. XXX10304, NEC, KME
  81. };
  82. /*
  83. driver specific data structure
  84. */
  85. struct local_info {
  86. struct pcmcia_device *p_dev;
  87. long open_time;
  88. uint tx_started:1;
  89. uint tx_queue;
  90. u_short tx_queue_len;
  91. enum cardtype cardtype;
  92. u_short sent;
  93. u_char __iomem *base;
  94. };
  95. #define MC_FILTERBREAK 64
  96. /*====================================================================*/
  97. /*
  98. ioport offset from the base address
  99. */
  100. #define TX_STATUS 0 /* transmit status register */
  101. #define RX_STATUS 1 /* receive status register */
  102. #define TX_INTR 2 /* transmit interrupt mask register */
  103. #define RX_INTR 3 /* receive interrupt mask register */
  104. #define TX_MODE 4 /* transmit mode register */
  105. #define RX_MODE 5 /* receive mode register */
  106. #define CONFIG_0 6 /* configuration register 0 */
  107. #define CONFIG_1 7 /* configuration register 1 */
  108. #define NODE_ID 8 /* node ID register (bank 0) */
  109. #define MAR_ADR 8 /* multicast address registers (bank 1) */
  110. #define DATAPORT 8 /* buffer mem port registers (bank 2) */
  111. #define TX_START 10 /* transmit start register */
  112. #define COL_CTRL 11 /* 16 collision control register */
  113. #define BMPR12 12 /* reserved */
  114. #define BMPR13 13 /* reserved */
  115. #define RX_SKIP 14 /* skip received packet register */
  116. #define LAN_CTRL 16 /* LAN card control register */
  117. #define MAC_ID 0x1a /* hardware address */
  118. #define UNGERMANN_MAC_ID 0x18 /* UNGERMANN-BASS hardware address */
  119. /*
  120. control bits
  121. */
  122. #define ENA_TMT_OK 0x80
  123. #define ENA_TMT_REC 0x20
  124. #define ENA_COL 0x04
  125. #define ENA_16_COL 0x02
  126. #define ENA_TBUS_ERR 0x01
  127. #define ENA_PKT_RDY 0x80
  128. #define ENA_BUS_ERR 0x40
  129. #define ENA_LEN_ERR 0x08
  130. #define ENA_ALG_ERR 0x04
  131. #define ENA_CRC_ERR 0x02
  132. #define ENA_OVR_FLO 0x01
  133. /* flags */
  134. #define F_TMT_RDY 0x80 /* can accept new packet */
  135. #define F_NET_BSY 0x40 /* carrier is detected */
  136. #define F_TMT_OK 0x20 /* send packet successfully */
  137. #define F_SRT_PKT 0x10 /* short packet error */
  138. #define F_COL_ERR 0x04 /* collision error */
  139. #define F_16_COL 0x02 /* 16 collision error */
  140. #define F_TBUS_ERR 0x01 /* bus read error */
  141. #define F_PKT_RDY 0x80 /* packet(s) in buffer */
  142. #define F_BUS_ERR 0x40 /* bus read error */
  143. #define F_LEN_ERR 0x08 /* short packet */
  144. #define F_ALG_ERR 0x04 /* frame error */
  145. #define F_CRC_ERR 0x02 /* CRC error */
  146. #define F_OVR_FLO 0x01 /* overflow error */
  147. #define F_BUF_EMP 0x40 /* receive buffer is empty */
  148. #define F_SKP_PKT 0x05 /* drop packet in buffer */
  149. /* default bitmaps */
  150. #define D_TX_INTR ( ENA_TMT_OK )
  151. #define D_RX_INTR ( ENA_PKT_RDY | ENA_LEN_ERR \
  152. | ENA_ALG_ERR | ENA_CRC_ERR | ENA_OVR_FLO )
  153. #define TX_STAT_M ( F_TMT_RDY )
  154. #define RX_STAT_M ( F_PKT_RDY | F_LEN_ERR \
  155. | F_ALG_ERR | F_CRC_ERR | F_OVR_FLO )
  156. /* commands */
  157. #define D_TX_MODE 0x06 /* no tests, detect carrier */
  158. #define ID_MATCHED 0x02 /* (RX_MODE) */
  159. #define RECV_ALL 0x03 /* (RX_MODE) */
  160. #define CONFIG0_DFL 0x5a /* 16bit bus, 4K x 2 Tx queues */
  161. #define CONFIG0_DFL_1 0x5e /* 16bit bus, 8K x 2 Tx queues */
  162. #define CONFIG0_RST 0xda /* Data Link Controller off (CONFIG_0) */
  163. #define CONFIG0_RST_1 0xde /* Data Link Controller off (CONFIG_0) */
  164. #define BANK_0 0xa0 /* bank 0 (CONFIG_1) */
  165. #define BANK_1 0xa4 /* bank 1 (CONFIG_1) */
  166. #define BANK_2 0xa8 /* bank 2 (CONFIG_1) */
  167. #define CHIP_OFF 0x80 /* contrl chip power off (CONFIG_1) */
  168. #define DO_TX 0x80 /* do transmit packet */
  169. #define SEND_PKT 0x81 /* send a packet */
  170. #define AUTO_MODE 0x07 /* Auto skip packet on 16 col detected */
  171. #define MANU_MODE 0x03 /* Stop and skip packet on 16 col */
  172. #define TDK_AUTO_MODE 0x47 /* Auto skip packet on 16 col detected */
  173. #define TDK_MANU_MODE 0x43 /* Stop and skip packet on 16 col */
  174. #define INTR_OFF 0x0d /* LAN controller ignores interrupts */
  175. #define INTR_ON 0x1d /* LAN controller will catch interrupts */
  176. #define TX_TIMEOUT ((400*HZ)/1000)
  177. #define BANK_0U 0x20 /* bank 0 (CONFIG_1) */
  178. #define BANK_1U 0x24 /* bank 1 (CONFIG_1) */
  179. #define BANK_2U 0x28 /* bank 2 (CONFIG_1) */
  180. static const struct net_device_ops fjn_netdev_ops = {
  181. .ndo_open = fjn_open,
  182. .ndo_stop = fjn_close,
  183. .ndo_start_xmit = fjn_start_xmit,
  184. .ndo_tx_timeout = fjn_tx_timeout,
  185. .ndo_set_config = fjn_config,
  186. .ndo_set_rx_mode = set_rx_mode,
  187. .ndo_set_mac_address = eth_mac_addr,
  188. .ndo_validate_addr = eth_validate_addr,
  189. };
  190. static int fmvj18x_probe(struct pcmcia_device *link)
  191. {
  192. struct local_info *lp;
  193. struct net_device *dev;
  194. dev_dbg(&link->dev, "fmvj18x_attach()\n");
  195. /* Make up a FMVJ18x specific data structure */
  196. dev = alloc_etherdev(sizeof(struct local_info));
  197. if (!dev)
  198. return -ENOMEM;
  199. lp = netdev_priv(dev);
  200. link->priv = dev;
  201. lp->p_dev = link;
  202. lp->base = NULL;
  203. /* The io structure describes IO port mapping */
  204. link->resource[0]->end = 32;
  205. link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
  206. /* General socket configuration */
  207. link->config_flags |= CONF_ENABLE_IRQ;
  208. dev->netdev_ops = &fjn_netdev_ops;
  209. dev->watchdog_timeo = TX_TIMEOUT;
  210. dev->ethtool_ops = &netdev_ethtool_ops;
  211. return fmvj18x_config(link);
  212. } /* fmvj18x_attach */
  213. /*====================================================================*/
  214. static void fmvj18x_detach(struct pcmcia_device *link)
  215. {
  216. struct net_device *dev = link->priv;
  217. dev_dbg(&link->dev, "fmvj18x_detach\n");
  218. unregister_netdev(dev);
  219. fmvj18x_release(link);
  220. free_netdev(dev);
  221. } /* fmvj18x_detach */
  222. /*====================================================================*/
  223. static int mfc_try_io_port(struct pcmcia_device *link)
  224. {
  225. int i, ret;
  226. static const unsigned int serial_base[5] =
  227. { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
  228. for (i = 0; i < 5; i++) {
  229. link->resource[1]->start = serial_base[i];
  230. link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
  231. if (link->resource[1]->start == 0) {
  232. link->resource[1]->end = 0;
  233. pr_notice("out of resource for serial\n");
  234. }
  235. ret = pcmcia_request_io(link);
  236. if (ret == 0)
  237. return ret;
  238. }
  239. return ret;
  240. }
  241. static int ungermann_try_io_port(struct pcmcia_device *link)
  242. {
  243. int ret;
  244. unsigned int ioaddr;
  245. /*
  246. Ungermann-Bass Access/CARD accepts 0x300,0x320,0x340,0x360
  247. 0x380,0x3c0 only for ioport.
  248. */
  249. for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) {
  250. link->resource[0]->start = ioaddr;
  251. ret = pcmcia_request_io(link);
  252. if (ret == 0) {
  253. /* calculate ConfigIndex value */
  254. link->config_index =
  255. ((link->resource[0]->start & 0x0f0) >> 3) | 0x22;
  256. return ret;
  257. }
  258. }
  259. return ret; /* RequestIO failed */
  260. }
  261. static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
  262. {
  263. return 0; /* strange, but that's what the code did already before... */
  264. }
  265. static int fmvj18x_config(struct pcmcia_device *link)
  266. {
  267. struct net_device *dev = link->priv;
  268. struct local_info *lp = netdev_priv(dev);
  269. int i, ret;
  270. unsigned int ioaddr;
  271. enum cardtype cardtype;
  272. char *card_name = "unknown";
  273. u8 *buf;
  274. size_t len;
  275. u_char buggybuf[32];
  276. dev_dbg(&link->dev, "fmvj18x_config\n");
  277. link->io_lines = 5;
  278. len = pcmcia_get_tuple(link, CISTPL_FUNCE, &buf);
  279. kfree(buf);
  280. if (len) {
  281. /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */
  282. ret = pcmcia_loop_config(link, fmvj18x_ioprobe, NULL);
  283. if (ret != 0)
  284. goto failed;
  285. switch (link->manf_id) {
  286. case MANFID_TDK:
  287. cardtype = TDK;
  288. if (link->card_id == PRODID_TDK_GN3410 ||
  289. link->card_id == PRODID_TDK_NP9610 ||
  290. link->card_id == PRODID_TDK_MN3200) {
  291. /* MultiFunction Card */
  292. link->config_base = 0x800;
  293. link->config_index = 0x47;
  294. link->resource[1]->end = 8;
  295. }
  296. break;
  297. case MANFID_NEC:
  298. cardtype = NEC; /* MultiFunction Card */
  299. link->config_base = 0x800;
  300. link->config_index = 0x47;
  301. link->resource[1]->end = 8;
  302. break;
  303. case MANFID_KME:
  304. cardtype = KME; /* MultiFunction Card */
  305. link->config_base = 0x800;
  306. link->config_index = 0x47;
  307. link->resource[1]->end = 8;
  308. break;
  309. case MANFID_CONTEC:
  310. cardtype = CONTEC;
  311. break;
  312. case MANFID_FUJITSU:
  313. if (link->config_base == 0x0fe0)
  314. cardtype = MBH10302;
  315. else if (link->card_id == PRODID_FUJITSU_MBH10302)
  316. /* RATOC REX-5588/9822/4886's PRODID are 0004(=MBH10302),
  317. but these are MBH10304 based card. */
  318. cardtype = MBH10304;
  319. else if (link->card_id == PRODID_FUJITSU_MBH10304)
  320. cardtype = MBH10304;
  321. else
  322. cardtype = LA501;
  323. break;
  324. default:
  325. cardtype = MBH10304;
  326. }
  327. } else {
  328. /* old type card */
  329. switch (link->manf_id) {
  330. case MANFID_FUJITSU:
  331. if (link->card_id == PRODID_FUJITSU_MBH10304) {
  332. cardtype = XXX10304; /* MBH10304 with buggy CIS */
  333. link->config_index = 0x20;
  334. } else {
  335. cardtype = MBH10302; /* NextCom NC5310, etc. */
  336. link->config_index = 1;
  337. }
  338. break;
  339. case MANFID_UNGERMANN:
  340. cardtype = UNGERMANN;
  341. break;
  342. default:
  343. cardtype = MBH10302;
  344. link->config_index = 1;
  345. }
  346. }
  347. if (link->resource[1]->end != 0) {
  348. ret = mfc_try_io_port(link);
  349. if (ret != 0) goto failed;
  350. } else if (cardtype == UNGERMANN) {
  351. ret = ungermann_try_io_port(link);
  352. if (ret != 0) goto failed;
  353. } else {
  354. ret = pcmcia_request_io(link);
  355. if (ret)
  356. goto failed;
  357. }
  358. ret = pcmcia_request_irq(link, fjn_interrupt);
  359. if (ret)
  360. goto failed;
  361. ret = pcmcia_enable_device(link);
  362. if (ret)
  363. goto failed;
  364. dev->irq = link->irq;
  365. dev->base_addr = link->resource[0]->start;
  366. if (resource_size(link->resource[1]) != 0) {
  367. ret = fmvj18x_setup_mfc(link);
  368. if (ret != 0) goto failed;
  369. }
  370. ioaddr = dev->base_addr;
  371. /* Reset controller */
  372. if (sram_config == 0)
  373. outb(CONFIG0_RST, ioaddr + CONFIG_0);
  374. else
  375. outb(CONFIG0_RST_1, ioaddr + CONFIG_0);
  376. /* Power On chip and select bank 0 */
  377. if (cardtype == MBH10302)
  378. outb(BANK_0, ioaddr + CONFIG_1);
  379. else
  380. outb(BANK_0U, ioaddr + CONFIG_1);
  381. /* Set hardware address */
  382. switch (cardtype) {
  383. case MBH10304:
  384. case TDK:
  385. case LA501:
  386. case CONTEC:
  387. case NEC:
  388. case KME:
  389. if (cardtype == MBH10304) {
  390. card_name = "FMV-J182";
  391. len = pcmcia_get_tuple(link, CISTPL_FUNCE, &buf);
  392. if (len < 11) {
  393. kfree(buf);
  394. goto failed;
  395. }
  396. /* Read MACID from CIS */
  397. for (i = 0; i < 6; i++)
  398. dev->dev_addr[i] = buf[i + 5];
  399. kfree(buf);
  400. } else {
  401. if (pcmcia_get_mac_from_cis(link, dev))
  402. goto failed;
  403. if( cardtype == TDK ) {
  404. card_name = "TDK LAK-CD021";
  405. } else if( cardtype == LA501 ) {
  406. card_name = "LA501";
  407. } else if( cardtype == NEC ) {
  408. card_name = "PK-UG-J001";
  409. } else if( cardtype == KME ) {
  410. card_name = "Panasonic";
  411. } else {
  412. card_name = "C-NET(PC)C";
  413. }
  414. }
  415. break;
  416. case UNGERMANN:
  417. /* Read MACID from register */
  418. for (i = 0; i < 6; i++)
  419. dev->dev_addr[i] = inb(ioaddr + UNGERMANN_MAC_ID + i);
  420. card_name = "Access/CARD";
  421. break;
  422. case XXX10304:
  423. /* Read MACID from Buggy CIS */
  424. if (fmvj18x_get_hwinfo(link, buggybuf) == -1) {
  425. pr_notice("unable to read hardware net address\n");
  426. goto failed;
  427. }
  428. for (i = 0 ; i < 6; i++) {
  429. dev->dev_addr[i] = buggybuf[i];
  430. }
  431. card_name = "FMV-J182";
  432. break;
  433. case MBH10302:
  434. default:
  435. /* Read MACID from register */
  436. for (i = 0; i < 6; i++)
  437. dev->dev_addr[i] = inb(ioaddr + MAC_ID + i);
  438. card_name = "FMV-J181";
  439. break;
  440. }
  441. lp->cardtype = cardtype;
  442. SET_NETDEV_DEV(dev, &link->dev);
  443. if (register_netdev(dev) != 0) {
  444. pr_notice("register_netdev() failed\n");
  445. goto failed;
  446. }
  447. /* print current configuration */
  448. netdev_info(dev, "%s, sram %s, port %#3lx, irq %d, hw_addr %pM\n",
  449. card_name, sram_config == 0 ? "4K TX*2" : "8K TX*2",
  450. dev->base_addr, dev->irq, dev->dev_addr);
  451. return 0;
  452. failed:
  453. fmvj18x_release(link);
  454. return -ENODEV;
  455. } /* fmvj18x_config */
  456. /*====================================================================*/
  457. static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
  458. {
  459. u_char __iomem *base;
  460. int i, j;
  461. /* Allocate a small memory window */
  462. link->resource[2]->flags |= WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
  463. link->resource[2]->start = 0; link->resource[2]->end = 0;
  464. i = pcmcia_request_window(link, link->resource[2], 0);
  465. if (i != 0)
  466. return -1;
  467. base = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
  468. if (!base) {
  469. pcmcia_release_window(link, link->resource[2]);
  470. return -1;
  471. }
  472. pcmcia_map_mem_page(link, link->resource[2], 0);
  473. /*
  474. * MBH10304 CISTPL_FUNCE_LAN_NODE_ID format
  475. * 22 0d xx xx xx 04 06 yy yy yy yy yy yy ff
  476. * 'xx' is garbage.
  477. * 'yy' is MAC address.
  478. */
  479. for (i = 0; i < 0x200; i++) {
  480. if (readb(base+i*2) == 0x22) {
  481. if (readb(base+(i-1)*2) == 0xff &&
  482. readb(base+(i+5)*2) == 0x04 &&
  483. readb(base+(i+6)*2) == 0x06 &&
  484. readb(base+(i+13)*2) == 0xff)
  485. break;
  486. }
  487. }
  488. if (i != 0x200) {
  489. for (j = 0 ; j < 6; j++,i++) {
  490. node_id[j] = readb(base+(i+7)*2);
  491. }
  492. }
  493. iounmap(base);
  494. j = pcmcia_release_window(link, link->resource[2]);
  495. return (i != 0x200) ? 0 : -1;
  496. } /* fmvj18x_get_hwinfo */
  497. /*====================================================================*/
  498. static int fmvj18x_setup_mfc(struct pcmcia_device *link)
  499. {
  500. int i;
  501. struct net_device *dev = link->priv;
  502. unsigned int ioaddr;
  503. struct local_info *lp = netdev_priv(dev);
  504. /* Allocate a small memory window */
  505. link->resource[3]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
  506. link->resource[3]->start = link->resource[3]->end = 0;
  507. i = pcmcia_request_window(link, link->resource[3], 0);
  508. if (i != 0)
  509. return -1;
  510. lp->base = ioremap(link->resource[3]->start,
  511. resource_size(link->resource[3]));
  512. if (lp->base == NULL) {
  513. netdev_notice(dev, "ioremap failed\n");
  514. return -1;
  515. }
  516. i = pcmcia_map_mem_page(link, link->resource[3], 0);
  517. if (i != 0) {
  518. iounmap(lp->base);
  519. lp->base = NULL;
  520. return -1;
  521. }
  522. ioaddr = dev->base_addr;
  523. writeb(0x47, lp->base+0x800); /* Config Option Register of LAN */
  524. writeb(0x0, lp->base+0x802); /* Config and Status Register */
  525. writeb(ioaddr & 0xff, lp->base+0x80a); /* I/O Base(Low) of LAN */
  526. writeb((ioaddr >> 8) & 0xff, lp->base+0x80c); /* I/O Base(High) of LAN */
  527. writeb(0x45, lp->base+0x820); /* Config Option Register of Modem */
  528. writeb(0x8, lp->base+0x822); /* Config and Status Register */
  529. return 0;
  530. }
  531. /*====================================================================*/
  532. static void fmvj18x_release(struct pcmcia_device *link)
  533. {
  534. struct net_device *dev = link->priv;
  535. struct local_info *lp = netdev_priv(dev);
  536. u_char __iomem *tmp;
  537. dev_dbg(&link->dev, "fmvj18x_release\n");
  538. if (lp->base != NULL) {
  539. tmp = lp->base;
  540. lp->base = NULL; /* set NULL before iounmap */
  541. iounmap(tmp);
  542. }
  543. pcmcia_disable_device(link);
  544. }
  545. static int fmvj18x_suspend(struct pcmcia_device *link)
  546. {
  547. struct net_device *dev = link->priv;
  548. if (link->open)
  549. netif_device_detach(dev);
  550. return 0;
  551. }
  552. static int fmvj18x_resume(struct pcmcia_device *link)
  553. {
  554. struct net_device *dev = link->priv;
  555. if (link->open) {
  556. fjn_reset(dev);
  557. netif_device_attach(dev);
  558. }
  559. return 0;
  560. }
  561. /*====================================================================*/
  562. static const struct pcmcia_device_id fmvj18x_ids[] = {
  563. PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004),
  564. PCMCIA_DEVICE_PROD_ID12("EAGLE Technology", "NE200 ETHERNET LAN MBH10302 04", 0x528c88c4, 0x74f91e59),
  565. PCMCIA_DEVICE_PROD_ID12("Eiger Labs,Inc", "EPX-10BT PC Card Ethernet 10BT", 0x53af556e, 0x877f9922),
  566. PCMCIA_DEVICE_PROD_ID12("Eiger labs,Inc.", "EPX-10BT PC Card Ethernet 10BT", 0xf47e6c66, 0x877f9922),
  567. PCMCIA_DEVICE_PROD_ID12("FUJITSU", "LAN Card(FMV-J182)", 0x6ee5a3d8, 0x5baf31db),
  568. PCMCIA_DEVICE_PROD_ID12("FUJITSU", "MBH10308", 0x6ee5a3d8, 0x3f04875e),
  569. PCMCIA_DEVICE_PROD_ID12("FUJITSU TOWA", "LA501", 0xb8451188, 0x12939ba2),
  570. PCMCIA_DEVICE_PROD_ID12("HITACHI", "HT-4840-11", 0xf4f43949, 0x773910f4),
  571. PCMCIA_DEVICE_PROD_ID12("NextComK.K.", "NC5310B Ver1.0 ", 0x8cef4d3a, 0x075fc7b6),
  572. PCMCIA_DEVICE_PROD_ID12("NextComK.K.", "NC5310 Ver1.0 ", 0x8cef4d3a, 0xbccf43e6),
  573. PCMCIA_DEVICE_PROD_ID12("RATOC System Inc.", "10BASE_T CARD R280", 0x85c10e17, 0xd9413666),
  574. PCMCIA_DEVICE_PROD_ID12("TDK", "LAC-CD02x", 0x1eae9475, 0x8fa0ee70),
  575. PCMCIA_DEVICE_PROD_ID12("TDK", "LAC-CF010", 0x1eae9475, 0x7683bc9a),
  576. PCMCIA_DEVICE_PROD_ID1("CONTEC Co.,Ltd.", 0x58d8fee2),
  577. PCMCIA_DEVICE_PROD_ID1("PCMCIA LAN MBH10304 ES", 0x2599f454),
  578. PCMCIA_DEVICE_PROD_ID1("PCMCIA MBH10302", 0x8f4005da),
  579. PCMCIA_DEVICE_PROD_ID1("UBKK,V2.0", 0x90888080),
  580. PCMCIA_PFC_DEVICE_PROD_ID12(0, "TDK", "GlobalNetworker 3410/3412", 0x1eae9475, 0xd9a93bed),
  581. PCMCIA_PFC_DEVICE_PROD_ID12(0, "NEC", "PK-UG-J001" ,0x18df0ba0 ,0x831b1064),
  582. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0x0d0a),
  583. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0x0e0a),
  584. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0032, 0x0e01),
  585. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0032, 0x0a05),
  586. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0032, 0x0b05),
  587. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0032, 0x1101),
  588. PCMCIA_DEVICE_NULL,
  589. };
  590. MODULE_DEVICE_TABLE(pcmcia, fmvj18x_ids);
  591. static struct pcmcia_driver fmvj18x_cs_driver = {
  592. .owner = THIS_MODULE,
  593. .name = "fmvj18x_cs",
  594. .probe = fmvj18x_probe,
  595. .remove = fmvj18x_detach,
  596. .id_table = fmvj18x_ids,
  597. .suspend = fmvj18x_suspend,
  598. .resume = fmvj18x_resume,
  599. };
  600. module_pcmcia_driver(fmvj18x_cs_driver);
  601. /*====================================================================*/
  602. static irqreturn_t fjn_interrupt(int dummy, void *dev_id)
  603. {
  604. struct net_device *dev = dev_id;
  605. struct local_info *lp = netdev_priv(dev);
  606. unsigned int ioaddr;
  607. unsigned short tx_stat, rx_stat;
  608. ioaddr = dev->base_addr;
  609. /* avoid multiple interrupts */
  610. outw(0x0000, ioaddr + TX_INTR);
  611. /* wait for a while */
  612. udelay(1);
  613. /* get status */
  614. tx_stat = inb(ioaddr + TX_STATUS);
  615. rx_stat = inb(ioaddr + RX_STATUS);
  616. /* clear status */
  617. outb(tx_stat, ioaddr + TX_STATUS);
  618. outb(rx_stat, ioaddr + RX_STATUS);
  619. pr_debug("%s: interrupt, rx_status %02x.\n", dev->name, rx_stat);
  620. pr_debug(" tx_status %02x.\n", tx_stat);
  621. if (rx_stat || (inb(ioaddr + RX_MODE) & F_BUF_EMP) == 0) {
  622. /* there is packet(s) in rx buffer */
  623. fjn_rx(dev);
  624. }
  625. if (tx_stat & F_TMT_RDY) {
  626. dev->stats.tx_packets += lp->sent ;
  627. lp->sent = 0 ;
  628. if (lp->tx_queue) {
  629. outb(DO_TX | lp->tx_queue, ioaddr + TX_START);
  630. lp->sent = lp->tx_queue ;
  631. lp->tx_queue = 0;
  632. lp->tx_queue_len = 0;
  633. netif_trans_update(dev);
  634. } else {
  635. lp->tx_started = 0;
  636. }
  637. netif_wake_queue(dev);
  638. }
  639. pr_debug("%s: exiting interrupt,\n", dev->name);
  640. pr_debug(" tx_status %02x, rx_status %02x.\n", tx_stat, rx_stat);
  641. outb(D_TX_INTR, ioaddr + TX_INTR);
  642. outb(D_RX_INTR, ioaddr + RX_INTR);
  643. if (lp->base != NULL) {
  644. /* Ack interrupt for multifunction card */
  645. writeb(0x01, lp->base+0x802);
  646. writeb(0x09, lp->base+0x822);
  647. }
  648. return IRQ_HANDLED;
  649. } /* fjn_interrupt */
  650. /*====================================================================*/
  651. static void fjn_tx_timeout(struct net_device *dev)
  652. {
  653. struct local_info *lp = netdev_priv(dev);
  654. unsigned int ioaddr = dev->base_addr;
  655. netdev_notice(dev, "transmit timed out with status %04x, %s?\n",
  656. htons(inw(ioaddr + TX_STATUS)),
  657. inb(ioaddr + TX_STATUS) & F_TMT_RDY
  658. ? "IRQ conflict" : "network cable problem");
  659. netdev_notice(dev, "timeout registers: %04x %04x %04x "
  660. "%04x %04x %04x %04x %04x.\n",
  661. htons(inw(ioaddr + 0)), htons(inw(ioaddr + 2)),
  662. htons(inw(ioaddr + 4)), htons(inw(ioaddr + 6)),
  663. htons(inw(ioaddr + 8)), htons(inw(ioaddr + 10)),
  664. htons(inw(ioaddr + 12)), htons(inw(ioaddr + 14)));
  665. dev->stats.tx_errors++;
  666. /* ToDo: We should try to restart the adaptor... */
  667. local_irq_disable();
  668. fjn_reset(dev);
  669. lp->tx_started = 0;
  670. lp->tx_queue = 0;
  671. lp->tx_queue_len = 0;
  672. lp->sent = 0;
  673. lp->open_time = jiffies;
  674. local_irq_enable();
  675. netif_wake_queue(dev);
  676. }
  677. static netdev_tx_t fjn_start_xmit(struct sk_buff *skb,
  678. struct net_device *dev)
  679. {
  680. struct local_info *lp = netdev_priv(dev);
  681. unsigned int ioaddr = dev->base_addr;
  682. short length = skb->len;
  683. if (length < ETH_ZLEN)
  684. {
  685. if (skb_padto(skb, ETH_ZLEN))
  686. return NETDEV_TX_OK;
  687. length = ETH_ZLEN;
  688. }
  689. netif_stop_queue(dev);
  690. {
  691. unsigned char *buf = skb->data;
  692. if (length > ETH_FRAME_LEN) {
  693. netdev_notice(dev, "Attempting to send a large packet (%d bytes)\n",
  694. length);
  695. return NETDEV_TX_BUSY;
  696. }
  697. netdev_dbg(dev, "Transmitting a packet of length %lu\n",
  698. (unsigned long)skb->len);
  699. dev->stats.tx_bytes += skb->len;
  700. /* Disable both interrupts. */
  701. outw(0x0000, ioaddr + TX_INTR);
  702. /* wait for a while */
  703. udelay(1);
  704. outw(length, ioaddr + DATAPORT);
  705. outsw(ioaddr + DATAPORT, buf, (length + 1) >> 1);
  706. lp->tx_queue++;
  707. lp->tx_queue_len += ((length+3) & ~1);
  708. if (lp->tx_started == 0) {
  709. /* If the Tx is idle, always trigger a transmit. */
  710. outb(DO_TX | lp->tx_queue, ioaddr + TX_START);
  711. lp->sent = lp->tx_queue ;
  712. lp->tx_queue = 0;
  713. lp->tx_queue_len = 0;
  714. lp->tx_started = 1;
  715. netif_start_queue(dev);
  716. } else {
  717. if( sram_config == 0 ) {
  718. if (lp->tx_queue_len < (4096 - (ETH_FRAME_LEN +2)) )
  719. /* Yes, there is room for one more packet. */
  720. netif_start_queue(dev);
  721. } else {
  722. if (lp->tx_queue_len < (8192 - (ETH_FRAME_LEN +2)) &&
  723. lp->tx_queue < 127 )
  724. /* Yes, there is room for one more packet. */
  725. netif_start_queue(dev);
  726. }
  727. }
  728. /* Re-enable interrupts */
  729. outb(D_TX_INTR, ioaddr + TX_INTR);
  730. outb(D_RX_INTR, ioaddr + RX_INTR);
  731. }
  732. dev_kfree_skb (skb);
  733. return NETDEV_TX_OK;
  734. } /* fjn_start_xmit */
  735. /*====================================================================*/
  736. static void fjn_reset(struct net_device *dev)
  737. {
  738. struct local_info *lp = netdev_priv(dev);
  739. unsigned int ioaddr = dev->base_addr;
  740. int i;
  741. netdev_dbg(dev, "fjn_reset() called\n");
  742. /* Reset controller */
  743. if( sram_config == 0 )
  744. outb(CONFIG0_RST, ioaddr + CONFIG_0);
  745. else
  746. outb(CONFIG0_RST_1, ioaddr + CONFIG_0);
  747. /* Power On chip and select bank 0 */
  748. if (lp->cardtype == MBH10302)
  749. outb(BANK_0, ioaddr + CONFIG_1);
  750. else
  751. outb(BANK_0U, ioaddr + CONFIG_1);
  752. /* Set Tx modes */
  753. outb(D_TX_MODE, ioaddr + TX_MODE);
  754. /* set Rx modes */
  755. outb(ID_MATCHED, ioaddr + RX_MODE);
  756. /* Set hardware address */
  757. for (i = 0; i < 6; i++)
  758. outb(dev->dev_addr[i], ioaddr + NODE_ID + i);
  759. /* (re)initialize the multicast table */
  760. set_rx_mode(dev);
  761. /* Switch to bank 2 (runtime mode) */
  762. if (lp->cardtype == MBH10302)
  763. outb(BANK_2, ioaddr + CONFIG_1);
  764. else
  765. outb(BANK_2U, ioaddr + CONFIG_1);
  766. /* set 16col ctrl bits */
  767. if( lp->cardtype == TDK || lp->cardtype == CONTEC)
  768. outb(TDK_AUTO_MODE, ioaddr + COL_CTRL);
  769. else
  770. outb(AUTO_MODE, ioaddr + COL_CTRL);
  771. /* clear Reserved Regs */
  772. outb(0x00, ioaddr + BMPR12);
  773. outb(0x00, ioaddr + BMPR13);
  774. /* reset Skip packet reg. */
  775. outb(0x01, ioaddr + RX_SKIP);
  776. /* Enable Tx and Rx */
  777. if( sram_config == 0 )
  778. outb(CONFIG0_DFL, ioaddr + CONFIG_0);
  779. else
  780. outb(CONFIG0_DFL_1, ioaddr + CONFIG_0);
  781. /* Init receive pointer ? */
  782. inw(ioaddr + DATAPORT);
  783. inw(ioaddr + DATAPORT);
  784. /* Clear all status */
  785. outb(0xff, ioaddr + TX_STATUS);
  786. outb(0xff, ioaddr + RX_STATUS);
  787. if (lp->cardtype == MBH10302)
  788. outb(INTR_OFF, ioaddr + LAN_CTRL);
  789. /* Turn on Rx interrupts */
  790. outb(D_TX_INTR, ioaddr + TX_INTR);
  791. outb(D_RX_INTR, ioaddr + RX_INTR);
  792. /* Turn on interrupts from LAN card controller */
  793. if (lp->cardtype == MBH10302)
  794. outb(INTR_ON, ioaddr + LAN_CTRL);
  795. } /* fjn_reset */
  796. /*====================================================================*/
  797. static void fjn_rx(struct net_device *dev)
  798. {
  799. unsigned int ioaddr = dev->base_addr;
  800. int boguscount = 10; /* 5 -> 10: by agy 19940922 */
  801. pr_debug("%s: in rx_packet(), rx_status %02x.\n",
  802. dev->name, inb(ioaddr + RX_STATUS));
  803. while ((inb(ioaddr + RX_MODE) & F_BUF_EMP) == 0) {
  804. u_short status = inw(ioaddr + DATAPORT);
  805. netdev_dbg(dev, "Rxing packet mode %02x status %04x.\n",
  806. inb(ioaddr + RX_MODE), status);
  807. #ifndef final_version
  808. if (status == 0) {
  809. outb(F_SKP_PKT, ioaddr + RX_SKIP);
  810. break;
  811. }
  812. #endif
  813. if ((status & 0xF0) != 0x20) { /* There was an error. */
  814. dev->stats.rx_errors++;
  815. if (status & F_LEN_ERR) dev->stats.rx_length_errors++;
  816. if (status & F_ALG_ERR) dev->stats.rx_frame_errors++;
  817. if (status & F_CRC_ERR) dev->stats.rx_crc_errors++;
  818. if (status & F_OVR_FLO) dev->stats.rx_over_errors++;
  819. } else {
  820. u_short pkt_len = inw(ioaddr + DATAPORT);
  821. /* Malloc up new buffer. */
  822. struct sk_buff *skb;
  823. if (pkt_len > 1550) {
  824. netdev_notice(dev, "The FMV-18x claimed a very large packet, size %d\n",
  825. pkt_len);
  826. outb(F_SKP_PKT, ioaddr + RX_SKIP);
  827. dev->stats.rx_errors++;
  828. break;
  829. }
  830. skb = netdev_alloc_skb(dev, pkt_len + 2);
  831. if (skb == NULL) {
  832. outb(F_SKP_PKT, ioaddr + RX_SKIP);
  833. dev->stats.rx_dropped++;
  834. break;
  835. }
  836. skb_reserve(skb, 2);
  837. insw(ioaddr + DATAPORT, skb_put(skb, pkt_len),
  838. (pkt_len + 1) >> 1);
  839. skb->protocol = eth_type_trans(skb, dev);
  840. {
  841. int i;
  842. pr_debug("%s: Rxed packet of length %d: ",
  843. dev->name, pkt_len);
  844. for (i = 0; i < 14; i++)
  845. pr_debug(" %02x", skb->data[i]);
  846. pr_debug(".\n");
  847. }
  848. netif_rx(skb);
  849. dev->stats.rx_packets++;
  850. dev->stats.rx_bytes += pkt_len;
  851. }
  852. if (--boguscount <= 0)
  853. break;
  854. }
  855. /* If any worth-while packets have been received, dev_rint()
  856. has done a netif_wake_queue() for us and will work on them
  857. when we get to the bottom-half routine. */
  858. /*
  859. if (lp->cardtype != TDK) {
  860. int i;
  861. for (i = 0; i < 20; i++) {
  862. if ((inb(ioaddr + RX_MODE) & F_BUF_EMP) == F_BUF_EMP)
  863. break;
  864. (void)inw(ioaddr + DATAPORT); /+ dummy status read +/
  865. outb(F_SKP_PKT, ioaddr + RX_SKIP);
  866. }
  867. if (i > 0)
  868. pr_debug("%s: Exint Rx packet with mode %02x after "
  869. "%d ticks.\n", dev->name, inb(ioaddr + RX_MODE), i);
  870. }
  871. */
  872. } /* fjn_rx */
  873. /*====================================================================*/
  874. static void netdev_get_drvinfo(struct net_device *dev,
  875. struct ethtool_drvinfo *info)
  876. {
  877. strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
  878. strlcpy(info->version, DRV_VERSION, sizeof(info->version));
  879. snprintf(info->bus_info, sizeof(info->bus_info),
  880. "PCMCIA 0x%lx", dev->base_addr);
  881. }
  882. static const struct ethtool_ops netdev_ethtool_ops = {
  883. .get_drvinfo = netdev_get_drvinfo,
  884. };
  885. static int fjn_config(struct net_device *dev, struct ifmap *map){
  886. return 0;
  887. }
  888. static int fjn_open(struct net_device *dev)
  889. {
  890. struct local_info *lp = netdev_priv(dev);
  891. struct pcmcia_device *link = lp->p_dev;
  892. pr_debug("fjn_open('%s').\n", dev->name);
  893. if (!pcmcia_dev_present(link))
  894. return -ENODEV;
  895. link->open++;
  896. fjn_reset(dev);
  897. lp->tx_started = 0;
  898. lp->tx_queue = 0;
  899. lp->tx_queue_len = 0;
  900. lp->open_time = jiffies;
  901. netif_start_queue(dev);
  902. return 0;
  903. } /* fjn_open */
  904. /*====================================================================*/
  905. static int fjn_close(struct net_device *dev)
  906. {
  907. struct local_info *lp = netdev_priv(dev);
  908. struct pcmcia_device *link = lp->p_dev;
  909. unsigned int ioaddr = dev->base_addr;
  910. pr_debug("fjn_close('%s').\n", dev->name);
  911. lp->open_time = 0;
  912. netif_stop_queue(dev);
  913. /* Set configuration register 0 to disable Tx and Rx. */
  914. if( sram_config == 0 )
  915. outb(CONFIG0_RST ,ioaddr + CONFIG_0);
  916. else
  917. outb(CONFIG0_RST_1 ,ioaddr + CONFIG_0);
  918. /* Update the statistics -- ToDo. */
  919. /* Power-down the chip. Green, green, green! */
  920. outb(CHIP_OFF ,ioaddr + CONFIG_1);
  921. /* Set the ethernet adaptor disable IRQ */
  922. if (lp->cardtype == MBH10302)
  923. outb(INTR_OFF, ioaddr + LAN_CTRL);
  924. link->open--;
  925. return 0;
  926. } /* fjn_close */
  927. /*====================================================================*/
  928. /*
  929. Set the multicast/promiscuous mode for this adaptor.
  930. */
  931. static void set_rx_mode(struct net_device *dev)
  932. {
  933. unsigned int ioaddr = dev->base_addr;
  934. u_char mc_filter[8]; /* Multicast hash filter */
  935. u_long flags;
  936. int i;
  937. int saved_bank;
  938. int saved_config_0 = inb(ioaddr + CONFIG_0);
  939. local_irq_save(flags);
  940. /* Disable Tx and Rx */
  941. if (sram_config == 0)
  942. outb(CONFIG0_RST, ioaddr + CONFIG_0);
  943. else
  944. outb(CONFIG0_RST_1, ioaddr + CONFIG_0);
  945. if (dev->flags & IFF_PROMISC) {
  946. memset(mc_filter, 0xff, sizeof(mc_filter));
  947. outb(3, ioaddr + RX_MODE); /* Enable promiscuous mode */
  948. } else if (netdev_mc_count(dev) > MC_FILTERBREAK ||
  949. (dev->flags & IFF_ALLMULTI)) {
  950. /* Too many to filter perfectly -- accept all multicasts. */
  951. memset(mc_filter, 0xff, sizeof(mc_filter));
  952. outb(2, ioaddr + RX_MODE); /* Use normal mode. */
  953. } else if (netdev_mc_empty(dev)) {
  954. memset(mc_filter, 0x00, sizeof(mc_filter));
  955. outb(1, ioaddr + RX_MODE); /* Ignore almost all multicasts. */
  956. } else {
  957. struct netdev_hw_addr *ha;
  958. memset(mc_filter, 0, sizeof(mc_filter));
  959. netdev_for_each_mc_addr(ha, dev) {
  960. unsigned int bit = ether_crc_le(ETH_ALEN, ha->addr) >> 26;
  961. mc_filter[bit >> 3] |= (1 << (bit & 7));
  962. }
  963. outb(2, ioaddr + RX_MODE); /* Use normal mode. */
  964. }
  965. /* Switch to bank 1 and set the multicast table. */
  966. saved_bank = inb(ioaddr + CONFIG_1);
  967. outb(0xe4, ioaddr + CONFIG_1);
  968. for (i = 0; i < 8; i++)
  969. outb(mc_filter[i], ioaddr + MAR_ADR + i);
  970. outb(saved_bank, ioaddr + CONFIG_1);
  971. outb(saved_config_0, ioaddr + CONFIG_0);
  972. local_irq_restore(flags);
  973. }