您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

eepro.c 19KB

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