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

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