Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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