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

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