ixgbe_x550.c 113 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082
  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. hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
  1946. hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
  1947. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1948. return 0;
  1949. }
  1950. /* Link capabilities are based on SFP */
  1951. if (hw->phy.multispeed_fiber)
  1952. *speed = IXGBE_LINK_SPEED_10GB_FULL |
  1953. IXGBE_LINK_SPEED_1GB_FULL;
  1954. else
  1955. *speed = IXGBE_LINK_SPEED_10GB_FULL;
  1956. } else {
  1957. switch (hw->phy.type) {
  1958. case ixgbe_phy_x550em_kx4:
  1959. *speed = IXGBE_LINK_SPEED_1GB_FULL |
  1960. IXGBE_LINK_SPEED_2_5GB_FULL |
  1961. IXGBE_LINK_SPEED_10GB_FULL;
  1962. break;
  1963. case ixgbe_phy_x550em_xfi:
  1964. *speed = IXGBE_LINK_SPEED_1GB_FULL |
  1965. IXGBE_LINK_SPEED_10GB_FULL;
  1966. break;
  1967. case ixgbe_phy_ext_1g_t:
  1968. case ixgbe_phy_sgmii:
  1969. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1970. break;
  1971. case ixgbe_phy_x550em_kr:
  1972. if (hw->mac.type == ixgbe_mac_x550em_a) {
  1973. /* check different backplane modes */
  1974. if (hw->phy.nw_mng_if_sel &
  1975. IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
  1976. *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
  1977. break;
  1978. } else if (hw->device_id ==
  1979. IXGBE_DEV_ID_X550EM_A_KR_L) {
  1980. *speed = IXGBE_LINK_SPEED_1GB_FULL;
  1981. break;
  1982. }
  1983. }
  1984. /* fall through */
  1985. default:
  1986. *speed = IXGBE_LINK_SPEED_10GB_FULL |
  1987. IXGBE_LINK_SPEED_1GB_FULL;
  1988. break;
  1989. }
  1990. *autoneg = true;
  1991. }
  1992. return 0;
  1993. }
  1994. /**
  1995. * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
  1996. * @hw: pointer to hardware structure
  1997. * @lsc: pointer to boolean flag which indicates whether external Base T
  1998. * PHY interrupt is lsc
  1999. *
  2000. * Determime if external Base T PHY interrupt cause is high temperature
  2001. * failure alarm or link status change.
  2002. *
  2003. * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  2004. * failure alarm, else return PHY access status.
  2005. **/
  2006. static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
  2007. {
  2008. u32 status;
  2009. u16 reg;
  2010. *lsc = false;
  2011. /* Vendor alarm triggered */
  2012. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
  2013. MDIO_MMD_VEND1,
  2014. &reg);
  2015. if (status || !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
  2016. return status;
  2017. /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
  2018. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
  2019. MDIO_MMD_VEND1,
  2020. &reg);
  2021. if (status || !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
  2022. IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
  2023. return status;
  2024. /* Global alarm triggered */
  2025. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
  2026. MDIO_MMD_VEND1,
  2027. &reg);
  2028. if (status)
  2029. return status;
  2030. /* If high temperature failure, then return over temp error and exit */
  2031. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
  2032. /* power down the PHY in case the PHY FW didn't already */
  2033. ixgbe_set_copper_phy_power(hw, false);
  2034. return IXGBE_ERR_OVERTEMP;
  2035. }
  2036. if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
  2037. /* device fault alarm triggered */
  2038. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
  2039. MDIO_MMD_VEND1,
  2040. &reg);
  2041. if (status)
  2042. return status;
  2043. /* if device fault was due to high temp alarm handle and exit */
  2044. if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
  2045. /* power down the PHY in case the PHY FW didn't */
  2046. ixgbe_set_copper_phy_power(hw, false);
  2047. return IXGBE_ERR_OVERTEMP;
  2048. }
  2049. }
  2050. /* Vendor alarm 2 triggered */
  2051. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
  2052. MDIO_MMD_AN, &reg);
  2053. if (status || !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
  2054. return status;
  2055. /* link connect/disconnect event occurred */
  2056. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
  2057. MDIO_MMD_AN, &reg);
  2058. if (status)
  2059. return status;
  2060. /* Indicate LSC */
  2061. if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
  2062. *lsc = true;
  2063. return 0;
  2064. }
  2065. /**
  2066. * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
  2067. * @hw: pointer to hardware structure
  2068. *
  2069. * Enable link status change and temperature failure alarm for the external
  2070. * Base T PHY
  2071. *
  2072. * Returns PHY access status
  2073. **/
  2074. static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  2075. {
  2076. u32 status;
  2077. u16 reg;
  2078. bool lsc;
  2079. /* Clear interrupt flags */
  2080. status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  2081. /* Enable link status change alarm */
  2082. /* Enable the LASI interrupts on X552 devices to receive notifications
  2083. * of the link configurations of the external PHY and correspondingly
  2084. * support the configuration of the internal iXFI link, since iXFI does
  2085. * not support auto-negotiation. This is not required for X553 devices
  2086. * having KR support, which performs auto-negotiations and which is used
  2087. * as the internal link to the external PHY. Hence adding a check here
  2088. * to avoid enabling LASI interrupts for X553 devices.
  2089. */
  2090. if (hw->mac.type != ixgbe_mac_x550em_a) {
  2091. status = hw->phy.ops.read_reg(hw,
  2092. IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
  2093. MDIO_MMD_AN, &reg);
  2094. if (status)
  2095. return status;
  2096. reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
  2097. status = hw->phy.ops.write_reg(hw,
  2098. IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
  2099. MDIO_MMD_AN, reg);
  2100. if (status)
  2101. return status;
  2102. }
  2103. /* Enable high temperature failure and global fault alarms */
  2104. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
  2105. MDIO_MMD_VEND1,
  2106. &reg);
  2107. if (status)
  2108. return status;
  2109. reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
  2110. IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
  2111. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
  2112. MDIO_MMD_VEND1,
  2113. reg);
  2114. if (status)
  2115. return status;
  2116. /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
  2117. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
  2118. MDIO_MMD_VEND1,
  2119. &reg);
  2120. if (status)
  2121. return status;
  2122. reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
  2123. IXGBE_MDIO_GLOBAL_ALARM_1_INT);
  2124. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
  2125. MDIO_MMD_VEND1,
  2126. reg);
  2127. if (status)
  2128. return status;
  2129. /* Enable chip-wide vendor alarm */
  2130. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
  2131. MDIO_MMD_VEND1,
  2132. &reg);
  2133. if (status)
  2134. return status;
  2135. reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
  2136. status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
  2137. MDIO_MMD_VEND1,
  2138. reg);
  2139. return status;
  2140. }
  2141. /**
  2142. * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
  2143. * @hw: pointer to hardware structure
  2144. *
  2145. * Handle external Base T PHY interrupt. If high temperature
  2146. * failure alarm then return error, else if link status change
  2147. * then setup internal/external PHY link
  2148. *
  2149. * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
  2150. * failure alarm, else return PHY access status.
  2151. **/
  2152. static s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
  2153. {
  2154. struct ixgbe_phy_info *phy = &hw->phy;
  2155. bool lsc;
  2156. u32 status;
  2157. status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
  2158. if (status)
  2159. return status;
  2160. if (lsc && phy->ops.setup_internal_link)
  2161. return phy->ops.setup_internal_link(hw);
  2162. return 0;
  2163. }
  2164. /**
  2165. * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
  2166. * @hw: pointer to hardware structure
  2167. * @speed: link speed
  2168. *
  2169. * Configures the integrated KR PHY.
  2170. **/
  2171. static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
  2172. ixgbe_link_speed speed)
  2173. {
  2174. s32 status;
  2175. u32 reg_val;
  2176. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2177. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  2178. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  2179. if (status)
  2180. return status;
  2181. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
  2182. reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
  2183. IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
  2184. /* Advertise 10G support. */
  2185. if (speed & IXGBE_LINK_SPEED_10GB_FULL)
  2186. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
  2187. /* Advertise 1G support. */
  2188. if (speed & IXGBE_LINK_SPEED_1GB_FULL)
  2189. reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
  2190. status = hw->mac.ops.write_iosf_sb_reg(hw,
  2191. IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  2192. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  2193. if (hw->mac.type == ixgbe_mac_x550em_a) {
  2194. /* Set lane mode to KR auto negotiation */
  2195. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2196. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  2197. IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
  2198. if (status)
  2199. return status;
  2200. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
  2201. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
  2202. reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
  2203. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
  2204. reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
  2205. status = hw->mac.ops.write_iosf_sb_reg(hw,
  2206. IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
  2207. IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
  2208. }
  2209. return ixgbe_restart_an_internal_phy_x550em(hw);
  2210. }
  2211. /**
  2212. * ixgbe_setup_kr_x550em - Configure the KR PHY
  2213. * @hw: pointer to hardware structure
  2214. **/
  2215. static s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
  2216. {
  2217. /* leave link alone for 2.5G */
  2218. if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
  2219. return 0;
  2220. if (ixgbe_check_reset_blocked(hw))
  2221. return 0;
  2222. return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
  2223. }
  2224. /** ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
  2225. * @hw: address of hardware structure
  2226. * @link_up: address of boolean to indicate link status
  2227. *
  2228. * Returns error code if unable to get link status.
  2229. **/
  2230. static s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
  2231. {
  2232. u32 ret;
  2233. u16 autoneg_status;
  2234. *link_up = false;
  2235. /* read this twice back to back to indicate current status */
  2236. ret = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN,
  2237. &autoneg_status);
  2238. if (ret)
  2239. return ret;
  2240. ret = hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN,
  2241. &autoneg_status);
  2242. if (ret)
  2243. return ret;
  2244. *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
  2245. return 0;
  2246. }
  2247. /** ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
  2248. * @hw: point to hardware structure
  2249. *
  2250. * Configures the link between the integrated KR PHY and the external X557 PHY
  2251. * The driver will call this function when it gets a link status change
  2252. * interrupt from the X557 PHY. This function configures the link speed
  2253. * between the PHYs to match the link speed of the BASE-T link.
  2254. *
  2255. * A return of a non-zero value indicates an error, and the base driver should
  2256. * not report link up.
  2257. **/
  2258. static s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
  2259. {
  2260. ixgbe_link_speed force_speed;
  2261. bool link_up;
  2262. u32 status;
  2263. u16 speed;
  2264. if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
  2265. return IXGBE_ERR_CONFIG;
  2266. if (!(hw->mac.type == ixgbe_mac_X550EM_x &&
  2267. !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE))) {
  2268. speed = IXGBE_LINK_SPEED_10GB_FULL |
  2269. IXGBE_LINK_SPEED_1GB_FULL;
  2270. return ixgbe_setup_kr_speed_x550em(hw, speed);
  2271. }
  2272. /* If link is not up, then there is no setup necessary so return */
  2273. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2274. if (status)
  2275. return status;
  2276. if (!link_up)
  2277. return 0;
  2278. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
  2279. MDIO_MMD_AN,
  2280. &speed);
  2281. if (status)
  2282. return status;
  2283. /* If link is not still up, then no setup is necessary so return */
  2284. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2285. if (status)
  2286. return status;
  2287. if (!link_up)
  2288. return 0;
  2289. /* clear everything but the speed and duplex bits */
  2290. speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
  2291. switch (speed) {
  2292. case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
  2293. force_speed = IXGBE_LINK_SPEED_10GB_FULL;
  2294. break;
  2295. case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
  2296. force_speed = IXGBE_LINK_SPEED_1GB_FULL;
  2297. break;
  2298. default:
  2299. /* Internal PHY does not support anything else */
  2300. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  2301. }
  2302. return ixgbe_setup_ixfi_x550em(hw, &force_speed);
  2303. }
  2304. /** ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
  2305. * @hw: pointer to hardware structure
  2306. **/
  2307. static s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
  2308. {
  2309. s32 status;
  2310. status = ixgbe_reset_phy_generic(hw);
  2311. if (status)
  2312. return status;
  2313. /* Configure Link Status Alarm and Temperature Threshold interrupts */
  2314. return ixgbe_enable_lasi_ext_t_x550em(hw);
  2315. }
  2316. /**
  2317. * ixgbe_led_on_t_x550em - Turns on the software controllable LEDs.
  2318. * @hw: pointer to hardware structure
  2319. * @led_idx: led number to turn on
  2320. **/
  2321. static s32 ixgbe_led_on_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
  2322. {
  2323. u16 phy_data;
  2324. if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
  2325. return IXGBE_ERR_PARAM;
  2326. /* To turn on the LED, set mode to ON. */
  2327. hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2328. MDIO_MMD_VEND1, &phy_data);
  2329. phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
  2330. hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2331. MDIO_MMD_VEND1, phy_data);
  2332. return 0;
  2333. }
  2334. /**
  2335. * ixgbe_led_off_t_x550em - Turns off the software controllable LEDs.
  2336. * @hw: pointer to hardware structure
  2337. * @led_idx: led number to turn off
  2338. **/
  2339. static s32 ixgbe_led_off_t_x550em(struct ixgbe_hw *hw, u32 led_idx)
  2340. {
  2341. u16 phy_data;
  2342. if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
  2343. return IXGBE_ERR_PARAM;
  2344. /* To turn on the LED, set mode to ON. */
  2345. hw->phy.ops.read_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2346. MDIO_MMD_VEND1, &phy_data);
  2347. phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
  2348. hw->phy.ops.write_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
  2349. MDIO_MMD_VEND1, phy_data);
  2350. return 0;
  2351. }
  2352. /**
  2353. * ixgbe_set_fw_drv_ver_x550 - Sends driver version to firmware
  2354. * @hw: pointer to the HW structure
  2355. * @maj: driver version major number
  2356. * @min: driver version minor number
  2357. * @build: driver version build number
  2358. * @sub: driver version sub build number
  2359. * @len: length of driver_ver string
  2360. * @driver_ver: driver string
  2361. *
  2362. * Sends driver version number to firmware through the manageability
  2363. * block. On success return 0
  2364. * else returns IXGBE_ERR_SWFW_SYNC when encountering an error acquiring
  2365. * semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
  2366. **/
  2367. static s32 ixgbe_set_fw_drv_ver_x550(struct ixgbe_hw *hw, u8 maj, u8 min,
  2368. u8 build, u8 sub, u16 len,
  2369. const char *driver_ver)
  2370. {
  2371. struct ixgbe_hic_drv_info2 fw_cmd;
  2372. s32 ret_val;
  2373. int i;
  2374. if (!len || !driver_ver || (len > sizeof(fw_cmd.driver_string)))
  2375. return IXGBE_ERR_INVALID_ARGUMENT;
  2376. fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
  2377. fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN + len;
  2378. fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
  2379. fw_cmd.port_num = (u8)hw->bus.func;
  2380. fw_cmd.ver_maj = maj;
  2381. fw_cmd.ver_min = min;
  2382. fw_cmd.ver_build = build;
  2383. fw_cmd.ver_sub = sub;
  2384. fw_cmd.hdr.checksum = 0;
  2385. memcpy(fw_cmd.driver_string, driver_ver, len);
  2386. fw_cmd.hdr.checksum = ixgbe_calculate_checksum((u8 *)&fw_cmd,
  2387. (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));
  2388. for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
  2389. ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
  2390. sizeof(fw_cmd),
  2391. IXGBE_HI_COMMAND_TIMEOUT,
  2392. true);
  2393. if (ret_val)
  2394. continue;
  2395. if (fw_cmd.hdr.cmd_or_resp.ret_status !=
  2396. FW_CEM_RESP_STATUS_SUCCESS)
  2397. return IXGBE_ERR_HOST_INTERFACE_COMMAND;
  2398. return 0;
  2399. }
  2400. return ret_val;
  2401. }
  2402. /** ixgbe_get_lcd_x550em - Determine lowest common denominator
  2403. * @hw: pointer to hardware structure
  2404. * @lcd_speed: pointer to lowest common link speed
  2405. *
  2406. * Determine lowest common link speed with link partner.
  2407. **/
  2408. static s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw,
  2409. ixgbe_link_speed *lcd_speed)
  2410. {
  2411. u16 an_lp_status;
  2412. s32 status;
  2413. u16 word = hw->eeprom.ctrl_word_3;
  2414. *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
  2415. status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
  2416. MDIO_MMD_AN,
  2417. &an_lp_status);
  2418. if (status)
  2419. return status;
  2420. /* If link partner advertised 1G, return 1G */
  2421. if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
  2422. *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
  2423. return status;
  2424. }
  2425. /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
  2426. if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
  2427. (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
  2428. return status;
  2429. /* Link partner not capable of lower speeds, return 10G */
  2430. *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
  2431. return status;
  2432. }
  2433. /**
  2434. * ixgbe_setup_fc_x550em - Set up flow control
  2435. * @hw: pointer to hardware structure
  2436. */
  2437. static s32 ixgbe_setup_fc_x550em(struct ixgbe_hw *hw)
  2438. {
  2439. bool pause, asm_dir;
  2440. u32 reg_val;
  2441. s32 rc = 0;
  2442. /* Validate the requested mode */
  2443. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  2444. hw_err(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
  2445. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  2446. }
  2447. /* 10gig parts do not have a word in the EEPROM to determine the
  2448. * default flow control setting, so we explicitly set it to full.
  2449. */
  2450. if (hw->fc.requested_mode == ixgbe_fc_default)
  2451. hw->fc.requested_mode = ixgbe_fc_full;
  2452. /* Determine PAUSE and ASM_DIR bits. */
  2453. switch (hw->fc.requested_mode) {
  2454. case ixgbe_fc_none:
  2455. pause = false;
  2456. asm_dir = false;
  2457. break;
  2458. case ixgbe_fc_tx_pause:
  2459. pause = false;
  2460. asm_dir = true;
  2461. break;
  2462. case ixgbe_fc_rx_pause:
  2463. /* Rx Flow control is enabled and Tx Flow control is
  2464. * disabled by software override. Since there really
  2465. * isn't a way to advertise that we are capable of RX
  2466. * Pause ONLY, we will advertise that we support both
  2467. * symmetric and asymmetric Rx PAUSE, as such we fall
  2468. * through to the fc_full statement. Later, we will
  2469. * disable the adapter's ability to send PAUSE frames.
  2470. */
  2471. /* Fallthrough */
  2472. case ixgbe_fc_full:
  2473. pause = true;
  2474. asm_dir = true;
  2475. break;
  2476. default:
  2477. hw_err(hw, "Flow control param set incorrectly\n");
  2478. return IXGBE_ERR_CONFIG;
  2479. }
  2480. switch (hw->device_id) {
  2481. case IXGBE_DEV_ID_X550EM_X_KR:
  2482. case IXGBE_DEV_ID_X550EM_A_KR:
  2483. case IXGBE_DEV_ID_X550EM_A_KR_L:
  2484. rc = hw->mac.ops.read_iosf_sb_reg(hw,
  2485. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  2486. IXGBE_SB_IOSF_TARGET_KR_PHY,
  2487. &reg_val);
  2488. if (rc)
  2489. return rc;
  2490. reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  2491. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
  2492. if (pause)
  2493. reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
  2494. if (asm_dir)
  2495. reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  2496. rc = hw->mac.ops.write_iosf_sb_reg(hw,
  2497. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  2498. IXGBE_SB_IOSF_TARGET_KR_PHY,
  2499. reg_val);
  2500. /* This device does not fully support AN. */
  2501. hw->fc.disable_fc_autoneg = true;
  2502. break;
  2503. case IXGBE_DEV_ID_X550EM_X_XFI:
  2504. hw->fc.disable_fc_autoneg = true;
  2505. break;
  2506. default:
  2507. break;
  2508. }
  2509. return rc;
  2510. }
  2511. /**
  2512. * ixgbe_fc_autoneg_backplane_x550em_a - Enable flow control IEEE clause 37
  2513. * @hw: pointer to hardware structure
  2514. **/
  2515. static void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *hw)
  2516. {
  2517. u32 link_s1, lp_an_page_low, an_cntl_1;
  2518. s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  2519. ixgbe_link_speed speed;
  2520. bool link_up;
  2521. /* AN should have completed when the cable was plugged in.
  2522. * Look for reasons to bail out. Bail out if:
  2523. * - FC autoneg is disabled, or if
  2524. * - link is not up.
  2525. */
  2526. if (hw->fc.disable_fc_autoneg) {
  2527. hw_err(hw, "Flow control autoneg is disabled");
  2528. goto out;
  2529. }
  2530. hw->mac.ops.check_link(hw, &speed, &link_up, false);
  2531. if (!link_up) {
  2532. hw_err(hw, "The link is down");
  2533. goto out;
  2534. }
  2535. /* Check at auto-negotiation has completed */
  2536. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2537. IXGBE_KRM_LINK_S1(hw->bus.lan_id),
  2538. IXGBE_SB_IOSF_TARGET_KR_PHY, &link_s1);
  2539. if (status || (link_s1 & IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE) == 0) {
  2540. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  2541. status = IXGBE_ERR_FC_NOT_NEGOTIATED;
  2542. goto out;
  2543. }
  2544. /* Read the 10g AN autoc and LP ability registers and resolve
  2545. * local flow control settings accordingly
  2546. */
  2547. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2548. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  2549. IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl_1);
  2550. if (status) {
  2551. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  2552. goto out;
  2553. }
  2554. status = hw->mac.ops.read_iosf_sb_reg(hw,
  2555. IXGBE_KRM_LP_BASE_PAGE_HIGH(hw->bus.lan_id),
  2556. IXGBE_SB_IOSF_TARGET_KR_PHY, &lp_an_page_low);
  2557. if (status) {
  2558. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  2559. goto out;
  2560. }
  2561. status = ixgbe_negotiate_fc(hw, an_cntl_1, lp_an_page_low,
  2562. IXGBE_KRM_AN_CNTL_1_SYM_PAUSE,
  2563. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE,
  2564. IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE,
  2565. IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE);
  2566. out:
  2567. if (!status) {
  2568. hw->fc.fc_was_autonegged = true;
  2569. } else {
  2570. hw->fc.fc_was_autonegged = false;
  2571. hw->fc.current_mode = hw->fc.requested_mode;
  2572. }
  2573. }
  2574. /**
  2575. * ixgbe_fc_autoneg_fiber_x550em_a - passthrough FC settings
  2576. * @hw: pointer to hardware structure
  2577. **/
  2578. static void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *hw)
  2579. {
  2580. hw->fc.fc_was_autonegged = false;
  2581. hw->fc.current_mode = hw->fc.requested_mode;
  2582. }
  2583. /** ixgbe_enter_lplu_x550em - Transition to low power states
  2584. * @hw: pointer to hardware structure
  2585. *
  2586. * Configures Low Power Link Up on transition to low power states
  2587. * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting
  2588. * the X557 PHY immediately prior to entering LPLU.
  2589. **/
  2590. static s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
  2591. {
  2592. u16 an_10g_cntl_reg, autoneg_reg, speed;
  2593. s32 status;
  2594. ixgbe_link_speed lcd_speed;
  2595. u32 save_autoneg;
  2596. bool link_up;
  2597. /* If blocked by MNG FW, then don't restart AN */
  2598. if (ixgbe_check_reset_blocked(hw))
  2599. return 0;
  2600. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2601. if (status)
  2602. return status;
  2603. status = hw->eeprom.ops.read(hw, NVM_INIT_CTRL_3,
  2604. &hw->eeprom.ctrl_word_3);
  2605. if (status)
  2606. return status;
  2607. /* If link is down, LPLU disabled in NVM, WoL disabled, or
  2608. * manageability disabled, then force link down by entering
  2609. * low power mode.
  2610. */
  2611. if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
  2612. !(hw->wol_enabled || ixgbe_mng_present(hw)))
  2613. return ixgbe_set_copper_phy_power(hw, false);
  2614. /* Determine LCD */
  2615. status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
  2616. if (status)
  2617. return status;
  2618. /* If no valid LCD link speed, then force link down and exit. */
  2619. if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
  2620. return ixgbe_set_copper_phy_power(hw, false);
  2621. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
  2622. MDIO_MMD_AN,
  2623. &speed);
  2624. if (status)
  2625. return status;
  2626. /* If no link now, speed is invalid so take link down */
  2627. status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
  2628. if (status)
  2629. return ixgbe_set_copper_phy_power(hw, false);
  2630. /* clear everything but the speed bits */
  2631. speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
  2632. /* If current speed is already LCD, then exit. */
  2633. if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
  2634. (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
  2635. ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
  2636. (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
  2637. return status;
  2638. /* Clear AN completed indication */
  2639. status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
  2640. MDIO_MMD_AN,
  2641. &autoneg_reg);
  2642. if (status)
  2643. return status;
  2644. status = hw->phy.ops.read_reg(hw, MDIO_AN_10GBT_CTRL,
  2645. MDIO_MMD_AN,
  2646. &an_10g_cntl_reg);
  2647. if (status)
  2648. return status;
  2649. status = hw->phy.ops.read_reg(hw,
  2650. IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
  2651. MDIO_MMD_AN,
  2652. &autoneg_reg);
  2653. if (status)
  2654. return status;
  2655. save_autoneg = hw->phy.autoneg_advertised;
  2656. /* Setup link at least common link speed */
  2657. status = hw->mac.ops.setup_link(hw, lcd_speed, false);
  2658. /* restore autoneg from before setting lplu speed */
  2659. hw->phy.autoneg_advertised = save_autoneg;
  2660. return status;
  2661. }
  2662. /**
  2663. * ixgbe_reset_phy_fw - Reset firmware-controlled PHYs
  2664. * @hw: pointer to hardware structure
  2665. */
  2666. static s32 ixgbe_reset_phy_fw(struct ixgbe_hw *hw)
  2667. {
  2668. u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
  2669. s32 rc;
  2670. if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
  2671. return 0;
  2672. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_PHY_SW_RESET, &store);
  2673. if (rc)
  2674. return rc;
  2675. memset(store, 0, sizeof(store));
  2676. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_INIT_PHY, &store);
  2677. if (rc)
  2678. return rc;
  2679. return ixgbe_setup_fw_link(hw);
  2680. }
  2681. /**
  2682. * ixgbe_check_overtemp_fw - Check firmware-controlled PHYs for overtemp
  2683. * @hw: pointer to hardware structure
  2684. */
  2685. static s32 ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
  2686. {
  2687. u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
  2688. s32 rc;
  2689. rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &store);
  2690. if (rc)
  2691. return rc;
  2692. if (store[0] & FW_PHY_ACT_GET_LINK_INFO_TEMP) {
  2693. ixgbe_shutdown_fw_phy(hw);
  2694. return IXGBE_ERR_OVERTEMP;
  2695. }
  2696. return 0;
  2697. }
  2698. /**
  2699. * ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
  2700. * @hw: pointer to hardware structure
  2701. *
  2702. * Read NW_MNG_IF_SEL register and save field values.
  2703. */
  2704. static void ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
  2705. {
  2706. /* Save NW management interface connected on board. This is used
  2707. * to determine internal PHY mode.
  2708. */
  2709. hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
  2710. /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
  2711. * PHY address. This register field was has only been used for X552.
  2712. */
  2713. if (hw->mac.type == ixgbe_mac_x550em_a &&
  2714. hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
  2715. hw->phy.mdio.prtad = (hw->phy.nw_mng_if_sel &
  2716. IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
  2717. IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
  2718. }
  2719. }
  2720. /** ixgbe_init_phy_ops_X550em - PHY/SFP specific init
  2721. * @hw: pointer to hardware structure
  2722. *
  2723. * Initialize any function pointers that were not able to be
  2724. * set during init_shared_code because the PHY/SFP type was
  2725. * not known. Perform the SFP init if necessary.
  2726. **/
  2727. static s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
  2728. {
  2729. struct ixgbe_phy_info *phy = &hw->phy;
  2730. s32 ret_val;
  2731. hw->mac.ops.set_lan_id(hw);
  2732. ixgbe_read_mng_if_sel_x550em(hw);
  2733. if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
  2734. phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
  2735. ixgbe_setup_mux_ctl(hw);
  2736. }
  2737. /* Identify the PHY or SFP module */
  2738. ret_val = phy->ops.identify(hw);
  2739. if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED ||
  2740. ret_val == IXGBE_ERR_PHY_ADDR_INVALID)
  2741. return ret_val;
  2742. /* Setup function pointers based on detected hardware */
  2743. ixgbe_init_mac_link_ops_X550em(hw);
  2744. if (phy->sfp_type != ixgbe_sfp_type_unknown)
  2745. phy->ops.reset = NULL;
  2746. /* Set functions pointers based on phy type */
  2747. switch (hw->phy.type) {
  2748. case ixgbe_phy_x550em_kx4:
  2749. phy->ops.setup_link = NULL;
  2750. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2751. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2752. break;
  2753. case ixgbe_phy_x550em_kr:
  2754. phy->ops.setup_link = ixgbe_setup_kr_x550em;
  2755. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2756. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2757. break;
  2758. case ixgbe_phy_x550em_xfi:
  2759. /* link is managed by HW */
  2760. phy->ops.setup_link = NULL;
  2761. phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
  2762. phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
  2763. break;
  2764. case ixgbe_phy_x550em_ext_t:
  2765. /* Save NW management interface connected on board. This is used
  2766. * to determine internal PHY mode
  2767. */
  2768. phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
  2769. /* If internal link mode is XFI, then setup iXFI internal link,
  2770. * else setup KR now.
  2771. */
  2772. phy->ops.setup_internal_link =
  2773. ixgbe_setup_internal_phy_t_x550em;
  2774. /* setup SW LPLU only for first revision */
  2775. if (hw->mac.type == ixgbe_mac_X550EM_x &&
  2776. !(IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0)) &
  2777. IXGBE_FUSES0_REV_MASK))
  2778. phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
  2779. phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
  2780. phy->ops.reset = ixgbe_reset_phy_t_X550em;
  2781. break;
  2782. case ixgbe_phy_sgmii:
  2783. phy->ops.setup_link = NULL;
  2784. break;
  2785. case ixgbe_phy_fw:
  2786. phy->ops.setup_link = ixgbe_setup_fw_link;
  2787. phy->ops.reset = ixgbe_reset_phy_fw;
  2788. break;
  2789. case ixgbe_phy_ext_1g_t:
  2790. phy->ops.setup_link = NULL;
  2791. phy->ops.read_reg = NULL;
  2792. phy->ops.write_reg = NULL;
  2793. phy->ops.reset = NULL;
  2794. break;
  2795. default:
  2796. break;
  2797. }
  2798. return ret_val;
  2799. }
  2800. /** ixgbe_get_media_type_X550em - Get media type
  2801. * @hw: pointer to hardware structure
  2802. *
  2803. * Returns the media type (fiber, copper, backplane)
  2804. *
  2805. */
  2806. static enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
  2807. {
  2808. enum ixgbe_media_type media_type;
  2809. /* Detect if there is a copper PHY attached. */
  2810. switch (hw->device_id) {
  2811. case IXGBE_DEV_ID_X550EM_A_SGMII:
  2812. case IXGBE_DEV_ID_X550EM_A_SGMII_L:
  2813. hw->phy.type = ixgbe_phy_sgmii;
  2814. /* Fallthrough */
  2815. case IXGBE_DEV_ID_X550EM_X_KR:
  2816. case IXGBE_DEV_ID_X550EM_X_KX4:
  2817. case IXGBE_DEV_ID_X550EM_X_XFI:
  2818. case IXGBE_DEV_ID_X550EM_A_KR:
  2819. case IXGBE_DEV_ID_X550EM_A_KR_L:
  2820. media_type = ixgbe_media_type_backplane;
  2821. break;
  2822. case IXGBE_DEV_ID_X550EM_X_SFP:
  2823. case IXGBE_DEV_ID_X550EM_A_SFP:
  2824. case IXGBE_DEV_ID_X550EM_A_SFP_N:
  2825. media_type = ixgbe_media_type_fiber;
  2826. break;
  2827. case IXGBE_DEV_ID_X550EM_X_1G_T:
  2828. case IXGBE_DEV_ID_X550EM_X_10G_T:
  2829. case IXGBE_DEV_ID_X550EM_A_10G_T:
  2830. case IXGBE_DEV_ID_X550EM_A_1G_T:
  2831. case IXGBE_DEV_ID_X550EM_A_1G_T_L:
  2832. media_type = ixgbe_media_type_copper;
  2833. break;
  2834. default:
  2835. media_type = ixgbe_media_type_unknown;
  2836. break;
  2837. }
  2838. return media_type;
  2839. }
  2840. /** ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
  2841. ** @hw: pointer to hardware structure
  2842. **/
  2843. static s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
  2844. {
  2845. s32 status;
  2846. u16 reg;
  2847. status = hw->phy.ops.read_reg(hw,
  2848. IXGBE_MDIO_TX_VENDOR_ALARMS_3,
  2849. MDIO_MMD_PMAPMD,
  2850. &reg);
  2851. if (status)
  2852. return status;
  2853. /* If PHY FW reset completed bit is set then this is the first
  2854. * SW instance after a power on so the PHY FW must be un-stalled.
  2855. */
  2856. if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
  2857. status = hw->phy.ops.read_reg(hw,
  2858. IXGBE_MDIO_GLOBAL_RES_PR_10,
  2859. MDIO_MMD_VEND1,
  2860. &reg);
  2861. if (status)
  2862. return status;
  2863. reg &= ~IXGBE_MDIO_POWER_UP_STALL;
  2864. status = hw->phy.ops.write_reg(hw,
  2865. IXGBE_MDIO_GLOBAL_RES_PR_10,
  2866. MDIO_MMD_VEND1,
  2867. reg);
  2868. if (status)
  2869. return status;
  2870. }
  2871. return status;
  2872. }
  2873. /**
  2874. * ixgbe_set_mdio_speed - Set MDIO clock speed
  2875. * @hw: pointer to hardware structure
  2876. */
  2877. static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
  2878. {
  2879. u32 hlreg0;
  2880. switch (hw->device_id) {
  2881. case IXGBE_DEV_ID_X550EM_X_10G_T:
  2882. case IXGBE_DEV_ID_X550EM_A_SGMII:
  2883. case IXGBE_DEV_ID_X550EM_A_SGMII_L:
  2884. case IXGBE_DEV_ID_X550EM_A_10G_T:
  2885. case IXGBE_DEV_ID_X550EM_A_SFP:
  2886. /* Config MDIO clock speed before the first MDIO PHY access */
  2887. hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
  2888. hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
  2889. IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
  2890. break;
  2891. case IXGBE_DEV_ID_X550EM_A_1G_T:
  2892. case IXGBE_DEV_ID_X550EM_A_1G_T_L:
  2893. /* Select fast MDIO clock speed for these devices */
  2894. hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
  2895. hlreg0 |= IXGBE_HLREG0_MDCSPD;
  2896. IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
  2897. break;
  2898. default:
  2899. break;
  2900. }
  2901. }
  2902. /** ixgbe_reset_hw_X550em - Perform hardware reset
  2903. ** @hw: pointer to hardware structure
  2904. **
  2905. ** Resets the hardware by resetting the transmit and receive units, masks
  2906. ** and clears all interrupts, perform a PHY reset, and perform a link (MAC)
  2907. ** reset.
  2908. **/
  2909. static s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
  2910. {
  2911. ixgbe_link_speed link_speed;
  2912. s32 status;
  2913. u32 ctrl = 0;
  2914. u32 i;
  2915. bool link_up = false;
  2916. u32 swfw_mask = hw->phy.phy_semaphore_mask;
  2917. /* Call adapter stop to disable Tx/Rx and clear interrupts */
  2918. status = hw->mac.ops.stop_adapter(hw);
  2919. if (status)
  2920. return status;
  2921. /* flush pending Tx transactions */
  2922. ixgbe_clear_tx_pending(hw);
  2923. /* PHY ops must be identified and initialized prior to reset */
  2924. status = hw->phy.ops.init(hw);
  2925. if (status == IXGBE_ERR_SFP_NOT_SUPPORTED ||
  2926. status == IXGBE_ERR_PHY_ADDR_INVALID)
  2927. return status;
  2928. /* start the external PHY */
  2929. if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
  2930. status = ixgbe_init_ext_t_x550em(hw);
  2931. if (status)
  2932. return status;
  2933. }
  2934. /* Setup SFP module if there is one present. */
  2935. if (hw->phy.sfp_setup_needed) {
  2936. status = hw->mac.ops.setup_sfp(hw);
  2937. hw->phy.sfp_setup_needed = false;
  2938. }
  2939. if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
  2940. return status;
  2941. /* Reset PHY */
  2942. if (!hw->phy.reset_disable && hw->phy.ops.reset)
  2943. hw->phy.ops.reset(hw);
  2944. mac_reset_top:
  2945. /* Issue global reset to the MAC. Needs to be SW reset if link is up.
  2946. * If link reset is used when link is up, it might reset the PHY when
  2947. * mng is using it. If link is down or the flag to force full link
  2948. * reset is set, then perform link reset.
  2949. */
  2950. ctrl = IXGBE_CTRL_LNK_RST;
  2951. if (!hw->force_full_reset) {
  2952. hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
  2953. if (link_up)
  2954. ctrl = IXGBE_CTRL_RST;
  2955. }
  2956. status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
  2957. if (status) {
  2958. hw_dbg(hw, "semaphore failed with %d", status);
  2959. return IXGBE_ERR_SWFW_SYNC;
  2960. }
  2961. ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
  2962. IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
  2963. IXGBE_WRITE_FLUSH(hw);
  2964. hw->mac.ops.release_swfw_sync(hw, swfw_mask);
  2965. usleep_range(1000, 1200);
  2966. /* Poll for reset bit to self-clear meaning reset is complete */
  2967. for (i = 0; i < 10; i++) {
  2968. ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
  2969. if (!(ctrl & IXGBE_CTRL_RST_MASK))
  2970. break;
  2971. udelay(1);
  2972. }
  2973. if (ctrl & IXGBE_CTRL_RST_MASK) {
  2974. status = IXGBE_ERR_RESET_FAILED;
  2975. hw_dbg(hw, "Reset polling failed to complete.\n");
  2976. }
  2977. msleep(50);
  2978. /* Double resets are required for recovery from certain error
  2979. * clear the multicast table. Also reset num_rar_entries to 128,
  2980. * since we modify this value when programming the SAN MAC address.
  2981. */
  2982. if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
  2983. hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
  2984. goto mac_reset_top;
  2985. }
  2986. /* Store the permanent mac address */
  2987. hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
  2988. /* Store MAC address from RAR0, clear receive address registers, and
  2989. * clear the multicast table. Also reset num_rar_entries to 128,
  2990. * since we modify this value when programming the SAN MAC address.
  2991. */
  2992. hw->mac.num_rar_entries = 128;
  2993. hw->mac.ops.init_rx_addrs(hw);
  2994. ixgbe_set_mdio_speed(hw);
  2995. if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
  2996. ixgbe_setup_mux_ctl(hw);
  2997. return status;
  2998. }
  2999. /** ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype
  3000. * anti-spoofing
  3001. * @hw: pointer to hardware structure
  3002. * @enable: enable or disable switch for Ethertype anti-spoofing
  3003. * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
  3004. **/
  3005. static void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
  3006. bool enable, int vf)
  3007. {
  3008. int vf_target_reg = vf >> 3;
  3009. int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
  3010. u32 pfvfspoof;
  3011. pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
  3012. if (enable)
  3013. pfvfspoof |= BIT(vf_target_shift);
  3014. else
  3015. pfvfspoof &= ~BIT(vf_target_shift);
  3016. IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
  3017. }
  3018. /** ixgbe_set_source_address_pruning_X550 - Enable/Disbale src address pruning
  3019. * @hw: pointer to hardware structure
  3020. * @enable: enable or disable source address pruning
  3021. * @pool: Rx pool to set source address pruning for
  3022. **/
  3023. static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,
  3024. bool enable,
  3025. unsigned int pool)
  3026. {
  3027. u64 pfflp;
  3028. /* max rx pool is 63 */
  3029. if (pool > 63)
  3030. return;
  3031. pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
  3032. pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
  3033. if (enable)
  3034. pfflp |= (1ULL << pool);
  3035. else
  3036. pfflp &= ~(1ULL << pool);
  3037. IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
  3038. IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
  3039. }
  3040. /**
  3041. * ixgbe_setup_fc_backplane_x550em_a - Set up flow control
  3042. * @hw: pointer to hardware structure
  3043. *
  3044. * Called at init time to set up flow control.
  3045. **/
  3046. static s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *hw)
  3047. {
  3048. s32 status = 0;
  3049. u32 an_cntl = 0;
  3050. /* Validate the requested mode */
  3051. if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
  3052. hw_err(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
  3053. return IXGBE_ERR_INVALID_LINK_SETTINGS;
  3054. }
  3055. if (hw->fc.requested_mode == ixgbe_fc_default)
  3056. hw->fc.requested_mode = ixgbe_fc_full;
  3057. /* Set up the 1G and 10G flow control advertisement registers so the
  3058. * HW will be able to do FC autoneg once the cable is plugged in. If
  3059. * we link at 10G, the 1G advertisement is harmless and vice versa.
  3060. */
  3061. status = hw->mac.ops.read_iosf_sb_reg(hw,
  3062. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  3063. IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl);
  3064. if (status) {
  3065. hw_dbg(hw, "Auto-Negotiation did not complete\n");
  3066. return status;
  3067. }
  3068. /* The possible values of fc.requested_mode are:
  3069. * 0: Flow control is completely disabled
  3070. * 1: Rx flow control is enabled (we can receive pause frames,
  3071. * but not send pause frames).
  3072. * 2: Tx flow control is enabled (we can send pause frames but
  3073. * we do not support receiving pause frames).
  3074. * 3: Both Rx and Tx flow control (symmetric) are enabled.
  3075. * other: Invalid.
  3076. */
  3077. switch (hw->fc.requested_mode) {
  3078. case ixgbe_fc_none:
  3079. /* Flow control completely disabled by software override. */
  3080. an_cntl &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  3081. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
  3082. break;
  3083. case ixgbe_fc_tx_pause:
  3084. /* Tx Flow control is enabled, and Rx Flow control is
  3085. * disabled by software override.
  3086. */
  3087. an_cntl |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  3088. an_cntl &= ~IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
  3089. break;
  3090. case ixgbe_fc_rx_pause:
  3091. /* Rx Flow control is enabled and Tx Flow control is
  3092. * disabled by software override. Since there really
  3093. * isn't a way to advertise that we are capable of RX
  3094. * Pause ONLY, we will advertise that we support both
  3095. * symmetric and asymmetric Rx PAUSE, as such we fall
  3096. * through to the fc_full statement. Later, we will
  3097. * disable the adapter's ability to send PAUSE frames.
  3098. */
  3099. case ixgbe_fc_full:
  3100. /* Flow control (both Rx and Tx) is enabled by SW override. */
  3101. an_cntl |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
  3102. IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
  3103. break;
  3104. default:
  3105. hw_err(hw, "Flow control param set incorrectly\n");
  3106. return IXGBE_ERR_CONFIG;
  3107. }
  3108. status = hw->mac.ops.write_iosf_sb_reg(hw,
  3109. IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
  3110. IXGBE_SB_IOSF_TARGET_KR_PHY, an_cntl);
  3111. /* Restart auto-negotiation. */
  3112. status = ixgbe_restart_an_internal_phy_x550em(hw);
  3113. return status;
  3114. }
  3115. /**
  3116. * ixgbe_set_mux - Set mux for port 1 access with CS4227
  3117. * @hw: pointer to hardware structure
  3118. * @state: set mux if 1, clear if 0
  3119. */
  3120. static void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
  3121. {
  3122. u32 esdp;
  3123. if (!hw->bus.lan_id)
  3124. return;
  3125. esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
  3126. if (state)
  3127. esdp |= IXGBE_ESDP_SDP1;
  3128. else
  3129. esdp &= ~IXGBE_ESDP_SDP1;
  3130. IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
  3131. IXGBE_WRITE_FLUSH(hw);
  3132. }
  3133. /**
  3134. * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
  3135. * @hw: pointer to hardware structure
  3136. * @mask: Mask to specify which semaphore to acquire
  3137. *
  3138. * Acquires the SWFW semaphore and sets the I2C MUX
  3139. */
  3140. static s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
  3141. {
  3142. s32 status;
  3143. status = ixgbe_acquire_swfw_sync_X540(hw, mask);
  3144. if (status)
  3145. return status;
  3146. if (mask & IXGBE_GSSR_I2C_MASK)
  3147. ixgbe_set_mux(hw, 1);
  3148. return 0;
  3149. }
  3150. /**
  3151. * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
  3152. * @hw: pointer to hardware structure
  3153. * @mask: Mask to specify which semaphore to release
  3154. *
  3155. * Releases the SWFW semaphore and sets the I2C MUX
  3156. */
  3157. static void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
  3158. {
  3159. if (mask & IXGBE_GSSR_I2C_MASK)
  3160. ixgbe_set_mux(hw, 0);
  3161. ixgbe_release_swfw_sync_X540(hw, mask);
  3162. }
  3163. /**
  3164. * ixgbe_acquire_swfw_sync_x550em_a - Acquire SWFW semaphore
  3165. * @hw: pointer to hardware structure
  3166. * @mask: Mask to specify which semaphore to acquire
  3167. *
  3168. * Acquires the SWFW semaphore and get the shared PHY token as needed
  3169. */
  3170. static s32 ixgbe_acquire_swfw_sync_x550em_a(struct ixgbe_hw *hw, u32 mask)
  3171. {
  3172. u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
  3173. int retries = FW_PHY_TOKEN_RETRIES;
  3174. s32 status;
  3175. while (--retries) {
  3176. status = 0;
  3177. if (hmask)
  3178. status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
  3179. if (status)
  3180. return status;
  3181. if (!(mask & IXGBE_GSSR_TOKEN_SM))
  3182. return 0;
  3183. status = ixgbe_get_phy_token(hw);
  3184. if (!status)
  3185. return 0;
  3186. if (hmask)
  3187. ixgbe_release_swfw_sync_X540(hw, hmask);
  3188. if (status != IXGBE_ERR_TOKEN_RETRY)
  3189. return status;
  3190. msleep(FW_PHY_TOKEN_DELAY);
  3191. }
  3192. return status;
  3193. }
  3194. /**
  3195. * ixgbe_release_swfw_sync_x550em_a - Release SWFW semaphore
  3196. * @hw: pointer to hardware structure
  3197. * @mask: Mask to specify which semaphore to release
  3198. *
  3199. * Release the SWFW semaphore and puts the shared PHY token as needed
  3200. */
  3201. static void ixgbe_release_swfw_sync_x550em_a(struct ixgbe_hw *hw, u32 mask)
  3202. {
  3203. u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
  3204. if (mask & IXGBE_GSSR_TOKEN_SM)
  3205. ixgbe_put_phy_token(hw);
  3206. if (hmask)
  3207. ixgbe_release_swfw_sync_X540(hw, hmask);
  3208. }
  3209. /**
  3210. * ixgbe_read_phy_reg_x550a - Reads specified PHY register
  3211. * @hw: pointer to hardware structure
  3212. * @reg_addr: 32 bit address of PHY register to read
  3213. * @device_type: 5 bit device type
  3214. * @phy_data: Pointer to read data from PHY register
  3215. *
  3216. * Reads a value from a specified PHY register using the SWFW lock and PHY
  3217. * Token. The PHY Token is needed since the MDIO is shared between to MAC
  3218. * instances.
  3219. */
  3220. static s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  3221. u32 device_type, u16 *phy_data)
  3222. {
  3223. u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
  3224. s32 status;
  3225. if (hw->mac.ops.acquire_swfw_sync(hw, mask))
  3226. return IXGBE_ERR_SWFW_SYNC;
  3227. status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
  3228. hw->mac.ops.release_swfw_sync(hw, mask);
  3229. return status;
  3230. }
  3231. /**
  3232. * ixgbe_write_phy_reg_x550a - Writes specified PHY register
  3233. * @hw: pointer to hardware structure
  3234. * @reg_addr: 32 bit PHY register to write
  3235. * @device_type: 5 bit device type
  3236. * @phy_data: Data to write to the PHY register
  3237. *
  3238. * Writes a value to specified PHY register using the SWFW lock and PHY Token.
  3239. * The PHY Token is needed since the MDIO is shared between to MAC instances.
  3240. */
  3241. static s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
  3242. u32 device_type, u16 phy_data)
  3243. {
  3244. u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
  3245. s32 status;
  3246. if (hw->mac.ops.acquire_swfw_sync(hw, mask))
  3247. return IXGBE_ERR_SWFW_SYNC;
  3248. status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type, phy_data);
  3249. hw->mac.ops.release_swfw_sync(hw, mask);
  3250. return status;
  3251. }
  3252. #define X550_COMMON_MAC \
  3253. .init_hw = &ixgbe_init_hw_generic, \
  3254. .start_hw = &ixgbe_start_hw_X540, \
  3255. .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic, \
  3256. .enable_rx_dma = &ixgbe_enable_rx_dma_generic, \
  3257. .get_mac_addr = &ixgbe_get_mac_addr_generic, \
  3258. .get_device_caps = &ixgbe_get_device_caps_generic, \
  3259. .stop_adapter = &ixgbe_stop_adapter_generic, \
  3260. .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie, \
  3261. .read_analog_reg8 = NULL, \
  3262. .write_analog_reg8 = NULL, \
  3263. .set_rxpba = &ixgbe_set_rxpba_generic, \
  3264. .check_link = &ixgbe_check_mac_link_generic, \
  3265. .blink_led_start = &ixgbe_blink_led_start_X540, \
  3266. .blink_led_stop = &ixgbe_blink_led_stop_X540, \
  3267. .set_rar = &ixgbe_set_rar_generic, \
  3268. .clear_rar = &ixgbe_clear_rar_generic, \
  3269. .set_vmdq = &ixgbe_set_vmdq_generic, \
  3270. .set_vmdq_san_mac = &ixgbe_set_vmdq_san_mac_generic, \
  3271. .clear_vmdq = &ixgbe_clear_vmdq_generic, \
  3272. .init_rx_addrs = &ixgbe_init_rx_addrs_generic, \
  3273. .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic, \
  3274. .enable_mc = &ixgbe_enable_mc_generic, \
  3275. .disable_mc = &ixgbe_disable_mc_generic, \
  3276. .clear_vfta = &ixgbe_clear_vfta_generic, \
  3277. .set_vfta = &ixgbe_set_vfta_generic, \
  3278. .fc_enable = &ixgbe_fc_enable_generic, \
  3279. .set_fw_drv_ver = &ixgbe_set_fw_drv_ver_x550, \
  3280. .init_uta_tables = &ixgbe_init_uta_tables_generic, \
  3281. .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing, \
  3282. .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing, \
  3283. .set_source_address_pruning = \
  3284. &ixgbe_set_source_address_pruning_X550, \
  3285. .set_ethertype_anti_spoofing = \
  3286. &ixgbe_set_ethertype_anti_spoofing_X550, \
  3287. .disable_rx_buff = &ixgbe_disable_rx_buff_generic, \
  3288. .enable_rx_buff = &ixgbe_enable_rx_buff_generic, \
  3289. .get_thermal_sensor_data = NULL, \
  3290. .init_thermal_sensor_thresh = NULL, \
  3291. .enable_rx = &ixgbe_enable_rx_generic, \
  3292. .disable_rx = &ixgbe_disable_rx_x550, \
  3293. static const struct ixgbe_mac_operations mac_ops_X550 = {
  3294. X550_COMMON_MAC
  3295. .led_on = ixgbe_led_on_generic,
  3296. .led_off = ixgbe_led_off_generic,
  3297. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3298. .reset_hw = &ixgbe_reset_hw_X540,
  3299. .get_media_type = &ixgbe_get_media_type_X540,
  3300. .get_san_mac_addr = &ixgbe_get_san_mac_addr_generic,
  3301. .get_wwn_prefix = &ixgbe_get_wwn_prefix_generic,
  3302. .setup_link = &ixgbe_setup_mac_link_X540,
  3303. .get_link_capabilities = &ixgbe_get_copper_link_capabilities_generic,
  3304. .get_bus_info = &ixgbe_get_bus_info_generic,
  3305. .setup_sfp = NULL,
  3306. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X540,
  3307. .release_swfw_sync = &ixgbe_release_swfw_sync_X540,
  3308. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  3309. .prot_autoc_read = prot_autoc_read_generic,
  3310. .prot_autoc_write = prot_autoc_write_generic,
  3311. .setup_fc = ixgbe_setup_fc_generic,
  3312. .fc_autoneg = ixgbe_fc_autoneg,
  3313. };
  3314. static const struct ixgbe_mac_operations mac_ops_X550EM_x = {
  3315. X550_COMMON_MAC
  3316. .led_on = ixgbe_led_on_t_x550em,
  3317. .led_off = ixgbe_led_off_t_x550em,
  3318. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3319. .reset_hw = &ixgbe_reset_hw_X550em,
  3320. .get_media_type = &ixgbe_get_media_type_X550em,
  3321. .get_san_mac_addr = NULL,
  3322. .get_wwn_prefix = NULL,
  3323. .setup_link = &ixgbe_setup_mac_link_X540,
  3324. .get_link_capabilities = &ixgbe_get_link_capabilities_X550em,
  3325. .get_bus_info = &ixgbe_get_bus_info_X550em,
  3326. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3327. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X550em,
  3328. .release_swfw_sync = &ixgbe_release_swfw_sync_X550em,
  3329. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  3330. .setup_fc = NULL, /* defined later */
  3331. .fc_autoneg = ixgbe_fc_autoneg,
  3332. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550,
  3333. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550,
  3334. };
  3335. static const struct ixgbe_mac_operations mac_ops_X550EM_x_fw = {
  3336. X550_COMMON_MAC
  3337. .led_on = NULL,
  3338. .led_off = NULL,
  3339. .init_led_link_act = NULL,
  3340. .reset_hw = &ixgbe_reset_hw_X550em,
  3341. .get_media_type = &ixgbe_get_media_type_X550em,
  3342. .get_san_mac_addr = NULL,
  3343. .get_wwn_prefix = NULL,
  3344. .setup_link = &ixgbe_setup_mac_link_X540,
  3345. .get_link_capabilities = &ixgbe_get_link_capabilities_X550em,
  3346. .get_bus_info = &ixgbe_get_bus_info_X550em,
  3347. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3348. .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X550em,
  3349. .release_swfw_sync = &ixgbe_release_swfw_sync_X550em,
  3350. .init_swfw_sync = &ixgbe_init_swfw_sync_X540,
  3351. .setup_fc = NULL,
  3352. .fc_autoneg = ixgbe_fc_autoneg,
  3353. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550,
  3354. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550,
  3355. };
  3356. static const struct ixgbe_mac_operations mac_ops_x550em_a = {
  3357. X550_COMMON_MAC
  3358. .led_on = ixgbe_led_on_t_x550em,
  3359. .led_off = ixgbe_led_off_t_x550em,
  3360. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3361. .reset_hw = ixgbe_reset_hw_X550em,
  3362. .get_media_type = ixgbe_get_media_type_X550em,
  3363. .get_san_mac_addr = NULL,
  3364. .get_wwn_prefix = NULL,
  3365. .setup_link = &ixgbe_setup_mac_link_X540,
  3366. .get_link_capabilities = ixgbe_get_link_capabilities_X550em,
  3367. .get_bus_info = ixgbe_get_bus_info_X550em,
  3368. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3369. .acquire_swfw_sync = ixgbe_acquire_swfw_sync_x550em_a,
  3370. .release_swfw_sync = ixgbe_release_swfw_sync_x550em_a,
  3371. .setup_fc = ixgbe_setup_fc_x550em,
  3372. .fc_autoneg = ixgbe_fc_autoneg,
  3373. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a,
  3374. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a,
  3375. };
  3376. static const struct ixgbe_mac_operations mac_ops_x550em_a_fw = {
  3377. X550_COMMON_MAC
  3378. .led_on = ixgbe_led_on_generic,
  3379. .led_off = ixgbe_led_off_generic,
  3380. .init_led_link_act = ixgbe_init_led_link_act_generic,
  3381. .reset_hw = ixgbe_reset_hw_X550em,
  3382. .get_media_type = ixgbe_get_media_type_X550em,
  3383. .get_san_mac_addr = NULL,
  3384. .get_wwn_prefix = NULL,
  3385. .setup_link = NULL, /* defined later */
  3386. .get_link_capabilities = ixgbe_get_link_capabilities_X550em,
  3387. .get_bus_info = ixgbe_get_bus_info_X550em,
  3388. .setup_sfp = ixgbe_setup_sfp_modules_X550em,
  3389. .acquire_swfw_sync = ixgbe_acquire_swfw_sync_x550em_a,
  3390. .release_swfw_sync = ixgbe_release_swfw_sync_x550em_a,
  3391. .setup_fc = ixgbe_setup_fc_x550em,
  3392. .fc_autoneg = ixgbe_fc_autoneg,
  3393. .read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a,
  3394. .write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a,
  3395. };
  3396. #define X550_COMMON_EEP \
  3397. .read = &ixgbe_read_ee_hostif_X550, \
  3398. .read_buffer = &ixgbe_read_ee_hostif_buffer_X550, \
  3399. .write = &ixgbe_write_ee_hostif_X550, \
  3400. .write_buffer = &ixgbe_write_ee_hostif_buffer_X550, \
  3401. .validate_checksum = &ixgbe_validate_eeprom_checksum_X550, \
  3402. .update_checksum = &ixgbe_update_eeprom_checksum_X550, \
  3403. .calc_checksum = &ixgbe_calc_eeprom_checksum_X550, \
  3404. static const struct ixgbe_eeprom_operations eeprom_ops_X550 = {
  3405. X550_COMMON_EEP
  3406. .init_params = &ixgbe_init_eeprom_params_X550,
  3407. };
  3408. static const struct ixgbe_eeprom_operations eeprom_ops_X550EM_x = {
  3409. X550_COMMON_EEP
  3410. .init_params = &ixgbe_init_eeprom_params_X540,
  3411. };
  3412. #define X550_COMMON_PHY \
  3413. .identify_sfp = &ixgbe_identify_module_generic, \
  3414. .reset = NULL, \
  3415. .setup_link_speed = &ixgbe_setup_phy_link_speed_generic, \
  3416. .read_i2c_byte = &ixgbe_read_i2c_byte_generic, \
  3417. .write_i2c_byte = &ixgbe_write_i2c_byte_generic, \
  3418. .read_i2c_sff8472 = &ixgbe_read_i2c_sff8472_generic, \
  3419. .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic, \
  3420. .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic, \
  3421. .setup_link = &ixgbe_setup_phy_link_generic, \
  3422. .set_phy_power = NULL,
  3423. static const struct ixgbe_phy_operations phy_ops_X550 = {
  3424. X550_COMMON_PHY
  3425. .check_overtemp = &ixgbe_tn_check_overtemp,
  3426. .init = NULL,
  3427. .identify = &ixgbe_identify_phy_generic,
  3428. .read_reg = &ixgbe_read_phy_reg_generic,
  3429. .write_reg = &ixgbe_write_phy_reg_generic,
  3430. };
  3431. static const struct ixgbe_phy_operations phy_ops_X550EM_x = {
  3432. X550_COMMON_PHY
  3433. .check_overtemp = &ixgbe_tn_check_overtemp,
  3434. .init = &ixgbe_init_phy_ops_X550em,
  3435. .identify = &ixgbe_identify_phy_x550em,
  3436. .read_reg = &ixgbe_read_phy_reg_generic,
  3437. .write_reg = &ixgbe_write_phy_reg_generic,
  3438. };
  3439. static const struct ixgbe_phy_operations phy_ops_x550em_x_fw = {
  3440. X550_COMMON_PHY
  3441. .check_overtemp = NULL,
  3442. .init = ixgbe_init_phy_ops_X550em,
  3443. .identify = ixgbe_identify_phy_x550em,
  3444. .read_reg = NULL,
  3445. .write_reg = NULL,
  3446. .read_reg_mdi = NULL,
  3447. .write_reg_mdi = NULL,
  3448. };
  3449. static const struct ixgbe_phy_operations phy_ops_x550em_a = {
  3450. X550_COMMON_PHY
  3451. .check_overtemp = &ixgbe_tn_check_overtemp,
  3452. .init = &ixgbe_init_phy_ops_X550em,
  3453. .identify = &ixgbe_identify_phy_x550em,
  3454. .read_reg = &ixgbe_read_phy_reg_x550a,
  3455. .write_reg = &ixgbe_write_phy_reg_x550a,
  3456. .read_reg_mdi = &ixgbe_read_phy_reg_mdi,
  3457. .write_reg_mdi = &ixgbe_write_phy_reg_mdi,
  3458. };
  3459. static const struct ixgbe_phy_operations phy_ops_x550em_a_fw = {
  3460. X550_COMMON_PHY
  3461. .check_overtemp = ixgbe_check_overtemp_fw,
  3462. .init = ixgbe_init_phy_ops_X550em,
  3463. .identify = ixgbe_identify_phy_fw,
  3464. .read_reg = NULL,
  3465. .write_reg = NULL,
  3466. .read_reg_mdi = NULL,
  3467. .write_reg_mdi = NULL,
  3468. };
  3469. static const struct ixgbe_link_operations link_ops_x550em_x = {
  3470. .read_link = &ixgbe_read_i2c_combined_generic,
  3471. .read_link_unlocked = &ixgbe_read_i2c_combined_generic_unlocked,
  3472. .write_link = &ixgbe_write_i2c_combined_generic,
  3473. .write_link_unlocked = &ixgbe_write_i2c_combined_generic_unlocked,
  3474. };
  3475. static const u32 ixgbe_mvals_X550[IXGBE_MVALS_IDX_LIMIT] = {
  3476. IXGBE_MVALS_INIT(X550)
  3477. };
  3478. static const u32 ixgbe_mvals_X550EM_x[IXGBE_MVALS_IDX_LIMIT] = {
  3479. IXGBE_MVALS_INIT(X550EM_x)
  3480. };
  3481. static const u32 ixgbe_mvals_x550em_a[IXGBE_MVALS_IDX_LIMIT] = {
  3482. IXGBE_MVALS_INIT(X550EM_a)
  3483. };
  3484. const struct ixgbe_info ixgbe_X550_info = {
  3485. .mac = ixgbe_mac_X550,
  3486. .get_invariants = &ixgbe_get_invariants_X540,
  3487. .mac_ops = &mac_ops_X550,
  3488. .eeprom_ops = &eeprom_ops_X550,
  3489. .phy_ops = &phy_ops_X550,
  3490. .mbx_ops = &mbx_ops_generic,
  3491. .mvals = ixgbe_mvals_X550,
  3492. };
  3493. const struct ixgbe_info ixgbe_X550EM_x_info = {
  3494. .mac = ixgbe_mac_X550EM_x,
  3495. .get_invariants = &ixgbe_get_invariants_X550_x,
  3496. .mac_ops = &mac_ops_X550EM_x,
  3497. .eeprom_ops = &eeprom_ops_X550EM_x,
  3498. .phy_ops = &phy_ops_X550EM_x,
  3499. .mbx_ops = &mbx_ops_generic,
  3500. .mvals = ixgbe_mvals_X550EM_x,
  3501. .link_ops = &link_ops_x550em_x,
  3502. };
  3503. const struct ixgbe_info ixgbe_x550em_x_fw_info = {
  3504. .mac = ixgbe_mac_X550EM_x,
  3505. .get_invariants = ixgbe_get_invariants_X550_x_fw,
  3506. .mac_ops = &mac_ops_X550EM_x_fw,
  3507. .eeprom_ops = &eeprom_ops_X550EM_x,
  3508. .phy_ops = &phy_ops_x550em_x_fw,
  3509. .mbx_ops = &mbx_ops_generic,
  3510. .mvals = ixgbe_mvals_X550EM_x,
  3511. };
  3512. const struct ixgbe_info ixgbe_x550em_a_info = {
  3513. .mac = ixgbe_mac_x550em_a,
  3514. .get_invariants = &ixgbe_get_invariants_X550_a,
  3515. .mac_ops = &mac_ops_x550em_a,
  3516. .eeprom_ops = &eeprom_ops_X550EM_x,
  3517. .phy_ops = &phy_ops_x550em_a,
  3518. .mbx_ops = &mbx_ops_generic,
  3519. .mvals = ixgbe_mvals_x550em_a,
  3520. };
  3521. const struct ixgbe_info ixgbe_x550em_a_fw_info = {
  3522. .mac = ixgbe_mac_x550em_a,
  3523. .get_invariants = ixgbe_get_invariants_X550_a_fw,
  3524. .mac_ops = &mac_ops_x550em_a_fw,
  3525. .eeprom_ops = &eeprom_ops_X550EM_x,
  3526. .phy_ops = &phy_ops_x550em_a_fw,
  3527. .mbx_ops = &mbx_ops_generic,
  3528. .mvals = ixgbe_mvals_x550em_a,
  3529. };