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