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 20KB

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