eepro.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. /**************************************************************************
  2. Etherboot - BOOTP/TFTP Bootstrap Program
  3. Intel EEPRO/10 NIC driver for Etherboot
  4. Adapted from Linux eepro.c from kernel 2.2.17
  5. This board accepts a 32 pin EEPROM (29C256), however a test with a
  6. 27C010 shows that this EPROM also works in the socket, but it's not clear
  7. how repeatably. The two top address pins appear to be held low, thus
  8. the bottom 32kB of the 27C010 is visible in the CPU's address space.
  9. To be sure you could put 4 copies of the code in the 27C010, then
  10. it doesn't matter whether the extra lines are held low or high, just
  11. hopefully not floating as CMOS chips don't like floating inputs.
  12. Be careful with seating the EPROM as the socket on my board actually
  13. has 34 pins, the top row of 2 are not used.
  14. ***************************************************************************/
  15. /*
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License as
  18. * published by the Free Software Foundation; either version 2, or (at
  19. * your option) any later version.
  20. */
  21. /* to get some global routines like printf */
  22. #include "etherboot.h"
  23. /* to get the interface to the body of the program */
  24. #include "nic.h"
  25. /* to get our own prototype */
  26. #include "cards.h"
  27. /* we use timer2 for microsecond waits */
  28. #include "timer.h"
  29. #undef DEBUG /* only after include files */
  30. /* Different 82595 chips */
  31. #define LAN595 0
  32. #define LAN595TX 1
  33. #define LAN595FX 2
  34. #define LAN595FX_10ISA 3
  35. #define SLOW_DOWN inb(0x80);
  36. /* The station (ethernet) address prefix, used for IDing the board. */
  37. #define SA_ADDR0 0x00 /* Etherexpress Pro/10 */
  38. #define SA_ADDR1 0xaa
  39. #define SA_ADDR2 0x00
  40. #define GetBit(x,y) ((x & (1<<y))>>y)
  41. /* EEPROM Word 0: */
  42. #define ee_PnP 0 /* Plug 'n Play enable bit */
  43. #define ee_Word1 1 /* Word 1? */
  44. #define ee_BusWidth 2 /* 8/16 bit */
  45. #define ee_FlashAddr 3 /* Flash Address */
  46. #define ee_FlashMask 0x7 /* Mask */
  47. #define ee_AutoIO 6 /* */
  48. #define ee_reserved0 7 /* =0! */
  49. #define ee_Flash 8 /* Flash there? */
  50. #define ee_AutoNeg 9 /* Auto Negotiation enabled? */
  51. #define ee_IO0 10 /* IO Address LSB */
  52. #define ee_IO0Mask 0x /*...*/
  53. #define ee_IO1 15 /* IO MSB */
  54. /* EEPROM Word 1: */
  55. #define ee_IntSel 0 /* Interrupt */
  56. #define ee_IntMask 0x7
  57. #define ee_LI 3 /* Link Integrity 0= enabled */
  58. #define ee_PC 4 /* Polarity Correction 0= enabled */
  59. #define ee_TPE_AUI 5 /* PortSelection 1=TPE */
  60. #define ee_Jabber 6 /* Jabber prevention 0= enabled */
  61. #define ee_AutoPort 7 /* Auto Port Selection 1= Disabled */
  62. #define ee_SMOUT 8 /* SMout Pin Control 0= Input */
  63. #define ee_PROM 9 /* Flash EPROM / PROM 0=Flash */
  64. #define ee_reserved1 10 /* .. 12 =0! */
  65. #define ee_AltReady 13 /* Alternate Ready, 0=normal */
  66. #define ee_reserved2 14 /* =0! */
  67. #define ee_Duplex 15
  68. /* Word2,3,4: */
  69. #define ee_IA5 0 /*bit start for individual Addr Byte 5 */
  70. #define ee_IA4 8 /*bit start for individual Addr Byte 5 */
  71. #define ee_IA3 0 /*bit start for individual Addr Byte 5 */
  72. #define ee_IA2 8 /*bit start for individual Addr Byte 5 */
  73. #define ee_IA1 0 /*bit start for individual Addr Byte 5 */
  74. #define ee_IA0 8 /*bit start for individual Addr Byte 5 */
  75. /* Word 5: */
  76. #define ee_BNC_TPE 0 /* 0=TPE */
  77. #define ee_BootType 1 /* 00=None, 01=IPX, 10=ODI, 11=NDIS */
  78. #define ee_BootTypeMask 0x3
  79. #define ee_NumConn 3 /* Number of Connections 0= One or Two */
  80. #define ee_FlashSock 4 /* Presence of Flash Socket 0= Present */
  81. #define ee_PortTPE 5
  82. #define ee_PortBNC 6
  83. #define ee_PortAUI 7
  84. #define ee_PowerMgt 10 /* 0= disabled */
  85. #define ee_CP 13 /* Concurrent Processing */
  86. #define ee_CPMask 0x7
  87. /* Word 6: */
  88. #define ee_Stepping 0 /* Stepping info */
  89. #define ee_StepMask 0x0F
  90. #define ee_BoardID 4 /* Manucaturer Board ID, reserved */
  91. #define ee_BoardMask 0x0FFF
  92. /* Word 7: */
  93. #define ee_INT_TO_IRQ 0 /* int to IRQ Mapping = 0x1EB8 for Pro/10+ */
  94. #define ee_FX_INT2IRQ 0x1EB8 /* the _only_ mapping allowed for FX chips */
  95. /*..*/
  96. #define ee_SIZE 0x40 /* total EEprom Size */
  97. #define ee_Checksum 0xBABA /* initial and final value for adding checksum */
  98. /* Card identification via EEprom: */
  99. #define ee_addr_vendor 0x10 /* Word offset for EISA Vendor ID */
  100. #define ee_addr_id 0x11 /* Word offset for Card ID */
  101. #define ee_addr_SN 0x12 /* Serial Number */
  102. #define ee_addr_CRC_8 0x14 /* CRC over last thee Bytes */
  103. #define ee_vendor_intel0 0x25 /* Vendor ID Intel */
  104. #define ee_vendor_intel1 0xD4
  105. #define ee_id_eepro10p0 0x10 /* ID for eepro/10+ */
  106. #define ee_id_eepro10p1 0x31
  107. /* now this section could be used by both boards: the oldies and the ee10:
  108. * ee10 uses tx buffer before of rx buffer and the oldies the inverse.
  109. * (aris)
  110. */
  111. #define RAM_SIZE 0x8000
  112. #define RCV_HEADER 8
  113. #define RCV_DEFAULT_RAM 0x6000
  114. #define RCV_RAM rcv_ram
  115. static unsigned rcv_ram = RCV_DEFAULT_RAM;
  116. #define XMT_HEADER 8
  117. #define XMT_RAM (RAM_SIZE - RCV_RAM)
  118. #define XMT_START ((rcv_start + RCV_RAM) % RAM_SIZE)
  119. #define RCV_LOWER_LIMIT (rcv_start >> 8)
  120. #define RCV_UPPER_LIMIT (((rcv_start + RCV_RAM) - 2) >> 8)
  121. #define XMT_LOWER_LIMIT (XMT_START >> 8)
  122. #define XMT_UPPER_LIMIT (((XMT_START + XMT_RAM) - 2) >> 8)
  123. #define RCV_START_PRO 0x00
  124. #define RCV_START_10 XMT_RAM
  125. /* by default the old driver */
  126. static unsigned rcv_start = RCV_START_PRO;
  127. #define RCV_DONE 0x0008
  128. #define RX_OK 0x2000
  129. #define RX_ERROR 0x0d81
  130. #define TX_DONE_BIT 0x0080
  131. #define CHAIN_BIT 0x8000
  132. #define XMT_STATUS 0x02
  133. #define XMT_CHAIN 0x04
  134. #define XMT_COUNT 0x06
  135. #define BANK0_SELECT 0x00
  136. #define BANK1_SELECT 0x40
  137. #define BANK2_SELECT 0x80
  138. /* Bank 0 registers */
  139. #define COMMAND_REG 0x00 /* Register 0 */
  140. #define MC_SETUP 0x03
  141. #define XMT_CMD 0x04
  142. #define DIAGNOSE_CMD 0x07
  143. #define RCV_ENABLE_CMD 0x08
  144. #define RCV_DISABLE_CMD 0x0a
  145. #define STOP_RCV_CMD 0x0b
  146. #define RESET_CMD 0x0e
  147. #define POWER_DOWN_CMD 0x18
  148. #define RESUME_XMT_CMD 0x1c
  149. #define SEL_RESET_CMD 0x1e
  150. #define STATUS_REG 0x01 /* Register 1 */
  151. #define RX_INT 0x02
  152. #define TX_INT 0x04
  153. #define EXEC_STATUS 0x30
  154. #define ID_REG 0x02 /* Register 2 */
  155. #define R_ROBIN_BITS 0xc0 /* round robin counter */
  156. #define ID_REG_MASK 0x2c
  157. #define ID_REG_SIG 0x24
  158. #define AUTO_ENABLE 0x10
  159. #define INT_MASK_REG 0x03 /* Register 3 */
  160. #define RX_STOP_MASK 0x01
  161. #define RX_MASK 0x02
  162. #define TX_MASK 0x04
  163. #define EXEC_MASK 0x08
  164. #define ALL_MASK 0x0f
  165. #define IO_32_BIT 0x10
  166. #define RCV_BAR 0x04 /* The following are word (16-bit) registers */
  167. #define RCV_STOP 0x06
  168. #define XMT_BAR_PRO 0x0a
  169. #define XMT_BAR_10 0x0b
  170. static unsigned xmt_bar = XMT_BAR_PRO;
  171. #define HOST_ADDRESS_REG 0x0c
  172. #define IO_PORT 0x0e
  173. #define IO_PORT_32_BIT 0x0c
  174. /* Bank 1 registers */
  175. #define REG1 0x01
  176. #define WORD_WIDTH 0x02
  177. #define INT_ENABLE 0x80
  178. #define INT_NO_REG 0x02
  179. #define RCV_LOWER_LIMIT_REG 0x08
  180. #define RCV_UPPER_LIMIT_REG 0x09
  181. #define XMT_LOWER_LIMIT_REG_PRO 0x0a
  182. #define XMT_UPPER_LIMIT_REG_PRO 0x0b
  183. #define XMT_LOWER_LIMIT_REG_10 0x0b
  184. #define XMT_UPPER_LIMIT_REG_10 0x0a
  185. static unsigned xmt_lower_limit_reg = XMT_LOWER_LIMIT_REG_PRO;
  186. static unsigned xmt_upper_limit_reg = XMT_UPPER_LIMIT_REG_PRO;
  187. /* Bank 2 registers */
  188. #define XMT_Chain_Int 0x20 /* Interrupt at the end of the transmit chain */
  189. #define XMT_Chain_ErrStop 0x40 /* Interrupt at the end of the chain even if there are errors */
  190. #define RCV_Discard_BadFrame 0x80 /* Throw bad frames away, and continue to receive others */
  191. #define REG2 0x02
  192. #define PRMSC_Mode 0x01
  193. #define Multi_IA 0x20
  194. #define REG3 0x03
  195. #define TPE_BIT 0x04
  196. #define BNC_BIT 0x20
  197. #define REG13 0x0d
  198. #define FDX 0x00
  199. #define A_N_ENABLE 0x02
  200. #define I_ADD_REG0 0x04
  201. #define I_ADD_REG1 0x05
  202. #define I_ADD_REG2 0x06
  203. #define I_ADD_REG3 0x07
  204. #define I_ADD_REG4 0x08
  205. #define I_ADD_REG5 0x09
  206. #define EEPROM_REG_PRO 0x0a
  207. #define EEPROM_REG_10 0x0b
  208. static unsigned eeprom_reg = EEPROM_REG_PRO;
  209. #define EESK 0x01
  210. #define EECS 0x02
  211. #define EEDI 0x04
  212. #define EEDO 0x08
  213. /* The horrible routine to read a word from the serial EEPROM. */
  214. /* IMPORTANT - the 82595 will be set to Bank 0 after the eeprom is read */
  215. /* The delay between EEPROM clock transitions. */
  216. #define eeprom_delay() { udelay(40); }
  217. #define EE_READ_CMD (6 << 6)
  218. /* do a full reset */
  219. #define eepro_full_reset(ioaddr) outb(RESET_CMD, ioaddr); udelay(40);
  220. /* do a nice reset */
  221. #define eepro_sel_reset(ioaddr) { \
  222. outb(SEL_RESET_CMD, ioaddr); \
  223. SLOW_DOWN; \
  224. SLOW_DOWN; \
  225. }
  226. /* clear all interrupts */
  227. #define eepro_clear_int(ioaddr) outb(ALL_MASK, ioaddr + STATUS_REG)
  228. /* enable rx */
  229. #define eepro_en_rx(ioaddr) outb(RCV_ENABLE_CMD, ioaddr)
  230. /* disable rx */
  231. #define eepro_dis_rx(ioaddr) outb(RCV_DISABLE_CMD, ioaddr)
  232. /* switch bank */
  233. #define eepro_sw2bank0(ioaddr) outb(BANK0_SELECT, ioaddr)
  234. #define eepro_sw2bank1(ioaddr) outb(BANK1_SELECT, ioaddr)
  235. #define eepro_sw2bank2(ioaddr) outb(BANK2_SELECT, ioaddr)
  236. static unsigned int rx_start, tx_start;
  237. static int tx_last;
  238. static unsigned tx_end;
  239. static int eepro = 0;
  240. static unsigned short ioaddr = 0;
  241. static unsigned int mem_start, mem_end = RCV_DEFAULT_RAM / 1024;
  242. #define udelay(n) waiton_timer2(((n)*TICKS_PER_MS)/1000)
  243. /**************************************************************************
  244. RESET - Reset adapter
  245. ***************************************************************************/
  246. static void eepro_reset(struct nic *nic)
  247. {
  248. int temp_reg, i;
  249. /* put the card in its initial state */
  250. eepro_sw2bank2(ioaddr); /* be careful, bank2 now */
  251. temp_reg = inb(ioaddr + eeprom_reg);
  252. #ifdef DEBUG
  253. printf("Stepping %d\n", temp_reg >> 5);
  254. #endif
  255. if (temp_reg & 0x10) /* check the TurnOff Enable bit */
  256. outb(temp_reg & 0xEF, ioaddr + eeprom_reg);
  257. for (i = 0; i < ETH_ALEN; i++) /* fill the MAC address */
  258. outb(nic->node_addr[i], ioaddr + I_ADD_REG0 + i);
  259. temp_reg = inb(ioaddr + REG1);
  260. /* setup Transmit Chaining and discard bad RCV frames */
  261. outb(temp_reg | XMT_Chain_Int | XMT_Chain_ErrStop
  262. | RCV_Discard_BadFrame, ioaddr + REG1);
  263. temp_reg = inb(ioaddr + REG2); /* match broadcast */
  264. outb(temp_reg | 0x14, ioaddr + REG2);
  265. temp_reg = inb(ioaddr + REG3);
  266. outb(temp_reg & 0x3F, ioaddr + REG3); /* clear test mode */
  267. /* set the receiving mode */
  268. eepro_sw2bank1(ioaddr); /* be careful, bank1 now */
  269. /* initialise the RCV and XMT upper and lower limits */
  270. outb(RCV_LOWER_LIMIT, ioaddr + RCV_LOWER_LIMIT_REG);
  271. outb(RCV_UPPER_LIMIT, ioaddr + RCV_UPPER_LIMIT_REG);
  272. outb(XMT_LOWER_LIMIT, ioaddr + xmt_lower_limit_reg);
  273. outb(XMT_UPPER_LIMIT, ioaddr + xmt_upper_limit_reg);
  274. eepro_sw2bank0(ioaddr); /* Switch back to bank 0 */
  275. eepro_clear_int(ioaddr);
  276. /* Initialise RCV */
  277. outw(rx_start = (RCV_LOWER_LIMIT << 8), ioaddr + RCV_BAR);
  278. outw(((RCV_UPPER_LIMIT << 8) | 0xFE), ioaddr + RCV_STOP);
  279. /* Intialise XMT */
  280. outw((XMT_LOWER_LIMIT << 8), ioaddr + xmt_bar);
  281. eepro_sel_reset(ioaddr);
  282. tx_start = tx_end = (XMT_LOWER_LIMIT << 8);
  283. tx_last = 0;
  284. eepro_en_rx(ioaddr);
  285. }
  286. /**************************************************************************
  287. POLL - Wait for a frame
  288. ***************************************************************************/
  289. static int eepro_poll(struct nic *nic)
  290. {
  291. int i;
  292. unsigned int rcv_car = rx_start;
  293. unsigned int rcv_event, rcv_status, rcv_next_frame, rcv_size;
  294. /* return true if there's an ethernet packet ready to read */
  295. /* nic->packet should contain data on return */
  296. /* nic->packetlen should contain length of data */
  297. #if 0
  298. if ((inb(ioaddr + STATUS_REG) & 0x40) == 0)
  299. return (0);
  300. outb(0x40, ioaddr + STATUS_REG);
  301. #endif
  302. outw(rcv_car, ioaddr + HOST_ADDRESS_REG);
  303. rcv_event = inw(ioaddr + IO_PORT);
  304. if (rcv_event != RCV_DONE)
  305. return (0);
  306. rcv_status = inw(ioaddr + IO_PORT);
  307. rcv_next_frame = inw(ioaddr + IO_PORT);
  308. rcv_size = inw(ioaddr + IO_PORT);
  309. #if 0
  310. printf("%hX %hX %d %hhX\n", rcv_status, rcv_next_frame, rcv_size,
  311. inb(ioaddr + STATUS_REG));
  312. #endif
  313. if ((rcv_status & (RX_OK|RX_ERROR)) != RX_OK) {
  314. printf("Receive error %hX\n", rcv_status);
  315. return (0);
  316. }
  317. rcv_size &= 0x3FFF;
  318. insw(ioaddr + IO_PORT, nic->packet, ((rcv_size + 3) >> 1));
  319. #if 0
  320. for (i = 0; i < 48; i++) {
  321. printf("%hhX", nic->packet[i]);
  322. putchar(i % 16 == 15 ? '\n' : ' ');
  323. }
  324. #endif
  325. nic->packetlen = rcv_size;
  326. rcv_car = rx_start + RCV_HEADER + rcv_size;
  327. rx_start = rcv_next_frame;
  328. if (rcv_car == 0)
  329. rcv_car = ((RCV_UPPER_LIMIT << 8) | 0xff);
  330. outw(rcv_car - 1, ioaddr + RCV_STOP);
  331. return (1);
  332. }
  333. /**************************************************************************
  334. TRANSMIT - Transmit a frame
  335. ***************************************************************************/
  336. static void eepro_transmit(
  337. struct nic *nic,
  338. const char *d, /* Destination */
  339. unsigned int t, /* Type */
  340. unsigned int s, /* size */
  341. const char *p) /* Packet */
  342. {
  343. unsigned int status, tx_available, last, end, length;
  344. unsigned short type;
  345. int boguscount = 20;
  346. length = s + ETH_HLEN;
  347. if (tx_end > tx_start)
  348. tx_available = XMT_RAM - (tx_end - tx_start);
  349. else if (tx_end < tx_start)
  350. tx_available = tx_start - tx_end;
  351. else
  352. tx_available = XMT_RAM;
  353. last = tx_end;
  354. end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
  355. if (end >= (XMT_UPPER_LIMIT << 8)) {
  356. last = (XMT_LOWER_LIMIT << 8);
  357. end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
  358. }
  359. outw(last, ioaddr + HOST_ADDRESS_REG);
  360. outw(XMT_CMD, ioaddr + IO_PORT);
  361. outw(0, ioaddr + IO_PORT);
  362. outw(end, ioaddr + IO_PORT);
  363. outw(length, ioaddr + IO_PORT);
  364. outsw(ioaddr + IO_PORT, d, ETH_ALEN / 2);
  365. outsw(ioaddr + IO_PORT, nic->node_addr, ETH_ALEN / 2);
  366. type = htons(t);
  367. outsw(ioaddr + IO_PORT, &type, sizeof(type) / 2);
  368. outsw(ioaddr + IO_PORT, p, (s + 3) >> 1);
  369. /* A dummy read to flush the DRAM write pipeline */
  370. status = inw(ioaddr + IO_PORT);
  371. outw(last, ioaddr + xmt_bar);
  372. outb(XMT_CMD, ioaddr);
  373. tx_start = last;
  374. tx_last = last;
  375. tx_end = end;
  376. #if 0
  377. printf("%d %d\n", tx_start, tx_end);
  378. #endif
  379. while (boguscount > 0) {
  380. if (((status = inw(ioaddr + IO_PORT)) & TX_DONE_BIT) == 0) {
  381. udelay(40);
  382. boguscount--;
  383. continue;
  384. }
  385. #if DEBUG
  386. if ((status & 0x2000) == 0)
  387. printf("Transmit status %hX\n", status);
  388. #endif
  389. }
  390. }
  391. /**************************************************************************
  392. DISABLE - Turn off ethernet interface
  393. ***************************************************************************/
  394. static void eepro_disable(struct nic *nic)
  395. {
  396. eepro_sw2bank0(ioaddr); /* Switch to bank 0 */
  397. /* Flush the Tx and disable Rx */
  398. outb(STOP_RCV_CMD, ioaddr);
  399. tx_start = tx_end = (XMT_LOWER_LIMIT << 8);
  400. tx_last = 0;
  401. /* Reset the 82595 */
  402. eepro_full_reset(ioaddr);
  403. }
  404. static int read_eeprom(int location)
  405. {
  406. int i;
  407. unsigned short retval = 0;
  408. int ee_addr = ioaddr + eeprom_reg;
  409. int read_cmd = location | EE_READ_CMD;
  410. int ctrl_val = EECS;
  411. if (eepro == LAN595FX_10ISA) {
  412. eepro_sw2bank1(ioaddr);
  413. outb(0x00, ioaddr + STATUS_REG);
  414. }
  415. eepro_sw2bank2(ioaddr);
  416. outb(ctrl_val, ee_addr);
  417. /* shift the read command bits out */
  418. for (i = 8; i >= 0; i--) {
  419. short outval = (read_cmd & (1 << i)) ? ctrl_val | EEDI : ctrl_val;
  420. outb(outval, ee_addr);
  421. outb(outval | EESK, ee_addr); /* EEPROM clock tick */
  422. eeprom_delay();
  423. outb(outval, ee_addr); /* finish EEPROM clock tick */
  424. eeprom_delay();
  425. }
  426. outb(ctrl_val, ee_addr);
  427. for (i = 16; i > 0; i--) {
  428. outb(ctrl_val | EESK, ee_addr);
  429. eeprom_delay();
  430. retval = (retval << 1) | ((inb(ee_addr) & EEDO) ? 1 : 0);
  431. outb(ctrl_val, ee_addr);
  432. eeprom_delay();
  433. }
  434. /* terminate the EEPROM access */
  435. ctrl_val &= ~EECS;
  436. outb(ctrl_val | EESK, ee_addr);
  437. eeprom_delay();
  438. outb(ctrl_val, ee_addr);
  439. eeprom_delay();
  440. eepro_sw2bank0(ioaddr);
  441. return (retval);
  442. }
  443. static int eepro_probe1(struct nic *nic)
  444. {
  445. int i, id, counter, l_eepro = 0;
  446. union {
  447. unsigned char caddr[ETH_ALEN];
  448. unsigned short saddr[ETH_ALEN/2];
  449. } station_addr;
  450. char *name;
  451. id = inb(ioaddr + ID_REG);
  452. if ((id & ID_REG_MASK) != ID_REG_SIG)
  453. return (0);
  454. counter = id & R_ROBIN_BITS;
  455. if (((id = inb(ioaddr + ID_REG)) & R_ROBIN_BITS) != (counter + 0x40))
  456. return (0);
  457. /* yes the 82595 has been found */
  458. station_addr.saddr[2] = read_eeprom(2);
  459. if (station_addr.saddr[2] == 0x0000 || station_addr.saddr[2] == 0xFFFF) {
  460. l_eepro = 3;
  461. eepro = LAN595FX_10ISA;
  462. eeprom_reg= EEPROM_REG_10;
  463. rcv_start = RCV_START_10;
  464. xmt_lower_limit_reg = XMT_LOWER_LIMIT_REG_10;
  465. xmt_upper_limit_reg = XMT_UPPER_LIMIT_REG_10;
  466. station_addr.saddr[2] = read_eeprom(2);
  467. }
  468. station_addr.saddr[1] = read_eeprom(3);
  469. station_addr.saddr[0] = read_eeprom(4);
  470. if (l_eepro)
  471. name = "Intel EtherExpress 10 ISA";
  472. else if (read_eeprom(7) == ee_FX_INT2IRQ) {
  473. name = "Intel EtherExpress Pro/10+ ISA";
  474. l_eepro = 2;
  475. } else if (station_addr.saddr[0] == SA_ADDR1) {
  476. name = "Intel EtherExpress Pro/10 ISA";
  477. l_eepro = 1;
  478. } else {
  479. l_eepro = 0;
  480. name = "Intel 82595-based LAN card";
  481. }
  482. station_addr.saddr[0] = swap16(station_addr.saddr[0]);
  483. station_addr.saddr[1] = swap16(station_addr.saddr[1]);
  484. station_addr.saddr[2] = swap16(station_addr.saddr[2]);
  485. for (i = 0; i < ETH_ALEN; i++) {
  486. nic->node_addr[i] = station_addr.caddr[i];
  487. }
  488. printf("\n%s ioaddr %#hX, addr %!", name, ioaddr, nic->node_addr);
  489. mem_start = RCV_LOWER_LIMIT << 8;
  490. if ((mem_end & 0x3F) < 3 || (mem_end & 0x3F) > 29)
  491. mem_end = RCV_UPPER_LIMIT << 8;
  492. else {
  493. mem_end = mem_end * 1024 + (RCV_LOWER_LIMIT << 8);
  494. rcv_ram = mem_end - (RCV_LOWER_LIMIT << 8);
  495. }
  496. printf(", Rx mem %dK, if %s\n", (mem_end - mem_start) >> 10,
  497. GetBit(read_eeprom(5), ee_BNC_TPE) ? "BNC" : "TP");
  498. return (1);
  499. }
  500. /**************************************************************************
  501. PROBE - Look for an adapter, this routine's visible to the outside
  502. ***************************************************************************/
  503. struct nic *eepro_probe(struct nic *nic, unsigned short *probe_addrs)
  504. {
  505. unsigned short *p;
  506. /* same probe list as the Linux driver */
  507. static unsigned short ioaddrs[] = {
  508. 0x300, 0x210, 0x240, 0x280, 0x2C0, 0x200, 0x320, 0x340, 0x360, 0};
  509. if (probe_addrs == 0 || probe_addrs[0] == 0)
  510. probe_addrs = ioaddrs;
  511. for (p = probe_addrs; (ioaddr = *p) != 0; p++) {
  512. if (eepro_probe1(nic))
  513. break;
  514. }
  515. if (*p == 0)
  516. return (0);
  517. eepro_reset(nic);
  518. /* point to NIC specific routines */
  519. nic->reset = eepro_reset;
  520. nic->poll = eepro_poll;
  521. nic->transmit = eepro_transmit;
  522. nic->disable = eepro_disable;
  523. return (nic);
  524. }