ixgbe_x550.c 113 KB

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