ixgbe_x550.c 113 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Copyright(c) 1999 - 2018 Intel Corporation. */
  3. #include "ixgbe_x540.h"
  4. #include "ixgbe_type.h"
  5. #include "ixgbe_common.h"
  6. #include "ixgbe_phy.h"
  7. static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *, ixgbe_link_speed);
  8. static s32 ixgbe_setup_fc_x550em(struct ixgbe_hw *);
  9. static void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *);
  10. static void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *);
  11. static s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *);
  12. static s32 ixgbe_get_invariants_X550_x(struct ixgbe_hw *hw)
  13. {
  14. struct ixgbe_mac_info *mac = &hw->mac;
  15. struct ixgbe_phy_info *phy = &hw->phy;
  16. struct ixgbe_link_info *link = &hw->link;
  17. /* Start with X540 invariants, since so simular */
  18. ixgbe_get_invariants_X540(hw);
  19. if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
  20. phy->ops.set_phy_power = NULL;
  21. link->addr = IXGBE_CS4227;
  22. return 0;
  23. }
  24. static s32 ixgbe_get_invariants_X550_x_fw(struct ixgbe_hw *hw)
  25. {
  26. struct ixgbe_phy_info *phy = &hw->phy;
  27. /* Start with X540 invariants, since so similar */
  28. ixgbe_get_invariants_X540(hw);
  29. phy->ops.set_phy_power = NULL;
  30. return 0;
  31. }
  32. static s32 ixgbe_get_invariants_X550_a(struct ixgbe_hw *hw)
  33. {
  34. struct ixgbe_mac_info *mac = &hw->mac;
  35. struct ixgbe_phy_info *phy = &hw->phy;
  36. /* Start with X540 invariants, since so simular */
  37. ixgbe_get_invariants_X540(hw);
  38. if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
  39. phy->ops.set_phy_power = NULL;
  40. return 0;
  41. }
  42. static s32 ixgbe_get_invariants_X550_a_fw(struct ixgbe_hw *hw)
  43. {
  44. struct ixgbe_phy_info *phy = &hw->phy;
  45. /* Start with X540 invariants, since so similar */
  46. ixgbe_get_invariants_X540(hw);
  47. phy->ops.set_phy_power = NULL;
  48. return 0;
  49. }
  50. /** ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
  51. * @hw: pointer to hardware structure
  52. **/
  53. static void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
  54. {
  55. u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  56. if (hw->bus.lan_id) {
  57. esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
  58. esdp |= IXGBE_ESDP_SDP1_DIR;
  59. }
  60. esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
  61. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  62. IXGBE_WRITE_FLUSH(hw);
  63. }
  64. /**
  65. * ixgbe_read_cs4227 - Read CS4227 register
  66. * @hw: pointer to hardware structure
  67. * @reg: register number to write
  68. * @value: pointer to receive value read
  69. *
  70. * Returns status code
  71. */
  72. static s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
  73. {
  74. return hw->link.ops.read_link_unlocked(hw, hw->link.addr, reg, value);
  75. }
  76. /**
  77. * ixgbe_write_cs4227 - Write CS4227 register
  78. * @hw: pointer to hardware structure
  79. * @reg: register number to write
  80. * @value: value to write to register
  81. *
  82. * Returns status code
  83. */
  84. static s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
  85. {
  86. return hw->link.ops.write_link_unlocked(hw, hw->link.addr, reg, value);
  87. }
  88. /**
  89. * ixgbe_read_pe - Read register from port expander
  90. * @hw: pointer to hardware structure
  91. * @reg: register number to read
  92. * @value: pointer to receive read value
  93. *
  94. * Returns status code
  95. */
  96. static s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
  97. {
  98. s32 status;
  99. status = ixgbe_read_i2c_byte_generic_unlocked(hw, reg, IXGBE_PE, value);
  100. if (status)
  101. hw_err(hw, "port expander access failed with %d\n", status);
  102. return status;
  103. }
  104. /**
  105. * ixgbe_write_pe - Write register to port expander
  106. * @hw: pointer to hardware structure
  107. * @reg: register number to write
  108. * @value: value to write
  109. *
  110. * Returns status code
  111. */
  112. static s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
  113. {
  114. s32 status;
  115. status = ixgbe_write_i2c_byte_generic_unlocked(hw, reg, IXGBE_PE,
  116. value);
  117. if (status)
  118. hw_err(hw, "port expander access failed with %d\n", status);
  119. return status;
  120. }
  121. /**
  122. * ixgbe_reset_cs4227 - Reset CS4227 using port expander
  123. * @hw: pointer to hardware structure
  124. *
  125. * This function assumes that the caller has acquired the proper semaphore.
  126. * Returns error code
  127. */
  128. static s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
  129. {
  130. s32 status;
  131. u32 retry;
  132. u16 value;
  133. u8 reg;
  134. /* Trigger hard reset. */
  135. status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
  136. if (status)
  137. return status;
  138. reg |= IXGBE_PE_BIT1;
  139. status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
  140. if (status)
  141. return status;
  142. status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, &reg);
  143. if (status)
  144. return status;
  145. reg &= ~IXGBE_PE_BIT1;
  146. status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
  147. if (status)
  148. return status;
  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. usleep_range(IXGBE_CS4227_RESET_HOLD, IXGBE_CS4227_RESET_HOLD + 100);
  157. status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
  158. if (status)
  159. return status;
  160. reg |= IXGBE_PE_BIT1;
  161. status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
  162. if (status)
  163. return status;
  164. /* Wait for the reset to complete. */
  165. msleep(IXGBE_CS4227_RESET_DELAY);
  166. for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
  167. status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
  168. &value);
  169. if (!status && value == IXGBE_CS4227_EEPROM_LOAD_OK)
  170. break;
  171. msleep(IXGBE_CS4227_CHECK_DELAY);
  172. }
  173. if (retry == IXGBE_CS4227_RETRIES) {
  174. hw_err(hw, "CS4227 reset did not complete\n");
  175. return IXGBE_ERR_PHY;
  176. }
  177. status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
  178. if (status || !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
  179. hw_err(hw, "CS4227 EEPROM did not load successfully\n");
  180. return IXGBE_ERR_PHY;
  181. }
  182. return 0;
  183. }
  184. /**
  185. * ixgbe_check_cs4227 - Check CS4227 and reset as needed
  186. * @hw: pointer to hardware structure
  187. */
  188. static void ixgbe_check_cs4227(struct ixgbe_hw *hw)
  189. {
  190. u32 swfw_mask = hw->phy.phy_semaphore_mask;
  191. s32 status;
  192. u16 value;
  193. u8 retry;
  194. for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
  195. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  196. if (status) {
  197. hw_err(hw, "semaphore failed with %d\n", status);
  198. msleep(IXGBE_CS4227_CHECK_DELAY);
  199. continue;
  200. }
  201. /* Get status of reset flow. */
  202. status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
  203. if (!status && value == IXGBE_CS4227_RESET_COMPLETE)
  204. goto out;
  205. if (status || value != IXGBE_CS4227_RESET_PENDING)
  206. break;
  207. /* Reset is pending. Wait and check again. */
  208. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  209. msleep(IXGBE_CS4227_CHECK_DELAY);
  210. }
  211. /* If still pending, assume other instance failed. */
  212. if (retry == IXGBE_CS4227_RETRIES) {
  213. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  214. if (status) {
  215. hw_err(hw, "semaphore failed with %d\n", status);
  216. return;
  217. }
  218. }
  219. /* Reset the CS4227. */
  220. status = ixgbe_reset_cs4227(hw);
  221. if (status) {
  222. hw_err(hw, "CS4227 reset failed: %d", status);
  223. goto out;
  224. }
  225. /* Reset takes so long, temporarily release semaphore in case the
  226. * other driver instance is waiting for the reset indication.
  227. */
  228. ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
  229. IXGBE_CS4227_RESET_PENDING);
  230. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  231. usleep_range(10000, 12000);
  232. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  233. if (status) {
  234. hw_err(hw, "semaphore failed with %d", status);
  235. return;
  236. }
  237. /* Record completion for next time. */
  238. status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
  239. IXGBE_CS4227_RESET_COMPLETE);
  240. out:
  241. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  242. msleep(hw->eeprom.semaphore_delay);
  243. }
  244. /** ixgbe_identify_phy_x550em - Get PHY type based on device id
  245. * @hw: pointer to hardware structure
  246. *
  247. * Returns error code
  248. */
  249. static s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
  250. {
  251. switch (hw->device_id) {
  252. case IXGBE_DEV_ID_X550EM_A_SFP:
  253. if (hw->bus.lan_id)
  254. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
  255. else
  256. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
  257. return ixgbe_identify_module_generic(hw);
  258. case IXGBE_DEV_ID_X550EM_X_SFP:
  259. /* set up for CS4227 usage */
  260. hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
  261. ixgbe_setup_mux_ctl(hw);
  262. ixgbe_check_cs4227(hw);
  263. /* Fallthrough */
  264. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  265. return ixgbe_identify_module_generic(hw);
  266. case IXGBE_DEV_ID_X550EM_X_KX4:
  267. hw->phy.type = ixgbe_phy_x550em_kx4;
  268. break;
  269. case IXGBE_DEV_ID_X550EM_X_XFI:
  270. hw->phy.type = ixgbe_phy_x550em_xfi;
  271. break;
  272. case IXGBE_DEV_ID_X550EM_X_KR:
  273. case IXGBE_DEV_ID_X550EM_A_KR:
  274. case IXGBE_DEV_ID_X550EM_A_KR_L:
  275. hw->phy.type = ixgbe_phy_x550em_kr;
  276. break;
  277. case IXGBE_DEV_ID_X550EM_A_10G_T:
  278. if (hw->bus.lan_id)
  279. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
  280. else
  281. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
  282. /* Fallthrough */
  283. case IXGBE_DEV_ID_X550EM_X_10G_T:
  284. return ixgbe_identify_phy_generic(hw);
  285. case IXGBE_DEV_ID_X550EM_X_1G_T:
  286. hw->phy.type = ixgbe_phy_ext_1g_t;
  287. break;
  288. case IXGBE_DEV_ID_X550EM_A_1G_T:
  289. case IXGBE_DEV_ID_X550EM_A_1G_T_L:
  290. hw->phy.type = ixgbe_phy_fw;
  291. hw->phy.ops.read_reg = NULL;
  292. hw->phy.ops.write_reg = NULL;
  293. if (hw->bus.lan_id)
  294. hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
  295. else
  296. hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
  297. break;
  298. default:
  299. break;
  300. }
  301. return 0;
  302. }
  303. static s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
  304. u32 device_type, u16 *phy_data)
  305. {
  306. return IXGBE_NOT_IMPLEMENTED;
  307. }
  308. static s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
  309. u32 device_type, u16 phy_data)
  310. {
  311. return IXGBE_NOT_IMPLEMENTED;
  312. }
  313. /**
  314. * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
  315. * @hw: pointer to the hardware structure
  316. * @addr: I2C bus address to read from
  317. * @reg: I2C device register to read from
  318. * @val: pointer to location to receive read value
  319. *
  320. * Returns an error code on error.
  321. **/
  322. static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
  323. u16 reg, u16 *val)
  324. {
  325. return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
  326. }
  327. /**
  328. * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
  329. * @hw: pointer to the hardware structure
  330. * @addr: I2C bus address to read from
  331. * @reg: I2C device register to read from
  332. * @val: pointer to location to receive read value
  333. *
  334. * Returns an error code on error.
  335. **/
  336. static s32
  337. ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
  338. u16 reg, u16 *val)
  339. {
  340. return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, false);
  341. }
  342. /**
  343. * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
  344. * @hw: pointer to the hardware structure
  345. * @addr: I2C bus address to write to
  346. * @reg: I2C device register to write to
  347. * @val: value to write
  348. *
  349. * Returns an error code on error.
  350. **/
  351. static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
  352. u8 addr, u16 reg, u16 val)
  353. {
  354. return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
  355. }
  356. /**
  357. * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
  358. * @hw: pointer to the hardware structure
  359. * @addr: I2C bus address to write to
  360. * @reg: I2C device register to write to
  361. * @val: value to write
  362. *
  363. * Returns an error code on error.
  364. **/
  365. static s32
  366. ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
  367. u8 addr, u16 reg, u16 val)
  368. {
  369. return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, false);
  370. }
  371. /**
  372. * ixgbe_fw_phy_activity - Perform an activity on a PHY
  373. * @hw: pointer to hardware structure
  374. * @activity: activity to perform
  375. * @data: Pointer to 4 32-bit words of data
  376. */
  377. s32 ixgbe_fw_phy_activity(struct ixgbe_hw *hw, u16 activity,
  378. u32 (*data)[FW_PHY_ACT_DATA_COUNT])
  379. {
  380. union {
  381. struct ixgbe_hic_phy_activity_req cmd;
  382. struct ixgbe_hic_phy_activity_resp rsp;
  383. } hic;
  384. u16 retries = FW_PHY_ACT_RETRIES;
  385. s32 rc;
  386. u32 i;
  387. do {
  388. memset(&hic, 0, sizeof(hic));
  389. hic.cmd.hdr.cmd = FW_PHY_ACT_REQ_CMD;
  390. hic.cmd.hdr.buf_len = FW_PHY_ACT_REQ_LEN;
  391. hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  392. hic.cmd.port_number = hw->bus.lan_id;
  393. hic.cmd.activity_id = cpu_to_le16(activity);
  394. for (i = 0; i < ARRAY_SIZE(hic.cmd.data); ++i)
  395. hic.cmd.data[i] = cpu_to_be32((*data)[i]);
  396. rc = ixgbe_host_interface_command(hw, &hic.cmd, sizeof(hic.cmd),
  397. IXGBE_HI_COMMAND_TIMEOUT,
  398. true);
  399. if (rc)
  400. return rc;
  401. if (hic.rsp.hdr.cmd_or_resp.ret_status ==
  402. FW_CEM_RESP_STATUS_SUCCESS) {
  403. for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
  404. (*data)[i] = be32_to_cpu(hic.rsp.data[i]);
  405. return 0;
  406. }
  407. usleep_range(20, 30);
  408. --retries;
  409. } while (retries > 0);
  410. return IXGBE_ERR_HOST_INTERFACE_COMMAND;
  411. }
  412. static const struct {
  413. u16 fw_speed;
  414. ixgbe_link_speed phy_speed;
  415. } ixgbe_fw_map[] = {
  416. { FW_PHY_ACT_LINK_SPEED_10, IXGBE_LINK_SPEED_10_FULL },
  417. { FW_PHY_ACT_LINK_SPEED_100, IXGBE_LINK_SPEED_100_FULL },
  418. { FW_PHY_ACT_LINK_SPEED_1G, IXGBE_LINK_SPEED_1GB_FULL },
  419. { FW_PHY_ACT_LINK_SPEED_2_5G, IXGBE_LINK_SPEED_2_5GB_FULL },
  420. { FW_PHY_ACT_LINK_SPEED_5G, IXGBE_LINK_SPEED_5GB_FULL },
  421. { FW_PHY_ACT_LINK_SPEED_10G, IXGBE_LINK_SPEED_10GB_FULL },
  422. };
  423. /**
  424. * ixgbe_get_phy_id_fw - Get the phy ID via firmware command
  425. * @hw: pointer to hardware structure
  426. *
  427. * Returns error code
  428. */
  429. static s32 ixgbe_get_phy_id_fw(struct ixgbe_hw *hw)
  430. {
  431. u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
  432. u16 phy_speeds;
  433. u16 phy_id_lo;
  434. s32 rc;
  435. u16 i;
  436. if (hw->phy.id)
  437. return 0;
  438. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_PHY_INFO, &info);
  439. if (rc)
  440. return rc;
  441. hw->phy.speeds_supported = 0;
  442. phy_speeds = info[0] & FW_PHY_INFO_SPEED_MASK;
  443. for (i = 0; i < ARRAY_SIZE(ixgbe_fw_map); ++i) {
  444. if (phy_speeds & ixgbe_fw_map[i].fw_speed)
  445. hw->phy.speeds_supported |= ixgbe_fw_map[i].phy_speed;
  446. }
  447. hw->phy.id = info[0] & FW_PHY_INFO_ID_HI_MASK;
  448. phy_id_lo = info[1] & FW_PHY_INFO_ID_LO_MASK;
  449. hw->phy.id |= phy_id_lo & IXGBE_PHY_REVISION_MASK;
  450. hw->phy.revision = phy_id_lo & ~IXGBE_PHY_REVISION_MASK;
  451. if (!hw->phy.id || hw->phy.id == IXGBE_PHY_REVISION_MASK)
  452. return IXGBE_ERR_PHY_ADDR_INVALID;
  453. hw->phy.autoneg_advertised = hw->phy.speeds_supported;
  454. hw->phy.eee_speeds_supported = IXGBE_LINK_SPEED_100_FULL |
  455. IXGBE_LINK_SPEED_1GB_FULL;
  456. hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
  457. return 0;
  458. }
  459. /**
  460. * ixgbe_identify_phy_fw - Get PHY type based on firmware command
  461. * @hw: pointer to hardware structure
  462. *
  463. * Returns error code
  464. */
  465. static s32 ixgbe_identify_phy_fw(struct ixgbe_hw *hw)
  466. {
  467. if (hw->bus.lan_id)
  468. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
  469. else
  470. hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
  471. hw->phy.type = ixgbe_phy_fw;
  472. hw->phy.ops.read_reg = NULL;
  473. hw->phy.ops.write_reg = NULL;
  474. return ixgbe_get_phy_id_fw(hw);
  475. }
  476. /**
  477. * ixgbe_shutdown_fw_phy - Shutdown a firmware-controlled PHY
  478. * @hw: pointer to hardware structure
  479. *
  480. * Returns error code
  481. */
  482. static s32 ixgbe_shutdown_fw_phy(struct ixgbe_hw *hw)
  483. {
  484. u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
  485. setup[0] = FW_PHY_ACT_FORCE_LINK_DOWN_OFF;
  486. return ixgbe_fw_phy_activity(hw, FW_PHY_ACT_FORCE_LINK_DOWN, &setup);
  487. }
  488. /**
  489. * ixgbe_setup_fw_link - Setup firmware-controlled PHYs
  490. * @hw: pointer to hardware structure
  491. */
  492. static s32 ixgbe_setup_fw_link(struct ixgbe_hw *hw)
  493. {
  494. u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
  495. s32 rc;
  496. u16 i;
  497. if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
  498. return 0;
  499. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  500. hw_err(hw, "rx_pause not valid in strict IEEE mode\n");
  501. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  502. }
  503. switch (hw->fc.requested_mode) {
  504. case ixgbe_fc_full:
  505. setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RXTX <<
  506. FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
  507. break;
  508. case ixgbe_fc_rx_pause:
  509. setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RX <<
  510. FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
  511. break;
  512. case ixgbe_fc_tx_pause:
  513. setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_TX <<
  514. FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
  515. break;
  516. default:
  517. break;
  518. }
  519. for (i = 0; i < ARRAY_SIZE(ixgbe_fw_map); ++i) {
  520. if (hw->phy.autoneg_advertised & ixgbe_fw_map[i].phy_speed)
  521. setup[0] |= ixgbe_fw_map[i].fw_speed;
  522. }
  523. setup[0] |= FW_PHY_ACT_SETUP_LINK_HP | FW_PHY_ACT_SETUP_LINK_AN;
  524. if (hw->phy.eee_speeds_advertised)
  525. setup[0] |= FW_PHY_ACT_SETUP_LINK_EEE;
  526. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_SETUP_LINK, &setup);
  527. if (rc)
  528. return rc;
  529. if (setup[0] == FW_PHY_ACT_SETUP_LINK_RSP_DOWN)
  530. return IXGBE_ERR_OVERTEMP;
  531. return 0;
  532. }
  533. /**
  534. * ixgbe_fc_autoneg_fw - Set up flow control for FW-controlled PHYs
  535. * @hw: pointer to hardware structure
  536. *
  537. * Called at init time to set up flow control.
  538. */
  539. static s32 ixgbe_fc_autoneg_fw(struct ixgbe_hw *hw)
  540. {
  541. if (hw->fc.requested_mode == ixgbe_fc_default)
  542. hw->fc.requested_mode = ixgbe_fc_full;
  543. return ixgbe_setup_fw_link(hw);
  544. }
  545. /** ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
  546. * @hw: pointer to hardware structure
  547. *
  548. * Initializes the EEPROM parameters ixgbe_eeprom_info within the
  549. * ixgbe_hw struct in order to set up EEPROM access.
  550. **/
  551. static s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  552. {
  553. struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
  554. u32 eec;
  555. u16 eeprom_size;
  556. if (eeprom->type == ixgbe_eeprom_uninitialized) {
  557. eeprom->semaphore_delay = 10;
  558. eeprom->type = ixgbe_flash;
  559. eec = IXGBE_READ_REG(hw, IXGBE_EEC(hw));
  560. eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
  561. IXGBE_EEC_SIZE_SHIFT);
  562. eeprom->word_size = BIT(eeprom_size +
  563. IXGBE_EEPROM_WORD_SIZE_SHIFT);
  564. hw_dbg(hw, "Eeprom params: type = %d, size = %d\n",
  565. eeprom->type, eeprom->word_size);
  566. }
  567. return 0;
  568. }
  569. /**
  570. * ixgbe_iosf_wait - Wait for IOSF command completion
  571. * @hw: pointer to hardware structure
  572. * @ctrl: pointer to location to receive final IOSF control value
  573. *
  574. * Return: failing status on timeout
  575. *
  576. * Note: ctrl can be NULL if the IOSF control register value is not needed
  577. */
  578. static s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
  579. {
  580. u32 i, command;
  581. /* Check every 10 usec to see if the address cycle completed.
  582. * The SB IOSF BUSY bit will clear when the operation is
  583. * complete.
  584. */
  585. for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
  586. command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
  587. if (!(command & IXGBE_SB_IOSF_CTRL_BUSY))
  588. break;
  589. udelay(10);
  590. }
  591. if (ctrl)
  592. *ctrl = command;
  593. if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
  594. hw_dbg(hw, "IOSF wait timed out\n");
  595. return IXGBE_ERR_PHY;
  596. }
  597. return 0;
  598. }
  599. /** ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the
  600. * IOSF device
  601. * @hw: pointer to hardware structure
  602. * @reg_addr: 32 bit PHY register to write
  603. * @device_type: 3 bit device type
  604. * @phy_data: Pointer to read data from the register
  605. **/
  606. static s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
  607. u32 device_type, u32 *data)
  608. {
  609. u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
  610. u32 command, error;
  611. s32 ret;
  612. ret = hw->mac.ops.acquire_swfw_sync(hw, gssr);
  613. if (ret)
  614. return ret;
  615. ret = ixgbe_iosf_wait(hw, NULL);
  616. if (ret)
  617. goto out;
  618. command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
  619. (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
  620. /* Write IOSF control register */
  621. IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
  622. ret = ixgbe_iosf_wait(hw, &command);
  623. if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
  624. error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
  625. IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
  626. hw_dbg(hw, "Failed to read, error %x\n", error);
  627. return IXGBE_ERR_PHY;
  628. }
  629. if (!ret)
  630. *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
  631. out:
  632. hw->mac.ops.release_swfw_sync(hw, gssr);
  633. return ret;
  634. }
  635. /**
  636. * ixgbe_get_phy_token - Get the token for shared PHY access
  637. * @hw: Pointer to hardware structure
  638. */
  639. static s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
  640. {
  641. struct ixgbe_hic_phy_token_req token_cmd;
  642. s32 status;
  643. token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
  644. token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
  645. token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
  646. token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  647. token_cmd.port_number = hw->bus.lan_id;
  648. token_cmd.command_type = FW_PHY_TOKEN_REQ;
  649. token_cmd.pad = 0;
  650. status = ixgbe_host_interface_command(hw, &token_cmd, sizeof(token_cmd),
  651. IXGBE_HI_COMMAND_TIMEOUT,
  652. true);
  653. if (status)
  654. return status;
  655. if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
  656. return 0;
  657. if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY)
  658. return IXGBE_ERR_FW_RESP_INVALID;
  659. return IXGBE_ERR_TOKEN_RETRY;
  660. }
  661. /**
  662. * ixgbe_put_phy_token - Put the token for shared PHY access
  663. * @hw: Pointer to hardware structure
  664. */
  665. static s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
  666. {
  667. struct ixgbe_hic_phy_token_req token_cmd;
  668. s32 status;
  669. token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
  670. token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
  671. token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
  672. token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  673. token_cmd.port_number = hw->bus.lan_id;
  674. token_cmd.command_type = FW_PHY_TOKEN_REL;
  675. token_cmd.pad = 0;
  676. status = ixgbe_host_interface_command(hw, &token_cmd, sizeof(token_cmd),
  677. IXGBE_HI_COMMAND_TIMEOUT,
  678. true);
  679. if (status)
  680. return status;
  681. if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
  682. return 0;
  683. return IXGBE_ERR_FW_RESP_INVALID;
  684. }
  685. /**
  686. * ixgbe_write_iosf_sb_reg_x550a - Write to IOSF PHY register
  687. * @hw: pointer to hardware structure
  688. * @reg_addr: 32 bit PHY register to write
  689. * @device_type: 3 bit device type
  690. * @data: Data to write to the register
  691. **/
  692. static s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  693. __always_unused u32 device_type,
  694. u32 data)
  695. {
  696. struct ixgbe_hic_internal_phy_req write_cmd;
  697. memset(&write_cmd, 0, sizeof(write_cmd));
  698. write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
  699. write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
  700. write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  701. write_cmd.port_number = hw->bus.lan_id;
  702. write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
  703. write_cmd.address = cpu_to_be16(reg_addr);
  704. write_cmd.write_data = cpu_to_be32(data);
  705. return ixgbe_host_interface_command(hw, &write_cmd, sizeof(write_cmd),
  706. IXGBE_HI_COMMAND_TIMEOUT, false);
  707. }
  708. /**
  709. * ixgbe_read_iosf_sb_reg_x550a - Read from IOSF PHY register
  710. * @hw: pointer to hardware structure
  711. * @reg_addr: 32 bit PHY register to write
  712. * @device_type: 3 bit device type
  713. * @data: Pointer to read data from the register
  714. **/
  715. static s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  716. __always_unused u32 device_type,
  717. u32 *data)
  718. {
  719. union {
  720. struct ixgbe_hic_internal_phy_req cmd;
  721. struct ixgbe_hic_internal_phy_resp rsp;
  722. } hic;
  723. s32 status;
  724. memset(&hic, 0, sizeof(hic));
  725. hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
  726. hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
  727. hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  728. hic.cmd.port_number = hw->bus.lan_id;
  729. hic.cmd.command_type = FW_INT_PHY_REQ_READ;
  730. hic.cmd.address = cpu_to_be16(reg_addr);
  731. status = ixgbe_host_interface_command(hw, &hic.cmd, sizeof(hic.cmd),
  732. IXGBE_HI_COMMAND_TIMEOUT, true);
  733. /* Extract the register value from the response. */
  734. *data = be32_to_cpu(hic.rsp.read_data);
  735. return status;
  736. }
  737. /** ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
  738. * @hw: pointer to hardware structure
  739. * @offset: offset of word in the EEPROM to read
  740. * @words: number of words
  741. * @data: word(s) read from the EEPROM
  742. *
  743. * Reads a 16 bit word(s) from the EEPROM using the hostif.
  744. **/
  745. static s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
  746. u16 offset, u16 words, u16 *data)
  747. {
  748. const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
  749. struct ixgbe_hic_read_shadow_ram buffer;
  750. u32 current_word = 0;
  751. u16 words_to_read;
  752. s32 status;
  753. u32 i;
  754. /* Take semaphore for the entire operation. */
  755. status = hw->mac.ops.acquire_swfw_sync(hw, mask);
  756. if (status) {
  757. hw_dbg(hw, "EEPROM read buffer - semaphore failed\n");
  758. return status;
  759. }
  760. while (words) {
  761. if (words > FW_MAX_READ_BUFFER_SIZE / 2)
  762. words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
  763. else
  764. words_to_read = words;
  765. buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
  766. buffer.hdr.req.buf_lenh = 0;
  767. buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
  768. buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
  769. /* convert offset from words to bytes */
  770. buffer.address = (__force u32)cpu_to_be32((offset +
  771. current_word) * 2);
  772. buffer.length = (__force u16)cpu_to_be16(words_to_read * 2);
  773. buffer.pad2 = 0;
  774. buffer.pad3 = 0;
  775. status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
  776. IXGBE_HI_COMMAND_TIMEOUT);
  777. if (status) {
  778. hw_dbg(hw, "Host interface command failed\n");
  779. goto out;
  780. }
  781. for (i = 0; i < words_to_read; i++) {
  782. u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
  783. 2 * i;
  784. u32 value = IXGBE_READ_REG(hw, reg);
  785. data[current_word] = (u16)(value & 0xffff);
  786. current_word++;
  787. i++;
  788. if (i < words_to_read) {
  789. value >>= 16;
  790. data[current_word] = (u16)(value & 0xffff);
  791. current_word++;
  792. }
  793. }
  794. words -= words_to_read;
  795. }
  796. out:
  797. hw->mac.ops.release_swfw_sync(hw, mask);
  798. return status;
  799. }
  800. /** ixgbe_checksum_ptr_x550 - Checksum one pointer region
  801. * @hw: pointer to hardware structure
  802. * @ptr: pointer offset in eeprom
  803. * @size: size of section pointed by ptr, if 0 first word will be used as size
  804. * @csum: address of checksum to update
  805. *
  806. * Returns error status for any failure
  807. **/
  808. static s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
  809. u16 size, u16 *csum, u16 *buffer,
  810. u32 buffer_size)
  811. {
  812. u16 buf[256];
  813. s32 status;
  814. u16 length, bufsz, i, start;
  815. u16 *local_buffer;
  816. bufsz = ARRAY_SIZE(buf);
  817. /* Read a chunk at the pointer location */
  818. if (!buffer) {
  819. status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
  820. if (status) {
  821. hw_dbg(hw, "Failed to read EEPROM image\n");
  822. return status;
  823. }
  824. local_buffer = buf;
  825. } else {
  826. if (buffer_size < ptr)
  827. return IXGBE_ERR_PARAM;
  828. local_buffer = &buffer[ptr];
  829. }
  830. if (size) {
  831. start = 0;
  832. length = size;
  833. } else {
  834. start = 1;
  835. length = local_buffer[0];
  836. /* Skip pointer section if length is invalid. */
  837. if (length == 0xFFFF || length == 0 ||
  838. (ptr + length) >= hw->eeprom.word_size)
  839. return 0;
  840. }
  841. if (buffer && ((u32)start + (u32)length > buffer_size))
  842. return IXGBE_ERR_PARAM;
  843. for (i = start; length; i++, length--) {
  844. if (i == bufsz && !buffer) {
  845. ptr += bufsz;
  846. i = 0;
  847. if (length < bufsz)
  848. bufsz = length;
  849. /* Read a chunk at the pointer location */
  850. status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
  851. bufsz, buf);
  852. if (status) {
  853. hw_dbg(hw, "Failed to read EEPROM image\n");
  854. return status;
  855. }
  856. }
  857. *csum += local_buffer[i];
  858. }
  859. return 0;
  860. }
  861. /** ixgbe_calc_checksum_X550 - Calculates and returns the checksum
  862. * @hw: pointer to hardware structure
  863. * @buffer: pointer to buffer containing calculated checksum
  864. * @buffer_size: size of buffer
  865. *
  866. * Returns a negative error code on error, or the 16-bit checksum
  867. **/
  868. static s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer,
  869. u32 buffer_size)
  870. {
  871. u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
  872. u16 *local_buffer;
  873. s32 status;
  874. u16 checksum = 0;
  875. u16 pointer, i, size;
  876. hw->eeprom.ops.init_params(hw);
  877. if (!buffer) {
  878. /* Read pointer area */
  879. status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
  880. IXGBE_EEPROM_LAST_WORD + 1,
  881. eeprom_ptrs);
  882. if (status) {
  883. hw_dbg(hw, "Failed to read EEPROM image\n");
  884. return status;
  885. }
  886. local_buffer = eeprom_ptrs;
  887. } else {
  888. if (buffer_size < IXGBE_EEPROM_LAST_WORD)
  889. return IXGBE_ERR_PARAM;
  890. local_buffer = buffer;
  891. }
  892. /* For X550 hardware include 0x0-0x41 in the checksum, skip the
  893. * checksum word itself
  894. */
  895. for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
  896. if (i != IXGBE_EEPROM_CHECKSUM)
  897. checksum += local_buffer[i];
  898. /* Include all data from pointers 0x3, 0x6-0xE. This excludes the
  899. * FW, PHY module, and PCIe Expansion/Option ROM pointers.
  900. */
  901. for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
  902. if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
  903. continue;
  904. pointer = local_buffer[i];
  905. /* Skip pointer section if the pointer is invalid. */
  906. if (pointer == 0xFFFF || pointer == 0 ||
  907. pointer >= hw->eeprom.word_size)
  908. continue;
  909. switch (i) {
  910. case IXGBE_PCIE_GENERAL_PTR:
  911. size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
  912. break;
  913. case IXGBE_PCIE_CONFIG0_PTR:
  914. case IXGBE_PCIE_CONFIG1_PTR:
  915. size = IXGBE_PCIE_CONFIG_SIZE;
  916. break;
  917. default:
  918. size = 0;
  919. break;
  920. }
  921. status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
  922. buffer, buffer_size);
  923. if (status)
  924. return status;
  925. }
  926. checksum = (u16)IXGBE_EEPROM_SUM - checksum;
  927. return (s32)checksum;
  928. }
  929. /** ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
  930. * @hw: pointer to hardware structure
  931. *
  932. * Returns a negative error code on error, or the 16-bit checksum
  933. **/
  934. static s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
  935. {
  936. return ixgbe_calc_checksum_X550(hw, NULL, 0);
  937. }
  938. /** ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
  939. * @hw: pointer to hardware structure
  940. * @offset: offset of word in the EEPROM to read
  941. * @data: word read from the EEPROM
  942. *
  943. * Reads a 16 bit word from the EEPROM using the hostif.
  944. **/
  945. static s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 *data)
  946. {
  947. const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
  948. struct ixgbe_hic_read_shadow_ram buffer;
  949. s32 status;
  950. buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
  951. buffer.hdr.req.buf_lenh = 0;
  952. buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
  953. buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
  954. /* convert offset from words to bytes */
  955. buffer.address = (__force u32)cpu_to_be32(offset * 2);
  956. /* one word */
  957. buffer.length = (__force u16)cpu_to_be16(sizeof(u16));
  958. status = hw->mac.ops.acquire_swfw_sync(hw, mask);
  959. if (status)
  960. return status;
  961. status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
  962. IXGBE_HI_COMMAND_TIMEOUT);
  963. if (!status) {
  964. *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
  965. FW_NVM_DATA_OFFSET);
  966. }
  967. hw->mac.ops.release_swfw_sync(hw, mask);
  968. return status;
  969. }
  970. /** ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
  971. * @hw: pointer to hardware structure
  972. * @checksum_val: calculated checksum
  973. *
  974. * Performs checksum calculation and validates the EEPROM checksum. If the
  975. * caller does not need checksum_val, the value can be NULL.
  976. **/
  977. static s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw,
  978. u16 *checksum_val)
  979. {
  980. s32 status;
  981. u16 checksum;
  982. u16 read_checksum = 0;
  983. /* Read the first word from the EEPROM. If this times out or fails, do
  984. * not continue or we could be in for a very long wait while every
  985. * EEPROM read fails
  986. */
  987. status = hw->eeprom.ops.read(hw, 0, &checksum);
  988. if (status) {
  989. hw_dbg(hw, "EEPROM read failed\n");
  990. return status;
  991. }
  992. status = hw->eeprom.ops.calc_checksum(hw);
  993. if (status < 0)
  994. return status;
  995. checksum = (u16)(status & 0xffff);
  996. status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
  997. &read_checksum);
  998. if (status)
  999. return status;
  1000. /* Verify read checksum from EEPROM is the same as
  1001. * calculated checksum
  1002. */
  1003. if (read_checksum != checksum) {
  1004. status = IXGBE_ERR_EEPROM_CHECKSUM;
  1005. hw_dbg(hw, "Invalid EEPROM checksum");
  1006. }
  1007. /* If the user cares, return the calculated checksum */
  1008. if (checksum_val)
  1009. *checksum_val = checksum;
  1010. return status;
  1011. }
  1012. /** ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
  1013. * @hw: pointer to hardware structure
  1014. * @offset: offset of word in the EEPROM to write
  1015. * @data: word write to the EEPROM
  1016. *
  1017. * Write a 16 bit word to the EEPROM using the hostif.
  1018. **/
  1019. static s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
  1020. u16 data)
  1021. {
  1022. s32 status;
  1023. struct ixgbe_hic_write_shadow_ram buffer;
  1024. buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
  1025. buffer.hdr.req.buf_lenh = 0;
  1026. buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
  1027. buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
  1028. /* one word */
  1029. buffer.length = cpu_to_be16(sizeof(u16));
  1030. buffer.data = data;
  1031. buffer.address = cpu_to_be32(offset * 2);
  1032. status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
  1033. IXGBE_HI_COMMAND_TIMEOUT, false);
  1034. return status;
  1035. }
  1036. /** ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
  1037. * @hw: pointer to hardware structure
  1038. * @offset: offset of word in the EEPROM to write
  1039. * @data: word write to the EEPROM
  1040. *
  1041. * Write a 16 bit word to the EEPROM using the hostif.
  1042. **/
  1043. static s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 data)
  1044. {
  1045. s32 status = 0;
  1046. if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) == 0) {
  1047. status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
  1048. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  1049. } else {
  1050. hw_dbg(hw, "write ee hostif failed to get semaphore");
  1051. status = IXGBE_ERR_SWFW_SYNC;
  1052. }
  1053. return status;
  1054. }
  1055. /** ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
  1056. * @hw: pointer to hardware structure
  1057. *
  1058. * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
  1059. **/
  1060. static s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
  1061. {
  1062. s32 status = 0;
  1063. union ixgbe_hic_hdr2 buffer;
  1064. buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
  1065. buffer.req.buf_lenh = 0;
  1066. buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
  1067. buffer.req.checksum = FW_DEFAULT_CHECKSUM;
  1068. status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
  1069. IXGBE_HI_COMMAND_TIMEOUT, false);
  1070. return status;
  1071. }
  1072. /**
  1073. * ixgbe_get_bus_info_X550em - Set PCI bus info
  1074. * @hw: pointer to hardware structure
  1075. *
  1076. * Sets bus link width and speed to unknown because X550em is
  1077. * not a PCI device.
  1078. **/
  1079. static s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
  1080. {
  1081. hw->bus.type = ixgbe_bus_type_internal;
  1082. hw->bus.width = ixgbe_bus_width_unknown;
  1083. hw->bus.speed = ixgbe_bus_speed_unknown;
  1084. hw->mac.ops.set_lan_id(hw);
  1085. return 0;
  1086. }
  1087. /** ixgbe_disable_rx_x550 - Disable RX unit
  1088. *
  1089. * Enables the Rx DMA unit for x550
  1090. **/
  1091. static void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
  1092. {
  1093. u32 rxctrl, pfdtxgswc;
  1094. s32 status;
  1095. struct ixgbe_hic_disable_rxen fw_cmd;
  1096. rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
  1097. if (rxctrl & IXGBE_RXCTRL_RXEN) {
  1098. pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
  1099. if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
  1100. pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
  1101. IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
  1102. hw->mac.set_lben = true;
  1103. } else {
  1104. hw->mac.set_lben = false;
  1105. }
  1106. fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
  1107. fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
  1108. fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
  1109. fw_cmd.port_number = hw->bus.lan_id;
  1110. status = ixgbe_host_interface_command(hw, &fw_cmd,
  1111. sizeof(struct ixgbe_hic_disable_rxen),
  1112. IXGBE_HI_COMMAND_TIMEOUT, true);
  1113. /* If we fail - disable RX using register write */
  1114. if (status) {
  1115. rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
  1116. if (rxctrl & IXGBE_RXCTRL_RXEN) {
  1117. rxctrl &= ~IXGBE_RXCTRL_RXEN;
  1118. IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
  1119. }
  1120. }
  1121. }
  1122. }
  1123. /** ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
  1124. * @hw: pointer to hardware structure
  1125. *
  1126. * After writing EEPROM to shadow RAM using EEWR register, software calculates
  1127. * checksum and updates the EEPROM and instructs the hardware to update
  1128. * the flash.
  1129. **/
  1130. static s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
  1131. {
  1132. s32 status;
  1133. u16 checksum = 0;
  1134. /* Read the first word from the EEPROM. If this times out or fails, do
  1135. * not continue or we could be in for a very long wait while every
  1136. * EEPROM read fails
  1137. */
  1138. status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
  1139. if (status) {
  1140. hw_dbg(hw, "EEPROM read failed\n");
  1141. return status;
  1142. }
  1143. status = ixgbe_calc_eeprom_checksum_X550(hw);
  1144. if (status < 0)
  1145. return status;
  1146. checksum = (u16)(status & 0xffff);
  1147. status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
  1148. checksum);
  1149. if (status)
  1150. return status;
  1151. status = ixgbe_update_flash_X550(hw);
  1152. return status;
  1153. }
  1154. /** ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
  1155. * @hw: pointer to hardware structure
  1156. * @offset: offset of word in the EEPROM to write
  1157. * @words: number of words
  1158. * @data: word(s) write to the EEPROM
  1159. *
  1160. *
  1161. * Write a 16 bit word(s) to the EEPROM using the hostif.
  1162. **/
  1163. static s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
  1164. u16 offset, u16 words,
  1165. u16 *data)
  1166. {
  1167. s32 status = 0;
  1168. u32 i = 0;
  1169. /* Take semaphore for the entire operation. */
  1170. status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  1171. if (status) {
  1172. hw_dbg(hw, "EEPROM write buffer - semaphore failed\n");
  1173. return status;
  1174. }
  1175. for (i = 0; i < words; i++) {
  1176. status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
  1177. data[i]);
  1178. if (status) {
  1179. hw_dbg(hw, "Eeprom buffered write failed\n");
  1180. break;
  1181. }
  1182. }
  1183. hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
  1184. return status;
  1185. }
  1186. /** ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the
  1187. * IOSF device
  1188. *
  1189. * @hw: pointer to hardware structure
  1190. * @reg_addr: 32 bit PHY register to write
  1191. * @device_type: 3 bit device type
  1192. * @data: Data to write to the register
  1193. **/
  1194. static s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
  1195. u32 device_type, u32 data)
  1196. {
  1197. u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
  1198. u32 command, error;
  1199. s32 ret;
  1200. ret = hw->mac.ops.acquire_swfw_sync(hw, gssr);
  1201. if (ret)
  1202. return ret;
  1203. ret = ixgbe_iosf_wait(hw, NULL);
  1204. if (ret)
  1205. goto out;
  1206. command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
  1207. (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
  1208. /* Write IOSF control register */
  1209. IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
  1210. /* Write IOSF data register */
  1211. IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
  1212. ret = ixgbe_iosf_wait(hw, &command);
  1213. if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
  1214. error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
  1215. IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
  1216. hw_dbg(hw, "Failed to write, error %x\n", error);
  1217. return IXGBE_ERR_PHY;
  1218. }
  1219. out:
  1220. hw->mac.ops.release_swfw_sync(hw, gssr);
  1221. return ret;
  1222. }
  1223. /**
  1224. * ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
  1225. * @hw: pointer to hardware structure
  1226. *
  1227. * iXfI configuration needed for ixgbe_mac_X550EM_x devices.
  1228. **/
  1229. static s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
  1230. {
  1231. s32 status;
  1232. u32 reg_val;
  1233. /* Disable training protocol FSM. */
  1234. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1235. IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
  1236. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1237. if (status)
  1238. return status;
  1239. reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
  1240. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1241. IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
  1242. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1243. if (status)
  1244. return status;
  1245. /* Disable Flex from training TXFFE. */
  1246. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1247. IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
  1248. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1249. if (status)
  1250. return status;
  1251. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
  1252. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
  1253. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
  1254. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1255. IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
  1256. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1257. if (status)
  1258. return status;
  1259. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1260. IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
  1261. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1262. if (status)
  1263. return status;
  1264. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
  1265. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
  1266. reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
  1267. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1268. IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
  1269. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1270. if (status)
  1271. return status;
  1272. /* Enable override for coefficients. */
  1273. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1274. IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
  1275. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1276. if (status)
  1277. return status;
  1278. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
  1279. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
  1280. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
  1281. reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
  1282. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1283. IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
  1284. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1285. return status;
  1286. }
  1287. /**
  1288. * ixgbe_restart_an_internal_phy_x550em - restart autonegotiation for the
  1289. * internal PHY
  1290. * @hw: pointer to hardware structure
  1291. **/
  1292. static s32 ixgbe_restart_an_internal_phy_x550em(struct ixgbe_hw *hw)
  1293. {
  1294. s32 status;
  1295. u32 link_ctrl;
  1296. /* Restart auto-negotiation. */
  1297. status = hw->mac.ops.read_iosf_sb_reg(hw,
  1298. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1299. IXGBE_SB_IOSF_TARGET_KR_PHY, &link_ctrl);
  1300. if (status) {
  1301. hw_dbg(hw, "Auto-negotiation did not complete\n");
  1302. return status;
  1303. }
  1304. link_ctrl |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
  1305. status = hw->mac.ops.write_iosf_sb_reg(hw,
  1306. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1307. IXGBE_SB_IOSF_TARGET_KR_PHY, link_ctrl);
  1308. if (hw->mac.type == ixgbe_mac_x550em_a) {
  1309. u32 flx_mask_st20;
  1310. /* Indicate to FW that AN restart has been asserted */
  1311. status = hw->mac.ops.read_iosf_sb_reg(hw,
  1312. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1313. IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_mask_st20);
  1314. if (status) {
  1315. hw_dbg(hw, "Auto-negotiation did not complete\n");
  1316. return status;
  1317. }
  1318. flx_mask_st20 |= IXGBE_KRM_PMD_FLX_MASK_ST20_FW_AN_RESTART;
  1319. status = hw->mac.ops.write_iosf_sb_reg(hw,
  1320. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1321. IXGBE_SB_IOSF_TARGET_KR_PHY, flx_mask_st20);
  1322. }
  1323. return status;
  1324. }
  1325. /** ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
  1326. * @hw: pointer to hardware structure
  1327. * @speed: the link speed to force
  1328. *
  1329. * Configures the integrated KR PHY to use iXFI mode. Used to connect an
  1330. * internal and external PHY at a specific speed, without autonegotiation.
  1331. **/
  1332. static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
  1333. {
  1334. struct ixgbe_mac_info *mac = &hw->mac;
  1335. s32 status;
  1336. u32 reg_val;
  1337. /* iXFI is only supported with X552 */
  1338. if (mac->type != ixgbe_mac_X550EM_x)
  1339. return IXGBE_ERR_LINK_SETUP;
  1340. /* Disable AN and force speed to 10G Serial. */
  1341. status = ixgbe_read_iosf_sb_reg_x550(hw,
  1342. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1343. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1344. if (status)
  1345. return status;
  1346. reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  1347. reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
  1348. /* Select forced link speed for internal PHY. */
  1349. switch (*speed) {
  1350. case IXGBE_LINK_SPEED_10GB_FULL:
  1351. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
  1352. break;
  1353. case IXGBE_LINK_SPEED_1GB_FULL:
  1354. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
  1355. break;
  1356. default:
  1357. /* Other link speeds are not supported by internal KR PHY. */
  1358. return IXGBE_ERR_LINK_SETUP;
  1359. }
  1360. status = ixgbe_write_iosf_sb_reg_x550(hw,
  1361. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1362. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1363. if (status)
  1364. return status;
  1365. /* Additional configuration needed for x550em_x */
  1366. if (hw->mac.type == ixgbe_mac_X550EM_x) {
  1367. status = ixgbe_setup_ixfi_x550em_x(hw);
  1368. if (status)
  1369. return status;
  1370. }
  1371. /* Toggle port SW reset by AN reset. */
  1372. status = ixgbe_restart_an_internal_phy_x550em(hw);
  1373. return status;
  1374. }
  1375. /**
  1376. * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
  1377. * @hw: pointer to hardware structure
  1378. * @linear: true if SFP module is linear
  1379. */
  1380. static s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
  1381. {
  1382. switch (hw->phy.sfp_type) {
  1383. case ixgbe_sfp_type_not_present:
  1384. return IXGBE_ERR_SFP_NOT_PRESENT;
  1385. case ixgbe_sfp_type_da_cu_core0:
  1386. case ixgbe_sfp_type_da_cu_core1:
  1387. *linear = true;
  1388. break;
  1389. case ixgbe_sfp_type_srlr_core0:
  1390. case ixgbe_sfp_type_srlr_core1:
  1391. case ixgbe_sfp_type_da_act_lmt_core0:
  1392. case ixgbe_sfp_type_da_act_lmt_core1:
  1393. case ixgbe_sfp_type_1g_sx_core0:
  1394. case ixgbe_sfp_type_1g_sx_core1:
  1395. case ixgbe_sfp_type_1g_lx_core0:
  1396. case ixgbe_sfp_type_1g_lx_core1:
  1397. *linear = false;
  1398. break;
  1399. case ixgbe_sfp_type_unknown:
  1400. case ixgbe_sfp_type_1g_cu_core0:
  1401. case ixgbe_sfp_type_1g_cu_core1:
  1402. default:
  1403. return IXGBE_ERR_SFP_NOT_SUPPORTED;
  1404. }
  1405. return 0;
  1406. }
  1407. /**
  1408. * ixgbe_setup_mac_link_sfp_x550em - Configure the KR PHY for SFP.
  1409. * @hw: pointer to hardware structure
  1410. * @speed: the link speed to force
  1411. * @autoneg_wait_to_complete: unused
  1412. *
  1413. * Configures the extern PHY and the integrated KR PHY for SFP support.
  1414. */
  1415. static s32
  1416. ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
  1417. ixgbe_link_speed speed,
  1418. __always_unused bool autoneg_wait_to_complete)
  1419. {
  1420. s32 status;
  1421. u16 reg_slice, reg_val;
  1422. bool setup_linear = false;
  1423. /* Check if SFP module is supported and linear */
  1424. status = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
  1425. /* If no SFP module present, then return success. Return success since
  1426. * there is no reason to configure CS4227 and SFP not present error is
  1427. * not accepted in the setup MAC link flow.
  1428. */
  1429. if (status == IXGBE_ERR_SFP_NOT_PRESENT)
  1430. return 0;
  1431. if (status)
  1432. return status;
  1433. /* Configure internal PHY for KR/KX. */
  1434. ixgbe_setup_kr_speed_x550em(hw, speed);
  1435. /* Configure CS4227 LINE side to proper mode. */
  1436. reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
  1437. if (setup_linear)
  1438. reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
  1439. else
  1440. reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
  1441. status = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
  1442. reg_val);
  1443. return status;
  1444. }
  1445. /**
  1446. * ixgbe_setup_sfi_x550a - Configure the internal PHY for native SFI mode
  1447. * @hw: pointer to hardware structure
  1448. * @speed: the link speed to force
  1449. *
  1450. * Configures the integrated PHY for native SFI mode. Used to connect the
  1451. * internal PHY directly to an SFP cage, without autonegotiation.
  1452. **/
  1453. static s32 ixgbe_setup_sfi_x550a(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
  1454. {
  1455. struct ixgbe_mac_info *mac = &hw->mac;
  1456. s32 status;
  1457. u32 reg_val;
  1458. /* Disable all AN and force speed to 10G Serial. */
  1459. status = mac->ops.read_iosf_sb_reg(hw,
  1460. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1461. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  1462. if (status)
  1463. return status;
  1464. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
  1465. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
  1466. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
  1467. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
  1468. /* Select forced link speed for internal PHY. */
  1469. switch (*speed) {
  1470. case IXGBE_LINK_SPEED_10GB_FULL:
  1471. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_10G;
  1472. break;
  1473. case IXGBE_LINK_SPEED_1GB_FULL:
  1474. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
  1475. break;
  1476. default:
  1477. /* Other link speeds are not supported by internal PHY. */
  1478. return IXGBE_ERR_LINK_SETUP;
  1479. }
  1480. status = mac->ops.write_iosf_sb_reg(hw,
  1481. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1482. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  1483. /* Toggle port SW reset by AN reset. */
  1484. status = ixgbe_restart_an_internal_phy_x550em(hw);
  1485. return status;
  1486. }
  1487. /**
  1488. * ixgbe_setup_mac_link_sfp_n - Setup internal PHY for native SFP
  1489. * @hw: pointer to hardware structure
  1490. * @speed: link speed
  1491. * @autoneg_wait_to_complete: unused
  1492. *
  1493. * Configure the the integrated PHY for native SFP support.
  1494. */
  1495. static s32
  1496. ixgbe_setup_mac_link_sfp_n(struct ixgbe_hw *hw, ixgbe_link_speed speed,
  1497. __always_unused bool autoneg_wait_to_complete)
  1498. {
  1499. bool setup_linear = false;
  1500. u32 reg_phy_int;
  1501. s32 ret_val;
  1502. /* Check if SFP module is supported and linear */
  1503. ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
  1504. /* If no SFP module present, then return success. Return success since
  1505. * SFP not present error is not excepted in the setup MAC link flow.
  1506. */
  1507. if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
  1508. return 0;
  1509. if (ret_val)
  1510. return ret_val;
  1511. /* Configure internal PHY for native SFI based on module type */
  1512. ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
  1513. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1514. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_phy_int);
  1515. if (ret_val)
  1516. return ret_val;
  1517. reg_phy_int &= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_DA;
  1518. if (!setup_linear)
  1519. reg_phy_int |= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_SR;
  1520. ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
  1521. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1522. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_phy_int);
  1523. if (ret_val)
  1524. return ret_val;
  1525. /* Setup SFI internal link. */
  1526. return ixgbe_setup_sfi_x550a(hw, &speed);
  1527. }
  1528. /**
  1529. * ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
  1530. * @hw: pointer to hardware structure
  1531. * @speed: link speed
  1532. * @autoneg_wait_to_complete: unused
  1533. *
  1534. * Configure the the integrated PHY for SFP support.
  1535. */
  1536. static s32
  1537. ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw, ixgbe_link_speed speed,
  1538. __always_unused bool autoneg_wait_to_complete)
  1539. {
  1540. u32 reg_slice, slice_offset;
  1541. bool setup_linear = false;
  1542. u16 reg_phy_ext;
  1543. s32 ret_val;
  1544. /* Check if SFP module is supported and linear */
  1545. ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
  1546. /* If no SFP module present, then return success. Return success since
  1547. * SFP not present error is not excepted in the setup MAC link flow.
  1548. */
  1549. if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
  1550. return 0;
  1551. if (ret_val)
  1552. return ret_val;
  1553. /* Configure internal PHY for KR/KX. */
  1554. ixgbe_setup_kr_speed_x550em(hw, speed);
  1555. if (hw->phy.mdio.prtad == MDIO_PRTAD_NONE)
  1556. return IXGBE_ERR_PHY_ADDR_INVALID;
  1557. /* Get external PHY SKU id */
  1558. ret_val = hw->phy.ops.read_reg(hw, IXGBE_CS4227_EFUSE_PDF_SKU,
  1559. IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
  1560. if (ret_val)
  1561. return ret_val;
  1562. /* When configuring quad port CS4223, the MAC instance is part
  1563. * of the slice offset.
  1564. */
  1565. if (reg_phy_ext == IXGBE_CS4223_SKU_ID)
  1566. slice_offset = (hw->bus.lan_id +
  1567. (hw->bus.instance_id << 1)) << 12;
  1568. else
  1569. slice_offset = hw->bus.lan_id << 12;
  1570. /* Configure CS4227/CS4223 LINE side to proper mode. */
  1571. reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
  1572. ret_val = hw->phy.ops.read_reg(hw, reg_slice,
  1573. IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
  1574. if (ret_val)
  1575. return ret_val;
  1576. reg_phy_ext &= ~((IXGBE_CS4227_EDC_MODE_CX1 << 1) |
  1577. (IXGBE_CS4227_EDC_MODE_SR << 1));
  1578. if (setup_linear)
  1579. reg_phy_ext |= (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 1;
  1580. else
  1581. reg_phy_ext |= (IXGBE_CS4227_EDC_MODE_SR << 1) | 1;
  1582. ret_val = hw->phy.ops.write_reg(hw, reg_slice,
  1583. IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
  1584. if (ret_val)
  1585. return ret_val;
  1586. /* Flush previous write with a read */
  1587. return hw->phy.ops.read_reg(hw, reg_slice,
  1588. IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
  1589. }
  1590. /**
  1591. * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
  1592. * @hw: pointer to hardware structure
  1593. * @speed: new link speed
  1594. * @autoneg_wait: true when waiting for completion is needed
  1595. *
  1596. * Setup internal/external PHY link speed based on link speed, then set
  1597. * external PHY auto advertised link speed.
  1598. *
  1599. * Returns error status for any failure
  1600. **/
  1601. static s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
  1602. ixgbe_link_speed speed,
  1603. bool autoneg_wait)
  1604. {
  1605. s32 status;
  1606. ixgbe_link_speed force_speed;
  1607. /* Setup internal/external PHY link speed to iXFI (10G), unless
  1608. * only 1G is auto advertised then setup KX link.
  1609. */
  1610. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  1611. force_speed = IXGBE_LINK_SPEED_10GB_FULL;
  1612. else
  1613. force_speed = IXGBE_LINK_SPEED_1GB_FULL;
  1614. /* If X552 and internal link mode is XFI, then setup XFI internal link.
  1615. */
  1616. if (hw->mac.type == ixgbe_mac_X550EM_x &&
  1617. !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
  1618. status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
  1619. if (status)
  1620. return status;
  1621. }
  1622. return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
  1623. }
  1624. /** ixgbe_check_link_t_X550em - Determine link and speed status
  1625. * @hw: pointer to hardware structure
  1626. * @speed: pointer to link speed
  1627. * @link_up: true when link is up
  1628. * @link_up_wait_to_complete: bool used to wait for link up or not
  1629. *
  1630. * Check that both the MAC and X557 external PHY have link.
  1631. **/
  1632. static s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw,
  1633. ixgbe_link_speed *speed,
  1634. bool *link_up,
  1635. bool link_up_wait_to_complete)
  1636. {
  1637. u32 status;
  1638. u16 i, autoneg_status;
  1639. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
  1640. return IXGBE_ERR_CONFIG;
  1641. status = ixgbe_check_mac_link_generic(hw, speed, link_up,
  1642. link_up_wait_to_complete);
  1643. /* If check link fails or MAC link is not up, then return */
  1644. if (status || !(*link_up))
  1645. return status;
  1646. /* MAC link is up, so check external PHY link.
  1647. * Link status is latching low, and can only be used to detect link
  1648. * drop, and not the current status of the link without performing
  1649. * back-to-back reads.
  1650. */
  1651. for (i = 0; i < 2; i++) {
  1652. status = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN,
  1653. &autoneg_status);
  1654. if (status)
  1655. return status;
  1656. }
  1657. /* If external PHY link is not up, then indicate link not up */
  1658. if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
  1659. *link_up = false;
  1660. return 0;
  1661. }
  1662. /**
  1663. * ixgbe_setup_sgmii - Set up link for sgmii
  1664. * @hw: pointer to hardware structure
  1665. * @speed: unused
  1666. * @autoneg_wait_to_complete: unused
  1667. */
  1668. static s32
  1669. ixgbe_setup_sgmii(struct ixgbe_hw *hw, __always_unused ixgbe_link_speed speed,
  1670. __always_unused bool autoneg_wait_to_complete)
  1671. {
  1672. struct ixgbe_mac_info *mac = &hw->mac;
  1673. u32 lval, sval, flx_val;
  1674. s32 rc;
  1675. rc = mac->ops.read_iosf_sb_reg(hw,
  1676. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1677. IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
  1678. if (rc)
  1679. return rc;
  1680. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  1681. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
  1682. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
  1683. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
  1684. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
  1685. rc = mac->ops.write_iosf_sb_reg(hw,
  1686. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1687. IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
  1688. if (rc)
  1689. return rc;
  1690. rc = mac->ops.read_iosf_sb_reg(hw,
  1691. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1692. IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
  1693. if (rc)
  1694. return rc;
  1695. sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
  1696. sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
  1697. rc = mac->ops.write_iosf_sb_reg(hw,
  1698. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1699. IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
  1700. if (rc)
  1701. return rc;
  1702. rc = mac->ops.read_iosf_sb_reg(hw,
  1703. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1704. IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
  1705. if (rc)
  1706. return rc;
  1707. rc = mac->ops.read_iosf_sb_reg(hw,
  1708. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1709. IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
  1710. if (rc)
  1711. return rc;
  1712. flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
  1713. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
  1714. flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
  1715. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
  1716. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
  1717. rc = mac->ops.write_iosf_sb_reg(hw,
  1718. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1719. IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
  1720. if (rc)
  1721. return rc;
  1722. rc = ixgbe_restart_an_internal_phy_x550em(hw);
  1723. return rc;
  1724. }
  1725. /**
  1726. * ixgbe_setup_sgmii_fw - Set up link for sgmii with firmware-controlled PHYs
  1727. * @hw: pointer to hardware structure
  1728. * @speed: the link speed to force
  1729. * @autoneg_wait: true when waiting for completion is needed
  1730. */
  1731. static s32 ixgbe_setup_sgmii_fw(struct ixgbe_hw *hw, ixgbe_link_speed speed,
  1732. bool autoneg_wait)
  1733. {
  1734. struct ixgbe_mac_info *mac = &hw->mac;
  1735. u32 lval, sval, flx_val;
  1736. s32 rc;
  1737. rc = mac->ops.read_iosf_sb_reg(hw,
  1738. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1739. IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
  1740. if (rc)
  1741. return rc;
  1742. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  1743. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
  1744. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
  1745. lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
  1746. lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
  1747. rc = mac->ops.write_iosf_sb_reg(hw,
  1748. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1749. IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
  1750. if (rc)
  1751. return rc;
  1752. rc = mac->ops.read_iosf_sb_reg(hw,
  1753. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1754. IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
  1755. if (rc)
  1756. return rc;
  1757. sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
  1758. sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
  1759. rc = mac->ops.write_iosf_sb_reg(hw,
  1760. IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
  1761. IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
  1762. if (rc)
  1763. return rc;
  1764. rc = mac->ops.write_iosf_sb_reg(hw,
  1765. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  1766. IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
  1767. if (rc)
  1768. return rc;
  1769. rc = mac->ops.read_iosf_sb_reg(hw,
  1770. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1771. IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
  1772. if (rc)
  1773. return rc;
  1774. flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
  1775. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
  1776. flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
  1777. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
  1778. flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
  1779. rc = mac->ops.write_iosf_sb_reg(hw,
  1780. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  1781. IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
  1782. if (rc)
  1783. return rc;
  1784. ixgbe_restart_an_internal_phy_x550em(hw);
  1785. return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
  1786. }
  1787. /**
  1788. * ixgbe_fc_autoneg_sgmii_x550em_a - Enable flow control IEEE clause 37
  1789. * @hw: pointer to hardware structure
  1790. *
  1791. * Enable flow control according to IEEE clause 37.
  1792. */
  1793. static void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
  1794. {
  1795. s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  1796. u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
  1797. ixgbe_link_speed speed;
  1798. bool link_up;
  1799. /* AN should have completed when the cable was plugged in.
  1800. * Look for reasons to bail out. Bail out if:
  1801. * - FC autoneg is disabled, or if
  1802. * - link is not up.
  1803. */
  1804. if (hw->fc.disable_fc_autoneg)
  1805. goto out;
  1806. hw->mac.ops.check_link(hw, &speed, &link_up, false);
  1807. if (!link_up)
  1808. goto out;
  1809. /* Check if auto-negotiation has completed */
  1810. status = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &info);
  1811. if (status || !(info[0] & FW_PHY_ACT_GET_LINK_INFO_AN_COMPLETE)) {
  1812. status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  1813. goto out;
  1814. }
  1815. /* Negotiate the flow control */
  1816. status = ixgbe_negotiate_fc(hw, info[0], info[0],
  1817. FW_PHY_ACT_GET_LINK_INFO_FC_RX,
  1818. FW_PHY_ACT_GET_LINK_INFO_FC_TX,
  1819. FW_PHY_ACT_GET_LINK_INFO_LP_FC_RX,
  1820. FW_PHY_ACT_GET_LINK_INFO_LP_FC_TX);
  1821. out:
  1822. if (!status) {
  1823. hw->fc.fc_was_autonegged = true;
  1824. } else {
  1825. hw->fc.fc_was_autonegged = false;
  1826. hw->fc.current_mode = hw->fc.requested_mode;
  1827. }
  1828. }
  1829. /** ixgbe_init_mac_link_ops_X550em_a - Init mac link function pointers
  1830. * @hw: pointer to hardware structure
  1831. **/
  1832. static void ixgbe_init_mac_link_ops_X550em_a(struct ixgbe_hw *hw)
  1833. {
  1834. struct ixgbe_mac_info *mac = &hw->mac;
  1835. switch (mac->ops.get_media_type(hw)) {
  1836. case ixgbe_media_type_fiber:
  1837. mac->ops.setup_fc = NULL;
  1838. mac->ops.fc_autoneg = ixgbe_fc_autoneg_fiber_x550em_a;
  1839. break;
  1840. case ixgbe_media_type_copper:
  1841. if (hw->device_id != IXGBE_DEV_ID_X550EM_A_1G_T &&
  1842. hw->device_id != IXGBE_DEV_ID_X550EM_A_1G_T_L) {
  1843. mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
  1844. break;
  1845. }
  1846. mac->ops.fc_autoneg = ixgbe_fc_autoneg_sgmii_x550em_a;
  1847. mac->ops.setup_fc = ixgbe_fc_autoneg_fw;
  1848. mac->ops.setup_link = ixgbe_setup_sgmii_fw;
  1849. mac->ops.check_link = ixgbe_check_mac_link_generic;
  1850. break;
  1851. case ixgbe_media_type_backplane:
  1852. mac->ops.fc_autoneg = ixgbe_fc_autoneg_backplane_x550em_a;
  1853. mac->ops.setup_fc = ixgbe_setup_fc_backplane_x550em_a;
  1854. break;
  1855. default:
  1856. break;
  1857. }
  1858. }
  1859. /** ixgbe_init_mac_link_ops_X550em - init mac link function pointers
  1860. * @hw: pointer to hardware structure
  1861. **/
  1862. static void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
  1863. {
  1864. struct ixgbe_mac_info *mac = &hw->mac;
  1865. mac->ops.setup_fc = ixgbe_setup_fc_x550em;
  1866. switch (mac->ops.get_media_type(hw)) {
  1867. case ixgbe_media_type_fiber:
  1868. /* CS4227 does not support autoneg, so disable the laser control
  1869. * functions for SFP+ fiber
  1870. */
  1871. mac->ops.disable_tx_laser = NULL;
  1872. mac->ops.enable_tx_laser = NULL;
  1873. mac->ops.flap_tx_laser = NULL;
  1874. mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
  1875. switch (hw->device_id) {
  1876. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  1877. mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_n;
  1878. break;
  1879. case IXGBE_DEV_ID_X550EM_A_SFP:
  1880. mac->ops.setup_mac_link =
  1881. ixgbe_setup_mac_link_sfp_x550a;
  1882. break;
  1883. default:
  1884. mac->ops.setup_mac_link =
  1885. ixgbe_setup_mac_link_sfp_x550em;
  1886. break;
  1887. }
  1888. mac->ops.set_rate_select_speed =
  1889. ixgbe_set_soft_rate_select_speed;
  1890. break;
  1891. case ixgbe_media_type_copper:
  1892. if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T)
  1893. break;
  1894. mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
  1895. mac->ops.setup_fc = ixgbe_setup_fc_generic;
  1896. mac->ops.check_link = ixgbe_check_link_t_X550em;
  1897. break;
  1898. case ixgbe_media_type_backplane:
  1899. if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
  1900. hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
  1901. mac->ops.setup_link = ixgbe_setup_sgmii;
  1902. break;
  1903. default:
  1904. break;
  1905. }
  1906. /* Additional modification for X550em_a devices */
  1907. if (hw->mac.type == ixgbe_mac_x550em_a)
  1908. ixgbe_init_mac_link_ops_X550em_a(hw);
  1909. }
  1910. /** ixgbe_setup_sfp_modules_X550em - Setup SFP module
  1911. * @hw: pointer to hardware structure
  1912. */
  1913. static s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
  1914. {
  1915. s32 status;
  1916. bool linear;
  1917. /* Check if SFP module is supported */
  1918. status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
  1919. if (status)
  1920. return status;
  1921. ixgbe_init_mac_link_ops_X550em(hw);
  1922. hw->phy.ops.reset = NULL;
  1923. return 0;
  1924. }
  1925. /** ixgbe_get_link_capabilities_x550em - Determines link capabilities
  1926. * @hw: pointer to hardware structure
  1927. * @speed: pointer to link speed
  1928. * @autoneg: true when autoneg or autotry is enabled
  1929. **/
  1930. static s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
  1931. ixgbe_link_speed *speed,
  1932. bool *autoneg)
  1933. {
  1934. if (hw->phy.type == ixgbe_phy_fw) {
  1935. *autoneg = true;
  1936. *speed = hw->phy.speeds_supported;
  1937. return 0;
  1938. }
  1939. /* SFP */
  1940. if (hw->phy.media_type == ixgbe_media_type_fiber) {
  1941. /* CS4227 SFP must not enable auto-negotiation */
  1942. *autoneg = false;
  1943. if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
  1944. hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
  1945. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1946. return 0;
  1947. }
  1948. /* Link capabilities are based on SFP */
  1949. if (hw->phy.multispeed_fiber)
  1950. *speed = IXGBE_LINK_SPEED_10GB_FULL |
  1951. IXGBE_LINK_SPEED_1GB_FULL;
  1952. else
  1953. *speed = IXGBE_LINK_SPEED_10GB_FULL;
  1954. } else {
  1955. switch (hw->phy.type) {
  1956. case ixgbe_phy_x550em_kx4:
  1957. *speed = IXGBE_LINK_SPEED_1GB_FULL |
  1958. IXGBE_LINK_SPEED_2_5GB_FULL |
  1959. IXGBE_LINK_SPEED_10GB_FULL;
  1960. break;
  1961. case ixgbe_phy_x550em_xfi:
  1962. *speed = IXGBE_LINK_SPEED_1GB_FULL |
  1963. IXGBE_LINK_SPEED_10GB_FULL;
  1964. break;
  1965. case ixgbe_phy_ext_1g_t:
  1966. case ixgbe_phy_sgmii:
  1967. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1968. break;
  1969. case ixgbe_phy_x550em_kr:
  1970. if (hw->mac.type == ixgbe_mac_x550em_a) {
  1971. /* check different backplane modes */
  1972. if (hw->phy.nw_mng_if_sel &
  1973. IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
  1974. *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
  1975. break;
  1976. } else if (hw->device_id ==
  1977. IXGBE_DEV_ID_X550EM_A_KR_L) {
  1978. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1979. break;
  1980. }
  1981. }
  1982. /* fall through */
  1983. default:
  1984. *speed = IXGBE_LINK_SPEED_10GB_FULL |
  1985. IXGBE_LINK_SPEED_1GB_FULL;
  1986. break;
  1987. }
  1988. *autoneg = true;
  1989. }
  1990. return 0;
  1991. }
  1992. /**
  1993. * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
  1994. * @hw: pointer to hardware structure
  1995. * @lsc: pointer to boolean flag which indicates whether external Base T
  1996. * PHY interrupt is lsc
  1997. *
  1998. * Determime if external Base T PHY interrupt cause is high temperature
  1999. * failure alarm or link status change.
  2000. *
  2001. * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  2002. * failure alarm, else return PHY access status.
  2003. **/
  2004. static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
  2005. {
  2006. u32 status;
  2007. u16 reg;
  2008. *lsc = false;
  2009. /* Vendor alarm triggered */
  2010. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
  2011. MDIO_MMD_VEND1,
  2012. &reg);
  2013. if (status || !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
  2014. return status;
  2015. /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
  2016. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
  2017. MDIO_MMD_VEND1,
  2018. &reg);
  2019. if (status || !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
  2020. IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
  2021. return status;
  2022. /* Global alarm triggered */
  2023. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
  2024. MDIO_MMD_VEND1,
  2025. &reg);
  2026. if (status)
  2027. return status;
  2028. /* If high temperature failure, then return over temp error and exit */
  2029. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
  2030. /* power down the PHY in case the PHY FW didn't already */
  2031. ixgbe_set_copper_phy_power(hw, false);
  2032. return IXGBE_ERR_OVERTEMP;
  2033. }
  2034. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
  2035. /* device fault alarm triggered */
  2036. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
  2037. MDIO_MMD_VEND1,
  2038. &reg);
  2039. if (status)
  2040. return status;
  2041. /* if device fault was due to high temp alarm handle and exit */
  2042. if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
  2043. /* power down the PHY in case the PHY FW didn't */
  2044. ixgbe_set_copper_phy_power(hw, false);
  2045. return IXGBE_ERR_OVERTEMP;
  2046. }
  2047. }
  2048. /* Vendor alarm 2 triggered */
  2049. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
  2050. MDIO_MMD_AN, &reg);
  2051. if (status || !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
  2052. return status;
  2053. /* link connect/disconnect event occurred */
  2054. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
  2055. MDIO_MMD_AN, &reg);
  2056. if (status)
  2057. return status;
  2058. /* Indicate LSC */
  2059. if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
  2060. *lsc = true;
  2061. return 0;
  2062. }
  2063. /**
  2064. * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
  2065. * @hw: pointer to hardware structure
  2066. *
  2067. * Enable link status change and temperature failure alarm for the external
  2068. * Base T PHY
  2069. *
  2070. * Returns PHY access status
  2071. **/
  2072. static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  2073. {
  2074. u32 status;
  2075. u16 reg;
  2076. bool lsc;
  2077. /* Clear interrupt flags */
  2078. status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  2079. /* Enable link status change alarm */
  2080. /* Enable the LASI interrupts on X552 devices to receive notifications
  2081. * of the link configurations of the external PHY and correspondingly
  2082. * support the configuration of the internal iXFI link, since iXFI does
  2083. * not support auto-negotiation. This is not required for X553 devices
  2084. * having KR support, which performs auto-negotiations and which is used
  2085. * as the internal link to the external PHY. Hence adding a check here
  2086. * to avoid enabling LASI interrupts for X553 devices.
  2087. */
  2088. if (hw->mac.type != ixgbe_mac_x550em_a) {
  2089. status = hw->phy.ops.read_reg(hw,
  2090. IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
  2091. MDIO_MMD_AN, &reg);
  2092. if (status)
  2093. return status;
  2094. reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
  2095. status = hw->phy.ops.write_reg(hw,
  2096. IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
  2097. MDIO_MMD_AN, reg);
  2098. if (status)
  2099. return status;
  2100. }
  2101. /* Enable high temperature failure and global fault alarms */
  2102. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
  2103. MDIO_MMD_VEND1,
  2104. &reg);
  2105. if (status)
  2106. return status;
  2107. reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
  2108. IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
  2109. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
  2110. MDIO_MMD_VEND1,
  2111. reg);
  2112. if (status)
  2113. return status;
  2114. /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
  2115. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
  2116. MDIO_MMD_VEND1,
  2117. &reg);
  2118. if (status)
  2119. return status;
  2120. reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
  2121. IXGBE_MDIO_GLOBAL_ALARM_1_INT);
  2122. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
  2123. MDIO_MMD_VEND1,
  2124. reg);
  2125. if (status)
  2126. return status;
  2127. /* Enable chip-wide vendor alarm */
  2128. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
  2129. MDIO_MMD_VEND1,
  2130. &reg);
  2131. if (status)
  2132. return status;
  2133. reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
  2134. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
  2135. MDIO_MMD_VEND1,
  2136. reg);
  2137. return status;
  2138. }
  2139. /**
  2140. * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
  2141. * @hw: pointer to hardware structure
  2142. *
  2143. * Handle external Base T PHY interrupt. If high temperature
  2144. * failure alarm then return error, else if link status change
  2145. * then setup internal/external PHY link
  2146. *
  2147. * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  2148. * failure alarm, else return PHY access status.
  2149. **/
  2150. static s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  2151. {
  2152. struct ixgbe_phy_info *phy = &hw->phy;
  2153. bool lsc;
  2154. u32 status;
  2155. status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  2156. if (status)
  2157. return status;
  2158. if (lsc && phy->ops.setup_internal_link)
  2159. return phy->ops.setup_internal_link(hw);
  2160. return 0;
  2161. }
  2162. /**
  2163. * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
  2164. * @hw: pointer to hardware structure
  2165. * @speed: link speed
  2166. *
  2167. * Configures the integrated KR PHY.
  2168. **/
  2169. static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
  2170. ixgbe_link_speed speed)
  2171. {
  2172. s32 status;
  2173. u32 reg_val;
  2174. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2175. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  2176. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  2177. if (status)
  2178. return status;
  2179. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  2180. reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
  2181. IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
  2182. /* Advertise 10G support. */
  2183. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  2184. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
  2185. /* Advertise 1G support. */
  2186. if (speed & IXGBE_LINK_SPEED_1GB_FULL)
  2187. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
  2188. status = hw->mac.ops.write_iosf_sb_reg(hw,
  2189. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  2190. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  2191. if (hw->mac.type == ixgbe_mac_x550em_a) {
  2192. /* Set lane mode to KR auto negotiation */
  2193. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2194. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  2195. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  2196. if (status)
  2197. return status;
  2198. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
  2199. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
  2200. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
  2201. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
  2202. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
  2203. status = hw->mac.ops.write_iosf_sb_reg(hw,
  2204. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  2205. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  2206. }
  2207. return ixgbe_restart_an_internal_phy_x550em(hw);
  2208. }
  2209. /**
  2210. * ixgbe_setup_kr_x550em - Configure the KR PHY
  2211. * @hw: pointer to hardware structure
  2212. **/
  2213. static s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
  2214. {
  2215. /* leave link alone for 2.5G */
  2216. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
  2217. return 0;
  2218. if (ixgbe_check_reset_blocked(hw))
  2219. return 0;
  2220. return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
  2221. }
  2222. /** ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
  2223. * @hw: address of hardware structure
  2224. * @link_up: address of boolean to indicate link status
  2225. *
  2226. * Returns error code if unable to get link status.
  2227. **/
  2228. static s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
  2229. {
  2230. u32 ret;
  2231. u16 autoneg_status;
  2232. *link_up = false;
  2233. /* read this twice back to back to indicate current status */
  2234. ret = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN,
  2235. &autoneg_status);
  2236. if (ret)
  2237. return ret;
  2238. ret = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN,
  2239. &autoneg_status);
  2240. if (ret)
  2241. return ret;
  2242. *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
  2243. return 0;
  2244. }
  2245. /** ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
  2246. * @hw: point to hardware structure
  2247. *
  2248. * Configures the link between the integrated KR PHY and the external X557 PHY
  2249. * The driver will call this function when it gets a link status change
  2250. * interrupt from the X557 PHY. This function configures the link speed
  2251. * between the PHYs to match the link speed of the BASE-T link.
  2252. *
  2253. * A return of a non-zero value indicates an error, and the base driver should
  2254. * not report link up.
  2255. **/
  2256. static s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
  2257. {
  2258. ixgbe_link_speed force_speed;
  2259. bool link_up;
  2260. u32 status;
  2261. u16 speed;
  2262. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
  2263. return IXGBE_ERR_CONFIG;
  2264. if (!(hw->mac.type == ixgbe_mac_X550EM_x &&
  2265. !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE))) {
  2266. speed = IXGBE_LINK_SPEED_10GB_FULL |
  2267. IXGBE_LINK_SPEED_1GB_FULL;
  2268. return ixgbe_setup_kr_speed_x550em(hw, speed);
  2269. }
  2270. /* If link is not up, then there is no setup necessary so return */
  2271. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2272. if (status)
  2273. return status;
  2274. if (!link_up)
  2275. return 0;
  2276. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
  2277. MDIO_MMD_AN,
  2278. &speed);
  2279. if (status)
  2280. return status;
  2281. /* If link is not still up, then no setup is necessary so return */
  2282. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2283. if (status)
  2284. return status;
  2285. if (!link_up)
  2286. return 0;
  2287. /* clear everything but the speed and duplex bits */
  2288. speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
  2289. switch (speed) {
  2290. case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
  2291. force_speed = IXGBE_LINK_SPEED_10GB_FULL;
  2292. break;
  2293. case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
  2294. force_speed = IXGBE_LINK_SPEED_1GB_FULL;
  2295. break;
  2296. default:
  2297. /* Internal PHY does not support anything else */
  2298. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  2299. }
  2300. return ixgbe_setup_ixfi_x550em(hw, &force_speed);
  2301. }
  2302. /** ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
  2303. * @hw: pointer to hardware structure
  2304. **/
  2305. static s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
  2306. {
  2307. s32 status;
  2308. status = ixgbe_reset_phy_generic(hw);
  2309. if (status)
  2310. return status;
  2311. /* Configure Link Status Alarm and Temperature Threshold interrupts */
  2312. return ixgbe_enable_lasi_ext_t_x550em(hw);
  2313. }
  2314. /**
  2315. * ixgbe_led_on_t_x550em - Turns on the software controllable LEDs.
  2316. * @hw: pointer to hardware structure
  2317. * @led_idx: led number to turn on
  2318. **/
  2319. static s32 ixgbe_led_on_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
  2320. {
  2321. u16 phy_data;
  2322. if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
  2323. return IXGBE_ERR_PARAM;
  2324. /* To turn on the LED, set mode to ON. */
  2325. hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2326. MDIO_MMD_VEND1, &phy_data);
  2327. phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
  2328. hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2329. MDIO_MMD_VEND1, phy_data);
  2330. return 0;
  2331. }
  2332. /**
  2333. * ixgbe_led_off_t_x550em - Turns off the software controllable LEDs.
  2334. * @hw: pointer to hardware structure
  2335. * @led_idx: led number to turn off
  2336. **/
  2337. static s32 ixgbe_led_off_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
  2338. {
  2339. u16 phy_data;
  2340. if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
  2341. return IXGBE_ERR_PARAM;
  2342. /* To turn on the LED, set mode to ON. */
  2343. hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2344. MDIO_MMD_VEND1, &phy_data);
  2345. phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
  2346. hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2347. MDIO_MMD_VEND1, phy_data);
  2348. return 0;
  2349. }
  2350. /**
  2351. * ixgbe_set_fw_drv_ver_x550 - Sends driver version to firmware
  2352. * @hw: pointer to the HW structure
  2353. * @maj: driver version major number
  2354. * @min: driver version minor number
  2355. * @build: driver version build number
  2356. * @sub: driver version sub build number
  2357. * @len: length of driver_ver string
  2358. * @driver_ver: driver string
  2359. *
  2360. * Sends driver version number to firmware through the manageability
  2361. * block. On success return 0
  2362. * else returns IXGBE_ERR_SWFW_SYNC when encountering an error acquiring
  2363. * semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
  2364. **/
  2365. static s32 ixgbe_set_fw_drv_ver_x550(struct ixgbe_hw *hw, u8 maj, u8 min,
  2366. u8 build, u8 sub, u16 len,
  2367. const char *driver_ver)
  2368. {
  2369. struct ixgbe_hic_drv_info2 fw_cmd;
  2370. s32 ret_val;
  2371. int i;
  2372. if (!len || !driver_ver || (len > sizeof(fw_cmd.driver_string)))
  2373. return IXGBE_ERR_INVALID_ARGUMENT;
  2374. fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
  2375. fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN + len;
  2376. fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
  2377. fw_cmd.port_num = (u8)hw->bus.func;
  2378. fw_cmd.ver_maj = maj;
  2379. fw_cmd.ver_min = min;
  2380. fw_cmd.ver_build = build;
  2381. fw_cmd.ver_sub = sub;
  2382. fw_cmd.hdr.checksum = 0;
  2383. memcpy(fw_cmd.driver_string, driver_ver, len);
  2384. fw_cmd.hdr.checksum = ixgbe_calculate_checksum((u8 *)&fw_cmd,
  2385. (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));
  2386. for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
  2387. ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
  2388. sizeof(fw_cmd),
  2389. IXGBE_HI_COMMAND_TIMEOUT,
  2390. true);
  2391. if (ret_val)
  2392. continue;
  2393. if (fw_cmd.hdr.cmd_or_resp.ret_status !=
  2394. FW_CEM_RESP_STATUS_SUCCESS)
  2395. return IXGBE_ERR_HOST_INTERFACE_COMMAND;
  2396. return 0;
  2397. }
  2398. return ret_val;
  2399. }
  2400. /** ixgbe_get_lcd_x550em - Determine lowest common denominator
  2401. * @hw: pointer to hardware structure
  2402. * @lcd_speed: pointer to lowest common link speed
  2403. *
  2404. * Determine lowest common link speed with link partner.
  2405. **/
  2406. static s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw,
  2407. ixgbe_link_speed *lcd_speed)
  2408. {
  2409. u16 an_lp_status;
  2410. s32 status;
  2411. u16 word = hw->eeprom.ctrl_word_3;
  2412. *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
  2413. status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
  2414. MDIO_MMD_AN,
  2415. &an_lp_status);
  2416. if (status)
  2417. return status;
  2418. /* If link partner advertised 1G, return 1G */
  2419. if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
  2420. *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
  2421. return status;
  2422. }
  2423. /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
  2424. if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
  2425. (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
  2426. return status;
  2427. /* Link partner not capable of lower speeds, return 10G */
  2428. *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
  2429. return status;
  2430. }
  2431. /**
  2432. * ixgbe_setup_fc_x550em - Set up flow control
  2433. * @hw: pointer to hardware structure
  2434. */
  2435. static s32 ixgbe_setup_fc_x550em(struct ixgbe_hw *hw)
  2436. {
  2437. bool pause, asm_dir;
  2438. u32 reg_val;
  2439. s32 rc = 0;
  2440. /* Validate the requested mode */
  2441. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  2442. hw_err(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
  2443. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  2444. }
  2445. /* 10gig parts do not have a word in the EEPROM to determine the
  2446. * default flow control setting, so we explicitly set it to full.
  2447. */
  2448. if (hw->fc.requested_mode == ixgbe_fc_default)
  2449. hw->fc.requested_mode = ixgbe_fc_full;
  2450. /* Determine PAUSE and ASM_DIR bits. */
  2451. switch (hw->fc.requested_mode) {
  2452. case ixgbe_fc_none:
  2453. pause = false;
  2454. asm_dir = false;
  2455. break;
  2456. case ixgbe_fc_tx_pause:
  2457. pause = false;
  2458. asm_dir = true;
  2459. break;
  2460. case ixgbe_fc_rx_pause:
  2461. /* Rx Flow control is enabled and Tx Flow control is
  2462. * disabled by software override. Since there really
  2463. * isn't a way to advertise that we are capable of RX
  2464. * Pause ONLY, we will advertise that we support both
  2465. * symmetric and asymmetric Rx PAUSE, as such we fall
  2466. * through to the fc_full statement. Later, we will
  2467. * disable the adapter's ability to send PAUSE frames.
  2468. */
  2469. /* Fallthrough */
  2470. case ixgbe_fc_full:
  2471. pause = true;
  2472. asm_dir = true;
  2473. break;
  2474. default:
  2475. hw_err(hw, "Flow control param set incorrectly\n");
  2476. return IXGBE_ERR_CONFIG;
  2477. }
  2478. switch (hw->device_id) {
  2479. case IXGBE_DEV_ID_X550EM_X_KR:
  2480. case IXGBE_DEV_ID_X550EM_A_KR:
  2481. case IXGBE_DEV_ID_X550EM_A_KR_L:
  2482. rc = hw->mac.ops.read_iosf_sb_reg(hw,
  2483. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  2484. IXGBE_SB_IOSF_TARGET_KR_PHY,
  2485. &reg_val);
  2486. if (rc)
  2487. return rc;
  2488. reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  2489. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
  2490. if (pause)
  2491. reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
  2492. if (asm_dir)
  2493. reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  2494. rc = hw->mac.ops.write_iosf_sb_reg(hw,
  2495. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  2496. IXGBE_SB_IOSF_TARGET_KR_PHY,
  2497. reg_val);
  2498. /* This device does not fully support AN. */
  2499. hw->fc.disable_fc_autoneg = true;
  2500. break;
  2501. case IXGBE_DEV_ID_X550EM_X_XFI:
  2502. hw->fc.disable_fc_autoneg = true;
  2503. break;
  2504. default:
  2505. break;
  2506. }
  2507. return rc;
  2508. }
  2509. /**
  2510. * ixgbe_fc_autoneg_backplane_x550em_a - Enable flow control IEEE clause 37
  2511. * @hw: pointer to hardware structure
  2512. **/
  2513. static void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *hw)
  2514. {
  2515. u32 link_s1, lp_an_page_low, an_cntl_1;
  2516. s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  2517. ixgbe_link_speed speed;
  2518. bool link_up;
  2519. /* AN should have completed when the cable was plugged in.
  2520. * Look for reasons to bail out. Bail out if:
  2521. * - FC autoneg is disabled, or if
  2522. * - link is not up.
  2523. */
  2524. if (hw->fc.disable_fc_autoneg) {
  2525. hw_err(hw, "Flow control autoneg is disabled");
  2526. goto out;
  2527. }
  2528. hw->mac.ops.check_link(hw, &speed, &link_up, false);
  2529. if (!link_up) {
  2530. hw_err(hw, "The link is down");
  2531. goto out;
  2532. }
  2533. /* Check at auto-negotiation has completed */
  2534. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2535. IXGBE_KRM_LINK_S1(hw->bus.lan_id),
  2536. IXGBE_SB_IOSF_TARGET_KR_PHY, &link_s1);
  2537. if (status || (link_s1 & IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE) == 0) {
  2538. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  2539. status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  2540. goto out;
  2541. }
  2542. /* Read the 10g AN autoc and LP ability registers and resolve
  2543. * local flow control settings accordingly
  2544. */
  2545. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2546. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  2547. IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl_1);
  2548. if (status) {
  2549. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  2550. goto out;
  2551. }
  2552. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2553. IXGBE_KRM_LP_BASE_PAGE_HIGH(hw->bus.lan_id),
  2554. IXGBE_SB_IOSF_TARGET_KR_PHY, &lp_an_page_low);
  2555. if (status) {
  2556. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  2557. goto out;
  2558. }
  2559. status = ixgbe_negotiate_fc(hw, an_cntl_1, lp_an_page_low,
  2560. IXGBE_KRM_AN_CNTL_1_SYM_PAUSE,
  2561. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE,
  2562. IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE,
  2563. IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE);
  2564. out:
  2565. if (!status) {
  2566. hw->fc.fc_was_autonegged = true;
  2567. } else {
  2568. hw->fc.fc_was_autonegged = false;
  2569. hw->fc.current_mode = hw->fc.requested_mode;
  2570. }
  2571. }
  2572. /**
  2573. * ixgbe_fc_autoneg_fiber_x550em_a - passthrough FC settings
  2574. * @hw: pointer to hardware structure
  2575. **/
  2576. static void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *hw)
  2577. {
  2578. hw->fc.fc_was_autonegged = false;
  2579. hw->fc.current_mode = hw->fc.requested_mode;
  2580. }
  2581. /** ixgbe_enter_lplu_x550em - Transition to low power states
  2582. * @hw: pointer to hardware structure
  2583. *
  2584. * Configures Low Power Link Up on transition to low power states
  2585. * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting
  2586. * the X557 PHY immediately prior to entering LPLU.
  2587. **/
  2588. static s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
  2589. {
  2590. u16 an_10g_cntl_reg, autoneg_reg, speed;
  2591. s32 status;
  2592. ixgbe_link_speed lcd_speed;
  2593. u32 save_autoneg;
  2594. bool link_up;
  2595. /* If blocked by MNG FW, then don't restart AN */
  2596. if (ixgbe_check_reset_blocked(hw))
  2597. return 0;
  2598. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2599. if (status)
  2600. return status;
  2601. status = hw->eeprom.ops.read(hw, NVM_INIT_CTRL_3,
  2602. &hw->eeprom.ctrl_word_3);
  2603. if (status)
  2604. return status;
  2605. /* If link is down, LPLU disabled in NVM, WoL disabled, or
  2606. * manageability disabled, then force link down by entering
  2607. * low power mode.
  2608. */
  2609. if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
  2610. !(hw->wol_enabled || ixgbe_mng_present(hw)))
  2611. return ixgbe_set_copper_phy_power(hw, false);
  2612. /* Determine LCD */
  2613. status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
  2614. if (status)
  2615. return status;
  2616. /* If no valid LCD link speed, then force link down and exit. */
  2617. if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
  2618. return ixgbe_set_copper_phy_power(hw, false);
  2619. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
  2620. MDIO_MMD_AN,
  2621. &speed);
  2622. if (status)
  2623. return status;
  2624. /* If no link now, speed is invalid so take link down */
  2625. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2626. if (status)
  2627. return ixgbe_set_copper_phy_power(hw, false);
  2628. /* clear everything but the speed bits */
  2629. speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
  2630. /* If current speed is already LCD, then exit. */
  2631. if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
  2632. (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
  2633. ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
  2634. (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
  2635. return status;
  2636. /* Clear AN completed indication */
  2637. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
  2638. MDIO_MMD_AN,
  2639. &autoneg_reg);
  2640. if (status)
  2641. return status;
  2642. status = hw->phy.ops.read_reg(hw, MDIO_AN_10GBT_CTRL,
  2643. MDIO_MMD_AN,
  2644. &an_10g_cntl_reg);
  2645. if (status)
  2646. return status;
  2647. status = hw->phy.ops.read_reg(hw,
  2648. IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
  2649. MDIO_MMD_AN,
  2650. &autoneg_reg);
  2651. if (status)
  2652. return status;
  2653. save_autoneg = hw->phy.autoneg_advertised;
  2654. /* Setup link at least common link speed */
  2655. status = hw->mac.ops.setup_link(hw, lcd_speed, false);
  2656. /* restore autoneg from before setting lplu speed */
  2657. hw->phy.autoneg_advertised = save_autoneg;
  2658. return status;
  2659. }
  2660. /**
  2661. * ixgbe_reset_phy_fw - Reset firmware-controlled PHYs
  2662. * @hw: pointer to hardware structure
  2663. */
  2664. static s32 ixgbe_reset_phy_fw(struct ixgbe_hw *hw)
  2665. {
  2666. u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
  2667. s32 rc;
  2668. if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
  2669. return 0;
  2670. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_PHY_SW_RESET, &store);
  2671. if (rc)
  2672. return rc;
  2673. memset(store, 0, sizeof(store));
  2674. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_INIT_PHY, &store);
  2675. if (rc)
  2676. return rc;
  2677. return ixgbe_setup_fw_link(hw);
  2678. }
  2679. /**
  2680. * ixgbe_check_overtemp_fw - Check firmware-controlled PHYs for overtemp
  2681. * @hw: pointer to hardware structure
  2682. */
  2683. static s32 ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
  2684. {
  2685. u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
  2686. s32 rc;
  2687. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &store);
  2688. if (rc)
  2689. return rc;
  2690. if (store[0] & FW_PHY_ACT_GET_LINK_INFO_TEMP) {
  2691. ixgbe_shutdown_fw_phy(hw);
  2692. return IXGBE_ERR_OVERTEMP;
  2693. }
  2694. return 0;
  2695. }
  2696. /**
  2697. * ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
  2698. * @hw: pointer to hardware structure
  2699. *
  2700. * Read NW_MNG_IF_SEL register and save field values.
  2701. */
  2702. static void ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
  2703. {
  2704. /* Save NW management interface connected on board. This is used
  2705. * to determine internal PHY mode.
  2706. */
  2707. hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
  2708. /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
  2709. * PHY address. This register field was has only been used for X552.
  2710. */
  2711. if (hw->mac.type == ixgbe_mac_x550em_a &&
  2712. hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
  2713. hw->phy.mdio.prtad = (hw->phy.nw_mng_if_sel &
  2714. IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
  2715. IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
  2716. }
  2717. }
  2718. /** ixgbe_init_phy_ops_X550em - PHY/SFP specific init
  2719. * @hw: pointer to hardware structure
  2720. *
  2721. * Initialize any function pointers that were not able to be
  2722. * set during init_shared_code because the PHY/SFP type was
  2723. * not known. Perform the SFP init if necessary.
  2724. **/
  2725. static s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
  2726. {
  2727. struct ixgbe_phy_info *phy = &hw->phy;
  2728. s32 ret_val;
  2729. hw->mac.ops.set_lan_id(hw);
  2730. ixgbe_read_mng_if_sel_x550em(hw);
  2731. if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
  2732. phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
  2733. ixgbe_setup_mux_ctl(hw);
  2734. }
  2735. /* Identify the PHY or SFP module */
  2736. ret_val = phy->ops.identify(hw);
  2737. if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED ||
  2738. ret_val == IXGBE_ERR_PHY_ADDR_INVALID)
  2739. return ret_val;
  2740. /* Setup function pointers based on detected hardware */
  2741. ixgbe_init_mac_link_ops_X550em(hw);
  2742. if (phy->sfp_type != ixgbe_sfp_type_unknown)
  2743. phy->ops.reset = NULL;
  2744. /* Set functions pointers based on phy type */
  2745. switch (hw->phy.type) {
  2746. case ixgbe_phy_x550em_kx4:
  2747. phy->ops.setup_link = NULL;
  2748. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2749. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2750. break;
  2751. case ixgbe_phy_x550em_kr:
  2752. phy->ops.setup_link = ixgbe_setup_kr_x550em;
  2753. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2754. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2755. break;
  2756. case ixgbe_phy_x550em_xfi:
  2757. /* link is managed by HW */
  2758. phy->ops.setup_link = NULL;
  2759. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2760. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2761. break;
  2762. case ixgbe_phy_x550em_ext_t:
  2763. /* Save NW management interface connected on board. This is used
  2764. * to determine internal PHY mode
  2765. */
  2766. phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
  2767. /* If internal link mode is XFI, then setup iXFI internal link,
  2768. * else setup KR now.
  2769. */
  2770. phy->ops.setup_internal_link =
  2771. ixgbe_setup_internal_phy_t_x550em;
  2772. /* setup SW LPLU only for first revision */
  2773. if (hw->mac.type == ixgbe_mac_X550EM_x &&
  2774. !(IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0)) &
  2775. IXGBE_FUSES0_REV_MASK))
  2776. phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
  2777. phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
  2778. phy->ops.reset = ixgbe_reset_phy_t_X550em;
  2779. break;
  2780. case ixgbe_phy_sgmii:
  2781. phy->ops.setup_link = NULL;
  2782. break;
  2783. case ixgbe_phy_fw:
  2784. phy->ops.setup_link = ixgbe_setup_fw_link;
  2785. phy->ops.reset = ixgbe_reset_phy_fw;
  2786. break;
  2787. case ixgbe_phy_ext_1g_t:
  2788. phy->ops.setup_link = NULL;
  2789. phy->ops.read_reg = NULL;
  2790. phy->ops.write_reg = NULL;
  2791. phy->ops.reset = NULL;
  2792. break;
  2793. default:
  2794. break;
  2795. }
  2796. return ret_val;
  2797. }
  2798. /** ixgbe_get_media_type_X550em - Get media type
  2799. * @hw: pointer to hardware structure
  2800. *
  2801. * Returns the media type (fiber, copper, backplane)
  2802. *
  2803. */
  2804. static enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
  2805. {
  2806. enum ixgbe_media_type media_type;
  2807. /* Detect if there is a copper PHY attached. */
  2808. switch (hw->device_id) {
  2809. case IXGBE_DEV_ID_X550EM_A_SGMII:
  2810. case IXGBE_DEV_ID_X550EM_A_SGMII_L:
  2811. hw->phy.type = ixgbe_phy_sgmii;
  2812. /* Fallthrough */
  2813. case IXGBE_DEV_ID_X550EM_X_KR:
  2814. case IXGBE_DEV_ID_X550EM_X_KX4:
  2815. case IXGBE_DEV_ID_X550EM_X_XFI:
  2816. case IXGBE_DEV_ID_X550EM_A_KR:
  2817. case IXGBE_DEV_ID_X550EM_A_KR_L:
  2818. media_type = ixgbe_media_type_backplane;
  2819. break;
  2820. case IXGBE_DEV_ID_X550EM_X_SFP:
  2821. case IXGBE_DEV_ID_X550EM_A_SFP:
  2822. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  2823. media_type = ixgbe_media_type_fiber;
  2824. break;
  2825. case IXGBE_DEV_ID_X550EM_X_1G_T:
  2826. case IXGBE_DEV_ID_X550EM_X_10G_T:
  2827. case IXGBE_DEV_ID_X550EM_A_10G_T:
  2828. case IXGBE_DEV_ID_X550EM_A_1G_T:
  2829. case IXGBE_DEV_ID_X550EM_A_1G_T_L:
  2830. media_type = ixgbe_media_type_copper;
  2831. break;
  2832. default:
  2833. media_type = ixgbe_media_type_unknown;
  2834. break;
  2835. }
  2836. return media_type;
  2837. }
  2838. /** ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
  2839. ** @hw: pointer to hardware structure
  2840. **/
  2841. static s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
  2842. {
  2843. s32 status;
  2844. u16 reg;
  2845. status = hw->phy.ops.read_reg(hw,
  2846. IXGBE_MDIO_TX_VENDOR_ALARMS_3,
  2847. MDIO_MMD_PMAPMD,
  2848. &reg);
  2849. if (status)
  2850. return status;
  2851. /* If PHY FW reset completed bit is set then this is the first
  2852. * SW instance after a power on so the PHY FW must be un-stalled.
  2853. */
  2854. if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
  2855. status = hw->phy.ops.read_reg(hw,
  2856. IXGBE_MDIO_GLOBAL_RES_PR_10,
  2857. MDIO_MMD_VEND1,
  2858. &reg);
  2859. if (status)
  2860. return status;
  2861. reg &= ~IXGBE_MDIO_POWER_UP_STALL;
  2862. status = hw->phy.ops.write_reg(hw,
  2863. IXGBE_MDIO_GLOBAL_RES_PR_10,
  2864. MDIO_MMD_VEND1,
  2865. reg);
  2866. if (status)
  2867. return status;
  2868. }
  2869. return status;
  2870. }
  2871. /**
  2872. * ixgbe_set_mdio_speed - Set MDIO clock speed
  2873. * @hw: pointer to hardware structure
  2874. */
  2875. static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
  2876. {
  2877. u32 hlreg0;
  2878. switch (hw->device_id) {
  2879. case IXGBE_DEV_ID_X550EM_X_10G_T:
  2880. case IXGBE_DEV_ID_X550EM_A_SGMII:
  2881. case IXGBE_DEV_ID_X550EM_A_SGMII_L:
  2882. case IXGBE_DEV_ID_X550EM_A_10G_T:
  2883. case IXGBE_DEV_ID_X550EM_A_SFP:
  2884. /* Config MDIO clock speed before the first MDIO PHY access */
  2885. hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
  2886. hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
  2887. IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
  2888. break;
  2889. case IXGBE_DEV_ID_X550EM_A_1G_T:
  2890. case IXGBE_DEV_ID_X550EM_A_1G_T_L:
  2891. /* Select fast MDIO clock speed for these devices */
  2892. hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
  2893. hlreg0 |= IXGBE_HLREG0_MDCSPD;
  2894. IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
  2895. break;
  2896. default:
  2897. break;
  2898. }
  2899. }
  2900. /** ixgbe_reset_hw_X550em - Perform hardware reset
  2901. ** @hw: pointer to hardware structure
  2902. **
  2903. ** Resets the hardware by resetting the transmit and receive units, masks
  2904. ** and clears all interrupts, perform a PHY reset, and perform a link (MAC)
  2905. ** reset.
  2906. **/
  2907. static s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
  2908. {
  2909. ixgbe_link_speed link_speed;
  2910. s32 status;
  2911. u32 ctrl = 0;
  2912. u32 i;
  2913. bool link_up = false;
  2914. u32 swfw_mask = hw->phy.phy_semaphore_mask;
  2915. /* Call adapter stop to disable Tx/Rx and clear interrupts */
  2916. status = hw->mac.ops.stop_adapter(hw);
  2917. if (status)
  2918. return status;
  2919. /* flush pending Tx transactions */
  2920. ixgbe_clear_tx_pending(hw);
  2921. /* PHY ops must be identified and initialized prior to reset */
  2922. status = hw->phy.ops.init(hw);
  2923. if (status == IXGBE_ERR_SFP_NOT_SUPPORTED ||
  2924. status == IXGBE_ERR_PHY_ADDR_INVALID)
  2925. return status;
  2926. /* start the external PHY */
  2927. if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
  2928. status = ixgbe_init_ext_t_x550em(hw);
  2929. if (status)
  2930. return status;
  2931. }
  2932. /* Setup SFP module if there is one present. */
  2933. if (hw->phy.sfp_setup_needed) {
  2934. status = hw->mac.ops.setup_sfp(hw);
  2935. hw->phy.sfp_setup_needed = false;
  2936. }
  2937. if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
  2938. return status;
  2939. /* Reset PHY */
  2940. if (!hw->phy.reset_disable && hw->phy.ops.reset)
  2941. hw->phy.ops.reset(hw);
  2942. mac_reset_top:
  2943. /* Issue global reset to the MAC. Needs to be SW reset if link is up.
  2944. * If link reset is used when link is up, it might reset the PHY when
  2945. * mng is using it. If link is down or the flag to force full link
  2946. * reset is set, then perform link reset.
  2947. */
  2948. ctrl = IXGBE_CTRL_LNK_RST;
  2949. if (!hw->force_full_reset) {
  2950. hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
  2951. if (link_up)
  2952. ctrl = IXGBE_CTRL_RST;
  2953. }
  2954. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  2955. if (status) {
  2956. hw_dbg(hw, "semaphore failed with %d", status);
  2957. return IXGBE_ERR_SWFW_SYNC;
  2958. }
  2959. ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
  2960. IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
  2961. IXGBE_WRITE_FLUSH(hw);
  2962. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  2963. usleep_range(1000, 1200);
  2964. /* Poll for reset bit to self-clear meaning reset is complete */
  2965. for (i = 0; i < 10; i++) {
  2966. ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
  2967. if (!(ctrl & IXGBE_CTRL_RST_MASK))
  2968. break;
  2969. udelay(1);
  2970. }
  2971. if (ctrl & IXGBE_CTRL_RST_MASK) {
  2972. status = IXGBE_ERR_RESET_FAILED;
  2973. hw_dbg(hw, "Reset polling failed to complete.\n");
  2974. }
  2975. msleep(50);
  2976. /* Double resets are required for recovery from certain error
  2977. * clear the multicast table. Also reset num_rar_entries to 128,
  2978. * since we modify this value when programming the SAN MAC address.
  2979. */
  2980. if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
  2981. hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
  2982. goto mac_reset_top;
  2983. }
  2984. /* Store the permanent mac address */
  2985. hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
  2986. /* Store MAC address from RAR0, clear receive address registers, and
  2987. * clear the multicast table. Also reset num_rar_entries to 128,
  2988. * since we modify this value when programming the SAN MAC address.
  2989. */
  2990. hw->mac.num_rar_entries = 128;
  2991. hw->mac.ops.init_rx_addrs(hw);
  2992. ixgbe_set_mdio_speed(hw);
  2993. if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
  2994. ixgbe_setup_mux_ctl(hw);
  2995. return status;
  2996. }
  2997. /** ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype
  2998. * anti-spoofing
  2999. * @hw: pointer to hardware structure
  3000. * @enable: enable or disable switch for Ethertype anti-spoofing
  3001. * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
  3002. **/
  3003. static void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
  3004. bool enable, int vf)
  3005. {
  3006. int vf_target_reg = vf >> 3;
  3007. int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
  3008. u32 pfvfspoof;
  3009. pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
  3010. if (enable)
  3011. pfvfspoof |= BIT(vf_target_shift);
  3012. else
  3013. pfvfspoof &= ~BIT(vf_target_shift);
  3014. IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
  3015. }
  3016. /** ixgbe_set_source_address_pruning_X550 - Enable/Disbale src address pruning
  3017. * @hw: pointer to hardware structure
  3018. * @enable: enable or disable source address pruning
  3019. * @pool: Rx pool to set source address pruning for
  3020. **/
  3021. static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,
  3022. bool enable,
  3023. unsigned int pool)
  3024. {
  3025. u64 pfflp;
  3026. /* max rx pool is 63 */
  3027. if (pool > 63)
  3028. return;
  3029. pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
  3030. pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
  3031. if (enable)
  3032. pfflp |= (1ULL << pool);
  3033. else
  3034. pfflp &= ~(1ULL << pool);
  3035. IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
  3036. IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
  3037. }
  3038. /**
  3039. * ixgbe_setup_fc_backplane_x550em_a - Set up flow control
  3040. * @hw: pointer to hardware structure
  3041. *
  3042. * Called at init time to set up flow control.
  3043. **/
  3044. static s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *hw)
  3045. {
  3046. s32 status = 0;
  3047. u32 an_cntl = 0;
  3048. /* Validate the requested mode */
  3049. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  3050. hw_err(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
  3051. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  3052. }
  3053. if (hw->fc.requested_mode == ixgbe_fc_default)
  3054. hw->fc.requested_mode = ixgbe_fc_full;
  3055. /* Set up the 1G and 10G flow control advertisement registers so the
  3056. * HW will be able to do FC autoneg once the cable is plugged in. If
  3057. * we link at 10G, the 1G advertisement is harmless and vice versa.
  3058. */
  3059. status = hw->mac.ops.read_iosf_sb_reg(hw,
  3060. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  3061. IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl);
  3062. if (status) {
  3063. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  3064. return status;
  3065. }
  3066. /* The possible values of fc.requested_mode are:
  3067. * 0: Flow control is completely disabled
  3068. * 1: Rx flow control is enabled (we can receive pause frames,
  3069. * but not send pause frames).
  3070. * 2: Tx flow control is enabled (we can send pause frames but
  3071. * we do not support receiving pause frames).
  3072. * 3: Both Rx and Tx flow control (symmetric) are enabled.
  3073. * other: Invalid.
  3074. */
  3075. switch (hw->fc.requested_mode) {
  3076. case ixgbe_fc_none:
  3077. /* Flow control completely disabled by software override. */
  3078. an_cntl &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  3079. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
  3080. break;
  3081. case ixgbe_fc_tx_pause:
  3082. /* Tx Flow control is enabled, and Rx Flow control is
  3083. * disabled by software override.
  3084. */
  3085. an_cntl |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  3086. an_cntl &= ~IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
  3087. break;
  3088. case ixgbe_fc_rx_pause:
  3089. /* Rx Flow control is enabled and Tx Flow control is
  3090. * disabled by software override. Since there really
  3091. * isn't a way to advertise that we are capable of RX
  3092. * Pause ONLY, we will advertise that we support both
  3093. * symmetric and asymmetric Rx PAUSE, as such we fall
  3094. * through to the fc_full statement. Later, we will
  3095. * disable the adapter's ability to send PAUSE frames.
  3096. */
  3097. case ixgbe_fc_full:
  3098. /* Flow control (both Rx and Tx) is enabled by SW override. */
  3099. an_cntl |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  3100. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  3101. break;
  3102. default:
  3103. hw_err(hw, "Flow control param set incorrectly\n");
  3104. return IXGBE_ERR_CONFIG;
  3105. }
  3106. status = hw->mac.ops.write_iosf_sb_reg(hw,
  3107. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  3108. IXGBE_SB_IOSF_TARGET_KR_PHY, an_cntl);
  3109. /* Restart auto-negotiation. */
  3110. status = ixgbe_restart_an_internal_phy_x550em(hw);
  3111. return status;
  3112. }
  3113. /**
  3114. * ixgbe_set_mux - Set mux for port 1 access with CS4227
  3115. * @hw: pointer to hardware structure
  3116. * @state: set mux if 1, clear if 0
  3117. */
  3118. static void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
  3119. {
  3120. u32 esdp;
  3121. if (!hw->bus.lan_id)
  3122. return;
  3123. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  3124. if (state)
  3125. esdp |= IXGBE_ESDP_SDP1;
  3126. else
  3127. esdp &= ~IXGBE_ESDP_SDP1;
  3128. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  3129. IXGBE_WRITE_FLUSH(hw);
  3130. }
  3131. /**
  3132. * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
  3133. * @hw: pointer to hardware structure
  3134. * @mask: Mask to specify which semaphore to acquire
  3135. *
  3136. * Acquires the SWFW semaphore and sets the I2C MUX
  3137. */
  3138. static s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
  3139. {
  3140. s32 status;
  3141. status = ixgbe_acquire_swfw_sync_X540(hw, mask);
  3142. if (status)
  3143. return status;
  3144. if (mask & IXGBE_GSSR_I2C_MASK)
  3145. ixgbe_set_mux(hw, 1);
  3146. return 0;
  3147. }
  3148. /**
  3149. * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
  3150. * @hw: pointer to hardware structure
  3151. * @mask: Mask to specify which semaphore to release
  3152. *
  3153. * Releases the SWFW semaphore and sets the I2C MUX
  3154. */
  3155. static void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
  3156. {
  3157. if (mask & IXGBE_GSSR_I2C_MASK)
  3158. ixgbe_set_mux(hw, 0);
  3159. ixgbe_release_swfw_sync_X540(hw, mask);
  3160. }
  3161. /**
  3162. * ixgbe_acquire_swfw_sync_x550em_a - Acquire SWFW semaphore
  3163. * @hw: pointer to hardware structure
  3164. * @mask: Mask to specify which semaphore to acquire
  3165. *
  3166. * Acquires the SWFW semaphore and get the shared PHY token as needed
  3167. */
  3168. static s32 ixgbe_acquire_swfw_sync_x550em_a(struct ixgbe_hw *hw, u32 mask)
  3169. {
  3170. u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
  3171. int retries = FW_PHY_TOKEN_RETRIES;
  3172. s32 status;
  3173. while (--retries) {
  3174. status = 0;
  3175. if (hmask)
  3176. status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
  3177. if (status)
  3178. return status;
  3179. if (!(mask & IXGBE_GSSR_TOKEN_SM))
  3180. return 0;
  3181. status = ixgbe_get_phy_token(hw);
  3182. if (!status)
  3183. return 0;
  3184. if (hmask)
  3185. ixgbe_release_swfw_sync_X540(hw, hmask);
  3186. if (status != IXGBE_ERR_TOKEN_RETRY)
  3187. return status;
  3188. msleep(FW_PHY_TOKEN_DELAY);
  3189. }
  3190. return status;
  3191. }
  3192. /**
  3193. * ixgbe_release_swfw_sync_x550em_a - Release SWFW semaphore
  3194. * @hw: pointer to hardware structure
  3195. * @mask: Mask to specify which semaphore to release
  3196. *
  3197. * Release the SWFW semaphore and puts the shared PHY token as needed
  3198. */
  3199. static void ixgbe_release_swfw_sync_x550em_a(struct ixgbe_hw *hw, u32 mask)
  3200. {
  3201. u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
  3202. if (mask & IXGBE_GSSR_TOKEN_SM)
  3203. ixgbe_put_phy_token(hw);
  3204. if (hmask)
  3205. ixgbe_release_swfw_sync_X540(hw, hmask);
  3206. }
  3207. /**
  3208. * ixgbe_read_phy_reg_x550a - Reads specified PHY register
  3209. * @hw: pointer to hardware structure
  3210. * @reg_addr: 32 bit address of PHY register to read
  3211. * @device_type: 5 bit device type
  3212. * @phy_data: Pointer to read data from PHY register
  3213. *
  3214. * Reads a value from a specified PHY register using the SWFW lock and PHY
  3215. * Token. The PHY Token is needed since the MDIO is shared between to MAC
  3216. * instances.
  3217. */
  3218. static s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  3219. u32 device_type, u16 *phy_data)
  3220. {
  3221. u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
  3222. s32 status;
  3223. if (hw->mac.ops.acquire_swfw_sync(hw, mask))
  3224. return IXGBE_ERR_SWFW_SYNC;
  3225. status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
  3226. hw->mac.ops.release_swfw_sync(hw, mask);
  3227. return status;
  3228. }
  3229. /**
  3230. * ixgbe_write_phy_reg_x550a - Writes specified PHY register
  3231. * @hw: pointer to hardware structure
  3232. * @reg_addr: 32 bit PHY register to write
  3233. * @device_type: 5 bit device type
  3234. * @phy_data: Data to write to the PHY register
  3235. *
  3236. * Writes a value to specified PHY register using the SWFW lock and PHY Token.
  3237. * The PHY Token is needed since the MDIO is shared between to MAC instances.
  3238. */
  3239. static s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  3240. u32 device_type, u16 phy_data)
  3241. {
  3242. u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
  3243. s32 status;
  3244. if (hw->mac.ops.acquire_swfw_sync(hw, mask))
  3245. return IXGBE_ERR_SWFW_SYNC;
  3246. status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type, phy_data);
  3247. hw->mac.ops.release_swfw_sync(hw, mask);
  3248. return status;
  3249. }
  3250. #define X550_COMMON_MAC \
  3251. .init_hw = &ixgbe_init_hw_generic, \
  3252. .start_hw = &ixgbe_start_hw_X540, \
  3253. .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic, \
  3254. .enable_rx_dma = &ixgbe_enable_rx_dma_generic, \
  3255. .get_mac_addr = &ixgbe_get_mac_addr_generic, \
  3256. .get_device_caps = &ixgbe_get_device_caps_generic, \
  3257. .stop_adapter = &ixgbe_stop_adapter_generic, \
  3258. .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie, \
  3259. .read_analog_reg8 = NULL, \
  3260. .write_analog_reg8 = NULL, \
  3261. .set_rxpba = &ixgbe_set_rxpba_generic, \
  3262. .check_link = &ixgbe_check_mac_link_generic, \
  3263. .blink_led_start = &ixgbe_blink_led_start_X540, \
  3264. .blink_led_stop = &ixgbe_blink_led_stop_X540, \
  3265. .set_rar = &ixgbe_set_rar_generic, \
  3266. .clear_rar = &ixgbe_clear_rar_generic, \
  3267. .set_vmdq = &ixgbe_set_vmdq_generic, \
  3268. .set_vmdq_san_mac = &ixgbe_set_vmdq_san_mac_generic, \
  3269. .clear_vmdq = &ixgbe_clear_vmdq_generic, \
  3270. .init_rx_addrs = &ixgbe_init_rx_addrs_generic, \
  3271. .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic, \
  3272. .enable_mc = &ixgbe_enable_mc_generic, \
  3273. .disable_mc = &ixgbe_disable_mc_generic, \
  3274. .clear_vfta = &ixgbe_clear_vfta_generic, \
  3275. .set_vfta = &ixgbe_set_vfta_generic, \
  3276. .fc_enable = &ixgbe_fc_enable_generic, \
  3277. .set_fw_drv_ver = &ixgbe_set_fw_drv_ver_x550, \
  3278. .init_uta_tables = &ixgbe_init_uta_tables_generic, \
  3279. .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing, \
  3280. .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing, \
  3281. .set_source_address_pruning = \
  3282. &ixgbe_set_source_address_pruning_X550, \
  3283. .set_ethertype_anti_spoofing = \
  3284. &ixgbe_set_ethertype_anti_spoofing_X550, \
  3285. .disable_rx_buff = &ixgbe_disable_rx_buff_generic, \
  3286. .enable_rx_buff = &ixgbe_enable_rx_buff_generic, \
  3287. .get_thermal_sensor_data = NULL, \
  3288. .init_thermal_sensor_thresh = NULL, \
  3289. .enable_rx = &ixgbe_enable_rx_generic, \
  3290. .disable_rx = &ixgbe_disable_rx_x550, \
  3291. static const struct ixgbe_mac_operations mac_ops_X550 = {
  3292. X550_COMMON_MAC
  3293. .led_on = ixgbe_led_on_generic,
  3294. .led_off = ixgbe_led_off_generic,
  3295. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3296. .reset_hw = &ixgbe_reset_hw_X540,
  3297. .get_media_type = &ixgbe_get_media_type_X540,
  3298. .get_san_mac_addr = &ixgbe_get_san_mac_addr_generic,
  3299. .get_wwn_prefix = &ixgbe_get_wwn_prefix_generic,
  3300. .setup_link = &ixgbe_setup_mac_link_X540,
  3301. .get_link_capabilities = &ixgbe_get_copper_link_capabilities_generic,
  3302. .get_bus_info = &ixgbe_get_bus_info_generic,
  3303. .setup_sfp = NULL,
  3304. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X540,
  3305. .release_swfw_sync = &ixgbe_release_swfw_sync_X540,
  3306. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  3307. .prot_autoc_read = prot_autoc_read_generic,
  3308. .prot_autoc_write = prot_autoc_write_generic,
  3309. .setup_fc = ixgbe_setup_fc_generic,
  3310. .fc_autoneg = ixgbe_fc_autoneg,
  3311. };
  3312. static const struct ixgbe_mac_operations mac_ops_X550EM_x = {
  3313. X550_COMMON_MAC
  3314. .led_on = ixgbe_led_on_t_x550em,
  3315. .led_off = ixgbe_led_off_t_x550em,
  3316. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3317. .reset_hw = &ixgbe_reset_hw_X550em,
  3318. .get_media_type = &ixgbe_get_media_type_X550em,
  3319. .get_san_mac_addr = NULL,
  3320. .get_wwn_prefix = NULL,
  3321. .setup_link = &ixgbe_setup_mac_link_X540,
  3322. .get_link_capabilities = &ixgbe_get_link_capabilities_X550em,
  3323. .get_bus_info = &ixgbe_get_bus_info_X550em,
  3324. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3325. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X550em,
  3326. .release_swfw_sync = &ixgbe_release_swfw_sync_X550em,
  3327. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  3328. .setup_fc = NULL, /* defined later */
  3329. .fc_autoneg = ixgbe_fc_autoneg,
  3330. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550,
  3331. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550,
  3332. };
  3333. static const struct ixgbe_mac_operations mac_ops_X550EM_x_fw = {
  3334. X550_COMMON_MAC
  3335. .led_on = NULL,
  3336. .led_off = NULL,
  3337. .init_led_link_act = NULL,
  3338. .reset_hw = &ixgbe_reset_hw_X550em,
  3339. .get_media_type = &ixgbe_get_media_type_X550em,
  3340. .get_san_mac_addr = NULL,
  3341. .get_wwn_prefix = NULL,
  3342. .setup_link = &ixgbe_setup_mac_link_X540,
  3343. .get_link_capabilities = &ixgbe_get_link_capabilities_X550em,
  3344. .get_bus_info = &ixgbe_get_bus_info_X550em,
  3345. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3346. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X550em,
  3347. .release_swfw_sync = &ixgbe_release_swfw_sync_X550em,
  3348. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  3349. .setup_fc = NULL,
  3350. .fc_autoneg = ixgbe_fc_autoneg,
  3351. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550,
  3352. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550,
  3353. };
  3354. static const struct ixgbe_mac_operations mac_ops_x550em_a = {
  3355. X550_COMMON_MAC
  3356. .led_on = ixgbe_led_on_t_x550em,
  3357. .led_off = ixgbe_led_off_t_x550em,
  3358. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3359. .reset_hw = ixgbe_reset_hw_X550em,
  3360. .get_media_type = ixgbe_get_media_type_X550em,
  3361. .get_san_mac_addr = NULL,
  3362. .get_wwn_prefix = NULL,
  3363. .setup_link = &ixgbe_setup_mac_link_X540,
  3364. .get_link_capabilities = ixgbe_get_link_capabilities_X550em,
  3365. .get_bus_info = ixgbe_get_bus_info_X550em,
  3366. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3367. .acquire_swfw_sync = ixgbe_acquire_swfw_sync_x550em_a,
  3368. .release_swfw_sync = ixgbe_release_swfw_sync_x550em_a,
  3369. .setup_fc = ixgbe_setup_fc_x550em,
  3370. .fc_autoneg = ixgbe_fc_autoneg,
  3371. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a,
  3372. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a,
  3373. };
  3374. static const struct ixgbe_mac_operations mac_ops_x550em_a_fw = {
  3375. X550_COMMON_MAC
  3376. .led_on = ixgbe_led_on_generic,
  3377. .led_off = ixgbe_led_off_generic,
  3378. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3379. .reset_hw = ixgbe_reset_hw_X550em,
  3380. .get_media_type = ixgbe_get_media_type_X550em,
  3381. .get_san_mac_addr = NULL,
  3382. .get_wwn_prefix = NULL,
  3383. .setup_link = NULL, /* defined later */
  3384. .get_link_capabilities = ixgbe_get_link_capabilities_X550em,
  3385. .get_bus_info = ixgbe_get_bus_info_X550em,
  3386. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3387. .acquire_swfw_sync = ixgbe_acquire_swfw_sync_x550em_a,
  3388. .release_swfw_sync = ixgbe_release_swfw_sync_x550em_a,
  3389. .setup_fc = ixgbe_setup_fc_x550em,
  3390. .fc_autoneg = ixgbe_fc_autoneg,
  3391. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a,
  3392. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a,
  3393. };
  3394. #define X550_COMMON_EEP \
  3395. .read = &ixgbe_read_ee_hostif_X550, \
  3396. .read_buffer = &ixgbe_read_ee_hostif_buffer_X550, \
  3397. .write = &ixgbe_write_ee_hostif_X550, \
  3398. .write_buffer = &ixgbe_write_ee_hostif_buffer_X550, \
  3399. .validate_checksum = &ixgbe_validate_eeprom_checksum_X550, \
  3400. .update_checksum = &ixgbe_update_eeprom_checksum_X550, \
  3401. .calc_checksum = &ixgbe_calc_eeprom_checksum_X550, \
  3402. static const struct ixgbe_eeprom_operations eeprom_ops_X550 = {
  3403. X550_COMMON_EEP
  3404. .init_params = &ixgbe_init_eeprom_params_X550,
  3405. };
  3406. static const struct ixgbe_eeprom_operations eeprom_ops_X550EM_x = {
  3407. X550_COMMON_EEP
  3408. .init_params = &ixgbe_init_eeprom_params_X540,
  3409. };
  3410. #define X550_COMMON_PHY \
  3411. .identify_sfp = &ixgbe_identify_module_generic, \
  3412. .reset = NULL, \
  3413. .setup_link_speed = &ixgbe_setup_phy_link_speed_generic, \
  3414. .read_i2c_byte = &ixgbe_read_i2c_byte_generic, \
  3415. .write_i2c_byte = &ixgbe_write_i2c_byte_generic, \
  3416. .read_i2c_sff8472 = &ixgbe_read_i2c_sff8472_generic, \
  3417. .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic, \
  3418. .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic, \
  3419. .setup_link = &ixgbe_setup_phy_link_generic, \
  3420. .set_phy_power = NULL,
  3421. static const struct ixgbe_phy_operations phy_ops_X550 = {
  3422. X550_COMMON_PHY
  3423. .check_overtemp = &ixgbe_tn_check_overtemp,
  3424. .init = NULL,
  3425. .identify = &ixgbe_identify_phy_generic,
  3426. .read_reg = &ixgbe_read_phy_reg_generic,
  3427. .write_reg = &ixgbe_write_phy_reg_generic,
  3428. };
  3429. static const struct ixgbe_phy_operations phy_ops_X550EM_x = {
  3430. X550_COMMON_PHY
  3431. .check_overtemp = &ixgbe_tn_check_overtemp,
  3432. .init = &ixgbe_init_phy_ops_X550em,
  3433. .identify = &ixgbe_identify_phy_x550em,
  3434. .read_reg = &ixgbe_read_phy_reg_generic,
  3435. .write_reg = &ixgbe_write_phy_reg_generic,
  3436. };
  3437. static const struct ixgbe_phy_operations phy_ops_x550em_x_fw = {
  3438. X550_COMMON_PHY
  3439. .check_overtemp = NULL,
  3440. .init = ixgbe_init_phy_ops_X550em,
  3441. .identify = ixgbe_identify_phy_x550em,
  3442. .read_reg = NULL,
  3443. .write_reg = NULL,
  3444. .read_reg_mdi = NULL,
  3445. .write_reg_mdi = NULL,
  3446. };
  3447. static const struct ixgbe_phy_operations phy_ops_x550em_a = {
  3448. X550_COMMON_PHY
  3449. .check_overtemp = &ixgbe_tn_check_overtemp,
  3450. .init = &ixgbe_init_phy_ops_X550em,
  3451. .identify = &ixgbe_identify_phy_x550em,
  3452. .read_reg = &ixgbe_read_phy_reg_x550a,
  3453. .write_reg = &ixgbe_write_phy_reg_x550a,
  3454. .read_reg_mdi = &ixgbe_read_phy_reg_mdi,
  3455. .write_reg_mdi = &ixgbe_write_phy_reg_mdi,
  3456. };
  3457. static const struct ixgbe_phy_operations phy_ops_x550em_a_fw = {
  3458. X550_COMMON_PHY
  3459. .check_overtemp = ixgbe_check_overtemp_fw,
  3460. .init = ixgbe_init_phy_ops_X550em,
  3461. .identify = ixgbe_identify_phy_fw,
  3462. .read_reg = NULL,
  3463. .write_reg = NULL,
  3464. .read_reg_mdi = NULL,
  3465. .write_reg_mdi = NULL,
  3466. };
  3467. static const struct ixgbe_link_operations link_ops_x550em_x = {
  3468. .read_link = &ixgbe_read_i2c_combined_generic,
  3469. .read_link_unlocked = &ixgbe_read_i2c_combined_generic_unlocked,
  3470. .write_link = &ixgbe_write_i2c_combined_generic,
  3471. .write_link_unlocked = &ixgbe_write_i2c_combined_generic_unlocked,
  3472. };
  3473. static const u32 ixgbe_mvals_X550[IXGBE_MVALS_IDX_LIMIT] = {
  3474. IXGBE_MVALS_INIT(X550)
  3475. };
  3476. static const u32 ixgbe_mvals_X550EM_x[IXGBE_MVALS_IDX_LIMIT] = {
  3477. IXGBE_MVALS_INIT(X550EM_x)
  3478. };
  3479. static const u32 ixgbe_mvals_x550em_a[IXGBE_MVALS_IDX_LIMIT] = {
  3480. IXGBE_MVALS_INIT(X550EM_a)
  3481. };
  3482. const struct ixgbe_info ixgbe_X550_info = {
  3483. .mac = ixgbe_mac_X550,
  3484. .get_invariants = &ixgbe_get_invariants_X540,
  3485. .mac_ops = &mac_ops_X550,
  3486. .eeprom_ops = &eeprom_ops_X550,
  3487. .phy_ops = &phy_ops_X550,
  3488. .mbx_ops = &mbx_ops_generic,
  3489. .mvals = ixgbe_mvals_X550,
  3490. };
  3491. const struct ixgbe_info ixgbe_X550EM_x_info = {
  3492. .mac = ixgbe_mac_X550EM_x,
  3493. .get_invariants = &ixgbe_get_invariants_X550_x,
  3494. .mac_ops = &mac_ops_X550EM_x,
  3495. .eeprom_ops = &eeprom_ops_X550EM_x,
  3496. .phy_ops = &phy_ops_X550EM_x,
  3497. .mbx_ops = &mbx_ops_generic,
  3498. .mvals = ixgbe_mvals_X550EM_x,
  3499. .link_ops = &link_ops_x550em_x,
  3500. };
  3501. const struct ixgbe_info ixgbe_x550em_x_fw_info = {
  3502. .mac = ixgbe_mac_X550EM_x,
  3503. .get_invariants = ixgbe_get_invariants_X550_x_fw,
  3504. .mac_ops = &mac_ops_X550EM_x_fw,
  3505. .eeprom_ops = &eeprom_ops_X550EM_x,
  3506. .phy_ops = &phy_ops_x550em_x_fw,
  3507. .mbx_ops = &mbx_ops_generic,
  3508. .mvals = ixgbe_mvals_X550EM_x,
  3509. };
  3510. const struct ixgbe_info ixgbe_x550em_a_info = {
  3511. .mac = ixgbe_mac_x550em_a,
  3512. .get_invariants = &ixgbe_get_invariants_X550_a,
  3513. .mac_ops = &mac_ops_x550em_a,
  3514. .eeprom_ops = &eeprom_ops_X550EM_x,
  3515. .phy_ops = &phy_ops_x550em_a,
  3516. .mbx_ops = &mbx_ops_generic,
  3517. .mvals = ixgbe_mvals_x550em_a,
  3518. };
  3519. const struct ixgbe_info ixgbe_x550em_a_fw_info = {
  3520. .mac = ixgbe_mac_x550em_a,
  3521. .get_invariants = ixgbe_get_invariants_X550_a_fw,
  3522. .mac_ops = &mac_ops_x550em_a_fw,
  3523. .eeprom_ops = &eeprom_ops_X550EM_x,
  3524. .phy_ops = &phy_ops_x550em_a_fw,
  3525. .mbx_ops = &mbx_ops_generic,
  3526. .mvals = ixgbe_mvals_x550em_a,
  3527. };