ixgbe_x550.c 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096
  1. /*******************************************************************************
  2. *
  3. * Intel 10 Gigabit PCI Express Linux driver
  4. * Copyright(c) 1999 - 2016 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Contact Information:
  19. * Linux NICS <linux.nics@intel.com>
  20. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  21. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  22. *
  23. ******************************************************************************/
  24. #include "ixgbe_x540.h"
  25. #include "ixgbe_type.h"
  26. #include "ixgbe_common.h"
  27. #include "ixgbe_phy.h"
  28. static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *, ixgbe_link_speed);
  29. static s32 ixgbe_setup_fc_x550em(struct ixgbe_hw *);
  30. static s32 ixgbe_get_invariants_X550_x(struct ixgbe_hw *hw)
  31. {
  32. struct ixgbe_mac_info *mac = &hw->mac;
  33. struct ixgbe_phy_info *phy = &hw->phy;
  34. /* Start with X540 invariants, since so simular */
  35. ixgbe_get_invariants_X540(hw);
  36. if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
  37. phy->ops.set_phy_power = NULL;
  38. return 0;
  39. }
  40. /** ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
  41. * @hw: pointer to hardware structure
  42. **/
  43. static void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
  44. {
  45. u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  46. if (hw->bus.lan_id) {
  47. esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
  48. esdp |= IXGBE_ESDP_SDP1_DIR;
  49. }
  50. esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
  51. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  52. IXGBE_WRITE_FLUSH(hw);
  53. }
  54. /**
  55. * ixgbe_read_cs4227 - Read CS4227 register
  56. * @hw: pointer to hardware structure
  57. * @reg: register number to write
  58. * @value: pointer to receive value read
  59. *
  60. * Returns status code
  61. */
  62. static s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
  63. {
  64. return hw->phy.ops.read_i2c_combined_unlocked(hw, IXGBE_CS4227, reg,
  65. value);
  66. }
  67. /**
  68. * ixgbe_write_cs4227 - Write CS4227 register
  69. * @hw: pointer to hardware structure
  70. * @reg: register number to write
  71. * @value: value to write to register
  72. *
  73. * Returns status code
  74. */
  75. static s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
  76. {
  77. return hw->phy.ops.write_i2c_combined_unlocked(hw, IXGBE_CS4227, reg,
  78. value);
  79. }
  80. /**
  81. * ixgbe_read_pe - Read register from port expander
  82. * @hw: pointer to hardware structure
  83. * @reg: register number to read
  84. * @value: pointer to receive read value
  85. *
  86. * Returns status code
  87. */
  88. static s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
  89. {
  90. s32 status;
  91. status = ixgbe_read_i2c_byte_generic_unlocked(hw, reg, IXGBE_PE, value);
  92. if (status)
  93. hw_err(hw, "port expander access failed with %d\n", status);
  94. return status;
  95. }
  96. /**
  97. * ixgbe_write_pe - Write register to port expander
  98. * @hw: pointer to hardware structure
  99. * @reg: register number to write
  100. * @value: value to write
  101. *
  102. * Returns status code
  103. */
  104. static s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
  105. {
  106. s32 status;
  107. status = ixgbe_write_i2c_byte_generic_unlocked(hw, reg, IXGBE_PE,
  108. value);
  109. if (status)
  110. hw_err(hw, "port expander access failed with %d\n", status);
  111. return status;
  112. }
  113. /**
  114. * ixgbe_reset_cs4227 - Reset CS4227 using port expander
  115. * @hw: pointer to hardware structure
  116. *
  117. * This function assumes that the caller has acquired the proper semaphore.
  118. * Returns error code
  119. */
  120. static s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
  121. {
  122. s32 status;
  123. u32 retry;
  124. u16 value;
  125. u8 reg;
  126. /* Trigger hard reset. */
  127. status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
  128. if (status)
  129. return status;
  130. reg |= IXGBE_PE_BIT1;
  131. status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
  132. if (status)
  133. return status;
  134. status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, &reg);
  135. if (status)
  136. return status;
  137. reg &= ~IXGBE_PE_BIT1;
  138. status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
  139. if (status)
  140. return status;
  141. status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
  142. if (status)
  143. return status;
  144. reg &= ~IXGBE_PE_BIT1;
  145. status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
  146. if (status)
  147. return status;
  148. usleep_range(IXGBE_CS4227_RESET_HOLD, IXGBE_CS4227_RESET_HOLD + 100);
  149. status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
  150. if (status)
  151. return status;
  152. reg |= IXGBE_PE_BIT1;
  153. status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
  154. if (status)
  155. return status;
  156. /* Wait for the reset to complete. */
  157. msleep(IXGBE_CS4227_RESET_DELAY);
  158. for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
  159. status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
  160. &value);
  161. if (!status && value == IXGBE_CS4227_EEPROM_LOAD_OK)
  162. break;
  163. msleep(IXGBE_CS4227_CHECK_DELAY);
  164. }
  165. if (retry == IXGBE_CS4227_RETRIES) {
  166. hw_err(hw, "CS4227 reset did not complete\n");
  167. return IXGBE_ERR_PHY;
  168. }
  169. status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
  170. if (status || !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
  171. hw_err(hw, "CS4227 EEPROM did not load successfully\n");
  172. return IXGBE_ERR_PHY;
  173. }
  174. return 0;
  175. }
  176. /**
  177. * ixgbe_check_cs4227 - Check CS4227 and reset as needed
  178. * @hw: pointer to hardware structure
  179. */
  180. static void ixgbe_check_cs4227(struct ixgbe_hw *hw)
  181. {
  182. u32 swfw_mask = hw->phy.phy_semaphore_mask;
  183. s32 status;
  184. u16 value;
  185. u8 retry;
  186. for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
  187. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  188. if (status) {
  189. hw_err(hw, "semaphore failed with %d\n", status);
  190. msleep(IXGBE_CS4227_CHECK_DELAY);
  191. continue;
  192. }
  193. /* Get status of reset flow. */
  194. status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
  195. if (!status && value == IXGBE_CS4227_RESET_COMPLETE)
  196. goto out;
  197. if (status || value != IXGBE_CS4227_RESET_PENDING)
  198. break;
  199. /* Reset is pending. Wait and check again. */
  200. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  201. msleep(IXGBE_CS4227_CHECK_DELAY);
  202. }
  203. /* If still pending, assume other instance failed. */
  204. if (retry == IXGBE_CS4227_RETRIES) {
  205. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  206. if (status) {
  207. hw_err(hw, "semaphore failed with %d\n", status);
  208. return;
  209. }
  210. }
  211. /* Reset the CS4227. */
  212. status = ixgbe_reset_cs4227(hw);
  213. if (status) {
  214. hw_err(hw, "CS4227 reset failed: %d", status);
  215. goto out;
  216. }
  217. /* Reset takes so long, temporarily release semaphore in case the
  218. * other driver instance is waiting for the reset indication.
  219. */
  220. ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
  221. IXGBE_CS4227_RESET_PENDING);
  222. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  223. usleep_range(10000, 12000);
  224. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  225. if (status) {
  226. hw_err(hw, "semaphore failed with %d", status);
  227. return;
  228. }
  229. /* Record completion for next time. */
  230. status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
  231. IXGBE_CS4227_RESET_COMPLETE);
  232. out:
  233. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  234. msleep(hw->eeprom.semaphore_delay);
  235. }
  236. /** ixgbe_identify_phy_x550em - Get PHY type based on device id
  237. * @hw: pointer to hardware structure
  238. *
  239. * Returns error code
  240. */
  241. static s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
  242. {
  243. switch (hw->device_id) {
  244. case IXGBE_DEV_ID_X550EM_A_SFP:
  245. if (hw->bus.lan_id)
  246. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
  247. else
  248. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
  249. return ixgbe_identify_module_generic(hw);
  250. case IXGBE_DEV_ID_X550EM_X_SFP:
  251. /* set up for CS4227 usage */
  252. hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
  253. ixgbe_setup_mux_ctl(hw);
  254. ixgbe_check_cs4227(hw);
  255. /* Fallthrough */
  256. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  257. return ixgbe_identify_module_generic(hw);
  258. case IXGBE_DEV_ID_X550EM_X_KX4:
  259. hw->phy.type = ixgbe_phy_x550em_kx4;
  260. break;
  261. case IXGBE_DEV_ID_X550EM_X_KR:
  262. case IXGBE_DEV_ID_X550EM_A_KR:
  263. case IXGBE_DEV_ID_X550EM_A_KR_L:
  264. hw->phy.type = ixgbe_phy_x550em_kr;
  265. break;
  266. case IXGBE_DEV_ID_X550EM_A_10G_T:
  267. if (hw->bus.lan_id)
  268. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
  269. else
  270. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
  271. /* Fallthrough */
  272. case IXGBE_DEV_ID_X550EM_X_1G_T:
  273. case IXGBE_DEV_ID_X550EM_X_10G_T:
  274. return ixgbe_identify_phy_generic(hw);
  275. default:
  276. break;
  277. }
  278. return 0;
  279. }
  280. static s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
  281. u32 device_type, u16 *phy_data)
  282. {
  283. return IXGBE_NOT_IMPLEMENTED;
  284. }
  285. static s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
  286. u32 device_type, u16 phy_data)
  287. {
  288. return IXGBE_NOT_IMPLEMENTED;
  289. }
  290. /** ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
  291. * @hw: pointer to hardware structure
  292. *
  293. * Initializes the EEPROM parameters ixgbe_eeprom_info within the
  294. * ixgbe_hw struct in order to set up EEPROM access.
  295. **/
  296. static s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  297. {
  298. struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
  299. u32 eec;
  300. u16 eeprom_size;
  301. if (eeprom->type == ixgbe_eeprom_uninitialized) {
  302. eeprom->semaphore_delay = 10;
  303. eeprom->type = ixgbe_flash;
  304. eec = IXGBE_READ_REG(hw, IXGBE_EEC(hw));
  305. eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
  306. IXGBE_EEC_SIZE_SHIFT);
  307. eeprom->word_size = BIT(eeprom_size +
  308. IXGBE_EEPROM_WORD_SIZE_SHIFT);
  309. hw_dbg(hw, "Eeprom params: type = %d, size = %d\n",
  310. eeprom->type, eeprom->word_size);
  311. }
  312. return 0;
  313. }
  314. /**
  315. * ixgbe_iosf_wait - Wait for IOSF command completion
  316. * @hw: pointer to hardware structure
  317. * @ctrl: pointer to location to receive final IOSF control value
  318. *
  319. * Return: failing status on timeout
  320. *
  321. * Note: ctrl can be NULL if the IOSF control register value is not needed
  322. */
  323. static s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
  324. {
  325. u32 i, command;
  326. /* Check every 10 usec to see if the address cycle completed.
  327. * The SB IOSF BUSY bit will clear when the operation is
  328. * complete.
  329. */
  330. for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
  331. command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
  332. if (!(command & IXGBE_SB_IOSF_CTRL_BUSY))
  333. break;
  334. udelay(10);
  335. }
  336. if (ctrl)
  337. *ctrl = command;
  338. if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
  339. hw_dbg(hw, "IOSF wait timed out\n");
  340. return IXGBE_ERR_PHY;
  341. }
  342. return 0;
  343. }
  344. /** ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the
  345. * IOSF device
  346. * @hw: pointer to hardware structure
  347. * @reg_addr: 32 bit PHY register to write
  348. * @device_type: 3 bit device type
  349. * @phy_data: Pointer to read data from the register
  350. **/
  351. static s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
  352. u32 device_type, u32 *data)
  353. {
  354. u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
  355. u32 command, error;
  356. s32 ret;
  357. ret = hw->mac.ops.acquire_swfw_sync(hw, gssr);
  358. if (ret)
  359. return ret;
  360. ret = ixgbe_iosf_wait(hw, NULL);
  361. if (ret)
  362. goto out;
  363. command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
  364. (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
  365. /* Write IOSF control register */
  366. IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
  367. ret = ixgbe_iosf_wait(hw, &command);
  368. if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
  369. error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
  370. IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
  371. hw_dbg(hw, "Failed to read, error %x\n", error);
  372. return IXGBE_ERR_PHY;
  373. }
  374. if (!ret)
  375. *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
  376. out:
  377. hw->mac.ops.release_swfw_sync(hw, gssr);
  378. return ret;
  379. }
  380. /**
  381. * ixgbe_get_phy_token - Get the token for shared PHY access
  382. * @hw: Pointer to hardware structure
  383. */
  384. static s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
  385. {
  386. struct ixgbe_hic_phy_token_req token_cmd;
  387. s32 status;
  388. token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
  389. token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
  390. token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
  391. token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  392. token_cmd.port_number = hw->bus.lan_id;
  393. token_cmd.command_type = FW_PHY_TOKEN_REQ;
  394. token_cmd.pad = 0;
  395. status = ixgbe_host_interface_command(hw, &token_cmd, sizeof(token_cmd),
  396. IXGBE_HI_COMMAND_TIMEOUT,
  397. true);
  398. if (status)
  399. return status;
  400. if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
  401. return 0;
  402. if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY)
  403. return IXGBE_ERR_FW_RESP_INVALID;
  404. return IXGBE_ERR_TOKEN_RETRY;
  405. }
  406. /**
  407. * ixgbe_put_phy_token - Put the token for shared PHY access
  408. * @hw: Pointer to hardware structure
  409. */
  410. static s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
  411. {
  412. struct ixgbe_hic_phy_token_req token_cmd;
  413. s32 status;
  414. token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
  415. token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
  416. token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
  417. token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  418. token_cmd.port_number = hw->bus.lan_id;
  419. token_cmd.command_type = FW_PHY_TOKEN_REL;
  420. token_cmd.pad = 0;
  421. status = ixgbe_host_interface_command(hw, &token_cmd, sizeof(token_cmd),
  422. IXGBE_HI_COMMAND_TIMEOUT,
  423. true);
  424. if (status)
  425. return status;
  426. if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
  427. return 0;
  428. return IXGBE_ERR_FW_RESP_INVALID;
  429. }
  430. /**
  431. * ixgbe_write_iosf_sb_reg_x550a - Write to IOSF PHY register
  432. * @hw: pointer to hardware structure
  433. * @reg_addr: 32 bit PHY register to write
  434. * @device_type: 3 bit device type
  435. * @data: Data to write to the register
  436. **/
  437. static s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  438. __always_unused u32 device_type,
  439. u32 data)
  440. {
  441. struct ixgbe_hic_internal_phy_req write_cmd;
  442. memset(&write_cmd, 0, sizeof(write_cmd));
  443. write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
  444. write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
  445. write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  446. write_cmd.port_number = hw->bus.lan_id;
  447. write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
  448. write_cmd.address = cpu_to_be16(reg_addr);
  449. write_cmd.write_data = cpu_to_be32(data);
  450. return ixgbe_host_interface_command(hw, &write_cmd, sizeof(write_cmd),
  451. IXGBE_HI_COMMAND_TIMEOUT, false);
  452. }
  453. /**
  454. * ixgbe_read_iosf_sb_reg_x550a - Read from IOSF PHY register
  455. * @hw: pointer to hardware structure
  456. * @reg_addr: 32 bit PHY register to write
  457. * @device_type: 3 bit device type
  458. * @data: Pointer to read data from the register
  459. **/
  460. static s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  461. __always_unused u32 device_type,
  462. u32 *data)
  463. {
  464. union {
  465. struct ixgbe_hic_internal_phy_req cmd;
  466. struct ixgbe_hic_internal_phy_resp rsp;
  467. } hic;
  468. s32 status;
  469. memset(&hic, 0, sizeof(hic));
  470. hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
  471. hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
  472. hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  473. hic.cmd.port_number = hw->bus.lan_id;
  474. hic.cmd.command_type = FW_INT_PHY_REQ_READ;
  475. hic.cmd.address = cpu_to_be16(reg_addr);
  476. status = ixgbe_host_interface_command(hw, &hic.cmd, sizeof(hic.cmd),
  477. IXGBE_HI_COMMAND_TIMEOUT, true);
  478. /* Extract the register value from the response. */
  479. *data = be32_to_cpu(hic.rsp.read_data);
  480. return status;
  481. }
  482. /** ixgbe_read_ee_hostif_data_X550 - Read EEPROM word using a host interface
  483. * command assuming that the semaphore is already obtained.
  484. * @hw: pointer to hardware structure
  485. * @offset: offset of word in the EEPROM to read
  486. * @data: word read from the EEPROM
  487. *
  488. * Reads a 16 bit word from the EEPROM using the hostif.
  489. **/
  490. static s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
  491. u16 *data)
  492. {
  493. s32 status;
  494. struct ixgbe_hic_read_shadow_ram buffer;
  495. buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
  496. buffer.hdr.req.buf_lenh = 0;
  497. buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
  498. buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
  499. /* convert offset from words to bytes */
  500. buffer.address = cpu_to_be32(offset * 2);
  501. /* one word */
  502. buffer.length = cpu_to_be16(sizeof(u16));
  503. status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
  504. IXGBE_HI_COMMAND_TIMEOUT, false);
  505. if (status)
  506. return status;
  507. *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
  508. FW_NVM_DATA_OFFSET);
  509. return 0;
  510. }
  511. /** ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
  512. * @hw: pointer to hardware structure
  513. * @offset: offset of word in the EEPROM to read
  514. * @words: number of words
  515. * @data: word(s) read from the EEPROM
  516. *
  517. * Reads a 16 bit word(s) from the EEPROM using the hostif.
  518. **/
  519. static s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
  520. u16 offset, u16 words, u16 *data)
  521. {
  522. struct ixgbe_hic_read_shadow_ram buffer;
  523. u32 current_word = 0;
  524. u16 words_to_read;
  525. s32 status;
  526. u32 i;
  527. /* Take semaphore for the entire operation. */
  528. status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  529. if (status) {
  530. hw_dbg(hw, "EEPROM read buffer - semaphore failed\n");
  531. return status;
  532. }
  533. while (words) {
  534. if (words > FW_MAX_READ_BUFFER_SIZE / 2)
  535. words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
  536. else
  537. words_to_read = words;
  538. buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
  539. buffer.hdr.req.buf_lenh = 0;
  540. buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
  541. buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
  542. /* convert offset from words to bytes */
  543. buffer.address = cpu_to_be32((offset + current_word) * 2);
  544. buffer.length = cpu_to_be16(words_to_read * 2);
  545. buffer.pad2 = 0;
  546. buffer.pad3 = 0;
  547. status = ixgbe_host_interface_command(hw, &buffer,
  548. sizeof(buffer),
  549. IXGBE_HI_COMMAND_TIMEOUT,
  550. false);
  551. if (status) {
  552. hw_dbg(hw, "Host interface command failed\n");
  553. goto out;
  554. }
  555. for (i = 0; i < words_to_read; i++) {
  556. u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
  557. 2 * i;
  558. u32 value = IXGBE_READ_REG(hw, reg);
  559. data[current_word] = (u16)(value & 0xffff);
  560. current_word++;
  561. i++;
  562. if (i < words_to_read) {
  563. value >>= 16;
  564. data[current_word] = (u16)(value & 0xffff);
  565. current_word++;
  566. }
  567. }
  568. words -= words_to_read;
  569. }
  570. out:
  571. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  572. return status;
  573. }
  574. /** ixgbe_checksum_ptr_x550 - Checksum one pointer region
  575. * @hw: pointer to hardware structure
  576. * @ptr: pointer offset in eeprom
  577. * @size: size of section pointed by ptr, if 0 first word will be used as size
  578. * @csum: address of checksum to update
  579. *
  580. * Returns error status for any failure
  581. **/
  582. static s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
  583. u16 size, u16 *csum, u16 *buffer,
  584. u32 buffer_size)
  585. {
  586. u16 buf[256];
  587. s32 status;
  588. u16 length, bufsz, i, start;
  589. u16 *local_buffer;
  590. bufsz = sizeof(buf) / sizeof(buf[0]);
  591. /* Read a chunk at the pointer location */
  592. if (!buffer) {
  593. status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
  594. if (status) {
  595. hw_dbg(hw, "Failed to read EEPROM image\n");
  596. return status;
  597. }
  598. local_buffer = buf;
  599. } else {
  600. if (buffer_size < ptr)
  601. return IXGBE_ERR_PARAM;
  602. local_buffer = &buffer[ptr];
  603. }
  604. if (size) {
  605. start = 0;
  606. length = size;
  607. } else {
  608. start = 1;
  609. length = local_buffer[0];
  610. /* Skip pointer section if length is invalid. */
  611. if (length == 0xFFFF || length == 0 ||
  612. (ptr + length) >= hw->eeprom.word_size)
  613. return 0;
  614. }
  615. if (buffer && ((u32)start + (u32)length > buffer_size))
  616. return IXGBE_ERR_PARAM;
  617. for (i = start; length; i++, length--) {
  618. if (i == bufsz && !buffer) {
  619. ptr += bufsz;
  620. i = 0;
  621. if (length < bufsz)
  622. bufsz = length;
  623. /* Read a chunk at the pointer location */
  624. status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
  625. bufsz, buf);
  626. if (status) {
  627. hw_dbg(hw, "Failed to read EEPROM image\n");
  628. return status;
  629. }
  630. }
  631. *csum += local_buffer[i];
  632. }
  633. return 0;
  634. }
  635. /** ixgbe_calc_checksum_X550 - Calculates and returns the checksum
  636. * @hw: pointer to hardware structure
  637. * @buffer: pointer to buffer containing calculated checksum
  638. * @buffer_size: size of buffer
  639. *
  640. * Returns a negative error code on error, or the 16-bit checksum
  641. **/
  642. static s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer,
  643. u32 buffer_size)
  644. {
  645. u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
  646. u16 *local_buffer;
  647. s32 status;
  648. u16 checksum = 0;
  649. u16 pointer, i, size;
  650. hw->eeprom.ops.init_params(hw);
  651. if (!buffer) {
  652. /* Read pointer area */
  653. status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
  654. IXGBE_EEPROM_LAST_WORD + 1,
  655. eeprom_ptrs);
  656. if (status) {
  657. hw_dbg(hw, "Failed to read EEPROM image\n");
  658. return status;
  659. }
  660. local_buffer = eeprom_ptrs;
  661. } else {
  662. if (buffer_size < IXGBE_EEPROM_LAST_WORD)
  663. return IXGBE_ERR_PARAM;
  664. local_buffer = buffer;
  665. }
  666. /* For X550 hardware include 0x0-0x41 in the checksum, skip the
  667. * checksum word itself
  668. */
  669. for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
  670. if (i != IXGBE_EEPROM_CHECKSUM)
  671. checksum += local_buffer[i];
  672. /* Include all data from pointers 0x3, 0x6-0xE. This excludes the
  673. * FW, PHY module, and PCIe Expansion/Option ROM pointers.
  674. */
  675. for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
  676. if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
  677. continue;
  678. pointer = local_buffer[i];
  679. /* Skip pointer section if the pointer is invalid. */
  680. if (pointer == 0xFFFF || pointer == 0 ||
  681. pointer >= hw->eeprom.word_size)
  682. continue;
  683. switch (i) {
  684. case IXGBE_PCIE_GENERAL_PTR:
  685. size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
  686. break;
  687. case IXGBE_PCIE_CONFIG0_PTR:
  688. case IXGBE_PCIE_CONFIG1_PTR:
  689. size = IXGBE_PCIE_CONFIG_SIZE;
  690. break;
  691. default:
  692. size = 0;
  693. break;
  694. }
  695. status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
  696. buffer, buffer_size);
  697. if (status)
  698. return status;
  699. }
  700. checksum = (u16)IXGBE_EEPROM_SUM - checksum;
  701. return (s32)checksum;
  702. }
  703. /** ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
  704. * @hw: pointer to hardware structure
  705. *
  706. * Returns a negative error code on error, or the 16-bit checksum
  707. **/
  708. static s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
  709. {
  710. return ixgbe_calc_checksum_X550(hw, NULL, 0);
  711. }
  712. /** ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
  713. * @hw: pointer to hardware structure
  714. * @offset: offset of word in the EEPROM to read
  715. * @data: word read from the EEPROM
  716. *
  717. * Reads a 16 bit word from the EEPROM using the hostif.
  718. **/
  719. static s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 *data)
  720. {
  721. s32 status = 0;
  722. if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) == 0) {
  723. status = ixgbe_read_ee_hostif_data_X550(hw, offset, data);
  724. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  725. } else {
  726. status = IXGBE_ERR_SWFW_SYNC;
  727. }
  728. return status;
  729. }
  730. /** ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
  731. * @hw: pointer to hardware structure
  732. * @checksum_val: calculated checksum
  733. *
  734. * Performs checksum calculation and validates the EEPROM checksum. If the
  735. * caller does not need checksum_val, the value can be NULL.
  736. **/
  737. static s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw,
  738. u16 *checksum_val)
  739. {
  740. s32 status;
  741. u16 checksum;
  742. u16 read_checksum = 0;
  743. /* Read the first word from the EEPROM. If this times out or fails, do
  744. * not continue or we could be in for a very long wait while every
  745. * EEPROM read fails
  746. */
  747. status = hw->eeprom.ops.read(hw, 0, &checksum);
  748. if (status) {
  749. hw_dbg(hw, "EEPROM read failed\n");
  750. return status;
  751. }
  752. status = hw->eeprom.ops.calc_checksum(hw);
  753. if (status < 0)
  754. return status;
  755. checksum = (u16)(status & 0xffff);
  756. status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
  757. &read_checksum);
  758. if (status)
  759. return status;
  760. /* Verify read checksum from EEPROM is the same as
  761. * calculated checksum
  762. */
  763. if (read_checksum != checksum) {
  764. status = IXGBE_ERR_EEPROM_CHECKSUM;
  765. hw_dbg(hw, "Invalid EEPROM checksum");
  766. }
  767. /* If the user cares, return the calculated checksum */
  768. if (checksum_val)
  769. *checksum_val = checksum;
  770. return status;
  771. }
  772. /** ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
  773. * @hw: pointer to hardware structure
  774. * @offset: offset of word in the EEPROM to write
  775. * @data: word write to the EEPROM
  776. *
  777. * Write a 16 bit word to the EEPROM using the hostif.
  778. **/
  779. static s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
  780. u16 data)
  781. {
  782. s32 status;
  783. struct ixgbe_hic_write_shadow_ram buffer;
  784. buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
  785. buffer.hdr.req.buf_lenh = 0;
  786. buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
  787. buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
  788. /* one word */
  789. buffer.length = cpu_to_be16(sizeof(u16));
  790. buffer.data = data;
  791. buffer.address = cpu_to_be32(offset * 2);
  792. status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
  793. IXGBE_HI_COMMAND_TIMEOUT, false);
  794. return status;
  795. }
  796. /** ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
  797. * @hw: pointer to hardware structure
  798. * @offset: offset of word in the EEPROM to write
  799. * @data: word write to the EEPROM
  800. *
  801. * Write a 16 bit word to the EEPROM using the hostif.
  802. **/
  803. static s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 data)
  804. {
  805. s32 status = 0;
  806. if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) == 0) {
  807. status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
  808. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  809. } else {
  810. hw_dbg(hw, "write ee hostif failed to get semaphore");
  811. status = IXGBE_ERR_SWFW_SYNC;
  812. }
  813. return status;
  814. }
  815. /** ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
  816. * @hw: pointer to hardware structure
  817. *
  818. * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
  819. **/
  820. static s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
  821. {
  822. s32 status = 0;
  823. union ixgbe_hic_hdr2 buffer;
  824. buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
  825. buffer.req.buf_lenh = 0;
  826. buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
  827. buffer.req.checksum = FW_DEFAULT_CHECKSUM;
  828. status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
  829. IXGBE_HI_COMMAND_TIMEOUT, false);
  830. return status;
  831. }
  832. /**
  833. * ixgbe_get_bus_info_X550em - Set PCI bus info
  834. * @hw: pointer to hardware structure
  835. *
  836. * Sets bus link width and speed to unknown because X550em is
  837. * not a PCI device.
  838. **/
  839. static s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
  840. {
  841. hw->bus.type = ixgbe_bus_type_internal;
  842. hw->bus.width = ixgbe_bus_width_unknown;
  843. hw->bus.speed = ixgbe_bus_speed_unknown;
  844. hw->mac.ops.set_lan_id(hw);
  845. return 0;
  846. }
  847. /** ixgbe_disable_rx_x550 - Disable RX unit
  848. *
  849. * Enables the Rx DMA unit for x550
  850. **/
  851. static void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
  852. {
  853. u32 rxctrl, pfdtxgswc;
  854. s32 status;
  855. struct ixgbe_hic_disable_rxen fw_cmd;
  856. rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
  857. if (rxctrl & IXGBE_RXCTRL_RXEN) {
  858. pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
  859. if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
  860. pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
  861. IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
  862. hw->mac.set_lben = true;
  863. } else {
  864. hw->mac.set_lben = false;
  865. }
  866. fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
  867. fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
  868. fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  869. fw_cmd.port_number = hw->bus.lan_id;
  870. status = ixgbe_host_interface_command(hw, &fw_cmd,
  871. sizeof(struct ixgbe_hic_disable_rxen),
  872. IXGBE_HI_COMMAND_TIMEOUT, true);
  873. /* If we fail - disable RX using register write */
  874. if (status) {
  875. rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
  876. if (rxctrl & IXGBE_RXCTRL_RXEN) {
  877. rxctrl &= ~IXGBE_RXCTRL_RXEN;
  878. IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
  879. }
  880. }
  881. }
  882. }
  883. /** ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
  884. * @hw: pointer to hardware structure
  885. *
  886. * After writing EEPROM to shadow RAM using EEWR register, software calculates
  887. * checksum and updates the EEPROM and instructs the hardware to update
  888. * the flash.
  889. **/
  890. static s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
  891. {
  892. s32 status;
  893. u16 checksum = 0;
  894. /* Read the first word from the EEPROM. If this times out or fails, do
  895. * not continue or we could be in for a very long wait while every
  896. * EEPROM read fails
  897. */
  898. status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
  899. if (status) {
  900. hw_dbg(hw, "EEPROM read failed\n");
  901. return status;
  902. }
  903. status = ixgbe_calc_eeprom_checksum_X550(hw);
  904. if (status < 0)
  905. return status;
  906. checksum = (u16)(status & 0xffff);
  907. status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
  908. checksum);
  909. if (status)
  910. return status;
  911. status = ixgbe_update_flash_X550(hw);
  912. return status;
  913. }
  914. /** ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
  915. * @hw: pointer to hardware structure
  916. * @offset: offset of word in the EEPROM to write
  917. * @words: number of words
  918. * @data: word(s) write to the EEPROM
  919. *
  920. *
  921. * Write a 16 bit word(s) to the EEPROM using the hostif.
  922. **/
  923. static s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
  924. u16 offset, u16 words,
  925. u16 *data)
  926. {
  927. s32 status = 0;
  928. u32 i = 0;
  929. /* Take semaphore for the entire operation. */
  930. status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  931. if (status) {
  932. hw_dbg(hw, "EEPROM write buffer - semaphore failed\n");
  933. return status;
  934. }
  935. for (i = 0; i < words; i++) {
  936. status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
  937. data[i]);
  938. if (status) {
  939. hw_dbg(hw, "Eeprom buffered write failed\n");
  940. break;
  941. }
  942. }
  943. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  944. return status;
  945. }
  946. /** ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the
  947. * IOSF device
  948. *
  949. * @hw: pointer to hardware structure
  950. * @reg_addr: 32 bit PHY register to write
  951. * @device_type: 3 bit device type
  952. * @data: Data to write to the register
  953. **/
  954. static s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
  955. u32 device_type, u32 data)
  956. {
  957. u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
  958. u32 command, error;
  959. s32 ret;
  960. ret = hw->mac.ops.acquire_swfw_sync(hw, gssr);
  961. if (ret)
  962. return ret;
  963. ret = ixgbe_iosf_wait(hw, NULL);
  964. if (ret)
  965. goto out;
  966. command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
  967. (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
  968. /* Write IOSF control register */
  969. IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
  970. /* Write IOSF data register */
  971. IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
  972. ret = ixgbe_iosf_wait(hw, &command);
  973. if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
  974. error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
  975. IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
  976. hw_dbg(hw, "Failed to write, error %x\n", error);
  977. return IXGBE_ERR_PHY;
  978. }
  979. out:
  980. hw->mac.ops.release_swfw_sync(hw, gssr);
  981. return ret;
  982. }
  983. /** ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
  984. * @hw: pointer to hardware structure
  985. * @speed: the link speed to force
  986. *
  987. * Configures the integrated KR PHY to use iXFI mode. Used to connect an
  988. * internal and external PHY at a specific speed, without autonegotiation.
  989. **/
  990. static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
  991. {
  992. s32 status;
  993. u32 reg_val;
  994. /* Disable AN and force speed to 10G Serial. */
  995. status = ixgbe_read_iosf_sb_reg_x550(hw,
  996. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  997. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  998. if (status)
  999. return status;
  1000. reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  1001. reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
  1002. /* Select forced link speed for internal PHY. */
  1003. switch (*speed) {
  1004. case IXGBE_LINK_SPEED_10GB_FULL:
  1005. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
  1006. break;
  1007. case IXGBE_LINK_SPEED_1GB_FULL:
  1008. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
  1009. break;
  1010. default:
  1011. /* Other link speeds are not supported by internal KR PHY. */
  1012. return IXGBE_ERR_LINK_SETUP;
  1013. }
  1014. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1015. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1016. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1017. if (status)
  1018. return status;
  1019. /* Disable training protocol FSM. */
  1020. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1021. IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
  1022. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1023. if (status)
  1024. return status;
  1025. reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
  1026. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1027. IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
  1028. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1029. if (status)
  1030. return status;
  1031. /* Disable Flex from training TXFFE. */
  1032. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1033. IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
  1034. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1035. if (status)
  1036. return status;
  1037. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
  1038. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
  1039. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
  1040. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1041. IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
  1042. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1043. if (status)
  1044. return status;
  1045. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1046. IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
  1047. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1048. if (status)
  1049. return status;
  1050. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
  1051. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
  1052. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
  1053. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1054. IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
  1055. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1056. if (status)
  1057. return status;
  1058. /* Enable override for coefficients. */
  1059. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1060. IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
  1061. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1062. if (status)
  1063. return status;
  1064. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
  1065. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
  1066. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
  1067. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
  1068. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1069. IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
  1070. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1071. if (status)
  1072. return status;
  1073. /* Toggle port SW reset by AN reset. */
  1074. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1075. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1076. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1077. if (status)
  1078. return status;
  1079. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
  1080. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1081. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1082. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1083. return status;
  1084. }
  1085. /**
  1086. * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
  1087. * @hw: pointer to hardware structure
  1088. * @linear: true if SFP module is linear
  1089. */
  1090. static s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
  1091. {
  1092. switch (hw->phy.sfp_type) {
  1093. case ixgbe_sfp_type_not_present:
  1094. return IXGBE_ERR_SFP_NOT_PRESENT;
  1095. case ixgbe_sfp_type_da_cu_core0:
  1096. case ixgbe_sfp_type_da_cu_core1:
  1097. *linear = true;
  1098. break;
  1099. case ixgbe_sfp_type_srlr_core0:
  1100. case ixgbe_sfp_type_srlr_core1:
  1101. case ixgbe_sfp_type_da_act_lmt_core0:
  1102. case ixgbe_sfp_type_da_act_lmt_core1:
  1103. case ixgbe_sfp_type_1g_sx_core0:
  1104. case ixgbe_sfp_type_1g_sx_core1:
  1105. case ixgbe_sfp_type_1g_lx_core0:
  1106. case ixgbe_sfp_type_1g_lx_core1:
  1107. *linear = false;
  1108. break;
  1109. case ixgbe_sfp_type_unknown:
  1110. case ixgbe_sfp_type_1g_cu_core0:
  1111. case ixgbe_sfp_type_1g_cu_core1:
  1112. default:
  1113. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1114. }
  1115. return 0;
  1116. }
  1117. /**
  1118. * ixgbe_setup_mac_link_sfp_x550em - Configure the KR PHY for SFP.
  1119. * @hw: pointer to hardware structure
  1120. *
  1121. * Configures the extern PHY and the integrated KR PHY for SFP support.
  1122. */
  1123. static s32
  1124. ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
  1125. ixgbe_link_speed speed,
  1126. __always_unused bool autoneg_wait_to_complete)
  1127. {
  1128. s32 status;
  1129. u16 slice, value;
  1130. bool setup_linear = false;
  1131. /* Check if SFP module is supported and linear */
  1132. status = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
  1133. /* If no SFP module present, then return success. Return success since
  1134. * there is no reason to configure CS4227 and SFP not present error is
  1135. * not accepted in the setup MAC link flow.
  1136. */
  1137. if (status == IXGBE_ERR_SFP_NOT_PRESENT)
  1138. return 0;
  1139. if (status)
  1140. return status;
  1141. if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
  1142. /* Configure CS4227 LINE side to 10G SR. */
  1143. slice = IXGBE_CS4227_LINE_SPARE22_MSB + (hw->bus.lan_id << 12);
  1144. value = IXGBE_CS4227_SPEED_10G;
  1145. status = ixgbe_write_i2c_combined_generic(hw, IXGBE_CS4227,
  1146. slice, value);
  1147. if (status)
  1148. goto i2c_err;
  1149. slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
  1150. value = (IXGBE_CS4227_EDC_MODE_SR << 1) | 1;
  1151. status = ixgbe_write_i2c_combined_generic(hw, IXGBE_CS4227,
  1152. slice, value);
  1153. if (status)
  1154. goto i2c_err;
  1155. /* Configure CS4227 for HOST connection rate then type. */
  1156. slice = IXGBE_CS4227_HOST_SPARE22_MSB + (hw->bus.lan_id << 12);
  1157. value = speed & IXGBE_LINK_SPEED_10GB_FULL ?
  1158. IXGBE_CS4227_SPEED_10G : IXGBE_CS4227_SPEED_1G;
  1159. status = ixgbe_write_i2c_combined_generic(hw, IXGBE_CS4227,
  1160. slice, value);
  1161. if (status)
  1162. goto i2c_err;
  1163. slice = IXGBE_CS4227_HOST_SPARE24_LSB + (hw->bus.lan_id << 12);
  1164. if (setup_linear)
  1165. value = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 1;
  1166. else
  1167. value = (IXGBE_CS4227_EDC_MODE_SR << 1) | 1;
  1168. status = ixgbe_write_i2c_combined_generic(hw, IXGBE_CS4227,
  1169. slice, value);
  1170. if (status)
  1171. goto i2c_err;
  1172. /* Setup XFI internal link. */
  1173. status = ixgbe_setup_ixfi_x550em(hw, &speed);
  1174. if (status) {
  1175. hw_dbg(hw, "setup_ixfi failed with %d\n", status);
  1176. return status;
  1177. }
  1178. } else {
  1179. /* Configure internal PHY for KR/KX. */
  1180. status = ixgbe_setup_kr_speed_x550em(hw, speed);
  1181. if (status) {
  1182. hw_dbg(hw, "setup_kr_speed failed with %d\n", status);
  1183. return status;
  1184. }
  1185. /* Configure CS4227 LINE side to proper mode. */
  1186. slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
  1187. if (setup_linear)
  1188. value = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 1;
  1189. else
  1190. value = (IXGBE_CS4227_EDC_MODE_SR << 1) | 1;
  1191. status = ixgbe_write_i2c_combined_generic(hw, IXGBE_CS4227,
  1192. slice, value);
  1193. if (status)
  1194. goto i2c_err;
  1195. }
  1196. return 0;
  1197. i2c_err:
  1198. hw_dbg(hw, "combined i2c access failed with %d\n", status);
  1199. return status;
  1200. }
  1201. /**
  1202. * ixgbe_setup_mac_link_sfp_n - Setup internal PHY for native SFP
  1203. * @hw: pointer to hardware structure
  1204. *
  1205. * Configure the the integrated PHY for native SFP support.
  1206. */
  1207. static s32
  1208. ixgbe_setup_mac_link_sfp_n(struct ixgbe_hw *hw, ixgbe_link_speed speed,
  1209. __always_unused bool autoneg_wait_to_complete)
  1210. {
  1211. bool setup_linear = false;
  1212. u32 reg_phy_int;
  1213. s32 rc;
  1214. /* Check if SFP module is supported and linear */
  1215. rc = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
  1216. /* If no SFP module present, then return success. Return success since
  1217. * SFP not present error is not excepted in the setup MAC link flow.
  1218. */
  1219. if (rc == IXGBE_ERR_SFP_NOT_PRESENT)
  1220. return 0;
  1221. if (!rc)
  1222. return rc;
  1223. /* Configure internal PHY for native SFI */
  1224. rc = hw->mac.ops.read_iosf_sb_reg(hw,
  1225. IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
  1226. IXGBE_SB_IOSF_TARGET_KR_PHY,
  1227. &reg_phy_int);
  1228. if (rc)
  1229. return rc;
  1230. if (setup_linear) {
  1231. reg_phy_int &= ~IXGBE_KRM_AN_CNTL_8_LIMITING;
  1232. reg_phy_int |= IXGBE_KRM_AN_CNTL_8_LINEAR;
  1233. } else {
  1234. reg_phy_int |= IXGBE_KRM_AN_CNTL_8_LIMITING;
  1235. reg_phy_int &= ~IXGBE_KRM_AN_CNTL_8_LINEAR;
  1236. }
  1237. rc = hw->mac.ops.write_iosf_sb_reg(hw,
  1238. IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
  1239. IXGBE_SB_IOSF_TARGET_KR_PHY,
  1240. reg_phy_int);
  1241. if (rc)
  1242. return rc;
  1243. /* Setup XFI/SFI internal link */
  1244. return ixgbe_setup_ixfi_x550em(hw, &speed);
  1245. }
  1246. /**
  1247. * ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
  1248. * @hw: pointer to hardware structure
  1249. *
  1250. * Configure the the integrated PHY for SFP support.
  1251. */
  1252. static s32
  1253. ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw, ixgbe_link_speed speed,
  1254. __always_unused bool autoneg_wait_to_complete)
  1255. {
  1256. u32 reg_slice, slice_offset;
  1257. bool setup_linear = false;
  1258. u16 reg_phy_ext;
  1259. s32 rc;
  1260. /* Check if SFP module is supported and linear */
  1261. rc = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
  1262. /* If no SFP module present, then return success. Return success since
  1263. * SFP not present error is not excepted in the setup MAC link flow.
  1264. */
  1265. if (rc == IXGBE_ERR_SFP_NOT_PRESENT)
  1266. return 0;
  1267. if (!rc)
  1268. return rc;
  1269. /* Configure internal PHY for KR/KX. */
  1270. ixgbe_setup_kr_speed_x550em(hw, speed);
  1271. if (hw->phy.mdio.prtad == MDIO_PRTAD_NONE)
  1272. return IXGBE_ERR_PHY_ADDR_INVALID;
  1273. /* Get external PHY device id */
  1274. rc = hw->phy.ops.read_reg(hw, IXGBE_CS4227_GLOBAL_ID_MSB,
  1275. IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
  1276. if (rc)
  1277. return rc;
  1278. /* When configuring quad port CS4223, the MAC instance is part
  1279. * of the slice offset.
  1280. */
  1281. if (reg_phy_ext == IXGBE_CS4223_PHY_ID)
  1282. slice_offset = (hw->bus.lan_id +
  1283. (hw->bus.instance_id << 1)) << 12;
  1284. else
  1285. slice_offset = hw->bus.lan_id << 12;
  1286. /* Configure CS4227/CS4223 LINE side to proper mode. */
  1287. reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
  1288. if (setup_linear)
  1289. reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 1;
  1290. else
  1291. reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 1;
  1292. return hw->phy.ops.write_reg(hw, reg_slice, IXGBE_MDIO_ZERO_DEV_TYPE,
  1293. reg_phy_ext);
  1294. }
  1295. /**
  1296. * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
  1297. * @hw: pointer to hardware structure
  1298. * @speed: new link speed
  1299. * @autoneg_wait_to_complete: true when waiting for completion is needed
  1300. *
  1301. * Setup internal/external PHY link speed based on link speed, then set
  1302. * external PHY auto advertised link speed.
  1303. *
  1304. * Returns error status for any failure
  1305. **/
  1306. static s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
  1307. ixgbe_link_speed speed,
  1308. bool autoneg_wait)
  1309. {
  1310. s32 status;
  1311. ixgbe_link_speed force_speed;
  1312. /* Setup internal/external PHY link speed to iXFI (10G), unless
  1313. * only 1G is auto advertised then setup KX link.
  1314. */
  1315. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  1316. force_speed = IXGBE_LINK_SPEED_10GB_FULL;
  1317. else
  1318. force_speed = IXGBE_LINK_SPEED_1GB_FULL;
  1319. /* If internal link mode is XFI, then setup XFI internal link. */
  1320. if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
  1321. status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
  1322. if (status)
  1323. return status;
  1324. }
  1325. return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
  1326. }
  1327. /** ixgbe_check_link_t_X550em - Determine link and speed status
  1328. * @hw: pointer to hardware structure
  1329. * @speed: pointer to link speed
  1330. * @link_up: true when link is up
  1331. * @link_up_wait_to_complete: bool used to wait for link up or not
  1332. *
  1333. * Check that both the MAC and X557 external PHY have link.
  1334. **/
  1335. static s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw,
  1336. ixgbe_link_speed *speed,
  1337. bool *link_up,
  1338. bool link_up_wait_to_complete)
  1339. {
  1340. u32 status;
  1341. u16 autoneg_status;
  1342. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
  1343. return IXGBE_ERR_CONFIG;
  1344. status = ixgbe_check_mac_link_generic(hw, speed, link_up,
  1345. link_up_wait_to_complete);
  1346. /* If check link fails or MAC link is not up, then return */
  1347. if (status || !(*link_up))
  1348. return status;
  1349. /* MAC link is up, so check external PHY link.
  1350. * Read this twice back to back to indicate current status.
  1351. */
  1352. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
  1353. IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  1354. &autoneg_status);
  1355. if (status)
  1356. return status;
  1357. /* If external PHY link is not up, then indicate link not up */
  1358. if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
  1359. *link_up = false;
  1360. return 0;
  1361. }
  1362. /**
  1363. * ixgbe_setup_sgmii - Set up link for sgmii
  1364. * @hw: pointer to hardware structure
  1365. */
  1366. static s32
  1367. ixgbe_setup_sgmii(struct ixgbe_hw *hw, __always_unused ixgbe_link_speed speed,
  1368. __always_unused bool autoneg_wait_to_complete)
  1369. {
  1370. struct ixgbe_mac_info *mac = &hw->mac;
  1371. u32 lval, sval;
  1372. s32 rc;
  1373. rc = mac->ops.read_iosf_sb_reg(hw,
  1374. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1375. IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
  1376. if (rc)
  1377. return rc;
  1378. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  1379. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
  1380. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
  1381. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
  1382. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
  1383. rc = mac->ops.write_iosf_sb_reg(hw,
  1384. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1385. IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
  1386. if (rc)
  1387. return rc;
  1388. rc = mac->ops.read_iosf_sb_reg(hw,
  1389. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1390. IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
  1391. if (rc)
  1392. return rc;
  1393. sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
  1394. sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
  1395. rc = mac->ops.write_iosf_sb_reg(hw,
  1396. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1397. IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
  1398. if (rc)
  1399. return rc;
  1400. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
  1401. rc = mac->ops.write_iosf_sb_reg(hw,
  1402. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1403. IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
  1404. return rc;
  1405. }
  1406. /** ixgbe_init_mac_link_ops_X550em - init mac link function pointers
  1407. * @hw: pointer to hardware structure
  1408. **/
  1409. static void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
  1410. {
  1411. struct ixgbe_mac_info *mac = &hw->mac;
  1412. mac->ops.setup_fc = ixgbe_setup_fc_x550em;
  1413. switch (mac->ops.get_media_type(hw)) {
  1414. case ixgbe_media_type_fiber:
  1415. /* CS4227 does not support autoneg, so disable the laser control
  1416. * functions for SFP+ fiber
  1417. */
  1418. mac->ops.disable_tx_laser = NULL;
  1419. mac->ops.enable_tx_laser = NULL;
  1420. mac->ops.flap_tx_laser = NULL;
  1421. mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
  1422. switch (hw->device_id) {
  1423. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  1424. mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_n;
  1425. break;
  1426. case IXGBE_DEV_ID_X550EM_A_SFP:
  1427. mac->ops.setup_mac_link =
  1428. ixgbe_setup_mac_link_sfp_x550a;
  1429. break;
  1430. default:
  1431. mac->ops.setup_mac_link =
  1432. ixgbe_setup_mac_link_sfp_x550em;
  1433. break;
  1434. }
  1435. mac->ops.set_rate_select_speed =
  1436. ixgbe_set_soft_rate_select_speed;
  1437. break;
  1438. case ixgbe_media_type_copper:
  1439. mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
  1440. mac->ops.setup_fc = ixgbe_setup_fc_generic;
  1441. mac->ops.check_link = ixgbe_check_link_t_X550em;
  1442. return;
  1443. case ixgbe_media_type_backplane:
  1444. if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
  1445. hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
  1446. mac->ops.setup_link = ixgbe_setup_sgmii;
  1447. break;
  1448. default:
  1449. break;
  1450. }
  1451. }
  1452. /** ixgbe_setup_sfp_modules_X550em - Setup SFP module
  1453. * @hw: pointer to hardware structure
  1454. */
  1455. static s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
  1456. {
  1457. s32 status;
  1458. bool linear;
  1459. /* Check if SFP module is supported */
  1460. status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
  1461. if (status)
  1462. return status;
  1463. ixgbe_init_mac_link_ops_X550em(hw);
  1464. hw->phy.ops.reset = NULL;
  1465. return 0;
  1466. }
  1467. /** ixgbe_get_link_capabilities_x550em - Determines link capabilities
  1468. * @hw: pointer to hardware structure
  1469. * @speed: pointer to link speed
  1470. * @autoneg: true when autoneg or autotry is enabled
  1471. **/
  1472. static s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
  1473. ixgbe_link_speed *speed,
  1474. bool *autoneg)
  1475. {
  1476. /* SFP */
  1477. if (hw->phy.media_type == ixgbe_media_type_fiber) {
  1478. /* CS4227 SFP must not enable auto-negotiation */
  1479. *autoneg = false;
  1480. if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
  1481. hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
  1482. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1483. return 0;
  1484. }
  1485. /* Link capabilities are based on SFP */
  1486. if (hw->phy.multispeed_fiber)
  1487. *speed = IXGBE_LINK_SPEED_10GB_FULL |
  1488. IXGBE_LINK_SPEED_1GB_FULL;
  1489. else
  1490. *speed = IXGBE_LINK_SPEED_10GB_FULL;
  1491. } else {
  1492. *speed = IXGBE_LINK_SPEED_10GB_FULL |
  1493. IXGBE_LINK_SPEED_1GB_FULL;
  1494. *autoneg = true;
  1495. }
  1496. return 0;
  1497. }
  1498. /**
  1499. * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
  1500. * @hw: pointer to hardware structure
  1501. * @lsc: pointer to boolean flag which indicates whether external Base T
  1502. * PHY interrupt is lsc
  1503. *
  1504. * Determime if external Base T PHY interrupt cause is high temperature
  1505. * failure alarm or link status change.
  1506. *
  1507. * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  1508. * failure alarm, else return PHY access status.
  1509. **/
  1510. static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
  1511. {
  1512. u32 status;
  1513. u16 reg;
  1514. *lsc = false;
  1515. /* Vendor alarm triggered */
  1516. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
  1517. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1518. &reg);
  1519. if (status || !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
  1520. return status;
  1521. /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
  1522. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
  1523. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1524. &reg);
  1525. if (status || !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
  1526. IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
  1527. return status;
  1528. /* Global alarm triggered */
  1529. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
  1530. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1531. &reg);
  1532. if (status)
  1533. return status;
  1534. /* If high temperature failure, then return over temp error and exit */
  1535. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
  1536. /* power down the PHY in case the PHY FW didn't already */
  1537. ixgbe_set_copper_phy_power(hw, false);
  1538. return IXGBE_ERR_OVERTEMP;
  1539. }
  1540. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
  1541. /* device fault alarm triggered */
  1542. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
  1543. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1544. &reg);
  1545. if (status)
  1546. return status;
  1547. /* if device fault was due to high temp alarm handle and exit */
  1548. if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
  1549. /* power down the PHY in case the PHY FW didn't */
  1550. ixgbe_set_copper_phy_power(hw, false);
  1551. return IXGBE_ERR_OVERTEMP;
  1552. }
  1553. }
  1554. /* Vendor alarm 2 triggered */
  1555. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
  1556. IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &reg);
  1557. if (status || !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
  1558. return status;
  1559. /* link connect/disconnect event occurred */
  1560. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
  1561. IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &reg);
  1562. if (status)
  1563. return status;
  1564. /* Indicate LSC */
  1565. if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
  1566. *lsc = true;
  1567. return 0;
  1568. }
  1569. /**
  1570. * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
  1571. * @hw: pointer to hardware structure
  1572. *
  1573. * Enable link status change and temperature failure alarm for the external
  1574. * Base T PHY
  1575. *
  1576. * Returns PHY access status
  1577. **/
  1578. static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  1579. {
  1580. u32 status;
  1581. u16 reg;
  1582. bool lsc;
  1583. /* Clear interrupt flags */
  1584. status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  1585. /* Enable link status change alarm */
  1586. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
  1587. IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &reg);
  1588. if (status)
  1589. return status;
  1590. reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
  1591. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
  1592. IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
  1593. if (status)
  1594. return status;
  1595. /* Enable high temperature failure and global fault alarms */
  1596. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
  1597. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1598. &reg);
  1599. if (status)
  1600. return status;
  1601. reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
  1602. IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
  1603. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
  1604. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1605. reg);
  1606. if (status)
  1607. return status;
  1608. /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
  1609. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
  1610. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1611. &reg);
  1612. if (status)
  1613. return status;
  1614. reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
  1615. IXGBE_MDIO_GLOBAL_ALARM_1_INT);
  1616. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
  1617. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1618. reg);
  1619. if (status)
  1620. return status;
  1621. /* Enable chip-wide vendor alarm */
  1622. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
  1623. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1624. &reg);
  1625. if (status)
  1626. return status;
  1627. reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
  1628. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
  1629. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  1630. reg);
  1631. return status;
  1632. }
  1633. /**
  1634. * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
  1635. * @hw: pointer to hardware structure
  1636. *
  1637. * Handle external Base T PHY interrupt. If high temperature
  1638. * failure alarm then return error, else if link status change
  1639. * then setup internal/external PHY link
  1640. *
  1641. * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  1642. * failure alarm, else return PHY access status.
  1643. **/
  1644. static s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  1645. {
  1646. struct ixgbe_phy_info *phy = &hw->phy;
  1647. bool lsc;
  1648. u32 status;
  1649. status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  1650. if (status)
  1651. return status;
  1652. if (lsc && phy->ops.setup_internal_link)
  1653. return phy->ops.setup_internal_link(hw);
  1654. return 0;
  1655. }
  1656. /**
  1657. * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
  1658. * @hw: pointer to hardware structure
  1659. * @speed: link speed
  1660. *
  1661. * Configures the integrated KR PHY.
  1662. **/
  1663. static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
  1664. ixgbe_link_speed speed)
  1665. {
  1666. s32 status;
  1667. u32 reg_val;
  1668. status = hw->mac.ops.read_iosf_sb_reg(hw,
  1669. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1670. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1671. if (status)
  1672. return status;
  1673. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  1674. reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
  1675. IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
  1676. /* Advertise 10G support. */
  1677. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  1678. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
  1679. /* Advertise 1G support. */
  1680. if (speed & IXGBE_LINK_SPEED_1GB_FULL)
  1681. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
  1682. /* Restart auto-negotiation. */
  1683. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
  1684. status = hw->mac.ops.write_iosf_sb_reg(hw,
  1685. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1686. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1687. return status;
  1688. }
  1689. /** ixgbe_setup_kx4_x550em - Configure the KX4 PHY.
  1690. * @hw: pointer to hardware structure
  1691. *
  1692. * Configures the integrated KX4 PHY.
  1693. **/
  1694. static s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
  1695. {
  1696. s32 status;
  1697. u32 reg_val;
  1698. status = hw->mac.ops.read_iosf_sb_reg(hw, IXGBE_KX4_LINK_CNTL_1,
  1699. IXGBE_SB_IOSF_TARGET_KX4_PCS0 +
  1700. hw->bus.lan_id, &reg_val);
  1701. if (status)
  1702. return status;
  1703. reg_val &= ~(IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4 |
  1704. IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX);
  1705. reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE;
  1706. /* Advertise 10G support. */
  1707. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
  1708. reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4;
  1709. /* Advertise 1G support. */
  1710. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
  1711. reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX;
  1712. /* Restart auto-negotiation. */
  1713. reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART;
  1714. status = hw->mac.ops.write_iosf_sb_reg(hw, IXGBE_KX4_LINK_CNTL_1,
  1715. IXGBE_SB_IOSF_TARGET_KX4_PCS0 +
  1716. hw->bus.lan_id, reg_val);
  1717. return status;
  1718. }
  1719. /**
  1720. * ixgbe_setup_kr_x550em - Configure the KR PHY
  1721. * @hw: pointer to hardware structure
  1722. **/
  1723. static s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
  1724. {
  1725. /* leave link alone for 2.5G */
  1726. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
  1727. return 0;
  1728. return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
  1729. }
  1730. /** ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
  1731. * @hw: address of hardware structure
  1732. * @link_up: address of boolean to indicate link status
  1733. *
  1734. * Returns error code if unable to get link status.
  1735. **/
  1736. static s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
  1737. {
  1738. u32 ret;
  1739. u16 autoneg_status;
  1740. *link_up = false;
  1741. /* read this twice back to back to indicate current status */
  1742. ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
  1743. IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  1744. &autoneg_status);
  1745. if (ret)
  1746. return ret;
  1747. ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
  1748. IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  1749. &autoneg_status);
  1750. if (ret)
  1751. return ret;
  1752. *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
  1753. return 0;
  1754. }
  1755. /** ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
  1756. * @hw: point to hardware structure
  1757. *
  1758. * Configures the link between the integrated KR PHY and the external X557 PHY
  1759. * The driver will call this function when it gets a link status change
  1760. * interrupt from the X557 PHY. This function configures the link speed
  1761. * between the PHYs to match the link speed of the BASE-T link.
  1762. *
  1763. * A return of a non-zero value indicates an error, and the base driver should
  1764. * not report link up.
  1765. **/
  1766. static s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
  1767. {
  1768. ixgbe_link_speed force_speed;
  1769. bool link_up;
  1770. u32 status;
  1771. u16 speed;
  1772. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
  1773. return IXGBE_ERR_CONFIG;
  1774. if (hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE) {
  1775. speed = IXGBE_LINK_SPEED_10GB_FULL |
  1776. IXGBE_LINK_SPEED_1GB_FULL;
  1777. return ixgbe_setup_kr_speed_x550em(hw, speed);
  1778. }
  1779. /* If link is not up, then there is no setup necessary so return */
  1780. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  1781. if (status)
  1782. return status;
  1783. if (!link_up)
  1784. return 0;
  1785. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
  1786. IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  1787. &speed);
  1788. if (status)
  1789. return status;
  1790. /* If link is not still up, then no setup is necessary so return */
  1791. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  1792. if (status)
  1793. return status;
  1794. if (!link_up)
  1795. return 0;
  1796. /* clear everything but the speed and duplex bits */
  1797. speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
  1798. switch (speed) {
  1799. case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
  1800. force_speed = IXGBE_LINK_SPEED_10GB_FULL;
  1801. break;
  1802. case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
  1803. force_speed = IXGBE_LINK_SPEED_1GB_FULL;
  1804. break;
  1805. default:
  1806. /* Internal PHY does not support anything else */
  1807. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  1808. }
  1809. return ixgbe_setup_ixfi_x550em(hw, &force_speed);
  1810. }
  1811. /** ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
  1812. * @hw: pointer to hardware structure
  1813. **/
  1814. static s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
  1815. {
  1816. s32 status;
  1817. status = ixgbe_reset_phy_generic(hw);
  1818. if (status)
  1819. return status;
  1820. /* Configure Link Status Alarm and Temperature Threshold interrupts */
  1821. return ixgbe_enable_lasi_ext_t_x550em(hw);
  1822. }
  1823. /**
  1824. * ixgbe_led_on_t_x550em - Turns on the software controllable LEDs.
  1825. * @hw: pointer to hardware structure
  1826. * @led_idx: led number to turn on
  1827. **/
  1828. static s32 ixgbe_led_on_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
  1829. {
  1830. u16 phy_data;
  1831. if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
  1832. return IXGBE_ERR_PARAM;
  1833. /* To turn on the LED, set mode to ON. */
  1834. hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  1835. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
  1836. phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
  1837. hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  1838. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
  1839. return 0;
  1840. }
  1841. /**
  1842. * ixgbe_led_off_t_x550em - Turns off the software controllable LEDs.
  1843. * @hw: pointer to hardware structure
  1844. * @led_idx: led number to turn off
  1845. **/
  1846. static s32 ixgbe_led_off_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
  1847. {
  1848. u16 phy_data;
  1849. if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
  1850. return IXGBE_ERR_PARAM;
  1851. /* To turn on the LED, set mode to ON. */
  1852. hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  1853. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
  1854. phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
  1855. hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  1856. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
  1857. return 0;
  1858. }
  1859. /** ixgbe_get_lcd_x550em - Determine lowest common denominator
  1860. * @hw: pointer to hardware structure
  1861. * @lcd_speed: pointer to lowest common link speed
  1862. *
  1863. * Determine lowest common link speed with link partner.
  1864. **/
  1865. static s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw,
  1866. ixgbe_link_speed *lcd_speed)
  1867. {
  1868. u16 an_lp_status;
  1869. s32 status;
  1870. u16 word = hw->eeprom.ctrl_word_3;
  1871. *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
  1872. status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
  1873. IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  1874. &an_lp_status);
  1875. if (status)
  1876. return status;
  1877. /* If link partner advertised 1G, return 1G */
  1878. if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
  1879. *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
  1880. return status;
  1881. }
  1882. /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
  1883. if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
  1884. (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
  1885. return status;
  1886. /* Link partner not capable of lower speeds, return 10G */
  1887. *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
  1888. return status;
  1889. }
  1890. /**
  1891. * ixgbe_setup_fc_x550em - Set up flow control
  1892. * @hw: pointer to hardware structure
  1893. */
  1894. static s32 ixgbe_setup_fc_x550em(struct ixgbe_hw *hw)
  1895. {
  1896. bool pause, asm_dir;
  1897. u32 reg_val;
  1898. s32 rc;
  1899. /* Validate the requested mode */
  1900. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  1901. hw_err(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
  1902. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  1903. }
  1904. /* 10gig parts do not have a word in the EEPROM to determine the
  1905. * default flow control setting, so we explicitly set it to full.
  1906. */
  1907. if (hw->fc.requested_mode == ixgbe_fc_default)
  1908. hw->fc.requested_mode = ixgbe_fc_full;
  1909. /* Determine PAUSE and ASM_DIR bits. */
  1910. switch (hw->fc.requested_mode) {
  1911. case ixgbe_fc_none:
  1912. pause = false;
  1913. asm_dir = false;
  1914. break;
  1915. case ixgbe_fc_tx_pause:
  1916. pause = false;
  1917. asm_dir = true;
  1918. break;
  1919. case ixgbe_fc_rx_pause:
  1920. /* Rx Flow control is enabled and Tx Flow control is
  1921. * disabled by software override. Since there really
  1922. * isn't a way to advertise that we are capable of RX
  1923. * Pause ONLY, we will advertise that we support both
  1924. * symmetric and asymmetric Rx PAUSE, as such we fall
  1925. * through to the fc_full statement. Later, we will
  1926. * disable the adapter's ability to send PAUSE frames.
  1927. */
  1928. /* Fallthrough */
  1929. case ixgbe_fc_full:
  1930. pause = true;
  1931. asm_dir = true;
  1932. break;
  1933. default:
  1934. hw_err(hw, "Flow control param set incorrectly\n");
  1935. return IXGBE_ERR_CONFIG;
  1936. }
  1937. if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR &&
  1938. hw->device_id != IXGBE_DEV_ID_X550EM_A_KR &&
  1939. hw->device_id != IXGBE_DEV_ID_X550EM_A_KR_L)
  1940. return 0;
  1941. rc = hw->mac.ops.read_iosf_sb_reg(hw,
  1942. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  1943. IXGBE_SB_IOSF_TARGET_KR_PHY,
  1944. &reg_val);
  1945. if (rc)
  1946. return rc;
  1947. reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  1948. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
  1949. if (pause)
  1950. reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
  1951. if (asm_dir)
  1952. reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  1953. rc = hw->mac.ops.write_iosf_sb_reg(hw,
  1954. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  1955. IXGBE_SB_IOSF_TARGET_KR_PHY,
  1956. reg_val);
  1957. /* This device does not fully support AN. */
  1958. hw->fc.disable_fc_autoneg = true;
  1959. return rc;
  1960. }
  1961. /** ixgbe_enter_lplu_x550em - Transition to low power states
  1962. * @hw: pointer to hardware structure
  1963. *
  1964. * Configures Low Power Link Up on transition to low power states
  1965. * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting
  1966. * the X557 PHY immediately prior to entering LPLU.
  1967. **/
  1968. static s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
  1969. {
  1970. u16 an_10g_cntl_reg, autoneg_reg, speed;
  1971. s32 status;
  1972. ixgbe_link_speed lcd_speed;
  1973. u32 save_autoneg;
  1974. bool link_up;
  1975. /* If blocked by MNG FW, then don't restart AN */
  1976. if (ixgbe_check_reset_blocked(hw))
  1977. return 0;
  1978. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  1979. if (status)
  1980. return status;
  1981. status = hw->eeprom.ops.read(hw, NVM_INIT_CTRL_3,
  1982. &hw->eeprom.ctrl_word_3);
  1983. if (status)
  1984. return status;
  1985. /* If link is down, LPLU disabled in NVM, WoL disabled, or
  1986. * manageability disabled, then force link down by entering
  1987. * low power mode.
  1988. */
  1989. if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
  1990. !(hw->wol_enabled || ixgbe_mng_present(hw)))
  1991. return ixgbe_set_copper_phy_power(hw, false);
  1992. /* Determine LCD */
  1993. status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
  1994. if (status)
  1995. return status;
  1996. /* If no valid LCD link speed, then force link down and exit. */
  1997. if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
  1998. return ixgbe_set_copper_phy_power(hw, false);
  1999. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
  2000. IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  2001. &speed);
  2002. if (status)
  2003. return status;
  2004. /* If no link now, speed is invalid so take link down */
  2005. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2006. if (status)
  2007. return ixgbe_set_copper_phy_power(hw, false);
  2008. /* clear everything but the speed bits */
  2009. speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
  2010. /* If current speed is already LCD, then exit. */
  2011. if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
  2012. (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
  2013. ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
  2014. (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
  2015. return status;
  2016. /* Clear AN completed indication */
  2017. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
  2018. IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  2019. &autoneg_reg);
  2020. if (status)
  2021. return status;
  2022. status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
  2023. IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  2024. &an_10g_cntl_reg);
  2025. if (status)
  2026. return status;
  2027. status = hw->phy.ops.read_reg(hw,
  2028. IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
  2029. IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  2030. &autoneg_reg);
  2031. if (status)
  2032. return status;
  2033. save_autoneg = hw->phy.autoneg_advertised;
  2034. /* Setup link at least common link speed */
  2035. status = hw->mac.ops.setup_link(hw, lcd_speed, false);
  2036. /* restore autoneg from before setting lplu speed */
  2037. hw->phy.autoneg_advertised = save_autoneg;
  2038. return status;
  2039. }
  2040. /**
  2041. * ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
  2042. * @hw: pointer to hardware structure
  2043. *
  2044. * Read NW_MNG_IF_SEL register and save field values.
  2045. */
  2046. static void ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
  2047. {
  2048. /* Save NW management interface connected on board. This is used
  2049. * to determine internal PHY mode.
  2050. */
  2051. hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
  2052. /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
  2053. * PHY address. This register field was has only been used for X552.
  2054. */
  2055. if (hw->mac.type == ixgbe_mac_x550em_a &&
  2056. hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
  2057. hw->phy.mdio.prtad = (hw->phy.nw_mng_if_sel &
  2058. IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
  2059. IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
  2060. }
  2061. }
  2062. /** ixgbe_init_phy_ops_X550em - PHY/SFP specific init
  2063. * @hw: pointer to hardware structure
  2064. *
  2065. * Initialize any function pointers that were not able to be
  2066. * set during init_shared_code because the PHY/SFP type was
  2067. * not known. Perform the SFP init if necessary.
  2068. **/
  2069. static s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
  2070. {
  2071. struct ixgbe_phy_info *phy = &hw->phy;
  2072. s32 ret_val;
  2073. hw->mac.ops.set_lan_id(hw);
  2074. ixgbe_read_mng_if_sel_x550em(hw);
  2075. if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
  2076. phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
  2077. ixgbe_setup_mux_ctl(hw);
  2078. }
  2079. /* Identify the PHY or SFP module */
  2080. ret_val = phy->ops.identify(hw);
  2081. /* Setup function pointers based on detected hardware */
  2082. ixgbe_init_mac_link_ops_X550em(hw);
  2083. if (phy->sfp_type != ixgbe_sfp_type_unknown)
  2084. phy->ops.reset = NULL;
  2085. /* Set functions pointers based on phy type */
  2086. switch (hw->phy.type) {
  2087. case ixgbe_phy_x550em_kx4:
  2088. phy->ops.setup_link = ixgbe_setup_kx4_x550em;
  2089. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2090. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2091. break;
  2092. case ixgbe_phy_x550em_kr:
  2093. phy->ops.setup_link = ixgbe_setup_kr_x550em;
  2094. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2095. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2096. break;
  2097. case ixgbe_phy_x550em_ext_t:
  2098. /* Save NW management interface connected on board. This is used
  2099. * to determine internal PHY mode
  2100. */
  2101. phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
  2102. /* If internal link mode is XFI, then setup iXFI internal link,
  2103. * else setup KR now.
  2104. */
  2105. phy->ops.setup_internal_link =
  2106. ixgbe_setup_internal_phy_t_x550em;
  2107. /* setup SW LPLU only for first revision */
  2108. if (hw->mac.type == ixgbe_mac_X550EM_x &&
  2109. !(IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0)) &
  2110. IXGBE_FUSES0_REV_MASK))
  2111. phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
  2112. phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
  2113. phy->ops.reset = ixgbe_reset_phy_t_X550em;
  2114. break;
  2115. default:
  2116. break;
  2117. }
  2118. return ret_val;
  2119. }
  2120. /** ixgbe_get_media_type_X550em - Get media type
  2121. * @hw: pointer to hardware structure
  2122. *
  2123. * Returns the media type (fiber, copper, backplane)
  2124. *
  2125. */
  2126. static enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
  2127. {
  2128. enum ixgbe_media_type media_type;
  2129. /* Detect if there is a copper PHY attached. */
  2130. switch (hw->device_id) {
  2131. case IXGBE_DEV_ID_X550EM_A_SGMII:
  2132. case IXGBE_DEV_ID_X550EM_A_SGMII_L:
  2133. hw->phy.type = ixgbe_phy_sgmii;
  2134. /* Fallthrough */
  2135. case IXGBE_DEV_ID_X550EM_X_KR:
  2136. case IXGBE_DEV_ID_X550EM_X_KX4:
  2137. case IXGBE_DEV_ID_X550EM_A_KR:
  2138. case IXGBE_DEV_ID_X550EM_A_KR_L:
  2139. media_type = ixgbe_media_type_backplane;
  2140. break;
  2141. case IXGBE_DEV_ID_X550EM_X_SFP:
  2142. case IXGBE_DEV_ID_X550EM_A_SFP:
  2143. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  2144. media_type = ixgbe_media_type_fiber;
  2145. break;
  2146. case IXGBE_DEV_ID_X550EM_X_1G_T:
  2147. case IXGBE_DEV_ID_X550EM_X_10G_T:
  2148. case IXGBE_DEV_ID_X550EM_A_10G_T:
  2149. media_type = ixgbe_media_type_copper;
  2150. break;
  2151. default:
  2152. media_type = ixgbe_media_type_unknown;
  2153. break;
  2154. }
  2155. return media_type;
  2156. }
  2157. /** ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
  2158. ** @hw: pointer to hardware structure
  2159. **/
  2160. static s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
  2161. {
  2162. s32 status;
  2163. u16 reg;
  2164. status = hw->phy.ops.read_reg(hw,
  2165. IXGBE_MDIO_TX_VENDOR_ALARMS_3,
  2166. IXGBE_MDIO_PMA_PMD_DEV_TYPE,
  2167. &reg);
  2168. if (status)
  2169. return status;
  2170. /* If PHY FW reset completed bit is set then this is the first
  2171. * SW instance after a power on so the PHY FW must be un-stalled.
  2172. */
  2173. if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
  2174. status = hw->phy.ops.read_reg(hw,
  2175. IXGBE_MDIO_GLOBAL_RES_PR_10,
  2176. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  2177. &reg);
  2178. if (status)
  2179. return status;
  2180. reg &= ~IXGBE_MDIO_POWER_UP_STALL;
  2181. status = hw->phy.ops.write_reg(hw,
  2182. IXGBE_MDIO_GLOBAL_RES_PR_10,
  2183. IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
  2184. reg);
  2185. if (status)
  2186. return status;
  2187. }
  2188. return status;
  2189. }
  2190. /**
  2191. * ixgbe_set_mdio_speed - Set MDIO clock speed
  2192. * @hw: pointer to hardware structure
  2193. */
  2194. static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
  2195. {
  2196. u32 hlreg0;
  2197. switch (hw->device_id) {
  2198. case IXGBE_DEV_ID_X550EM_X_10G_T:
  2199. case IXGBE_DEV_ID_X550EM_A_SGMII:
  2200. case IXGBE_DEV_ID_X550EM_A_SGMII_L:
  2201. case IXGBE_DEV_ID_X550EM_A_10G_T:
  2202. case IXGBE_DEV_ID_X550EM_A_SFP:
  2203. /* Config MDIO clock speed before the first MDIO PHY access */
  2204. hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
  2205. hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
  2206. IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
  2207. break;
  2208. default:
  2209. break;
  2210. }
  2211. }
  2212. /** ixgbe_reset_hw_X550em - Perform hardware reset
  2213. ** @hw: pointer to hardware structure
  2214. **
  2215. ** Resets the hardware by resetting the transmit and receive units, masks
  2216. ** and clears all interrupts, perform a PHY reset, and perform a link (MAC)
  2217. ** reset.
  2218. **/
  2219. static s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
  2220. {
  2221. ixgbe_link_speed link_speed;
  2222. s32 status;
  2223. u32 ctrl = 0;
  2224. u32 i;
  2225. bool link_up = false;
  2226. /* Call adapter stop to disable Tx/Rx and clear interrupts */
  2227. status = hw->mac.ops.stop_adapter(hw);
  2228. if (status)
  2229. return status;
  2230. /* flush pending Tx transactions */
  2231. ixgbe_clear_tx_pending(hw);
  2232. /* PHY ops must be identified and initialized prior to reset */
  2233. /* Identify PHY and related function pointers */
  2234. status = hw->phy.ops.init(hw);
  2235. /* start the external PHY */
  2236. if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
  2237. status = ixgbe_init_ext_t_x550em(hw);
  2238. if (status)
  2239. return status;
  2240. }
  2241. /* Setup SFP module if there is one present. */
  2242. if (hw->phy.sfp_setup_needed) {
  2243. status = hw->mac.ops.setup_sfp(hw);
  2244. hw->phy.sfp_setup_needed = false;
  2245. }
  2246. /* Reset PHY */
  2247. if (!hw->phy.reset_disable && hw->phy.ops.reset)
  2248. hw->phy.ops.reset(hw);
  2249. mac_reset_top:
  2250. /* Issue global reset to the MAC. Needs to be SW reset if link is up.
  2251. * If link reset is used when link is up, it might reset the PHY when
  2252. * mng is using it. If link is down or the flag to force full link
  2253. * reset is set, then perform link reset.
  2254. */
  2255. ctrl = IXGBE_CTRL_LNK_RST;
  2256. if (!hw->force_full_reset) {
  2257. hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
  2258. if (link_up)
  2259. ctrl = IXGBE_CTRL_RST;
  2260. }
  2261. ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
  2262. IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
  2263. IXGBE_WRITE_FLUSH(hw);
  2264. usleep_range(1000, 1200);
  2265. /* Poll for reset bit to self-clear meaning reset is complete */
  2266. for (i = 0; i < 10; i++) {
  2267. ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
  2268. if (!(ctrl & IXGBE_CTRL_RST_MASK))
  2269. break;
  2270. udelay(1);
  2271. }
  2272. if (ctrl & IXGBE_CTRL_RST_MASK) {
  2273. status = IXGBE_ERR_RESET_FAILED;
  2274. hw_dbg(hw, "Reset polling failed to complete.\n");
  2275. }
  2276. msleep(50);
  2277. /* Double resets are required for recovery from certain error
  2278. * clear the multicast table. Also reset num_rar_entries to 128,
  2279. * since we modify this value when programming the SAN MAC address.
  2280. */
  2281. if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
  2282. hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
  2283. goto mac_reset_top;
  2284. }
  2285. /* Store the permanent mac address */
  2286. hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
  2287. /* Store MAC address from RAR0, clear receive address registers, and
  2288. * clear the multicast table. Also reset num_rar_entries to 128,
  2289. * since we modify this value when programming the SAN MAC address.
  2290. */
  2291. hw->mac.num_rar_entries = 128;
  2292. hw->mac.ops.init_rx_addrs(hw);
  2293. ixgbe_set_mdio_speed(hw);
  2294. if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
  2295. ixgbe_setup_mux_ctl(hw);
  2296. return status;
  2297. }
  2298. /** ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype
  2299. * anti-spoofing
  2300. * @hw: pointer to hardware structure
  2301. * @enable: enable or disable switch for Ethertype anti-spoofing
  2302. * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
  2303. **/
  2304. static void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
  2305. bool enable, int vf)
  2306. {
  2307. int vf_target_reg = vf >> 3;
  2308. int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
  2309. u32 pfvfspoof;
  2310. pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
  2311. if (enable)
  2312. pfvfspoof |= BIT(vf_target_shift);
  2313. else
  2314. pfvfspoof &= ~BIT(vf_target_shift);
  2315. IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
  2316. }
  2317. /** ixgbe_set_source_address_pruning_X550 - Enable/Disbale src address pruning
  2318. * @hw: pointer to hardware structure
  2319. * @enable: enable or disable source address pruning
  2320. * @pool: Rx pool to set source address pruning for
  2321. **/
  2322. static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,
  2323. bool enable,
  2324. unsigned int pool)
  2325. {
  2326. u64 pfflp;
  2327. /* max rx pool is 63 */
  2328. if (pool > 63)
  2329. return;
  2330. pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
  2331. pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
  2332. if (enable)
  2333. pfflp |= (1ULL << pool);
  2334. else
  2335. pfflp &= ~(1ULL << pool);
  2336. IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
  2337. IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
  2338. }
  2339. /**
  2340. * ixgbe_set_mux - Set mux for port 1 access with CS4227
  2341. * @hw: pointer to hardware structure
  2342. * @state: set mux if 1, clear if 0
  2343. */
  2344. static void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
  2345. {
  2346. u32 esdp;
  2347. if (!hw->bus.lan_id)
  2348. return;
  2349. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  2350. if (state)
  2351. esdp |= IXGBE_ESDP_SDP1;
  2352. else
  2353. esdp &= ~IXGBE_ESDP_SDP1;
  2354. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  2355. IXGBE_WRITE_FLUSH(hw);
  2356. }
  2357. /**
  2358. * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
  2359. * @hw: pointer to hardware structure
  2360. * @mask: Mask to specify which semaphore to acquire
  2361. *
  2362. * Acquires the SWFW semaphore and sets the I2C MUX
  2363. */
  2364. static s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
  2365. {
  2366. s32 status;
  2367. status = ixgbe_acquire_swfw_sync_X540(hw, mask);
  2368. if (status)
  2369. return status;
  2370. if (mask & IXGBE_GSSR_I2C_MASK)
  2371. ixgbe_set_mux(hw, 1);
  2372. return 0;
  2373. }
  2374. /**
  2375. * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
  2376. * @hw: pointer to hardware structure
  2377. * @mask: Mask to specify which semaphore to release
  2378. *
  2379. * Releases the SWFW semaphore and sets the I2C MUX
  2380. */
  2381. static void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
  2382. {
  2383. if (mask & IXGBE_GSSR_I2C_MASK)
  2384. ixgbe_set_mux(hw, 0);
  2385. ixgbe_release_swfw_sync_X540(hw, mask);
  2386. }
  2387. /**
  2388. * ixgbe_acquire_swfw_sync_x550em_a - Acquire SWFW semaphore
  2389. * @hw: pointer to hardware structure
  2390. * @mask: Mask to specify which semaphore to acquire
  2391. *
  2392. * Acquires the SWFW semaphore and get the shared PHY token as needed
  2393. */
  2394. static s32 ixgbe_acquire_swfw_sync_x550em_a(struct ixgbe_hw *hw, u32 mask)
  2395. {
  2396. u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
  2397. int retries = FW_PHY_TOKEN_RETRIES;
  2398. s32 status;
  2399. while (--retries) {
  2400. status = 0;
  2401. if (hmask)
  2402. status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
  2403. if (status)
  2404. return status;
  2405. if (!(mask & IXGBE_GSSR_TOKEN_SM))
  2406. return 0;
  2407. status = ixgbe_get_phy_token(hw);
  2408. if (!status)
  2409. return 0;
  2410. if (hmask)
  2411. ixgbe_release_swfw_sync_X540(hw, hmask);
  2412. if (status != IXGBE_ERR_TOKEN_RETRY)
  2413. return status;
  2414. msleep(FW_PHY_TOKEN_DELAY);
  2415. }
  2416. return status;
  2417. }
  2418. /**
  2419. * ixgbe_release_swfw_sync_x550em_a - Release SWFW semaphore
  2420. * @hw: pointer to hardware structure
  2421. * @mask: Mask to specify which semaphore to release
  2422. *
  2423. * Release the SWFW semaphore and puts the shared PHY token as needed
  2424. */
  2425. static void ixgbe_release_swfw_sync_x550em_a(struct ixgbe_hw *hw, u32 mask)
  2426. {
  2427. u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
  2428. if (mask & IXGBE_GSSR_TOKEN_SM)
  2429. ixgbe_put_phy_token(hw);
  2430. if (hmask)
  2431. ixgbe_release_swfw_sync_X540(hw, hmask);
  2432. }
  2433. /**
  2434. * ixgbe_read_phy_reg_x550a - Reads specified PHY register
  2435. * @hw: pointer to hardware structure
  2436. * @reg_addr: 32 bit address of PHY register to read
  2437. * @phy_data: Pointer to read data from PHY register
  2438. *
  2439. * Reads a value from a specified PHY register using the SWFW lock and PHY
  2440. * Token. The PHY Token is needed since the MDIO is shared between to MAC
  2441. * instances.
  2442. */
  2443. static s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  2444. u32 device_type, u16 *phy_data)
  2445. {
  2446. u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
  2447. s32 status;
  2448. if (hw->mac.ops.acquire_swfw_sync(hw, mask))
  2449. return IXGBE_ERR_SWFW_SYNC;
  2450. status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
  2451. hw->mac.ops.release_swfw_sync(hw, mask);
  2452. return status;
  2453. }
  2454. /**
  2455. * ixgbe_write_phy_reg_x550a - Writes specified PHY register
  2456. * @hw: pointer to hardware structure
  2457. * @reg_addr: 32 bit PHY register to write
  2458. * @device_type: 5 bit device type
  2459. * @phy_data: Data to write to the PHY register
  2460. *
  2461. * Writes a value to specified PHY register using the SWFW lock and PHY Token.
  2462. * The PHY Token is needed since the MDIO is shared between to MAC instances.
  2463. */
  2464. static s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  2465. u32 device_type, u16 phy_data)
  2466. {
  2467. u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
  2468. s32 status;
  2469. if (hw->mac.ops.acquire_swfw_sync(hw, mask))
  2470. return IXGBE_ERR_SWFW_SYNC;
  2471. status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type, phy_data);
  2472. hw->mac.ops.release_swfw_sync(hw, mask);
  2473. return status;
  2474. }
  2475. #define X550_COMMON_MAC \
  2476. .init_hw = &ixgbe_init_hw_generic, \
  2477. .start_hw = &ixgbe_start_hw_X540, \
  2478. .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic, \
  2479. .enable_rx_dma = &ixgbe_enable_rx_dma_generic, \
  2480. .get_mac_addr = &ixgbe_get_mac_addr_generic, \
  2481. .get_device_caps = &ixgbe_get_device_caps_generic, \
  2482. .stop_adapter = &ixgbe_stop_adapter_generic, \
  2483. .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie, \
  2484. .read_analog_reg8 = NULL, \
  2485. .write_analog_reg8 = NULL, \
  2486. .set_rxpba = &ixgbe_set_rxpba_generic, \
  2487. .check_link = &ixgbe_check_mac_link_generic, \
  2488. .blink_led_start = &ixgbe_blink_led_start_X540, \
  2489. .blink_led_stop = &ixgbe_blink_led_stop_X540, \
  2490. .set_rar = &ixgbe_set_rar_generic, \
  2491. .clear_rar = &ixgbe_clear_rar_generic, \
  2492. .set_vmdq = &ixgbe_set_vmdq_generic, \
  2493. .set_vmdq_san_mac = &ixgbe_set_vmdq_san_mac_generic, \
  2494. .clear_vmdq = &ixgbe_clear_vmdq_generic, \
  2495. .init_rx_addrs = &ixgbe_init_rx_addrs_generic, \
  2496. .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic, \
  2497. .enable_mc = &ixgbe_enable_mc_generic, \
  2498. .disable_mc = &ixgbe_disable_mc_generic, \
  2499. .clear_vfta = &ixgbe_clear_vfta_generic, \
  2500. .set_vfta = &ixgbe_set_vfta_generic, \
  2501. .fc_enable = &ixgbe_fc_enable_generic, \
  2502. .set_fw_drv_ver = &ixgbe_set_fw_drv_ver_generic, \
  2503. .init_uta_tables = &ixgbe_init_uta_tables_generic, \
  2504. .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing, \
  2505. .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing, \
  2506. .set_source_address_pruning = \
  2507. &ixgbe_set_source_address_pruning_X550, \
  2508. .set_ethertype_anti_spoofing = \
  2509. &ixgbe_set_ethertype_anti_spoofing_X550, \
  2510. .disable_rx_buff = &ixgbe_disable_rx_buff_generic, \
  2511. .enable_rx_buff = &ixgbe_enable_rx_buff_generic, \
  2512. .get_thermal_sensor_data = NULL, \
  2513. .init_thermal_sensor_thresh = NULL, \
  2514. .enable_rx = &ixgbe_enable_rx_generic, \
  2515. .disable_rx = &ixgbe_disable_rx_x550, \
  2516. static const struct ixgbe_mac_operations mac_ops_X550 = {
  2517. X550_COMMON_MAC
  2518. .led_on = ixgbe_led_on_generic,
  2519. .led_off = ixgbe_led_off_generic,
  2520. .reset_hw = &ixgbe_reset_hw_X540,
  2521. .get_media_type = &ixgbe_get_media_type_X540,
  2522. .get_san_mac_addr = &ixgbe_get_san_mac_addr_generic,
  2523. .get_wwn_prefix = &ixgbe_get_wwn_prefix_generic,
  2524. .setup_link = &ixgbe_setup_mac_link_X540,
  2525. .get_link_capabilities = &ixgbe_get_copper_link_capabilities_generic,
  2526. .get_bus_info = &ixgbe_get_bus_info_generic,
  2527. .setup_sfp = NULL,
  2528. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X540,
  2529. .release_swfw_sync = &ixgbe_release_swfw_sync_X540,
  2530. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  2531. .prot_autoc_read = prot_autoc_read_generic,
  2532. .prot_autoc_write = prot_autoc_write_generic,
  2533. .setup_fc = ixgbe_setup_fc_generic,
  2534. };
  2535. static const struct ixgbe_mac_operations mac_ops_X550EM_x = {
  2536. X550_COMMON_MAC
  2537. .led_on = ixgbe_led_on_t_x550em,
  2538. .led_off = ixgbe_led_off_t_x550em,
  2539. .reset_hw = &ixgbe_reset_hw_X550em,
  2540. .get_media_type = &ixgbe_get_media_type_X550em,
  2541. .get_san_mac_addr = NULL,
  2542. .get_wwn_prefix = NULL,
  2543. .setup_link = &ixgbe_setup_mac_link_X540,
  2544. .get_link_capabilities = &ixgbe_get_link_capabilities_X550em,
  2545. .get_bus_info = &ixgbe_get_bus_info_X550em,
  2546. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  2547. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X550em,
  2548. .release_swfw_sync = &ixgbe_release_swfw_sync_X550em,
  2549. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  2550. .setup_fc = NULL, /* defined later */
  2551. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550,
  2552. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550,
  2553. };
  2554. static struct ixgbe_mac_operations mac_ops_x550em_a = {
  2555. X550_COMMON_MAC
  2556. .led_on = ixgbe_led_on_t_x550em,
  2557. .led_off = ixgbe_led_off_t_x550em,
  2558. .reset_hw = ixgbe_reset_hw_X550em,
  2559. .get_media_type = ixgbe_get_media_type_X550em,
  2560. .get_san_mac_addr = NULL,
  2561. .get_wwn_prefix = NULL,
  2562. .setup_link = NULL, /* defined later */
  2563. .get_link_capabilities = ixgbe_get_link_capabilities_X550em,
  2564. .get_bus_info = ixgbe_get_bus_info_X550em,
  2565. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  2566. .acquire_swfw_sync = ixgbe_acquire_swfw_sync_x550em_a,
  2567. .release_swfw_sync = ixgbe_release_swfw_sync_x550em_a,
  2568. .setup_fc = ixgbe_setup_fc_x550em,
  2569. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a,
  2570. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a,
  2571. };
  2572. #define X550_COMMON_EEP \
  2573. .read = &ixgbe_read_ee_hostif_X550, \
  2574. .read_buffer = &ixgbe_read_ee_hostif_buffer_X550, \
  2575. .write = &ixgbe_write_ee_hostif_X550, \
  2576. .write_buffer = &ixgbe_write_ee_hostif_buffer_X550, \
  2577. .validate_checksum = &ixgbe_validate_eeprom_checksum_X550, \
  2578. .update_checksum = &ixgbe_update_eeprom_checksum_X550, \
  2579. .calc_checksum = &ixgbe_calc_eeprom_checksum_X550, \
  2580. static const struct ixgbe_eeprom_operations eeprom_ops_X550 = {
  2581. X550_COMMON_EEP
  2582. .init_params = &ixgbe_init_eeprom_params_X550,
  2583. };
  2584. static const struct ixgbe_eeprom_operations eeprom_ops_X550EM_x = {
  2585. X550_COMMON_EEP
  2586. .init_params = &ixgbe_init_eeprom_params_X540,
  2587. };
  2588. #define X550_COMMON_PHY \
  2589. .identify_sfp = &ixgbe_identify_module_generic, \
  2590. .reset = NULL, \
  2591. .setup_link_speed = &ixgbe_setup_phy_link_speed_generic, \
  2592. .read_i2c_byte = &ixgbe_read_i2c_byte_generic, \
  2593. .write_i2c_byte = &ixgbe_write_i2c_byte_generic, \
  2594. .read_i2c_sff8472 = &ixgbe_read_i2c_sff8472_generic, \
  2595. .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic, \
  2596. .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic, \
  2597. .setup_link = &ixgbe_setup_phy_link_generic, \
  2598. .set_phy_power = NULL, \
  2599. .check_overtemp = &ixgbe_tn_check_overtemp, \
  2600. .get_firmware_version = &ixgbe_get_phy_firmware_version_generic,
  2601. static const struct ixgbe_phy_operations phy_ops_X550 = {
  2602. X550_COMMON_PHY
  2603. .init = NULL,
  2604. .identify = &ixgbe_identify_phy_generic,
  2605. .read_reg = &ixgbe_read_phy_reg_generic,
  2606. .write_reg = &ixgbe_write_phy_reg_generic,
  2607. };
  2608. static const struct ixgbe_phy_operations phy_ops_X550EM_x = {
  2609. X550_COMMON_PHY
  2610. .init = &ixgbe_init_phy_ops_X550em,
  2611. .identify = &ixgbe_identify_phy_x550em,
  2612. .read_reg = &ixgbe_read_phy_reg_generic,
  2613. .write_reg = &ixgbe_write_phy_reg_generic,
  2614. .read_i2c_combined = &ixgbe_read_i2c_combined_generic,
  2615. .write_i2c_combined = &ixgbe_write_i2c_combined_generic,
  2616. .read_i2c_combined_unlocked = &ixgbe_read_i2c_combined_generic_unlocked,
  2617. .write_i2c_combined_unlocked =
  2618. &ixgbe_write_i2c_combined_generic_unlocked,
  2619. };
  2620. static const struct ixgbe_phy_operations phy_ops_x550em_a = {
  2621. X550_COMMON_PHY
  2622. .init = &ixgbe_init_phy_ops_X550em,
  2623. .identify = &ixgbe_identify_phy_x550em,
  2624. .read_reg = &ixgbe_read_phy_reg_x550a,
  2625. .write_reg = &ixgbe_write_phy_reg_x550a,
  2626. .read_reg_mdi = &ixgbe_read_phy_reg_mdi,
  2627. .write_reg_mdi = &ixgbe_write_phy_reg_mdi,
  2628. };
  2629. static const u32 ixgbe_mvals_X550[IXGBE_MVALS_IDX_LIMIT] = {
  2630. IXGBE_MVALS_INIT(X550)
  2631. };
  2632. static const u32 ixgbe_mvals_X550EM_x[IXGBE_MVALS_IDX_LIMIT] = {
  2633. IXGBE_MVALS_INIT(X550EM_x)
  2634. };
  2635. static const u32 ixgbe_mvals_x550em_a[IXGBE_MVALS_IDX_LIMIT] = {
  2636. IXGBE_MVALS_INIT(X550EM_a)
  2637. };
  2638. const struct ixgbe_info ixgbe_X550_info = {
  2639. .mac = ixgbe_mac_X550,
  2640. .get_invariants = &ixgbe_get_invariants_X540,
  2641. .mac_ops = &mac_ops_X550,
  2642. .eeprom_ops = &eeprom_ops_X550,
  2643. .phy_ops = &phy_ops_X550,
  2644. .mbx_ops = &mbx_ops_generic,
  2645. .mvals = ixgbe_mvals_X550,
  2646. };
  2647. const struct ixgbe_info ixgbe_X550EM_x_info = {
  2648. .mac = ixgbe_mac_X550EM_x,
  2649. .get_invariants = &ixgbe_get_invariants_X550_x,
  2650. .mac_ops = &mac_ops_X550EM_x,
  2651. .eeprom_ops = &eeprom_ops_X550EM_x,
  2652. .phy_ops = &phy_ops_X550EM_x,
  2653. .mbx_ops = &mbx_ops_generic,
  2654. .mvals = ixgbe_mvals_X550EM_x,
  2655. };
  2656. const struct ixgbe_info ixgbe_x550em_a_info = {
  2657. .mac = ixgbe_mac_x550em_a,
  2658. .get_invariants = &ixgbe_get_invariants_X550_x,
  2659. .mac_ops = &mac_ops_x550em_a,
  2660. .eeprom_ops = &eeprom_ops_X550EM_x,
  2661. .phy_ops = &phy_ops_x550em_a,
  2662. .mbx_ops = &mbx_ops_generic,
  2663. .mvals = ixgbe_mvals_x550em_a,
  2664. };