ixgbe_x550.c 114 KB

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