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

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