You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rtl8139.c 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /* rtl8139.c - etherboot driver for the Realtek 8139 chipset
  2. ported from the linux driver written by Donald Becker
  3. by Rainer Bawidamann (Rainer.Bawidamann@informatik.uni-ulm.de) 1999
  4. This software may be used and distributed according to the terms
  5. of the GNU Public License, incorporated herein by reference.
  6. changes to the original driver:
  7. - removed support for interrupts, switching to polling mode (yuck!)
  8. - removed support for the 8129 chip (external MII)
  9. */
  10. /*********************************************************************/
  11. /* Revision History */
  12. /*********************************************************************/
  13. /*
  14. 28 Dec 2002 ken_yap@users.sourceforge.net (Ken Yap)
  15. Put in virt_to_bus calls to allow Etherboot relocation.
  16. 06 Apr 2001 ken_yap@users.sourceforge.net (Ken Yap)
  17. Following email from Hyun-Joon Cha, added a disable routine, otherwise
  18. NIC remains live and can crash the kernel later.
  19. 4 Feb 2000 espenlaub@informatik.uni-ulm.de (Klaus Espenlaub)
  20. Shuffled things around, removed the leftovers from the 8129 support
  21. that was in the Linux driver and added a bit more 8139 definitions.
  22. Moved the 8K receive buffer to a fixed, available address outside the
  23. 0x98000-0x9ffff range. This is a bit of a hack, but currently the only
  24. way to make room for the Etherboot features that need substantial amounts
  25. of code like the ANSI console support. Currently the buffer is just below
  26. 0x10000, so this even conforms to the tagged boot image specification,
  27. which reserves the ranges 0x00000-0x10000 and 0x98000-0xA0000. My
  28. interpretation of this "reserved" is that Etherboot may do whatever it
  29. likes, as long as its environment is kept intact (like the BIOS
  30. variables). Hopefully fixed rtl_poll() once and for all. The symptoms
  31. were that if Etherboot was left at the boot menu for several minutes, the
  32. first eth_poll failed. Seems like I am the only person who does this.
  33. First of all I fixed the debugging code and then set out for a long bug
  34. hunting session. It took me about a week full time work - poking around
  35. various places in the driver, reading Don Becker's and Jeff Garzik's Linux
  36. driver and even the FreeBSD driver (what a piece of crap!) - and
  37. eventually spotted the nasty thing: the transmit routine was acknowledging
  38. each and every interrupt pending, including the RxOverrun and RxFIFIOver
  39. interrupts. This confused the RTL8139 thoroughly. It destroyed the
  40. Rx ring contents by dumping the 2K FIFO contents right where we wanted to
  41. get the next packet. Oh well, what fun.
  42. 18 Jan 2000 mdc@thinguin.org (Marty Connor)
  43. Drastically simplified error handling. Basically, if any error
  44. in transmission or reception occurs, the card is reset.
  45. Also, pointed all transmit descriptors to the same buffer to
  46. save buffer space. This should decrease driver size and avoid
  47. corruption because of exceeding 32K during runtime.
  48. 28 Jul 1999 (Matthias Meixner - meixner@rbg.informatik.tu-darmstadt.de)
  49. rtl_poll was quite broken: it used the RxOK interrupt flag instead
  50. of the RxBufferEmpty flag which often resulted in very bad
  51. transmission performace - below 1kBytes/s.
  52. */
  53. #include "etherboot.h"
  54. #include "nic.h"
  55. #include "pci.h"
  56. #include "timer.h"
  57. #define RTL_TIMEOUT (1*TICKS_PER_SEC)
  58. /* PCI Tuning Parameters
  59. Threshold is bytes transferred to chip before transmission starts. */
  60. #define TX_FIFO_THRESH 256 /* In bytes, rounded down to 32 byte units. */
  61. #define RX_FIFO_THRESH 4 /* Rx buffer level before first PCI xfer. */
  62. #define RX_DMA_BURST 4 /* Maximum PCI burst, '4' is 256 bytes */
  63. #define TX_DMA_BURST 4 /* Calculate as 16<<val. */
  64. #define NUM_TX_DESC 4 /* Number of Tx descriptor registers. */
  65. #define TX_BUF_SIZE ETH_FRAME_LEN /* FCS is added by the chip */
  66. #define RX_BUF_LEN_IDX 0 /* 0, 1, 2 is allowed - 8,16,32K rx buffer */
  67. #define RX_BUF_LEN (8192 << RX_BUF_LEN_IDX)
  68. #undef DEBUG_TX
  69. #undef DEBUG_RX
  70. /* Symbolic offsets to registers. */
  71. enum RTL8139_registers {
  72. MAC0=0, /* Ethernet hardware address. */
  73. MAR0=8, /* Multicast filter. */
  74. TxStatus0=0x10, /* Transmit status (four 32bit registers). */
  75. TxAddr0=0x20, /* Tx descriptors (also four 32bit). */
  76. RxBuf=0x30, RxEarlyCnt=0x34, RxEarlyStatus=0x36,
  77. ChipCmd=0x37, RxBufPtr=0x38, RxBufAddr=0x3A,
  78. IntrMask=0x3C, IntrStatus=0x3E,
  79. TxConfig=0x40, RxConfig=0x44,
  80. Timer=0x48, /* general-purpose counter. */
  81. RxMissed=0x4C, /* 24 bits valid, write clears. */
  82. Cfg9346=0x50, Config0=0x51, Config1=0x52,
  83. TimerIntrReg=0x54, /* intr if gp counter reaches this value */
  84. MediaStatus=0x58,
  85. Config3=0x59,
  86. MultiIntr=0x5C,
  87. RevisionID=0x5E, /* revision of the RTL8139 chip */
  88. TxSummary=0x60,
  89. MII_BMCR=0x62, MII_BMSR=0x64, NWayAdvert=0x66, NWayLPAR=0x68,
  90. NWayExpansion=0x6A,
  91. DisconnectCnt=0x6C, FalseCarrierCnt=0x6E,
  92. NWayTestReg=0x70,
  93. RxCnt=0x72, /* packet received counter */
  94. CSCR=0x74, /* chip status and configuration register */
  95. PhyParm1=0x78,TwisterParm=0x7c,PhyParm2=0x80, /* undocumented */
  96. /* from 0x84 onwards are a number of power management/wakeup frame
  97. * definitions we will probably never need to know about. */
  98. };
  99. enum RxEarlyStatusBits {
  100. ERGood=0x08, ERBad=0x04, EROVW=0x02, EROK=0x01
  101. };
  102. enum ChipCmdBits {
  103. CmdReset=0x10, CmdRxEnb=0x08, CmdTxEnb=0x04, RxBufEmpty=0x01, };
  104. enum IntrMaskBits {
  105. SERR=0x8000, TimeOut=0x4000, LenChg=0x2000,
  106. FOVW=0x40, PUN_LinkChg=0x20, RXOVW=0x10,
  107. TER=0x08, TOK=0x04, RER=0x02, ROK=0x01
  108. };
  109. /* Interrupt register bits, using my own meaningful names. */
  110. enum IntrStatusBits {
  111. PCIErr=0x8000, PCSTimeout=0x4000, CableLenChange= 0x2000,
  112. RxFIFOOver=0x40, RxUnderrun=0x20, RxOverflow=0x10,
  113. TxErr=0x08, TxOK=0x04, RxErr=0x02, RxOK=0x01,
  114. };
  115. enum TxStatusBits {
  116. TxHostOwns=0x2000, TxUnderrun=0x4000, TxStatOK=0x8000,
  117. TxOutOfWindow=0x20000000, TxAborted=0x40000000,
  118. TxCarrierLost=0x80000000,
  119. };
  120. enum RxStatusBits {
  121. RxMulticast=0x8000, RxPhysical=0x4000, RxBroadcast=0x2000,
  122. RxBadSymbol=0x0020, RxRunt=0x0010, RxTooLong=0x0008, RxCRCErr=0x0004,
  123. RxBadAlign=0x0002, RxStatusOK=0x0001,
  124. };
  125. enum MediaStatusBits {
  126. MSRTxFlowEnable=0x80, MSRRxFlowEnable=0x40, MSRSpeed10=0x08,
  127. MSRLinkFail=0x04, MSRRxPauseFlag=0x02, MSRTxPauseFlag=0x01,
  128. };
  129. enum MIIBMCRBits {
  130. BMCRReset=0x8000, BMCRSpeed100=0x2000, BMCRNWayEnable=0x1000,
  131. BMCRRestartNWay=0x0200, BMCRDuplex=0x0100,
  132. };
  133. enum CSCRBits {
  134. CSCR_LinkOKBit=0x0400, CSCR_LinkChangeBit=0x0800,
  135. CSCR_LinkStatusBits=0x0f000, CSCR_LinkDownOffCmd=0x003c0,
  136. CSCR_LinkDownCmd=0x0f3c0,
  137. };
  138. /* Bits in RxConfig. */
  139. enum rx_mode_bits {
  140. RxCfgWrap=0x80,
  141. AcceptErr=0x20, AcceptRunt=0x10, AcceptBroadcast=0x08,
  142. AcceptMulticast=0x04, AcceptMyPhys=0x02, AcceptAllPhys=0x01,
  143. };
  144. static unsigned int cur_rx,cur_tx;
  145. /* The RTL8139 can only transmit from a contiguous, aligned memory block. */
  146. static unsigned char tx_buffer[TX_BUF_SIZE] __attribute__((aligned(4)));
  147. static unsigned char rx_ring[RX_BUF_LEN+16] __attribute__((aligned(4)));
  148. static int rtl8139_probe(struct dev *dev, struct pci_device *pci);
  149. static int read_eeprom(struct nic *nic, int location, int addr_len);
  150. static void rtl_reset(struct nic *nic);
  151. static void rtl_transmit(struct nic *nic, const char *destaddr,
  152. unsigned int type, unsigned int len, const char *data);
  153. static int rtl_poll(struct nic *nic, int retrieve);
  154. static void rtl_disable(struct dev *);
  155. static void rtl_irq(struct nic *nic, irq_action_t action);
  156. static int rtl8139_probe ( struct dev *dev ) {
  157. struct nic *nic = nic_device ( dev );
  158. struct pci_device *pci = pci_device ( dev );
  159. int i;
  160. int speed10, fullduplex;
  161. int addr_len;
  162. unsigned short *ap = (unsigned short*)nic->node_addr;
  163. /* There are enough "RTL8139" strings on the console already, so
  164. * be brief and concentrate on the interesting pieces of info... */
  165. printf(" - ");
  166. /* Mask the bit that says "this is an io addr" */
  167. nic->ioaddr = pci->ioaddr & ~3;
  168. /* Copy IRQ from PCI information */
  169. nic->irqno = pci->irq;
  170. adjust_pci_device(pci);
  171. /* Bring the chip out of low-power mode. */
  172. outb(0x00, nic->ioaddr + Config1);
  173. addr_len = read_eeprom(nic,0,8) == 0x8129 ? 8 : 6;
  174. for (i = 0; i < 3; i++)
  175. *ap++ = read_eeprom(nic,i + 7,addr_len);
  176. speed10 = inb(nic->ioaddr + MediaStatus) & MSRSpeed10;
  177. fullduplex = inw(nic->ioaddr + MII_BMCR) & BMCRDuplex;
  178. printf("ioaddr %#hX, irq %d, addr %! %sMbps %s-duplex\n", nic->ioaddr,
  179. nic->irqno, nic->node_addr, speed10 ? "10" : "100",
  180. fullduplex ? "full" : "half");
  181. rtl_reset(nic);
  182. if (inb(nic->ioaddr + MediaStatus) & MSRLinkFail) {
  183. printf("Cable not connected or other link failure\n");
  184. return(0);
  185. }
  186. dev->disable = rtl_disable;
  187. nic->poll = rtl_poll;
  188. nic->transmit = rtl_transmit;
  189. nic->irq = rtl_irq;
  190. return 1;
  191. }
  192. /* Serial EEPROM section. */
  193. /* EEPROM_Ctrl bits. */
  194. #define EE_SHIFT_CLK 0x04 /* EEPROM shift clock. */
  195. #define EE_CS 0x08 /* EEPROM chip select. */
  196. #define EE_DATA_WRITE 0x02 /* EEPROM chip data in. */
  197. #define EE_WRITE_0 0x00
  198. #define EE_WRITE_1 0x02
  199. #define EE_DATA_READ 0x01 /* EEPROM chip data out. */
  200. #define EE_ENB (0x80 | EE_CS)
  201. /*
  202. Delay between EEPROM clock transitions.
  203. No extra delay is needed with 33Mhz PCI, but 66Mhz may change this.
  204. */
  205. #define eeprom_delay() inl(ee_addr)
  206. /* The EEPROM commands include the alway-set leading bit. */
  207. #define EE_WRITE_CMD (5)
  208. #define EE_READ_CMD (6)
  209. #define EE_ERASE_CMD (7)
  210. static int read_eeprom(struct nic *nic, int location, int addr_len)
  211. {
  212. int i;
  213. unsigned int retval = 0;
  214. long ee_addr = nic->ioaddr + Cfg9346;
  215. int read_cmd = location | (EE_READ_CMD << addr_len);
  216. outb(EE_ENB & ~EE_CS, ee_addr);
  217. outb(EE_ENB, ee_addr);
  218. eeprom_delay();
  219. /* Shift the read command bits out. */
  220. for (i = 4 + addr_len; i >= 0; i--) {
  221. int dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
  222. outb(EE_ENB | dataval, ee_addr);
  223. eeprom_delay();
  224. outb(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
  225. eeprom_delay();
  226. }
  227. outb(EE_ENB, ee_addr);
  228. eeprom_delay();
  229. for (i = 16; i > 0; i--) {
  230. outb(EE_ENB | EE_SHIFT_CLK, ee_addr);
  231. eeprom_delay();
  232. retval = (retval << 1) | ((inb(ee_addr) & EE_DATA_READ) ? 1 : 0);
  233. outb(EE_ENB, ee_addr);
  234. eeprom_delay();
  235. }
  236. /* Terminate the EEPROM access. */
  237. outb(~EE_CS, ee_addr);
  238. eeprom_delay();
  239. return retval;
  240. }
  241. static const unsigned int rtl8139_rx_config =
  242. (RX_BUF_LEN_IDX << 11) |
  243. (RX_FIFO_THRESH << 13) |
  244. (RX_DMA_BURST << 8);
  245. static void set_rx_mode(struct nic *nic) {
  246. unsigned int mc_filter[2];
  247. int rx_mode;
  248. /* !IFF_PROMISC */
  249. rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
  250. mc_filter[1] = mc_filter[0] = 0xffffffff;
  251. outl(rtl8139_rx_config | rx_mode, nic->ioaddr + RxConfig);
  252. outl(mc_filter[0], nic->ioaddr + MAR0 + 0);
  253. outl(mc_filter[1], nic->ioaddr + MAR0 + 4);
  254. }
  255. static void rtl_reset(struct nic* nic)
  256. {
  257. int i;
  258. outb(CmdReset, nic->ioaddr + ChipCmd);
  259. cur_rx = 0;
  260. cur_tx = 0;
  261. /* Give the chip 10ms to finish the reset. */
  262. load_timer2(10*TICKS_PER_MS);
  263. while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 &&
  264. timer2_running())
  265. /* wait */;
  266. for (i = 0; i < ETH_ALEN; i++)
  267. outb(nic->node_addr[i], nic->ioaddr + MAC0 + i);
  268. /* Must enable Tx/Rx before setting transfer thresholds! */
  269. outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd);
  270. outl((RX_FIFO_THRESH<<13) | (RX_BUF_LEN_IDX<<11) | (RX_DMA_BURST<<8),
  271. nic->ioaddr + RxConfig); /* accept no frames yet! */
  272. outl((TX_DMA_BURST<<8)|0x03000000, nic->ioaddr + TxConfig);
  273. /* The Linux driver changes Config1 here to use a different LED pattern
  274. * for half duplex or full/autodetect duplex (for full/autodetect, the
  275. * outputs are TX/RX, Link10/100, FULL, while for half duplex it uses
  276. * TX/RX, Link100, Link10). This is messy, because it doesn't match
  277. * the inscription on the mounting bracket. It should not be changed
  278. * from the configuration EEPROM default, because the card manufacturer
  279. * should have set that to match the card. */
  280. #ifdef DEBUG_RX
  281. printf("rx ring address is %X\n",(unsigned long)rx_ring);
  282. #endif
  283. outl((unsigned long)virt_to_bus(rx_ring), nic->ioaddr + RxBuf);
  284. /* If we add multicast support, the MAR0 register would have to be
  285. * initialized to 0xffffffffffffffff (two 32 bit accesses). Etherboot
  286. * only needs broadcast (for ARP/RARP/BOOTP/DHCP) and unicast. */
  287. outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd);
  288. outl(rtl8139_rx_config, nic->ioaddr + RxConfig);
  289. /* Start the chip's Tx and Rx process. */
  290. outl(0, nic->ioaddr + RxMissed);
  291. /* set_rx_mode */
  292. set_rx_mode(nic);
  293. /* Disable all known interrupts by setting the interrupt mask. */
  294. outw(0, nic->ioaddr + IntrMask);
  295. }
  296. static void rtl_transmit(struct nic *nic, const char *destaddr,
  297. unsigned int type, unsigned int len, const char *data)
  298. {
  299. unsigned int status, to, nstype;
  300. unsigned long txstatus;
  301. /* nstype assignment moved up here to avoid gcc 3.0.3 compiler bug */
  302. nstype = htons(type);
  303. memcpy(tx_buffer, destaddr, ETH_ALEN);
  304. memcpy(tx_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN);
  305. memcpy(tx_buffer + 2 * ETH_ALEN, &nstype, 2);
  306. memcpy(tx_buffer + ETH_HLEN, data, len);
  307. len += ETH_HLEN;
  308. #ifdef DEBUG_TX
  309. printf("sending %d bytes ethtype %hX\n", len, type);
  310. #endif
  311. /* Note: RTL8139 doesn't auto-pad, send minimum payload (another 4
  312. * bytes are sent automatically for the FCS, totalling to 64 bytes). */
  313. while (len < ETH_ZLEN) {
  314. tx_buffer[len++] = '\0';
  315. }
  316. outl((unsigned long)virt_to_bus(tx_buffer), nic->ioaddr + TxAddr0 + cur_tx*4);
  317. outl(((TX_FIFO_THRESH<<11) & 0x003f0000) | len,
  318. nic->ioaddr + TxStatus0 + cur_tx*4);
  319. to = currticks() + RTL_TIMEOUT;
  320. do {
  321. status = inw(nic->ioaddr + IntrStatus);
  322. /* Only acknlowledge interrupt sources we can properly handle
  323. * here - the RxOverflow/RxFIFOOver MUST be handled in the
  324. * rtl_poll() function. */
  325. outw(status & (TxOK | TxErr | PCIErr), nic->ioaddr + IntrStatus);
  326. if ((status & (TxOK | TxErr | PCIErr)) != 0) break;
  327. } while (currticks() < to);
  328. txstatus = inl(nic->ioaddr+ TxStatus0 + cur_tx*4);
  329. if (status & TxOK) {
  330. cur_tx = (cur_tx + 1) % NUM_TX_DESC;
  331. #ifdef DEBUG_TX
  332. printf("tx done (%d ticks), status %hX txstatus %X\n",
  333. to-currticks(), status, txstatus);
  334. #endif
  335. } else {
  336. #ifdef DEBUG_TX
  337. printf("tx timeout/error (%d ticks), status %hX txstatus %X\n",
  338. currticks()-to, status, txstatus);
  339. #endif
  340. rtl_reset(nic);
  341. }
  342. }
  343. static int rtl_poll(struct nic *nic, int retrieve)
  344. {
  345. unsigned int status;
  346. unsigned int ring_offs;
  347. unsigned int rx_size, rx_status;
  348. if (inb(nic->ioaddr + ChipCmd) & RxBufEmpty) {
  349. return 0;
  350. }
  351. /* There is a packet ready */
  352. if ( ! retrieve ) return 1;
  353. status = inw(nic->ioaddr + IntrStatus);
  354. /* See below for the rest of the interrupt acknowledges. */
  355. outw(status & ~(RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus);
  356. #ifdef DEBUG_RX
  357. printf("rtl_poll: int %hX ", status);
  358. #endif
  359. ring_offs = cur_rx % RX_BUF_LEN;
  360. rx_status = *(unsigned int*)(rx_ring + ring_offs);
  361. rx_size = rx_status >> 16;
  362. rx_status &= 0xffff;
  363. if ((rx_status & (RxBadSymbol|RxRunt|RxTooLong|RxCRCErr|RxBadAlign)) ||
  364. (rx_size < ETH_ZLEN) || (rx_size > ETH_FRAME_LEN + 4)) {
  365. printf("rx error %hX\n", rx_status);
  366. rtl_reset(nic); /* this clears all interrupts still pending */
  367. return 0;
  368. }
  369. /* Received a good packet */
  370. nic->packetlen = rx_size - 4; /* no one cares about the FCS */
  371. if (ring_offs+4+rx_size-4 > RX_BUF_LEN) {
  372. int semi_count = RX_BUF_LEN - ring_offs - 4;
  373. memcpy(nic->packet, rx_ring + ring_offs + 4, semi_count);
  374. memcpy(nic->packet+semi_count, rx_ring, rx_size-4-semi_count);
  375. #ifdef DEBUG_RX
  376. printf("rx packet %d+%d bytes", semi_count,rx_size-4-semi_count);
  377. #endif
  378. } else {
  379. memcpy(nic->packet, rx_ring + ring_offs + 4, nic->packetlen);
  380. #ifdef DEBUG_RX
  381. printf("rx packet %d bytes", rx_size-4);
  382. #endif
  383. }
  384. #ifdef DEBUG_RX
  385. printf(" at %X type %hhX%hhX rxstatus %hX\n",
  386. (unsigned long)(rx_ring+ring_offs+4),
  387. nic->packet[12], nic->packet[13], rx_status);
  388. #endif
  389. cur_rx = (cur_rx + rx_size + 4 + 3) & ~3;
  390. outw(cur_rx - 16, nic->ioaddr + RxBufPtr);
  391. /* See RTL8139 Programming Guide V0.1 for the official handling of
  392. * Rx overflow situations. The document itself contains basically no
  393. * usable information, except for a few exception handling rules. */
  394. outw(status & (RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus);
  395. return 1;
  396. }
  397. static void rtl_irq(struct nic *nic, irq_action_t action)
  398. {
  399. unsigned int mask;
  400. /* Bit of a guess as to which interrupts we should allow */
  401. unsigned int interested = ROK | RER | RXOVW | FOVW | SERR;
  402. switch ( action ) {
  403. case DISABLE :
  404. case ENABLE :
  405. mask = inw(nic->ioaddr + IntrMask);
  406. mask = mask & ~interested;
  407. if ( action == ENABLE ) mask = mask | interested;
  408. outw(mask, nic->ioaddr + IntrMask);
  409. break;
  410. case FORCE :
  411. /* Apparently writing a 1 to this read-only bit of a
  412. * read-only and otherwise unrelated register will
  413. * force an interrupt. If you ever want to see how
  414. * not to write a datasheet, read the one for the
  415. * RTL8139...
  416. */
  417. outb(EROK, nic->ioaddr + RxEarlyStatus);
  418. break;
  419. }
  420. }
  421. static void rtl_disable ( struct nic *nic ) {
  422. /* merge reset and disable */
  423. rtl_reset(nic);
  424. /* reset the chip */
  425. outb(CmdReset, nic->ioaddr + ChipCmd);
  426. /* 10 ms timeout */
  427. load_timer2(10*TICKS_PER_MS);
  428. while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 && timer2_running())
  429. /* wait */;
  430. }
  431. static struct pci_id rtl8139_nics[] = {
  432. PCI_ROM(0x10ec, 0x8129, "rtl8129", "Realtek 8129"),
  433. PCI_ROM(0x10ec, 0x8139, "rtl8139", "Realtek 8139"),
  434. PCI_ROM(0x10ec, 0x8138, "rtl8139b", "Realtek 8139B"),
  435. PCI_ROM(0x1186, 0x1300, "dfe538", "DFE530TX+/DFE538TX"),
  436. PCI_ROM(0x1113, 0x1211, "smc1211-1", "SMC EZ10/100"),
  437. PCI_ROM(0x1112, 0x1211, "smc1211", "SMC EZ10/100"),
  438. PCI_ROM(0x1500, 0x1360, "delta8139", "Delta Electronics 8139"),
  439. PCI_ROM(0x4033, 0x1360, "addtron8139", "Addtron Technology 8139"),
  440. PCI_ROM(0x1186, 0x1340, "dfe690txd", "D-Link DFE690TXD"),
  441. PCI_ROM(0x13d1, 0xab06, "fe2000vx", "AboCom FE2000VX"),
  442. PCI_ROM(0x1259, 0xa117, "allied8139", "Allied Telesyn 8139"),
  443. PCI_ROM(0x14ea, 0xab06, "fnw3603tx", "Planex FNW-3603-TX"),
  444. PCI_ROM(0x14ea, 0xab07, "fnw3800tx", "Planex FNW-3800-TX"),
  445. PCI_ROM(0xffff, 0x8139, "clone-rtl8139", "Cloned 8139"),
  446. };
  447. static struct pci_driver rtl8139_driver =
  448. PCI_DRIVER ( "RTL8139", rtl8139_nics, PCI_NO_CLASS );
  449. BOOT_DRIVER ( "RTL8139", rtl8139_probe );