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.

eepro.c 19KB

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