fmvj18x_cs.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  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 <asm/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_change_mtu = eth_change_mtu,
  188. .ndo_set_mac_address = eth_mac_addr,
  189. .ndo_validate_addr = eth_validate_addr,
  190. };
  191. static int fmvj18x_probe(struct pcmcia_device *link)
  192. {
  193. struct local_info *lp;
  194. struct net_device *dev;
  195. dev_dbg(&link->dev, "fmvj18x_attach()\n");
  196. /* Make up a FMVJ18x specific data structure */
  197. dev = alloc_etherdev(sizeof(struct local_info));
  198. if (!dev)
  199. return -ENOMEM;
  200. lp = netdev_priv(dev);
  201. link->priv = dev;
  202. lp->p_dev = link;
  203. lp->base = NULL;
  204. /* The io structure describes IO port mapping */
  205. link->resource[0]->end = 32;
  206. link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
  207. /* General socket configuration */
  208. link->config_flags |= CONF_ENABLE_IRQ;
  209. dev->netdev_ops = &fjn_netdev_ops;
  210. dev->watchdog_timeo = TX_TIMEOUT;
  211. dev->ethtool_ops = &netdev_ethtool_ops;
  212. return fmvj18x_config(link);
  213. } /* fmvj18x_attach */
  214. /*====================================================================*/
  215. static void fmvj18x_detach(struct pcmcia_device *link)
  216. {
  217. struct net_device *dev = link->priv;
  218. dev_dbg(&link->dev, "fmvj18x_detach\n");
  219. unregister_netdev(dev);
  220. fmvj18x_release(link);
  221. free_netdev(dev);
  222. } /* fmvj18x_detach */
  223. /*====================================================================*/
  224. static int mfc_try_io_port(struct pcmcia_device *link)
  225. {
  226. int i, ret;
  227. static const unsigned int serial_base[5] =
  228. { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
  229. for (i = 0; i < 5; i++) {
  230. link->resource[1]->start = serial_base[i];
  231. link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
  232. if (link->resource[1]->start == 0) {
  233. link->resource[1]->end = 0;
  234. pr_notice("out of resource for serial\n");
  235. }
  236. ret = pcmcia_request_io(link);
  237. if (ret == 0)
  238. return ret;
  239. }
  240. return ret;
  241. }
  242. static int ungermann_try_io_port(struct pcmcia_device *link)
  243. {
  244. int ret;
  245. unsigned int ioaddr;
  246. /*
  247. Ungermann-Bass Access/CARD accepts 0x300,0x320,0x340,0x360
  248. 0x380,0x3c0 only for ioport.
  249. */
  250. for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) {
  251. link->resource[0]->start = ioaddr;
  252. ret = pcmcia_request_io(link);
  253. if (ret == 0) {
  254. /* calculate ConfigIndex value */
  255. link->config_index =
  256. ((link->resource[0]->start & 0x0f0) >> 3) | 0x22;
  257. return ret;
  258. }
  259. }
  260. return ret; /* RequestIO failed */
  261. }
  262. static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
  263. {
  264. return 0; /* strange, but that's what the code did already before... */
  265. }
  266. static int fmvj18x_config(struct pcmcia_device *link)
  267. {
  268. struct net_device *dev = link->priv;
  269. struct local_info *lp = netdev_priv(dev);
  270. int i, ret;
  271. unsigned int ioaddr;
  272. enum cardtype cardtype;
  273. char *card_name = "unknown";
  274. u8 *buf;
  275. size_t len;
  276. u_char buggybuf[32];
  277. dev_dbg(&link->dev, "fmvj18x_config\n");
  278. link->io_lines = 5;
  279. len = pcmcia_get_tuple(link, CISTPL_FUNCE, &buf);
  280. kfree(buf);
  281. if (len) {
  282. /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */
  283. ret = pcmcia_loop_config(link, fmvj18x_ioprobe, NULL);
  284. if (ret != 0)
  285. goto failed;
  286. switch (link->manf_id) {
  287. case MANFID_TDK:
  288. cardtype = TDK;
  289. if (link->card_id == PRODID_TDK_GN3410 ||
  290. link->card_id == PRODID_TDK_NP9610 ||
  291. link->card_id == PRODID_TDK_MN3200) {
  292. /* MultiFunction Card */
  293. link->config_base = 0x800;
  294. link->config_index = 0x47;
  295. link->resource[1]->end = 8;
  296. }
  297. break;
  298. case MANFID_NEC:
  299. cardtype = NEC; /* MultiFunction Card */
  300. link->config_base = 0x800;
  301. link->config_index = 0x47;
  302. link->resource[1]->end = 8;
  303. break;
  304. case MANFID_KME:
  305. cardtype = KME; /* MultiFunction Card */
  306. link->config_base = 0x800;
  307. link->config_index = 0x47;
  308. link->resource[1]->end = 8;
  309. break;
  310. case MANFID_CONTEC:
  311. cardtype = CONTEC;
  312. break;
  313. case MANFID_FUJITSU:
  314. if (link->config_base == 0x0fe0)
  315. cardtype = MBH10302;
  316. else if (link->card_id == PRODID_FUJITSU_MBH10302)
  317. /* RATOC REX-5588/9822/4886's PRODID are 0004(=MBH10302),
  318. but these are MBH10304 based card. */
  319. cardtype = MBH10304;
  320. else if (link->card_id == PRODID_FUJITSU_MBH10304)
  321. cardtype = MBH10304;
  322. else
  323. cardtype = LA501;
  324. break;
  325. default:
  326. cardtype = MBH10304;
  327. }
  328. } else {
  329. /* old type card */
  330. switch (link->manf_id) {
  331. case MANFID_FUJITSU:
  332. if (link->card_id == PRODID_FUJITSU_MBH10304) {
  333. cardtype = XXX10304; /* MBH10304 with buggy CIS */
  334. link->config_index = 0x20;
  335. } else {
  336. cardtype = MBH10302; /* NextCom NC5310, etc. */
  337. link->config_index = 1;
  338. }
  339. break;
  340. case MANFID_UNGERMANN:
  341. cardtype = UNGERMANN;
  342. break;
  343. default:
  344. cardtype = MBH10302;
  345. link->config_index = 1;
  346. }
  347. }
  348. if (link->resource[1]->end != 0) {
  349. ret = mfc_try_io_port(link);
  350. if (ret != 0) goto failed;
  351. } else if (cardtype == UNGERMANN) {
  352. ret = ungermann_try_io_port(link);
  353. if (ret != 0) goto failed;
  354. } else {
  355. ret = pcmcia_request_io(link);
  356. if (ret)
  357. goto failed;
  358. }
  359. ret = pcmcia_request_irq(link, fjn_interrupt);
  360. if (ret)
  361. goto failed;
  362. ret = pcmcia_enable_device(link);
  363. if (ret)
  364. goto failed;
  365. dev->irq = link->irq;
  366. dev->base_addr = link->resource[0]->start;
  367. if (resource_size(link->resource[1]) != 0) {
  368. ret = fmvj18x_setup_mfc(link);
  369. if (ret != 0) goto failed;
  370. }
  371. ioaddr = dev->base_addr;
  372. /* Reset controller */
  373. if (sram_config == 0)
  374. outb(CONFIG0_RST, ioaddr + CONFIG_0);
  375. else
  376. outb(CONFIG0_RST_1, ioaddr + CONFIG_0);
  377. /* Power On chip and select bank 0 */
  378. if (cardtype == MBH10302)
  379. outb(BANK_0, ioaddr + CONFIG_1);
  380. else
  381. outb(BANK_0U, ioaddr + CONFIG_1);
  382. /* Set hardware address */
  383. switch (cardtype) {
  384. case MBH10304:
  385. case TDK:
  386. case LA501:
  387. case CONTEC:
  388. case NEC:
  389. case KME:
  390. if (cardtype == MBH10304) {
  391. card_name = "FMV-J182";
  392. len = pcmcia_get_tuple(link, CISTPL_FUNCE, &buf);
  393. if (len < 11) {
  394. kfree(buf);
  395. goto failed;
  396. }
  397. /* Read MACID from CIS */
  398. for (i = 0; i < 6; i++)
  399. dev->dev_addr[i] = buf[i + 5];
  400. kfree(buf);
  401. } else {
  402. if (pcmcia_get_mac_from_cis(link, dev))
  403. goto failed;
  404. if( cardtype == TDK ) {
  405. card_name = "TDK LAK-CD021";
  406. } else if( cardtype == LA501 ) {
  407. card_name = "LA501";
  408. } else if( cardtype == NEC ) {
  409. card_name = "PK-UG-J001";
  410. } else if( cardtype == KME ) {
  411. card_name = "Panasonic";
  412. } else {
  413. card_name = "C-NET(PC)C";
  414. }
  415. }
  416. break;
  417. case UNGERMANN:
  418. /* Read MACID from register */
  419. for (i = 0; i < 6; i++)
  420. dev->dev_addr[i] = inb(ioaddr + UNGERMANN_MAC_ID + i);
  421. card_name = "Access/CARD";
  422. break;
  423. case XXX10304:
  424. /* Read MACID from Buggy CIS */
  425. if (fmvj18x_get_hwinfo(link, buggybuf) == -1) {
  426. pr_notice("unable to read hardware net address\n");
  427. goto failed;
  428. }
  429. for (i = 0 ; i < 6; i++) {
  430. dev->dev_addr[i] = buggybuf[i];
  431. }
  432. card_name = "FMV-J182";
  433. break;
  434. case MBH10302:
  435. default:
  436. /* Read MACID from register */
  437. for (i = 0; i < 6; i++)
  438. dev->dev_addr[i] = inb(ioaddr + MAC_ID + i);
  439. card_name = "FMV-J181";
  440. break;
  441. }
  442. lp->cardtype = cardtype;
  443. SET_NETDEV_DEV(dev, &link->dev);
  444. if (register_netdev(dev) != 0) {
  445. pr_notice("register_netdev() failed\n");
  446. goto failed;
  447. }
  448. /* print current configuration */
  449. netdev_info(dev, "%s, sram %s, port %#3lx, irq %d, hw_addr %pM\n",
  450. card_name, sram_config == 0 ? "4K TX*2" : "8K TX*2",
  451. dev->base_addr, dev->irq, dev->dev_addr);
  452. return 0;
  453. failed:
  454. fmvj18x_release(link);
  455. return -ENODEV;
  456. } /* fmvj18x_config */
  457. /*====================================================================*/
  458. static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
  459. {
  460. u_char __iomem *base;
  461. int i, j;
  462. /* Allocate a small memory window */
  463. link->resource[2]->flags |= WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
  464. link->resource[2]->start = 0; link->resource[2]->end = 0;
  465. i = pcmcia_request_window(link, link->resource[2], 0);
  466. if (i != 0)
  467. return -1;
  468. base = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
  469. pcmcia_map_mem_page(link, link->resource[2], 0);
  470. /*
  471. * MBH10304 CISTPL_FUNCE_LAN_NODE_ID format
  472. * 22 0d xx xx xx 04 06 yy yy yy yy yy yy ff
  473. * 'xx' is garbage.
  474. * 'yy' is MAC address.
  475. */
  476. for (i = 0; i < 0x200; i++) {
  477. if (readb(base+i*2) == 0x22) {
  478. if (readb(base+(i-1)*2) == 0xff &&
  479. readb(base+(i+5)*2) == 0x04 &&
  480. readb(base+(i+6)*2) == 0x06 &&
  481. readb(base+(i+13)*2) == 0xff)
  482. break;
  483. }
  484. }
  485. if (i != 0x200) {
  486. for (j = 0 ; j < 6; j++,i++) {
  487. node_id[j] = readb(base+(i+7)*2);
  488. }
  489. }
  490. iounmap(base);
  491. j = pcmcia_release_window(link, link->resource[2]);
  492. return (i != 0x200) ? 0 : -1;
  493. } /* fmvj18x_get_hwinfo */
  494. /*====================================================================*/
  495. static int fmvj18x_setup_mfc(struct pcmcia_device *link)
  496. {
  497. int i;
  498. struct net_device *dev = link->priv;
  499. unsigned int ioaddr;
  500. struct local_info *lp = netdev_priv(dev);
  501. /* Allocate a small memory window */
  502. link->resource[3]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
  503. link->resource[3]->start = link->resource[3]->end = 0;
  504. i = pcmcia_request_window(link, link->resource[3], 0);
  505. if (i != 0)
  506. return -1;
  507. lp->base = ioremap(link->resource[3]->start,
  508. resource_size(link->resource[3]));
  509. if (lp->base == NULL) {
  510. netdev_notice(dev, "ioremap failed\n");
  511. return -1;
  512. }
  513. i = pcmcia_map_mem_page(link, link->resource[3], 0);
  514. if (i != 0) {
  515. iounmap(lp->base);
  516. lp->base = NULL;
  517. return -1;
  518. }
  519. ioaddr = dev->base_addr;
  520. writeb(0x47, lp->base+0x800); /* Config Option Register of LAN */
  521. writeb(0x0, lp->base+0x802); /* Config and Status Register */
  522. writeb(ioaddr & 0xff, lp->base+0x80a); /* I/O Base(Low) of LAN */
  523. writeb((ioaddr >> 8) & 0xff, lp->base+0x80c); /* I/O Base(High) of LAN */
  524. writeb(0x45, lp->base+0x820); /* Config Option Register of Modem */
  525. writeb(0x8, lp->base+0x822); /* Config and Status Register */
  526. return 0;
  527. }
  528. /*====================================================================*/
  529. static void fmvj18x_release(struct pcmcia_device *link)
  530. {
  531. struct net_device *dev = link->priv;
  532. struct local_info *lp = netdev_priv(dev);
  533. u_char __iomem *tmp;
  534. dev_dbg(&link->dev, "fmvj18x_release\n");
  535. if (lp->base != NULL) {
  536. tmp = lp->base;
  537. lp->base = NULL; /* set NULL before iounmap */
  538. iounmap(tmp);
  539. }
  540. pcmcia_disable_device(link);
  541. }
  542. static int fmvj18x_suspend(struct pcmcia_device *link)
  543. {
  544. struct net_device *dev = link->priv;
  545. if (link->open)
  546. netif_device_detach(dev);
  547. return 0;
  548. }
  549. static int fmvj18x_resume(struct pcmcia_device *link)
  550. {
  551. struct net_device *dev = link->priv;
  552. if (link->open) {
  553. fjn_reset(dev);
  554. netif_device_attach(dev);
  555. }
  556. return 0;
  557. }
  558. /*====================================================================*/
  559. static const struct pcmcia_device_id fmvj18x_ids[] = {
  560. PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004),
  561. PCMCIA_DEVICE_PROD_ID12("EAGLE Technology", "NE200 ETHERNET LAN MBH10302 04", 0x528c88c4, 0x74f91e59),
  562. PCMCIA_DEVICE_PROD_ID12("Eiger Labs,Inc", "EPX-10BT PC Card Ethernet 10BT", 0x53af556e, 0x877f9922),
  563. PCMCIA_DEVICE_PROD_ID12("Eiger labs,Inc.", "EPX-10BT PC Card Ethernet 10BT", 0xf47e6c66, 0x877f9922),
  564. PCMCIA_DEVICE_PROD_ID12("FUJITSU", "LAN Card(FMV-J182)", 0x6ee5a3d8, 0x5baf31db),
  565. PCMCIA_DEVICE_PROD_ID12("FUJITSU", "MBH10308", 0x6ee5a3d8, 0x3f04875e),
  566. PCMCIA_DEVICE_PROD_ID12("FUJITSU TOWA", "LA501", 0xb8451188, 0x12939ba2),
  567. PCMCIA_DEVICE_PROD_ID12("HITACHI", "HT-4840-11", 0xf4f43949, 0x773910f4),
  568. PCMCIA_DEVICE_PROD_ID12("NextComK.K.", "NC5310B Ver1.0 ", 0x8cef4d3a, 0x075fc7b6),
  569. PCMCIA_DEVICE_PROD_ID12("NextComK.K.", "NC5310 Ver1.0 ", 0x8cef4d3a, 0xbccf43e6),
  570. PCMCIA_DEVICE_PROD_ID12("RATOC System Inc.", "10BASE_T CARD R280", 0x85c10e17, 0xd9413666),
  571. PCMCIA_DEVICE_PROD_ID12("TDK", "LAC-CD02x", 0x1eae9475, 0x8fa0ee70),
  572. PCMCIA_DEVICE_PROD_ID12("TDK", "LAC-CF010", 0x1eae9475, 0x7683bc9a),
  573. PCMCIA_DEVICE_PROD_ID1("CONTEC Co.,Ltd.", 0x58d8fee2),
  574. PCMCIA_DEVICE_PROD_ID1("PCMCIA LAN MBH10304 ES", 0x2599f454),
  575. PCMCIA_DEVICE_PROD_ID1("PCMCIA MBH10302", 0x8f4005da),
  576. PCMCIA_DEVICE_PROD_ID1("UBKK,V2.0", 0x90888080),
  577. PCMCIA_PFC_DEVICE_PROD_ID12(0, "TDK", "GlobalNetworker 3410/3412", 0x1eae9475, 0xd9a93bed),
  578. PCMCIA_PFC_DEVICE_PROD_ID12(0, "NEC", "PK-UG-J001" ,0x18df0ba0 ,0x831b1064),
  579. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0x0d0a),
  580. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0x0e0a),
  581. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0032, 0x0e01),
  582. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0032, 0x0a05),
  583. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0032, 0x0b05),
  584. PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0032, 0x1101),
  585. PCMCIA_DEVICE_NULL,
  586. };
  587. MODULE_DEVICE_TABLE(pcmcia, fmvj18x_ids);
  588. static struct pcmcia_driver fmvj18x_cs_driver = {
  589. .owner = THIS_MODULE,
  590. .name = "fmvj18x_cs",
  591. .probe = fmvj18x_probe,
  592. .remove = fmvj18x_detach,
  593. .id_table = fmvj18x_ids,
  594. .suspend = fmvj18x_suspend,
  595. .resume = fmvj18x_resume,
  596. };
  597. module_pcmcia_driver(fmvj18x_cs_driver);
  598. /*====================================================================*/
  599. static irqreturn_t fjn_interrupt(int dummy, void *dev_id)
  600. {
  601. struct net_device *dev = dev_id;
  602. struct local_info *lp = netdev_priv(dev);
  603. unsigned int ioaddr;
  604. unsigned short tx_stat, rx_stat;
  605. ioaddr = dev->base_addr;
  606. /* avoid multiple interrupts */
  607. outw(0x0000, ioaddr + TX_INTR);
  608. /* wait for a while */
  609. udelay(1);
  610. /* get status */
  611. tx_stat = inb(ioaddr + TX_STATUS);
  612. rx_stat = inb(ioaddr + RX_STATUS);
  613. /* clear status */
  614. outb(tx_stat, ioaddr + TX_STATUS);
  615. outb(rx_stat, ioaddr + RX_STATUS);
  616. pr_debug("%s: interrupt, rx_status %02x.\n", dev->name, rx_stat);
  617. pr_debug(" tx_status %02x.\n", tx_stat);
  618. if (rx_stat || (inb(ioaddr + RX_MODE) & F_BUF_EMP) == 0) {
  619. /* there is packet(s) in rx buffer */
  620. fjn_rx(dev);
  621. }
  622. if (tx_stat & F_TMT_RDY) {
  623. dev->stats.tx_packets += lp->sent ;
  624. lp->sent = 0 ;
  625. if (lp->tx_queue) {
  626. outb(DO_TX | lp->tx_queue, ioaddr + TX_START);
  627. lp->sent = lp->tx_queue ;
  628. lp->tx_queue = 0;
  629. lp->tx_queue_len = 0;
  630. netif_trans_update(dev);
  631. } else {
  632. lp->tx_started = 0;
  633. }
  634. netif_wake_queue(dev);
  635. }
  636. pr_debug("%s: exiting interrupt,\n", dev->name);
  637. pr_debug(" tx_status %02x, rx_status %02x.\n", tx_stat, rx_stat);
  638. outb(D_TX_INTR, ioaddr + TX_INTR);
  639. outb(D_RX_INTR, ioaddr + RX_INTR);
  640. if (lp->base != NULL) {
  641. /* Ack interrupt for multifunction card */
  642. writeb(0x01, lp->base+0x802);
  643. writeb(0x09, lp->base+0x822);
  644. }
  645. return IRQ_HANDLED;
  646. } /* fjn_interrupt */
  647. /*====================================================================*/
  648. static void fjn_tx_timeout(struct net_device *dev)
  649. {
  650. struct local_info *lp = netdev_priv(dev);
  651. unsigned int ioaddr = dev->base_addr;
  652. netdev_notice(dev, "transmit timed out with status %04x, %s?\n",
  653. htons(inw(ioaddr + TX_STATUS)),
  654. inb(ioaddr + TX_STATUS) & F_TMT_RDY
  655. ? "IRQ conflict" : "network cable problem");
  656. netdev_notice(dev, "timeout registers: %04x %04x %04x "
  657. "%04x %04x %04x %04x %04x.\n",
  658. htons(inw(ioaddr + 0)), htons(inw(ioaddr + 2)),
  659. htons(inw(ioaddr + 4)), htons(inw(ioaddr + 6)),
  660. htons(inw(ioaddr + 8)), htons(inw(ioaddr + 10)),
  661. htons(inw(ioaddr + 12)), htons(inw(ioaddr + 14)));
  662. dev->stats.tx_errors++;
  663. /* ToDo: We should try to restart the adaptor... */
  664. local_irq_disable();
  665. fjn_reset(dev);
  666. lp->tx_started = 0;
  667. lp->tx_queue = 0;
  668. lp->tx_queue_len = 0;
  669. lp->sent = 0;
  670. lp->open_time = jiffies;
  671. local_irq_enable();
  672. netif_wake_queue(dev);
  673. }
  674. static netdev_tx_t fjn_start_xmit(struct sk_buff *skb,
  675. struct net_device *dev)
  676. {
  677. struct local_info *lp = netdev_priv(dev);
  678. unsigned int ioaddr = dev->base_addr;
  679. short length = skb->len;
  680. if (length < ETH_ZLEN)
  681. {
  682. if (skb_padto(skb, ETH_ZLEN))
  683. return NETDEV_TX_OK;
  684. length = ETH_ZLEN;
  685. }
  686. netif_stop_queue(dev);
  687. {
  688. unsigned char *buf = skb->data;
  689. if (length > ETH_FRAME_LEN) {
  690. netdev_notice(dev, "Attempting to send a large packet (%d bytes)\n",
  691. length);
  692. return NETDEV_TX_BUSY;
  693. }
  694. netdev_dbg(dev, "Transmitting a packet of length %lu\n",
  695. (unsigned long)skb->len);
  696. dev->stats.tx_bytes += skb->len;
  697. /* Disable both interrupts. */
  698. outw(0x0000, ioaddr + TX_INTR);
  699. /* wait for a while */
  700. udelay(1);
  701. outw(length, ioaddr + DATAPORT);
  702. outsw(ioaddr + DATAPORT, buf, (length + 1) >> 1);
  703. lp->tx_queue++;
  704. lp->tx_queue_len += ((length+3) & ~1);
  705. if (lp->tx_started == 0) {
  706. /* If the Tx is idle, always trigger a transmit. */
  707. outb(DO_TX | lp->tx_queue, ioaddr + TX_START);
  708. lp->sent = lp->tx_queue ;
  709. lp->tx_queue = 0;
  710. lp->tx_queue_len = 0;
  711. lp->tx_started = 1;
  712. netif_start_queue(dev);
  713. } else {
  714. if( sram_config == 0 ) {
  715. if (lp->tx_queue_len < (4096 - (ETH_FRAME_LEN +2)) )
  716. /* Yes, there is room for one more packet. */
  717. netif_start_queue(dev);
  718. } else {
  719. if (lp->tx_queue_len < (8192 - (ETH_FRAME_LEN +2)) &&
  720. lp->tx_queue < 127 )
  721. /* Yes, there is room for one more packet. */
  722. netif_start_queue(dev);
  723. }
  724. }
  725. /* Re-enable interrupts */
  726. outb(D_TX_INTR, ioaddr + TX_INTR);
  727. outb(D_RX_INTR, ioaddr + RX_INTR);
  728. }
  729. dev_kfree_skb (skb);
  730. return NETDEV_TX_OK;
  731. } /* fjn_start_xmit */
  732. /*====================================================================*/
  733. static void fjn_reset(struct net_device *dev)
  734. {
  735. struct local_info *lp = netdev_priv(dev);
  736. unsigned int ioaddr = dev->base_addr;
  737. int i;
  738. netdev_dbg(dev, "fjn_reset() called\n");
  739. /* Reset controller */
  740. if( sram_config == 0 )
  741. outb(CONFIG0_RST, ioaddr + CONFIG_0);
  742. else
  743. outb(CONFIG0_RST_1, ioaddr + CONFIG_0);
  744. /* Power On chip and select bank 0 */
  745. if (lp->cardtype == MBH10302)
  746. outb(BANK_0, ioaddr + CONFIG_1);
  747. else
  748. outb(BANK_0U, ioaddr + CONFIG_1);
  749. /* Set Tx modes */
  750. outb(D_TX_MODE, ioaddr + TX_MODE);
  751. /* set Rx modes */
  752. outb(ID_MATCHED, ioaddr + RX_MODE);
  753. /* Set hardware address */
  754. for (i = 0; i < 6; i++)
  755. outb(dev->dev_addr[i], ioaddr + NODE_ID + i);
  756. /* (re)initialize the multicast table */
  757. set_rx_mode(dev);
  758. /* Switch to bank 2 (runtime mode) */
  759. if (lp->cardtype == MBH10302)
  760. outb(BANK_2, ioaddr + CONFIG_1);
  761. else
  762. outb(BANK_2U, ioaddr + CONFIG_1);
  763. /* set 16col ctrl bits */
  764. if( lp->cardtype == TDK || lp->cardtype == CONTEC)
  765. outb(TDK_AUTO_MODE, ioaddr + COL_CTRL);
  766. else
  767. outb(AUTO_MODE, ioaddr + COL_CTRL);
  768. /* clear Reserved Regs */
  769. outb(0x00, ioaddr + BMPR12);
  770. outb(0x00, ioaddr + BMPR13);
  771. /* reset Skip packet reg. */
  772. outb(0x01, ioaddr + RX_SKIP);
  773. /* Enable Tx and Rx */
  774. if( sram_config == 0 )
  775. outb(CONFIG0_DFL, ioaddr + CONFIG_0);
  776. else
  777. outb(CONFIG0_DFL_1, ioaddr + CONFIG_0);
  778. /* Init receive pointer ? */
  779. inw(ioaddr + DATAPORT);
  780. inw(ioaddr + DATAPORT);
  781. /* Clear all status */
  782. outb(0xff, ioaddr + TX_STATUS);
  783. outb(0xff, ioaddr + RX_STATUS);
  784. if (lp->cardtype == MBH10302)
  785. outb(INTR_OFF, ioaddr + LAN_CTRL);
  786. /* Turn on Rx interrupts */
  787. outb(D_TX_INTR, ioaddr + TX_INTR);
  788. outb(D_RX_INTR, ioaddr + RX_INTR);
  789. /* Turn on interrupts from LAN card controller */
  790. if (lp->cardtype == MBH10302)
  791. outb(INTR_ON, ioaddr + LAN_CTRL);
  792. } /* fjn_reset */
  793. /*====================================================================*/
  794. static void fjn_rx(struct net_device *dev)
  795. {
  796. unsigned int ioaddr = dev->base_addr;
  797. int boguscount = 10; /* 5 -> 10: by agy 19940922 */
  798. pr_debug("%s: in rx_packet(), rx_status %02x.\n",
  799. dev->name, inb(ioaddr + RX_STATUS));
  800. while ((inb(ioaddr + RX_MODE) & F_BUF_EMP) == 0) {
  801. u_short status = inw(ioaddr + DATAPORT);
  802. netdev_dbg(dev, "Rxing packet mode %02x status %04x.\n",
  803. inb(ioaddr + RX_MODE), status);
  804. #ifndef final_version
  805. if (status == 0) {
  806. outb(F_SKP_PKT, ioaddr + RX_SKIP);
  807. break;
  808. }
  809. #endif
  810. if ((status & 0xF0) != 0x20) { /* There was an error. */
  811. dev->stats.rx_errors++;
  812. if (status & F_LEN_ERR) dev->stats.rx_length_errors++;
  813. if (status & F_ALG_ERR) dev->stats.rx_frame_errors++;
  814. if (status & F_CRC_ERR) dev->stats.rx_crc_errors++;
  815. if (status & F_OVR_FLO) dev->stats.rx_over_errors++;
  816. } else {
  817. u_short pkt_len = inw(ioaddr + DATAPORT);
  818. /* Malloc up new buffer. */
  819. struct sk_buff *skb;
  820. if (pkt_len > 1550) {
  821. netdev_notice(dev, "The FMV-18x claimed a very large packet, size %d\n",
  822. pkt_len);
  823. outb(F_SKP_PKT, ioaddr + RX_SKIP);
  824. dev->stats.rx_errors++;
  825. break;
  826. }
  827. skb = netdev_alloc_skb(dev, pkt_len + 2);
  828. if (skb == NULL) {
  829. outb(F_SKP_PKT, ioaddr + RX_SKIP);
  830. dev->stats.rx_dropped++;
  831. break;
  832. }
  833. skb_reserve(skb, 2);
  834. insw(ioaddr + DATAPORT, skb_put(skb, pkt_len),
  835. (pkt_len + 1) >> 1);
  836. skb->protocol = eth_type_trans(skb, dev);
  837. {
  838. int i;
  839. pr_debug("%s: Rxed packet of length %d: ",
  840. dev->name, pkt_len);
  841. for (i = 0; i < 14; i++)
  842. pr_debug(" %02x", skb->data[i]);
  843. pr_debug(".\n");
  844. }
  845. netif_rx(skb);
  846. dev->stats.rx_packets++;
  847. dev->stats.rx_bytes += pkt_len;
  848. }
  849. if (--boguscount <= 0)
  850. break;
  851. }
  852. /* If any worth-while packets have been received, dev_rint()
  853. has done a netif_wake_queue() for us and will work on them
  854. when we get to the bottom-half routine. */
  855. /*
  856. if (lp->cardtype != TDK) {
  857. int i;
  858. for (i = 0; i < 20; i++) {
  859. if ((inb(ioaddr + RX_MODE) & F_BUF_EMP) == F_BUF_EMP)
  860. break;
  861. (void)inw(ioaddr + DATAPORT); /+ dummy status read +/
  862. outb(F_SKP_PKT, ioaddr + RX_SKIP);
  863. }
  864. if (i > 0)
  865. pr_debug("%s: Exint Rx packet with mode %02x after "
  866. "%d ticks.\n", dev->name, inb(ioaddr + RX_MODE), i);
  867. }
  868. */
  869. } /* fjn_rx */
  870. /*====================================================================*/
  871. static void netdev_get_drvinfo(struct net_device *dev,
  872. struct ethtool_drvinfo *info)
  873. {
  874. strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
  875. strlcpy(info->version, DRV_VERSION, sizeof(info->version));
  876. snprintf(info->bus_info, sizeof(info->bus_info),
  877. "PCMCIA 0x%lx", dev->base_addr);
  878. }
  879. static const struct ethtool_ops netdev_ethtool_ops = {
  880. .get_drvinfo = netdev_get_drvinfo,
  881. };
  882. static int fjn_config(struct net_device *dev, struct ifmap *map){
  883. return 0;
  884. }
  885. static int fjn_open(struct net_device *dev)
  886. {
  887. struct local_info *lp = netdev_priv(dev);
  888. struct pcmcia_device *link = lp->p_dev;
  889. pr_debug("fjn_open('%s').\n", dev->name);
  890. if (!pcmcia_dev_present(link))
  891. return -ENODEV;
  892. link->open++;
  893. fjn_reset(dev);
  894. lp->tx_started = 0;
  895. lp->tx_queue = 0;
  896. lp->tx_queue_len = 0;
  897. lp->open_time = jiffies;
  898. netif_start_queue(dev);
  899. return 0;
  900. } /* fjn_open */
  901. /*====================================================================*/
  902. static int fjn_close(struct net_device *dev)
  903. {
  904. struct local_info *lp = netdev_priv(dev);
  905. struct pcmcia_device *link = lp->p_dev;
  906. unsigned int ioaddr = dev->base_addr;
  907. pr_debug("fjn_close('%s').\n", dev->name);
  908. lp->open_time = 0;
  909. netif_stop_queue(dev);
  910. /* Set configuration register 0 to disable Tx and Rx. */
  911. if( sram_config == 0 )
  912. outb(CONFIG0_RST ,ioaddr + CONFIG_0);
  913. else
  914. outb(CONFIG0_RST_1 ,ioaddr + CONFIG_0);
  915. /* Update the statistics -- ToDo. */
  916. /* Power-down the chip. Green, green, green! */
  917. outb(CHIP_OFF ,ioaddr + CONFIG_1);
  918. /* Set the ethernet adaptor disable IRQ */
  919. if (lp->cardtype == MBH10302)
  920. outb(INTR_OFF, ioaddr + LAN_CTRL);
  921. link->open--;
  922. return 0;
  923. } /* fjn_close */
  924. /*====================================================================*/
  925. /*
  926. Set the multicast/promiscuous mode for this adaptor.
  927. */
  928. static void set_rx_mode(struct net_device *dev)
  929. {
  930. unsigned int ioaddr = dev->base_addr;
  931. u_char mc_filter[8]; /* Multicast hash filter */
  932. u_long flags;
  933. int i;
  934. int saved_bank;
  935. int saved_config_0 = inb(ioaddr + CONFIG_0);
  936. local_irq_save(flags);
  937. /* Disable Tx and Rx */
  938. if (sram_config == 0)
  939. outb(CONFIG0_RST, ioaddr + CONFIG_0);
  940. else
  941. outb(CONFIG0_RST_1, ioaddr + CONFIG_0);
  942. if (dev->flags & IFF_PROMISC) {
  943. memset(mc_filter, 0xff, sizeof(mc_filter));
  944. outb(3, ioaddr + RX_MODE); /* Enable promiscuous mode */
  945. } else if (netdev_mc_count(dev) > MC_FILTERBREAK ||
  946. (dev->flags & IFF_ALLMULTI)) {
  947. /* Too many to filter perfectly -- accept all multicasts. */
  948. memset(mc_filter, 0xff, sizeof(mc_filter));
  949. outb(2, ioaddr + RX_MODE); /* Use normal mode. */
  950. } else if (netdev_mc_empty(dev)) {
  951. memset(mc_filter, 0x00, sizeof(mc_filter));
  952. outb(1, ioaddr + RX_MODE); /* Ignore almost all multicasts. */
  953. } else {
  954. struct netdev_hw_addr *ha;
  955. memset(mc_filter, 0, sizeof(mc_filter));
  956. netdev_for_each_mc_addr(ha, dev) {
  957. unsigned int bit = ether_crc_le(ETH_ALEN, ha->addr) >> 26;
  958. mc_filter[bit >> 3] |= (1 << (bit & 7));
  959. }
  960. outb(2, ioaddr + RX_MODE); /* Use normal mode. */
  961. }
  962. /* Switch to bank 1 and set the multicast table. */
  963. saved_bank = inb(ioaddr + CONFIG_1);
  964. outb(0xe4, ioaddr + CONFIG_1);
  965. for (i = 0; i < 8; i++)
  966. outb(mc_filter[i], ioaddr + MAR_ADR + i);
  967. outb(saved_bank, ioaddr + CONFIG_1);
  968. outb(saved_config_0, ioaddr + CONFIG_0);
  969. local_irq_restore(flags);
  970. }