phy.c 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2007 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. /* Cable length tables */
  28. static const u16 e1000_m88_cable_length_table[] =
  29. { 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED };
  30. static const u16 e1000_igp_2_cable_length_table[] =
  31. { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, 0, 0, 0, 3,
  32. 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41, 6, 10, 14, 18, 22,
  33. 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61, 21, 26, 31, 35, 40,
  34. 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82, 40, 45, 51, 56, 61,
  35. 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104, 60, 66, 72, 77, 82,
  36. 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121, 83, 89, 95,
  37. 100, 105, 109, 113, 116, 119, 122, 124, 104, 109, 114, 118, 121,
  38. 124};
  39. #define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \
  40. ARRAY_SIZE(e1000_igp_2_cable_length_table)
  41. /**
  42. * e1000e_check_reset_block_generic - Check if PHY reset is blocked
  43. * @hw: pointer to the HW structure
  44. *
  45. * Read the PHY management control register and check whether a PHY reset
  46. * is blocked. If a reset is not blocked return 0, otherwise
  47. * return E1000_BLK_PHY_RESET (12).
  48. **/
  49. s32 e1000e_check_reset_block_generic(struct e1000_hw *hw)
  50. {
  51. u32 manc;
  52. manc = er32(MANC);
  53. return (manc & E1000_MANC_BLK_PHY_RST_ON_IDE) ?
  54. E1000_BLK_PHY_RESET : 0;
  55. }
  56. /**
  57. * e1000e_get_phy_id - Retrieve the PHY ID and revision
  58. * @hw: pointer to the HW structure
  59. *
  60. * Reads the PHY registers and stores the PHY ID and possibly the PHY
  61. * revision in the hardware structure.
  62. **/
  63. s32 e1000e_get_phy_id(struct e1000_hw *hw)
  64. {
  65. struct e1000_phy_info *phy = &hw->phy;
  66. s32 ret_val;
  67. u16 phy_id;
  68. ret_val = e1e_rphy(hw, PHY_ID1, &phy_id);
  69. if (ret_val)
  70. return ret_val;
  71. phy->id = (u32)(phy_id << 16);
  72. udelay(20);
  73. ret_val = e1e_rphy(hw, PHY_ID2, &phy_id);
  74. if (ret_val)
  75. return ret_val;
  76. phy->id |= (u32)(phy_id & PHY_REVISION_MASK);
  77. phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
  78. return 0;
  79. }
  80. /**
  81. * e1000e_phy_reset_dsp - Reset PHY DSP
  82. * @hw: pointer to the HW structure
  83. *
  84. * Reset the digital signal processor.
  85. **/
  86. s32 e1000e_phy_reset_dsp(struct e1000_hw *hw)
  87. {
  88. s32 ret_val;
  89. ret_val = e1e_wphy(hw, M88E1000_PHY_GEN_CONTROL, 0xC1);
  90. if (ret_val)
  91. return ret_val;
  92. return e1e_wphy(hw, M88E1000_PHY_GEN_CONTROL, 0);
  93. }
  94. /**
  95. * e1000_read_phy_reg_mdic - Read MDI control register
  96. * @hw: pointer to the HW structure
  97. * @offset: register offset to be read
  98. * @data: pointer to the read data
  99. *
  100. * Reads the MDI control register in the PHY at offset and stores the
  101. * information read to data.
  102. **/
  103. static s32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
  104. {
  105. struct e1000_phy_info *phy = &hw->phy;
  106. u32 i, mdic = 0;
  107. if (offset > MAX_PHY_REG_ADDRESS) {
  108. hw_dbg(hw, "PHY Address %d is out of range\n", offset);
  109. return -E1000_ERR_PARAM;
  110. }
  111. /* Set up Op-code, Phy Address, and register offset in the MDI
  112. * Control register. The MAC will take care of interfacing with the
  113. * PHY to retrieve the desired data.
  114. */
  115. mdic = ((offset << E1000_MDIC_REG_SHIFT) |
  116. (phy->addr << E1000_MDIC_PHY_SHIFT) |
  117. (E1000_MDIC_OP_READ));
  118. ew32(MDIC, mdic);
  119. /* Poll the ready bit to see if the MDI read completed */
  120. for (i = 0; i < 64; i++) {
  121. udelay(50);
  122. mdic = er32(MDIC);
  123. if (mdic & E1000_MDIC_READY)
  124. break;
  125. }
  126. if (!(mdic & E1000_MDIC_READY)) {
  127. hw_dbg(hw, "MDI Read did not complete\n");
  128. return -E1000_ERR_PHY;
  129. }
  130. if (mdic & E1000_MDIC_ERROR) {
  131. hw_dbg(hw, "MDI Error\n");
  132. return -E1000_ERR_PHY;
  133. }
  134. *data = (u16) mdic;
  135. return 0;
  136. }
  137. /**
  138. * e1000_write_phy_reg_mdic - Write MDI control register
  139. * @hw: pointer to the HW structure
  140. * @offset: register offset to write to
  141. * @data: data to write to register at offset
  142. *
  143. * Writes data to MDI control register in the PHY at offset.
  144. **/
  145. static s32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
  146. {
  147. struct e1000_phy_info *phy = &hw->phy;
  148. u32 i, mdic = 0;
  149. if (offset > MAX_PHY_REG_ADDRESS) {
  150. hw_dbg(hw, "PHY Address %d is out of range\n", offset);
  151. return -E1000_ERR_PARAM;
  152. }
  153. /* Set up Op-code, Phy Address, and register offset in the MDI
  154. * Control register. The MAC will take care of interfacing with the
  155. * PHY to retrieve the desired data.
  156. */
  157. mdic = (((u32)data) |
  158. (offset << E1000_MDIC_REG_SHIFT) |
  159. (phy->addr << E1000_MDIC_PHY_SHIFT) |
  160. (E1000_MDIC_OP_WRITE));
  161. ew32(MDIC, mdic);
  162. /* Poll the ready bit to see if the MDI read completed */
  163. for (i = 0; i < E1000_GEN_POLL_TIMEOUT; i++) {
  164. udelay(5);
  165. mdic = er32(MDIC);
  166. if (mdic & E1000_MDIC_READY)
  167. break;
  168. }
  169. if (!(mdic & E1000_MDIC_READY)) {
  170. hw_dbg(hw, "MDI Write did not complete\n");
  171. return -E1000_ERR_PHY;
  172. }
  173. return 0;
  174. }
  175. /**
  176. * e1000e_read_phy_reg_m88 - Read m88 PHY register
  177. * @hw: pointer to the HW structure
  178. * @offset: register offset to be read
  179. * @data: pointer to the read data
  180. *
  181. * Acquires semaphore, if necessary, then reads the PHY register at offset
  182. * and storing the retrieved information in data. Release any acquired
  183. * semaphores before exiting.
  184. **/
  185. s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data)
  186. {
  187. s32 ret_val;
  188. ret_val = hw->phy.ops.acquire_phy(hw);
  189. if (ret_val)
  190. return ret_val;
  191. ret_val = e1000_read_phy_reg_mdic(hw,
  192. MAX_PHY_REG_ADDRESS & offset,
  193. data);
  194. hw->phy.ops.release_phy(hw);
  195. return ret_val;
  196. }
  197. /**
  198. * e1000e_write_phy_reg_m88 - Write m88 PHY register
  199. * @hw: pointer to the HW structure
  200. * @offset: register offset to write to
  201. * @data: data to write at register offset
  202. *
  203. * Acquires semaphore, if necessary, then writes the data to PHY register
  204. * at the offset. Release any acquired semaphores before exiting.
  205. **/
  206. s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data)
  207. {
  208. s32 ret_val;
  209. ret_val = hw->phy.ops.acquire_phy(hw);
  210. if (ret_val)
  211. return ret_val;
  212. ret_val = e1000_write_phy_reg_mdic(hw,
  213. MAX_PHY_REG_ADDRESS & offset,
  214. data);
  215. hw->phy.ops.release_phy(hw);
  216. return ret_val;
  217. }
  218. /**
  219. * e1000e_read_phy_reg_igp - Read igp PHY register
  220. * @hw: pointer to the HW structure
  221. * @offset: register offset to be read
  222. * @data: pointer to the read data
  223. *
  224. * Acquires semaphore, if necessary, then reads the PHY register at offset
  225. * and storing the retrieved information in data. Release any acquired
  226. * semaphores before exiting.
  227. **/
  228. s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data)
  229. {
  230. s32 ret_val;
  231. ret_val = hw->phy.ops.acquire_phy(hw);
  232. if (ret_val)
  233. return ret_val;
  234. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  235. ret_val = e1000_write_phy_reg_mdic(hw,
  236. IGP01E1000_PHY_PAGE_SELECT,
  237. (u16)offset);
  238. if (ret_val) {
  239. hw->phy.ops.release_phy(hw);
  240. return ret_val;
  241. }
  242. }
  243. ret_val = e1000_read_phy_reg_mdic(hw,
  244. MAX_PHY_REG_ADDRESS & offset,
  245. data);
  246. hw->phy.ops.release_phy(hw);
  247. return ret_val;
  248. }
  249. /**
  250. * e1000e_write_phy_reg_igp - Write igp PHY register
  251. * @hw: pointer to the HW structure
  252. * @offset: register offset to write to
  253. * @data: data to write at register offset
  254. *
  255. * Acquires semaphore, if necessary, then writes the data to PHY register
  256. * at the offset. Release any acquired semaphores before exiting.
  257. **/
  258. s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data)
  259. {
  260. s32 ret_val;
  261. ret_val = hw->phy.ops.acquire_phy(hw);
  262. if (ret_val)
  263. return ret_val;
  264. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  265. ret_val = e1000_write_phy_reg_mdic(hw,
  266. IGP01E1000_PHY_PAGE_SELECT,
  267. (u16)offset);
  268. if (ret_val) {
  269. hw->phy.ops.release_phy(hw);
  270. return ret_val;
  271. }
  272. }
  273. ret_val = e1000_write_phy_reg_mdic(hw,
  274. MAX_PHY_REG_ADDRESS & offset,
  275. data);
  276. hw->phy.ops.release_phy(hw);
  277. return ret_val;
  278. }
  279. /**
  280. * e1000e_read_kmrn_reg - Read kumeran register
  281. * @hw: pointer to the HW structure
  282. * @offset: register offset to be read
  283. * @data: pointer to the read data
  284. *
  285. * Acquires semaphore, if necessary. Then reads the PHY register at offset
  286. * using the kumeran interface. The information retrieved is stored in data.
  287. * Release any acquired semaphores before exiting.
  288. **/
  289. s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
  290. {
  291. u32 kmrnctrlsta;
  292. s32 ret_val;
  293. ret_val = hw->phy.ops.acquire_phy(hw);
  294. if (ret_val)
  295. return ret_val;
  296. kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
  297. E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
  298. ew32(KMRNCTRLSTA, kmrnctrlsta);
  299. udelay(2);
  300. kmrnctrlsta = er32(KMRNCTRLSTA);
  301. *data = (u16)kmrnctrlsta;
  302. hw->phy.ops.release_phy(hw);
  303. return ret_val;
  304. }
  305. /**
  306. * e1000e_write_kmrn_reg - Write kumeran register
  307. * @hw: pointer to the HW structure
  308. * @offset: register offset to write to
  309. * @data: data to write at register offset
  310. *
  311. * Acquires semaphore, if necessary. Then write the data to PHY register
  312. * at the offset using the kumeran interface. Release any acquired semaphores
  313. * before exiting.
  314. **/
  315. s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
  316. {
  317. u32 kmrnctrlsta;
  318. s32 ret_val;
  319. ret_val = hw->phy.ops.acquire_phy(hw);
  320. if (ret_val)
  321. return ret_val;
  322. kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
  323. E1000_KMRNCTRLSTA_OFFSET) | data;
  324. ew32(KMRNCTRLSTA, kmrnctrlsta);
  325. udelay(2);
  326. hw->phy.ops.release_phy(hw);
  327. return ret_val;
  328. }
  329. /**
  330. * e1000e_copper_link_setup_m88 - Setup m88 PHY's for copper link
  331. * @hw: pointer to the HW structure
  332. *
  333. * Sets up MDI/MDI-X and polarity for m88 PHY's. If necessary, transmit clock
  334. * and downshift values are set also.
  335. **/
  336. s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw)
  337. {
  338. struct e1000_phy_info *phy = &hw->phy;
  339. s32 ret_val;
  340. u16 phy_data;
  341. /* Enable CRS on TX. This must be set for half-duplex operation. */
  342. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
  343. if (ret_val)
  344. return ret_val;
  345. phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
  346. /* Options:
  347. * MDI/MDI-X = 0 (default)
  348. * 0 - Auto for all speeds
  349. * 1 - MDI mode
  350. * 2 - MDI-X mode
  351. * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
  352. */
  353. phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
  354. switch (phy->mdix) {
  355. case 1:
  356. phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
  357. break;
  358. case 2:
  359. phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
  360. break;
  361. case 3:
  362. phy_data |= M88E1000_PSCR_AUTO_X_1000T;
  363. break;
  364. case 0:
  365. default:
  366. phy_data |= M88E1000_PSCR_AUTO_X_MODE;
  367. break;
  368. }
  369. /* Options:
  370. * disable_polarity_correction = 0 (default)
  371. * Automatic Correction for Reversed Cable Polarity
  372. * 0 - Disabled
  373. * 1 - Enabled
  374. */
  375. phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
  376. if (phy->disable_polarity_correction == 1)
  377. phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
  378. ret_val = e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
  379. if (ret_val)
  380. return ret_val;
  381. if (phy->revision < 4) {
  382. /* Force TX_CLK in the Extended PHY Specific Control Register
  383. * to 25MHz clock.
  384. */
  385. ret_val = e1e_rphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
  386. if (ret_val)
  387. return ret_val;
  388. phy_data |= M88E1000_EPSCR_TX_CLK_25;
  389. if ((phy->revision == 2) &&
  390. (phy->id == M88E1111_I_PHY_ID)) {
  391. /* 82573L PHY - set the downshift counter to 5x. */
  392. phy_data &= ~M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK;
  393. phy_data |= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X;
  394. } else {
  395. /* Configure Master and Slave downshift values */
  396. phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
  397. M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
  398. phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
  399. M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
  400. }
  401. ret_val = e1e_wphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
  402. if (ret_val)
  403. return ret_val;
  404. }
  405. /* Commit the changes. */
  406. ret_val = e1000e_commit_phy(hw);
  407. if (ret_val)
  408. hw_dbg(hw, "Error committing the PHY changes\n");
  409. return ret_val;
  410. }
  411. /**
  412. * e1000e_copper_link_setup_igp - Setup igp PHY's for copper link
  413. * @hw: pointer to the HW structure
  414. *
  415. * Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for
  416. * igp PHY's.
  417. **/
  418. s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw)
  419. {
  420. struct e1000_phy_info *phy = &hw->phy;
  421. s32 ret_val;
  422. u16 data;
  423. ret_val = e1000_phy_hw_reset(hw);
  424. if (ret_val) {
  425. hw_dbg(hw, "Error resetting the PHY.\n");
  426. return ret_val;
  427. }
  428. /* Wait 15ms for MAC to configure PHY from NVM settings. */
  429. msleep(15);
  430. /* disable lplu d0 during driver init */
  431. ret_val = e1000_set_d0_lplu_state(hw, 0);
  432. if (ret_val) {
  433. hw_dbg(hw, "Error Disabling LPLU D0\n");
  434. return ret_val;
  435. }
  436. /* Configure mdi-mdix settings */
  437. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CTRL, &data);
  438. if (ret_val)
  439. return ret_val;
  440. data &= ~IGP01E1000_PSCR_AUTO_MDIX;
  441. switch (phy->mdix) {
  442. case 1:
  443. data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
  444. break;
  445. case 2:
  446. data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
  447. break;
  448. case 0:
  449. default:
  450. data |= IGP01E1000_PSCR_AUTO_MDIX;
  451. break;
  452. }
  453. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CTRL, data);
  454. if (ret_val)
  455. return ret_val;
  456. /* set auto-master slave resolution settings */
  457. if (hw->mac.autoneg) {
  458. /* when autonegotiation advertisement is only 1000Mbps then we
  459. * should disable SmartSpeed and enable Auto MasterSlave
  460. * resolution as hardware default. */
  461. if (phy->autoneg_advertised == ADVERTISE_1000_FULL) {
  462. /* Disable SmartSpeed */
  463. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  464. &data);
  465. if (ret_val)
  466. return ret_val;
  467. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  468. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  469. data);
  470. if (ret_val)
  471. return ret_val;
  472. /* Set auto Master/Slave resolution process */
  473. ret_val = e1e_rphy(hw, PHY_1000T_CTRL, &data);
  474. if (ret_val)
  475. return ret_val;
  476. data &= ~CR_1000T_MS_ENABLE;
  477. ret_val = e1e_wphy(hw, PHY_1000T_CTRL, data);
  478. if (ret_val)
  479. return ret_val;
  480. }
  481. ret_val = e1e_rphy(hw, PHY_1000T_CTRL, &data);
  482. if (ret_val)
  483. return ret_val;
  484. /* load defaults for future use */
  485. phy->original_ms_type = (data & CR_1000T_MS_ENABLE) ?
  486. ((data & CR_1000T_MS_VALUE) ?
  487. e1000_ms_force_master :
  488. e1000_ms_force_slave) :
  489. e1000_ms_auto;
  490. switch (phy->ms_type) {
  491. case e1000_ms_force_master:
  492. data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
  493. break;
  494. case e1000_ms_force_slave:
  495. data |= CR_1000T_MS_ENABLE;
  496. data &= ~(CR_1000T_MS_VALUE);
  497. break;
  498. case e1000_ms_auto:
  499. data &= ~CR_1000T_MS_ENABLE;
  500. default:
  501. break;
  502. }
  503. ret_val = e1e_wphy(hw, PHY_1000T_CTRL, data);
  504. }
  505. return ret_val;
  506. }
  507. /**
  508. * e1000_phy_setup_autoneg - Configure PHY for auto-negotiation
  509. * @hw: pointer to the HW structure
  510. *
  511. * Reads the MII auto-neg advertisement register and/or the 1000T control
  512. * register and if the PHY is already setup for auto-negotiation, then
  513. * return successful. Otherwise, setup advertisement and flow control to
  514. * the appropriate values for the wanted auto-negotiation.
  515. **/
  516. static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)
  517. {
  518. struct e1000_phy_info *phy = &hw->phy;
  519. s32 ret_val;
  520. u16 mii_autoneg_adv_reg;
  521. u16 mii_1000t_ctrl_reg = 0;
  522. phy->autoneg_advertised &= phy->autoneg_mask;
  523. /* Read the MII Auto-Neg Advertisement Register (Address 4). */
  524. ret_val = e1e_rphy(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg);
  525. if (ret_val)
  526. return ret_val;
  527. if (phy->autoneg_mask & ADVERTISE_1000_FULL) {
  528. /* Read the MII 1000Base-T Control Register (Address 9). */
  529. ret_val = e1e_rphy(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg);
  530. if (ret_val)
  531. return ret_val;
  532. }
  533. /* Need to parse both autoneg_advertised and fc and set up
  534. * the appropriate PHY registers. First we will parse for
  535. * autoneg_advertised software override. Since we can advertise
  536. * a plethora of combinations, we need to check each bit
  537. * individually.
  538. */
  539. /* First we clear all the 10/100 mb speed bits in the Auto-Neg
  540. * Advertisement Register (Address 4) and the 1000 mb speed bits in
  541. * the 1000Base-T Control Register (Address 9).
  542. */
  543. mii_autoneg_adv_reg &= ~(NWAY_AR_100TX_FD_CAPS |
  544. NWAY_AR_100TX_HD_CAPS |
  545. NWAY_AR_10T_FD_CAPS |
  546. NWAY_AR_10T_HD_CAPS);
  547. mii_1000t_ctrl_reg &= ~(CR_1000T_HD_CAPS | CR_1000T_FD_CAPS);
  548. hw_dbg(hw, "autoneg_advertised %x\n", phy->autoneg_advertised);
  549. /* Do we want to advertise 10 Mb Half Duplex? */
  550. if (phy->autoneg_advertised & ADVERTISE_10_HALF) {
  551. hw_dbg(hw, "Advertise 10mb Half duplex\n");
  552. mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
  553. }
  554. /* Do we want to advertise 10 Mb Full Duplex? */
  555. if (phy->autoneg_advertised & ADVERTISE_10_FULL) {
  556. hw_dbg(hw, "Advertise 10mb Full duplex\n");
  557. mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
  558. }
  559. /* Do we want to advertise 100 Mb Half Duplex? */
  560. if (phy->autoneg_advertised & ADVERTISE_100_HALF) {
  561. hw_dbg(hw, "Advertise 100mb Half duplex\n");
  562. mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
  563. }
  564. /* Do we want to advertise 100 Mb Full Duplex? */
  565. if (phy->autoneg_advertised & ADVERTISE_100_FULL) {
  566. hw_dbg(hw, "Advertise 100mb Full duplex\n");
  567. mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
  568. }
  569. /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
  570. if (phy->autoneg_advertised & ADVERTISE_1000_HALF)
  571. hw_dbg(hw, "Advertise 1000mb Half duplex request denied!\n");
  572. /* Do we want to advertise 1000 Mb Full Duplex? */
  573. if (phy->autoneg_advertised & ADVERTISE_1000_FULL) {
  574. hw_dbg(hw, "Advertise 1000mb Full duplex\n");
  575. mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
  576. }
  577. /* Check for a software override of the flow control settings, and
  578. * setup the PHY advertisement registers accordingly. If
  579. * auto-negotiation is enabled, then software will have to set the
  580. * "PAUSE" bits to the correct value in the Auto-Negotiation
  581. * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-
  582. * negotiation.
  583. *
  584. * The possible values of the "fc" parameter are:
  585. * 0: Flow control is completely disabled
  586. * 1: Rx flow control is enabled (we can receive pause frames
  587. * but not send pause frames).
  588. * 2: Tx flow control is enabled (we can send pause frames
  589. * but we do not support receiving pause frames).
  590. * 3: Both Rx and TX flow control (symmetric) are enabled.
  591. * other: No software override. The flow control configuration
  592. * in the EEPROM is used.
  593. */
  594. switch (hw->mac.fc) {
  595. case e1000_fc_none:
  596. /* Flow control (RX & TX) is completely disabled by a
  597. * software over-ride.
  598. */
  599. mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  600. break;
  601. case e1000_fc_rx_pause:
  602. /* RX Flow control is enabled, and TX Flow control is
  603. * disabled, by a software over-ride.
  604. */
  605. /* Since there really isn't a way to advertise that we are
  606. * capable of RX Pause ONLY, we will advertise that we
  607. * support both symmetric and asymmetric RX PAUSE. Later
  608. * (in e1000e_config_fc_after_link_up) we will disable the
  609. * hw's ability to send PAUSE frames.
  610. */
  611. mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  612. break;
  613. case e1000_fc_tx_pause:
  614. /* TX Flow control is enabled, and RX Flow control is
  615. * disabled, by a software over-ride.
  616. */
  617. mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
  618. mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
  619. break;
  620. case e1000_fc_full:
  621. /* Flow control (both RX and TX) is enabled by a software
  622. * over-ride.
  623. */
  624. mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  625. break;
  626. default:
  627. hw_dbg(hw, "Flow control param set incorrectly\n");
  628. ret_val = -E1000_ERR_CONFIG;
  629. return ret_val;
  630. }
  631. ret_val = e1e_wphy(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg);
  632. if (ret_val)
  633. return ret_val;
  634. hw_dbg(hw, "Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
  635. if (phy->autoneg_mask & ADVERTISE_1000_FULL) {
  636. ret_val = e1e_wphy(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
  637. }
  638. return ret_val;
  639. }
  640. /**
  641. * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link
  642. * @hw: pointer to the HW structure
  643. *
  644. * Performs initial bounds checking on autoneg advertisement parameter, then
  645. * configure to advertise the full capability. Setup the PHY to autoneg
  646. * and restart the negotiation process between the link partner. If
  647. * wait_for_link, then wait for autoneg to complete before exiting.
  648. **/
  649. static s32 e1000_copper_link_autoneg(struct e1000_hw *hw)
  650. {
  651. struct e1000_phy_info *phy = &hw->phy;
  652. s32 ret_val;
  653. u16 phy_ctrl;
  654. /* Perform some bounds checking on the autoneg advertisement
  655. * parameter.
  656. */
  657. phy->autoneg_advertised &= phy->autoneg_mask;
  658. /* If autoneg_advertised is zero, we assume it was not defaulted
  659. * by the calling code so we set to advertise full capability.
  660. */
  661. if (phy->autoneg_advertised == 0)
  662. phy->autoneg_advertised = phy->autoneg_mask;
  663. hw_dbg(hw, "Reconfiguring auto-neg advertisement params\n");
  664. ret_val = e1000_phy_setup_autoneg(hw);
  665. if (ret_val) {
  666. hw_dbg(hw, "Error Setting up Auto-Negotiation\n");
  667. return ret_val;
  668. }
  669. hw_dbg(hw, "Restarting Auto-Neg\n");
  670. /* Restart auto-negotiation by setting the Auto Neg Enable bit and
  671. * the Auto Neg Restart bit in the PHY control register.
  672. */
  673. ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_ctrl);
  674. if (ret_val)
  675. return ret_val;
  676. phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
  677. ret_val = e1e_wphy(hw, PHY_CONTROL, phy_ctrl);
  678. if (ret_val)
  679. return ret_val;
  680. /* Does the user want to wait for Auto-Neg to complete here, or
  681. * check at a later time (for example, callback routine).
  682. */
  683. if (phy->wait_for_link) {
  684. ret_val = e1000_wait_autoneg(hw);
  685. if (ret_val) {
  686. hw_dbg(hw, "Error while waiting for "
  687. "autoneg to complete\n");
  688. return ret_val;
  689. }
  690. }
  691. hw->mac.get_link_status = 1;
  692. return ret_val;
  693. }
  694. /**
  695. * e1000e_setup_copper_link - Configure copper link settings
  696. * @hw: pointer to the HW structure
  697. *
  698. * Calls the appropriate function to configure the link for auto-neg or forced
  699. * speed and duplex. Then we check for link, once link is established calls
  700. * to configure collision distance and flow control are called. If link is
  701. * not established, we return -E1000_ERR_PHY (-2).
  702. **/
  703. s32 e1000e_setup_copper_link(struct e1000_hw *hw)
  704. {
  705. s32 ret_val;
  706. bool link;
  707. if (hw->mac.autoneg) {
  708. /* Setup autoneg and flow control advertisement and perform
  709. * autonegotiation. */
  710. ret_val = e1000_copper_link_autoneg(hw);
  711. if (ret_val)
  712. return ret_val;
  713. } else {
  714. /* PHY will be set to 10H, 10F, 100H or 100F
  715. * depending on user settings. */
  716. hw_dbg(hw, "Forcing Speed and Duplex\n");
  717. ret_val = e1000_phy_force_speed_duplex(hw);
  718. if (ret_val) {
  719. hw_dbg(hw, "Error Forcing Speed and Duplex\n");
  720. return ret_val;
  721. }
  722. }
  723. /* Check link status. Wait up to 100 microseconds for link to become
  724. * valid.
  725. */
  726. ret_val = e1000e_phy_has_link_generic(hw,
  727. COPPER_LINK_UP_LIMIT,
  728. 10,
  729. &link);
  730. if (ret_val)
  731. return ret_val;
  732. if (link) {
  733. hw_dbg(hw, "Valid link established!!!\n");
  734. e1000e_config_collision_dist(hw);
  735. ret_val = e1000e_config_fc_after_link_up(hw);
  736. } else {
  737. hw_dbg(hw, "Unable to establish link!!!\n");
  738. }
  739. return ret_val;
  740. }
  741. /**
  742. * e1000e_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY
  743. * @hw: pointer to the HW structure
  744. *
  745. * Calls the PHY setup function to force speed and duplex. Clears the
  746. * auto-crossover to force MDI manually. Waits for link and returns
  747. * successful if link up is successful, else -E1000_ERR_PHY (-2).
  748. **/
  749. s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw)
  750. {
  751. struct e1000_phy_info *phy = &hw->phy;
  752. s32 ret_val;
  753. u16 phy_data;
  754. bool link;
  755. ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
  756. if (ret_val)
  757. return ret_val;
  758. e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
  759. ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
  760. if (ret_val)
  761. return ret_val;
  762. /* Clear Auto-Crossover to force MDI manually. IGP requires MDI
  763. * forced whenever speed and duplex are forced.
  764. */
  765. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
  766. if (ret_val)
  767. return ret_val;
  768. phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
  769. phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
  770. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
  771. if (ret_val)
  772. return ret_val;
  773. hw_dbg(hw, "IGP PSCR: %X\n", phy_data);
  774. udelay(1);
  775. if (phy->wait_for_link) {
  776. hw_dbg(hw, "Waiting for forced speed/duplex link on IGP phy.\n");
  777. ret_val = e1000e_phy_has_link_generic(hw,
  778. PHY_FORCE_LIMIT,
  779. 100000,
  780. &link);
  781. if (ret_val)
  782. return ret_val;
  783. if (!link)
  784. hw_dbg(hw, "Link taking longer than expected.\n");
  785. /* Try once more */
  786. ret_val = e1000e_phy_has_link_generic(hw,
  787. PHY_FORCE_LIMIT,
  788. 100000,
  789. &link);
  790. if (ret_val)
  791. return ret_val;
  792. }
  793. return ret_val;
  794. }
  795. /**
  796. * e1000e_phy_force_speed_duplex_m88 - Force speed/duplex for m88 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. Resets the PHY to commit the
  801. * changes. If time expires while waiting for link up, we reset the DSP.
  802. * After reset, TX_CLK and CRS on TX must be set. Return successful upon
  803. * successful completion, else return corresponding error code.
  804. **/
  805. s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw)
  806. {
  807. struct e1000_phy_info *phy = &hw->phy;
  808. s32 ret_val;
  809. u16 phy_data;
  810. bool link;
  811. /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
  812. * forced whenever speed and duplex are forced.
  813. */
  814. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
  815. if (ret_val)
  816. return ret_val;
  817. phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
  818. ret_val = e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
  819. if (ret_val)
  820. return ret_val;
  821. hw_dbg(hw, "M88E1000 PSCR: %X\n", phy_data);
  822. ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
  823. if (ret_val)
  824. return ret_val;
  825. e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
  826. /* Reset the phy to commit changes. */
  827. phy_data |= MII_CR_RESET;
  828. ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
  829. if (ret_val)
  830. return ret_val;
  831. udelay(1);
  832. if (phy->wait_for_link) {
  833. hw_dbg(hw, "Waiting for forced speed/duplex link on M88 phy.\n");
  834. ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
  835. 100000, &link);
  836. if (ret_val)
  837. return ret_val;
  838. if (!link) {
  839. /* We didn't get link.
  840. * Reset the DSP and cross our fingers.
  841. */
  842. ret_val = e1e_wphy(hw, M88E1000_PHY_PAGE_SELECT, 0x001d);
  843. if (ret_val)
  844. return ret_val;
  845. ret_val = e1000e_phy_reset_dsp(hw);
  846. if (ret_val)
  847. return ret_val;
  848. }
  849. /* Try once more */
  850. ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
  851. 100000, &link);
  852. if (ret_val)
  853. return ret_val;
  854. }
  855. ret_val = e1e_rphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
  856. if (ret_val)
  857. return ret_val;
  858. /* Resetting the phy means we need to re-force TX_CLK in the
  859. * Extended PHY Specific Control Register to 25MHz clock from
  860. * the reset value of 2.5MHz.
  861. */
  862. phy_data |= M88E1000_EPSCR_TX_CLK_25;
  863. ret_val = e1e_wphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
  864. if (ret_val)
  865. return ret_val;
  866. /* In addition, we must re-enable CRS on Tx for both half and full
  867. * duplex.
  868. */
  869. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
  870. if (ret_val)
  871. return ret_val;
  872. phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
  873. ret_val = e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
  874. return ret_val;
  875. }
  876. /**
  877. * e1000e_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex
  878. * @hw: pointer to the HW structure
  879. * @phy_ctrl: pointer to current value of PHY_CONTROL
  880. *
  881. * Forces speed and duplex on the PHY by doing the following: disable flow
  882. * control, force speed/duplex on the MAC, disable auto speed detection,
  883. * disable auto-negotiation, configure duplex, configure speed, configure
  884. * the collision distance, write configuration to CTRL register. The
  885. * caller must write to the PHY_CONTROL register for these settings to
  886. * take affect.
  887. **/
  888. void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl)
  889. {
  890. struct e1000_mac_info *mac = &hw->mac;
  891. u32 ctrl;
  892. /* Turn off flow control when forcing speed/duplex */
  893. mac->fc = e1000_fc_none;
  894. /* Force speed/duplex on the mac */
  895. ctrl = er32(CTRL);
  896. ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  897. ctrl &= ~E1000_CTRL_SPD_SEL;
  898. /* Disable Auto Speed Detection */
  899. ctrl &= ~E1000_CTRL_ASDE;
  900. /* Disable autoneg on the phy */
  901. *phy_ctrl &= ~MII_CR_AUTO_NEG_EN;
  902. /* Forcing Full or Half Duplex? */
  903. if (mac->forced_speed_duplex & E1000_ALL_HALF_DUPLEX) {
  904. ctrl &= ~E1000_CTRL_FD;
  905. *phy_ctrl &= ~MII_CR_FULL_DUPLEX;
  906. hw_dbg(hw, "Half Duplex\n");
  907. } else {
  908. ctrl |= E1000_CTRL_FD;
  909. *phy_ctrl |= MII_CR_FULL_DUPLEX;
  910. hw_dbg(hw, "Full Duplex\n");
  911. }
  912. /* Forcing 10mb or 100mb? */
  913. if (mac->forced_speed_duplex & E1000_ALL_100_SPEED) {
  914. ctrl |= E1000_CTRL_SPD_100;
  915. *phy_ctrl |= MII_CR_SPEED_100;
  916. *phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_10);
  917. hw_dbg(hw, "Forcing 100mb\n");
  918. } else {
  919. ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
  920. *phy_ctrl |= MII_CR_SPEED_10;
  921. *phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100);
  922. hw_dbg(hw, "Forcing 10mb\n");
  923. }
  924. e1000e_config_collision_dist(hw);
  925. ew32(CTRL, ctrl);
  926. }
  927. /**
  928. * e1000e_set_d3_lplu_state - Sets low power link up state for D3
  929. * @hw: pointer to the HW structure
  930. * @active: boolean used to enable/disable lplu
  931. *
  932. * Success returns 0, Failure returns 1
  933. *
  934. * The low power link up (lplu) state is set to the power management level D3
  935. * and SmartSpeed is disabled when active is true, else clear lplu for D3
  936. * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
  937. * is used during Dx states where the power conservation is most important.
  938. * During driver activity, SmartSpeed should be enabled so performance is
  939. * maintained.
  940. **/
  941. s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active)
  942. {
  943. struct e1000_phy_info *phy = &hw->phy;
  944. s32 ret_val;
  945. u16 data;
  946. ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data);
  947. if (ret_val)
  948. return ret_val;
  949. if (!active) {
  950. data &= ~IGP02E1000_PM_D3_LPLU;
  951. ret_val = e1e_wphy(hw,
  952. IGP02E1000_PHY_POWER_MGMT,
  953. data);
  954. if (ret_val)
  955. return ret_val;
  956. /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
  957. * during Dx states where the power conservation is most
  958. * important. During driver activity we should enable
  959. * SmartSpeed, so performance is maintained. */
  960. if (phy->smart_speed == e1000_smart_speed_on) {
  961. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  962. &data);
  963. if (ret_val)
  964. return ret_val;
  965. data |= IGP01E1000_PSCFR_SMART_SPEED;
  966. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  967. data);
  968. if (ret_val)
  969. return ret_val;
  970. } else if (phy->smart_speed == e1000_smart_speed_off) {
  971. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  972. &data);
  973. if (ret_val)
  974. return ret_val;
  975. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  976. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  977. data);
  978. if (ret_val)
  979. return ret_val;
  980. }
  981. } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
  982. (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
  983. (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
  984. data |= IGP02E1000_PM_D3_LPLU;
  985. ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
  986. if (ret_val)
  987. return ret_val;
  988. /* When LPLU is enabled, we should disable SmartSpeed */
  989. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  990. if (ret_val)
  991. return ret_val;
  992. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  993. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  994. }
  995. return ret_val;
  996. }
  997. /**
  998. * e1000e_check_downshift - Checks whether a downshift in speed occurred
  999. * @hw: pointer to the HW structure
  1000. *
  1001. * Success returns 0, Failure returns 1
  1002. *
  1003. * A downshift is detected by querying the PHY link health.
  1004. **/
  1005. s32 e1000e_check_downshift(struct e1000_hw *hw)
  1006. {
  1007. struct e1000_phy_info *phy = &hw->phy;
  1008. s32 ret_val;
  1009. u16 phy_data, offset, mask;
  1010. switch (phy->type) {
  1011. case e1000_phy_m88:
  1012. case e1000_phy_gg82563:
  1013. offset = M88E1000_PHY_SPEC_STATUS;
  1014. mask = M88E1000_PSSR_DOWNSHIFT;
  1015. break;
  1016. case e1000_phy_igp_2:
  1017. case e1000_phy_igp_3:
  1018. offset = IGP01E1000_PHY_LINK_HEALTH;
  1019. mask = IGP01E1000_PLHR_SS_DOWNGRADE;
  1020. break;
  1021. default:
  1022. /* speed downshift not supported */
  1023. phy->speed_downgraded = 0;
  1024. return 0;
  1025. }
  1026. ret_val = e1e_rphy(hw, offset, &phy_data);
  1027. if (!ret_val)
  1028. phy->speed_downgraded = (phy_data & mask);
  1029. return ret_val;
  1030. }
  1031. /**
  1032. * e1000_check_polarity_m88 - Checks the polarity.
  1033. * @hw: pointer to the HW structure
  1034. *
  1035. * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
  1036. *
  1037. * Polarity is determined based on the PHY specific status register.
  1038. **/
  1039. static s32 e1000_check_polarity_m88(struct e1000_hw *hw)
  1040. {
  1041. struct e1000_phy_info *phy = &hw->phy;
  1042. s32 ret_val;
  1043. u16 data;
  1044. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &data);
  1045. if (!ret_val)
  1046. phy->cable_polarity = (data & M88E1000_PSSR_REV_POLARITY)
  1047. ? e1000_rev_polarity_reversed
  1048. : e1000_rev_polarity_normal;
  1049. return ret_val;
  1050. }
  1051. /**
  1052. * e1000_check_polarity_igp - Checks the polarity.
  1053. * @hw: pointer to the HW structure
  1054. *
  1055. * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
  1056. *
  1057. * Polarity is determined based on the PHY port status register, and the
  1058. * current speed (since there is no polarity at 100Mbps).
  1059. **/
  1060. static s32 e1000_check_polarity_igp(struct e1000_hw *hw)
  1061. {
  1062. struct e1000_phy_info *phy = &hw->phy;
  1063. s32 ret_val;
  1064. u16 data, offset, mask;
  1065. /* Polarity is determined based on the speed of
  1066. * our connection. */
  1067. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_STATUS, &data);
  1068. if (ret_val)
  1069. return ret_val;
  1070. if ((data & IGP01E1000_PSSR_SPEED_MASK) ==
  1071. IGP01E1000_PSSR_SPEED_1000MBPS) {
  1072. offset = IGP01E1000_PHY_PCS_INIT_REG;
  1073. mask = IGP01E1000_PHY_POLARITY_MASK;
  1074. } else {
  1075. /* This really only applies to 10Mbps since
  1076. * there is no polarity for 100Mbps (always 0).
  1077. */
  1078. offset = IGP01E1000_PHY_PORT_STATUS;
  1079. mask = IGP01E1000_PSSR_POLARITY_REVERSED;
  1080. }
  1081. ret_val = e1e_rphy(hw, offset, &data);
  1082. if (!ret_val)
  1083. phy->cable_polarity = (data & mask)
  1084. ? e1000_rev_polarity_reversed
  1085. : e1000_rev_polarity_normal;
  1086. return ret_val;
  1087. }
  1088. /**
  1089. * e1000_wait_autoneg - Wait for auto-neg compeletion
  1090. * @hw: pointer to the HW structure
  1091. *
  1092. * Waits for auto-negotiation to complete or for the auto-negotiation time
  1093. * limit to expire, which ever happens first.
  1094. **/
  1095. static s32 e1000_wait_autoneg(struct e1000_hw *hw)
  1096. {
  1097. s32 ret_val = 0;
  1098. u16 i, phy_status;
  1099. /* Break after autoneg completes or PHY_AUTO_NEG_LIMIT expires. */
  1100. for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) {
  1101. ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
  1102. if (ret_val)
  1103. break;
  1104. ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
  1105. if (ret_val)
  1106. break;
  1107. if (phy_status & MII_SR_AUTONEG_COMPLETE)
  1108. break;
  1109. msleep(100);
  1110. }
  1111. /* PHY_AUTO_NEG_TIME expiration doesn't guarantee auto-negotiation
  1112. * has completed.
  1113. */
  1114. return ret_val;
  1115. }
  1116. /**
  1117. * e1000e_phy_has_link_generic - Polls PHY for link
  1118. * @hw: pointer to the HW structure
  1119. * @iterations: number of times to poll for link
  1120. * @usec_interval: delay between polling attempts
  1121. * @success: pointer to whether polling was successful or not
  1122. *
  1123. * Polls the PHY status register for link, 'iterations' number of times.
  1124. **/
  1125. s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
  1126. u32 usec_interval, bool *success)
  1127. {
  1128. s32 ret_val = 0;
  1129. u16 i, phy_status;
  1130. for (i = 0; i < iterations; i++) {
  1131. /* Some PHYs require the PHY_STATUS register to be read
  1132. * twice due to the link bit being sticky. No harm doing
  1133. * it across the board.
  1134. */
  1135. ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
  1136. if (ret_val)
  1137. break;
  1138. ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
  1139. if (ret_val)
  1140. break;
  1141. if (phy_status & MII_SR_LINK_STATUS)
  1142. break;
  1143. if (usec_interval >= 1000)
  1144. mdelay(usec_interval/1000);
  1145. else
  1146. udelay(usec_interval);
  1147. }
  1148. *success = (i < iterations);
  1149. return ret_val;
  1150. }
  1151. /**
  1152. * e1000e_get_cable_length_m88 - Determine cable length for m88 PHY
  1153. * @hw: pointer to the HW structure
  1154. *
  1155. * Reads the PHY specific status register to retrieve the cable length
  1156. * information. The cable length is determined by averaging the minimum and
  1157. * maximum values to get the "average" cable length. The m88 PHY has four
  1158. * possible cable length values, which are:
  1159. * Register Value Cable Length
  1160. * 0 < 50 meters
  1161. * 1 50 - 80 meters
  1162. * 2 80 - 110 meters
  1163. * 3 110 - 140 meters
  1164. * 4 > 140 meters
  1165. **/
  1166. s32 e1000e_get_cable_length_m88(struct e1000_hw *hw)
  1167. {
  1168. struct e1000_phy_info *phy = &hw->phy;
  1169. s32 ret_val;
  1170. u16 phy_data, index;
  1171. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
  1172. if (ret_val)
  1173. return ret_val;
  1174. index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
  1175. M88E1000_PSSR_CABLE_LENGTH_SHIFT;
  1176. phy->min_cable_length = e1000_m88_cable_length_table[index];
  1177. phy->max_cable_length = e1000_m88_cable_length_table[index+1];
  1178. phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
  1179. return ret_val;
  1180. }
  1181. /**
  1182. * e1000e_get_cable_length_igp_2 - Determine cable length for igp2 PHY
  1183. * @hw: pointer to the HW structure
  1184. *
  1185. * The automatic gain control (agc) normalizes the amplitude of the
  1186. * received signal, adjusting for the attenuation produced by the
  1187. * cable. By reading the AGC registers, which represent the
  1188. * combination of course and fine gain value, the value can be put
  1189. * into a lookup table to obtain the approximate cable length
  1190. * for each channel.
  1191. **/
  1192. s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw)
  1193. {
  1194. struct e1000_phy_info *phy = &hw->phy;
  1195. s32 ret_val;
  1196. u16 phy_data, i, agc_value = 0;
  1197. u16 cur_agc_index, max_agc_index = 0;
  1198. u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1;
  1199. u16 agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] =
  1200. {IGP02E1000_PHY_AGC_A,
  1201. IGP02E1000_PHY_AGC_B,
  1202. IGP02E1000_PHY_AGC_C,
  1203. IGP02E1000_PHY_AGC_D};
  1204. /* Read the AGC registers for all channels */
  1205. for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) {
  1206. ret_val = e1e_rphy(hw, agc_reg_array[i], &phy_data);
  1207. if (ret_val)
  1208. return ret_val;
  1209. /* Getting bits 15:9, which represent the combination of
  1210. * course and fine gain values. The result is a number
  1211. * that can be put into the lookup table to obtain the
  1212. * approximate cable length. */
  1213. cur_agc_index = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) &
  1214. IGP02E1000_AGC_LENGTH_MASK;
  1215. /* Array index bound check. */
  1216. if ((cur_agc_index >= IGP02E1000_CABLE_LENGTH_TABLE_SIZE) ||
  1217. (cur_agc_index == 0))
  1218. return -E1000_ERR_PHY;
  1219. /* Remove min & max AGC values from calculation. */
  1220. if (e1000_igp_2_cable_length_table[min_agc_index] >
  1221. e1000_igp_2_cable_length_table[cur_agc_index])
  1222. min_agc_index = cur_agc_index;
  1223. if (e1000_igp_2_cable_length_table[max_agc_index] <
  1224. e1000_igp_2_cable_length_table[cur_agc_index])
  1225. max_agc_index = cur_agc_index;
  1226. agc_value += e1000_igp_2_cable_length_table[cur_agc_index];
  1227. }
  1228. agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] +
  1229. e1000_igp_2_cable_length_table[max_agc_index]);
  1230. agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2);
  1231. /* Calculate cable length with the error range of +/- 10 meters. */
  1232. phy->min_cable_length = ((agc_value - IGP02E1000_AGC_RANGE) > 0) ?
  1233. (agc_value - IGP02E1000_AGC_RANGE) : 0;
  1234. phy->max_cable_length = agc_value + IGP02E1000_AGC_RANGE;
  1235. phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
  1236. return ret_val;
  1237. }
  1238. /**
  1239. * e1000e_get_phy_info_m88 - Retrieve PHY information
  1240. * @hw: pointer to the HW structure
  1241. *
  1242. * Valid for only copper links. Read the PHY status register (sticky read)
  1243. * to verify that link is up. Read the PHY special control register to
  1244. * determine the polarity and 10base-T extended distance. Read the PHY
  1245. * special status register to determine MDI/MDIx and current speed. If
  1246. * speed is 1000, then determine cable length, local and remote receiver.
  1247. **/
  1248. s32 e1000e_get_phy_info_m88(struct e1000_hw *hw)
  1249. {
  1250. struct e1000_phy_info *phy = &hw->phy;
  1251. s32 ret_val;
  1252. u16 phy_data;
  1253. bool link;
  1254. if (hw->media_type != e1000_media_type_copper) {
  1255. hw_dbg(hw, "Phy info is only valid for copper media\n");
  1256. return -E1000_ERR_CONFIG;
  1257. }
  1258. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  1259. if (ret_val)
  1260. return ret_val;
  1261. if (!link) {
  1262. hw_dbg(hw, "Phy info is only valid if link is up\n");
  1263. return -E1000_ERR_CONFIG;
  1264. }
  1265. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
  1266. if (ret_val)
  1267. return ret_val;
  1268. phy->polarity_correction = (phy_data &
  1269. M88E1000_PSCR_POLARITY_REVERSAL);
  1270. ret_val = e1000_check_polarity_m88(hw);
  1271. if (ret_val)
  1272. return ret_val;
  1273. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
  1274. if (ret_val)
  1275. return ret_val;
  1276. phy->is_mdix = (phy_data & M88E1000_PSSR_MDIX);
  1277. if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) {
  1278. ret_val = e1000_get_cable_length(hw);
  1279. if (ret_val)
  1280. return ret_val;
  1281. ret_val = e1e_rphy(hw, PHY_1000T_STATUS, &phy_data);
  1282. if (ret_val)
  1283. return ret_val;
  1284. phy->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)
  1285. ? e1000_1000t_rx_status_ok
  1286. : e1000_1000t_rx_status_not_ok;
  1287. phy->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)
  1288. ? e1000_1000t_rx_status_ok
  1289. : e1000_1000t_rx_status_not_ok;
  1290. } else {
  1291. /* Set values to "undefined" */
  1292. phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;
  1293. phy->local_rx = e1000_1000t_rx_status_undefined;
  1294. phy->remote_rx = e1000_1000t_rx_status_undefined;
  1295. }
  1296. return ret_val;
  1297. }
  1298. /**
  1299. * e1000e_get_phy_info_igp - Retrieve igp PHY information
  1300. * @hw: pointer to the HW structure
  1301. *
  1302. * Read PHY status to determine if link is up. If link is up, then
  1303. * set/determine 10base-T extended distance and polarity correction. Read
  1304. * PHY port status to determine MDI/MDIx and speed. Based on the speed,
  1305. * determine on the cable length, local and remote receiver.
  1306. **/
  1307. s32 e1000e_get_phy_info_igp(struct e1000_hw *hw)
  1308. {
  1309. struct e1000_phy_info *phy = &hw->phy;
  1310. s32 ret_val;
  1311. u16 data;
  1312. bool link;
  1313. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  1314. if (ret_val)
  1315. return ret_val;
  1316. if (!link) {
  1317. hw_dbg(hw, "Phy info is only valid if link is up\n");
  1318. return -E1000_ERR_CONFIG;
  1319. }
  1320. phy->polarity_correction = 1;
  1321. ret_val = e1000_check_polarity_igp(hw);
  1322. if (ret_val)
  1323. return ret_val;
  1324. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_STATUS, &data);
  1325. if (ret_val)
  1326. return ret_val;
  1327. phy->is_mdix = (data & IGP01E1000_PSSR_MDIX);
  1328. if ((data & IGP01E1000_PSSR_SPEED_MASK) ==
  1329. IGP01E1000_PSSR_SPEED_1000MBPS) {
  1330. ret_val = e1000_get_cable_length(hw);
  1331. if (ret_val)
  1332. return ret_val;
  1333. ret_val = e1e_rphy(hw, PHY_1000T_STATUS, &data);
  1334. if (ret_val)
  1335. return ret_val;
  1336. phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS)
  1337. ? e1000_1000t_rx_status_ok
  1338. : e1000_1000t_rx_status_not_ok;
  1339. phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS)
  1340. ? e1000_1000t_rx_status_ok
  1341. : e1000_1000t_rx_status_not_ok;
  1342. } else {
  1343. phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;
  1344. phy->local_rx = e1000_1000t_rx_status_undefined;
  1345. phy->remote_rx = e1000_1000t_rx_status_undefined;
  1346. }
  1347. return ret_val;
  1348. }
  1349. /**
  1350. * e1000e_phy_sw_reset - PHY software reset
  1351. * @hw: pointer to the HW structure
  1352. *
  1353. * Does a software reset of the PHY by reading the PHY control register and
  1354. * setting/write the control register reset bit to the PHY.
  1355. **/
  1356. s32 e1000e_phy_sw_reset(struct e1000_hw *hw)
  1357. {
  1358. s32 ret_val;
  1359. u16 phy_ctrl;
  1360. ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_ctrl);
  1361. if (ret_val)
  1362. return ret_val;
  1363. phy_ctrl |= MII_CR_RESET;
  1364. ret_val = e1e_wphy(hw, PHY_CONTROL, phy_ctrl);
  1365. if (ret_val)
  1366. return ret_val;
  1367. udelay(1);
  1368. return ret_val;
  1369. }
  1370. /**
  1371. * e1000e_phy_hw_reset_generic - PHY hardware reset
  1372. * @hw: pointer to the HW structure
  1373. *
  1374. * Verify the reset block is not blocking us from resetting. Acquire
  1375. * semaphore (if necessary) and read/set/write the device control reset
  1376. * bit in the PHY. Wait the appropriate delay time for the device to
  1377. * reset and release the semaphore (if necessary).
  1378. **/
  1379. s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw)
  1380. {
  1381. struct e1000_phy_info *phy = &hw->phy;
  1382. s32 ret_val;
  1383. u32 ctrl;
  1384. ret_val = e1000_check_reset_block(hw);
  1385. if (ret_val)
  1386. return 0;
  1387. ret_val = phy->ops.acquire_phy(hw);
  1388. if (ret_val)
  1389. return ret_val;
  1390. ctrl = er32(CTRL);
  1391. ew32(CTRL, ctrl | E1000_CTRL_PHY_RST);
  1392. e1e_flush();
  1393. udelay(phy->reset_delay_us);
  1394. ew32(CTRL, ctrl);
  1395. e1e_flush();
  1396. udelay(150);
  1397. phy->ops.release_phy(hw);
  1398. return e1000_get_phy_cfg_done(hw);
  1399. }
  1400. /**
  1401. * e1000e_get_cfg_done - Generic configuration done
  1402. * @hw: pointer to the HW structure
  1403. *
  1404. * Generic function to wait 10 milli-seconds for configuration to complete
  1405. * and return success.
  1406. **/
  1407. s32 e1000e_get_cfg_done(struct e1000_hw *hw)
  1408. {
  1409. mdelay(10);
  1410. return 0;
  1411. }
  1412. /* Internal function pointers */
  1413. /**
  1414. * e1000_get_phy_cfg_done - Generic PHY configuration done
  1415. * @hw: pointer to the HW structure
  1416. *
  1417. * Return success if silicon family did not implement a family specific
  1418. * get_cfg_done function.
  1419. **/
  1420. static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw)
  1421. {
  1422. if (hw->phy.ops.get_cfg_done)
  1423. return hw->phy.ops.get_cfg_done(hw);
  1424. return 0;
  1425. }
  1426. /**
  1427. * e1000_phy_force_speed_duplex - Generic force PHY speed/duplex
  1428. * @hw: pointer to the HW structure
  1429. *
  1430. * When the silicon family has not implemented a forced speed/duplex
  1431. * function for the PHY, simply return 0.
  1432. **/
  1433. static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)
  1434. {
  1435. if (hw->phy.ops.force_speed_duplex)
  1436. return hw->phy.ops.force_speed_duplex(hw);
  1437. return 0;
  1438. }
  1439. /**
  1440. * e1000e_get_phy_type_from_id - Get PHY type from id
  1441. * @phy_id: phy_id read from the phy
  1442. *
  1443. * Returns the phy type from the id.
  1444. **/
  1445. enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id)
  1446. {
  1447. enum e1000_phy_type phy_type = e1000_phy_unknown;
  1448. switch (phy_id) {
  1449. case M88E1000_I_PHY_ID:
  1450. case M88E1000_E_PHY_ID:
  1451. case M88E1111_I_PHY_ID:
  1452. case M88E1011_I_PHY_ID:
  1453. phy_type = e1000_phy_m88;
  1454. break;
  1455. case IGP01E1000_I_PHY_ID: /* IGP 1 & 2 share this */
  1456. phy_type = e1000_phy_igp_2;
  1457. break;
  1458. case GG82563_E_PHY_ID:
  1459. phy_type = e1000_phy_gg82563;
  1460. break;
  1461. case IGP03E1000_E_PHY_ID:
  1462. phy_type = e1000_phy_igp_3;
  1463. break;
  1464. case IFE_E_PHY_ID:
  1465. case IFE_PLUS_E_PHY_ID:
  1466. case IFE_C_E_PHY_ID:
  1467. phy_type = e1000_phy_ife;
  1468. break;
  1469. default:
  1470. phy_type = e1000_phy_unknown;
  1471. break;
  1472. }
  1473. return phy_type;
  1474. }
  1475. /**
  1476. * e1000e_commit_phy - Soft PHY reset
  1477. * @hw: pointer to the HW structure
  1478. *
  1479. * Performs a soft PHY reset on those that apply. This is a function pointer
  1480. * entry point called by drivers.
  1481. **/
  1482. s32 e1000e_commit_phy(struct e1000_hw *hw)
  1483. {
  1484. if (hw->phy.ops.commit_phy)
  1485. return hw->phy.ops.commit_phy(hw);
  1486. return 0;
  1487. }
  1488. /**
  1489. * e1000_set_d0_lplu_state - Sets low power link up state for D0
  1490. * @hw: pointer to the HW structure
  1491. * @active: boolean used to enable/disable lplu
  1492. *
  1493. * Success returns 0, Failure returns 1
  1494. *
  1495. * The low power link up (lplu) state is set to the power management level D0
  1496. * and SmartSpeed is disabled when active is true, else clear lplu for D0
  1497. * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
  1498. * is used during Dx states where the power conservation is most important.
  1499. * During driver activity, SmartSpeed should be enabled so performance is
  1500. * maintained. This is a function pointer entry point called by drivers.
  1501. **/
  1502. static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
  1503. {
  1504. if (hw->phy.ops.set_d0_lplu_state)
  1505. return hw->phy.ops.set_d0_lplu_state(hw, active);
  1506. return 0;
  1507. }