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.

tlan.c 46KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719
  1. /**************************************************************************
  2. *
  3. * tlan.c -- Etherboot device driver for the Texas Instruments ThunderLAN
  4. * Written 2003-2003 by Timothy Legge <tlegge@rogers.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. * Portions of this code based on:
  21. * lan.c: Linux ThunderLan Driver:
  22. *
  23. * by James Banks
  24. *
  25. * (C) 1997-1998 Caldera, Inc.
  26. * (C) 1998 James Banks
  27. * (C) 1999-2001 Torben Mathiasen
  28. * (C) 2002 Samuel Chessman
  29. *
  30. * REVISION HISTORY:
  31. * ================
  32. * v1.0 07-08-2003 timlegge Initial not quite working version
  33. * v1.1 07-27-2003 timlegge Sync 5.0 and 5.1 versions
  34. * v1.2 08-19-2003 timlegge Implement Multicast Support
  35. * v1.3 08-23-2003 timlegge Fix the transmit Function
  36. * v1.4 01-17-2004 timlegge Initial driver output cleanup
  37. *
  38. * Indent Options: indent -kr -i8
  39. ***************************************************************************/
  40. /* to get some global routines like printf */
  41. #include "etherboot.h"
  42. /* to get the interface to the body of the program */
  43. #include "nic.h"
  44. /* to get the PCI support functions, if this is a PCI NIC */
  45. #include "pci.h"
  46. #include "timer.h"
  47. #include "tlan.h"
  48. #define drv_version "v1.4"
  49. #define drv_date "01-17-2004"
  50. /* NIC specific static variables go here */
  51. #define HZ 100
  52. #define TX_TIME_OUT (6*HZ)
  53. /* Condensed operations for readability. */
  54. #define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  55. #define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  56. //#define EDEBUG
  57. #ifdef EDEBUG
  58. #define dprintf(x) printf x
  59. #else
  60. #define dprintf(x)
  61. #endif
  62. static void TLan_ResetLists(struct nic *nic __unused);
  63. static void TLan_ResetAdapter(struct nic *nic __unused);
  64. static void TLan_FinishReset(struct nic *nic __unused);
  65. static void TLan_EeSendStart(u16);
  66. static int TLan_EeSendByte(u16, u8, int);
  67. static void TLan_EeReceiveByte(u16, u8 *, int);
  68. static int TLan_EeReadByte(u16 io_base, u8, u8 *);
  69. static void TLan_PhyDetect(struct nic *nic);
  70. static void TLan_PhyPowerDown(struct nic *nic);
  71. static void TLan_PhyPowerUp(struct nic *nic);
  72. static void TLan_SetMac(struct nic *nic __unused, int areg, char *mac);
  73. static void TLan_PhyReset(struct nic *nic);
  74. static void TLan_PhyStartLink(struct nic *nic);
  75. static void TLan_PhyFinishAutoNeg(struct nic *nic);
  76. #ifdef MONITOR
  77. static void TLan_PhyMonitor(struct nic *nic);
  78. #endif
  79. static void refill_rx(struct nic *nic __unused);
  80. static int TLan_MiiReadReg(struct nic *nic __unused, u16, u16, u16 *);
  81. static void TLan_MiiSendData(u16, u32, unsigned);
  82. static void TLan_MiiSync(u16);
  83. static void TLan_MiiWriteReg(struct nic *nic __unused, u16, u16, u16);
  84. const char *media[] = {
  85. "10BaseT-HD ", "10BaseT-FD ", "100baseTx-HD ",
  86. "100baseTx-FD", "100baseT4", 0
  87. };
  88. /* This much match tlan_pci_tbl[]! */
  89. enum tlan_nics {
  90. NETEL10 = 0, NETEL100 = 1, NETFLEX3I = 2, THUNDER = 3, NETFLEX3B =
  91. 4, NETEL100PI = 5,
  92. NETEL100D = 6, NETEL100I = 7, OC2183 = 8, OC2325 = 9, OC2326 =
  93. 10, NETELLIGENT_10_100_WS_5100 = 11,
  94. NETELLIGENT_10_T2 = 12
  95. };
  96. struct pci_id_info {
  97. const char *name;
  98. int nic_id;
  99. struct match_info {
  100. u32 pci, pci_mask, subsystem, subsystem_mask;
  101. u32 revision, revision_mask; /* Only 8 bits. */
  102. } id;
  103. u32 flags;
  104. u16 addrOfs; /* Address Offset */
  105. };
  106. static struct pci_id_info tlan_pci_tbl[] = {
  107. {"Compaq Netelligent 10 T PCI UTP", NETEL10,
  108. {0xae340e11, 0xffffffff, 0, 0, 0, 0},
  109. TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  110. {"Compaq Netelligent 10/100 TX PCI UTP", NETEL100,
  111. {0xae320e11, 0xffffffff, 0, 0, 0, 0},
  112. TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  113. {"Compaq Integrated NetFlex-3/P", NETFLEX3I,
  114. {0xae350e11, 0xffffffff, 0, 0, 0, 0},
  115. TLAN_ADAPTER_NONE, 0x83},
  116. {"Compaq NetFlex-3/P", THUNDER,
  117. {0xf1300e11, 0xffffffff, 0, 0, 0, 0},
  118. TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83},
  119. {"Compaq NetFlex-3/P", NETFLEX3B,
  120. {0xf1500e11, 0xffffffff, 0, 0, 0, 0},
  121. TLAN_ADAPTER_NONE, 0x83},
  122. {"Compaq Netelligent Integrated 10/100 TX UTP", NETEL100PI,
  123. {0xae430e11, 0xffffffff, 0, 0, 0, 0},
  124. TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  125. {"Compaq Netelligent Dual 10/100 TX PCI UTP", NETEL100D,
  126. {0xae400e11, 0xffffffff, 0, 0, 0, 0},
  127. TLAN_ADAPTER_NONE, 0x83},
  128. {"Compaq Netelligent 10/100 TX Embedded UTP", NETEL100I,
  129. {0xb0110e11, 0xffffffff, 0, 0, 0, 0},
  130. TLAN_ADAPTER_NONE, 0x83},
  131. {"Olicom OC-2183/2185", OC2183,
  132. {0x0013108d, 0xffffffff, 0, 0, 0, 0},
  133. TLAN_ADAPTER_USE_INTERN_10, 0x83},
  134. {"Olicom OC-2325", OC2325,
  135. {0x0012108d, 0xffffffff, 0, 0, 0, 0},
  136. TLAN_ADAPTER_UNMANAGED_PHY, 0xF8},
  137. {"Olicom OC-2326", OC2326,
  138. {0x0014108d, 0xffffffff, 0, 0, 0, 0},
  139. TLAN_ADAPTER_USE_INTERN_10, 0xF8},
  140. {"Compaq Netelligent 10/100 TX UTP", NETELLIGENT_10_100_WS_5100,
  141. {0xb0300e11, 0xffffffff, 0, 0, 0, 0},
  142. TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  143. {"Compaq Netelligent 10 T/2 PCI UTP/Coax", NETELLIGENT_10_T2,
  144. {0xb0120e11, 0xffffffff, 0, 0, 0, 0},
  145. TLAN_ADAPTER_NONE, 0x83},
  146. {"Compaq NetFlex-3/E", 0, /* EISA card */
  147. {0, 0, 0, 0, 0, 0},
  148. TLAN_ADAPTER_ACTIVITY_LED | TLAN_ADAPTER_UNMANAGED_PHY |
  149. TLAN_ADAPTER_BIT_RATE_PHY, 0x83},
  150. {"Compaq NetFlex-3/E", 0, /* EISA card */
  151. {0, 0, 0, 0, 0, 0},
  152. TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  153. {0, 0,
  154. {0, 0, 0, 0, 0, 0},
  155. 0, 0},
  156. };
  157. struct TLanList {
  158. u32 forward;
  159. u16 cStat;
  160. u16 frameSize;
  161. struct {
  162. u32 count;
  163. u32 address;
  164. } buffer[TLAN_BUFFERS_PER_LIST];
  165. };
  166. struct TLanList tx_ring[TLAN_NUM_TX_LISTS];
  167. static unsigned char txb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_TX_LISTS];
  168. struct TLanList rx_ring[TLAN_NUM_RX_LISTS];
  169. static unsigned char rxb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_RX_LISTS];
  170. typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
  171. int chip_idx;
  172. /*****************************************************************
  173. * TLAN Private Information Structure
  174. *
  175. ****************************************************************/
  176. struct tlan_private {
  177. unsigned short vendor_id; /* PCI Vendor code */
  178. unsigned short dev_id; /* PCI Device code */
  179. const char *nic_name;
  180. unsigned int cur_rx, dirty_rx; /* Producer/consumer ring indicies */
  181. unsigned rx_buf_sz; /* Based on mtu + Slack */
  182. struct TLanList *txList;
  183. u32 txHead;
  184. u32 txInProgress;
  185. u32 txTail;
  186. int eoc;
  187. u32 phyOnline;
  188. u32 aui;
  189. u32 duplex;
  190. u32 phy[2];
  191. u32 phyNum;
  192. u32 speed;
  193. u8 tlanRev;
  194. u8 tlanFullDuplex;
  195. u8 link;
  196. u8 neg_be_verbose;
  197. } TLanPrivateInfo;
  198. static struct tlan_private *priv;
  199. u32 BASE;
  200. /***************************************************************
  201. * TLan_ResetLists
  202. *
  203. * Returns:
  204. * Nothing
  205. * Parms:
  206. * dev The device structure with the list
  207. * stuctures to be reset.
  208. *
  209. * This routine sets the variables associated with managing
  210. * the TLAN lists to their initial values.
  211. *
  212. **************************************************************/
  213. void TLan_ResetLists(struct nic *nic __unused)
  214. {
  215. int i;
  216. struct TLanList *list;
  217. priv->txHead = 0;
  218. priv->txTail = 0;
  219. for (i = 0; i < TLAN_NUM_TX_LISTS; i++) {
  220. list = &tx_ring[i];
  221. list->cStat = TLAN_CSTAT_UNUSED;
  222. list->buffer[0].address = virt_to_bus(txb +
  223. (i * TLAN_MAX_FRAME_SIZE));
  224. list->buffer[2].count = 0;
  225. list->buffer[2].address = 0;
  226. list->buffer[9].address = 0;
  227. }
  228. priv->cur_rx = 0;
  229. priv->rx_buf_sz = (TLAN_MAX_FRAME_SIZE);
  230. // priv->rx_head_desc = &rx_ring[0];
  231. /* Initialize all the Rx descriptors */
  232. for (i = 0; i < TLAN_NUM_RX_LISTS; i++) {
  233. rx_ring[i].forward = virt_to_le32desc(&rx_ring[i + 1]);
  234. rx_ring[i].cStat = TLAN_CSTAT_READY;
  235. rx_ring[i].frameSize = TLAN_MAX_FRAME_SIZE;
  236. rx_ring[i].buffer[0].count =
  237. TLAN_MAX_FRAME_SIZE | TLAN_LAST_BUFFER;
  238. rx_ring[i].buffer[0].address =
  239. virt_to_le32desc(&rxb[i * TLAN_MAX_FRAME_SIZE]);
  240. rx_ring[i].buffer[1].count = 0;
  241. rx_ring[i].buffer[1].address = 0;
  242. }
  243. /* Mark the last entry as wrapping the ring */
  244. rx_ring[i - 1].forward = virt_to_le32desc(&rx_ring[0]);
  245. priv->dirty_rx = (unsigned int) (i - TLAN_NUM_RX_LISTS);
  246. } /* TLan_ResetLists */
  247. /***************************************************************
  248. * TLan_Reset
  249. *
  250. * Returns:
  251. * 0
  252. * Parms:
  253. * dev Pointer to device structure of adapter
  254. * to be reset.
  255. *
  256. * This function resets the adapter and it's physical
  257. * device. See Chap. 3, pp. 9-10 of the "ThunderLAN
  258. * Programmer's Guide" for details. The routine tries to
  259. * implement what is detailed there, though adjustments
  260. * have been made.
  261. *
  262. **************************************************************/
  263. void TLan_ResetAdapter(struct nic *nic __unused)
  264. {
  265. int i;
  266. u32 addr;
  267. u32 data;
  268. u8 data8;
  269. priv->tlanFullDuplex = FALSE;
  270. priv->phyOnline = 0;
  271. /* 1. Assert reset bit. */
  272. data = inl(BASE + TLAN_HOST_CMD);
  273. data |= TLAN_HC_AD_RST;
  274. outl(data, BASE + TLAN_HOST_CMD);
  275. udelay(1000);
  276. /* 2. Turn off interrupts. ( Probably isn't necessary ) */
  277. data = inl(BASE + TLAN_HOST_CMD);
  278. data |= TLAN_HC_INT_OFF;
  279. outl(data, BASE + TLAN_HOST_CMD);
  280. /* 3. Clear AREGs and HASHs. */
  281. for (i = TLAN_AREG_0; i <= TLAN_HASH_2; i += 4) {
  282. TLan_DioWrite32(BASE, (u16) i, 0);
  283. }
  284. /* 4. Setup NetConfig register. */
  285. data =
  286. TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
  287. TLan_DioWrite16(BASE, TLAN_NET_CONFIG, (u16) data);
  288. /* 5. Load Ld_Tmr and Ld_Thr in HOST_CMD. */
  289. outl(TLAN_HC_LD_TMR | 0x3f, BASE + TLAN_HOST_CMD);
  290. outl(TLAN_HC_LD_THR | 0x0, BASE + TLAN_HOST_CMD);
  291. /* 6. Unreset the MII by setting NMRST (in NetSio) to 1. */
  292. outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  293. addr = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  294. TLan_SetBit(TLAN_NET_SIO_NMRST, addr);
  295. /* 7. Setup the remaining registers. */
  296. if (priv->tlanRev >= 0x30) {
  297. data8 = TLAN_ID_TX_EOC | TLAN_ID_RX_EOC;
  298. TLan_DioWrite8(BASE, TLAN_INT_DIS, data8);
  299. }
  300. TLan_PhyDetect(nic);
  301. data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN;
  302. if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_BIT_RATE_PHY) {
  303. data |= TLAN_NET_CFG_BIT;
  304. if (priv->aui == 1) {
  305. TLan_DioWrite8(BASE, TLAN_ACOMMIT, 0x0a);
  306. } else if (priv->duplex == TLAN_DUPLEX_FULL) {
  307. TLan_DioWrite8(BASE, TLAN_ACOMMIT, 0x00);
  308. priv->tlanFullDuplex = TRUE;
  309. } else {
  310. TLan_DioWrite8(BASE, TLAN_ACOMMIT, 0x08);
  311. }
  312. }
  313. if (priv->phyNum == 0) {
  314. data |= TLAN_NET_CFG_PHY_EN;
  315. }
  316. TLan_DioWrite16(BASE, TLAN_NET_CONFIG, (u16) data);
  317. if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY) {
  318. TLan_FinishReset(nic);
  319. } else {
  320. TLan_PhyPowerDown(nic);
  321. }
  322. } /* TLan_ResetAdapter */
  323. void TLan_FinishReset(struct nic *nic)
  324. {
  325. u8 data;
  326. u32 phy;
  327. u8 sio;
  328. u16 status;
  329. u16 partner;
  330. u16 tlphy_ctl;
  331. u16 tlphy_par;
  332. u16 tlphy_id1, tlphy_id2;
  333. int i;
  334. phy = priv->phy[priv->phyNum];
  335. data = TLAN_NET_CMD_NRESET | TLAN_NET_CMD_NWRAP;
  336. if (priv->tlanFullDuplex) {
  337. data |= TLAN_NET_CMD_DUPLEX;
  338. }
  339. TLan_DioWrite8(BASE, TLAN_NET_CMD, data);
  340. data = TLAN_NET_MASK_MASK4 | TLAN_NET_MASK_MASK5;
  341. if (priv->phyNum == 0) {
  342. data |= TLAN_NET_MASK_MASK7;
  343. }
  344. TLan_DioWrite8(BASE, TLAN_NET_MASK, data);
  345. TLan_DioWrite16(BASE, TLAN_MAX_RX, ((1536) + 7) & ~7);
  346. TLan_MiiReadReg(nic, phy, MII_GEN_ID_HI, &tlphy_id1);
  347. TLan_MiiReadReg(nic, phy, MII_GEN_ID_LO, &tlphy_id2);
  348. if ((tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY)
  349. || (priv->aui)) {
  350. status = MII_GS_LINK;
  351. dprintf(("TLAN: %s: Link forced.\n", priv->nic_name));
  352. } else {
  353. TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  354. udelay(1000);
  355. TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  356. if ((status & MII_GS_LINK) && /* We only support link info on Nat.Sem. PHY's */
  357. (tlphy_id1 == NAT_SEM_ID1)
  358. && (tlphy_id2 == NAT_SEM_ID2)) {
  359. TLan_MiiReadReg(nic, phy, MII_AN_LPA, &partner);
  360. TLan_MiiReadReg(nic, phy, TLAN_TLPHY_PAR,
  361. &tlphy_par);
  362. dprintf(("TLAN: %s: Link active with ",
  363. priv->nic_name));
  364. if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) {
  365. dprintf(("forced 10%sMbps %s-Duplex\n",
  366. tlphy_par & TLAN_PHY_SPEED_100 ? ""
  367. : "0",
  368. tlphy_par & TLAN_PHY_DUPLEX_FULL ?
  369. "Full" : "Half"));
  370. } else {
  371. dprintf
  372. (("AutoNegotiation enabled, at 10%sMbps %s-Duplex\n",
  373. tlphy_par & TLAN_PHY_SPEED_100 ? "" :
  374. "0",
  375. tlphy_par & TLAN_PHY_DUPLEX_FULL ?
  376. "Full" : "Half"));
  377. dprintf(("TLAN: Partner capability: "));
  378. for (i = 5; i <= 10; i++)
  379. if (partner & (1 << i))
  380. dprintf(("%s", media[i - 5]));
  381. dprintf(("\n"));
  382. }
  383. TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
  384. #ifdef MONITOR
  385. /* We have link beat..for now anyway */
  386. priv->link = 1;
  387. /*Enabling link beat monitoring */
  388. /* TLan_SetTimer( nic, (10*HZ), TLAN_TIMER_LINK_BEAT ); */
  389. mdelay(10000);
  390. TLan_PhyMonitor(nic);
  391. #endif
  392. } else if (status & MII_GS_LINK) {
  393. dprintf(("TLAN: %s: Link active\n", priv->nic_name));
  394. TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
  395. }
  396. }
  397. if (priv->phyNum == 0) {
  398. TLan_MiiReadReg(nic, phy, TLAN_TLPHY_CTL, &tlphy_ctl);
  399. tlphy_ctl |= TLAN_TC_INTEN;
  400. TLan_MiiWriteReg(nic, phy, TLAN_TLPHY_CTL, tlphy_ctl);
  401. sio = TLan_DioRead8(BASE, TLAN_NET_SIO);
  402. sio |= TLAN_NET_SIO_MINTEN;
  403. TLan_DioWrite8(BASE, TLAN_NET_SIO, sio);
  404. }
  405. if (status & MII_GS_LINK) {
  406. TLan_SetMac(nic, 0, nic->node_addr);
  407. priv->phyOnline = 1;
  408. outb((TLAN_HC_INT_ON >> 8), BASE + TLAN_HOST_CMD + 1);
  409. outl(virt_to_bus(&rx_ring), BASE + TLAN_CH_PARM);
  410. outl(TLAN_HC_GO | TLAN_HC_RT, BASE + TLAN_HOST_CMD);
  411. } else {
  412. dprintf
  413. (("TLAN: %s: Link inactive, will retry in 10 secs...\n",
  414. priv->nic_name));
  415. /* TLan_SetTimer( nic, (10*HZ), TLAN_TIMER_FINISH_RESET ); */
  416. mdelay(10000);
  417. TLan_FinishReset(nic);
  418. return;
  419. }
  420. } /* TLan_FinishReset */
  421. /**************************************************************************
  422. POLL - Wait for a frame
  423. ***************************************************************************/
  424. static int tlan_poll(struct nic *nic, int retrieve)
  425. {
  426. /* return true if there's an ethernet packet ready to read */
  427. /* nic->packet should contain data on return */
  428. /* nic->packetlen should contain length of data */
  429. u32 framesize;
  430. u32 host_cmd = 0;
  431. u32 ack = 1;
  432. int eoc = 0;
  433. int entry = priv->cur_rx % TLAN_NUM_RX_LISTS;
  434. u16 tmpCStat = le32_to_cpu(rx_ring[entry].cStat);
  435. u16 host_int = inw(BASE + TLAN_HOST_INT);
  436. if ((tmpCStat & TLAN_CSTAT_FRM_CMP) && !retrieve)
  437. return 1;
  438. outw(host_int, BASE + TLAN_HOST_INT);
  439. if (!(tmpCStat & TLAN_CSTAT_FRM_CMP))
  440. return 0;
  441. /* printf("PI-1: 0x%hX\n", host_int); */
  442. if (tmpCStat & TLAN_CSTAT_EOC)
  443. eoc = 1;
  444. framesize = rx_ring[entry].frameSize;
  445. nic->packetlen = framesize;
  446. dprintf((".%d.", framesize));
  447. memcpy(nic->packet, rxb +
  448. (priv->cur_rx * TLAN_MAX_FRAME_SIZE), nic->packetlen);
  449. rx_ring[entry].cStat = 0;
  450. dprintf(("%d", entry));
  451. entry = (entry + 1) % TLAN_NUM_RX_LISTS;
  452. priv->cur_rx = entry;
  453. if (eoc) {
  454. if ((rx_ring[entry].cStat & TLAN_CSTAT_READY) ==
  455. TLAN_CSTAT_READY) {
  456. ack |= TLAN_HC_GO | TLAN_HC_RT;
  457. host_cmd = TLAN_HC_ACK | ack | 0x001C0000;
  458. outl(host_cmd, BASE + TLAN_HOST_CMD);
  459. }
  460. } else {
  461. host_cmd = TLAN_HC_ACK | ack | (0x000C0000);
  462. outl(host_cmd, BASE + TLAN_HOST_CMD);
  463. dprintf(("AC: 0x%hX\n", inw(BASE + TLAN_CH_PARM)));
  464. dprintf(("PI-2: 0x%hX\n", inw(BASE + TLAN_HOST_INT)));
  465. }
  466. refill_rx(nic);
  467. return (1); /* initially as this is called to flush the input */
  468. }
  469. static void refill_rx(struct nic *nic __unused)
  470. {
  471. int entry = 0;
  472. for (;
  473. (priv->cur_rx - priv->dirty_rx +
  474. TLAN_NUM_RX_LISTS) % TLAN_NUM_RX_LISTS > 0;
  475. priv->dirty_rx = (priv->dirty_rx + 1) % TLAN_NUM_RX_LISTS) {
  476. entry = priv->dirty_rx % TLAN_NUM_TX_LISTS;
  477. rx_ring[entry].frameSize = TLAN_MAX_FRAME_SIZE;
  478. rx_ring[entry].cStat = TLAN_CSTAT_READY;
  479. }
  480. }
  481. /**************************************************************************
  482. TRANSMIT - Transmit a frame
  483. ***************************************************************************/
  484. static void tlan_transmit(struct nic *nic, const char *d, /* Destination */
  485. unsigned int t, /* Type */
  486. unsigned int s, /* size */
  487. const char *p)
  488. { /* Packet */
  489. u16 nstype;
  490. u32 to;
  491. struct TLanList *tail_list;
  492. struct TLanList *head_list;
  493. u8 *tail_buffer;
  494. u32 ack = 0;
  495. u32 host_cmd;
  496. int eoc = 0;
  497. u16 tmpCStat;
  498. #ifdef EBDEBUG
  499. u16 host_int = inw(BASE + TLAN_HOST_INT);
  500. #endif
  501. int entry = 0;
  502. dprintf(("INT0-0x%hX\n", host_int));
  503. if (!priv->phyOnline) {
  504. printf("TRANSMIT: %s PHY is not ready\n", priv->nic_name);
  505. return;
  506. }
  507. tail_list = priv->txList + priv->txTail;
  508. if (tail_list->cStat != TLAN_CSTAT_UNUSED) {
  509. printf("TRANSMIT: %s is busy (Head=%d Tail=%d)\n",
  510. priv->nic_name, priv->txList, priv->txTail);
  511. tx_ring[entry].cStat = TLAN_CSTAT_UNUSED;
  512. // priv->txBusyCount++;
  513. return;
  514. }
  515. tail_list->forward = 0;
  516. tail_buffer = txb + (priv->txTail * TLAN_MAX_FRAME_SIZE);
  517. /* send the packet to destination */
  518. memcpy(tail_buffer, d, ETH_ALEN);
  519. memcpy(tail_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN);
  520. nstype = htons((u16) t);
  521. memcpy(tail_buffer + 2 * ETH_ALEN, (u8 *) & nstype, 2);
  522. memcpy(tail_buffer + ETH_HLEN, p, s);
  523. s += ETH_HLEN;
  524. s &= 0x0FFF;
  525. while (s < ETH_ZLEN)
  526. tail_buffer[s++] = '\0';
  527. /*=====================================================*/
  528. /* Receive
  529. * 0000 0000 0001 1100
  530. * 0000 0000 0000 1100
  531. * 0000 0000 0000 0011 = 0x0003
  532. *
  533. * 0000 0000 0000 0000 0000 0000 0000 0011
  534. * 0000 0000 0000 1100 0000 0000 0000 0000 = 0x000C0000
  535. *
  536. * Transmit
  537. * 0000 0000 0001 1100
  538. * 0000 0000 0000 0100
  539. * 0000 0000 0000 0001 = 0x0001
  540. *
  541. * 0000 0000 0000 0000 0000 0000 0000 0001
  542. * 0000 0000 0000 0100 0000 0000 0000 0000 = 0x00040000
  543. * */
  544. /* Setup the transmit descriptor */
  545. tail_list->frameSize = (u16) s;
  546. tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) s;
  547. tail_list->buffer[1].count = 0;
  548. tail_list->buffer[1].address = 0;
  549. tail_list->cStat = TLAN_CSTAT_READY;
  550. dprintf(("INT1-0x%hX\n", inw(BASE + TLAN_HOST_INT)));
  551. if (!priv->txInProgress) {
  552. priv->txInProgress = 1;
  553. outl(virt_to_le32desc(tail_list), BASE + TLAN_CH_PARM);
  554. outl(TLAN_HC_GO, BASE + TLAN_HOST_CMD);
  555. } else {
  556. if (priv->txTail == 0) {
  557. dprintf(("Out buffer\n"));
  558. (priv->txList + (TLAN_NUM_TX_LISTS - 1))->forward =
  559. virt_to_le32desc(tail_list);
  560. } else {
  561. dprintf(("Fix this \n"));
  562. (priv->txList + (priv->txTail - 1))->forward =
  563. virt_to_le32desc(tail_list);
  564. }
  565. }
  566. CIRC_INC(priv->txTail, TLAN_NUM_TX_LISTS);
  567. dprintf(("INT2-0x%hX\n", inw(BASE + TLAN_HOST_INT)));
  568. to = currticks() + TX_TIME_OUT;
  569. while ((tail_list->cStat == TLAN_CSTAT_READY) && currticks() < to);
  570. head_list = priv->txList + priv->txHead;
  571. while (((tmpCStat = head_list->cStat) & TLAN_CSTAT_FRM_CMP)
  572. && (ack < 255)) {
  573. ack++;
  574. if(tmpCStat & TLAN_CSTAT_EOC)
  575. eoc =1;
  576. head_list->cStat = TLAN_CSTAT_UNUSED;
  577. CIRC_INC(priv->txHead, TLAN_NUM_TX_LISTS);
  578. head_list = priv->txList + priv->txHead;
  579. }
  580. if(!ack)
  581. printf("Incomplete TX Frame\n");
  582. if(eoc) {
  583. head_list = priv->txList + priv->txHead;
  584. if ((head_list->cStat & TLAN_CSTAT_READY) == TLAN_CSTAT_READY) {
  585. outl(virt_to_le32desc(head_list), BASE + TLAN_CH_PARM);
  586. ack |= TLAN_HC_GO;
  587. } else {
  588. priv->txInProgress = 0;
  589. }
  590. }
  591. if(ack) {
  592. host_cmd = TLAN_HC_ACK | ack;
  593. outl(host_cmd, BASE + TLAN_HOST_CMD);
  594. }
  595. if(priv->tlanRev < 0x30 ) {
  596. ack = 1;
  597. head_list = priv->txList + priv->txHead;
  598. if ((head_list->cStat & TLAN_CSTAT_READY) == TLAN_CSTAT_READY) {
  599. outl(virt_to_le32desc(head_list), BASE + TLAN_CH_PARM);
  600. ack |= TLAN_HC_GO;
  601. } else {
  602. priv->txInProgress = 0;
  603. }
  604. host_cmd = TLAN_HC_ACK | ack | 0x00140000;
  605. outl(host_cmd, BASE + TLAN_HOST_CMD);
  606. }
  607. if (currticks() >= to) {
  608. printf("TX Time Out");
  609. }
  610. }
  611. /**************************************************************************
  612. DISABLE - Turn off ethernet interface
  613. ***************************************************************************/
  614. static void tlan_disable ( struct nic *nic __unused ) {
  615. /* put the card in its initial state */
  616. /* This function serves 3 purposes.
  617. * This disables DMA and interrupts so we don't receive
  618. * unexpected packets or interrupts from the card after
  619. * etherboot has finished.
  620. * This frees resources so etherboot may use
  621. * this driver on another interface
  622. * This allows etherboot to reinitialize the interface
  623. * if something is something goes wrong.
  624. *
  625. */
  626. outl(TLAN_HC_AD_RST, BASE + TLAN_HOST_CMD);
  627. }
  628. /**************************************************************************
  629. IRQ - Enable, Disable, or Force interrupts
  630. ***************************************************************************/
  631. static void tlan_irq(struct nic *nic __unused, irq_action_t action __unused)
  632. {
  633. switch ( action ) {
  634. case DISABLE :
  635. break;
  636. case ENABLE :
  637. break;
  638. case FORCE :
  639. break;
  640. }
  641. }
  642. static void TLan_SetMulticastList(struct nic *nic) {
  643. int i;
  644. u8 tmp;
  645. /* !IFF_PROMISC */
  646. tmp = TLan_DioRead8(BASE, TLAN_NET_CMD);
  647. TLan_DioWrite8(BASE, TLAN_NET_CMD, tmp & ~TLAN_NET_CMD_CAF);
  648. /* IFF_ALLMULTI */
  649. for(i = 0; i< 3; i++)
  650. TLan_SetMac(nic, i + 1, NULL);
  651. TLan_DioWrite32(BASE, TLAN_HASH_1, 0xFFFFFFFF);
  652. TLan_DioWrite32(BASE, TLAN_HASH_2, 0xFFFFFFFF);
  653. }
  654. /**************************************************************************
  655. PROBE - Look for an adapter, this routine's visible to the outside
  656. ***************************************************************************/
  657. #define board_found 1
  658. #define valid_link 0
  659. static int tlan_probe ( struct dev *dev ) {
  660. struct nic *nic = nic_device ( dev );
  661. struct pci_device *pci = pci_device ( dev );
  662. u16 data = 0;
  663. int err;
  664. int i;
  665. if (pci->ioaddr == 0)
  666. return 0;
  667. nic->irqno = 0;
  668. nic->ioaddr = pci->ioaddr & ~3;
  669. BASE = pci->ioaddr;
  670. printf("tlan.c: Found %s, Vendor 0x%hX, Device 0x%hX\n",
  671. pci->name, pci->vendor, pci->dev_id);
  672. /* Set nic as PCI bus master */
  673. adjust_pci_device(pci);
  674. /* Point to private storage */
  675. priv = &TLanPrivateInfo;
  676. /* Figure out which chip we're dealing with */
  677. i = 0;
  678. chip_idx = -1;
  679. while (tlan_pci_tbl[i].name) {
  680. if ((((u32) pci->dev_id << 16) | pci->vendor) ==
  681. (tlan_pci_tbl[i].id.pci & 0xffffffff)) {
  682. chip_idx = i;
  683. break;
  684. }
  685. i++;
  686. }
  687. priv->vendor_id = pci->vendor;
  688. priv->dev_id = pci->dev_id;
  689. priv->nic_name = pci->name;
  690. priv->eoc = 0;
  691. err = 0;
  692. for (i = 0; i < 6; i++)
  693. err |= TLan_EeReadByte(BASE,
  694. (u8) tlan_pci_tbl[chip_idx].
  695. addrOfs + i,
  696. (u8 *) & nic->node_addr[i]);
  697. if (err) {
  698. printf("TLAN: %s: Error reading MAC from eeprom: %d\n",
  699. pci->name, err);
  700. } else
  701. /* Print out some hardware info */
  702. printf("%s: %! at ioaddr %hX, ",
  703. pci->name, nic->node_addr, pci->ioaddr);
  704. priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
  705. printf("revision: 0x%hX\n", priv->tlanRev);
  706. TLan_ResetLists(nic);
  707. TLan_ResetAdapter(nic);
  708. data = inl(BASE + TLAN_HOST_CMD);
  709. data |= TLAN_HC_INT_OFF;
  710. outw(data, BASE + TLAN_HOST_CMD);
  711. TLan_SetMulticastList(nic);
  712. udelay(100);
  713. priv->txList = tx_ring;
  714. /* if (board_found && valid_link)
  715. {*/
  716. /* point to NIC specific routines */
  717. dev->disable = tlan_disable;
  718. nic->poll = tlan_poll;
  719. nic->transmit = tlan_transmit;
  720. nic->irq = tlan_irq;
  721. return 1;
  722. }
  723. /*****************************************************************************
  724. ******************************************************************************
  725. ThunderLAN Driver Eeprom routines
  726. The Compaq Netelligent 10 and 10/100 cards use a Microchip 24C02A
  727. EEPROM. These functions are based on information in Microchip's
  728. data sheet. I don't know how well this functions will work with
  729. other EEPROMs.
  730. ******************************************************************************
  731. *****************************************************************************/
  732. /***************************************************************
  733. * TLan_EeSendStart
  734. *
  735. * Returns:
  736. * Nothing
  737. * Parms:
  738. * io_base The IO port base address for the
  739. * TLAN device with the EEPROM to
  740. * use.
  741. *
  742. * This function sends a start cycle to an EEPROM attached
  743. * to a TLAN chip.
  744. *
  745. **************************************************************/
  746. void TLan_EeSendStart(u16 io_base)
  747. {
  748. u16 sio;
  749. outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  750. sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  751. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  752. TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  753. TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  754. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio);
  755. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  756. } /* TLan_EeSendStart */
  757. /***************************************************************
  758. * TLan_EeSendByte
  759. *
  760. * Returns:
  761. * If the correct ack was received, 0, otherwise 1
  762. * Parms: io_base The IO port base address for the
  763. * TLAN device with the EEPROM to
  764. * use.
  765. * data The 8 bits of information to
  766. * send to the EEPROM.
  767. * stop If TLAN_EEPROM_STOP is passed, a
  768. * stop cycle is sent after the
  769. * byte is sent after the ack is
  770. * read.
  771. *
  772. * This function sends a byte on the serial EEPROM line,
  773. * driving the clock to send each bit. The function then
  774. * reverses transmission direction and reads an acknowledge
  775. * bit.
  776. *
  777. **************************************************************/
  778. int TLan_EeSendByte(u16 io_base, u8 data, int stop)
  779. {
  780. int err;
  781. u8 place;
  782. u16 sio;
  783. outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  784. sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  785. /* Assume clock is low, tx is enabled; */
  786. for (place = 0x80; place != 0; place >>= 1) {
  787. if (place & data)
  788. TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  789. else
  790. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio);
  791. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  792. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  793. }
  794. TLan_ClearBit(TLAN_NET_SIO_ETXEN, sio);
  795. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  796. err = TLan_GetBit(TLAN_NET_SIO_EDATA, sio);
  797. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  798. TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  799. if ((!err) && stop) {
  800. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* STOP, raise data while clock is high */
  801. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  802. TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  803. }
  804. return (err);
  805. } /* TLan_EeSendByte */
  806. /***************************************************************
  807. * TLan_EeReceiveByte
  808. *
  809. * Returns:
  810. * Nothing
  811. * Parms:
  812. * io_base The IO port base address for the
  813. * TLAN device with the EEPROM to
  814. * use.
  815. * data An address to a char to hold the
  816. * data sent from the EEPROM.
  817. * stop If TLAN_EEPROM_STOP is passed, a
  818. * stop cycle is sent after the
  819. * byte is received, and no ack is
  820. * sent.
  821. *
  822. * This function receives 8 bits of data from the EEPROM
  823. * over the serial link. It then sends and ack bit, or no
  824. * ack and a stop bit. This function is used to retrieve
  825. * data after the address of a byte in the EEPROM has been
  826. * sent.
  827. *
  828. **************************************************************/
  829. void TLan_EeReceiveByte(u16 io_base, u8 * data, int stop)
  830. {
  831. u8 place;
  832. u16 sio;
  833. outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  834. sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  835. *data = 0;
  836. /* Assume clock is low, tx is enabled; */
  837. TLan_ClearBit(TLAN_NET_SIO_ETXEN, sio);
  838. for (place = 0x80; place; place >>= 1) {
  839. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  840. if (TLan_GetBit(TLAN_NET_SIO_EDATA, sio))
  841. *data |= place;
  842. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  843. }
  844. TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  845. if (!stop) {
  846. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* Ack = 0 */
  847. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  848. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  849. } else {
  850. TLan_SetBit(TLAN_NET_SIO_EDATA, sio); /* No ack = 1 (?) */
  851. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  852. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  853. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* STOP, raise data while clock is high */
  854. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  855. TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  856. }
  857. } /* TLan_EeReceiveByte */
  858. /***************************************************************
  859. * TLan_EeReadByte
  860. *
  861. * Returns:
  862. * No error = 0, else, the stage at which the error
  863. * occurred.
  864. * Parms:
  865. * io_base The IO port base address for the
  866. * TLAN device with the EEPROM to
  867. * use.
  868. * ee_addr The address of the byte in the
  869. * EEPROM whose contents are to be
  870. * retrieved.
  871. * data An address to a char to hold the
  872. * data obtained from the EEPROM.
  873. *
  874. * This function reads a byte of information from an byte
  875. * cell in the EEPROM.
  876. *
  877. **************************************************************/
  878. int TLan_EeReadByte(u16 io_base, u8 ee_addr, u8 * data)
  879. {
  880. int err;
  881. int ret = 0;
  882. TLan_EeSendStart(io_base);
  883. err = TLan_EeSendByte(io_base, 0xA0, TLAN_EEPROM_ACK);
  884. if (err) {
  885. ret = 1;
  886. goto fail;
  887. }
  888. err = TLan_EeSendByte(io_base, ee_addr, TLAN_EEPROM_ACK);
  889. if (err) {
  890. ret = 2;
  891. goto fail;
  892. }
  893. TLan_EeSendStart(io_base);
  894. err = TLan_EeSendByte(io_base, 0xA1, TLAN_EEPROM_ACK);
  895. if (err) {
  896. ret = 3;
  897. goto fail;
  898. }
  899. TLan_EeReceiveByte(io_base, data, TLAN_EEPROM_STOP);
  900. fail:
  901. return ret;
  902. } /* TLan_EeReadByte */
  903. /*****************************************************************************
  904. ******************************************************************************
  905. ThunderLAN Driver MII Routines
  906. These routines are based on the information in Chap. 2 of the
  907. "ThunderLAN Programmer's Guide", pp. 15-24.
  908. ******************************************************************************
  909. *****************************************************************************/
  910. /***************************************************************
  911. * TLan_MiiReadReg
  912. *
  913. * Returns:
  914. * 0 if ack received ok
  915. * 1 otherwise.
  916. *
  917. * Parms:
  918. * dev The device structure containing
  919. * The io address and interrupt count
  920. * for this device.
  921. * phy The address of the PHY to be queried.
  922. * reg The register whose contents are to be
  923. * retreived.
  924. * val A pointer to a variable to store the
  925. * retrieved value.
  926. *
  927. * This function uses the TLAN's MII bus to retreive the contents
  928. * of a given register on a PHY. It sends the appropriate info
  929. * and then reads the 16-bit register value from the MII bus via
  930. * the TLAN SIO register.
  931. *
  932. **************************************************************/
  933. int TLan_MiiReadReg(struct nic *nic __unused, u16 phy, u16 reg, u16 * val)
  934. {
  935. u8 nack;
  936. u16 sio, tmp;
  937. u32 i;
  938. int err;
  939. int minten;
  940. err = FALSE;
  941. outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  942. sio = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  943. TLan_MiiSync(BASE);
  944. minten = TLan_GetBit(TLAN_NET_SIO_MINTEN, sio);
  945. if (minten)
  946. TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  947. TLan_MiiSendData(BASE, 0x1, 2); /* Start ( 01b ) */
  948. TLan_MiiSendData(BASE, 0x2, 2); /* Read ( 10b ) */
  949. TLan_MiiSendData(BASE, phy, 5); /* Device # */
  950. TLan_MiiSendData(BASE, reg, 5); /* Register # */
  951. TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio); /* Change direction */
  952. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Clock Idle bit */
  953. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  954. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Wait 300ns */
  955. nack = TLan_GetBit(TLAN_NET_SIO_MDATA, sio); /* Check for ACK */
  956. TLan_SetBit(TLAN_NET_SIO_MCLK, sio); /* Finish ACK */
  957. if (nack) { /* No ACK, so fake it */
  958. for (i = 0; i < 16; i++) {
  959. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  960. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  961. }
  962. tmp = 0xffff;
  963. err = TRUE;
  964. } else { /* ACK, so read data */
  965. for (tmp = 0, i = 0x8000; i; i >>= 1) {
  966. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  967. if (TLan_GetBit(TLAN_NET_SIO_MDATA, sio))
  968. tmp |= i;
  969. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  970. }
  971. }
  972. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  973. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  974. if (minten)
  975. TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  976. *val = tmp;
  977. return err;
  978. } /* TLan_MiiReadReg */
  979. /***************************************************************
  980. * TLan_MiiSendData
  981. *
  982. * Returns:
  983. * Nothing
  984. * Parms:
  985. * base_port The base IO port of the adapter in
  986. * question.
  987. * dev The address of the PHY to be queried.
  988. * data The value to be placed on the MII bus.
  989. * num_bits The number of bits in data that are to
  990. * be placed on the MII bus.
  991. *
  992. * This function sends on sequence of bits on the MII
  993. * configuration bus.
  994. *
  995. **************************************************************/
  996. void TLan_MiiSendData(u16 base_port, u32 data, unsigned num_bits)
  997. {
  998. u16 sio;
  999. u32 i;
  1000. if (num_bits == 0)
  1001. return;
  1002. outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
  1003. sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  1004. TLan_SetBit(TLAN_NET_SIO_MTXEN, sio);
  1005. for (i = (0x1 << (num_bits - 1)); i; i >>= 1) {
  1006. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  1007. (void) TLan_GetBit(TLAN_NET_SIO_MCLK, sio);
  1008. if (data & i)
  1009. TLan_SetBit(TLAN_NET_SIO_MDATA, sio);
  1010. else
  1011. TLan_ClearBit(TLAN_NET_SIO_MDATA, sio);
  1012. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  1013. (void) TLan_GetBit(TLAN_NET_SIO_MCLK, sio);
  1014. }
  1015. } /* TLan_MiiSendData */
  1016. /***************************************************************
  1017. * TLan_MiiSync
  1018. *
  1019. * Returns:
  1020. * Nothing
  1021. * Parms:
  1022. * base_port The base IO port of the adapter in
  1023. * question.
  1024. *
  1025. * This functions syncs all PHYs in terms of the MII configuration
  1026. * bus.
  1027. *
  1028. **************************************************************/
  1029. void TLan_MiiSync(u16 base_port)
  1030. {
  1031. int i;
  1032. u16 sio;
  1033. outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
  1034. sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  1035. TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio);
  1036. for (i = 0; i < 32; i++) {
  1037. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  1038. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  1039. }
  1040. } /* TLan_MiiSync */
  1041. /***************************************************************
  1042. * TLan_MiiWriteReg
  1043. *
  1044. * Returns:
  1045. * Nothing
  1046. * Parms:
  1047. * dev The device structure for the device
  1048. * to write to.
  1049. * phy The address of the PHY to be written to.
  1050. * reg The register whose contents are to be
  1051. * written.
  1052. * val The value to be written to the register.
  1053. *
  1054. * This function uses the TLAN's MII bus to write the contents of a
  1055. * given register on a PHY. It sends the appropriate info and then
  1056. * writes the 16-bit register value from the MII configuration bus
  1057. * via the TLAN SIO register.
  1058. *
  1059. **************************************************************/
  1060. void TLan_MiiWriteReg(struct nic *nic __unused, u16 phy, u16 reg, u16 val)
  1061. {
  1062. u16 sio;
  1063. int minten;
  1064. outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  1065. sio = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  1066. TLan_MiiSync(BASE);
  1067. minten = TLan_GetBit(TLAN_NET_SIO_MINTEN, sio);
  1068. if (minten)
  1069. TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  1070. TLan_MiiSendData(BASE, 0x1, 2); /* Start ( 01b ) */
  1071. TLan_MiiSendData(BASE, 0x1, 2); /* Write ( 01b ) */
  1072. TLan_MiiSendData(BASE, phy, 5); /* Device # */
  1073. TLan_MiiSendData(BASE, reg, 5); /* Register # */
  1074. TLan_MiiSendData(BASE, 0x2, 2); /* Send ACK */
  1075. TLan_MiiSendData(BASE, val, 16); /* Send Data */
  1076. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  1077. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  1078. if (minten)
  1079. TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  1080. } /* TLan_MiiWriteReg */
  1081. /***************************************************************
  1082. * TLan_SetMac
  1083. *
  1084. * Returns:
  1085. * Nothing
  1086. * Parms:
  1087. * dev Pointer to device structure of adapter
  1088. * on which to change the AREG.
  1089. * areg The AREG to set the address in (0 - 3).
  1090. * mac A pointer to an array of chars. Each
  1091. * element stores one byte of the address.
  1092. * IE, it isn't in ascii.
  1093. *
  1094. * This function transfers a MAC address to one of the
  1095. * TLAN AREGs (address registers). The TLAN chip locks
  1096. * the register on writing to offset 0 and unlocks the
  1097. * register after writing to offset 5. If NULL is passed
  1098. * in mac, then the AREG is filled with 0's.
  1099. *
  1100. **************************************************************/
  1101. void TLan_SetMac(struct nic *nic __unused, int areg, char *mac)
  1102. {
  1103. int i;
  1104. areg *= 6;
  1105. if (mac != NULL) {
  1106. for (i = 0; i < 6; i++)
  1107. TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i,
  1108. mac[i]);
  1109. } else {
  1110. for (i = 0; i < 6; i++)
  1111. TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i, 0);
  1112. }
  1113. } /* TLan_SetMac */
  1114. /*********************************************************************
  1115. * TLan_PhyDetect
  1116. *
  1117. * Returns:
  1118. * Nothing
  1119. * Parms:
  1120. * dev A pointer to the device structure of the adapter
  1121. * for which the PHY needs determined.
  1122. *
  1123. * So far I've found that adapters which have external PHYs
  1124. * may also use the internal PHY for part of the functionality.
  1125. * (eg, AUI/Thinnet). This function finds out if this TLAN
  1126. * chip has an internal PHY, and then finds the first external
  1127. * PHY (starting from address 0) if it exists).
  1128. *
  1129. ********************************************************************/
  1130. void TLan_PhyDetect(struct nic *nic)
  1131. {
  1132. u16 control;
  1133. u16 hi;
  1134. u16 lo;
  1135. u32 phy;
  1136. if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY) {
  1137. priv->phyNum = 0xFFFF;
  1138. return;
  1139. }
  1140. TLan_MiiReadReg(nic, TLAN_PHY_MAX_ADDR, MII_GEN_ID_HI, &hi);
  1141. if (hi != 0xFFFF) {
  1142. priv->phy[0] = TLAN_PHY_MAX_ADDR;
  1143. } else {
  1144. priv->phy[0] = TLAN_PHY_NONE;
  1145. }
  1146. priv->phy[1] = TLAN_PHY_NONE;
  1147. for (phy = 0; phy <= TLAN_PHY_MAX_ADDR; phy++) {
  1148. TLan_MiiReadReg(nic, phy, MII_GEN_CTL, &control);
  1149. TLan_MiiReadReg(nic, phy, MII_GEN_ID_HI, &hi);
  1150. TLan_MiiReadReg(nic, phy, MII_GEN_ID_LO, &lo);
  1151. if ((control != 0xFFFF) || (hi != 0xFFFF)
  1152. || (lo != 0xFFFF)) {
  1153. printf("PHY found at %hX %hX %hX %hX\n", phy,
  1154. control, hi, lo);
  1155. if ((priv->phy[1] == TLAN_PHY_NONE)
  1156. && (phy != TLAN_PHY_MAX_ADDR)) {
  1157. priv->phy[1] = phy;
  1158. }
  1159. }
  1160. }
  1161. if (priv->phy[1] != TLAN_PHY_NONE) {
  1162. priv->phyNum = 1;
  1163. } else if (priv->phy[0] != TLAN_PHY_NONE) {
  1164. priv->phyNum = 0;
  1165. } else {
  1166. printf
  1167. ("TLAN: Cannot initialize device, no PHY was found!\n");
  1168. }
  1169. } /* TLan_PhyDetect */
  1170. void TLan_PhyPowerDown(struct nic *nic)
  1171. {
  1172. u16 value;
  1173. dprintf(("%s: Powering down PHY(s).\n", priv->nic_name));
  1174. value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE;
  1175. TLan_MiiSync(BASE);
  1176. TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
  1177. if ((priv->phyNum == 0) && (priv->phy[1] != TLAN_PHY_NONE)
  1178. &&
  1179. (!(tlan_pci_tbl[chip_idx].
  1180. flags & TLAN_ADAPTER_USE_INTERN_10))) {
  1181. TLan_MiiSync(BASE);
  1182. TLan_MiiWriteReg(nic, priv->phy[1], MII_GEN_CTL, value);
  1183. }
  1184. /* Wait for 50 ms and powerup
  1185. * This is abitrary. It is intended to make sure the
  1186. * tranceiver settles.
  1187. */
  1188. /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_PUP ); */
  1189. mdelay(50);
  1190. TLan_PhyPowerUp(nic);
  1191. } /* TLan_PhyPowerDown */
  1192. void TLan_PhyPowerUp(struct nic *nic)
  1193. {
  1194. u16 value;
  1195. dprintf(("%s: Powering up PHY.\n", priv->nic_name));
  1196. TLan_MiiSync(BASE);
  1197. value = MII_GC_LOOPBK;
  1198. TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
  1199. TLan_MiiSync(BASE);
  1200. /* Wait for 500 ms and reset the
  1201. * tranceiver. The TLAN docs say both 50 ms and
  1202. * 500 ms, so do the longer, just in case.
  1203. */
  1204. mdelay(500);
  1205. TLan_PhyReset(nic);
  1206. /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_RESET ); */
  1207. } /* TLan_PhyPowerUp */
  1208. void TLan_PhyReset(struct nic *nic)
  1209. {
  1210. u16 phy;
  1211. u16 value;
  1212. phy = priv->phy[priv->phyNum];
  1213. dprintf(("%s: Reseting PHY.\n", priv->nic_name));
  1214. TLan_MiiSync(BASE);
  1215. value = MII_GC_LOOPBK | MII_GC_RESET;
  1216. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, value);
  1217. TLan_MiiReadReg(nic, phy, MII_GEN_CTL, &value);
  1218. while (value & MII_GC_RESET) {
  1219. TLan_MiiReadReg(nic, phy, MII_GEN_CTL, &value);
  1220. }
  1221. /* Wait for 500 ms and initialize.
  1222. * I don't remember why I wait this long.
  1223. * I've changed this to 50ms, as it seems long enough.
  1224. */
  1225. /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_START_LINK ); */
  1226. mdelay(50);
  1227. TLan_PhyStartLink(nic);
  1228. } /* TLan_PhyReset */
  1229. void TLan_PhyStartLink(struct nic *nic)
  1230. {
  1231. u16 ability;
  1232. u16 control;
  1233. u16 data;
  1234. u16 phy;
  1235. u16 status;
  1236. u16 tctl;
  1237. phy = priv->phy[priv->phyNum];
  1238. dprintf(("%s: Trying to activate link.\n", priv->nic_name));
  1239. TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  1240. TLan_MiiReadReg(nic, phy, MII_GEN_STS, &ability);
  1241. if ((status & MII_GS_AUTONEG) && (!priv->aui)) {
  1242. ability = status >> 11;
  1243. if (priv->speed == TLAN_SPEED_10 &&
  1244. priv->duplex == TLAN_DUPLEX_HALF) {
  1245. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x0000);
  1246. } else if (priv->speed == TLAN_SPEED_10 &&
  1247. priv->duplex == TLAN_DUPLEX_FULL) {
  1248. priv->tlanFullDuplex = TRUE;
  1249. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x0100);
  1250. } else if (priv->speed == TLAN_SPEED_100 &&
  1251. priv->duplex == TLAN_DUPLEX_HALF) {
  1252. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x2000);
  1253. } else if (priv->speed == TLAN_SPEED_100 &&
  1254. priv->duplex == TLAN_DUPLEX_FULL) {
  1255. priv->tlanFullDuplex = TRUE;
  1256. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x2100);
  1257. } else {
  1258. /* Set Auto-Neg advertisement */
  1259. TLan_MiiWriteReg(nic, phy, MII_AN_ADV,
  1260. (ability << 5) | 1);
  1261. /* Enablee Auto-Neg */
  1262. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x1000);
  1263. /* Restart Auto-Neg */
  1264. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x1200);
  1265. /* Wait for 4 sec for autonegotiation
  1266. * to complete. The max spec time is less than this
  1267. * but the card need additional time to start AN.
  1268. * .5 sec should be plenty extra.
  1269. */
  1270. dprintf(("TLAN: %s: Starting autonegotiation.\n",
  1271. priv->nic_name));
  1272. mdelay(4000);
  1273. TLan_PhyFinishAutoNeg(nic);
  1274. /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
  1275. return;
  1276. }
  1277. }
  1278. if ((priv->aui) && (priv->phyNum != 0)) {
  1279. priv->phyNum = 0;
  1280. data =
  1281. TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN |
  1282. TLAN_NET_CFG_PHY_EN;
  1283. TLan_DioWrite16(BASE, TLAN_NET_CONFIG, data);
  1284. mdelay(50);
  1285. /* TLan_SetTimer( dev, (40*HZ/1000), TLAN_TIMER_PHY_PDOWN ); */
  1286. TLan_PhyPowerDown(nic);
  1287. return;
  1288. } else if (priv->phyNum == 0) {
  1289. control = 0;
  1290. TLan_MiiReadReg(nic, phy, TLAN_TLPHY_CTL, &tctl);
  1291. if (priv->aui) {
  1292. tctl |= TLAN_TC_AUISEL;
  1293. } else {
  1294. tctl &= ~TLAN_TC_AUISEL;
  1295. if (priv->duplex == TLAN_DUPLEX_FULL) {
  1296. control |= MII_GC_DUPLEX;
  1297. priv->tlanFullDuplex = TRUE;
  1298. }
  1299. if (priv->speed == TLAN_SPEED_100) {
  1300. control |= MII_GC_SPEEDSEL;
  1301. }
  1302. }
  1303. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, control);
  1304. TLan_MiiWriteReg(nic, phy, TLAN_TLPHY_CTL, tctl);
  1305. }
  1306. /* Wait for 2 sec to give the tranceiver time
  1307. * to establish link.
  1308. */
  1309. /* TLan_SetTimer( dev, (4*HZ), TLAN_TIMER_FINISH_RESET ); */
  1310. mdelay(2000);
  1311. TLan_FinishReset(nic);
  1312. } /* TLan_PhyStartLink */
  1313. void TLan_PhyFinishAutoNeg(struct nic *nic)
  1314. {
  1315. u16 an_adv;
  1316. u16 an_lpa;
  1317. u16 data;
  1318. u16 mode;
  1319. u16 phy;
  1320. u16 status;
  1321. phy = priv->phy[priv->phyNum];
  1322. TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  1323. udelay(1000);
  1324. TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  1325. if (!(status & MII_GS_AUTOCMPLT)) {
  1326. /* Wait for 8 sec to give the process
  1327. * more time. Perhaps we should fail after a while.
  1328. */
  1329. if (!priv->neg_be_verbose++) {
  1330. printf
  1331. ("TLAN: Giving autonegotiation more time.\n");
  1332. printf
  1333. ("TLAN: Please check that your adapter has\n");
  1334. printf
  1335. ("TLAN: been properly connected to a HUB or Switch.\n");
  1336. printf
  1337. ("TLAN: Trying to establish link in the background...\n");
  1338. }
  1339. mdelay(8000);
  1340. TLan_PhyFinishAutoNeg(nic);
  1341. /* TLan_SetTimer( dev, (8*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
  1342. return;
  1343. }
  1344. dprintf(("TLAN: %s: Autonegotiation complete.\n", priv->nic_name));
  1345. TLan_MiiReadReg(nic, phy, MII_AN_ADV, &an_adv);
  1346. TLan_MiiReadReg(nic, phy, MII_AN_LPA, &an_lpa);
  1347. mode = an_adv & an_lpa & 0x03E0;
  1348. if (mode & 0x0100) {
  1349. printf("Full Duplex\n");
  1350. priv->tlanFullDuplex = TRUE;
  1351. } else if (!(mode & 0x0080) && (mode & 0x0040)) {
  1352. priv->tlanFullDuplex = TRUE;
  1353. printf("Full Duplex\n");
  1354. }
  1355. if ((!(mode & 0x0180))
  1356. && (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_USE_INTERN_10)
  1357. && (priv->phyNum != 0)) {
  1358. priv->phyNum = 0;
  1359. data =
  1360. TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN |
  1361. TLAN_NET_CFG_PHY_EN;
  1362. TLan_DioWrite16(BASE, TLAN_NET_CONFIG, data);
  1363. /* TLan_SetTimer( nic, (400*HZ/1000), TLAN_TIMER_PHY_PDOWN ); */
  1364. mdelay(400);
  1365. TLan_PhyPowerDown(nic);
  1366. return;
  1367. }
  1368. if (priv->phyNum == 0) {
  1369. if ((priv->duplex == TLAN_DUPLEX_FULL)
  1370. || (an_adv & an_lpa & 0x0040)) {
  1371. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
  1372. MII_GC_AUTOENB | MII_GC_DUPLEX);
  1373. dprintf
  1374. (("TLAN: Starting internal PHY with FULL-DUPLEX\n"));
  1375. } else {
  1376. TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
  1377. MII_GC_AUTOENB);
  1378. dprintf
  1379. (("TLAN: Starting internal PHY with HALF-DUPLEX\n"));
  1380. }
  1381. }
  1382. /* Wait for 100 ms. No reason in partiticular.
  1383. */
  1384. /* TLan_SetTimer( dev, (HZ/10), TLAN_TIMER_FINISH_RESET ); */
  1385. mdelay(100);
  1386. TLan_FinishReset(nic);
  1387. } /* TLan_PhyFinishAutoNeg */
  1388. #ifdef MONITOR
  1389. /*********************************************************************
  1390. *
  1391. * TLan_phyMonitor
  1392. *
  1393. * Returns:
  1394. * None
  1395. *
  1396. * Params:
  1397. * dev The device structure of this device.
  1398. *
  1399. *
  1400. * This function monitors PHY condition by reading the status
  1401. * register via the MII bus. This can be used to give info
  1402. * about link changes (up/down), and possible switch to alternate
  1403. * media.
  1404. *
  1405. ********************************************************************/
  1406. void TLan_PhyMonitor(struct net_device *dev)
  1407. {
  1408. TLanPrivateInfo *priv = dev->priv;
  1409. u16 phy;
  1410. u16 phy_status;
  1411. phy = priv->phy[priv->phyNum];
  1412. /* Get PHY status register */
  1413. TLan_MiiReadReg(nic, phy, MII_GEN_STS, &phy_status);
  1414. /* Check if link has been lost */
  1415. if (!(phy_status & MII_GS_LINK)) {
  1416. if (priv->link) {
  1417. priv->link = 0;
  1418. printf("TLAN: %s has lost link\n", priv->nic_name);
  1419. priv->flags &= ~IFF_RUNNING;
  1420. mdelay(2000);
  1421. TLan_PhyMonitor(nic);
  1422. /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); */
  1423. return;
  1424. }
  1425. }
  1426. /* Link restablished? */
  1427. if ((phy_status & MII_GS_LINK) && !priv->link) {
  1428. priv->link = 1;
  1429. printf("TLAN: %s has reestablished link\n",
  1430. priv->nic_name);
  1431. priv->flags |= IFF_RUNNING;
  1432. }
  1433. /* Setup a new monitor */
  1434. /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); */
  1435. mdelay(2000);
  1436. TLan_PhyMonitor(nic);
  1437. }
  1438. #endif /* MONITOR */
  1439. static struct pci_id tlan_nics[] = {
  1440. PCI_ROM(0x0e11, 0xae34, "netel10", "Compaq Netelligent 10 T PCI UTP"),
  1441. PCI_ROM(0x0e11, 0xae32, "netel100","Compaq Netelligent 10/100 TX PCI UTP"),
  1442. PCI_ROM(0x0e11, 0xae35, "netflex3i", "Compaq Integrated NetFlex-3/P"),
  1443. PCI_ROM(0x0e11, 0xf130, "thunder", "Compaq NetFlex-3/P"),
  1444. PCI_ROM(0x0e11, 0xf150, "netflex3b", "Compaq NetFlex-3/P"),
  1445. PCI_ROM(0x0e11, 0xae43, "netel100pi", "Compaq Netelligent Integrated 10/100 TX UTP"),
  1446. PCI_ROM(0x0e11, 0xae40, "netel100d", "Compaq Netelligent Dual 10/100 TX PCI UTP"),
  1447. PCI_ROM(0x0e11, 0xb011, "netel100i", "Compaq Netelligent 10/100 TX Embedded UTP"),
  1448. PCI_ROM(0x108d, 0x0013, "oc2183", "Olicom OC-2183/2185"),
  1449. PCI_ROM(0x108d, 0x0012, "oc2325", "Olicom OC-2325"),
  1450. PCI_ROM(0x108d, 0x0014, "oc2326", "Olicom OC-2326"),
  1451. PCI_ROM(0x0e11, 0xb030, "netelligent_10_100_ws_5100", "Compaq Netelligent 10/100 TX UTP"),
  1452. PCI_ROM(0x0e11, 0xb012, "netelligent_10_t2", "Compaq Netelligent 10 T/2 PCI UTP/Coax"),
  1453. };
  1454. static struct pci_driver tlan_driver =
  1455. PCI_DRIVER ( "TLAN/PCI", tlan_nics, PCI_NO_CLASS );
  1456. BOOT_DRIVER ( "TLAN/PCI", tlan_probe );