Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

tlan.c 46KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724
  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", 0
  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. {0, 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. priv->vendor_id = pci->vendor;
  689. priv->dev_id = pci->device;
  690. priv->nic_name = pci->id->name;
  691. priv->eoc = 0;
  692. err = 0;
  693. for (i = 0; i < 6; i++)
  694. err |= TLan_EeReadByte(BASE,
  695. (u8) tlan_pci_tbl[chip_idx].
  696. addrOfs + i,
  697. (u8 *) & nic->node_addr[i]);
  698. if (err) {
  699. printf ( "TLAN: %s: Error reading MAC from eeprom: %d\n",
  700. pci->id->name, err);
  701. } else {
  702. DBG ( "%s: %s at ioaddr %#lX, ",
  703. pci->id->name, eth_ntoa ( nic->node_addr ), pci->ioaddr );
  704. }
  705. priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
  706. printf("revision: 0x%hX\n", priv->tlanRev);
  707. TLan_ResetLists(nic);
  708. TLan_ResetAdapter(nic);
  709. data = inl(BASE + TLAN_HOST_CMD);
  710. data |= TLAN_HC_INT_OFF;
  711. outw(data, BASE + TLAN_HOST_CMD);
  712. TLan_SetMulticastList(nic);
  713. udelay(100);
  714. priv->txList = tx_ring;
  715. /* if (board_found && valid_link)
  716. {*/
  717. /* point to NIC specific routines */
  718. nic->nic_op = &tlan_operations;
  719. return 1;
  720. }
  721. /*****************************************************************************
  722. ******************************************************************************
  723. ThunderLAN Driver Eeprom routines
  724. The Compaq Netelligent 10 and 10/100 cards use a Microchip 24C02A
  725. EEPROM. These functions are based on information in Microchip's
  726. data sheet. I don't know how well this functions will work with
  727. other EEPROMs.
  728. ******************************************************************************
  729. *****************************************************************************/
  730. /***************************************************************
  731. * TLan_EeSendStart
  732. *
  733. * Returns:
  734. * Nothing
  735. * Parms:
  736. * io_base The IO port base address for the
  737. * TLAN device with the EEPROM to
  738. * use.
  739. *
  740. * This function sends a start cycle to an EEPROM attached
  741. * to a TLAN chip.
  742. *
  743. **************************************************************/
  744. void TLan_EeSendStart(u16 io_base)
  745. {
  746. u16 sio;
  747. outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  748. sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  749. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  750. TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  751. TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  752. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio);
  753. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  754. } /* TLan_EeSendStart */
  755. /***************************************************************
  756. * TLan_EeSendByte
  757. *
  758. * Returns:
  759. * If the correct ack was received, 0, otherwise 1
  760. * Parms: io_base The IO port base address for the
  761. * TLAN device with the EEPROM to
  762. * use.
  763. * data The 8 bits of information to
  764. * send to the EEPROM.
  765. * stop If TLAN_EEPROM_STOP is passed, a
  766. * stop cycle is sent after the
  767. * byte is sent after the ack is
  768. * read.
  769. *
  770. * This function sends a byte on the serial EEPROM line,
  771. * driving the clock to send each bit. The function then
  772. * reverses transmission direction and reads an acknowledge
  773. * bit.
  774. *
  775. **************************************************************/
  776. int TLan_EeSendByte(u16 io_base, u8 data, int stop)
  777. {
  778. int err;
  779. u8 place;
  780. u16 sio;
  781. outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  782. sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  783. /* Assume clock is low, tx is enabled; */
  784. for (place = 0x80; place != 0; place >>= 1) {
  785. if (place & data)
  786. TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  787. else
  788. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio);
  789. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  790. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  791. }
  792. TLan_ClearBit(TLAN_NET_SIO_ETXEN, sio);
  793. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  794. err = TLan_GetBit(TLAN_NET_SIO_EDATA, sio);
  795. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  796. TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  797. if ((!err) && stop) {
  798. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* STOP, raise data while clock is high */
  799. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  800. TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  801. }
  802. return (err);
  803. } /* TLan_EeSendByte */
  804. /***************************************************************
  805. * TLan_EeReceiveByte
  806. *
  807. * Returns:
  808. * Nothing
  809. * Parms:
  810. * io_base The IO port base address for the
  811. * TLAN device with the EEPROM to
  812. * use.
  813. * data An address to a char to hold the
  814. * data sent from the EEPROM.
  815. * stop If TLAN_EEPROM_STOP is passed, a
  816. * stop cycle is sent after the
  817. * byte is received, and no ack is
  818. * sent.
  819. *
  820. * This function receives 8 bits of data from the EEPROM
  821. * over the serial link. It then sends and ack bit, or no
  822. * ack and a stop bit. This function is used to retrieve
  823. * data after the address of a byte in the EEPROM has been
  824. * sent.
  825. *
  826. **************************************************************/
  827. void TLan_EeReceiveByte(u16 io_base, u8 * data, int stop)
  828. {
  829. u8 place;
  830. u16 sio;
  831. outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  832. sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  833. *data = 0;
  834. /* Assume clock is low, tx is enabled; */
  835. TLan_ClearBit(TLAN_NET_SIO_ETXEN, sio);
  836. for (place = 0x80; place; place >>= 1) {
  837. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  838. if (TLan_GetBit(TLAN_NET_SIO_EDATA, sio))
  839. *data |= place;
  840. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  841. }
  842. TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  843. if (!stop) {
  844. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* Ack = 0 */
  845. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  846. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  847. } else {
  848. TLan_SetBit(TLAN_NET_SIO_EDATA, sio); /* No ack = 1 (?) */
  849. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  850. TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  851. TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* STOP, raise data while clock is high */
  852. TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  853. TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  854. }
  855. } /* TLan_EeReceiveByte */
  856. /***************************************************************
  857. * TLan_EeReadByte
  858. *
  859. * Returns:
  860. * No error = 0, else, the stage at which the error
  861. * occurred.
  862. * Parms:
  863. * io_base The IO port base address for the
  864. * TLAN device with the EEPROM to
  865. * use.
  866. * ee_addr The address of the byte in the
  867. * EEPROM whose contents are to be
  868. * retrieved.
  869. * data An address to a char to hold the
  870. * data obtained from the EEPROM.
  871. *
  872. * This function reads a byte of information from an byte
  873. * cell in the EEPROM.
  874. *
  875. **************************************************************/
  876. int TLan_EeReadByte(u16 io_base, u8 ee_addr, u8 * data)
  877. {
  878. int err;
  879. int ret = 0;
  880. TLan_EeSendStart(io_base);
  881. err = TLan_EeSendByte(io_base, 0xA0, TLAN_EEPROM_ACK);
  882. if (err) {
  883. ret = 1;
  884. goto fail;
  885. }
  886. err = TLan_EeSendByte(io_base, ee_addr, TLAN_EEPROM_ACK);
  887. if (err) {
  888. ret = 2;
  889. goto fail;
  890. }
  891. TLan_EeSendStart(io_base);
  892. err = TLan_EeSendByte(io_base, 0xA1, TLAN_EEPROM_ACK);
  893. if (err) {
  894. ret = 3;
  895. goto fail;
  896. }
  897. TLan_EeReceiveByte(io_base, data, TLAN_EEPROM_STOP);
  898. fail:
  899. return ret;
  900. } /* TLan_EeReadByte */
  901. /*****************************************************************************
  902. ******************************************************************************
  903. ThunderLAN Driver MII Routines
  904. These routines are based on the information in Chap. 2 of the
  905. "ThunderLAN Programmer's Guide", pp. 15-24.
  906. ******************************************************************************
  907. *****************************************************************************/
  908. /***************************************************************
  909. * TLan_MiiReadReg
  910. *
  911. * Returns:
  912. * 0 if ack received ok
  913. * 1 otherwise.
  914. *
  915. * Parms:
  916. * dev The device structure containing
  917. * The io address and interrupt count
  918. * for this device.
  919. * phy The address of the PHY to be queried.
  920. * reg The register whose contents are to be
  921. * retrieved.
  922. * val A pointer to a variable to store the
  923. * retrieved value.
  924. *
  925. * This function uses the TLAN's MII bus to retrieve the contents
  926. * of a given register on a PHY. It sends the appropriate info
  927. * and then reads the 16-bit register value from the MII bus via
  928. * the TLAN SIO register.
  929. *
  930. **************************************************************/
  931. int TLan_MiiReadReg(struct nic *nic __unused, u16 phy, u16 reg, u16 * val)
  932. {
  933. u8 nack;
  934. u16 sio, tmp;
  935. u32 i;
  936. int err;
  937. int minten;
  938. err = FALSE;
  939. outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  940. sio = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  941. TLan_MiiSync(BASE);
  942. minten = TLan_GetBit(TLAN_NET_SIO_MINTEN, sio);
  943. if (minten)
  944. TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  945. TLan_MiiSendData(BASE, 0x1, 2); /* Start ( 01b ) */
  946. TLan_MiiSendData(BASE, 0x2, 2); /* Read ( 10b ) */
  947. TLan_MiiSendData(BASE, phy, 5); /* Device # */
  948. TLan_MiiSendData(BASE, reg, 5); /* Register # */
  949. TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio); /* Change direction */
  950. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Clock Idle bit */
  951. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  952. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Wait 300ns */
  953. nack = TLan_GetBit(TLAN_NET_SIO_MDATA, sio); /* Check for ACK */
  954. TLan_SetBit(TLAN_NET_SIO_MCLK, sio); /* Finish ACK */
  955. if (nack) { /* No ACK, so fake it */
  956. for (i = 0; i < 16; i++) {
  957. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  958. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  959. }
  960. tmp = 0xffff;
  961. err = TRUE;
  962. } else { /* ACK, so read data */
  963. for (tmp = 0, i = 0x8000; i; i >>= 1) {
  964. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  965. if (TLan_GetBit(TLAN_NET_SIO_MDATA, sio))
  966. tmp |= i;
  967. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  968. }
  969. }
  970. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  971. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  972. if (minten)
  973. TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  974. *val = tmp;
  975. return err;
  976. } /* TLan_MiiReadReg */
  977. /***************************************************************
  978. * TLan_MiiSendData
  979. *
  980. * Returns:
  981. * Nothing
  982. * Parms:
  983. * base_port The base IO port of the adapter in
  984. * question.
  985. * dev The address of the PHY to be queried.
  986. * data The value to be placed on the MII bus.
  987. * num_bits The number of bits in data that are to
  988. * be placed on the MII bus.
  989. *
  990. * This function sends on sequence of bits on the MII
  991. * configuration bus.
  992. *
  993. **************************************************************/
  994. void TLan_MiiSendData(u16 base_port, u32 data, unsigned num_bits)
  995. {
  996. u16 sio;
  997. u32 i;
  998. if (num_bits == 0)
  999. return;
  1000. outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
  1001. sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  1002. TLan_SetBit(TLAN_NET_SIO_MTXEN, sio);
  1003. for (i = (0x1 << (num_bits - 1)); i; i >>= 1) {
  1004. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  1005. (void) TLan_GetBit(TLAN_NET_SIO_MCLK, sio);
  1006. if (data & i)
  1007. TLan_SetBit(TLAN_NET_SIO_MDATA, sio);
  1008. else
  1009. TLan_ClearBit(TLAN_NET_SIO_MDATA, sio);
  1010. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  1011. (void) TLan_GetBit(TLAN_NET_SIO_MCLK, sio);
  1012. }
  1013. } /* TLan_MiiSendData */
  1014. /***************************************************************
  1015. * TLan_MiiSync
  1016. *
  1017. * Returns:
  1018. * Nothing
  1019. * Parms:
  1020. * base_port The base IO port of the adapter in
  1021. * question.
  1022. *
  1023. * This functions syncs all PHYs in terms of the MII configuration
  1024. * bus.
  1025. *
  1026. **************************************************************/
  1027. void TLan_MiiSync(u16 base_port)
  1028. {
  1029. int i;
  1030. u16 sio;
  1031. outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
  1032. sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  1033. TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio);
  1034. for (i = 0; i < 32; i++) {
  1035. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  1036. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  1037. }
  1038. } /* TLan_MiiSync */
  1039. /***************************************************************
  1040. * TLan_MiiWriteReg
  1041. *
  1042. * Returns:
  1043. * Nothing
  1044. * Parms:
  1045. * dev The device structure for the device
  1046. * to write to.
  1047. * phy The address of the PHY to be written to.
  1048. * reg The register whose contents are to be
  1049. * written.
  1050. * val The value to be written to the register.
  1051. *
  1052. * This function uses the TLAN's MII bus to write the contents of a
  1053. * given register on a PHY. It sends the appropriate info and then
  1054. * writes the 16-bit register value from the MII configuration bus
  1055. * via the TLAN SIO register.
  1056. *
  1057. **************************************************************/
  1058. void TLan_MiiWriteReg(struct nic *nic __unused, u16 phy, u16 reg, u16 val)
  1059. {
  1060. u16 sio;
  1061. int minten;
  1062. outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  1063. sio = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  1064. TLan_MiiSync(BASE);
  1065. minten = TLan_GetBit(TLAN_NET_SIO_MINTEN, sio);
  1066. if (minten)
  1067. TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  1068. TLan_MiiSendData(BASE, 0x1, 2); /* Start ( 01b ) */
  1069. TLan_MiiSendData(BASE, 0x1, 2); /* Write ( 01b ) */
  1070. TLan_MiiSendData(BASE, phy, 5); /* Device # */
  1071. TLan_MiiSendData(BASE, reg, 5); /* Register # */
  1072. TLan_MiiSendData(BASE, 0x2, 2); /* Send ACK */
  1073. TLan_MiiSendData(BASE, val, 16); /* Send Data */
  1074. TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  1075. TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  1076. if (minten)
  1077. TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  1078. } /* TLan_MiiWriteReg */
  1079. /***************************************************************
  1080. * TLan_SetMac
  1081. *
  1082. * Returns:
  1083. * Nothing
  1084. * Parms:
  1085. * dev Pointer to device structure of adapter
  1086. * on which to change the AREG.
  1087. * areg The AREG to set the address in (0 - 3).
  1088. * mac A pointer to an array of chars. Each
  1089. * element stores one byte of the address.
  1090. * IE, it isn't in ascii.
  1091. *
  1092. * This function transfers a MAC address to one of the
  1093. * TLAN AREGs (address registers). The TLAN chip locks
  1094. * the register on writing to offset 0 and unlocks the
  1095. * register after writing to offset 5. If NULL is passed
  1096. * in mac, then the AREG is filled with 0's.
  1097. *
  1098. **************************************************************/
  1099. void TLan_SetMac(struct nic *nic __unused, int areg, unsigned char *mac)
  1100. {
  1101. int i;
  1102. areg *= 6;
  1103. if (mac != NULL) {
  1104. for (i = 0; i < 6; i++)
  1105. TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i,
  1106. mac[i]);
  1107. } else {
  1108. for (i = 0; i < 6; i++)
  1109. TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i, 0);
  1110. }
  1111. } /* TLan_SetMac */
  1112. /*********************************************************************
  1113. * TLan_PhyDetect
  1114. *
  1115. * Returns:
  1116. * Nothing
  1117. * Parms:
  1118. * dev A pointer to the device structure of the adapter
  1119. * for which the PHY needs determined.
  1120. *
  1121. * So far I've found that adapters which have external PHYs
  1122. * may also use the internal PHY for part of the functionality.
  1123. * (eg, AUI/Thinnet). This function finds out if this TLAN
  1124. * chip has an internal PHY, and then finds the first external
  1125. * PHY (starting from address 0) if it exists).
  1126. *
  1127. ********************************************************************/
  1128. void TLan_PhyDetect(struct nic *nic)
  1129. {
  1130. u16 control;
  1131. u16 hi;
  1132. u16 lo;
  1133. u32 phy;
  1134. if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY) {
  1135. priv->phyNum = 0xFFFF;
  1136. return;
  1137. }
  1138. TLan_MiiReadReg(nic, TLAN_PHY_MAX_ADDR, MII_PHYSID1, &hi);
  1139. if (hi != 0xFFFF) {
  1140. priv->phy[0] = TLAN_PHY_MAX_ADDR;
  1141. } else {
  1142. priv->phy[0] = TLAN_PHY_NONE;
  1143. }
  1144. priv->phy[1] = TLAN_PHY_NONE;
  1145. for (phy = 0; phy <= TLAN_PHY_MAX_ADDR; phy++) {
  1146. TLan_MiiReadReg(nic, phy, MII_BMCR, &control);
  1147. TLan_MiiReadReg(nic, phy, MII_PHYSID1, &hi);
  1148. TLan_MiiReadReg(nic, phy, MII_PHYSID2, &lo);
  1149. if ((control != 0xFFFF) || (hi != 0xFFFF)
  1150. || (lo != 0xFFFF)) {
  1151. printf("PHY found at %hX %hX %hX %hX\n",
  1152. (unsigned int) phy, control, hi, lo);
  1153. if ((priv->phy[1] == TLAN_PHY_NONE)
  1154. && (phy != TLAN_PHY_MAX_ADDR)) {
  1155. priv->phy[1] = phy;
  1156. }
  1157. }
  1158. }
  1159. if (priv->phy[1] != TLAN_PHY_NONE) {
  1160. priv->phyNum = 1;
  1161. } else if (priv->phy[0] != TLAN_PHY_NONE) {
  1162. priv->phyNum = 0;
  1163. } else {
  1164. printf
  1165. ("TLAN: Cannot initialize device, no PHY was found!\n");
  1166. }
  1167. } /* TLan_PhyDetect */
  1168. void TLan_PhyPowerDown(struct nic *nic)
  1169. {
  1170. u16 value;
  1171. DBG ( "%s: Powering down PHY(s).\n", priv->nic_name );
  1172. value = BMCR_PDOWN | BMCR_LOOPBACK | BMCR_ISOLATE;
  1173. TLan_MiiSync(BASE);
  1174. TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_BMCR, value);
  1175. if ((priv->phyNum == 0) && (priv->phy[1] != TLAN_PHY_NONE)
  1176. &&
  1177. (!(tlan_pci_tbl[chip_idx].
  1178. flags & TLAN_ADAPTER_USE_INTERN_10))) {
  1179. TLan_MiiSync(BASE);
  1180. TLan_MiiWriteReg(nic, priv->phy[1], MII_BMCR, value);
  1181. }
  1182. /* Wait for 50 ms and powerup
  1183. * This is abitrary. It is intended to make sure the
  1184. * tranceiver settles.
  1185. */
  1186. /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_PUP ); */
  1187. mdelay(50);
  1188. TLan_PhyPowerUp(nic);
  1189. } /* TLan_PhyPowerDown */
  1190. void TLan_PhyPowerUp(struct nic *nic)
  1191. {
  1192. u16 value;
  1193. DBG ( "%s: Powering up PHY.\n", priv->nic_name );
  1194. TLan_MiiSync(BASE);
  1195. value = BMCR_LOOPBACK;
  1196. TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_BMCR, value);
  1197. TLan_MiiSync(BASE);
  1198. /* Wait for 500 ms and reset the
  1199. * tranceiver. The TLAN docs say both 50 ms and
  1200. * 500 ms, so do the longer, just in case.
  1201. */
  1202. mdelay(500);
  1203. TLan_PhyReset(nic);
  1204. /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_RESET ); */
  1205. } /* TLan_PhyPowerUp */
  1206. void TLan_PhyReset(struct nic *nic)
  1207. {
  1208. u16 phy;
  1209. u16 value;
  1210. phy = priv->phy[priv->phyNum];
  1211. DBG ( "%s: Reseting PHY.\n", priv->nic_name );
  1212. TLan_MiiSync(BASE);
  1213. value = BMCR_LOOPBACK | BMCR_RESET;
  1214. TLan_MiiWriteReg(nic, phy, MII_BMCR, value);
  1215. TLan_MiiReadReg(nic, phy, MII_BMCR, &value);
  1216. while (value & BMCR_RESET) {
  1217. TLan_MiiReadReg(nic, phy, MII_BMCR, &value);
  1218. }
  1219. /* Wait for 500 ms and initialize.
  1220. * I don't remember why I wait this long.
  1221. * I've changed this to 50ms, as it seems long enough.
  1222. */
  1223. /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_START_LINK ); */
  1224. mdelay(50);
  1225. TLan_PhyStartLink(nic);
  1226. } /* TLan_PhyReset */
  1227. void TLan_PhyStartLink(struct nic *nic)
  1228. {
  1229. u16 ability;
  1230. u16 control;
  1231. u16 data;
  1232. u16 phy;
  1233. u16 status;
  1234. u16 tctl;
  1235. phy = priv->phy[priv->phyNum];
  1236. DBG ( "%s: Trying to activate link.\n", priv->nic_name );
  1237. TLan_MiiReadReg(nic, phy, MII_BMSR, &status);
  1238. TLan_MiiReadReg(nic, phy, MII_BMSR, &ability);
  1239. if ((status & BMSR_ANEGCAPABLE) && (!priv->aui)) {
  1240. ability = status >> 11;
  1241. if (priv->speed == TLAN_SPEED_10 &&
  1242. priv->duplex == TLAN_DUPLEX_HALF) {
  1243. TLan_MiiWriteReg(nic, phy, MII_BMCR, 0x0000);
  1244. } else if (priv->speed == TLAN_SPEED_10 &&
  1245. priv->duplex == TLAN_DUPLEX_FULL) {
  1246. priv->tlanFullDuplex = TRUE;
  1247. TLan_MiiWriteReg(nic, phy, MII_BMCR, 0x0100);
  1248. } else if (priv->speed == TLAN_SPEED_100 &&
  1249. priv->duplex == TLAN_DUPLEX_HALF) {
  1250. TLan_MiiWriteReg(nic, phy, MII_BMCR, 0x2000);
  1251. } else if (priv->speed == TLAN_SPEED_100 &&
  1252. priv->duplex == TLAN_DUPLEX_FULL) {
  1253. priv->tlanFullDuplex = TRUE;
  1254. TLan_MiiWriteReg(nic, phy, MII_BMCR, 0x2100);
  1255. } else {
  1256. /* Set Auto-Neg advertisement */
  1257. TLan_MiiWriteReg(nic, phy, MII_ADVERTISE,
  1258. (ability << 5) | 1);
  1259. /* Enablee Auto-Neg */
  1260. TLan_MiiWriteReg(nic, phy, MII_BMCR, 0x1000);
  1261. /* Restart Auto-Neg */
  1262. TLan_MiiWriteReg(nic, phy, MII_BMCR, 0x1200);
  1263. /* Wait for 4 sec for autonegotiation
  1264. * to complete. The max spec time is less than this
  1265. * but the card need additional time to start AN.
  1266. * .5 sec should be plenty extra.
  1267. */
  1268. DBG ( "TLAN: %s: Starting autonegotiation.\n",
  1269. priv->nic_name );
  1270. mdelay(4000);
  1271. TLan_PhyFinishAutoNeg(nic);
  1272. /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
  1273. return;
  1274. }
  1275. }
  1276. if ((priv->aui) && (priv->phyNum != 0)) {
  1277. priv->phyNum = 0;
  1278. data =
  1279. TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN |
  1280. TLAN_NET_CFG_PHY_EN;
  1281. TLan_DioWrite16(BASE, TLAN_NET_CONFIG, data);
  1282. mdelay(50);
  1283. /* TLan_SetTimer( dev, (40*HZ/1000), TLAN_TIMER_PHY_PDOWN ); */
  1284. TLan_PhyPowerDown(nic);
  1285. return;
  1286. } else if (priv->phyNum == 0) {
  1287. control = 0;
  1288. TLan_MiiReadReg(nic, phy, TLAN_TLPHY_CTL, &tctl);
  1289. if (priv->aui) {
  1290. tctl |= TLAN_TC_AUISEL;
  1291. } else {
  1292. tctl &= ~TLAN_TC_AUISEL;
  1293. if (priv->duplex == TLAN_DUPLEX_FULL) {
  1294. control |= BMCR_FULLDPLX;
  1295. priv->tlanFullDuplex = TRUE;
  1296. }
  1297. if (priv->speed == TLAN_SPEED_100) {
  1298. control |= BMCR_SPEED100;
  1299. }
  1300. }
  1301. TLan_MiiWriteReg(nic, phy, MII_BMCR, control);
  1302. TLan_MiiWriteReg(nic, phy, TLAN_TLPHY_CTL, tctl);
  1303. }
  1304. /* Wait for 2 sec to give the tranceiver time
  1305. * to establish link.
  1306. */
  1307. /* TLan_SetTimer( dev, (4*HZ), TLAN_TIMER_FINISH_RESET ); */
  1308. mdelay(2000);
  1309. TLan_FinishReset(nic);
  1310. } /* TLan_PhyStartLink */
  1311. void TLan_PhyFinishAutoNeg(struct nic *nic)
  1312. {
  1313. u16 an_adv;
  1314. u16 an_lpa;
  1315. u16 data;
  1316. u16 mode;
  1317. u16 phy;
  1318. u16 status;
  1319. phy = priv->phy[priv->phyNum];
  1320. TLan_MiiReadReg(nic, phy, MII_BMSR, &status);
  1321. udelay(1000);
  1322. TLan_MiiReadReg(nic, phy, MII_BMSR, &status);
  1323. if (!(status & BMSR_ANEGCOMPLETE)) {
  1324. /* Wait for 8 sec to give the process
  1325. * more time. Perhaps we should fail after a while.
  1326. */
  1327. if (!priv->neg_be_verbose++) {
  1328. printf
  1329. ("TLAN: Giving autonegotiation more time.\n");
  1330. printf
  1331. ("TLAN: Please check that your adapter has\n");
  1332. printf
  1333. ("TLAN: been properly connected to a HUB or Switch.\n");
  1334. printf
  1335. ("TLAN: Trying to establish link in the background...\n");
  1336. }
  1337. mdelay(8000);
  1338. TLan_PhyFinishAutoNeg(nic);
  1339. /* TLan_SetTimer( dev, (8*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
  1340. return;
  1341. }
  1342. DBG ( "TLAN: %s: Autonegotiation complete.\n", priv->nic_name );
  1343. TLan_MiiReadReg(nic, phy, MII_ADVERTISE, &an_adv);
  1344. TLan_MiiReadReg(nic, phy, MII_LPA, &an_lpa);
  1345. mode = an_adv & an_lpa & 0x03E0;
  1346. if (mode & 0x0100) {
  1347. printf("Full Duplex\n");
  1348. priv->tlanFullDuplex = TRUE;
  1349. } else if (!(mode & 0x0080) && (mode & 0x0040)) {
  1350. priv->tlanFullDuplex = TRUE;
  1351. printf("Full Duplex\n");
  1352. }
  1353. if ((!(mode & 0x0180))
  1354. && (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_USE_INTERN_10)
  1355. && (priv->phyNum != 0)) {
  1356. priv->phyNum = 0;
  1357. data =
  1358. TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN |
  1359. TLAN_NET_CFG_PHY_EN;
  1360. TLan_DioWrite16(BASE, TLAN_NET_CONFIG, data);
  1361. /* TLan_SetTimer( nic, (400*HZ/1000), TLAN_TIMER_PHY_PDOWN ); */
  1362. mdelay(400);
  1363. TLan_PhyPowerDown(nic);
  1364. return;
  1365. }
  1366. if (priv->phyNum == 0) {
  1367. if ((priv->duplex == TLAN_DUPLEX_FULL)
  1368. || (an_adv & an_lpa & 0x0040)) {
  1369. TLan_MiiWriteReg(nic, phy, MII_BMCR,
  1370. BMCR_ANENABLE | BMCR_FULLDPLX);
  1371. DBG
  1372. ( "TLAN: Starting internal PHY with FULL-DUPLEX\n" );
  1373. } else {
  1374. TLan_MiiWriteReg(nic, phy, MII_BMCR,
  1375. BMCR_ANENABLE);
  1376. DBG
  1377. ( "TLAN: Starting internal PHY with HALF-DUPLEX\n" );
  1378. }
  1379. }
  1380. /* Wait for 100 ms. No reason in partiticular.
  1381. */
  1382. /* TLan_SetTimer( dev, (HZ/10), TLAN_TIMER_FINISH_RESET ); */
  1383. mdelay(100);
  1384. TLan_FinishReset(nic);
  1385. } /* TLan_PhyFinishAutoNeg */
  1386. #ifdef MONITOR
  1387. /*********************************************************************
  1388. *
  1389. * TLan_phyMonitor
  1390. *
  1391. * Returns:
  1392. * None
  1393. *
  1394. * Params:
  1395. * dev The device structure of this device.
  1396. *
  1397. *
  1398. * This function monitors PHY condition by reading the status
  1399. * register via the MII bus. This can be used to give info
  1400. * about link changes (up/down), and possible switch to alternate
  1401. * media.
  1402. *
  1403. ********************************************************************/
  1404. void TLan_PhyMonitor(struct net_device *dev)
  1405. {
  1406. TLanPrivateInfo *priv = dev->priv;
  1407. u16 phy;
  1408. u16 phy_status;
  1409. phy = priv->phy[priv->phyNum];
  1410. /* Get PHY status register */
  1411. TLan_MiiReadReg(nic, phy, MII_BMSR, &phy_status);
  1412. /* Check if link has been lost */
  1413. if (!(phy_status & BMSR_LSTATUS)) {
  1414. if (priv->link) {
  1415. priv->link = 0;
  1416. printf("TLAN: %s has lost link\n", priv->nic_name);
  1417. priv->flags &= ~IFF_RUNNING;
  1418. mdelay(2000);
  1419. TLan_PhyMonitor(nic);
  1420. /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); */
  1421. return;
  1422. }
  1423. }
  1424. /* Link restablished? */
  1425. if ((phy_status & BMSR_LSTATUS) && !priv->link) {
  1426. priv->link = 1;
  1427. printf("TLAN: %s has reestablished link\n",
  1428. priv->nic_name);
  1429. priv->flags |= IFF_RUNNING;
  1430. }
  1431. /* Setup a new monitor */
  1432. /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); */
  1433. mdelay(2000);
  1434. TLan_PhyMonitor(nic);
  1435. }
  1436. #endif /* MONITOR */
  1437. static struct pci_device_id tlan_nics[] = {
  1438. PCI_ROM(0x0e11, 0xae34, "netel10", "Compaq Netelligent 10 T PCI UTP", 0),
  1439. PCI_ROM(0x0e11, 0xae32, "netel100","Compaq Netelligent 10/100 TX PCI UTP", 0),
  1440. PCI_ROM(0x0e11, 0xae35, "netflex3i", "Compaq Integrated NetFlex-3/P", 0),
  1441. PCI_ROM(0x0e11, 0xf130, "thunder", "Compaq NetFlex-3/P", 0),
  1442. PCI_ROM(0x0e11, 0xf150, "netflex3b", "Compaq NetFlex-3/P", 0),
  1443. PCI_ROM(0x0e11, 0xae43, "netel100pi", "Compaq Netelligent Integrated 10/100 TX UTP", 0),
  1444. PCI_ROM(0x0e11, 0xae40, "netel100d", "Compaq Netelligent Dual 10/100 TX PCI UTP", 0),
  1445. PCI_ROM(0x0e11, 0xb011, "netel100i", "Compaq Netelligent 10/100 TX Embedded UTP", 0),
  1446. PCI_ROM(0x108d, 0x0013, "oc2183", "Olicom OC-2183/2185", 0),
  1447. PCI_ROM(0x108d, 0x0012, "oc2325", "Olicom OC-2325", 0),
  1448. PCI_ROM(0x108d, 0x0014, "oc2326", "Olicom OC-2326", 0),
  1449. PCI_ROM(0x0e11, 0xb030, "netelligent_10_100_ws_5100", "Compaq Netelligent 10/100 TX UTP", 0),
  1450. PCI_ROM(0x0e11, 0xb012, "netelligent_10_t2", "Compaq Netelligent 10 T/2 PCI UTP/Coax", 0),
  1451. };
  1452. PCI_DRIVER ( tlan_driver, tlan_nics, PCI_NO_CLASS );
  1453. DRIVER ( "TLAN/PCI", nic_driver, pci_driver, tlan_driver,
  1454. tlan_probe, tlan_disable );
  1455. /*
  1456. * Local variables:
  1457. * c-basic-offset: 8
  1458. * c-indent-level: 8
  1459. * tab-width: 8
  1460. * End:
  1461. */