Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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