ixgbe_phy.c 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191
  1. /*******************************************************************************
  2. Intel 10 Gigabit PCI Express Linux driver
  3. Copyright(c) 1999 - 2014 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/pci.h>
  22. #include <linux/delay.h>
  23. #include <linux/sched.h>
  24. #include "ixgbe.h"
  25. #include "ixgbe_phy.h"
  26. static void ixgbe_i2c_start(struct ixgbe_hw *hw);
  27. static void ixgbe_i2c_stop(struct ixgbe_hw *hw);
  28. static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data);
  29. static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data);
  30. static s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw);
  31. static s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data);
  32. static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data);
  33. static void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
  34. static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
  35. static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data);
  36. static bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl);
  37. static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw);
  38. static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id);
  39. static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw);
  40. static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw);
  41. /**
  42. * ixgbe_out_i2c_byte_ack - Send I2C byte with ack
  43. * @hw: pointer to the hardware structure
  44. * @byte: byte to send
  45. *
  46. * Returns an error code on error.
  47. **/
  48. static s32 ixgbe_out_i2c_byte_ack(struct ixgbe_hw *hw, u8 byte)
  49. {
  50. s32 status;
  51. status = ixgbe_clock_out_i2c_byte(hw, byte);
  52. if (status)
  53. return status;
  54. return ixgbe_get_i2c_ack(hw);
  55. }
  56. /**
  57. * ixgbe_in_i2c_byte_ack - Receive an I2C byte and send ack
  58. * @hw: pointer to the hardware structure
  59. * @byte: pointer to a u8 to receive the byte
  60. *
  61. * Returns an error code on error.
  62. **/
  63. static s32 ixgbe_in_i2c_byte_ack(struct ixgbe_hw *hw, u8 *byte)
  64. {
  65. s32 status;
  66. status = ixgbe_clock_in_i2c_byte(hw, byte);
  67. if (status)
  68. return status;
  69. /* ACK */
  70. return ixgbe_clock_out_i2c_bit(hw, false);
  71. }
  72. /**
  73. * ixgbe_ones_comp_byte_add - Perform one's complement addition
  74. * @add1: addend 1
  75. * @add2: addend 2
  76. *
  77. * Returns one's complement 8-bit sum.
  78. **/
  79. static u8 ixgbe_ones_comp_byte_add(u8 add1, u8 add2)
  80. {
  81. u16 sum = add1 + add2;
  82. sum = (sum & 0xFF) + (sum >> 8);
  83. return sum & 0xFF;
  84. }
  85. /**
  86. * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
  87. * @hw: pointer to the hardware structure
  88. * @addr: I2C bus address to read from
  89. * @reg: I2C device register to read from
  90. * @val: pointer to location to receive read value
  91. *
  92. * Returns an error code on error.
  93. **/
  94. s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
  95. u16 reg, u16 *val)
  96. {
  97. u32 swfw_mask = hw->phy.phy_semaphore_mask;
  98. int max_retry = 10;
  99. int retry = 0;
  100. u8 csum_byte;
  101. u8 high_bits;
  102. u8 low_bits;
  103. u8 reg_high;
  104. u8 csum;
  105. reg_high = ((reg >> 7) & 0xFE) | 1; /* Indicate read combined */
  106. csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
  107. csum = ~csum;
  108. do {
  109. if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
  110. return IXGBE_ERR_SWFW_SYNC;
  111. ixgbe_i2c_start(hw);
  112. /* Device Address and write indication */
  113. if (ixgbe_out_i2c_byte_ack(hw, addr))
  114. goto fail;
  115. /* Write bits 14:8 */
  116. if (ixgbe_out_i2c_byte_ack(hw, reg_high))
  117. goto fail;
  118. /* Write bits 7:0 */
  119. if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
  120. goto fail;
  121. /* Write csum */
  122. if (ixgbe_out_i2c_byte_ack(hw, csum))
  123. goto fail;
  124. /* Re-start condition */
  125. ixgbe_i2c_start(hw);
  126. /* Device Address and read indication */
  127. if (ixgbe_out_i2c_byte_ack(hw, addr | 1))
  128. goto fail;
  129. /* Get upper bits */
  130. if (ixgbe_in_i2c_byte_ack(hw, &high_bits))
  131. goto fail;
  132. /* Get low bits */
  133. if (ixgbe_in_i2c_byte_ack(hw, &low_bits))
  134. goto fail;
  135. /* Get csum */
  136. if (ixgbe_clock_in_i2c_byte(hw, &csum_byte))
  137. goto fail;
  138. /* NACK */
  139. if (ixgbe_clock_out_i2c_bit(hw, false))
  140. goto fail;
  141. ixgbe_i2c_stop(hw);
  142. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  143. *val = (high_bits << 8) | low_bits;
  144. return 0;
  145. fail:
  146. ixgbe_i2c_bus_clear(hw);
  147. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  148. retry++;
  149. if (retry < max_retry)
  150. hw_dbg(hw, "I2C byte read combined error - Retry.\n");
  151. else
  152. hw_dbg(hw, "I2C byte read combined error.\n");
  153. } while (retry < max_retry);
  154. return IXGBE_ERR_I2C;
  155. }
  156. /**
  157. * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
  158. * @hw: pointer to the hardware structure
  159. * @addr: I2C bus address to write to
  160. * @reg: I2C device register to write to
  161. * @val: value to write
  162. *
  163. * Returns an error code on error.
  164. **/
  165. s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
  166. u8 addr, u16 reg, u16 val)
  167. {
  168. int max_retry = 1;
  169. int retry = 0;
  170. u8 reg_high;
  171. u8 csum;
  172. reg_high = (reg >> 7) & 0xFE; /* Indicate write combined */
  173. csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
  174. csum = ixgbe_ones_comp_byte_add(csum, val >> 8);
  175. csum = ixgbe_ones_comp_byte_add(csum, val & 0xFF);
  176. csum = ~csum;
  177. do {
  178. ixgbe_i2c_start(hw);
  179. /* Device Address and write indication */
  180. if (ixgbe_out_i2c_byte_ack(hw, addr))
  181. goto fail;
  182. /* Write bits 14:8 */
  183. if (ixgbe_out_i2c_byte_ack(hw, reg_high))
  184. goto fail;
  185. /* Write bits 7:0 */
  186. if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
  187. goto fail;
  188. /* Write data 15:8 */
  189. if (ixgbe_out_i2c_byte_ack(hw, val >> 8))
  190. goto fail;
  191. /* Write data 7:0 */
  192. if (ixgbe_out_i2c_byte_ack(hw, val & 0xFF))
  193. goto fail;
  194. /* Write csum */
  195. if (ixgbe_out_i2c_byte_ack(hw, csum))
  196. goto fail;
  197. ixgbe_i2c_stop(hw);
  198. return 0;
  199. fail:
  200. ixgbe_i2c_bus_clear(hw);
  201. retry++;
  202. if (retry < max_retry)
  203. hw_dbg(hw, "I2C byte write combined error - Retry.\n");
  204. else
  205. hw_dbg(hw, "I2C byte write combined error.\n");
  206. } while (retry < max_retry);
  207. return IXGBE_ERR_I2C;
  208. }
  209. /**
  210. * ixgbe_identify_phy_generic - Get physical layer module
  211. * @hw: pointer to hardware structure
  212. *
  213. * Determines the physical layer module found on the current adapter.
  214. **/
  215. s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
  216. {
  217. u32 phy_addr;
  218. u16 ext_ability = 0;
  219. if (!hw->phy.phy_semaphore_mask) {
  220. if (hw->bus.lan_id)
  221. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
  222. else
  223. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
  224. }
  225. if (hw->phy.type == ixgbe_phy_unknown) {
  226. for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
  227. hw->phy.mdio.prtad = phy_addr;
  228. if (mdio45_probe(&hw->phy.mdio, phy_addr) == 0) {
  229. ixgbe_get_phy_id(hw);
  230. hw->phy.type =
  231. ixgbe_get_phy_type_from_id(hw->phy.id);
  232. if (hw->phy.type == ixgbe_phy_unknown) {
  233. hw->phy.ops.read_reg(hw,
  234. MDIO_PMA_EXTABLE,
  235. MDIO_MMD_PMAPMD,
  236. &ext_ability);
  237. if (ext_ability &
  238. (MDIO_PMA_EXTABLE_10GBT |
  239. MDIO_PMA_EXTABLE_1000BT))
  240. hw->phy.type =
  241. ixgbe_phy_cu_unknown;
  242. else
  243. hw->phy.type =
  244. ixgbe_phy_generic;
  245. }
  246. return 0;
  247. }
  248. }
  249. /* clear value if nothing found */
  250. hw->phy.mdio.prtad = 0;
  251. return IXGBE_ERR_PHY_ADDR_INVALID;
  252. }
  253. return 0;
  254. }
  255. /**
  256. * ixgbe_check_reset_blocked - check status of MNG FW veto bit
  257. * @hw: pointer to the hardware structure
  258. *
  259. * This function checks the MMNGC.MNG_VETO bit to see if there are
  260. * any constraints on link from manageability. For MAC's that don't
  261. * have this bit just return false since the link can not be blocked
  262. * via this method.
  263. **/
  264. bool ixgbe_check_reset_blocked(struct ixgbe_hw *hw)
  265. {
  266. u32 mmngc;
  267. /* If we don't have this bit, it can't be blocking */
  268. if (hw->mac.type == ixgbe_mac_82598EB)
  269. return false;
  270. mmngc = IXGBE_READ_REG(hw, IXGBE_MMNGC);
  271. if (mmngc & IXGBE_MMNGC_MNG_VETO) {
  272. hw_dbg(hw, "MNG_VETO bit detected.\n");
  273. return true;
  274. }
  275. return false;
  276. }
  277. /**
  278. * ixgbe_get_phy_id - Get the phy type
  279. * @hw: pointer to hardware structure
  280. *
  281. **/
  282. static s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)
  283. {
  284. s32 status;
  285. u16 phy_id_high = 0;
  286. u16 phy_id_low = 0;
  287. status = hw->phy.ops.read_reg(hw, MDIO_DEVID1, MDIO_MMD_PMAPMD,
  288. &phy_id_high);
  289. if (!status) {
  290. hw->phy.id = (u32)(phy_id_high << 16);
  291. status = hw->phy.ops.read_reg(hw, MDIO_DEVID2, MDIO_MMD_PMAPMD,
  292. &phy_id_low);
  293. hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);
  294. hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);
  295. }
  296. return status;
  297. }
  298. /**
  299. * ixgbe_get_phy_type_from_id - Get the phy type
  300. * @hw: pointer to hardware structure
  301. *
  302. **/
  303. static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
  304. {
  305. enum ixgbe_phy_type phy_type;
  306. switch (phy_id) {
  307. case TN1010_PHY_ID:
  308. phy_type = ixgbe_phy_tn;
  309. break;
  310. case X550_PHY_ID:
  311. case X540_PHY_ID:
  312. phy_type = ixgbe_phy_aq;
  313. break;
  314. case QT2022_PHY_ID:
  315. phy_type = ixgbe_phy_qt;
  316. break;
  317. case ATH_PHY_ID:
  318. phy_type = ixgbe_phy_nl;
  319. break;
  320. case X557_PHY_ID:
  321. phy_type = ixgbe_phy_x550em_ext_t;
  322. break;
  323. default:
  324. phy_type = ixgbe_phy_unknown;
  325. break;
  326. }
  327. return phy_type;
  328. }
  329. /**
  330. * ixgbe_reset_phy_generic - Performs a PHY reset
  331. * @hw: pointer to hardware structure
  332. **/
  333. s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
  334. {
  335. u32 i;
  336. u16 ctrl = 0;
  337. s32 status = 0;
  338. if (hw->phy.type == ixgbe_phy_unknown)
  339. status = ixgbe_identify_phy_generic(hw);
  340. if (status != 0 || hw->phy.type == ixgbe_phy_none)
  341. return status;
  342. /* Don't reset PHY if it's shut down due to overtemp. */
  343. if (!hw->phy.reset_if_overtemp &&
  344. (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
  345. return 0;
  346. /* Blocked by MNG FW so bail */
  347. if (ixgbe_check_reset_blocked(hw))
  348. return 0;
  349. /*
  350. * Perform soft PHY reset to the PHY_XS.
  351. * This will cause a soft reset to the PHY
  352. */
  353. hw->phy.ops.write_reg(hw, MDIO_CTRL1,
  354. MDIO_MMD_PHYXS,
  355. MDIO_CTRL1_RESET);
  356. /*
  357. * Poll for reset bit to self-clear indicating reset is complete.
  358. * Some PHYs could take up to 3 seconds to complete and need about
  359. * 1.7 usec delay after the reset is complete.
  360. */
  361. for (i = 0; i < 30; i++) {
  362. msleep(100);
  363. hw->phy.ops.read_reg(hw, MDIO_CTRL1,
  364. MDIO_MMD_PHYXS, &ctrl);
  365. if (!(ctrl & MDIO_CTRL1_RESET)) {
  366. udelay(2);
  367. break;
  368. }
  369. }
  370. if (ctrl & MDIO_CTRL1_RESET) {
  371. hw_dbg(hw, "PHY reset polling failed to complete.\n");
  372. return IXGBE_ERR_RESET_FAILED;
  373. }
  374. return 0;
  375. }
  376. /**
  377. * ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
  378. * the SWFW lock
  379. * @hw: pointer to hardware structure
  380. * @reg_addr: 32 bit address of PHY register to read
  381. * @phy_data: Pointer to read data from PHY register
  382. **/
  383. s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
  384. u16 *phy_data)
  385. {
  386. u32 i, data, command;
  387. /* Setup and write the address cycle command */
  388. command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
  389. (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
  390. (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
  391. (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
  392. IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
  393. /* Check every 10 usec to see if the address cycle completed.
  394. * The MDI Command bit will clear when the operation is
  395. * complete
  396. */
  397. for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
  398. udelay(10);
  399. command = IXGBE_READ_REG(hw, IXGBE_MSCA);
  400. if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
  401. break;
  402. }
  403. if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
  404. hw_dbg(hw, "PHY address command did not complete.\n");
  405. return IXGBE_ERR_PHY;
  406. }
  407. /* Address cycle complete, setup and write the read
  408. * command
  409. */
  410. command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
  411. (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
  412. (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
  413. (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
  414. IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
  415. /* Check every 10 usec to see if the address cycle
  416. * completed. The MDI Command bit will clear when the
  417. * operation is complete
  418. */
  419. for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
  420. udelay(10);
  421. command = IXGBE_READ_REG(hw, IXGBE_MSCA);
  422. if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
  423. break;
  424. }
  425. if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
  426. hw_dbg(hw, "PHY read command didn't complete\n");
  427. return IXGBE_ERR_PHY;
  428. }
  429. /* Read operation is complete. Get the data
  430. * from MSRWD
  431. */
  432. data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
  433. data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
  434. *phy_data = (u16)(data);
  435. return 0;
  436. }
  437. /**
  438. * ixgbe_read_phy_reg_generic - Reads a value from a specified PHY register
  439. * using the SWFW lock - this function is needed in most cases
  440. * @hw: pointer to hardware structure
  441. * @reg_addr: 32 bit address of PHY register to read
  442. * @phy_data: Pointer to read data from PHY register
  443. **/
  444. s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
  445. u32 device_type, u16 *phy_data)
  446. {
  447. s32 status;
  448. u32 gssr = hw->phy.phy_semaphore_mask;
  449. if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == 0) {
  450. status = ixgbe_read_phy_reg_mdi(hw, reg_addr, device_type,
  451. phy_data);
  452. hw->mac.ops.release_swfw_sync(hw, gssr);
  453. } else {
  454. return IXGBE_ERR_SWFW_SYNC;
  455. }
  456. return status;
  457. }
  458. /**
  459. * ixgbe_write_phy_reg_mdi - Writes a value to specified PHY register
  460. * without SWFW lock
  461. * @hw: pointer to hardware structure
  462. * @reg_addr: 32 bit PHY register to write
  463. * @device_type: 5 bit device type
  464. * @phy_data: Data to write to the PHY register
  465. **/
  466. s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
  467. u32 device_type, u16 phy_data)
  468. {
  469. u32 i, command;
  470. /* Put the data in the MDI single read and write data register*/
  471. IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
  472. /* Setup and write the address cycle command */
  473. command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
  474. (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
  475. (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
  476. (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
  477. IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
  478. /*
  479. * Check every 10 usec to see if the address cycle completed.
  480. * The MDI Command bit will clear when the operation is
  481. * complete
  482. */
  483. for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
  484. udelay(10);
  485. command = IXGBE_READ_REG(hw, IXGBE_MSCA);
  486. if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
  487. break;
  488. }
  489. if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
  490. hw_dbg(hw, "PHY address cmd didn't complete\n");
  491. return IXGBE_ERR_PHY;
  492. }
  493. /*
  494. * Address cycle complete, setup and write the write
  495. * command
  496. */
  497. command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
  498. (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
  499. (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
  500. (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
  501. IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
  502. /* Check every 10 usec to see if the address cycle
  503. * completed. The MDI Command bit will clear when the
  504. * operation is complete
  505. */
  506. for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
  507. udelay(10);
  508. command = IXGBE_READ_REG(hw, IXGBE_MSCA);
  509. if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
  510. break;
  511. }
  512. if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
  513. hw_dbg(hw, "PHY write cmd didn't complete\n");
  514. return IXGBE_ERR_PHY;
  515. }
  516. return 0;
  517. }
  518. /**
  519. * ixgbe_write_phy_reg_generic - Writes a value to specified PHY register
  520. * using SWFW lock- this function is needed in most cases
  521. * @hw: pointer to hardware structure
  522. * @reg_addr: 32 bit PHY register to write
  523. * @device_type: 5 bit device type
  524. * @phy_data: Data to write to the PHY register
  525. **/
  526. s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
  527. u32 device_type, u16 phy_data)
  528. {
  529. s32 status;
  530. u32 gssr = hw->phy.phy_semaphore_mask;
  531. if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == 0) {
  532. status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type,
  533. phy_data);
  534. hw->mac.ops.release_swfw_sync(hw, gssr);
  535. } else {
  536. return IXGBE_ERR_SWFW_SYNC;
  537. }
  538. return status;
  539. }
  540. /**
  541. * ixgbe_setup_phy_link_generic - Set and restart autoneg
  542. * @hw: pointer to hardware structure
  543. *
  544. * Restart autonegotiation and PHY and waits for completion.
  545. **/
  546. s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
  547. {
  548. s32 status = 0;
  549. u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
  550. bool autoneg = false;
  551. ixgbe_link_speed speed;
  552. ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
  553. if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
  554. /* Set or unset auto-negotiation 10G advertisement */
  555. hw->phy.ops.read_reg(hw, MDIO_AN_10GBT_CTRL,
  556. MDIO_MMD_AN,
  557. &autoneg_reg);
  558. autoneg_reg &= ~MDIO_AN_10GBT_CTRL_ADV10G;
  559. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
  560. autoneg_reg |= MDIO_AN_10GBT_CTRL_ADV10G;
  561. hw->phy.ops.write_reg(hw, MDIO_AN_10GBT_CTRL,
  562. MDIO_MMD_AN,
  563. autoneg_reg);
  564. }
  565. if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
  566. /* Set or unset auto-negotiation 1G advertisement */
  567. hw->phy.ops.read_reg(hw,
  568. IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
  569. MDIO_MMD_AN,
  570. &autoneg_reg);
  571. autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE;
  572. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
  573. autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE;
  574. hw->phy.ops.write_reg(hw,
  575. IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
  576. MDIO_MMD_AN,
  577. autoneg_reg);
  578. }
  579. if (speed & IXGBE_LINK_SPEED_100_FULL) {
  580. /* Set or unset auto-negotiation 100M advertisement */
  581. hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE,
  582. MDIO_MMD_AN,
  583. &autoneg_reg);
  584. autoneg_reg &= ~(ADVERTISE_100FULL |
  585. ADVERTISE_100HALF);
  586. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
  587. autoneg_reg |= ADVERTISE_100FULL;
  588. hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE,
  589. MDIO_MMD_AN,
  590. autoneg_reg);
  591. }
  592. /* Blocked by MNG FW so don't reset PHY */
  593. if (ixgbe_check_reset_blocked(hw))
  594. return 0;
  595. /* Restart PHY autonegotiation and wait for completion */
  596. hw->phy.ops.read_reg(hw, MDIO_CTRL1,
  597. MDIO_MMD_AN, &autoneg_reg);
  598. autoneg_reg |= MDIO_AN_CTRL1_RESTART;
  599. hw->phy.ops.write_reg(hw, MDIO_CTRL1,
  600. MDIO_MMD_AN, autoneg_reg);
  601. return status;
  602. }
  603. /**
  604. * ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities
  605. * @hw: pointer to hardware structure
  606. * @speed: new link speed
  607. **/
  608. s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
  609. ixgbe_link_speed speed,
  610. bool autoneg_wait_to_complete)
  611. {
  612. /*
  613. * Clear autoneg_advertised and set new values based on input link
  614. * speed.
  615. */
  616. hw->phy.autoneg_advertised = 0;
  617. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  618. hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
  619. if (speed & IXGBE_LINK_SPEED_1GB_FULL)
  620. hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
  621. if (speed & IXGBE_LINK_SPEED_100_FULL)
  622. hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
  623. /* Setup link based on the new speed settings */
  624. hw->phy.ops.setup_link(hw);
  625. return 0;
  626. }
  627. /**
  628. * ixgbe_get_copper_speeds_supported - Get copper link speed from phy
  629. * @hw: pointer to hardware structure
  630. *
  631. * Determines the supported link capabilities by reading the PHY auto
  632. * negotiation register.
  633. */
  634. static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
  635. {
  636. u16 speed_ability;
  637. s32 status;
  638. status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
  639. &speed_ability);
  640. if (status)
  641. return status;
  642. if (speed_ability & MDIO_SPEED_10G)
  643. hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
  644. if (speed_ability & MDIO_PMA_SPEED_1000)
  645. hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
  646. if (speed_ability & MDIO_PMA_SPEED_100)
  647. hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
  648. switch (hw->mac.type) {
  649. case ixgbe_mac_X550:
  650. hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
  651. hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
  652. break;
  653. case ixgbe_mac_X550EM_x:
  654. hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
  655. break;
  656. default:
  657. break;
  658. }
  659. return 0;
  660. }
  661. /**
  662. * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
  663. * @hw: pointer to hardware structure
  664. * @speed: pointer to link speed
  665. * @autoneg: boolean auto-negotiation value
  666. */
  667. s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
  668. ixgbe_link_speed *speed,
  669. bool *autoneg)
  670. {
  671. s32 status = 0;
  672. *autoneg = true;
  673. if (!hw->phy.speeds_supported)
  674. status = ixgbe_get_copper_speeds_supported(hw);
  675. *speed = hw->phy.speeds_supported;
  676. return status;
  677. }
  678. /**
  679. * ixgbe_check_phy_link_tnx - Determine link and speed status
  680. * @hw: pointer to hardware structure
  681. *
  682. * Reads the VS1 register to determine if link is up and the current speed for
  683. * the PHY.
  684. **/
  685. s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
  686. bool *link_up)
  687. {
  688. s32 status;
  689. u32 time_out;
  690. u32 max_time_out = 10;
  691. u16 phy_link = 0;
  692. u16 phy_speed = 0;
  693. u16 phy_data = 0;
  694. /* Initialize speed and link to default case */
  695. *link_up = false;
  696. *speed = IXGBE_LINK_SPEED_10GB_FULL;
  697. /*
  698. * Check current speed and link status of the PHY register.
  699. * This is a vendor specific register and may have to
  700. * be changed for other copper PHYs.
  701. */
  702. for (time_out = 0; time_out < max_time_out; time_out++) {
  703. udelay(10);
  704. status = hw->phy.ops.read_reg(hw,
  705. MDIO_STAT1,
  706. MDIO_MMD_VEND1,
  707. &phy_data);
  708. phy_link = phy_data &
  709. IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
  710. phy_speed = phy_data &
  711. IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS;
  712. if (phy_link == IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS) {
  713. *link_up = true;
  714. if (phy_speed ==
  715. IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS)
  716. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  717. break;
  718. }
  719. }
  720. return status;
  721. }
  722. /**
  723. * ixgbe_setup_phy_link_tnx - Set and restart autoneg
  724. * @hw: pointer to hardware structure
  725. *
  726. * Restart autonegotiation and PHY and waits for completion.
  727. * This function always returns success, this is nessary since
  728. * it is called via a function pointer that could call other
  729. * functions that could return an error.
  730. **/
  731. s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
  732. {
  733. u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
  734. bool autoneg = false;
  735. ixgbe_link_speed speed;
  736. ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
  737. if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
  738. /* Set or unset auto-negotiation 10G advertisement */
  739. hw->phy.ops.read_reg(hw, MDIO_AN_10GBT_CTRL,
  740. MDIO_MMD_AN,
  741. &autoneg_reg);
  742. autoneg_reg &= ~MDIO_AN_10GBT_CTRL_ADV10G;
  743. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
  744. autoneg_reg |= MDIO_AN_10GBT_CTRL_ADV10G;
  745. hw->phy.ops.write_reg(hw, MDIO_AN_10GBT_CTRL,
  746. MDIO_MMD_AN,
  747. autoneg_reg);
  748. }
  749. if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
  750. /* Set or unset auto-negotiation 1G advertisement */
  751. hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
  752. MDIO_MMD_AN,
  753. &autoneg_reg);
  754. autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
  755. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
  756. autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
  757. hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
  758. MDIO_MMD_AN,
  759. autoneg_reg);
  760. }
  761. if (speed & IXGBE_LINK_SPEED_100_FULL) {
  762. /* Set or unset auto-negotiation 100M advertisement */
  763. hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE,
  764. MDIO_MMD_AN,
  765. &autoneg_reg);
  766. autoneg_reg &= ~(ADVERTISE_100FULL |
  767. ADVERTISE_100HALF);
  768. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
  769. autoneg_reg |= ADVERTISE_100FULL;
  770. hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE,
  771. MDIO_MMD_AN,
  772. autoneg_reg);
  773. }
  774. /* Blocked by MNG FW so don't reset PHY */
  775. if (ixgbe_check_reset_blocked(hw))
  776. return 0;
  777. /* Restart PHY autonegotiation and wait for completion */
  778. hw->phy.ops.read_reg(hw, MDIO_CTRL1,
  779. MDIO_MMD_AN, &autoneg_reg);
  780. autoneg_reg |= MDIO_AN_CTRL1_RESTART;
  781. hw->phy.ops.write_reg(hw, MDIO_CTRL1,
  782. MDIO_MMD_AN, autoneg_reg);
  783. return 0;
  784. }
  785. /**
  786. * ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version
  787. * @hw: pointer to hardware structure
  788. * @firmware_version: pointer to the PHY Firmware Version
  789. **/
  790. s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
  791. u16 *firmware_version)
  792. {
  793. s32 status;
  794. status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
  795. MDIO_MMD_VEND1,
  796. firmware_version);
  797. return status;
  798. }
  799. /**
  800. * ixgbe_get_phy_firmware_version_generic - Gets the PHY Firmware Version
  801. * @hw: pointer to hardware structure
  802. * @firmware_version: pointer to the PHY Firmware Version
  803. **/
  804. s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
  805. u16 *firmware_version)
  806. {
  807. s32 status;
  808. status = hw->phy.ops.read_reg(hw, AQ_FW_REV,
  809. MDIO_MMD_VEND1,
  810. firmware_version);
  811. return status;
  812. }
  813. /**
  814. * ixgbe_reset_phy_nl - Performs a PHY reset
  815. * @hw: pointer to hardware structure
  816. **/
  817. s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
  818. {
  819. u16 phy_offset, control, eword, edata, block_crc;
  820. bool end_data = false;
  821. u16 list_offset, data_offset;
  822. u16 phy_data = 0;
  823. s32 ret_val;
  824. u32 i;
  825. /* Blocked by MNG FW so bail */
  826. if (ixgbe_check_reset_blocked(hw))
  827. return 0;
  828. hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, &phy_data);
  829. /* reset the PHY and poll for completion */
  830. hw->phy.ops.write_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS,
  831. (phy_data | MDIO_CTRL1_RESET));
  832. for (i = 0; i < 100; i++) {
  833. hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS,
  834. &phy_data);
  835. if ((phy_data & MDIO_CTRL1_RESET) == 0)
  836. break;
  837. usleep_range(10000, 20000);
  838. }
  839. if ((phy_data & MDIO_CTRL1_RESET) != 0) {
  840. hw_dbg(hw, "PHY reset did not complete.\n");
  841. return IXGBE_ERR_PHY;
  842. }
  843. /* Get init offsets */
  844. ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
  845. &data_offset);
  846. if (ret_val)
  847. return ret_val;
  848. ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc);
  849. data_offset++;
  850. while (!end_data) {
  851. /*
  852. * Read control word from PHY init contents offset
  853. */
  854. ret_val = hw->eeprom.ops.read(hw, data_offset, &eword);
  855. if (ret_val)
  856. goto err_eeprom;
  857. control = (eword & IXGBE_CONTROL_MASK_NL) >>
  858. IXGBE_CONTROL_SHIFT_NL;
  859. edata = eword & IXGBE_DATA_MASK_NL;
  860. switch (control) {
  861. case IXGBE_DELAY_NL:
  862. data_offset++;
  863. hw_dbg(hw, "DELAY: %d MS\n", edata);
  864. usleep_range(edata * 1000, edata * 2000);
  865. break;
  866. case IXGBE_DATA_NL:
  867. hw_dbg(hw, "DATA:\n");
  868. data_offset++;
  869. ret_val = hw->eeprom.ops.read(hw, data_offset++,
  870. &phy_offset);
  871. if (ret_val)
  872. goto err_eeprom;
  873. for (i = 0; i < edata; i++) {
  874. ret_val = hw->eeprom.ops.read(hw, data_offset,
  875. &eword);
  876. if (ret_val)
  877. goto err_eeprom;
  878. hw->phy.ops.write_reg(hw, phy_offset,
  879. MDIO_MMD_PMAPMD, eword);
  880. hw_dbg(hw, "Wrote %4.4x to %4.4x\n", eword,
  881. phy_offset);
  882. data_offset++;
  883. phy_offset++;
  884. }
  885. break;
  886. case IXGBE_CONTROL_NL:
  887. data_offset++;
  888. hw_dbg(hw, "CONTROL:\n");
  889. if (edata == IXGBE_CONTROL_EOL_NL) {
  890. hw_dbg(hw, "EOL\n");
  891. end_data = true;
  892. } else if (edata == IXGBE_CONTROL_SOL_NL) {
  893. hw_dbg(hw, "SOL\n");
  894. } else {
  895. hw_dbg(hw, "Bad control value\n");
  896. return IXGBE_ERR_PHY;
  897. }
  898. break;
  899. default:
  900. hw_dbg(hw, "Bad control type\n");
  901. return IXGBE_ERR_PHY;
  902. }
  903. }
  904. return ret_val;
  905. err_eeprom:
  906. hw_err(hw, "eeprom read at offset %d failed\n", data_offset);
  907. return IXGBE_ERR_PHY;
  908. }
  909. /**
  910. * ixgbe_identify_module_generic - Identifies module type
  911. * @hw: pointer to hardware structure
  912. *
  913. * Determines HW type and calls appropriate function.
  914. **/
  915. s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
  916. {
  917. switch (hw->mac.ops.get_media_type(hw)) {
  918. case ixgbe_media_type_fiber:
  919. return ixgbe_identify_sfp_module_generic(hw);
  920. case ixgbe_media_type_fiber_qsfp:
  921. return ixgbe_identify_qsfp_module_generic(hw);
  922. default:
  923. hw->phy.sfp_type = ixgbe_sfp_type_not_present;
  924. return IXGBE_ERR_SFP_NOT_PRESENT;
  925. }
  926. return IXGBE_ERR_SFP_NOT_PRESENT;
  927. }
  928. /**
  929. * ixgbe_identify_sfp_module_generic - Identifies SFP modules
  930. * @hw: pointer to hardware structure
  931. *
  932. * Searches for and identifies the SFP module and assigns appropriate PHY type.
  933. **/
  934. s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
  935. {
  936. struct ixgbe_adapter *adapter = hw->back;
  937. s32 status;
  938. u32 vendor_oui = 0;
  939. enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
  940. u8 identifier = 0;
  941. u8 comp_codes_1g = 0;
  942. u8 comp_codes_10g = 0;
  943. u8 oui_bytes[3] = {0, 0, 0};
  944. u8 cable_tech = 0;
  945. u8 cable_spec = 0;
  946. u16 enforce_sfp = 0;
  947. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
  948. hw->phy.sfp_type = ixgbe_sfp_type_not_present;
  949. return IXGBE_ERR_SFP_NOT_PRESENT;
  950. }
  951. status = hw->phy.ops.read_i2c_eeprom(hw,
  952. IXGBE_SFF_IDENTIFIER,
  953. &identifier);
  954. if (status)
  955. goto err_read_i2c_eeprom;
  956. /* LAN ID is needed for sfp_type determination */
  957. hw->mac.ops.set_lan_id(hw);
  958. if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
  959. hw->phy.type = ixgbe_phy_sfp_unsupported;
  960. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  961. }
  962. status = hw->phy.ops.read_i2c_eeprom(hw,
  963. IXGBE_SFF_1GBE_COMP_CODES,
  964. &comp_codes_1g);
  965. if (status)
  966. goto err_read_i2c_eeprom;
  967. status = hw->phy.ops.read_i2c_eeprom(hw,
  968. IXGBE_SFF_10GBE_COMP_CODES,
  969. &comp_codes_10g);
  970. if (status)
  971. goto err_read_i2c_eeprom;
  972. status = hw->phy.ops.read_i2c_eeprom(hw,
  973. IXGBE_SFF_CABLE_TECHNOLOGY,
  974. &cable_tech);
  975. if (status)
  976. goto err_read_i2c_eeprom;
  977. /* ID Module
  978. * =========
  979. * 0 SFP_DA_CU
  980. * 1 SFP_SR
  981. * 2 SFP_LR
  982. * 3 SFP_DA_CORE0 - 82599-specific
  983. * 4 SFP_DA_CORE1 - 82599-specific
  984. * 5 SFP_SR/LR_CORE0 - 82599-specific
  985. * 6 SFP_SR/LR_CORE1 - 82599-specific
  986. * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
  987. * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
  988. * 9 SFP_1g_cu_CORE0 - 82599-specific
  989. * 10 SFP_1g_cu_CORE1 - 82599-specific
  990. * 11 SFP_1g_sx_CORE0 - 82599-specific
  991. * 12 SFP_1g_sx_CORE1 - 82599-specific
  992. */
  993. if (hw->mac.type == ixgbe_mac_82598EB) {
  994. if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
  995. hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
  996. else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
  997. hw->phy.sfp_type = ixgbe_sfp_type_sr;
  998. else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
  999. hw->phy.sfp_type = ixgbe_sfp_type_lr;
  1000. else
  1001. hw->phy.sfp_type = ixgbe_sfp_type_unknown;
  1002. } else if (hw->mac.type == ixgbe_mac_82599EB) {
  1003. if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
  1004. if (hw->bus.lan_id == 0)
  1005. hw->phy.sfp_type =
  1006. ixgbe_sfp_type_da_cu_core0;
  1007. else
  1008. hw->phy.sfp_type =
  1009. ixgbe_sfp_type_da_cu_core1;
  1010. } else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
  1011. hw->phy.ops.read_i2c_eeprom(
  1012. hw, IXGBE_SFF_CABLE_SPEC_COMP,
  1013. &cable_spec);
  1014. if (cable_spec &
  1015. IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
  1016. if (hw->bus.lan_id == 0)
  1017. hw->phy.sfp_type =
  1018. ixgbe_sfp_type_da_act_lmt_core0;
  1019. else
  1020. hw->phy.sfp_type =
  1021. ixgbe_sfp_type_da_act_lmt_core1;
  1022. } else {
  1023. hw->phy.sfp_type =
  1024. ixgbe_sfp_type_unknown;
  1025. }
  1026. } else if (comp_codes_10g &
  1027. (IXGBE_SFF_10GBASESR_CAPABLE |
  1028. IXGBE_SFF_10GBASELR_CAPABLE)) {
  1029. if (hw->bus.lan_id == 0)
  1030. hw->phy.sfp_type =
  1031. ixgbe_sfp_type_srlr_core0;
  1032. else
  1033. hw->phy.sfp_type =
  1034. ixgbe_sfp_type_srlr_core1;
  1035. } else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
  1036. if (hw->bus.lan_id == 0)
  1037. hw->phy.sfp_type =
  1038. ixgbe_sfp_type_1g_cu_core0;
  1039. else
  1040. hw->phy.sfp_type =
  1041. ixgbe_sfp_type_1g_cu_core1;
  1042. } else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
  1043. if (hw->bus.lan_id == 0)
  1044. hw->phy.sfp_type =
  1045. ixgbe_sfp_type_1g_sx_core0;
  1046. else
  1047. hw->phy.sfp_type =
  1048. ixgbe_sfp_type_1g_sx_core1;
  1049. } else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
  1050. if (hw->bus.lan_id == 0)
  1051. hw->phy.sfp_type =
  1052. ixgbe_sfp_type_1g_lx_core0;
  1053. else
  1054. hw->phy.sfp_type =
  1055. ixgbe_sfp_type_1g_lx_core1;
  1056. } else {
  1057. hw->phy.sfp_type = ixgbe_sfp_type_unknown;
  1058. }
  1059. }
  1060. if (hw->phy.sfp_type != stored_sfp_type)
  1061. hw->phy.sfp_setup_needed = true;
  1062. /* Determine if the SFP+ PHY is dual speed or not. */
  1063. hw->phy.multispeed_fiber = false;
  1064. if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
  1065. (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
  1066. ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
  1067. (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
  1068. hw->phy.multispeed_fiber = true;
  1069. /* Determine PHY vendor */
  1070. if (hw->phy.type != ixgbe_phy_nl) {
  1071. hw->phy.id = identifier;
  1072. status = hw->phy.ops.read_i2c_eeprom(hw,
  1073. IXGBE_SFF_VENDOR_OUI_BYTE0,
  1074. &oui_bytes[0]);
  1075. if (status != 0)
  1076. goto err_read_i2c_eeprom;
  1077. status = hw->phy.ops.read_i2c_eeprom(hw,
  1078. IXGBE_SFF_VENDOR_OUI_BYTE1,
  1079. &oui_bytes[1]);
  1080. if (status != 0)
  1081. goto err_read_i2c_eeprom;
  1082. status = hw->phy.ops.read_i2c_eeprom(hw,
  1083. IXGBE_SFF_VENDOR_OUI_BYTE2,
  1084. &oui_bytes[2]);
  1085. if (status != 0)
  1086. goto err_read_i2c_eeprom;
  1087. vendor_oui =
  1088. ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
  1089. (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
  1090. (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
  1091. switch (vendor_oui) {
  1092. case IXGBE_SFF_VENDOR_OUI_TYCO:
  1093. if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
  1094. hw->phy.type =
  1095. ixgbe_phy_sfp_passive_tyco;
  1096. break;
  1097. case IXGBE_SFF_VENDOR_OUI_FTL:
  1098. if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
  1099. hw->phy.type = ixgbe_phy_sfp_ftl_active;
  1100. else
  1101. hw->phy.type = ixgbe_phy_sfp_ftl;
  1102. break;
  1103. case IXGBE_SFF_VENDOR_OUI_AVAGO:
  1104. hw->phy.type = ixgbe_phy_sfp_avago;
  1105. break;
  1106. case IXGBE_SFF_VENDOR_OUI_INTEL:
  1107. hw->phy.type = ixgbe_phy_sfp_intel;
  1108. break;
  1109. default:
  1110. if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
  1111. hw->phy.type =
  1112. ixgbe_phy_sfp_passive_unknown;
  1113. else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
  1114. hw->phy.type =
  1115. ixgbe_phy_sfp_active_unknown;
  1116. else
  1117. hw->phy.type = ixgbe_phy_sfp_unknown;
  1118. break;
  1119. }
  1120. }
  1121. /* Allow any DA cable vendor */
  1122. if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
  1123. IXGBE_SFF_DA_ACTIVE_CABLE))
  1124. return 0;
  1125. /* Verify supported 1G SFP modules */
  1126. if (comp_codes_10g == 0 &&
  1127. !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
  1128. hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
  1129. hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
  1130. hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
  1131. hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
  1132. hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
  1133. hw->phy.type = ixgbe_phy_sfp_unsupported;
  1134. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1135. }
  1136. /* Anything else 82598-based is supported */
  1137. if (hw->mac.type == ixgbe_mac_82598EB)
  1138. return 0;
  1139. hw->mac.ops.get_device_caps(hw, &enforce_sfp);
  1140. if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
  1141. !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
  1142. hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
  1143. hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
  1144. hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
  1145. hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
  1146. hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
  1147. /* Make sure we're a supported PHY type */
  1148. if (hw->phy.type == ixgbe_phy_sfp_intel)
  1149. return 0;
  1150. if (hw->allow_unsupported_sfp) {
  1151. e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n");
  1152. return 0;
  1153. }
  1154. hw_dbg(hw, "SFP+ module not supported\n");
  1155. hw->phy.type = ixgbe_phy_sfp_unsupported;
  1156. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1157. }
  1158. return 0;
  1159. err_read_i2c_eeprom:
  1160. hw->phy.sfp_type = ixgbe_sfp_type_not_present;
  1161. if (hw->phy.type != ixgbe_phy_nl) {
  1162. hw->phy.id = 0;
  1163. hw->phy.type = ixgbe_phy_unknown;
  1164. }
  1165. return IXGBE_ERR_SFP_NOT_PRESENT;
  1166. }
  1167. /**
  1168. * ixgbe_identify_qsfp_module_generic - Identifies QSFP modules
  1169. * @hw: pointer to hardware structure
  1170. *
  1171. * Searches for and identifies the QSFP module and assigns appropriate PHY type
  1172. **/
  1173. static s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
  1174. {
  1175. struct ixgbe_adapter *adapter = hw->back;
  1176. s32 status;
  1177. u32 vendor_oui = 0;
  1178. enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
  1179. u8 identifier = 0;
  1180. u8 comp_codes_1g = 0;
  1181. u8 comp_codes_10g = 0;
  1182. u8 oui_bytes[3] = {0, 0, 0};
  1183. u16 enforce_sfp = 0;
  1184. u8 connector = 0;
  1185. u8 cable_length = 0;
  1186. u8 device_tech = 0;
  1187. bool active_cable = false;
  1188. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) {
  1189. hw->phy.sfp_type = ixgbe_sfp_type_not_present;
  1190. return IXGBE_ERR_SFP_NOT_PRESENT;
  1191. }
  1192. /* LAN ID is needed for sfp_type determination */
  1193. hw->mac.ops.set_lan_id(hw);
  1194. status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
  1195. &identifier);
  1196. if (status != 0)
  1197. goto err_read_i2c_eeprom;
  1198. if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) {
  1199. hw->phy.type = ixgbe_phy_sfp_unsupported;
  1200. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1201. }
  1202. hw->phy.id = identifier;
  1203. status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_10GBE_COMP,
  1204. &comp_codes_10g);
  1205. if (status != 0)
  1206. goto err_read_i2c_eeprom;
  1207. status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_1GBE_COMP,
  1208. &comp_codes_1g);
  1209. if (status != 0)
  1210. goto err_read_i2c_eeprom;
  1211. if (comp_codes_10g & IXGBE_SFF_QSFP_DA_PASSIVE_CABLE) {
  1212. hw->phy.type = ixgbe_phy_qsfp_passive_unknown;
  1213. if (hw->bus.lan_id == 0)
  1214. hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core0;
  1215. else
  1216. hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core1;
  1217. } else if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
  1218. IXGBE_SFF_10GBASELR_CAPABLE)) {
  1219. if (hw->bus.lan_id == 0)
  1220. hw->phy.sfp_type = ixgbe_sfp_type_srlr_core0;
  1221. else
  1222. hw->phy.sfp_type = ixgbe_sfp_type_srlr_core1;
  1223. } else {
  1224. if (comp_codes_10g & IXGBE_SFF_QSFP_DA_ACTIVE_CABLE)
  1225. active_cable = true;
  1226. if (!active_cable) {
  1227. /* check for active DA cables that pre-date
  1228. * SFF-8436 v3.6
  1229. */
  1230. hw->phy.ops.read_i2c_eeprom(hw,
  1231. IXGBE_SFF_QSFP_CONNECTOR,
  1232. &connector);
  1233. hw->phy.ops.read_i2c_eeprom(hw,
  1234. IXGBE_SFF_QSFP_CABLE_LENGTH,
  1235. &cable_length);
  1236. hw->phy.ops.read_i2c_eeprom(hw,
  1237. IXGBE_SFF_QSFP_DEVICE_TECH,
  1238. &device_tech);
  1239. if ((connector ==
  1240. IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE) &&
  1241. (cable_length > 0) &&
  1242. ((device_tech >> 4) ==
  1243. IXGBE_SFF_QSFP_TRANSMITER_850NM_VCSEL))
  1244. active_cable = true;
  1245. }
  1246. if (active_cable) {
  1247. hw->phy.type = ixgbe_phy_qsfp_active_unknown;
  1248. if (hw->bus.lan_id == 0)
  1249. hw->phy.sfp_type =
  1250. ixgbe_sfp_type_da_act_lmt_core0;
  1251. else
  1252. hw->phy.sfp_type =
  1253. ixgbe_sfp_type_da_act_lmt_core1;
  1254. } else {
  1255. /* unsupported module type */
  1256. hw->phy.type = ixgbe_phy_sfp_unsupported;
  1257. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1258. }
  1259. }
  1260. if (hw->phy.sfp_type != stored_sfp_type)
  1261. hw->phy.sfp_setup_needed = true;
  1262. /* Determine if the QSFP+ PHY is dual speed or not. */
  1263. hw->phy.multispeed_fiber = false;
  1264. if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
  1265. (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
  1266. ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
  1267. (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
  1268. hw->phy.multispeed_fiber = true;
  1269. /* Determine PHY vendor for optical modules */
  1270. if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
  1271. IXGBE_SFF_10GBASELR_CAPABLE)) {
  1272. status = hw->phy.ops.read_i2c_eeprom(hw,
  1273. IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0,
  1274. &oui_bytes[0]);
  1275. if (status != 0)
  1276. goto err_read_i2c_eeprom;
  1277. status = hw->phy.ops.read_i2c_eeprom(hw,
  1278. IXGBE_SFF_QSFP_VENDOR_OUI_BYTE1,
  1279. &oui_bytes[1]);
  1280. if (status != 0)
  1281. goto err_read_i2c_eeprom;
  1282. status = hw->phy.ops.read_i2c_eeprom(hw,
  1283. IXGBE_SFF_QSFP_VENDOR_OUI_BYTE2,
  1284. &oui_bytes[2]);
  1285. if (status != 0)
  1286. goto err_read_i2c_eeprom;
  1287. vendor_oui =
  1288. ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
  1289. (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
  1290. (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
  1291. if (vendor_oui == IXGBE_SFF_VENDOR_OUI_INTEL)
  1292. hw->phy.type = ixgbe_phy_qsfp_intel;
  1293. else
  1294. hw->phy.type = ixgbe_phy_qsfp_unknown;
  1295. hw->mac.ops.get_device_caps(hw, &enforce_sfp);
  1296. if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
  1297. /* Make sure we're a supported PHY type */
  1298. if (hw->phy.type == ixgbe_phy_qsfp_intel)
  1299. return 0;
  1300. if (hw->allow_unsupported_sfp) {
  1301. e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n");
  1302. return 0;
  1303. }
  1304. hw_dbg(hw, "QSFP module not supported\n");
  1305. hw->phy.type = ixgbe_phy_sfp_unsupported;
  1306. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1307. }
  1308. return 0;
  1309. }
  1310. return 0;
  1311. err_read_i2c_eeprom:
  1312. hw->phy.sfp_type = ixgbe_sfp_type_not_present;
  1313. hw->phy.id = 0;
  1314. hw->phy.type = ixgbe_phy_unknown;
  1315. return IXGBE_ERR_SFP_NOT_PRESENT;
  1316. }
  1317. /**
  1318. * ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
  1319. * @hw: pointer to hardware structure
  1320. * @list_offset: offset to the SFP ID list
  1321. * @data_offset: offset to the SFP data block
  1322. *
  1323. * Checks the MAC's EEPROM to see if it supports a given SFP+ module type, if
  1324. * so it returns the offsets to the phy init sequence block.
  1325. **/
  1326. s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
  1327. u16 *list_offset,
  1328. u16 *data_offset)
  1329. {
  1330. u16 sfp_id;
  1331. u16 sfp_type = hw->phy.sfp_type;
  1332. if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
  1333. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1334. if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
  1335. return IXGBE_ERR_SFP_NOT_PRESENT;
  1336. if ((hw->device_id == IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) &&
  1337. (hw->phy.sfp_type == ixgbe_sfp_type_da_cu))
  1338. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1339. /*
  1340. * Limiting active cables and 1G Phys must be initialized as
  1341. * SR modules
  1342. */
  1343. if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
  1344. sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
  1345. sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
  1346. sfp_type == ixgbe_sfp_type_1g_sx_core0)
  1347. sfp_type = ixgbe_sfp_type_srlr_core0;
  1348. else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
  1349. sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
  1350. sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
  1351. sfp_type == ixgbe_sfp_type_1g_sx_core1)
  1352. sfp_type = ixgbe_sfp_type_srlr_core1;
  1353. /* Read offset to PHY init contents */
  1354. if (hw->eeprom.ops.read(hw, IXGBE_PHY_INIT_OFFSET_NL, list_offset)) {
  1355. hw_err(hw, "eeprom read at %d failed\n",
  1356. IXGBE_PHY_INIT_OFFSET_NL);
  1357. return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
  1358. }
  1359. if ((!*list_offset) || (*list_offset == 0xFFFF))
  1360. return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
  1361. /* Shift offset to first ID word */
  1362. (*list_offset)++;
  1363. /*
  1364. * Find the matching SFP ID in the EEPROM
  1365. * and program the init sequence
  1366. */
  1367. if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
  1368. goto err_phy;
  1369. while (sfp_id != IXGBE_PHY_INIT_END_NL) {
  1370. if (sfp_id == sfp_type) {
  1371. (*list_offset)++;
  1372. if (hw->eeprom.ops.read(hw, *list_offset, data_offset))
  1373. goto err_phy;
  1374. if ((!*data_offset) || (*data_offset == 0xFFFF)) {
  1375. hw_dbg(hw, "SFP+ module not supported\n");
  1376. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1377. } else {
  1378. break;
  1379. }
  1380. } else {
  1381. (*list_offset) += 2;
  1382. if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
  1383. goto err_phy;
  1384. }
  1385. }
  1386. if (sfp_id == IXGBE_PHY_INIT_END_NL) {
  1387. hw_dbg(hw, "No matching SFP+ module found\n");
  1388. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1389. }
  1390. return 0;
  1391. err_phy:
  1392. hw_err(hw, "eeprom read at offset %d failed\n", *list_offset);
  1393. return IXGBE_ERR_PHY;
  1394. }
  1395. /**
  1396. * ixgbe_read_i2c_eeprom_generic - Reads 8 bit EEPROM word over I2C interface
  1397. * @hw: pointer to hardware structure
  1398. * @byte_offset: EEPROM byte offset to read
  1399. * @eeprom_data: value read
  1400. *
  1401. * Performs byte read operation to SFP module's EEPROM over I2C interface.
  1402. **/
  1403. s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
  1404. u8 *eeprom_data)
  1405. {
  1406. return hw->phy.ops.read_i2c_byte(hw, byte_offset,
  1407. IXGBE_I2C_EEPROM_DEV_ADDR,
  1408. eeprom_data);
  1409. }
  1410. /**
  1411. * ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface
  1412. * @hw: pointer to hardware structure
  1413. * @byte_offset: byte offset at address 0xA2
  1414. * @eeprom_data: value read
  1415. *
  1416. * Performs byte read operation to SFP module's SFF-8472 data over I2C
  1417. **/
  1418. s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
  1419. u8 *sff8472_data)
  1420. {
  1421. return hw->phy.ops.read_i2c_byte(hw, byte_offset,
  1422. IXGBE_I2C_EEPROM_DEV_ADDR2,
  1423. sff8472_data);
  1424. }
  1425. /**
  1426. * ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface
  1427. * @hw: pointer to hardware structure
  1428. * @byte_offset: EEPROM byte offset to write
  1429. * @eeprom_data: value to write
  1430. *
  1431. * Performs byte write operation to SFP module's EEPROM over I2C interface.
  1432. **/
  1433. s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
  1434. u8 eeprom_data)
  1435. {
  1436. return hw->phy.ops.write_i2c_byte(hw, byte_offset,
  1437. IXGBE_I2C_EEPROM_DEV_ADDR,
  1438. eeprom_data);
  1439. }
  1440. /**
  1441. * ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
  1442. * @hw: pointer to hardware structure
  1443. * @byte_offset: byte offset to read
  1444. * @data: value read
  1445. *
  1446. * Performs byte read operation to SFP module's EEPROM over I2C interface at
  1447. * a specified device address.
  1448. **/
  1449. s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
  1450. u8 dev_addr, u8 *data)
  1451. {
  1452. s32 status;
  1453. u32 max_retry = 10;
  1454. u32 retry = 0;
  1455. u32 swfw_mask = hw->phy.phy_semaphore_mask;
  1456. bool nack = true;
  1457. *data = 0;
  1458. do {
  1459. if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
  1460. return IXGBE_ERR_SWFW_SYNC;
  1461. ixgbe_i2c_start(hw);
  1462. /* Device Address and write indication */
  1463. status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
  1464. if (status != 0)
  1465. goto fail;
  1466. status = ixgbe_get_i2c_ack(hw);
  1467. if (status != 0)
  1468. goto fail;
  1469. status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
  1470. if (status != 0)
  1471. goto fail;
  1472. status = ixgbe_get_i2c_ack(hw);
  1473. if (status != 0)
  1474. goto fail;
  1475. ixgbe_i2c_start(hw);
  1476. /* Device Address and read indication */
  1477. status = ixgbe_clock_out_i2c_byte(hw, (dev_addr | 0x1));
  1478. if (status != 0)
  1479. goto fail;
  1480. status = ixgbe_get_i2c_ack(hw);
  1481. if (status != 0)
  1482. goto fail;
  1483. status = ixgbe_clock_in_i2c_byte(hw, data);
  1484. if (status != 0)
  1485. goto fail;
  1486. status = ixgbe_clock_out_i2c_bit(hw, nack);
  1487. if (status != 0)
  1488. goto fail;
  1489. ixgbe_i2c_stop(hw);
  1490. break;
  1491. fail:
  1492. ixgbe_i2c_bus_clear(hw);
  1493. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  1494. msleep(100);
  1495. retry++;
  1496. if (retry < max_retry)
  1497. hw_dbg(hw, "I2C byte read error - Retrying.\n");
  1498. else
  1499. hw_dbg(hw, "I2C byte read error.\n");
  1500. } while (retry < max_retry);
  1501. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  1502. return status;
  1503. }
  1504. /**
  1505. * ixgbe_write_i2c_byte_generic - Writes 8 bit word over I2C
  1506. * @hw: pointer to hardware structure
  1507. * @byte_offset: byte offset to write
  1508. * @data: value to write
  1509. *
  1510. * Performs byte write operation to SFP module's EEPROM over I2C interface at
  1511. * a specified device address.
  1512. **/
  1513. s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
  1514. u8 dev_addr, u8 data)
  1515. {
  1516. s32 status;
  1517. u32 max_retry = 1;
  1518. u32 retry = 0;
  1519. u32 swfw_mask = hw->phy.phy_semaphore_mask;
  1520. if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
  1521. return IXGBE_ERR_SWFW_SYNC;
  1522. do {
  1523. ixgbe_i2c_start(hw);
  1524. status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
  1525. if (status != 0)
  1526. goto fail;
  1527. status = ixgbe_get_i2c_ack(hw);
  1528. if (status != 0)
  1529. goto fail;
  1530. status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
  1531. if (status != 0)
  1532. goto fail;
  1533. status = ixgbe_get_i2c_ack(hw);
  1534. if (status != 0)
  1535. goto fail;
  1536. status = ixgbe_clock_out_i2c_byte(hw, data);
  1537. if (status != 0)
  1538. goto fail;
  1539. status = ixgbe_get_i2c_ack(hw);
  1540. if (status != 0)
  1541. goto fail;
  1542. ixgbe_i2c_stop(hw);
  1543. break;
  1544. fail:
  1545. ixgbe_i2c_bus_clear(hw);
  1546. retry++;
  1547. if (retry < max_retry)
  1548. hw_dbg(hw, "I2C byte write error - Retrying.\n");
  1549. else
  1550. hw_dbg(hw, "I2C byte write error.\n");
  1551. } while (retry < max_retry);
  1552. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  1553. return status;
  1554. }
  1555. /**
  1556. * ixgbe_i2c_start - Sets I2C start condition
  1557. * @hw: pointer to hardware structure
  1558. *
  1559. * Sets I2C start condition (High -> Low on SDA while SCL is High)
  1560. **/
  1561. static void ixgbe_i2c_start(struct ixgbe_hw *hw)
  1562. {
  1563. u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1564. /* Start condition must begin with data and clock high */
  1565. ixgbe_set_i2c_data(hw, &i2cctl, 1);
  1566. ixgbe_raise_i2c_clk(hw, &i2cctl);
  1567. /* Setup time for start condition (4.7us) */
  1568. udelay(IXGBE_I2C_T_SU_STA);
  1569. ixgbe_set_i2c_data(hw, &i2cctl, 0);
  1570. /* Hold time for start condition (4us) */
  1571. udelay(IXGBE_I2C_T_HD_STA);
  1572. ixgbe_lower_i2c_clk(hw, &i2cctl);
  1573. /* Minimum low period of clock is 4.7 us */
  1574. udelay(IXGBE_I2C_T_LOW);
  1575. }
  1576. /**
  1577. * ixgbe_i2c_stop - Sets I2C stop condition
  1578. * @hw: pointer to hardware structure
  1579. *
  1580. * Sets I2C stop condition (Low -> High on SDA while SCL is High)
  1581. **/
  1582. static void ixgbe_i2c_stop(struct ixgbe_hw *hw)
  1583. {
  1584. u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1585. /* Stop condition must begin with data low and clock high */
  1586. ixgbe_set_i2c_data(hw, &i2cctl, 0);
  1587. ixgbe_raise_i2c_clk(hw, &i2cctl);
  1588. /* Setup time for stop condition (4us) */
  1589. udelay(IXGBE_I2C_T_SU_STO);
  1590. ixgbe_set_i2c_data(hw, &i2cctl, 1);
  1591. /* bus free time between stop and start (4.7us)*/
  1592. udelay(IXGBE_I2C_T_BUF);
  1593. }
  1594. /**
  1595. * ixgbe_clock_in_i2c_byte - Clocks in one byte via I2C
  1596. * @hw: pointer to hardware structure
  1597. * @data: data byte to clock in
  1598. *
  1599. * Clocks in one byte data via I2C data/clock
  1600. **/
  1601. static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data)
  1602. {
  1603. s32 i;
  1604. bool bit = false;
  1605. for (i = 7; i >= 0; i--) {
  1606. ixgbe_clock_in_i2c_bit(hw, &bit);
  1607. *data |= bit << i;
  1608. }
  1609. return 0;
  1610. }
  1611. /**
  1612. * ixgbe_clock_out_i2c_byte - Clocks out one byte via I2C
  1613. * @hw: pointer to hardware structure
  1614. * @data: data byte clocked out
  1615. *
  1616. * Clocks out one byte data via I2C data/clock
  1617. **/
  1618. static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
  1619. {
  1620. s32 status;
  1621. s32 i;
  1622. u32 i2cctl;
  1623. bool bit = false;
  1624. for (i = 7; i >= 0; i--) {
  1625. bit = (data >> i) & 0x1;
  1626. status = ixgbe_clock_out_i2c_bit(hw, bit);
  1627. if (status != 0)
  1628. break;
  1629. }
  1630. /* Release SDA line (set high) */
  1631. i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1632. i2cctl |= IXGBE_I2C_DATA_OUT(hw);
  1633. IXGBE_WRITE_REG(hw, IXGBE_I2CCTL(hw), i2cctl);
  1634. IXGBE_WRITE_FLUSH(hw);
  1635. return status;
  1636. }
  1637. /**
  1638. * ixgbe_get_i2c_ack - Polls for I2C ACK
  1639. * @hw: pointer to hardware structure
  1640. *
  1641. * Clocks in/out one bit via I2C data/clock
  1642. **/
  1643. static s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
  1644. {
  1645. s32 status = 0;
  1646. u32 i = 0;
  1647. u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1648. u32 timeout = 10;
  1649. bool ack = true;
  1650. ixgbe_raise_i2c_clk(hw, &i2cctl);
  1651. /* Minimum high period of clock is 4us */
  1652. udelay(IXGBE_I2C_T_HIGH);
  1653. /* Poll for ACK. Note that ACK in I2C spec is
  1654. * transition from 1 to 0 */
  1655. for (i = 0; i < timeout; i++) {
  1656. i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1657. ack = ixgbe_get_i2c_data(hw, &i2cctl);
  1658. udelay(1);
  1659. if (ack == 0)
  1660. break;
  1661. }
  1662. if (ack == 1) {
  1663. hw_dbg(hw, "I2C ack was not received.\n");
  1664. status = IXGBE_ERR_I2C;
  1665. }
  1666. ixgbe_lower_i2c_clk(hw, &i2cctl);
  1667. /* Minimum low period of clock is 4.7 us */
  1668. udelay(IXGBE_I2C_T_LOW);
  1669. return status;
  1670. }
  1671. /**
  1672. * ixgbe_clock_in_i2c_bit - Clocks in one bit via I2C data/clock
  1673. * @hw: pointer to hardware structure
  1674. * @data: read data value
  1675. *
  1676. * Clocks in one bit via I2C data/clock
  1677. **/
  1678. static s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data)
  1679. {
  1680. u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1681. ixgbe_raise_i2c_clk(hw, &i2cctl);
  1682. /* Minimum high period of clock is 4us */
  1683. udelay(IXGBE_I2C_T_HIGH);
  1684. i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1685. *data = ixgbe_get_i2c_data(hw, &i2cctl);
  1686. ixgbe_lower_i2c_clk(hw, &i2cctl);
  1687. /* Minimum low period of clock is 4.7 us */
  1688. udelay(IXGBE_I2C_T_LOW);
  1689. return 0;
  1690. }
  1691. /**
  1692. * ixgbe_clock_out_i2c_bit - Clocks in/out one bit via I2C data/clock
  1693. * @hw: pointer to hardware structure
  1694. * @data: data value to write
  1695. *
  1696. * Clocks out one bit via I2C data/clock
  1697. **/
  1698. static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data)
  1699. {
  1700. s32 status;
  1701. u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1702. status = ixgbe_set_i2c_data(hw, &i2cctl, data);
  1703. if (status == 0) {
  1704. ixgbe_raise_i2c_clk(hw, &i2cctl);
  1705. /* Minimum high period of clock is 4us */
  1706. udelay(IXGBE_I2C_T_HIGH);
  1707. ixgbe_lower_i2c_clk(hw, &i2cctl);
  1708. /* Minimum low period of clock is 4.7 us.
  1709. * This also takes care of the data hold time.
  1710. */
  1711. udelay(IXGBE_I2C_T_LOW);
  1712. } else {
  1713. hw_dbg(hw, "I2C data was not set to %X\n", data);
  1714. return IXGBE_ERR_I2C;
  1715. }
  1716. return 0;
  1717. }
  1718. /**
  1719. * ixgbe_raise_i2c_clk - Raises the I2C SCL clock
  1720. * @hw: pointer to hardware structure
  1721. * @i2cctl: Current value of I2CCTL register
  1722. *
  1723. * Raises the I2C clock line '0'->'1'
  1724. **/
  1725. static void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
  1726. {
  1727. u32 i = 0;
  1728. u32 timeout = IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT;
  1729. u32 i2cctl_r = 0;
  1730. for (i = 0; i < timeout; i++) {
  1731. *i2cctl |= IXGBE_I2C_CLK_OUT(hw);
  1732. IXGBE_WRITE_REG(hw, IXGBE_I2CCTL(hw), *i2cctl);
  1733. IXGBE_WRITE_FLUSH(hw);
  1734. /* SCL rise time (1000ns) */
  1735. udelay(IXGBE_I2C_T_RISE);
  1736. i2cctl_r = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1737. if (i2cctl_r & IXGBE_I2C_CLK_IN(hw))
  1738. break;
  1739. }
  1740. }
  1741. /**
  1742. * ixgbe_lower_i2c_clk - Lowers the I2C SCL clock
  1743. * @hw: pointer to hardware structure
  1744. * @i2cctl: Current value of I2CCTL register
  1745. *
  1746. * Lowers the I2C clock line '1'->'0'
  1747. **/
  1748. static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
  1749. {
  1750. *i2cctl &= ~IXGBE_I2C_CLK_OUT(hw);
  1751. IXGBE_WRITE_REG(hw, IXGBE_I2CCTL(hw), *i2cctl);
  1752. IXGBE_WRITE_FLUSH(hw);
  1753. /* SCL fall time (300ns) */
  1754. udelay(IXGBE_I2C_T_FALL);
  1755. }
  1756. /**
  1757. * ixgbe_set_i2c_data - Sets the I2C data bit
  1758. * @hw: pointer to hardware structure
  1759. * @i2cctl: Current value of I2CCTL register
  1760. * @data: I2C data value (0 or 1) to set
  1761. *
  1762. * Sets the I2C data bit
  1763. **/
  1764. static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
  1765. {
  1766. if (data)
  1767. *i2cctl |= IXGBE_I2C_DATA_OUT(hw);
  1768. else
  1769. *i2cctl &= ~IXGBE_I2C_DATA_OUT(hw);
  1770. IXGBE_WRITE_REG(hw, IXGBE_I2CCTL(hw), *i2cctl);
  1771. IXGBE_WRITE_FLUSH(hw);
  1772. /* Data rise/fall (1000ns/300ns) and set-up time (250ns) */
  1773. udelay(IXGBE_I2C_T_RISE + IXGBE_I2C_T_FALL + IXGBE_I2C_T_SU_DATA);
  1774. /* Verify data was set correctly */
  1775. *i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1776. if (data != ixgbe_get_i2c_data(hw, i2cctl)) {
  1777. hw_dbg(hw, "Error - I2C data was not set to %X.\n", data);
  1778. return IXGBE_ERR_I2C;
  1779. }
  1780. return 0;
  1781. }
  1782. /**
  1783. * ixgbe_get_i2c_data - Reads the I2C SDA data bit
  1784. * @hw: pointer to hardware structure
  1785. * @i2cctl: Current value of I2CCTL register
  1786. *
  1787. * Returns the I2C data bit value
  1788. **/
  1789. static bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl)
  1790. {
  1791. if (*i2cctl & IXGBE_I2C_DATA_IN(hw))
  1792. return true;
  1793. return false;
  1794. }
  1795. /**
  1796. * ixgbe_i2c_bus_clear - Clears the I2C bus
  1797. * @hw: pointer to hardware structure
  1798. *
  1799. * Clears the I2C bus by sending nine clock pulses.
  1800. * Used when data line is stuck low.
  1801. **/
  1802. static void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
  1803. {
  1804. u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL(hw));
  1805. u32 i;
  1806. ixgbe_i2c_start(hw);
  1807. ixgbe_set_i2c_data(hw, &i2cctl, 1);
  1808. for (i = 0; i < 9; i++) {
  1809. ixgbe_raise_i2c_clk(hw, &i2cctl);
  1810. /* Min high period of clock is 4us */
  1811. udelay(IXGBE_I2C_T_HIGH);
  1812. ixgbe_lower_i2c_clk(hw, &i2cctl);
  1813. /* Min low period of clock is 4.7us*/
  1814. udelay(IXGBE_I2C_T_LOW);
  1815. }
  1816. ixgbe_i2c_start(hw);
  1817. /* Put the i2c bus back to default state */
  1818. ixgbe_i2c_stop(hw);
  1819. }
  1820. /**
  1821. * ixgbe_tn_check_overtemp - Checks if an overtemp occurred.
  1822. * @hw: pointer to hardware structure
  1823. *
  1824. * Checks if the LASI temp alarm status was triggered due to overtemp
  1825. **/
  1826. s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
  1827. {
  1828. u16 phy_data = 0;
  1829. if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
  1830. return 0;
  1831. /* Check that the LASI temp alarm status was triggered */
  1832. hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
  1833. MDIO_MMD_PMAPMD, &phy_data);
  1834. if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
  1835. return 0;
  1836. return IXGBE_ERR_OVERTEMP;
  1837. }
  1838. /** ixgbe_set_copper_phy_power - Control power for copper phy
  1839. * @hw: pointer to hardware structure
  1840. * @on: true for on, false for off
  1841. **/
  1842. s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
  1843. {
  1844. u32 status;
  1845. u16 reg;
  1846. /* Bail if we don't have copper phy */
  1847. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
  1848. return 0;
  1849. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
  1850. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1851. &reg);
  1852. if (status)
  1853. return status;
  1854. if (on) {
  1855. reg &= ~IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
  1856. } else {
  1857. if (ixgbe_check_reset_blocked(hw))
  1858. return 0;
  1859. reg |= IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
  1860. }
  1861. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
  1862. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1863. reg);
  1864. return status;
  1865. }