phy.c 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2008 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. Linux NICS <linux.nics@intel.com>
  18. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  19. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20. *******************************************************************************/
  21. #include <linux/delay.h>
  22. #include "e1000.h"
  23. static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw);
  24. static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw);
  25. static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active);
  26. static s32 e1000_wait_autoneg(struct e1000_hw *hw);
  27. static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg);
  28. static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
  29. u16 *data, bool read);
  30. /* Cable length tables */
  31. static const u16 e1000_m88_cable_length_table[] =
  32. { 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED };
  33. static const u16 e1000_igp_2_cable_length_table[] =
  34. { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, 0, 0, 0, 3,
  35. 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41, 6, 10, 14, 18, 22,
  36. 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61, 21, 26, 31, 35, 40,
  37. 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82, 40, 45, 51, 56, 61,
  38. 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104, 60, 66, 72, 77, 82,
  39. 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121, 83, 89, 95,
  40. 100, 105, 109, 113, 116, 119, 122, 124, 104, 109, 114, 118, 121,
  41. 124};
  42. #define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \
  43. ARRAY_SIZE(e1000_igp_2_cable_length_table)
  44. /**
  45. * e1000e_check_reset_block_generic - Check if PHY reset is blocked
  46. * @hw: pointer to the HW structure
  47. *
  48. * Read the PHY management control register and check whether a PHY reset
  49. * is blocked. If a reset is not blocked return 0, otherwise
  50. * return E1000_BLK_PHY_RESET (12).
  51. **/
  52. s32 e1000e_check_reset_block_generic(struct e1000_hw *hw)
  53. {
  54. u32 manc;
  55. manc = er32(MANC);
  56. return (manc & E1000_MANC_BLK_PHY_RST_ON_IDE) ?
  57. E1000_BLK_PHY_RESET : 0;
  58. }
  59. /**
  60. * e1000e_get_phy_id - Retrieve the PHY ID and revision
  61. * @hw: pointer to the HW structure
  62. *
  63. * Reads the PHY registers and stores the PHY ID and possibly the PHY
  64. * revision in the hardware structure.
  65. **/
  66. s32 e1000e_get_phy_id(struct e1000_hw *hw)
  67. {
  68. struct e1000_phy_info *phy = &hw->phy;
  69. s32 ret_val;
  70. u16 phy_id;
  71. ret_val = e1e_rphy(hw, PHY_ID1, &phy_id);
  72. if (ret_val)
  73. return ret_val;
  74. phy->id = (u32)(phy_id << 16);
  75. udelay(20);
  76. ret_val = e1e_rphy(hw, PHY_ID2, &phy_id);
  77. if (ret_val)
  78. return ret_val;
  79. phy->id |= (u32)(phy_id & PHY_REVISION_MASK);
  80. phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
  81. return 0;
  82. }
  83. /**
  84. * e1000e_phy_reset_dsp - Reset PHY DSP
  85. * @hw: pointer to the HW structure
  86. *
  87. * Reset the digital signal processor.
  88. **/
  89. s32 e1000e_phy_reset_dsp(struct e1000_hw *hw)
  90. {
  91. s32 ret_val;
  92. ret_val = e1e_wphy(hw, M88E1000_PHY_GEN_CONTROL, 0xC1);
  93. if (ret_val)
  94. return ret_val;
  95. return e1e_wphy(hw, M88E1000_PHY_GEN_CONTROL, 0);
  96. }
  97. /**
  98. * e1000e_read_phy_reg_mdic - Read MDI control register
  99. * @hw: pointer to the HW structure
  100. * @offset: register offset to be read
  101. * @data: pointer to the read data
  102. *
  103. * Reads the MDI control register in the PHY at offset and stores the
  104. * information read to data.
  105. **/
  106. s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
  107. {
  108. struct e1000_phy_info *phy = &hw->phy;
  109. u32 i, mdic = 0;
  110. if (offset > MAX_PHY_REG_ADDRESS) {
  111. hw_dbg(hw, "PHY Address %d is out of range\n", offset);
  112. return -E1000_ERR_PARAM;
  113. }
  114. /*
  115. * Set up Op-code, Phy Address, and register offset in the MDI
  116. * Control register. The MAC will take care of interfacing with the
  117. * PHY to retrieve the desired data.
  118. */
  119. mdic = ((offset << E1000_MDIC_REG_SHIFT) |
  120. (phy->addr << E1000_MDIC_PHY_SHIFT) |
  121. (E1000_MDIC_OP_READ));
  122. ew32(MDIC, mdic);
  123. /*
  124. * Poll the ready bit to see if the MDI read completed
  125. * Increasing the time out as testing showed failures with
  126. * the lower time out
  127. */
  128. for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) {
  129. udelay(50);
  130. mdic = er32(MDIC);
  131. if (mdic & E1000_MDIC_READY)
  132. break;
  133. }
  134. if (!(mdic & E1000_MDIC_READY)) {
  135. hw_dbg(hw, "MDI Read did not complete\n");
  136. return -E1000_ERR_PHY;
  137. }
  138. if (mdic & E1000_MDIC_ERROR) {
  139. hw_dbg(hw, "MDI Error\n");
  140. return -E1000_ERR_PHY;
  141. }
  142. *data = (u16) mdic;
  143. return 0;
  144. }
  145. /**
  146. * e1000e_write_phy_reg_mdic - Write MDI control register
  147. * @hw: pointer to the HW structure
  148. * @offset: register offset to write to
  149. * @data: data to write to register at offset
  150. *
  151. * Writes data to MDI control register in the PHY at offset.
  152. **/
  153. s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
  154. {
  155. struct e1000_phy_info *phy = &hw->phy;
  156. u32 i, mdic = 0;
  157. if (offset > MAX_PHY_REG_ADDRESS) {
  158. hw_dbg(hw, "PHY Address %d is out of range\n", offset);
  159. return -E1000_ERR_PARAM;
  160. }
  161. /*
  162. * Set up Op-code, Phy Address, and register offset in the MDI
  163. * Control register. The MAC will take care of interfacing with the
  164. * PHY to retrieve the desired data.
  165. */
  166. mdic = (((u32)data) |
  167. (offset << E1000_MDIC_REG_SHIFT) |
  168. (phy->addr << E1000_MDIC_PHY_SHIFT) |
  169. (E1000_MDIC_OP_WRITE));
  170. ew32(MDIC, mdic);
  171. /*
  172. * Poll the ready bit to see if the MDI read completed
  173. * Increasing the time out as testing showed failures with
  174. * the lower time out
  175. */
  176. for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) {
  177. udelay(50);
  178. mdic = er32(MDIC);
  179. if (mdic & E1000_MDIC_READY)
  180. break;
  181. }
  182. if (!(mdic & E1000_MDIC_READY)) {
  183. hw_dbg(hw, "MDI Write did not complete\n");
  184. return -E1000_ERR_PHY;
  185. }
  186. if (mdic & E1000_MDIC_ERROR) {
  187. hw_dbg(hw, "MDI Error\n");
  188. return -E1000_ERR_PHY;
  189. }
  190. return 0;
  191. }
  192. /**
  193. * e1000e_read_phy_reg_m88 - Read m88 PHY register
  194. * @hw: pointer to the HW structure
  195. * @offset: register offset to be read
  196. * @data: pointer to the read data
  197. *
  198. * Acquires semaphore, if necessary, then reads the PHY register at offset
  199. * and storing the retrieved information in data. Release any acquired
  200. * semaphores before exiting.
  201. **/
  202. s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data)
  203. {
  204. s32 ret_val;
  205. ret_val = hw->phy.ops.acquire_phy(hw);
  206. if (ret_val)
  207. return ret_val;
  208. ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  209. data);
  210. hw->phy.ops.release_phy(hw);
  211. return ret_val;
  212. }
  213. /**
  214. * e1000e_write_phy_reg_m88 - Write m88 PHY register
  215. * @hw: pointer to the HW structure
  216. * @offset: register offset to write to
  217. * @data: data to write at register offset
  218. *
  219. * Acquires semaphore, if necessary, then writes the data to PHY register
  220. * at the offset. Release any acquired semaphores before exiting.
  221. **/
  222. s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data)
  223. {
  224. s32 ret_val;
  225. ret_val = hw->phy.ops.acquire_phy(hw);
  226. if (ret_val)
  227. return ret_val;
  228. ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  229. data);
  230. hw->phy.ops.release_phy(hw);
  231. return ret_val;
  232. }
  233. /**
  234. * e1000e_read_phy_reg_igp - Read igp PHY register
  235. * @hw: pointer to the HW structure
  236. * @offset: register offset to be read
  237. * @data: pointer to the read data
  238. *
  239. * Acquires semaphore, if necessary, then reads the PHY register at offset
  240. * and storing the retrieved information in data. Release any acquired
  241. * semaphores before exiting.
  242. **/
  243. s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data)
  244. {
  245. s32 ret_val;
  246. ret_val = hw->phy.ops.acquire_phy(hw);
  247. if (ret_val)
  248. return ret_val;
  249. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  250. ret_val = e1000e_write_phy_reg_mdic(hw,
  251. IGP01E1000_PHY_PAGE_SELECT,
  252. (u16)offset);
  253. if (ret_val) {
  254. hw->phy.ops.release_phy(hw);
  255. return ret_val;
  256. }
  257. }
  258. ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  259. data);
  260. hw->phy.ops.release_phy(hw);
  261. return ret_val;
  262. }
  263. /**
  264. * e1000e_write_phy_reg_igp - Write igp PHY register
  265. * @hw: pointer to the HW structure
  266. * @offset: register offset to write to
  267. * @data: data to write at register offset
  268. *
  269. * Acquires semaphore, if necessary, then writes the data to PHY register
  270. * at the offset. Release any acquired semaphores before exiting.
  271. **/
  272. s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data)
  273. {
  274. s32 ret_val;
  275. ret_val = hw->phy.ops.acquire_phy(hw);
  276. if (ret_val)
  277. return ret_val;
  278. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  279. ret_val = e1000e_write_phy_reg_mdic(hw,
  280. IGP01E1000_PHY_PAGE_SELECT,
  281. (u16)offset);
  282. if (ret_val) {
  283. hw->phy.ops.release_phy(hw);
  284. return ret_val;
  285. }
  286. }
  287. ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  288. data);
  289. hw->phy.ops.release_phy(hw);
  290. return ret_val;
  291. }
  292. /**
  293. * e1000e_read_kmrn_reg - Read kumeran register
  294. * @hw: pointer to the HW structure
  295. * @offset: register offset to be read
  296. * @data: pointer to the read data
  297. *
  298. * Acquires semaphore, if necessary. Then reads the PHY register at offset
  299. * using the kumeran interface. The information retrieved is stored in data.
  300. * Release any acquired semaphores before exiting.
  301. **/
  302. s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
  303. {
  304. u32 kmrnctrlsta;
  305. s32 ret_val;
  306. ret_val = hw->phy.ops.acquire_phy(hw);
  307. if (ret_val)
  308. return ret_val;
  309. kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
  310. E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
  311. ew32(KMRNCTRLSTA, kmrnctrlsta);
  312. udelay(2);
  313. kmrnctrlsta = er32(KMRNCTRLSTA);
  314. *data = (u16)kmrnctrlsta;
  315. hw->phy.ops.release_phy(hw);
  316. return ret_val;
  317. }
  318. /**
  319. * e1000e_write_kmrn_reg - Write kumeran register
  320. * @hw: pointer to the HW structure
  321. * @offset: register offset to write to
  322. * @data: data to write at register offset
  323. *
  324. * Acquires semaphore, if necessary. Then write the data to PHY register
  325. * at the offset using the kumeran interface. Release any acquired semaphores
  326. * before exiting.
  327. **/
  328. s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
  329. {
  330. u32 kmrnctrlsta;
  331. s32 ret_val;
  332. ret_val = hw->phy.ops.acquire_phy(hw);
  333. if (ret_val)
  334. return ret_val;
  335. kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
  336. E1000_KMRNCTRLSTA_OFFSET) | data;
  337. ew32(KMRNCTRLSTA, kmrnctrlsta);
  338. udelay(2);
  339. hw->phy.ops.release_phy(hw);
  340. return ret_val;
  341. }
  342. /**
  343. * e1000e_copper_link_setup_m88 - Setup m88 PHY's for copper link
  344. * @hw: pointer to the HW structure
  345. *
  346. * Sets up MDI/MDI-X and polarity for m88 PHY's. If necessary, transmit clock
  347. * and downshift values are set also.
  348. **/
  349. s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw)
  350. {
  351. struct e1000_phy_info *phy = &hw->phy;
  352. s32 ret_val;
  353. u16 phy_data;
  354. /* Enable CRS on Tx. This must be set for half-duplex operation. */
  355. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
  356. if (ret_val)
  357. return ret_val;
  358. /* For newer PHYs this bit is downshift enable */
  359. if (phy->type == e1000_phy_m88)
  360. phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
  361. /*
  362. * Options:
  363. * MDI/MDI-X = 0 (default)
  364. * 0 - Auto for all speeds
  365. * 1 - MDI mode
  366. * 2 - MDI-X mode
  367. * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
  368. */
  369. phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
  370. switch (phy->mdix) {
  371. case 1:
  372. phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
  373. break;
  374. case 2:
  375. phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
  376. break;
  377. case 3:
  378. phy_data |= M88E1000_PSCR_AUTO_X_1000T;
  379. break;
  380. case 0:
  381. default:
  382. phy_data |= M88E1000_PSCR_AUTO_X_MODE;
  383. break;
  384. }
  385. /*
  386. * Options:
  387. * disable_polarity_correction = 0 (default)
  388. * Automatic Correction for Reversed Cable Polarity
  389. * 0 - Disabled
  390. * 1 - Enabled
  391. */
  392. phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
  393. if (phy->disable_polarity_correction == 1)
  394. phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
  395. /* Enable downshift on BM (disabled by default) */
  396. if (phy->type == e1000_phy_bm)
  397. phy_data |= BME1000_PSCR_ENABLE_DOWNSHIFT;
  398. ret_val = e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
  399. if (ret_val)
  400. return ret_val;
  401. if ((phy->type == e1000_phy_m88) &&
  402. (phy->revision < E1000_REVISION_4) &&
  403. (phy->id != BME1000_E_PHY_ID_R2)) {
  404. /*
  405. * Force TX_CLK in the Extended PHY Specific Control Register
  406. * to 25MHz clock.
  407. */
  408. ret_val = e1e_rphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
  409. if (ret_val)
  410. return ret_val;
  411. phy_data |= M88E1000_EPSCR_TX_CLK_25;
  412. if ((phy->revision == 2) &&
  413. (phy->id == M88E1111_I_PHY_ID)) {
  414. /* 82573L PHY - set the downshift counter to 5x. */
  415. phy_data &= ~M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK;
  416. phy_data |= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X;
  417. } else {
  418. /* Configure Master and Slave downshift values */
  419. phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
  420. M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
  421. phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
  422. M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
  423. }
  424. ret_val = e1e_wphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
  425. if (ret_val)
  426. return ret_val;
  427. }
  428. if ((phy->type == e1000_phy_bm) && (phy->id == BME1000_E_PHY_ID_R2)) {
  429. /* Set PHY page 0, register 29 to 0x0003 */
  430. ret_val = e1e_wphy(hw, 29, 0x0003);
  431. if (ret_val)
  432. return ret_val;
  433. /* Set PHY page 0, register 30 to 0x0000 */
  434. ret_val = e1e_wphy(hw, 30, 0x0000);
  435. if (ret_val)
  436. return ret_val;
  437. }
  438. /* Commit the changes. */
  439. ret_val = e1000e_commit_phy(hw);
  440. if (ret_val)
  441. hw_dbg(hw, "Error committing the PHY changes\n");
  442. return ret_val;
  443. }
  444. /**
  445. * e1000e_copper_link_setup_igp - Setup igp PHY's for copper link
  446. * @hw: pointer to the HW structure
  447. *
  448. * Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for
  449. * igp PHY's.
  450. **/
  451. s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw)
  452. {
  453. struct e1000_phy_info *phy = &hw->phy;
  454. s32 ret_val;
  455. u16 data;
  456. ret_val = e1000_phy_hw_reset(hw);
  457. if (ret_val) {
  458. hw_dbg(hw, "Error resetting the PHY.\n");
  459. return ret_val;
  460. }
  461. /*
  462. * Wait 100ms for MAC to configure PHY from NVM settings, to avoid
  463. * timeout issues when LFS is enabled.
  464. */
  465. msleep(100);
  466. /* disable lplu d0 during driver init */
  467. ret_val = e1000_set_d0_lplu_state(hw, 0);
  468. if (ret_val) {
  469. hw_dbg(hw, "Error Disabling LPLU D0\n");
  470. return ret_val;
  471. }
  472. /* Configure mdi-mdix settings */
  473. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CTRL, &data);
  474. if (ret_val)
  475. return ret_val;
  476. data &= ~IGP01E1000_PSCR_AUTO_MDIX;
  477. switch (phy->mdix) {
  478. case 1:
  479. data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
  480. break;
  481. case 2:
  482. data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
  483. break;
  484. case 0:
  485. default:
  486. data |= IGP01E1000_PSCR_AUTO_MDIX;
  487. break;
  488. }
  489. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CTRL, data);
  490. if (ret_val)
  491. return ret_val;
  492. /* set auto-master slave resolution settings */
  493. if (hw->mac.autoneg) {
  494. /*
  495. * when autonegotiation advertisement is only 1000Mbps then we
  496. * should disable SmartSpeed and enable Auto MasterSlave
  497. * resolution as hardware default.
  498. */
  499. if (phy->autoneg_advertised == ADVERTISE_1000_FULL) {
  500. /* Disable SmartSpeed */
  501. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  502. &data);
  503. if (ret_val)
  504. return ret_val;
  505. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  506. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  507. data);
  508. if (ret_val)
  509. return ret_val;
  510. /* Set auto Master/Slave resolution process */
  511. ret_val = e1e_rphy(hw, PHY_1000T_CTRL, &data);
  512. if (ret_val)
  513. return ret_val;
  514. data &= ~CR_1000T_MS_ENABLE;
  515. ret_val = e1e_wphy(hw, PHY_1000T_CTRL, data);
  516. if (ret_val)
  517. return ret_val;
  518. }
  519. ret_val = e1e_rphy(hw, PHY_1000T_CTRL, &data);
  520. if (ret_val)
  521. return ret_val;
  522. /* load defaults for future use */
  523. phy->original_ms_type = (data & CR_1000T_MS_ENABLE) ?
  524. ((data & CR_1000T_MS_VALUE) ?
  525. e1000_ms_force_master :
  526. e1000_ms_force_slave) :
  527. e1000_ms_auto;
  528. switch (phy->ms_type) {
  529. case e1000_ms_force_master:
  530. data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
  531. break;
  532. case e1000_ms_force_slave:
  533. data |= CR_1000T_MS_ENABLE;
  534. data &= ~(CR_1000T_MS_VALUE);
  535. break;
  536. case e1000_ms_auto:
  537. data &= ~CR_1000T_MS_ENABLE;
  538. default:
  539. break;
  540. }
  541. ret_val = e1e_wphy(hw, PHY_1000T_CTRL, data);
  542. }
  543. return ret_val;
  544. }
  545. /**
  546. * e1000_phy_setup_autoneg - Configure PHY for auto-negotiation
  547. * @hw: pointer to the HW structure
  548. *
  549. * Reads the MII auto-neg advertisement register and/or the 1000T control
  550. * register and if the PHY is already setup for auto-negotiation, then
  551. * return successful. Otherwise, setup advertisement and flow control to
  552. * the appropriate values for the wanted auto-negotiation.
  553. **/
  554. static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)
  555. {
  556. struct e1000_phy_info *phy = &hw->phy;
  557. s32 ret_val;
  558. u16 mii_autoneg_adv_reg;
  559. u16 mii_1000t_ctrl_reg = 0;
  560. phy->autoneg_advertised &= phy->autoneg_mask;
  561. /* Read the MII Auto-Neg Advertisement Register (Address 4). */
  562. ret_val = e1e_rphy(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg);
  563. if (ret_val)
  564. return ret_val;
  565. if (phy->autoneg_mask & ADVERTISE_1000_FULL) {
  566. /* Read the MII 1000Base-T Control Register (Address 9). */
  567. ret_val = e1e_rphy(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg);
  568. if (ret_val)
  569. return ret_val;
  570. }
  571. /*
  572. * Need to parse both autoneg_advertised and fc and set up
  573. * the appropriate PHY registers. First we will parse for
  574. * autoneg_advertised software override. Since we can advertise
  575. * a plethora of combinations, we need to check each bit
  576. * individually.
  577. */
  578. /*
  579. * First we clear all the 10/100 mb speed bits in the Auto-Neg
  580. * Advertisement Register (Address 4) and the 1000 mb speed bits in
  581. * the 1000Base-T Control Register (Address 9).
  582. */
  583. mii_autoneg_adv_reg &= ~(NWAY_AR_100TX_FD_CAPS |
  584. NWAY_AR_100TX_HD_CAPS |
  585. NWAY_AR_10T_FD_CAPS |
  586. NWAY_AR_10T_HD_CAPS);
  587. mii_1000t_ctrl_reg &= ~(CR_1000T_HD_CAPS | CR_1000T_FD_CAPS);
  588. hw_dbg(hw, "autoneg_advertised %x\n", phy->autoneg_advertised);
  589. /* Do we want to advertise 10 Mb Half Duplex? */
  590. if (phy->autoneg_advertised & ADVERTISE_10_HALF) {
  591. hw_dbg(hw, "Advertise 10mb Half duplex\n");
  592. mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
  593. }
  594. /* Do we want to advertise 10 Mb Full Duplex? */
  595. if (phy->autoneg_advertised & ADVERTISE_10_FULL) {
  596. hw_dbg(hw, "Advertise 10mb Full duplex\n");
  597. mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
  598. }
  599. /* Do we want to advertise 100 Mb Half Duplex? */
  600. if (phy->autoneg_advertised & ADVERTISE_100_HALF) {
  601. hw_dbg(hw, "Advertise 100mb Half duplex\n");
  602. mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
  603. }
  604. /* Do we want to advertise 100 Mb Full Duplex? */
  605. if (phy->autoneg_advertised & ADVERTISE_100_FULL) {
  606. hw_dbg(hw, "Advertise 100mb Full duplex\n");
  607. mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
  608. }
  609. /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
  610. if (phy->autoneg_advertised & ADVERTISE_1000_HALF)
  611. hw_dbg(hw, "Advertise 1000mb Half duplex request denied!\n");
  612. /* Do we want to advertise 1000 Mb Full Duplex? */
  613. if (phy->autoneg_advertised & ADVERTISE_1000_FULL) {
  614. hw_dbg(hw, "Advertise 1000mb Full duplex\n");
  615. mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
  616. }
  617. /*
  618. * Check for a software override of the flow control settings, and
  619. * setup the PHY advertisement registers accordingly. If
  620. * auto-negotiation is enabled, then software will have to set the
  621. * "PAUSE" bits to the correct value in the Auto-Negotiation
  622. * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-
  623. * negotiation.
  624. *
  625. * The possible values of the "fc" parameter are:
  626. * 0: Flow control is completely disabled
  627. * 1: Rx flow control is enabled (we can receive pause frames
  628. * but not send pause frames).
  629. * 2: Tx flow control is enabled (we can send pause frames
  630. * but we do not support receiving pause frames).
  631. * 3: Both Rx and Tx flow control (symmetric) are enabled.
  632. * other: No software override. The flow control configuration
  633. * in the EEPROM is used.
  634. */
  635. switch (hw->fc.current_mode) {
  636. case e1000_fc_none:
  637. /*
  638. * Flow control (Rx & Tx) is completely disabled by a
  639. * software over-ride.
  640. */
  641. mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  642. break;
  643. case e1000_fc_rx_pause:
  644. /*
  645. * Rx Flow control is enabled, and Tx Flow control is
  646. * disabled, by a software over-ride.
  647. *
  648. * Since there really isn't a way to advertise that we are
  649. * capable of Rx Pause ONLY, we will advertise that we
  650. * support both symmetric and asymmetric Rx PAUSE. Later
  651. * (in e1000e_config_fc_after_link_up) we will disable the
  652. * hw's ability to send PAUSE frames.
  653. */
  654. mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  655. break;
  656. case e1000_fc_tx_pause:
  657. /*
  658. * Tx Flow control is enabled, and Rx Flow control is
  659. * disabled, by a software over-ride.
  660. */
  661. mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
  662. mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
  663. break;
  664. case e1000_fc_full:
  665. /*
  666. * Flow control (both Rx and Tx) is enabled by a software
  667. * over-ride.
  668. */
  669. mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  670. break;
  671. default:
  672. hw_dbg(hw, "Flow control param set incorrectly\n");
  673. ret_val = -E1000_ERR_CONFIG;
  674. return ret_val;
  675. }
  676. ret_val = e1e_wphy(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg);
  677. if (ret_val)
  678. return ret_val;
  679. hw_dbg(hw, "Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
  680. if (phy->autoneg_mask & ADVERTISE_1000_FULL) {
  681. ret_val = e1e_wphy(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
  682. }
  683. return ret_val;
  684. }
  685. /**
  686. * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link
  687. * @hw: pointer to the HW structure
  688. *
  689. * Performs initial bounds checking on autoneg advertisement parameter, then
  690. * configure to advertise the full capability. Setup the PHY to autoneg
  691. * and restart the negotiation process between the link partner. If
  692. * autoneg_wait_to_complete, then wait for autoneg to complete before exiting.
  693. **/
  694. static s32 e1000_copper_link_autoneg(struct e1000_hw *hw)
  695. {
  696. struct e1000_phy_info *phy = &hw->phy;
  697. s32 ret_val;
  698. u16 phy_ctrl;
  699. /*
  700. * Perform some bounds checking on the autoneg advertisement
  701. * parameter.
  702. */
  703. phy->autoneg_advertised &= phy->autoneg_mask;
  704. /*
  705. * If autoneg_advertised is zero, we assume it was not defaulted
  706. * by the calling code so we set to advertise full capability.
  707. */
  708. if (phy->autoneg_advertised == 0)
  709. phy->autoneg_advertised = phy->autoneg_mask;
  710. hw_dbg(hw, "Reconfiguring auto-neg advertisement params\n");
  711. ret_val = e1000_phy_setup_autoneg(hw);
  712. if (ret_val) {
  713. hw_dbg(hw, "Error Setting up Auto-Negotiation\n");
  714. return ret_val;
  715. }
  716. hw_dbg(hw, "Restarting Auto-Neg\n");
  717. /*
  718. * Restart auto-negotiation by setting the Auto Neg Enable bit and
  719. * the Auto Neg Restart bit in the PHY control register.
  720. */
  721. ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_ctrl);
  722. if (ret_val)
  723. return ret_val;
  724. phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
  725. ret_val = e1e_wphy(hw, PHY_CONTROL, phy_ctrl);
  726. if (ret_val)
  727. return ret_val;
  728. /*
  729. * Does the user want to wait for Auto-Neg to complete here, or
  730. * check at a later time (for example, callback routine).
  731. */
  732. if (phy->autoneg_wait_to_complete) {
  733. ret_val = e1000_wait_autoneg(hw);
  734. if (ret_val) {
  735. hw_dbg(hw, "Error while waiting for "
  736. "autoneg to complete\n");
  737. return ret_val;
  738. }
  739. }
  740. hw->mac.get_link_status = 1;
  741. return ret_val;
  742. }
  743. /**
  744. * e1000e_setup_copper_link - Configure copper link settings
  745. * @hw: pointer to the HW structure
  746. *
  747. * Calls the appropriate function to configure the link for auto-neg or forced
  748. * speed and duplex. Then we check for link, once link is established calls
  749. * to configure collision distance and flow control are called. If link is
  750. * not established, we return -E1000_ERR_PHY (-2).
  751. **/
  752. s32 e1000e_setup_copper_link(struct e1000_hw *hw)
  753. {
  754. s32 ret_val;
  755. bool link;
  756. if (hw->mac.autoneg) {
  757. /*
  758. * Setup autoneg and flow control advertisement and perform
  759. * autonegotiation.
  760. */
  761. ret_val = e1000_copper_link_autoneg(hw);
  762. if (ret_val)
  763. return ret_val;
  764. } else {
  765. /*
  766. * PHY will be set to 10H, 10F, 100H or 100F
  767. * depending on user settings.
  768. */
  769. hw_dbg(hw, "Forcing Speed and Duplex\n");
  770. ret_val = e1000_phy_force_speed_duplex(hw);
  771. if (ret_val) {
  772. hw_dbg(hw, "Error Forcing Speed and Duplex\n");
  773. return ret_val;
  774. }
  775. }
  776. /*
  777. * Check link status. Wait up to 100 microseconds for link to become
  778. * valid.
  779. */
  780. ret_val = e1000e_phy_has_link_generic(hw,
  781. COPPER_LINK_UP_LIMIT,
  782. 10,
  783. &link);
  784. if (ret_val)
  785. return ret_val;
  786. if (link) {
  787. hw_dbg(hw, "Valid link established!!!\n");
  788. e1000e_config_collision_dist(hw);
  789. ret_val = e1000e_config_fc_after_link_up(hw);
  790. } else {
  791. hw_dbg(hw, "Unable to establish link!!!\n");
  792. }
  793. return ret_val;
  794. }
  795. /**
  796. * e1000e_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY
  797. * @hw: pointer to the HW structure
  798. *
  799. * Calls the PHY setup function to force speed and duplex. Clears the
  800. * auto-crossover to force MDI manually. Waits for link and returns
  801. * successful if link up is successful, else -E1000_ERR_PHY (-2).
  802. **/
  803. s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw)
  804. {
  805. struct e1000_phy_info *phy = &hw->phy;
  806. s32 ret_val;
  807. u16 phy_data;
  808. bool link;
  809. ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
  810. if (ret_val)
  811. return ret_val;
  812. e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
  813. ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
  814. if (ret_val)
  815. return ret_val;
  816. /*
  817. * Clear Auto-Crossover to force MDI manually. IGP requires MDI
  818. * forced whenever speed and duplex are forced.
  819. */
  820. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
  821. if (ret_val)
  822. return ret_val;
  823. phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
  824. phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
  825. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
  826. if (ret_val)
  827. return ret_val;
  828. hw_dbg(hw, "IGP PSCR: %X\n", phy_data);
  829. udelay(1);
  830. if (phy->autoneg_wait_to_complete) {
  831. hw_dbg(hw, "Waiting for forced speed/duplex link on IGP phy.\n");
  832. ret_val = e1000e_phy_has_link_generic(hw,
  833. PHY_FORCE_LIMIT,
  834. 100000,
  835. &link);
  836. if (ret_val)
  837. return ret_val;
  838. if (!link)
  839. hw_dbg(hw, "Link taking longer than expected.\n");
  840. /* Try once more */
  841. ret_val = e1000e_phy_has_link_generic(hw,
  842. PHY_FORCE_LIMIT,
  843. 100000,
  844. &link);
  845. if (ret_val)
  846. return ret_val;
  847. }
  848. return ret_val;
  849. }
  850. /**
  851. * e1000e_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY
  852. * @hw: pointer to the HW structure
  853. *
  854. * Calls the PHY setup function to force speed and duplex. Clears the
  855. * auto-crossover to force MDI manually. Resets the PHY to commit the
  856. * changes. If time expires while waiting for link up, we reset the DSP.
  857. * After reset, TX_CLK and CRS on Tx must be set. Return successful upon
  858. * successful completion, else return corresponding error code.
  859. **/
  860. s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw)
  861. {
  862. struct e1000_phy_info *phy = &hw->phy;
  863. s32 ret_val;
  864. u16 phy_data;
  865. bool link;
  866. /*
  867. * Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
  868. * forced whenever speed and duplex are forced.
  869. */
  870. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
  871. if (ret_val)
  872. return ret_val;
  873. phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
  874. ret_val = e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
  875. if (ret_val)
  876. return ret_val;
  877. hw_dbg(hw, "M88E1000 PSCR: %X\n", phy_data);
  878. ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
  879. if (ret_val)
  880. return ret_val;
  881. e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
  882. ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
  883. if (ret_val)
  884. return ret_val;
  885. /* Reset the phy to commit changes. */
  886. ret_val = e1000e_commit_phy(hw);
  887. if (ret_val)
  888. return ret_val;
  889. if (phy->autoneg_wait_to_complete) {
  890. hw_dbg(hw, "Waiting for forced speed/duplex link on M88 phy.\n");
  891. ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
  892. 100000, &link);
  893. if (ret_val)
  894. return ret_val;
  895. if (!link) {
  896. /*
  897. * We didn't get link.
  898. * Reset the DSP and cross our fingers.
  899. */
  900. ret_val = e1e_wphy(hw, M88E1000_PHY_PAGE_SELECT,
  901. 0x001d);
  902. if (ret_val)
  903. return ret_val;
  904. ret_val = e1000e_phy_reset_dsp(hw);
  905. if (ret_val)
  906. return ret_val;
  907. }
  908. /* Try once more */
  909. ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
  910. 100000, &link);
  911. if (ret_val)
  912. return ret_val;
  913. }
  914. ret_val = e1e_rphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
  915. if (ret_val)
  916. return ret_val;
  917. /*
  918. * Resetting the phy means we need to re-force TX_CLK in the
  919. * Extended PHY Specific Control Register to 25MHz clock from
  920. * the reset value of 2.5MHz.
  921. */
  922. phy_data |= M88E1000_EPSCR_TX_CLK_25;
  923. ret_val = e1e_wphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
  924. if (ret_val)
  925. return ret_val;
  926. /*
  927. * In addition, we must re-enable CRS on Tx for both half and full
  928. * duplex.
  929. */
  930. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
  931. if (ret_val)
  932. return ret_val;
  933. phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
  934. ret_val = e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
  935. return ret_val;
  936. }
  937. /**
  938. * e1000e_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex
  939. * @hw: pointer to the HW structure
  940. * @phy_ctrl: pointer to current value of PHY_CONTROL
  941. *
  942. * Forces speed and duplex on the PHY by doing the following: disable flow
  943. * control, force speed/duplex on the MAC, disable auto speed detection,
  944. * disable auto-negotiation, configure duplex, configure speed, configure
  945. * the collision distance, write configuration to CTRL register. The
  946. * caller must write to the PHY_CONTROL register for these settings to
  947. * take affect.
  948. **/
  949. void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl)
  950. {
  951. struct e1000_mac_info *mac = &hw->mac;
  952. u32 ctrl;
  953. /* Turn off flow control when forcing speed/duplex */
  954. hw->fc.current_mode = e1000_fc_none;
  955. /* Force speed/duplex on the mac */
  956. ctrl = er32(CTRL);
  957. ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  958. ctrl &= ~E1000_CTRL_SPD_SEL;
  959. /* Disable Auto Speed Detection */
  960. ctrl &= ~E1000_CTRL_ASDE;
  961. /* Disable autoneg on the phy */
  962. *phy_ctrl &= ~MII_CR_AUTO_NEG_EN;
  963. /* Forcing Full or Half Duplex? */
  964. if (mac->forced_speed_duplex & E1000_ALL_HALF_DUPLEX) {
  965. ctrl &= ~E1000_CTRL_FD;
  966. *phy_ctrl &= ~MII_CR_FULL_DUPLEX;
  967. hw_dbg(hw, "Half Duplex\n");
  968. } else {
  969. ctrl |= E1000_CTRL_FD;
  970. *phy_ctrl |= MII_CR_FULL_DUPLEX;
  971. hw_dbg(hw, "Full Duplex\n");
  972. }
  973. /* Forcing 10mb or 100mb? */
  974. if (mac->forced_speed_duplex & E1000_ALL_100_SPEED) {
  975. ctrl |= E1000_CTRL_SPD_100;
  976. *phy_ctrl |= MII_CR_SPEED_100;
  977. *phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_10);
  978. hw_dbg(hw, "Forcing 100mb\n");
  979. } else {
  980. ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
  981. *phy_ctrl |= MII_CR_SPEED_10;
  982. *phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100);
  983. hw_dbg(hw, "Forcing 10mb\n");
  984. }
  985. e1000e_config_collision_dist(hw);
  986. ew32(CTRL, ctrl);
  987. }
  988. /**
  989. * e1000e_set_d3_lplu_state - Sets low power link up state for D3
  990. * @hw: pointer to the HW structure
  991. * @active: boolean used to enable/disable lplu
  992. *
  993. * Success returns 0, Failure returns 1
  994. *
  995. * The low power link up (lplu) state is set to the power management level D3
  996. * and SmartSpeed is disabled when active is true, else clear lplu for D3
  997. * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
  998. * is used during Dx states where the power conservation is most important.
  999. * During driver activity, SmartSpeed should be enabled so performance is
  1000. * maintained.
  1001. **/
  1002. s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active)
  1003. {
  1004. struct e1000_phy_info *phy = &hw->phy;
  1005. s32 ret_val;
  1006. u16 data;
  1007. ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data);
  1008. if (ret_val)
  1009. return ret_val;
  1010. if (!active) {
  1011. data &= ~IGP02E1000_PM_D3_LPLU;
  1012. ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
  1013. if (ret_val)
  1014. return ret_val;
  1015. /*
  1016. * LPLU and SmartSpeed are mutually exclusive. LPLU is used
  1017. * during Dx states where the power conservation is most
  1018. * important. During driver activity we should enable
  1019. * SmartSpeed, so performance is maintained.
  1020. */
  1021. if (phy->smart_speed == e1000_smart_speed_on) {
  1022. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1023. &data);
  1024. if (ret_val)
  1025. return ret_val;
  1026. data |= IGP01E1000_PSCFR_SMART_SPEED;
  1027. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1028. data);
  1029. if (ret_val)
  1030. return ret_val;
  1031. } else if (phy->smart_speed == e1000_smart_speed_off) {
  1032. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1033. &data);
  1034. if (ret_val)
  1035. return ret_val;
  1036. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1037. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1038. data);
  1039. if (ret_val)
  1040. return ret_val;
  1041. }
  1042. } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
  1043. (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
  1044. (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
  1045. data |= IGP02E1000_PM_D3_LPLU;
  1046. ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
  1047. if (ret_val)
  1048. return ret_val;
  1049. /* When LPLU is enabled, we should disable SmartSpeed */
  1050. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  1051. if (ret_val)
  1052. return ret_val;
  1053. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1054. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  1055. }
  1056. return ret_val;
  1057. }
  1058. /**
  1059. * e1000e_check_downshift - Checks whether a downshift in speed occurred
  1060. * @hw: pointer to the HW structure
  1061. *
  1062. * Success returns 0, Failure returns 1
  1063. *
  1064. * A downshift is detected by querying the PHY link health.
  1065. **/
  1066. s32 e1000e_check_downshift(struct e1000_hw *hw)
  1067. {
  1068. struct e1000_phy_info *phy = &hw->phy;
  1069. s32 ret_val;
  1070. u16 phy_data, offset, mask;
  1071. switch (phy->type) {
  1072. case e1000_phy_m88:
  1073. case e1000_phy_gg82563:
  1074. offset = M88E1000_PHY_SPEC_STATUS;
  1075. mask = M88E1000_PSSR_DOWNSHIFT;
  1076. break;
  1077. case e1000_phy_igp_2:
  1078. case e1000_phy_igp_3:
  1079. offset = IGP01E1000_PHY_LINK_HEALTH;
  1080. mask = IGP01E1000_PLHR_SS_DOWNGRADE;
  1081. break;
  1082. default:
  1083. /* speed downshift not supported */
  1084. phy->speed_downgraded = 0;
  1085. return 0;
  1086. }
  1087. ret_val = e1e_rphy(hw, offset, &phy_data);
  1088. if (!ret_val)
  1089. phy->speed_downgraded = (phy_data & mask);
  1090. return ret_val;
  1091. }
  1092. /**
  1093. * e1000_check_polarity_m88 - Checks the polarity.
  1094. * @hw: pointer to the HW structure
  1095. *
  1096. * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
  1097. *
  1098. * Polarity is determined based on the PHY specific status register.
  1099. **/
  1100. static s32 e1000_check_polarity_m88(struct e1000_hw *hw)
  1101. {
  1102. struct e1000_phy_info *phy = &hw->phy;
  1103. s32 ret_val;
  1104. u16 data;
  1105. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &data);
  1106. if (!ret_val)
  1107. phy->cable_polarity = (data & M88E1000_PSSR_REV_POLARITY)
  1108. ? e1000_rev_polarity_reversed
  1109. : e1000_rev_polarity_normal;
  1110. return ret_val;
  1111. }
  1112. /**
  1113. * e1000_check_polarity_igp - Checks the polarity.
  1114. * @hw: pointer to the HW structure
  1115. *
  1116. * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
  1117. *
  1118. * Polarity is determined based on the PHY port status register, and the
  1119. * current speed (since there is no polarity at 100Mbps).
  1120. **/
  1121. static s32 e1000_check_polarity_igp(struct e1000_hw *hw)
  1122. {
  1123. struct e1000_phy_info *phy = &hw->phy;
  1124. s32 ret_val;
  1125. u16 data, offset, mask;
  1126. /*
  1127. * Polarity is determined based on the speed of
  1128. * our connection.
  1129. */
  1130. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_STATUS, &data);
  1131. if (ret_val)
  1132. return ret_val;
  1133. if ((data & IGP01E1000_PSSR_SPEED_MASK) ==
  1134. IGP01E1000_PSSR_SPEED_1000MBPS) {
  1135. offset = IGP01E1000_PHY_PCS_INIT_REG;
  1136. mask = IGP01E1000_PHY_POLARITY_MASK;
  1137. } else {
  1138. /*
  1139. * This really only applies to 10Mbps since
  1140. * there is no polarity for 100Mbps (always 0).
  1141. */
  1142. offset = IGP01E1000_PHY_PORT_STATUS;
  1143. mask = IGP01E1000_PSSR_POLARITY_REVERSED;
  1144. }
  1145. ret_val = e1e_rphy(hw, offset, &data);
  1146. if (!ret_val)
  1147. phy->cable_polarity = (data & mask)
  1148. ? e1000_rev_polarity_reversed
  1149. : e1000_rev_polarity_normal;
  1150. return ret_val;
  1151. }
  1152. /**
  1153. * e1000_wait_autoneg - Wait for auto-neg completion
  1154. * @hw: pointer to the HW structure
  1155. *
  1156. * Waits for auto-negotiation to complete or for the auto-negotiation time
  1157. * limit to expire, which ever happens first.
  1158. **/
  1159. static s32 e1000_wait_autoneg(struct e1000_hw *hw)
  1160. {
  1161. s32 ret_val = 0;
  1162. u16 i, phy_status;
  1163. /* Break after autoneg completes or PHY_AUTO_NEG_LIMIT expires. */
  1164. for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) {
  1165. ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
  1166. if (ret_val)
  1167. break;
  1168. ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
  1169. if (ret_val)
  1170. break;
  1171. if (phy_status & MII_SR_AUTONEG_COMPLETE)
  1172. break;
  1173. msleep(100);
  1174. }
  1175. /*
  1176. * PHY_AUTO_NEG_TIME expiration doesn't guarantee auto-negotiation
  1177. * has completed.
  1178. */
  1179. return ret_val;
  1180. }
  1181. /**
  1182. * e1000e_phy_has_link_generic - Polls PHY for link
  1183. * @hw: pointer to the HW structure
  1184. * @iterations: number of times to poll for link
  1185. * @usec_interval: delay between polling attempts
  1186. * @success: pointer to whether polling was successful or not
  1187. *
  1188. * Polls the PHY status register for link, 'iterations' number of times.
  1189. **/
  1190. s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
  1191. u32 usec_interval, bool *success)
  1192. {
  1193. s32 ret_val = 0;
  1194. u16 i, phy_status;
  1195. for (i = 0; i < iterations; i++) {
  1196. /*
  1197. * Some PHYs require the PHY_STATUS register to be read
  1198. * twice due to the link bit being sticky. No harm doing
  1199. * it across the board.
  1200. */
  1201. ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
  1202. if (ret_val)
  1203. break;
  1204. ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
  1205. if (ret_val)
  1206. break;
  1207. if (phy_status & MII_SR_LINK_STATUS)
  1208. break;
  1209. if (usec_interval >= 1000)
  1210. mdelay(usec_interval/1000);
  1211. else
  1212. udelay(usec_interval);
  1213. }
  1214. *success = (i < iterations);
  1215. return ret_val;
  1216. }
  1217. /**
  1218. * e1000e_get_cable_length_m88 - Determine cable length for m88 PHY
  1219. * @hw: pointer to the HW structure
  1220. *
  1221. * Reads the PHY specific status register to retrieve the cable length
  1222. * information. The cable length is determined by averaging the minimum and
  1223. * maximum values to get the "average" cable length. The m88 PHY has four
  1224. * possible cable length values, which are:
  1225. * Register Value Cable Length
  1226. * 0 < 50 meters
  1227. * 1 50 - 80 meters
  1228. * 2 80 - 110 meters
  1229. * 3 110 - 140 meters
  1230. * 4 > 140 meters
  1231. **/
  1232. s32 e1000e_get_cable_length_m88(struct e1000_hw *hw)
  1233. {
  1234. struct e1000_phy_info *phy = &hw->phy;
  1235. s32 ret_val;
  1236. u16 phy_data, index;
  1237. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
  1238. if (ret_val)
  1239. return ret_val;
  1240. index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
  1241. M88E1000_PSSR_CABLE_LENGTH_SHIFT;
  1242. phy->min_cable_length = e1000_m88_cable_length_table[index];
  1243. phy->max_cable_length = e1000_m88_cable_length_table[index+1];
  1244. phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
  1245. return ret_val;
  1246. }
  1247. /**
  1248. * e1000e_get_cable_length_igp_2 - Determine cable length for igp2 PHY
  1249. * @hw: pointer to the HW structure
  1250. *
  1251. * The automatic gain control (agc) normalizes the amplitude of the
  1252. * received signal, adjusting for the attenuation produced by the
  1253. * cable. By reading the AGC registers, which represent the
  1254. * combination of course and fine gain value, the value can be put
  1255. * into a lookup table to obtain the approximate cable length
  1256. * for each channel.
  1257. **/
  1258. s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw)
  1259. {
  1260. struct e1000_phy_info *phy = &hw->phy;
  1261. s32 ret_val;
  1262. u16 phy_data, i, agc_value = 0;
  1263. u16 cur_agc_index, max_agc_index = 0;
  1264. u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1;
  1265. u16 agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] =
  1266. {IGP02E1000_PHY_AGC_A,
  1267. IGP02E1000_PHY_AGC_B,
  1268. IGP02E1000_PHY_AGC_C,
  1269. IGP02E1000_PHY_AGC_D};
  1270. /* Read the AGC registers for all channels */
  1271. for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) {
  1272. ret_val = e1e_rphy(hw, agc_reg_array[i], &phy_data);
  1273. if (ret_val)
  1274. return ret_val;
  1275. /*
  1276. * Getting bits 15:9, which represent the combination of
  1277. * course and fine gain values. The result is a number
  1278. * that can be put into the lookup table to obtain the
  1279. * approximate cable length.
  1280. */
  1281. cur_agc_index = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) &
  1282. IGP02E1000_AGC_LENGTH_MASK;
  1283. /* Array index bound check. */
  1284. if ((cur_agc_index >= IGP02E1000_CABLE_LENGTH_TABLE_SIZE) ||
  1285. (cur_agc_index == 0))
  1286. return -E1000_ERR_PHY;
  1287. /* Remove min & max AGC values from calculation. */
  1288. if (e1000_igp_2_cable_length_table[min_agc_index] >
  1289. e1000_igp_2_cable_length_table[cur_agc_index])
  1290. min_agc_index = cur_agc_index;
  1291. if (e1000_igp_2_cable_length_table[max_agc_index] <
  1292. e1000_igp_2_cable_length_table[cur_agc_index])
  1293. max_agc_index = cur_agc_index;
  1294. agc_value += e1000_igp_2_cable_length_table[cur_agc_index];
  1295. }
  1296. agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] +
  1297. e1000_igp_2_cable_length_table[max_agc_index]);
  1298. agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2);
  1299. /* Calculate cable length with the error range of +/- 10 meters. */
  1300. phy->min_cable_length = ((agc_value - IGP02E1000_AGC_RANGE) > 0) ?
  1301. (agc_value - IGP02E1000_AGC_RANGE) : 0;
  1302. phy->max_cable_length = agc_value + IGP02E1000_AGC_RANGE;
  1303. phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
  1304. return ret_val;
  1305. }
  1306. /**
  1307. * e1000e_get_phy_info_m88 - Retrieve PHY information
  1308. * @hw: pointer to the HW structure
  1309. *
  1310. * Valid for only copper links. Read the PHY status register (sticky read)
  1311. * to verify that link is up. Read the PHY special control register to
  1312. * determine the polarity and 10base-T extended distance. Read the PHY
  1313. * special status register to determine MDI/MDIx and current speed. If
  1314. * speed is 1000, then determine cable length, local and remote receiver.
  1315. **/
  1316. s32 e1000e_get_phy_info_m88(struct e1000_hw *hw)
  1317. {
  1318. struct e1000_phy_info *phy = &hw->phy;
  1319. s32 ret_val;
  1320. u16 phy_data;
  1321. bool link;
  1322. if (hw->phy.media_type != e1000_media_type_copper) {
  1323. hw_dbg(hw, "Phy info is only valid for copper media\n");
  1324. return -E1000_ERR_CONFIG;
  1325. }
  1326. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  1327. if (ret_val)
  1328. return ret_val;
  1329. if (!link) {
  1330. hw_dbg(hw, "Phy info is only valid if link is up\n");
  1331. return -E1000_ERR_CONFIG;
  1332. }
  1333. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
  1334. if (ret_val)
  1335. return ret_val;
  1336. phy->polarity_correction = (phy_data &
  1337. M88E1000_PSCR_POLARITY_REVERSAL);
  1338. ret_val = e1000_check_polarity_m88(hw);
  1339. if (ret_val)
  1340. return ret_val;
  1341. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
  1342. if (ret_val)
  1343. return ret_val;
  1344. phy->is_mdix = (phy_data & M88E1000_PSSR_MDIX);
  1345. if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) {
  1346. ret_val = e1000_get_cable_length(hw);
  1347. if (ret_val)
  1348. return ret_val;
  1349. ret_val = e1e_rphy(hw, PHY_1000T_STATUS, &phy_data);
  1350. if (ret_val)
  1351. return ret_val;
  1352. phy->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)
  1353. ? e1000_1000t_rx_status_ok
  1354. : e1000_1000t_rx_status_not_ok;
  1355. phy->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)
  1356. ? e1000_1000t_rx_status_ok
  1357. : e1000_1000t_rx_status_not_ok;
  1358. } else {
  1359. /* Set values to "undefined" */
  1360. phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;
  1361. phy->local_rx = e1000_1000t_rx_status_undefined;
  1362. phy->remote_rx = e1000_1000t_rx_status_undefined;
  1363. }
  1364. return ret_val;
  1365. }
  1366. /**
  1367. * e1000e_get_phy_info_igp - Retrieve igp PHY information
  1368. * @hw: pointer to the HW structure
  1369. *
  1370. * Read PHY status to determine if link is up. If link is up, then
  1371. * set/determine 10base-T extended distance and polarity correction. Read
  1372. * PHY port status to determine MDI/MDIx and speed. Based on the speed,
  1373. * determine on the cable length, local and remote receiver.
  1374. **/
  1375. s32 e1000e_get_phy_info_igp(struct e1000_hw *hw)
  1376. {
  1377. struct e1000_phy_info *phy = &hw->phy;
  1378. s32 ret_val;
  1379. u16 data;
  1380. bool link;
  1381. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  1382. if (ret_val)
  1383. return ret_val;
  1384. if (!link) {
  1385. hw_dbg(hw, "Phy info is only valid if link is up\n");
  1386. return -E1000_ERR_CONFIG;
  1387. }
  1388. phy->polarity_correction = 1;
  1389. ret_val = e1000_check_polarity_igp(hw);
  1390. if (ret_val)
  1391. return ret_val;
  1392. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_STATUS, &data);
  1393. if (ret_val)
  1394. return ret_val;
  1395. phy->is_mdix = (data & IGP01E1000_PSSR_MDIX);
  1396. if ((data & IGP01E1000_PSSR_SPEED_MASK) ==
  1397. IGP01E1000_PSSR_SPEED_1000MBPS) {
  1398. ret_val = e1000_get_cable_length(hw);
  1399. if (ret_val)
  1400. return ret_val;
  1401. ret_val = e1e_rphy(hw, PHY_1000T_STATUS, &data);
  1402. if (ret_val)
  1403. return ret_val;
  1404. phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS)
  1405. ? e1000_1000t_rx_status_ok
  1406. : e1000_1000t_rx_status_not_ok;
  1407. phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS)
  1408. ? e1000_1000t_rx_status_ok
  1409. : e1000_1000t_rx_status_not_ok;
  1410. } else {
  1411. phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;
  1412. phy->local_rx = e1000_1000t_rx_status_undefined;
  1413. phy->remote_rx = e1000_1000t_rx_status_undefined;
  1414. }
  1415. return ret_val;
  1416. }
  1417. /**
  1418. * e1000e_phy_sw_reset - PHY software reset
  1419. * @hw: pointer to the HW structure
  1420. *
  1421. * Does a software reset of the PHY by reading the PHY control register and
  1422. * setting/write the control register reset bit to the PHY.
  1423. **/
  1424. s32 e1000e_phy_sw_reset(struct e1000_hw *hw)
  1425. {
  1426. s32 ret_val;
  1427. u16 phy_ctrl;
  1428. ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_ctrl);
  1429. if (ret_val)
  1430. return ret_val;
  1431. phy_ctrl |= MII_CR_RESET;
  1432. ret_val = e1e_wphy(hw, PHY_CONTROL, phy_ctrl);
  1433. if (ret_val)
  1434. return ret_val;
  1435. udelay(1);
  1436. return ret_val;
  1437. }
  1438. /**
  1439. * e1000e_phy_hw_reset_generic - PHY hardware reset
  1440. * @hw: pointer to the HW structure
  1441. *
  1442. * Verify the reset block is not blocking us from resetting. Acquire
  1443. * semaphore (if necessary) and read/set/write the device control reset
  1444. * bit in the PHY. Wait the appropriate delay time for the device to
  1445. * reset and release the semaphore (if necessary).
  1446. **/
  1447. s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw)
  1448. {
  1449. struct e1000_phy_info *phy = &hw->phy;
  1450. s32 ret_val;
  1451. u32 ctrl;
  1452. ret_val = e1000_check_reset_block(hw);
  1453. if (ret_val)
  1454. return 0;
  1455. ret_val = phy->ops.acquire_phy(hw);
  1456. if (ret_val)
  1457. return ret_val;
  1458. ctrl = er32(CTRL);
  1459. ew32(CTRL, ctrl | E1000_CTRL_PHY_RST);
  1460. e1e_flush();
  1461. udelay(phy->reset_delay_us);
  1462. ew32(CTRL, ctrl);
  1463. e1e_flush();
  1464. udelay(150);
  1465. phy->ops.release_phy(hw);
  1466. return e1000_get_phy_cfg_done(hw);
  1467. }
  1468. /**
  1469. * e1000e_get_cfg_done - Generic configuration done
  1470. * @hw: pointer to the HW structure
  1471. *
  1472. * Generic function to wait 10 milli-seconds for configuration to complete
  1473. * and return success.
  1474. **/
  1475. s32 e1000e_get_cfg_done(struct e1000_hw *hw)
  1476. {
  1477. mdelay(10);
  1478. return 0;
  1479. }
  1480. /**
  1481. * e1000e_phy_init_script_igp3 - Inits the IGP3 PHY
  1482. * @hw: pointer to the HW structure
  1483. *
  1484. * Initializes a Intel Gigabit PHY3 when an EEPROM is not present.
  1485. **/
  1486. s32 e1000e_phy_init_script_igp3(struct e1000_hw *hw)
  1487. {
  1488. hw_dbg(hw, "Running IGP 3 PHY init script\n");
  1489. /* PHY init IGP 3 */
  1490. /* Enable rise/fall, 10-mode work in class-A */
  1491. e1e_wphy(hw, 0x2F5B, 0x9018);
  1492. /* Remove all caps from Replica path filter */
  1493. e1e_wphy(hw, 0x2F52, 0x0000);
  1494. /* Bias trimming for ADC, AFE and Driver (Default) */
  1495. e1e_wphy(hw, 0x2FB1, 0x8B24);
  1496. /* Increase Hybrid poly bias */
  1497. e1e_wphy(hw, 0x2FB2, 0xF8F0);
  1498. /* Add 4% to Tx amplitude in Gig mode */
  1499. e1e_wphy(hw, 0x2010, 0x10B0);
  1500. /* Disable trimming (TTT) */
  1501. e1e_wphy(hw, 0x2011, 0x0000);
  1502. /* Poly DC correction to 94.6% + 2% for all channels */
  1503. e1e_wphy(hw, 0x20DD, 0x249A);
  1504. /* ABS DC correction to 95.9% */
  1505. e1e_wphy(hw, 0x20DE, 0x00D3);
  1506. /* BG temp curve trim */
  1507. e1e_wphy(hw, 0x28B4, 0x04CE);
  1508. /* Increasing ADC OPAMP stage 1 currents to max */
  1509. e1e_wphy(hw, 0x2F70, 0x29E4);
  1510. /* Force 1000 ( required for enabling PHY regs configuration) */
  1511. e1e_wphy(hw, 0x0000, 0x0140);
  1512. /* Set upd_freq to 6 */
  1513. e1e_wphy(hw, 0x1F30, 0x1606);
  1514. /* Disable NPDFE */
  1515. e1e_wphy(hw, 0x1F31, 0xB814);
  1516. /* Disable adaptive fixed FFE (Default) */
  1517. e1e_wphy(hw, 0x1F35, 0x002A);
  1518. /* Enable FFE hysteresis */
  1519. e1e_wphy(hw, 0x1F3E, 0x0067);
  1520. /* Fixed FFE for short cable lengths */
  1521. e1e_wphy(hw, 0x1F54, 0x0065);
  1522. /* Fixed FFE for medium cable lengths */
  1523. e1e_wphy(hw, 0x1F55, 0x002A);
  1524. /* Fixed FFE for long cable lengths */
  1525. e1e_wphy(hw, 0x1F56, 0x002A);
  1526. /* Enable Adaptive Clip Threshold */
  1527. e1e_wphy(hw, 0x1F72, 0x3FB0);
  1528. /* AHT reset limit to 1 */
  1529. e1e_wphy(hw, 0x1F76, 0xC0FF);
  1530. /* Set AHT master delay to 127 msec */
  1531. e1e_wphy(hw, 0x1F77, 0x1DEC);
  1532. /* Set scan bits for AHT */
  1533. e1e_wphy(hw, 0x1F78, 0xF9EF);
  1534. /* Set AHT Preset bits */
  1535. e1e_wphy(hw, 0x1F79, 0x0210);
  1536. /* Change integ_factor of channel A to 3 */
  1537. e1e_wphy(hw, 0x1895, 0x0003);
  1538. /* Change prop_factor of channels BCD to 8 */
  1539. e1e_wphy(hw, 0x1796, 0x0008);
  1540. /* Change cg_icount + enable integbp for channels BCD */
  1541. e1e_wphy(hw, 0x1798, 0xD008);
  1542. /*
  1543. * Change cg_icount + enable integbp + change prop_factor_master
  1544. * to 8 for channel A
  1545. */
  1546. e1e_wphy(hw, 0x1898, 0xD918);
  1547. /* Disable AHT in Slave mode on channel A */
  1548. e1e_wphy(hw, 0x187A, 0x0800);
  1549. /*
  1550. * Enable LPLU and disable AN to 1000 in non-D0a states,
  1551. * Enable SPD+B2B
  1552. */
  1553. e1e_wphy(hw, 0x0019, 0x008D);
  1554. /* Enable restart AN on an1000_dis change */
  1555. e1e_wphy(hw, 0x001B, 0x2080);
  1556. /* Enable wh_fifo read clock in 10/100 modes */
  1557. e1e_wphy(hw, 0x0014, 0x0045);
  1558. /* Restart AN, Speed selection is 1000 */
  1559. e1e_wphy(hw, 0x0000, 0x1340);
  1560. return 0;
  1561. }
  1562. /* Internal function pointers */
  1563. /**
  1564. * e1000_get_phy_cfg_done - Generic PHY configuration done
  1565. * @hw: pointer to the HW structure
  1566. *
  1567. * Return success if silicon family did not implement a family specific
  1568. * get_cfg_done function.
  1569. **/
  1570. static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw)
  1571. {
  1572. if (hw->phy.ops.get_cfg_done)
  1573. return hw->phy.ops.get_cfg_done(hw);
  1574. return 0;
  1575. }
  1576. /**
  1577. * e1000_phy_force_speed_duplex - Generic force PHY speed/duplex
  1578. * @hw: pointer to the HW structure
  1579. *
  1580. * When the silicon family has not implemented a forced speed/duplex
  1581. * function for the PHY, simply return 0.
  1582. **/
  1583. static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)
  1584. {
  1585. if (hw->phy.ops.force_speed_duplex)
  1586. return hw->phy.ops.force_speed_duplex(hw);
  1587. return 0;
  1588. }
  1589. /**
  1590. * e1000e_get_phy_type_from_id - Get PHY type from id
  1591. * @phy_id: phy_id read from the phy
  1592. *
  1593. * Returns the phy type from the id.
  1594. **/
  1595. enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id)
  1596. {
  1597. enum e1000_phy_type phy_type = e1000_phy_unknown;
  1598. switch (phy_id) {
  1599. case M88E1000_I_PHY_ID:
  1600. case M88E1000_E_PHY_ID:
  1601. case M88E1111_I_PHY_ID:
  1602. case M88E1011_I_PHY_ID:
  1603. phy_type = e1000_phy_m88;
  1604. break;
  1605. case IGP01E1000_I_PHY_ID: /* IGP 1 & 2 share this */
  1606. phy_type = e1000_phy_igp_2;
  1607. break;
  1608. case GG82563_E_PHY_ID:
  1609. phy_type = e1000_phy_gg82563;
  1610. break;
  1611. case IGP03E1000_E_PHY_ID:
  1612. phy_type = e1000_phy_igp_3;
  1613. break;
  1614. case IFE_E_PHY_ID:
  1615. case IFE_PLUS_E_PHY_ID:
  1616. case IFE_C_E_PHY_ID:
  1617. phy_type = e1000_phy_ife;
  1618. break;
  1619. case BME1000_E_PHY_ID:
  1620. case BME1000_E_PHY_ID_R2:
  1621. phy_type = e1000_phy_bm;
  1622. break;
  1623. default:
  1624. phy_type = e1000_phy_unknown;
  1625. break;
  1626. }
  1627. return phy_type;
  1628. }
  1629. /**
  1630. * e1000e_determine_phy_address - Determines PHY address.
  1631. * @hw: pointer to the HW structure
  1632. *
  1633. * This uses a trial and error method to loop through possible PHY
  1634. * addresses. It tests each by reading the PHY ID registers and
  1635. * checking for a match.
  1636. **/
  1637. s32 e1000e_determine_phy_address(struct e1000_hw *hw)
  1638. {
  1639. s32 ret_val = -E1000_ERR_PHY_TYPE;
  1640. u32 phy_addr= 0;
  1641. u32 i = 0;
  1642. enum e1000_phy_type phy_type = e1000_phy_unknown;
  1643. do {
  1644. for (phy_addr = 0; phy_addr < 4; phy_addr++) {
  1645. hw->phy.addr = phy_addr;
  1646. e1000e_get_phy_id(hw);
  1647. phy_type = e1000e_get_phy_type_from_id(hw->phy.id);
  1648. /*
  1649. * If phy_type is valid, break - we found our
  1650. * PHY address
  1651. */
  1652. if (phy_type != e1000_phy_unknown) {
  1653. ret_val = 0;
  1654. break;
  1655. }
  1656. }
  1657. i++;
  1658. } while ((ret_val != 0) && (i < 100));
  1659. return ret_val;
  1660. }
  1661. /**
  1662. * e1000_get_phy_addr_for_bm_page - Retrieve PHY page address
  1663. * @page: page to access
  1664. *
  1665. * Returns the phy address for the page requested.
  1666. **/
  1667. static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg)
  1668. {
  1669. u32 phy_addr = 2;
  1670. if ((page >= 768) || (page == 0 && reg == 25) || (reg == 31))
  1671. phy_addr = 1;
  1672. return phy_addr;
  1673. }
  1674. /**
  1675. * e1000e_write_phy_reg_bm - Write BM PHY register
  1676. * @hw: pointer to the HW structure
  1677. * @offset: register offset to write to
  1678. * @data: data to write at register offset
  1679. *
  1680. * Acquires semaphore, if necessary, then writes the data to PHY register
  1681. * at the offset. Release any acquired semaphores before exiting.
  1682. **/
  1683. s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data)
  1684. {
  1685. s32 ret_val;
  1686. u32 page_select = 0;
  1687. u32 page = offset >> IGP_PAGE_SHIFT;
  1688. u32 page_shift = 0;
  1689. /* Page 800 works differently than the rest so it has its own func */
  1690. if (page == BM_WUC_PAGE) {
  1691. ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
  1692. false);
  1693. goto out;
  1694. }
  1695. ret_val = hw->phy.ops.acquire_phy(hw);
  1696. if (ret_val)
  1697. goto out;
  1698. hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
  1699. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  1700. /*
  1701. * Page select is register 31 for phy address 1 and 22 for
  1702. * phy address 2 and 3. Page select is shifted only for
  1703. * phy address 1.
  1704. */
  1705. if (hw->phy.addr == 1) {
  1706. page_shift = IGP_PAGE_SHIFT;
  1707. page_select = IGP01E1000_PHY_PAGE_SELECT;
  1708. } else {
  1709. page_shift = 0;
  1710. page_select = BM_PHY_PAGE_SELECT;
  1711. }
  1712. /* Page is shifted left, PHY expects (page x 32) */
  1713. ret_val = e1000e_write_phy_reg_mdic(hw, page_select,
  1714. (page << page_shift));
  1715. if (ret_val) {
  1716. hw->phy.ops.release_phy(hw);
  1717. goto out;
  1718. }
  1719. }
  1720. ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  1721. data);
  1722. hw->phy.ops.release_phy(hw);
  1723. out:
  1724. return ret_val;
  1725. }
  1726. /**
  1727. * e1000e_read_phy_reg_bm - Read BM PHY register
  1728. * @hw: pointer to the HW structure
  1729. * @offset: register offset to be read
  1730. * @data: pointer to the read data
  1731. *
  1732. * Acquires semaphore, if necessary, then reads the PHY register at offset
  1733. * and storing the retrieved information in data. Release any acquired
  1734. * semaphores before exiting.
  1735. **/
  1736. s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data)
  1737. {
  1738. s32 ret_val;
  1739. u32 page_select = 0;
  1740. u32 page = offset >> IGP_PAGE_SHIFT;
  1741. u32 page_shift = 0;
  1742. /* Page 800 works differently than the rest so it has its own func */
  1743. if (page == BM_WUC_PAGE) {
  1744. ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
  1745. true);
  1746. goto out;
  1747. }
  1748. ret_val = hw->phy.ops.acquire_phy(hw);
  1749. if (ret_val)
  1750. goto out;
  1751. hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
  1752. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  1753. /*
  1754. * Page select is register 31 for phy address 1 and 22 for
  1755. * phy address 2 and 3. Page select is shifted only for
  1756. * phy address 1.
  1757. */
  1758. if (hw->phy.addr == 1) {
  1759. page_shift = IGP_PAGE_SHIFT;
  1760. page_select = IGP01E1000_PHY_PAGE_SELECT;
  1761. } else {
  1762. page_shift = 0;
  1763. page_select = BM_PHY_PAGE_SELECT;
  1764. }
  1765. /* Page is shifted left, PHY expects (page x 32) */
  1766. ret_val = e1000e_write_phy_reg_mdic(hw, page_select,
  1767. (page << page_shift));
  1768. if (ret_val) {
  1769. hw->phy.ops.release_phy(hw);
  1770. goto out;
  1771. }
  1772. }
  1773. ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  1774. data);
  1775. hw->phy.ops.release_phy(hw);
  1776. out:
  1777. return ret_val;
  1778. }
  1779. /**
  1780. * e1000e_read_phy_reg_bm2 - Read BM PHY register
  1781. * @hw: pointer to the HW structure
  1782. * @offset: register offset to be read
  1783. * @data: pointer to the read data
  1784. *
  1785. * Acquires semaphore, if necessary, then reads the PHY register at offset
  1786. * and storing the retrieved information in data. Release any acquired
  1787. * semaphores before exiting.
  1788. **/
  1789. s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data)
  1790. {
  1791. s32 ret_val;
  1792. u16 page = (u16)(offset >> IGP_PAGE_SHIFT);
  1793. /* Page 800 works differently than the rest so it has its own func */
  1794. if (page == BM_WUC_PAGE) {
  1795. ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
  1796. true);
  1797. return ret_val;
  1798. }
  1799. ret_val = hw->phy.ops.acquire_phy(hw);
  1800. if (ret_val)
  1801. return ret_val;
  1802. hw->phy.addr = 1;
  1803. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  1804. /* Page is shifted left, PHY expects (page x 32) */
  1805. ret_val = e1000e_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT,
  1806. page);
  1807. if (ret_val) {
  1808. hw->phy.ops.release_phy(hw);
  1809. return ret_val;
  1810. }
  1811. }
  1812. ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  1813. data);
  1814. hw->phy.ops.release_phy(hw);
  1815. return ret_val;
  1816. }
  1817. /**
  1818. * e1000e_write_phy_reg_bm2 - Write BM PHY register
  1819. * @hw: pointer to the HW structure
  1820. * @offset: register offset to write to
  1821. * @data: data to write at register offset
  1822. *
  1823. * Acquires semaphore, if necessary, then writes the data to PHY register
  1824. * at the offset. Release any acquired semaphores before exiting.
  1825. **/
  1826. s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data)
  1827. {
  1828. s32 ret_val;
  1829. u16 page = (u16)(offset >> IGP_PAGE_SHIFT);
  1830. /* Page 800 works differently than the rest so it has its own func */
  1831. if (page == BM_WUC_PAGE) {
  1832. ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
  1833. false);
  1834. return ret_val;
  1835. }
  1836. ret_val = hw->phy.ops.acquire_phy(hw);
  1837. if (ret_val)
  1838. return ret_val;
  1839. hw->phy.addr = 1;
  1840. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  1841. /* Page is shifted left, PHY expects (page x 32) */
  1842. ret_val = e1000e_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT,
  1843. page);
  1844. if (ret_val) {
  1845. hw->phy.ops.release_phy(hw);
  1846. return ret_val;
  1847. }
  1848. }
  1849. ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  1850. data);
  1851. hw->phy.ops.release_phy(hw);
  1852. return ret_val;
  1853. }
  1854. /**
  1855. * e1000_access_phy_wakeup_reg_bm - Read BM PHY wakeup register
  1856. * @hw: pointer to the HW structure
  1857. * @offset: register offset to be read or written
  1858. * @data: pointer to the data to read or write
  1859. * @read: determines if operation is read or write
  1860. *
  1861. * Acquires semaphore, if necessary, then reads the PHY register at offset
  1862. * and storing the retrieved information in data. Release any acquired
  1863. * semaphores before exiting. Note that procedure to read the wakeup
  1864. * registers are different. It works as such:
  1865. * 1) Set page 769, register 17, bit 2 = 1
  1866. * 2) Set page to 800 for host (801 if we were manageability)
  1867. * 3) Write the address using the address opcode (0x11)
  1868. * 4) Read or write the data using the data opcode (0x12)
  1869. * 5) Restore 769_17.2 to its original value
  1870. **/
  1871. static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
  1872. u16 *data, bool read)
  1873. {
  1874. s32 ret_val;
  1875. u16 reg = ((u16)offset) & PHY_REG_MASK;
  1876. u16 phy_reg = 0;
  1877. u8 phy_acquired = 1;
  1878. ret_val = hw->phy.ops.acquire_phy(hw);
  1879. if (ret_val) {
  1880. phy_acquired = 0;
  1881. goto out;
  1882. }
  1883. /* All operations in this function are phy address 1 */
  1884. hw->phy.addr = 1;
  1885. /* Set page 769 */
  1886. e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
  1887. (BM_WUC_ENABLE_PAGE << IGP_PAGE_SHIFT));
  1888. ret_val = e1000e_read_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, &phy_reg);
  1889. if (ret_val)
  1890. goto out;
  1891. /* First clear bit 4 to avoid a power state change */
  1892. phy_reg &= ~(BM_WUC_HOST_WU_BIT);
  1893. ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg);
  1894. if (ret_val)
  1895. goto out;
  1896. /* Write bit 2 = 1, and clear bit 4 to 769_17 */
  1897. ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG,
  1898. phy_reg | BM_WUC_ENABLE_BIT);
  1899. if (ret_val)
  1900. goto out;
  1901. /* Select page 800 */
  1902. ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
  1903. (BM_WUC_PAGE << IGP_PAGE_SHIFT));
  1904. /* Write the page 800 offset value using opcode 0x11 */
  1905. ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ADDRESS_OPCODE, reg);
  1906. if (ret_val)
  1907. goto out;
  1908. if (read) {
  1909. /* Read the page 800 value using opcode 0x12 */
  1910. ret_val = e1000e_read_phy_reg_mdic(hw, BM_WUC_DATA_OPCODE,
  1911. data);
  1912. } else {
  1913. /* Read the page 800 value using opcode 0x12 */
  1914. ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_DATA_OPCODE,
  1915. *data);
  1916. }
  1917. if (ret_val)
  1918. goto out;
  1919. /*
  1920. * Restore 769_17.2 to its original value
  1921. * Set page 769
  1922. */
  1923. e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
  1924. (BM_WUC_ENABLE_PAGE << IGP_PAGE_SHIFT));
  1925. /* Clear 769_17.2 */
  1926. ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg);
  1927. out:
  1928. if (phy_acquired == 1)
  1929. hw->phy.ops.release_phy(hw);
  1930. return ret_val;
  1931. }
  1932. /**
  1933. * e1000e_commit_phy - Soft PHY reset
  1934. * @hw: pointer to the HW structure
  1935. *
  1936. * Performs a soft PHY reset on those that apply. This is a function pointer
  1937. * entry point called by drivers.
  1938. **/
  1939. s32 e1000e_commit_phy(struct e1000_hw *hw)
  1940. {
  1941. if (hw->phy.ops.commit_phy)
  1942. return hw->phy.ops.commit_phy(hw);
  1943. return 0;
  1944. }
  1945. /**
  1946. * e1000_set_d0_lplu_state - Sets low power link up state for D0
  1947. * @hw: pointer to the HW structure
  1948. * @active: boolean used to enable/disable lplu
  1949. *
  1950. * Success returns 0, Failure returns 1
  1951. *
  1952. * The low power link up (lplu) state is set to the power management level D0
  1953. * and SmartSpeed is disabled when active is true, else clear lplu for D0
  1954. * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
  1955. * is used during Dx states where the power conservation is most important.
  1956. * During driver activity, SmartSpeed should be enabled so performance is
  1957. * maintained. This is a function pointer entry point called by drivers.
  1958. **/
  1959. static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
  1960. {
  1961. if (hw->phy.ops.set_d0_lplu_state)
  1962. return hw->phy.ops.set_d0_lplu_state(hw, active);
  1963. return 0;
  1964. }