phy-cadence-torrent.c 136 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Cadence Torrent SD0801 PHY driver.
  4. *
  5. * Copyright 2018 Cadence Design Systems, Inc.
  6. *
  7. */
  8. #include <dt-bindings/phy/phy.h>
  9. #include <dt-bindings/phy/phy-cadence.h>
  10. #include <linux/clk.h>
  11. #include <linux/clk-provider.h>
  12. #include <linux/delay.h>
  13. #include <linux/err.h>
  14. #include <linux/io.h>
  15. #include <linux/iopoll.h>
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/of.h>
  19. #include <linux/of_address.h>
  20. #include <linux/of_device.h>
  21. #include <linux/phy/phy.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/reset.h>
  24. #include <linux/regmap.h>
  25. #define REF_CLK_19_2MHZ 19200000
  26. #define REF_CLK_25MHZ 25000000
  27. #define REF_CLK_100MHZ 100000000
  28. #define MAX_NUM_LANES 4
  29. #define DEFAULT_MAX_BIT_RATE 8100 /* in Mbps */
  30. #define NUM_SSC_MODE 3
  31. #define NUM_REF_CLK 3
  32. #define NUM_PHY_TYPE 6
  33. #define POLL_TIMEOUT_US 5000
  34. #define PLL_LOCK_TIMEOUT 100000
  35. #define TORRENT_COMMON_CDB_OFFSET 0x0
  36. #define TORRENT_TX_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
  37. ((0x4000 << (block_offset)) + \
  38. (((ln) << 9) << (reg_offset)))
  39. #define TORRENT_RX_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
  40. ((0x8000 << (block_offset)) + \
  41. (((ln) << 9) << (reg_offset)))
  42. #define TORRENT_PHY_PCS_COMMON_OFFSET(block_offset) \
  43. (0xC000 << (block_offset))
  44. #define TORRENT_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
  45. ((0xD000 << (block_offset)) + \
  46. (((ln) << 8) << (reg_offset)))
  47. #define TORRENT_PHY_PMA_COMMON_OFFSET(block_offset) \
  48. (0xE000 << (block_offset))
  49. #define TORRENT_DPTX_PHY_OFFSET 0x0
  50. /*
  51. * register offsets from DPTX PHY register block base (i.e MHDP
  52. * register base + 0x30a00)
  53. */
  54. #define PHY_AUX_CTRL 0x04
  55. #define PHY_RESET 0x20
  56. #define PMA_TX_ELEC_IDLE_MASK 0xF0U
  57. #define PMA_TX_ELEC_IDLE_SHIFT 4
  58. #define PHY_L00_RESET_N_MASK 0x01U
  59. #define PHY_PMA_XCVR_PLLCLK_EN 0x24
  60. #define PHY_PMA_XCVR_PLLCLK_EN_ACK 0x28
  61. #define PHY_PMA_XCVR_POWER_STATE_REQ 0x2c
  62. #define PHY_POWER_STATE_LN_0 0x0000
  63. #define PHY_POWER_STATE_LN_1 0x0008
  64. #define PHY_POWER_STATE_LN_2 0x0010
  65. #define PHY_POWER_STATE_LN_3 0x0018
  66. #define PMA_XCVR_POWER_STATE_REQ_LN_MASK 0x3FU
  67. #define PHY_PMA_XCVR_POWER_STATE_ACK 0x30
  68. #define PHY_PMA_CMN_READY 0x34
  69. /*
  70. * register offsets from SD0801 PHY register block base (i.e MHDP
  71. * register base + 0x500000)
  72. */
  73. #define CMN_SSM_BANDGAP_TMR 0x0021U
  74. #define CMN_SSM_BIAS_TMR 0x0022U
  75. #define CMN_PLLSM0_PLLPRE_TMR 0x002AU
  76. #define CMN_PLLSM0_PLLLOCK_TMR 0x002CU
  77. #define CMN_PLLSM1_PLLPRE_TMR 0x0032U
  78. #define CMN_PLLSM1_PLLLOCK_TMR 0x0034U
  79. #define CMN_CDIAG_CDB_PWRI_OVRD 0x0041U
  80. #define CMN_CDIAG_XCVRC_PWRI_OVRD 0x0047U
  81. #define CMN_CDIAG_REFCLK_OVRD 0x004CU
  82. #define CMN_CDIAG_REFCLK_DRV0_CTRL 0x0050U
  83. #define CMN_BGCAL_INIT_TMR 0x0064U
  84. #define CMN_BGCAL_ITER_TMR 0x0065U
  85. #define CMN_IBCAL_INIT_TMR 0x0074U
  86. #define CMN_PLL0_VCOCAL_TCTRL 0x0082U
  87. #define CMN_PLL0_VCOCAL_INIT_TMR 0x0084U
  88. #define CMN_PLL0_VCOCAL_ITER_TMR 0x0085U
  89. #define CMN_PLL0_VCOCAL_REFTIM_START 0x0086U
  90. #define CMN_PLL0_VCOCAL_PLLCNT_START 0x0088U
  91. #define CMN_PLL0_INTDIV_M0 0x0090U
  92. #define CMN_PLL0_FRACDIVL_M0 0x0091U
  93. #define CMN_PLL0_FRACDIVH_M0 0x0092U
  94. #define CMN_PLL0_HIGH_THR_M0 0x0093U
  95. #define CMN_PLL0_DSM_DIAG_M0 0x0094U
  96. #define CMN_PLL0_DSM_FBH_OVRD_M0 0x0095U
  97. #define CMN_PLL0_SS_CTRL1_M0 0x0098U
  98. #define CMN_PLL0_SS_CTRL2_M0 0x0099U
  99. #define CMN_PLL0_SS_CTRL3_M0 0x009AU
  100. #define CMN_PLL0_SS_CTRL4_M0 0x009BU
  101. #define CMN_PLL0_LOCK_REFCNT_START 0x009CU
  102. #define CMN_PLL0_LOCK_PLLCNT_START 0x009EU
  103. #define CMN_PLL0_LOCK_PLLCNT_THR 0x009FU
  104. #define CMN_PLL0_INTDIV_M1 0x00A0U
  105. #define CMN_PLL0_FRACDIVH_M1 0x00A2U
  106. #define CMN_PLL0_HIGH_THR_M1 0x00A3U
  107. #define CMN_PLL0_DSM_DIAG_M1 0x00A4U
  108. #define CMN_PLL0_SS_CTRL1_M1 0x00A8U
  109. #define CMN_PLL0_SS_CTRL2_M1 0x00A9U
  110. #define CMN_PLL0_SS_CTRL3_M1 0x00AAU
  111. #define CMN_PLL0_SS_CTRL4_M1 0x00ABU
  112. #define CMN_PLL1_VCOCAL_TCTRL 0x00C2U
  113. #define CMN_PLL1_VCOCAL_INIT_TMR 0x00C4U
  114. #define CMN_PLL1_VCOCAL_ITER_TMR 0x00C5U
  115. #define CMN_PLL1_VCOCAL_REFTIM_START 0x00C6U
  116. #define CMN_PLL1_VCOCAL_PLLCNT_START 0x00C8U
  117. #define CMN_PLL1_INTDIV_M0 0x00D0U
  118. #define CMN_PLL1_FRACDIVL_M0 0x00D1U
  119. #define CMN_PLL1_FRACDIVH_M0 0x00D2U
  120. #define CMN_PLL1_HIGH_THR_M0 0x00D3U
  121. #define CMN_PLL1_DSM_DIAG_M0 0x00D4U
  122. #define CMN_PLL1_DSM_FBH_OVRD_M0 0x00D5U
  123. #define CMN_PLL1_DSM_FBL_OVRD_M0 0x00D6U
  124. #define CMN_PLL1_SS_CTRL1_M0 0x00D8U
  125. #define CMN_PLL1_SS_CTRL2_M0 0x00D9U
  126. #define CMN_PLL1_SS_CTRL3_M0 0x00DAU
  127. #define CMN_PLL1_SS_CTRL4_M0 0x00DBU
  128. #define CMN_PLL1_LOCK_REFCNT_START 0x00DCU
  129. #define CMN_PLL1_LOCK_PLLCNT_START 0x00DEU
  130. #define CMN_PLL1_LOCK_PLLCNT_THR 0x00DFU
  131. #define CMN_TXPUCAL_TUNE 0x0103U
  132. #define CMN_TXPUCAL_INIT_TMR 0x0104U
  133. #define CMN_TXPUCAL_ITER_TMR 0x0105U
  134. #define CMN_TXPDCAL_TUNE 0x010BU
  135. #define CMN_TXPDCAL_INIT_TMR 0x010CU
  136. #define CMN_TXPDCAL_ITER_TMR 0x010DU
  137. #define CMN_RXCAL_INIT_TMR 0x0114U
  138. #define CMN_RXCAL_ITER_TMR 0x0115U
  139. #define CMN_SD_CAL_INIT_TMR 0x0124U
  140. #define CMN_SD_CAL_ITER_TMR 0x0125U
  141. #define CMN_SD_CAL_REFTIM_START 0x0126U
  142. #define CMN_SD_CAL_PLLCNT_START 0x0128U
  143. #define CMN_PDIAG_PLL0_CTRL_M0 0x01A0U
  144. #define CMN_PDIAG_PLL0_CLK_SEL_M0 0x01A1U
  145. #define CMN_PDIAG_PLL0_CP_PADJ_M0 0x01A4U
  146. #define CMN_PDIAG_PLL0_CP_IADJ_M0 0x01A5U
  147. #define CMN_PDIAG_PLL0_FILT_PADJ_M0 0x01A6U
  148. #define CMN_PDIAG_PLL0_CTRL_M1 0x01B0U
  149. #define CMN_PDIAG_PLL0_CLK_SEL_M1 0x01B1U
  150. #define CMN_PDIAG_PLL0_CP_PADJ_M1 0x01B4U
  151. #define CMN_PDIAG_PLL0_CP_IADJ_M1 0x01B5U
  152. #define CMN_PDIAG_PLL0_FILT_PADJ_M1 0x01B6U
  153. #define CMN_PDIAG_PLL1_CTRL_M0 0x01C0U
  154. #define CMN_PDIAG_PLL1_CLK_SEL_M0 0x01C1U
  155. #define CMN_PDIAG_PLL1_CP_PADJ_M0 0x01C4U
  156. #define CMN_PDIAG_PLL1_CP_IADJ_M0 0x01C5U
  157. #define CMN_PDIAG_PLL1_FILT_PADJ_M0 0x01C6U
  158. #define CMN_DIAG_BIAS_OVRD1 0x01E1U
  159. /* PMA TX Lane registers */
  160. #define TX_TXCC_CTRL 0x0040U
  161. #define TX_TXCC_CPOST_MULT_00 0x004CU
  162. #define TX_TXCC_CPOST_MULT_01 0x004DU
  163. #define TX_TXCC_MGNFS_MULT_000 0x0050U
  164. #define TX_TXCC_MGNFS_MULT_100 0x0054U
  165. #define DRV_DIAG_TX_DRV 0x00C6U
  166. #define XCVR_DIAG_PLLDRC_CTRL 0x00E5U
  167. #define XCVR_DIAG_HSCLK_SEL 0x00E6U
  168. #define XCVR_DIAG_HSCLK_DIV 0x00E7U
  169. #define XCVR_DIAG_RXCLK_CTRL 0x00E9U
  170. #define XCVR_DIAG_BIDI_CTRL 0x00EAU
  171. #define XCVR_DIAG_PSC_OVRD 0x00EBU
  172. #define TX_PSC_A0 0x0100U
  173. #define TX_PSC_A1 0x0101U
  174. #define TX_PSC_A2 0x0102U
  175. #define TX_PSC_A3 0x0103U
  176. #define TX_RCVDET_ST_TMR 0x0123U
  177. #define TX_DIAG_ACYA 0x01E7U
  178. #define TX_DIAG_ACYA_HBDC_MASK 0x0001U
  179. /* PMA RX Lane registers */
  180. #define RX_PSC_A0 0x0000U
  181. #define RX_PSC_A1 0x0001U
  182. #define RX_PSC_A2 0x0002U
  183. #define RX_PSC_A3 0x0003U
  184. #define RX_PSC_CAL 0x0006U
  185. #define RX_CDRLF_CNFG 0x0080U
  186. #define RX_CDRLF_CNFG3 0x0082U
  187. #define RX_SIGDET_HL_FILT_TMR 0x0090U
  188. #define RX_REE_GCSM1_CTRL 0x0108U
  189. #define RX_REE_GCSM1_EQENM_PH1 0x0109U
  190. #define RX_REE_GCSM1_EQENM_PH2 0x010AU
  191. #define RX_REE_GCSM2_CTRL 0x0110U
  192. #define RX_REE_PERGCSM_CTRL 0x0118U
  193. #define RX_REE_ATTEN_THR 0x0149U
  194. #define RX_REE_TAP1_CLIP 0x0171U
  195. #define RX_REE_TAP2TON_CLIP 0x0172U
  196. #define RX_REE_SMGM_CTRL1 0x0177U
  197. #define RX_REE_SMGM_CTRL2 0x0178U
  198. #define RX_DIAG_DFE_CTRL 0x01E0U
  199. #define RX_DIAG_DFE_AMP_TUNE_2 0x01E2U
  200. #define RX_DIAG_DFE_AMP_TUNE_3 0x01E3U
  201. #define RX_DIAG_NQST_CTRL 0x01E5U
  202. #define RX_DIAG_SIGDET_TUNE 0x01E8U
  203. #define RX_DIAG_PI_RATE 0x01F4U
  204. #define RX_DIAG_PI_CAP 0x01F5U
  205. #define RX_DIAG_ACYA 0x01FFU
  206. /* PHY PCS common registers */
  207. #define PHY_PIPE_CMN_CTRL1 0x0000U
  208. #define PHY_PLL_CFG 0x000EU
  209. #define PHY_PIPE_USB3_GEN2_PRE_CFG0 0x0020U
  210. #define PHY_PIPE_USB3_GEN2_POST_CFG0 0x0022U
  211. #define PHY_PIPE_USB3_GEN2_POST_CFG1 0x0023U
  212. /* PHY PCS lane registers */
  213. #define PHY_PCS_ISO_LINK_CTRL 0x000BU
  214. /* PHY PMA common registers */
  215. #define PHY_PMA_CMN_CTRL1 0x0000U
  216. #define PHY_PMA_CMN_CTRL2 0x0001U
  217. #define PHY_PMA_PLL_RAW_CTRL 0x0003U
  218. #define CDNS_TORRENT_OUTPUT_CLOCKS 3
  219. static const char * const clk_names[] = {
  220. [CDNS_TORRENT_REFCLK_DRIVER] = "refclk-driver",
  221. [CDNS_TORRENT_DERIVED_REFCLK] = "refclk-der",
  222. [CDNS_TORRENT_RECEIVED_REFCLK] = "refclk-rec",
  223. };
  224. static const struct reg_field phy_pll_cfg =
  225. REG_FIELD(PHY_PLL_CFG, 0, 1);
  226. static const struct reg_field phy_pma_cmn_ctrl_1 =
  227. REG_FIELD(PHY_PMA_CMN_CTRL1, 0, 0);
  228. static const struct reg_field phy_pma_cmn_ctrl_2 =
  229. REG_FIELD(PHY_PMA_CMN_CTRL2, 0, 7);
  230. static const struct reg_field phy_pma_pll_raw_ctrl =
  231. REG_FIELD(PHY_PMA_PLL_RAW_CTRL, 0, 1);
  232. static const struct reg_field phy_reset_ctrl =
  233. REG_FIELD(PHY_RESET, 8, 8);
  234. static const struct reg_field phy_pcs_iso_link_ctrl_1 =
  235. REG_FIELD(PHY_PCS_ISO_LINK_CTRL, 1, 1);
  236. static const struct reg_field phy_pipe_cmn_ctrl1_0 = REG_FIELD(PHY_PIPE_CMN_CTRL1, 0, 0);
  237. static const struct reg_field cmn_cdiag_refclk_ovrd_4 =
  238. REG_FIELD(CMN_CDIAG_REFCLK_OVRD, 4, 4);
  239. #define REFCLK_OUT_NUM_CMN_CONFIG 4
  240. enum cdns_torrent_refclk_out_cmn {
  241. CMN_CDIAG_REFCLK_DRV0_CTRL_1,
  242. CMN_CDIAG_REFCLK_DRV0_CTRL_4,
  243. CMN_CDIAG_REFCLK_DRV0_CTRL_5,
  244. CMN_CDIAG_REFCLK_DRV0_CTRL_6,
  245. };
  246. static const struct reg_field refclk_out_cmn_cfg[] = {
  247. [CMN_CDIAG_REFCLK_DRV0_CTRL_1] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 1, 1),
  248. [CMN_CDIAG_REFCLK_DRV0_CTRL_4] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 4, 4),
  249. [CMN_CDIAG_REFCLK_DRV0_CTRL_5] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 5, 5),
  250. [CMN_CDIAG_REFCLK_DRV0_CTRL_6] = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 6, 6),
  251. };
  252. static const int refclk_driver_parent_index[] = {
  253. CDNS_TORRENT_DERIVED_REFCLK,
  254. CDNS_TORRENT_RECEIVED_REFCLK
  255. };
  256. static u32 cdns_torrent_refclk_driver_mux_table[] = { 1, 0 };
  257. enum cdns_torrent_phy_type {
  258. TYPE_NONE,
  259. TYPE_DP,
  260. TYPE_PCIE,
  261. TYPE_SGMII,
  262. TYPE_QSGMII,
  263. TYPE_USB,
  264. };
  265. enum cdns_torrent_ref_clk {
  266. CLK_19_2_MHZ,
  267. CLK_25_MHZ,
  268. CLK_100_MHZ
  269. };
  270. enum cdns_torrent_ssc_mode {
  271. NO_SSC,
  272. EXTERNAL_SSC,
  273. INTERNAL_SSC
  274. };
  275. struct cdns_torrent_inst {
  276. struct phy *phy;
  277. u32 mlane;
  278. enum cdns_torrent_phy_type phy_type;
  279. u32 num_lanes;
  280. struct reset_control *lnk_rst;
  281. enum cdns_torrent_ssc_mode ssc_mode;
  282. };
  283. struct cdns_torrent_phy {
  284. void __iomem *base; /* DPTX registers base */
  285. void __iomem *sd_base; /* SD0801 registers base */
  286. u32 max_bit_rate; /* Maximum link bit rate to use (in Mbps) */
  287. struct reset_control *phy_rst;
  288. struct reset_control *apb_rst;
  289. struct device *dev;
  290. struct clk *clk;
  291. enum cdns_torrent_ref_clk ref_clk_rate;
  292. struct cdns_torrent_inst phys[MAX_NUM_LANES];
  293. int nsubnodes;
  294. const struct cdns_torrent_data *init_data;
  295. struct regmap *regmap_common_cdb;
  296. struct regmap *regmap_phy_pcs_common_cdb;
  297. struct regmap *regmap_phy_pma_common_cdb;
  298. struct regmap *regmap_tx_lane_cdb[MAX_NUM_LANES];
  299. struct regmap *regmap_rx_lane_cdb[MAX_NUM_LANES];
  300. struct regmap *regmap_phy_pcs_lane_cdb[MAX_NUM_LANES];
  301. struct regmap *regmap_dptx_phy_reg;
  302. struct regmap_field *phy_pll_cfg;
  303. struct regmap_field *phy_pipe_cmn_ctrl1_0;
  304. struct regmap_field *cmn_cdiag_refclk_ovrd_4;
  305. struct regmap_field *phy_pma_cmn_ctrl_1;
  306. struct regmap_field *phy_pma_cmn_ctrl_2;
  307. struct regmap_field *phy_pma_pll_raw_ctrl;
  308. struct regmap_field *phy_reset_ctrl;
  309. struct regmap_field *phy_pcs_iso_link_ctrl_1[MAX_NUM_LANES];
  310. struct clk_hw_onecell_data *clk_hw_data;
  311. };
  312. enum phy_powerstate {
  313. POWERSTATE_A0 = 0,
  314. /* Powerstate A1 is unused */
  315. POWERSTATE_A2 = 2,
  316. POWERSTATE_A3 = 3,
  317. };
  318. struct cdns_torrent_refclk_driver {
  319. struct clk_hw hw;
  320. struct regmap_field *cmn_fields[REFCLK_OUT_NUM_CMN_CONFIG];
  321. struct clk_init_data clk_data;
  322. };
  323. #define to_cdns_torrent_refclk_driver(_hw) \
  324. container_of(_hw, struct cdns_torrent_refclk_driver, hw)
  325. struct cdns_torrent_derived_refclk {
  326. struct clk_hw hw;
  327. struct regmap_field *phy_pipe_cmn_ctrl1_0;
  328. struct regmap_field *cmn_cdiag_refclk_ovrd_4;
  329. struct clk_init_data clk_data;
  330. };
  331. #define to_cdns_torrent_derived_refclk(_hw) \
  332. container_of(_hw, struct cdns_torrent_derived_refclk, hw)
  333. struct cdns_torrent_received_refclk {
  334. struct clk_hw hw;
  335. struct regmap_field *phy_pipe_cmn_ctrl1_0;
  336. struct regmap_field *cmn_cdiag_refclk_ovrd_4;
  337. struct clk_init_data clk_data;
  338. };
  339. #define to_cdns_torrent_received_refclk(_hw) \
  340. container_of(_hw, struct cdns_torrent_received_refclk, hw)
  341. struct cdns_reg_pairs {
  342. u32 val;
  343. u32 off;
  344. };
  345. struct cdns_torrent_vals {
  346. struct cdns_reg_pairs *reg_pairs;
  347. u32 num_regs;
  348. };
  349. struct cdns_torrent_data {
  350. u8 block_offset_shift;
  351. u8 reg_offset_shift;
  352. struct cdns_torrent_vals *link_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
  353. [NUM_SSC_MODE];
  354. struct cdns_torrent_vals *xcvr_diag_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
  355. [NUM_SSC_MODE];
  356. struct cdns_torrent_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
  357. [NUM_SSC_MODE];
  358. struct cdns_torrent_vals *cmn_vals[NUM_REF_CLK][NUM_PHY_TYPE]
  359. [NUM_PHY_TYPE][NUM_SSC_MODE];
  360. struct cdns_torrent_vals *tx_ln_vals[NUM_REF_CLK][NUM_PHY_TYPE]
  361. [NUM_PHY_TYPE][NUM_SSC_MODE];
  362. struct cdns_torrent_vals *rx_ln_vals[NUM_REF_CLK][NUM_PHY_TYPE]
  363. [NUM_PHY_TYPE][NUM_SSC_MODE];
  364. };
  365. struct cdns_regmap_cdb_context {
  366. struct device *dev;
  367. void __iomem *base;
  368. u8 reg_offset_shift;
  369. };
  370. static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
  371. {
  372. struct cdns_regmap_cdb_context *ctx = context;
  373. u32 offset = reg << ctx->reg_offset_shift;
  374. writew(val, ctx->base + offset);
  375. return 0;
  376. }
  377. static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
  378. {
  379. struct cdns_regmap_cdb_context *ctx = context;
  380. u32 offset = reg << ctx->reg_offset_shift;
  381. *val = readw(ctx->base + offset);
  382. return 0;
  383. }
  384. static int cdns_regmap_dptx_write(void *context, unsigned int reg,
  385. unsigned int val)
  386. {
  387. struct cdns_regmap_cdb_context *ctx = context;
  388. u32 offset = reg;
  389. writel(val, ctx->base + offset);
  390. return 0;
  391. }
  392. static int cdns_regmap_dptx_read(void *context, unsigned int reg,
  393. unsigned int *val)
  394. {
  395. struct cdns_regmap_cdb_context *ctx = context;
  396. u32 offset = reg;
  397. *val = readl(ctx->base + offset);
  398. return 0;
  399. }
  400. #define TORRENT_TX_LANE_CDB_REGMAP_CONF(n) \
  401. { \
  402. .name = "torrent_tx_lane" n "_cdb", \
  403. .reg_stride = 1, \
  404. .fast_io = true, \
  405. .reg_write = cdns_regmap_write, \
  406. .reg_read = cdns_regmap_read, \
  407. }
  408. #define TORRENT_RX_LANE_CDB_REGMAP_CONF(n) \
  409. { \
  410. .name = "torrent_rx_lane" n "_cdb", \
  411. .reg_stride = 1, \
  412. .fast_io = true, \
  413. .reg_write = cdns_regmap_write, \
  414. .reg_read = cdns_regmap_read, \
  415. }
  416. static const struct regmap_config cdns_torrent_tx_lane_cdb_config[] = {
  417. TORRENT_TX_LANE_CDB_REGMAP_CONF("0"),
  418. TORRENT_TX_LANE_CDB_REGMAP_CONF("1"),
  419. TORRENT_TX_LANE_CDB_REGMAP_CONF("2"),
  420. TORRENT_TX_LANE_CDB_REGMAP_CONF("3"),
  421. };
  422. static const struct regmap_config cdns_torrent_rx_lane_cdb_config[] = {
  423. TORRENT_RX_LANE_CDB_REGMAP_CONF("0"),
  424. TORRENT_RX_LANE_CDB_REGMAP_CONF("1"),
  425. TORRENT_RX_LANE_CDB_REGMAP_CONF("2"),
  426. TORRENT_RX_LANE_CDB_REGMAP_CONF("3"),
  427. };
  428. static const struct regmap_config cdns_torrent_common_cdb_config = {
  429. .name = "torrent_common_cdb",
  430. .reg_stride = 1,
  431. .fast_io = true,
  432. .reg_write = cdns_regmap_write,
  433. .reg_read = cdns_regmap_read,
  434. };
  435. #define TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
  436. { \
  437. .name = "torrent_phy_pcs_lane" n "_cdb", \
  438. .reg_stride = 1, \
  439. .fast_io = true, \
  440. .reg_write = cdns_regmap_write, \
  441. .reg_read = cdns_regmap_read, \
  442. }
  443. static const struct regmap_config cdns_torrent_phy_pcs_lane_cdb_config[] = {
  444. TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
  445. TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
  446. TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
  447. TORRENT_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
  448. };
  449. static const struct regmap_config cdns_torrent_phy_pcs_cmn_cdb_config = {
  450. .name = "torrent_phy_pcs_cmn_cdb",
  451. .reg_stride = 1,
  452. .fast_io = true,
  453. .reg_write = cdns_regmap_write,
  454. .reg_read = cdns_regmap_read,
  455. };
  456. static const struct regmap_config cdns_torrent_phy_pma_cmn_cdb_config = {
  457. .name = "torrent_phy_pma_cmn_cdb",
  458. .reg_stride = 1,
  459. .fast_io = true,
  460. .reg_write = cdns_regmap_write,
  461. .reg_read = cdns_regmap_read,
  462. };
  463. static const struct regmap_config cdns_torrent_dptx_phy_config = {
  464. .name = "torrent_dptx_phy",
  465. .reg_stride = 1,
  466. .fast_io = true,
  467. .reg_write = cdns_regmap_dptx_write,
  468. .reg_read = cdns_regmap_dptx_read,
  469. };
  470. /* PHY mmr access functions */
  471. static void cdns_torrent_phy_write(struct regmap *regmap, u32 offset, u32 val)
  472. {
  473. regmap_write(regmap, offset, val);
  474. }
  475. static u32 cdns_torrent_phy_read(struct regmap *regmap, u32 offset)
  476. {
  477. unsigned int val;
  478. regmap_read(regmap, offset, &val);
  479. return val;
  480. }
  481. /* DPTX mmr access functions */
  482. static void cdns_torrent_dp_write(struct regmap *regmap, u32 offset, u32 val)
  483. {
  484. regmap_write(regmap, offset, val);
  485. }
  486. static u32 cdns_torrent_dp_read(struct regmap *regmap, u32 offset)
  487. {
  488. u32 val;
  489. regmap_read(regmap, offset, &val);
  490. return val;
  491. }
  492. /*
  493. * Structure used to store values of PHY registers for voltage-related
  494. * coefficients, for particular voltage swing and pre-emphasis level. Values
  495. * are shared across all physical lanes.
  496. */
  497. struct coefficients {
  498. /* Value of DRV_DIAG_TX_DRV register to use */
  499. u16 diag_tx_drv;
  500. /* Value of TX_TXCC_MGNFS_MULT_000 register to use */
  501. u16 mgnfs_mult;
  502. /* Value of TX_TXCC_CPOST_MULT_00 register to use */
  503. u16 cpost_mult;
  504. };
  505. /*
  506. * Array consists of values of voltage-related registers for sd0801 PHY. A value
  507. * of 0xFFFF is a placeholder for invalid combination, and will never be used.
  508. */
  509. static const struct coefficients vltg_coeff[4][4] = {
  510. /* voltage swing 0, pre-emphasis 0->3 */
  511. { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x002A,
  512. .cpost_mult = 0x0000},
  513. {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x001F,
  514. .cpost_mult = 0x0014},
  515. {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0012,
  516. .cpost_mult = 0x0020},
  517. {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
  518. .cpost_mult = 0x002A}
  519. },
  520. /* voltage swing 1, pre-emphasis 0->3 */
  521. { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x001F,
  522. .cpost_mult = 0x0000},
  523. {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0013,
  524. .cpost_mult = 0x0012},
  525. {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
  526. .cpost_mult = 0x001F},
  527. {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
  528. .cpost_mult = 0xFFFF}
  529. },
  530. /* voltage swing 2, pre-emphasis 0->3 */
  531. { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0013,
  532. .cpost_mult = 0x0000},
  533. {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
  534. .cpost_mult = 0x0013},
  535. {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
  536. .cpost_mult = 0xFFFF},
  537. {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
  538. .cpost_mult = 0xFFFF}
  539. },
  540. /* voltage swing 3, pre-emphasis 0->3 */
  541. { {.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
  542. .cpost_mult = 0x0000},
  543. {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
  544. .cpost_mult = 0xFFFF},
  545. {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
  546. .cpost_mult = 0xFFFF},
  547. {.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
  548. .cpost_mult = 0xFFFF}
  549. }
  550. };
  551. static const char *cdns_torrent_get_phy_type(enum cdns_torrent_phy_type phy_type)
  552. {
  553. switch (phy_type) {
  554. case TYPE_DP:
  555. return "DisplayPort";
  556. case TYPE_PCIE:
  557. return "PCIe";
  558. case TYPE_SGMII:
  559. return "SGMII";
  560. case TYPE_QSGMII:
  561. return "QSGMII";
  562. case TYPE_USB:
  563. return "USB";
  564. default:
  565. return "None";
  566. }
  567. }
  568. /*
  569. * Set registers responsible for enabling and configuring SSC, with second and
  570. * third register values provided by parameters.
  571. */
  572. static
  573. void cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy *cdns_phy,
  574. u32 ctrl2_val, u32 ctrl3_val)
  575. {
  576. struct regmap *regmap = cdns_phy->regmap_common_cdb;
  577. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0001);
  578. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl2_val);
  579. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl3_val);
  580. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0003);
  581. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0001);
  582. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl2_val);
  583. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl3_val);
  584. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0003);
  585. }
  586. static
  587. void cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy,
  588. u32 rate, bool ssc)
  589. {
  590. struct regmap *regmap = cdns_phy->regmap_common_cdb;
  591. /* Assumes 19.2 MHz refclock */
  592. switch (rate) {
  593. /* Setting VCO for 10.8GHz */
  594. case 2700:
  595. case 5400:
  596. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0119);
  597. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x4000);
  598. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  599. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00BC);
  600. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0012);
  601. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0119);
  602. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x4000);
  603. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  604. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00BC);
  605. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0012);
  606. if (ssc)
  607. cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x033A, 0x006A);
  608. break;
  609. /* Setting VCO for 9.72GHz */
  610. case 1620:
  611. case 2430:
  612. case 3240:
  613. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01FA);
  614. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x4000);
  615. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  616. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0152);
  617. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
  618. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01FA);
  619. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x4000);
  620. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  621. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0152);
  622. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
  623. if (ssc)
  624. cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x05DD, 0x0069);
  625. break;
  626. /* Setting VCO for 8.64GHz */
  627. case 2160:
  628. case 4320:
  629. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01C2);
  630. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
  631. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  632. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x012C);
  633. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
  634. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01C2);
  635. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
  636. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  637. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x012C);
  638. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
  639. if (ssc)
  640. cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x0536, 0x0069);
  641. break;
  642. /* Setting VCO for 8.1GHz */
  643. case 8100:
  644. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01A5);
  645. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0xE000);
  646. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  647. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x011A);
  648. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
  649. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01A5);
  650. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0xE000);
  651. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  652. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x011A);
  653. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
  654. if (ssc)
  655. cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x04D7, 0x006A);
  656. break;
  657. }
  658. if (ssc) {
  659. cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_PLLCNT_START, 0x025E);
  660. cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_THR, 0x0005);
  661. cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_PLLCNT_START, 0x025E);
  662. cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_THR, 0x0005);
  663. } else {
  664. cdns_torrent_phy_write(regmap, CMN_PLL0_VCOCAL_PLLCNT_START, 0x0260);
  665. cdns_torrent_phy_write(regmap, CMN_PLL1_VCOCAL_PLLCNT_START, 0x0260);
  666. /* Set reset register values to disable SSC */
  667. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0002);
  668. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL2_M0, 0x0000);
  669. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL3_M0, 0x0000);
  670. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0000);
  671. cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_THR, 0x0003);
  672. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0002);
  673. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL2_M0, 0x0000);
  674. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL3_M0, 0x0000);
  675. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0000);
  676. cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_THR, 0x0003);
  677. }
  678. cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_REFCNT_START, 0x0099);
  679. cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_START, 0x0099);
  680. cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_REFCNT_START, 0x0099);
  681. cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_START, 0x0099);
  682. }
  683. /*
  684. * Set registers responsible for enabling and configuring SSC, with second
  685. * register value provided by a parameter.
  686. */
  687. static void cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy *cdns_phy,
  688. u32 ctrl2_val)
  689. {
  690. struct regmap *regmap = cdns_phy->regmap_common_cdb;
  691. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0001);
  692. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, ctrl2_val);
  693. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x007F);
  694. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0003);
  695. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0001);
  696. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, ctrl2_val);
  697. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x007F);
  698. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0003);
  699. }
  700. static
  701. void cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy *cdns_phy,
  702. u32 rate, bool ssc)
  703. {
  704. struct regmap *regmap = cdns_phy->regmap_common_cdb;
  705. /* Assumes 25 MHz refclock */
  706. switch (rate) {
  707. /* Setting VCO for 10.8GHz */
  708. case 2700:
  709. case 5400:
  710. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x01B0);
  711. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
  712. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  713. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0120);
  714. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x01B0);
  715. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
  716. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  717. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0120);
  718. if (ssc)
  719. cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x0423);
  720. break;
  721. /* Setting VCO for 9.72GHz */
  722. case 1620:
  723. case 2430:
  724. case 3240:
  725. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0184);
  726. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0xCCCD);
  727. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  728. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0104);
  729. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0184);
  730. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0xCCCD);
  731. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  732. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0104);
  733. if (ssc)
  734. cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x03B9);
  735. break;
  736. /* Setting VCO for 8.64GHz */
  737. case 2160:
  738. case 4320:
  739. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0159);
  740. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x999A);
  741. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  742. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00E7);
  743. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0159);
  744. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x999A);
  745. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  746. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00E7);
  747. if (ssc)
  748. cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x034F);
  749. break;
  750. /* Setting VCO for 8.1GHz */
  751. case 8100:
  752. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0144);
  753. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x0000);
  754. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  755. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x00D8);
  756. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0144);
  757. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x0000);
  758. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  759. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x00D8);
  760. if (ssc)
  761. cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x031A);
  762. break;
  763. }
  764. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
  765. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
  766. if (ssc) {
  767. cdns_torrent_phy_write(regmap,
  768. CMN_PLL0_VCOCAL_PLLCNT_START, 0x0315);
  769. cdns_torrent_phy_write(regmap,
  770. CMN_PLL0_LOCK_PLLCNT_THR, 0x0005);
  771. cdns_torrent_phy_write(regmap,
  772. CMN_PLL1_VCOCAL_PLLCNT_START, 0x0315);
  773. cdns_torrent_phy_write(regmap,
  774. CMN_PLL1_LOCK_PLLCNT_THR, 0x0005);
  775. } else {
  776. cdns_torrent_phy_write(regmap,
  777. CMN_PLL0_VCOCAL_PLLCNT_START, 0x0317);
  778. cdns_torrent_phy_write(regmap,
  779. CMN_PLL1_VCOCAL_PLLCNT_START, 0x0317);
  780. /* Set reset register values to disable SSC */
  781. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL1_M0, 0x0002);
  782. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL2_M0, 0x0000);
  783. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL3_M0, 0x0000);
  784. cdns_torrent_phy_write(regmap, CMN_PLL0_SS_CTRL4_M0, 0x0000);
  785. cdns_torrent_phy_write(regmap,
  786. CMN_PLL0_LOCK_PLLCNT_THR, 0x0003);
  787. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL1_M0, 0x0002);
  788. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL2_M0, 0x0000);
  789. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL3_M0, 0x0000);
  790. cdns_torrent_phy_write(regmap, CMN_PLL1_SS_CTRL4_M0, 0x0000);
  791. cdns_torrent_phy_write(regmap,
  792. CMN_PLL1_LOCK_PLLCNT_THR, 0x0003);
  793. }
  794. cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_REFCNT_START, 0x00C7);
  795. cdns_torrent_phy_write(regmap, CMN_PLL0_LOCK_PLLCNT_START, 0x00C7);
  796. cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_REFCNT_START, 0x00C7);
  797. cdns_torrent_phy_write(regmap, CMN_PLL1_LOCK_PLLCNT_START, 0x00C7);
  798. }
  799. static
  800. void cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(struct cdns_torrent_phy *cdns_phy,
  801. u32 rate, bool ssc)
  802. {
  803. struct regmap *regmap = cdns_phy->regmap_common_cdb;
  804. /* Assumes 100 MHz refclock */
  805. switch (rate) {
  806. /* Setting VCO for 10.8GHz */
  807. case 2700:
  808. case 5400:
  809. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0028);
  810. cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_FBH_OVRD_M0, 0x0022);
  811. cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_FBH_OVRD_M0, 0x0022);
  812. cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_FBL_OVRD_M0, 0x000C);
  813. break;
  814. /* Setting VCO for 9.72GHz */
  815. case 1620:
  816. case 2430:
  817. case 3240:
  818. cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
  819. cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
  820. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
  821. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
  822. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
  823. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
  824. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
  825. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
  826. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0061);
  827. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0061);
  828. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x3333);
  829. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x3333);
  830. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  831. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  832. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0042);
  833. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0042);
  834. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
  835. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
  836. break;
  837. /* Setting VCO for 8.64GHz */
  838. case 2160:
  839. case 4320:
  840. cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
  841. cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
  842. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
  843. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
  844. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
  845. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
  846. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
  847. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
  848. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0056);
  849. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0056);
  850. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVL_M0, 0x6666);
  851. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVL_M0, 0x6666);
  852. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  853. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  854. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x003A);
  855. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x003A);
  856. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
  857. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
  858. break;
  859. /* Setting VCO for 8.1GHz */
  860. case 8100:
  861. cdns_torrent_phy_write(regmap, CMN_PLL0_DSM_DIAG_M0, 0x0004);
  862. cdns_torrent_phy_write(regmap, CMN_PLL1_DSM_DIAG_M0, 0x0004);
  863. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_PADJ_M0, 0x0509);
  864. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_PADJ_M0, 0x0509);
  865. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CP_IADJ_M0, 0x0F00);
  866. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CP_IADJ_M0, 0x0F00);
  867. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_FILT_PADJ_M0, 0x0F08);
  868. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_FILT_PADJ_M0, 0x0F08);
  869. cdns_torrent_phy_write(regmap, CMN_PLL0_INTDIV_M0, 0x0051);
  870. cdns_torrent_phy_write(regmap, CMN_PLL1_INTDIV_M0, 0x0051);
  871. cdns_torrent_phy_write(regmap, CMN_PLL0_FRACDIVH_M0, 0x0002);
  872. cdns_torrent_phy_write(regmap, CMN_PLL1_FRACDIVH_M0, 0x0002);
  873. cdns_torrent_phy_write(regmap, CMN_PLL0_HIGH_THR_M0, 0x0036);
  874. cdns_torrent_phy_write(regmap, CMN_PLL1_HIGH_THR_M0, 0x0036);
  875. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL0_CTRL_M0, 0x0002);
  876. cdns_torrent_phy_write(regmap, CMN_PDIAG_PLL1_CTRL_M0, 0x0002);
  877. break;
  878. }
  879. }
  880. /*
  881. * Enable or disable PLL for selected lanes.
  882. */
  883. static int cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy *cdns_phy,
  884. struct phy_configure_opts_dp *dp,
  885. bool enable)
  886. {
  887. u32 rd_val;
  888. u32 ret;
  889. struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
  890. /*
  891. * Used to determine, which bits to check for or enable in
  892. * PHY_PMA_XCVR_PLLCLK_EN register.
  893. */
  894. u32 pll_bits;
  895. /* Used to enable or disable lanes. */
  896. u32 pll_val;
  897. /* Select values of registers and mask, depending on enabled lane
  898. * count.
  899. */
  900. switch (dp->lanes) {
  901. /* lane 0 */
  902. case (1):
  903. pll_bits = 0x00000001;
  904. break;
  905. /* lanes 0-1 */
  906. case (2):
  907. pll_bits = 0x00000003;
  908. break;
  909. /* lanes 0-3, all */
  910. default:
  911. pll_bits = 0x0000000F;
  912. break;
  913. }
  914. if (enable)
  915. pll_val = pll_bits;
  916. else
  917. pll_val = 0x00000000;
  918. cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, pll_val);
  919. /* Wait for acknowledgment from PHY. */
  920. ret = regmap_read_poll_timeout(regmap,
  921. PHY_PMA_XCVR_PLLCLK_EN_ACK,
  922. rd_val,
  923. (rd_val & pll_bits) == pll_val,
  924. 0, POLL_TIMEOUT_US);
  925. ndelay(100);
  926. return ret;
  927. }
  928. static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy,
  929. u32 num_lanes,
  930. enum phy_powerstate powerstate)
  931. {
  932. /* Register value for power state for a single byte. */
  933. u32 value_part;
  934. u32 value;
  935. u32 mask;
  936. u32 read_val;
  937. u32 ret;
  938. struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
  939. switch (powerstate) {
  940. case (POWERSTATE_A0):
  941. value_part = 0x01U;
  942. break;
  943. case (POWERSTATE_A2):
  944. value_part = 0x04U;
  945. break;
  946. default:
  947. /* Powerstate A3 */
  948. value_part = 0x08U;
  949. break;
  950. }
  951. /* Select values of registers and mask, depending on enabled
  952. * lane count.
  953. */
  954. switch (num_lanes) {
  955. /* lane 0 */
  956. case (1):
  957. value = value_part;
  958. mask = 0x0000003FU;
  959. break;
  960. /* lanes 0-1 */
  961. case (2):
  962. value = (value_part
  963. | (value_part << 8));
  964. mask = 0x00003F3FU;
  965. break;
  966. /* lanes 0-3, all */
  967. default:
  968. value = (value_part
  969. | (value_part << 8)
  970. | (value_part << 16)
  971. | (value_part << 24));
  972. mask = 0x3F3F3F3FU;
  973. break;
  974. }
  975. /* Set power state A<n>. */
  976. cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, value);
  977. /* Wait, until PHY acknowledges power state completion. */
  978. ret = regmap_read_poll_timeout(regmap, PHY_PMA_XCVR_POWER_STATE_ACK,
  979. read_val, (read_val & mask) == value, 0,
  980. POLL_TIMEOUT_US);
  981. cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, 0x00000000);
  982. ndelay(100);
  983. return ret;
  984. }
  985. static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy, u32 num_lanes)
  986. {
  987. unsigned int read_val;
  988. int ret;
  989. struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
  990. /*
  991. * waiting for ACK of pma_xcvr_pllclk_en_ln_*, only for the
  992. * master lane
  993. */
  994. ret = regmap_read_poll_timeout(regmap, PHY_PMA_XCVR_PLLCLK_EN_ACK,
  995. read_val, read_val & 1,
  996. 0, POLL_TIMEOUT_US);
  997. if (ret == -ETIMEDOUT) {
  998. dev_err(cdns_phy->dev,
  999. "timeout waiting for link PLL clock enable ack\n");
  1000. return ret;
  1001. }
  1002. ndelay(100);
  1003. ret = cdns_torrent_dp_set_power_state(cdns_phy, num_lanes,
  1004. POWERSTATE_A2);
  1005. if (ret)
  1006. return ret;
  1007. ret = cdns_torrent_dp_set_power_state(cdns_phy, num_lanes,
  1008. POWERSTATE_A0);
  1009. return ret;
  1010. }
  1011. static int cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy *cdns_phy)
  1012. {
  1013. unsigned int reg;
  1014. int ret;
  1015. struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
  1016. ret = regmap_read_poll_timeout(regmap, PHY_PMA_CMN_READY, reg,
  1017. reg & 1, 0, POLL_TIMEOUT_US);
  1018. if (ret == -ETIMEDOUT) {
  1019. dev_err(cdns_phy->dev,
  1020. "timeout waiting for PMA common ready\n");
  1021. return -ETIMEDOUT;
  1022. }
  1023. return 0;
  1024. }
  1025. static void cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy *cdns_phy,
  1026. u32 rate, u32 num_lanes)
  1027. {
  1028. unsigned int clk_sel_val = 0;
  1029. unsigned int hsclk_div_val = 0;
  1030. unsigned int i;
  1031. switch (rate) {
  1032. case 1620:
  1033. clk_sel_val = 0x0f01;
  1034. hsclk_div_val = 2;
  1035. break;
  1036. case 2160:
  1037. case 2430:
  1038. case 2700:
  1039. clk_sel_val = 0x0701;
  1040. hsclk_div_val = 1;
  1041. break;
  1042. case 3240:
  1043. clk_sel_val = 0x0b00;
  1044. hsclk_div_val = 2;
  1045. break;
  1046. case 4320:
  1047. case 5400:
  1048. clk_sel_val = 0x0301;
  1049. hsclk_div_val = 0;
  1050. break;
  1051. case 8100:
  1052. clk_sel_val = 0x0200;
  1053. hsclk_div_val = 0;
  1054. break;
  1055. }
  1056. cdns_torrent_phy_write(cdns_phy->regmap_common_cdb,
  1057. CMN_PDIAG_PLL0_CLK_SEL_M0, clk_sel_val);
  1058. cdns_torrent_phy_write(cdns_phy->regmap_common_cdb,
  1059. CMN_PDIAG_PLL1_CLK_SEL_M0, clk_sel_val);
  1060. /* PMA lane configuration to deal with multi-link operation */
  1061. for (i = 0; i < num_lanes; i++)
  1062. cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[i],
  1063. XCVR_DIAG_HSCLK_DIV, hsclk_div_val);
  1064. }
  1065. /*
  1066. * Perform register operations related to setting link rate, once powerstate is
  1067. * set and PLL disable request was processed.
  1068. */
  1069. static int cdns_torrent_dp_configure_rate(struct cdns_torrent_phy *cdns_phy,
  1070. struct phy_configure_opts_dp *dp)
  1071. {
  1072. u32 read_val, ret;
  1073. /* Disable the cmn_pll0_en before re-programming the new data rate. */
  1074. regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x0);
  1075. /*
  1076. * Wait for PLL ready de-assertion.
  1077. * For PLL0 - PHY_PMA_CMN_CTRL2[2] == 1
  1078. */
  1079. ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
  1080. read_val,
  1081. ((read_val >> 2) & 0x01) != 0,
  1082. 0, POLL_TIMEOUT_US);
  1083. if (ret)
  1084. return ret;
  1085. ndelay(200);
  1086. /* DP Rate Change - VCO Output settings. */
  1087. if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ)
  1088. /* PMA common configuration 19.2MHz */
  1089. cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, dp->ssc);
  1090. else if (cdns_phy->ref_clk_rate == CLK_25_MHZ)
  1091. /* PMA common configuration 25MHz */
  1092. cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, dp->ssc);
  1093. else if (cdns_phy->ref_clk_rate == CLK_100_MHZ)
  1094. /* PMA common configuration 100MHz */
  1095. cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, dp->link_rate, dp->ssc);
  1096. cdns_torrent_dp_pma_cmn_rate(cdns_phy, dp->link_rate, dp->lanes);
  1097. /* Enable the cmn_pll0_en. */
  1098. regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x3);
  1099. /*
  1100. * Wait for PLL ready assertion.
  1101. * For PLL0 - PHY_PMA_CMN_CTRL2[0] == 1
  1102. */
  1103. ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2,
  1104. read_val,
  1105. (read_val & 0x01) != 0,
  1106. 0, POLL_TIMEOUT_US);
  1107. return ret;
  1108. }
  1109. /*
  1110. * Verify, that parameters to configure PHY with are correct.
  1111. */
  1112. static int cdns_torrent_dp_verify_config(struct cdns_torrent_inst *inst,
  1113. struct phy_configure_opts_dp *dp)
  1114. {
  1115. u8 i;
  1116. /* If changing link rate was required, verify it's supported. */
  1117. if (dp->set_rate) {
  1118. switch (dp->link_rate) {
  1119. case 1620:
  1120. case 2160:
  1121. case 2430:
  1122. case 2700:
  1123. case 3240:
  1124. case 4320:
  1125. case 5400:
  1126. case 8100:
  1127. /* valid bit rate */
  1128. break;
  1129. default:
  1130. return -EINVAL;
  1131. }
  1132. }
  1133. /* Verify lane count. */
  1134. switch (dp->lanes) {
  1135. case 1:
  1136. case 2:
  1137. case 4:
  1138. /* valid lane count. */
  1139. break;
  1140. default:
  1141. return -EINVAL;
  1142. }
  1143. /* Check against actual number of PHY's lanes. */
  1144. if (dp->lanes > inst->num_lanes)
  1145. return -EINVAL;
  1146. /*
  1147. * If changing voltages is required, check swing and pre-emphasis
  1148. * levels, per-lane.
  1149. */
  1150. if (dp->set_voltages) {
  1151. /* Lane count verified previously. */
  1152. for (i = 0; i < dp->lanes; i++) {
  1153. if (dp->voltage[i] > 3 || dp->pre[i] > 3)
  1154. return -EINVAL;
  1155. /* Sum of voltage swing and pre-emphasis levels cannot
  1156. * exceed 3.
  1157. */
  1158. if (dp->voltage[i] + dp->pre[i] > 3)
  1159. return -EINVAL;
  1160. }
  1161. }
  1162. return 0;
  1163. }
  1164. /* Set power state A0 and PLL clock enable to 0 on enabled lanes. */
  1165. static void cdns_torrent_dp_set_a0_pll(struct cdns_torrent_phy *cdns_phy,
  1166. u32 num_lanes)
  1167. {
  1168. struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
  1169. u32 pwr_state = cdns_torrent_dp_read(regmap,
  1170. PHY_PMA_XCVR_POWER_STATE_REQ);
  1171. u32 pll_clk_en = cdns_torrent_dp_read(regmap,
  1172. PHY_PMA_XCVR_PLLCLK_EN);
  1173. /* Lane 0 is always enabled. */
  1174. pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK <<
  1175. PHY_POWER_STATE_LN_0);
  1176. pll_clk_en &= ~0x01U;
  1177. if (num_lanes > 1) {
  1178. /* lane 1 */
  1179. pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK <<
  1180. PHY_POWER_STATE_LN_1);
  1181. pll_clk_en &= ~(0x01U << 1);
  1182. }
  1183. if (num_lanes > 2) {
  1184. /* lanes 2 and 3 */
  1185. pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK <<
  1186. PHY_POWER_STATE_LN_2);
  1187. pwr_state &= ~(PMA_XCVR_POWER_STATE_REQ_LN_MASK <<
  1188. PHY_POWER_STATE_LN_3);
  1189. pll_clk_en &= ~(0x01U << 2);
  1190. pll_clk_en &= ~(0x01U << 3);
  1191. }
  1192. cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_POWER_STATE_REQ, pwr_state);
  1193. cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, pll_clk_en);
  1194. }
  1195. /* Configure lane count as required. */
  1196. static int cdns_torrent_dp_set_lanes(struct cdns_torrent_phy *cdns_phy,
  1197. struct phy_configure_opts_dp *dp)
  1198. {
  1199. u32 value;
  1200. u32 ret;
  1201. struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
  1202. u8 lane_mask = (1 << dp->lanes) - 1;
  1203. value = cdns_torrent_dp_read(regmap, PHY_RESET);
  1204. /* clear pma_tx_elec_idle_ln_* bits. */
  1205. value &= ~PMA_TX_ELEC_IDLE_MASK;
  1206. /* Assert pma_tx_elec_idle_ln_* for disabled lanes. */
  1207. value |= ((~lane_mask) << PMA_TX_ELEC_IDLE_SHIFT) &
  1208. PMA_TX_ELEC_IDLE_MASK;
  1209. cdns_torrent_dp_write(regmap, PHY_RESET, value);
  1210. /* reset the link by asserting phy_l00_reset_n low */
  1211. cdns_torrent_dp_write(regmap, PHY_RESET,
  1212. value & (~PHY_L00_RESET_N_MASK));
  1213. /*
  1214. * Assert lane reset on unused lanes and lane 0 so they remain in reset
  1215. * and powered down when re-enabling the link
  1216. */
  1217. value = (value & 0x0000FFF0) | (0x0000000E & lane_mask);
  1218. cdns_torrent_dp_write(regmap, PHY_RESET, value);
  1219. cdns_torrent_dp_set_a0_pll(cdns_phy, dp->lanes);
  1220. /* release phy_l0*_reset_n based on used laneCount */
  1221. value = (value & 0x0000FFF0) | (0x0000000F & lane_mask);
  1222. cdns_torrent_dp_write(regmap, PHY_RESET, value);
  1223. /* Wait, until PHY gets ready after releasing PHY reset signal. */
  1224. ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
  1225. if (ret)
  1226. return ret;
  1227. ndelay(100);
  1228. /* release pma_xcvr_pllclk_en_ln_*, only for the master lane */
  1229. cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, 0x0001);
  1230. ret = cdns_torrent_dp_run(cdns_phy, dp->lanes);
  1231. return ret;
  1232. }
  1233. /* Configure link rate as required. */
  1234. static int cdns_torrent_dp_set_rate(struct cdns_torrent_phy *cdns_phy,
  1235. struct phy_configure_opts_dp *dp)
  1236. {
  1237. u32 ret;
  1238. ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes,
  1239. POWERSTATE_A3);
  1240. if (ret)
  1241. return ret;
  1242. ret = cdns_torrent_dp_set_pll_en(cdns_phy, dp, false);
  1243. if (ret)
  1244. return ret;
  1245. ndelay(200);
  1246. ret = cdns_torrent_dp_configure_rate(cdns_phy, dp);
  1247. if (ret)
  1248. return ret;
  1249. ndelay(200);
  1250. ret = cdns_torrent_dp_set_pll_en(cdns_phy, dp, true);
  1251. if (ret)
  1252. return ret;
  1253. ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes,
  1254. POWERSTATE_A2);
  1255. if (ret)
  1256. return ret;
  1257. ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes,
  1258. POWERSTATE_A0);
  1259. if (ret)
  1260. return ret;
  1261. ndelay(900);
  1262. return ret;
  1263. }
  1264. /* Configure voltage swing and pre-emphasis for all enabled lanes. */
  1265. static void cdns_torrent_dp_set_voltages(struct cdns_torrent_phy *cdns_phy,
  1266. struct phy_configure_opts_dp *dp)
  1267. {
  1268. u8 lane;
  1269. u16 val;
  1270. for (lane = 0; lane < dp->lanes; lane++) {
  1271. val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane],
  1272. TX_DIAG_ACYA);
  1273. /*
  1274. * Write 1 to register bit TX_DIAG_ACYA[0] to freeze the
  1275. * current state of the analog TX driver.
  1276. */
  1277. val |= TX_DIAG_ACYA_HBDC_MASK;
  1278. cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
  1279. TX_DIAG_ACYA, val);
  1280. cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
  1281. TX_TXCC_CTRL, 0x08A4);
  1282. val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].diag_tx_drv;
  1283. cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
  1284. DRV_DIAG_TX_DRV, val);
  1285. val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].mgnfs_mult;
  1286. cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
  1287. TX_TXCC_MGNFS_MULT_000,
  1288. val);
  1289. val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].cpost_mult;
  1290. cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
  1291. TX_TXCC_CPOST_MULT_00,
  1292. val);
  1293. val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane],
  1294. TX_DIAG_ACYA);
  1295. /*
  1296. * Write 0 to register bit TX_DIAG_ACYA[0] to allow the state of
  1297. * analog TX driver to reflect the new programmed one.
  1298. */
  1299. val &= ~TX_DIAG_ACYA_HBDC_MASK;
  1300. cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane],
  1301. TX_DIAG_ACYA, val);
  1302. }
  1303. };
  1304. static int cdns_torrent_dp_configure(struct phy *phy,
  1305. union phy_configure_opts *opts)
  1306. {
  1307. struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
  1308. struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
  1309. int ret;
  1310. ret = cdns_torrent_dp_verify_config(inst, &opts->dp);
  1311. if (ret) {
  1312. dev_err(&phy->dev, "invalid params for phy configure\n");
  1313. return ret;
  1314. }
  1315. if (opts->dp.set_lanes) {
  1316. ret = cdns_torrent_dp_set_lanes(cdns_phy, &opts->dp);
  1317. if (ret) {
  1318. dev_err(&phy->dev, "cdns_torrent_dp_set_lanes failed\n");
  1319. return ret;
  1320. }
  1321. }
  1322. if (opts->dp.set_rate) {
  1323. ret = cdns_torrent_dp_set_rate(cdns_phy, &opts->dp);
  1324. if (ret) {
  1325. dev_err(&phy->dev, "cdns_torrent_dp_set_rate failed\n");
  1326. return ret;
  1327. }
  1328. }
  1329. if (opts->dp.set_voltages)
  1330. cdns_torrent_dp_set_voltages(cdns_phy, &opts->dp);
  1331. return ret;
  1332. }
  1333. static int cdns_torrent_phy_on(struct phy *phy)
  1334. {
  1335. struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
  1336. struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
  1337. u32 read_val;
  1338. int ret;
  1339. if (cdns_phy->nsubnodes == 1) {
  1340. /* Take the PHY lane group out of reset */
  1341. reset_control_deassert(inst->lnk_rst);
  1342. /* Take the PHY out of reset */
  1343. ret = reset_control_deassert(cdns_phy->phy_rst);
  1344. if (ret)
  1345. return ret;
  1346. }
  1347. /*
  1348. * Wait for cmn_ready assertion
  1349. * PHY_PMA_CMN_CTRL1[0] == 1
  1350. */
  1351. ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1,
  1352. read_val, read_val, 1000,
  1353. PLL_LOCK_TIMEOUT);
  1354. if (ret) {
  1355. dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n");
  1356. return ret;
  1357. }
  1358. if (inst->phy_type == TYPE_PCIE || inst->phy_type == TYPE_USB) {
  1359. ret = regmap_field_read_poll_timeout(cdns_phy->phy_pcs_iso_link_ctrl_1[inst->mlane],
  1360. read_val, !read_val, 1000,
  1361. PLL_LOCK_TIMEOUT);
  1362. if (ret == -ETIMEDOUT) {
  1363. dev_err(cdns_phy->dev, "Timeout waiting for PHY status ready\n");
  1364. return ret;
  1365. }
  1366. }
  1367. return 0;
  1368. }
  1369. static int cdns_torrent_phy_off(struct phy *phy)
  1370. {
  1371. struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
  1372. struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
  1373. int ret;
  1374. if (cdns_phy->nsubnodes != 1)
  1375. return 0;
  1376. ret = reset_control_assert(cdns_phy->phy_rst);
  1377. if (ret)
  1378. return ret;
  1379. return reset_control_assert(inst->lnk_rst);
  1380. }
  1381. static void cdns_torrent_dp_common_init(struct cdns_torrent_phy *cdns_phy,
  1382. struct cdns_torrent_inst *inst)
  1383. {
  1384. struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg;
  1385. unsigned char lane_bits;
  1386. cdns_torrent_dp_write(regmap, PHY_AUX_CTRL, 0x0003); /* enable AUX */
  1387. /*
  1388. * Set lines power state to A0
  1389. * Set lines pll clk enable to 0
  1390. */
  1391. cdns_torrent_dp_set_a0_pll(cdns_phy, inst->num_lanes);
  1392. /*
  1393. * release phy_l0*_reset_n and pma_tx_elec_idle_ln_* based on
  1394. * used lanes
  1395. */
  1396. lane_bits = (1 << inst->num_lanes) - 1;
  1397. cdns_torrent_dp_write(regmap, PHY_RESET,
  1398. ((0xF & ~lane_bits) << 4) | (0xF & lane_bits));
  1399. /* release pma_xcvr_pllclk_en_ln_*, only for the master lane */
  1400. cdns_torrent_dp_write(regmap, PHY_PMA_XCVR_PLLCLK_EN, 0x0001);
  1401. /*
  1402. * PHY PMA registers configuration functions
  1403. * Initialize PHY with max supported link rate, without SSC.
  1404. */
  1405. if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ)
  1406. cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy,
  1407. cdns_phy->max_bit_rate,
  1408. false);
  1409. else if (cdns_phy->ref_clk_rate == CLK_25_MHZ)
  1410. cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy,
  1411. cdns_phy->max_bit_rate,
  1412. false);
  1413. else if (cdns_phy->ref_clk_rate == CLK_100_MHZ)
  1414. cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy,
  1415. cdns_phy->max_bit_rate,
  1416. false);
  1417. cdns_torrent_dp_pma_cmn_rate(cdns_phy, cdns_phy->max_bit_rate,
  1418. inst->num_lanes);
  1419. /* take out of reset */
  1420. regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1);
  1421. }
  1422. static int cdns_torrent_dp_start(struct cdns_torrent_phy *cdns_phy,
  1423. struct cdns_torrent_inst *inst,
  1424. struct phy *phy)
  1425. {
  1426. int ret;
  1427. cdns_torrent_phy_on(phy);
  1428. ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
  1429. if (ret)
  1430. return ret;
  1431. ret = cdns_torrent_dp_run(cdns_phy, inst->num_lanes);
  1432. return ret;
  1433. }
  1434. static int cdns_torrent_dp_init(struct phy *phy)
  1435. {
  1436. struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
  1437. struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
  1438. switch (cdns_phy->ref_clk_rate) {
  1439. case CLK_19_2_MHZ:
  1440. case CLK_25_MHZ:
  1441. case CLK_100_MHZ:
  1442. /* Valid Ref Clock Rate */
  1443. break;
  1444. default:
  1445. dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n");
  1446. return -EINVAL;
  1447. }
  1448. cdns_torrent_dp_common_init(cdns_phy, inst);
  1449. return cdns_torrent_dp_start(cdns_phy, inst, phy);
  1450. }
  1451. static int cdns_torrent_derived_refclk_enable(struct clk_hw *hw)
  1452. {
  1453. struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
  1454. regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 1);
  1455. regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 1);
  1456. return 0;
  1457. }
  1458. static void cdns_torrent_derived_refclk_disable(struct clk_hw *hw)
  1459. {
  1460. struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
  1461. regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 0);
  1462. regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 0);
  1463. }
  1464. static int cdns_torrent_derived_refclk_is_enabled(struct clk_hw *hw)
  1465. {
  1466. struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
  1467. int val;
  1468. regmap_field_read(derived_refclk->cmn_cdiag_refclk_ovrd_4, &val);
  1469. return !!val;
  1470. }
  1471. static const struct clk_ops cdns_torrent_derived_refclk_ops = {
  1472. .enable = cdns_torrent_derived_refclk_enable,
  1473. .disable = cdns_torrent_derived_refclk_disable,
  1474. .is_enabled = cdns_torrent_derived_refclk_is_enabled,
  1475. };
  1476. static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_phy)
  1477. {
  1478. struct cdns_torrent_derived_refclk *derived_refclk;
  1479. struct device *dev = cdns_phy->dev;
  1480. struct clk_init_data *init;
  1481. const char *parent_name;
  1482. char clk_name[100];
  1483. struct clk_hw *hw;
  1484. struct clk *clk;
  1485. int ret;
  1486. derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
  1487. if (!derived_refclk)
  1488. return -ENOMEM;
  1489. snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
  1490. clk_names[CDNS_TORRENT_DERIVED_REFCLK]);
  1491. clk = devm_clk_get_optional(dev, "phy_en_refclk");
  1492. if (IS_ERR(clk)) {
  1493. dev_err(dev, "No parent clock for derived_refclk\n");
  1494. return PTR_ERR(clk);
  1495. }
  1496. init = &derived_refclk->clk_data;
  1497. if (clk) {
  1498. parent_name = __clk_get_name(clk);
  1499. init->parent_names = &parent_name;
  1500. init->num_parents = 1;
  1501. }
  1502. init->ops = &cdns_torrent_derived_refclk_ops;
  1503. init->flags = 0;
  1504. init->name = clk_name;
  1505. derived_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0;
  1506. derived_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4;
  1507. derived_refclk->hw.init = init;
  1508. hw = &derived_refclk->hw;
  1509. ret = devm_clk_hw_register(dev, hw);
  1510. if (ret)
  1511. return ret;
  1512. cdns_phy->clk_hw_data->hws[CDNS_TORRENT_DERIVED_REFCLK] = hw;
  1513. return 0;
  1514. }
  1515. static int cdns_torrent_received_refclk_enable(struct clk_hw *hw)
  1516. {
  1517. struct cdns_torrent_received_refclk *received_refclk = to_cdns_torrent_received_refclk(hw);
  1518. regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 1);
  1519. return 0;
  1520. }
  1521. static void cdns_torrent_received_refclk_disable(struct clk_hw *hw)
  1522. {
  1523. struct cdns_torrent_received_refclk *received_refclk = to_cdns_torrent_received_refclk(hw);
  1524. regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 0);
  1525. }
  1526. static int cdns_torrent_received_refclk_is_enabled(struct clk_hw *hw)
  1527. {
  1528. struct cdns_torrent_received_refclk *received_refclk = to_cdns_torrent_received_refclk(hw);
  1529. int val, cmn_val;
  1530. regmap_field_read(received_refclk->phy_pipe_cmn_ctrl1_0, &val);
  1531. regmap_field_read(received_refclk->cmn_cdiag_refclk_ovrd_4, &cmn_val);
  1532. return val && !cmn_val;
  1533. }
  1534. static const struct clk_ops cdns_torrent_received_refclk_ops = {
  1535. .enable = cdns_torrent_received_refclk_enable,
  1536. .disable = cdns_torrent_received_refclk_disable,
  1537. .is_enabled = cdns_torrent_received_refclk_is_enabled,
  1538. };
  1539. static int cdns_torrent_received_refclk_register(struct cdns_torrent_phy *cdns_phy)
  1540. {
  1541. struct cdns_torrent_received_refclk *received_refclk;
  1542. struct device *dev = cdns_phy->dev;
  1543. struct clk_init_data *init;
  1544. const char *parent_name;
  1545. char clk_name[100];
  1546. struct clk_hw *hw;
  1547. struct clk *clk;
  1548. int ret;
  1549. received_refclk = devm_kzalloc(dev, sizeof(*received_refclk), GFP_KERNEL);
  1550. if (!received_refclk)
  1551. return -ENOMEM;
  1552. snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
  1553. clk_names[CDNS_TORRENT_RECEIVED_REFCLK]);
  1554. clk = devm_clk_get_optional(dev, "phy_en_refclk");
  1555. if (IS_ERR(clk)) {
  1556. dev_err(dev, "No parent clock for received_refclk\n");
  1557. return PTR_ERR(clk);
  1558. }
  1559. init = &received_refclk->clk_data;
  1560. if (clk) {
  1561. parent_name = __clk_get_name(clk);
  1562. init->parent_names = &parent_name;
  1563. init->num_parents = 1;
  1564. }
  1565. init->ops = &cdns_torrent_received_refclk_ops;
  1566. init->flags = 0;
  1567. init->name = clk_name;
  1568. received_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0;
  1569. received_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4;
  1570. received_refclk->hw.init = init;
  1571. hw = &received_refclk->hw;
  1572. ret = devm_clk_hw_register(dev, hw);
  1573. if (ret)
  1574. return ret;
  1575. cdns_phy->clk_hw_data->hws[CDNS_TORRENT_RECEIVED_REFCLK] = hw;
  1576. return 0;
  1577. }
  1578. static int cdns_torrent_refclk_driver_enable(struct clk_hw *hw)
  1579. {
  1580. struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
  1581. regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_6], 0);
  1582. regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_5], 1);
  1583. regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 0);
  1584. return 0;
  1585. }
  1586. static void cdns_torrent_refclk_driver_disable(struct clk_hw *hw)
  1587. {
  1588. struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
  1589. regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 1);
  1590. }
  1591. static int cdns_torrent_refclk_driver_is_enabled(struct clk_hw *hw)
  1592. {
  1593. struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
  1594. int val;
  1595. regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], &val);
  1596. return !val;
  1597. }
  1598. static u8 cdns_torrent_refclk_driver_get_parent(struct clk_hw *hw)
  1599. {
  1600. struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
  1601. unsigned int val;
  1602. regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], &val);
  1603. return clk_mux_val_to_index(hw, cdns_torrent_refclk_driver_mux_table, 0, val);
  1604. }
  1605. static int cdns_torrent_refclk_driver_set_parent(struct clk_hw *hw, u8 index)
  1606. {
  1607. struct cdns_torrent_refclk_driver *refclk_driver = to_cdns_torrent_refclk_driver(hw);
  1608. unsigned int val;
  1609. val = cdns_torrent_refclk_driver_mux_table[index];
  1610. return regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], val);
  1611. }
  1612. static const struct clk_ops cdns_torrent_refclk_driver_ops = {
  1613. .enable = cdns_torrent_refclk_driver_enable,
  1614. .disable = cdns_torrent_refclk_driver_disable,
  1615. .is_enabled = cdns_torrent_refclk_driver_is_enabled,
  1616. .set_parent = cdns_torrent_refclk_driver_set_parent,
  1617. .get_parent = cdns_torrent_refclk_driver_get_parent,
  1618. };
  1619. static int cdns_torrent_refclk_driver_register(struct cdns_torrent_phy *cdns_phy)
  1620. {
  1621. struct cdns_torrent_refclk_driver *refclk_driver;
  1622. struct device *dev = cdns_phy->dev;
  1623. struct regmap_field *field;
  1624. struct clk_init_data *init;
  1625. const char **parent_names;
  1626. unsigned int num_parents;
  1627. struct regmap *regmap;
  1628. char clk_name[100];
  1629. struct clk_hw *hw;
  1630. int i, ret;
  1631. refclk_driver = devm_kzalloc(dev, sizeof(*refclk_driver), GFP_KERNEL);
  1632. if (!refclk_driver)
  1633. return -ENOMEM;
  1634. num_parents = ARRAY_SIZE(refclk_driver_parent_index);
  1635. parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL);
  1636. if (!parent_names)
  1637. return -ENOMEM;
  1638. for (i = 0; i < num_parents; i++) {
  1639. hw = cdns_phy->clk_hw_data->hws[refclk_driver_parent_index[i]];
  1640. if (IS_ERR_OR_NULL(hw)) {
  1641. dev_err(dev, "No parent clock for refclk driver clock\n");
  1642. return IS_ERR(hw) ? PTR_ERR(hw) : -ENOENT;
  1643. }
  1644. parent_names[i] = clk_hw_get_name(hw);
  1645. }
  1646. snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
  1647. clk_names[CDNS_TORRENT_REFCLK_DRIVER]);
  1648. init = &refclk_driver->clk_data;
  1649. init->ops = &cdns_torrent_refclk_driver_ops;
  1650. init->flags = CLK_SET_RATE_NO_REPARENT;
  1651. init->parent_names = parent_names;
  1652. init->num_parents = num_parents;
  1653. init->name = clk_name;
  1654. regmap = cdns_phy->regmap_common_cdb;
  1655. for (i = 0; i < REFCLK_OUT_NUM_CMN_CONFIG; i++) {
  1656. field = devm_regmap_field_alloc(dev, regmap, refclk_out_cmn_cfg[i]);
  1657. if (IS_ERR(field)) {
  1658. dev_err(dev, "Refclk driver CMN reg field init failed\n");
  1659. return PTR_ERR(field);
  1660. }
  1661. refclk_driver->cmn_fields[i] = field;
  1662. }
  1663. /* Enable Derived reference clock as default */
  1664. regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], 1);
  1665. refclk_driver->hw.init = init;
  1666. hw = &refclk_driver->hw;
  1667. ret = devm_clk_hw_register(dev, hw);
  1668. if (ret)
  1669. return ret;
  1670. cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw;
  1671. return 0;
  1672. }
  1673. static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
  1674. u32 block_offset,
  1675. u8 reg_offset_shift,
  1676. const struct regmap_config *config)
  1677. {
  1678. struct cdns_regmap_cdb_context *ctx;
  1679. ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
  1680. if (!ctx)
  1681. return ERR_PTR(-ENOMEM);
  1682. ctx->dev = dev;
  1683. ctx->base = base + block_offset;
  1684. ctx->reg_offset_shift = reg_offset_shift;
  1685. return devm_regmap_init(dev, NULL, ctx, config);
  1686. }
  1687. static int cdns_torrent_dp_regfield_init(struct cdns_torrent_phy *cdns_phy)
  1688. {
  1689. struct device *dev = cdns_phy->dev;
  1690. struct regmap_field *field;
  1691. struct regmap *regmap;
  1692. regmap = cdns_phy->regmap_dptx_phy_reg;
  1693. field = devm_regmap_field_alloc(dev, regmap, phy_reset_ctrl);
  1694. if (IS_ERR(field)) {
  1695. dev_err(dev, "PHY_RESET reg field init failed\n");
  1696. return PTR_ERR(field);
  1697. }
  1698. cdns_phy->phy_reset_ctrl = field;
  1699. return 0;
  1700. }
  1701. static int cdns_torrent_regfield_init(struct cdns_torrent_phy *cdns_phy)
  1702. {
  1703. struct device *dev = cdns_phy->dev;
  1704. struct regmap_field *field;
  1705. struct regmap *regmap;
  1706. int i;
  1707. regmap = cdns_phy->regmap_phy_pcs_common_cdb;
  1708. field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg);
  1709. if (IS_ERR(field)) {
  1710. dev_err(dev, "PHY_PLL_CFG reg field init failed\n");
  1711. return PTR_ERR(field);
  1712. }
  1713. cdns_phy->phy_pll_cfg = field;
  1714. regmap = cdns_phy->regmap_phy_pcs_common_cdb;
  1715. field = devm_regmap_field_alloc(dev, regmap, phy_pipe_cmn_ctrl1_0);
  1716. if (IS_ERR(field)) {
  1717. dev_err(dev, "phy_pipe_cmn_ctrl1_0 reg field init failed\n");
  1718. return PTR_ERR(field);
  1719. }
  1720. cdns_phy->phy_pipe_cmn_ctrl1_0 = field;
  1721. regmap = cdns_phy->regmap_common_cdb;
  1722. field = devm_regmap_field_alloc(dev, regmap, cmn_cdiag_refclk_ovrd_4);
  1723. if (IS_ERR(field)) {
  1724. dev_err(dev, "cmn_cdiag_refclk_ovrd_4 reg field init failed\n");
  1725. return PTR_ERR(field);
  1726. }
  1727. cdns_phy->cmn_cdiag_refclk_ovrd_4 = field;
  1728. regmap = cdns_phy->regmap_phy_pma_common_cdb;
  1729. field = devm_regmap_field_alloc(dev, regmap, phy_pma_cmn_ctrl_1);
  1730. if (IS_ERR(field)) {
  1731. dev_err(dev, "PHY_PMA_CMN_CTRL1 reg field init failed\n");
  1732. return PTR_ERR(field);
  1733. }
  1734. cdns_phy->phy_pma_cmn_ctrl_1 = field;
  1735. regmap = cdns_phy->regmap_phy_pma_common_cdb;
  1736. field = devm_regmap_field_alloc(dev, regmap, phy_pma_cmn_ctrl_2);
  1737. if (IS_ERR(field)) {
  1738. dev_err(dev, "PHY_PMA_CMN_CTRL2 reg field init failed\n");
  1739. return PTR_ERR(field);
  1740. }
  1741. cdns_phy->phy_pma_cmn_ctrl_2 = field;
  1742. regmap = cdns_phy->regmap_phy_pma_common_cdb;
  1743. field = devm_regmap_field_alloc(dev, regmap, phy_pma_pll_raw_ctrl);
  1744. if (IS_ERR(field)) {
  1745. dev_err(dev, "PHY_PMA_PLL_RAW_CTRL reg field init failed\n");
  1746. return PTR_ERR(field);
  1747. }
  1748. cdns_phy->phy_pma_pll_raw_ctrl = field;
  1749. for (i = 0; i < MAX_NUM_LANES; i++) {
  1750. regmap = cdns_phy->regmap_phy_pcs_lane_cdb[i];
  1751. field = devm_regmap_field_alloc(dev, regmap, phy_pcs_iso_link_ctrl_1);
  1752. if (IS_ERR(field)) {
  1753. dev_err(dev, "PHY_PCS_ISO_LINK_CTRL reg field init for ln %d failed\n", i);
  1754. return PTR_ERR(field);
  1755. }
  1756. cdns_phy->phy_pcs_iso_link_ctrl_1[i] = field;
  1757. }
  1758. return 0;
  1759. }
  1760. static int cdns_torrent_dp_regmap_init(struct cdns_torrent_phy *cdns_phy)
  1761. {
  1762. void __iomem *base = cdns_phy->base;
  1763. struct device *dev = cdns_phy->dev;
  1764. struct regmap *regmap;
  1765. u8 reg_offset_shift;
  1766. u32 block_offset;
  1767. reg_offset_shift = cdns_phy->init_data->reg_offset_shift;
  1768. block_offset = TORRENT_DPTX_PHY_OFFSET;
  1769. regmap = cdns_regmap_init(dev, base, block_offset,
  1770. reg_offset_shift,
  1771. &cdns_torrent_dptx_phy_config);
  1772. if (IS_ERR(regmap)) {
  1773. dev_err(dev, "Failed to init DPTX PHY regmap\n");
  1774. return PTR_ERR(regmap);
  1775. }
  1776. cdns_phy->regmap_dptx_phy_reg = regmap;
  1777. return 0;
  1778. }
  1779. static int cdns_torrent_regmap_init(struct cdns_torrent_phy *cdns_phy)
  1780. {
  1781. void __iomem *sd_base = cdns_phy->sd_base;
  1782. u8 block_offset_shift, reg_offset_shift;
  1783. struct device *dev = cdns_phy->dev;
  1784. struct regmap *regmap;
  1785. u32 block_offset;
  1786. int i;
  1787. block_offset_shift = cdns_phy->init_data->block_offset_shift;
  1788. reg_offset_shift = cdns_phy->init_data->reg_offset_shift;
  1789. for (i = 0; i < MAX_NUM_LANES; i++) {
  1790. block_offset = TORRENT_TX_LANE_CDB_OFFSET(i, block_offset_shift,
  1791. reg_offset_shift);
  1792. regmap = cdns_regmap_init(dev, sd_base, block_offset,
  1793. reg_offset_shift,
  1794. &cdns_torrent_tx_lane_cdb_config[i]);
  1795. if (IS_ERR(regmap)) {
  1796. dev_err(dev, "Failed to init tx lane CDB regmap\n");
  1797. return PTR_ERR(regmap);
  1798. }
  1799. cdns_phy->regmap_tx_lane_cdb[i] = regmap;
  1800. block_offset = TORRENT_RX_LANE_CDB_OFFSET(i, block_offset_shift,
  1801. reg_offset_shift);
  1802. regmap = cdns_regmap_init(dev, sd_base, block_offset,
  1803. reg_offset_shift,
  1804. &cdns_torrent_rx_lane_cdb_config[i]);
  1805. if (IS_ERR(regmap)) {
  1806. dev_err(dev, "Failed to init rx lane CDB regmap\n");
  1807. return PTR_ERR(regmap);
  1808. }
  1809. cdns_phy->regmap_rx_lane_cdb[i] = regmap;
  1810. block_offset = TORRENT_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
  1811. reg_offset_shift);
  1812. regmap = cdns_regmap_init(dev, sd_base, block_offset,
  1813. reg_offset_shift,
  1814. &cdns_torrent_phy_pcs_lane_cdb_config[i]);
  1815. if (IS_ERR(regmap)) {
  1816. dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
  1817. return PTR_ERR(regmap);
  1818. }
  1819. cdns_phy->regmap_phy_pcs_lane_cdb[i] = regmap;
  1820. }
  1821. block_offset = TORRENT_COMMON_CDB_OFFSET;
  1822. regmap = cdns_regmap_init(dev, sd_base, block_offset,
  1823. reg_offset_shift,
  1824. &cdns_torrent_common_cdb_config);
  1825. if (IS_ERR(regmap)) {
  1826. dev_err(dev, "Failed to init common CDB regmap\n");
  1827. return PTR_ERR(regmap);
  1828. }
  1829. cdns_phy->regmap_common_cdb = regmap;
  1830. block_offset = TORRENT_PHY_PCS_COMMON_OFFSET(block_offset_shift);
  1831. regmap = cdns_regmap_init(dev, sd_base, block_offset,
  1832. reg_offset_shift,
  1833. &cdns_torrent_phy_pcs_cmn_cdb_config);
  1834. if (IS_ERR(regmap)) {
  1835. dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
  1836. return PTR_ERR(regmap);
  1837. }
  1838. cdns_phy->regmap_phy_pcs_common_cdb = regmap;
  1839. block_offset = TORRENT_PHY_PMA_COMMON_OFFSET(block_offset_shift);
  1840. regmap = cdns_regmap_init(dev, sd_base, block_offset,
  1841. reg_offset_shift,
  1842. &cdns_torrent_phy_pma_cmn_cdb_config);
  1843. if (IS_ERR(regmap)) {
  1844. dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
  1845. return PTR_ERR(regmap);
  1846. }
  1847. cdns_phy->regmap_phy_pma_common_cdb = regmap;
  1848. return 0;
  1849. }
  1850. static int cdns_torrent_phy_init(struct phy *phy)
  1851. {
  1852. struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
  1853. const struct cdns_torrent_data *init_data = cdns_phy->init_data;
  1854. struct cdns_torrent_vals *cmn_vals, *tx_ln_vals, *rx_ln_vals;
  1855. enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate;
  1856. struct cdns_torrent_vals *link_cmn_vals, *xcvr_diag_vals;
  1857. struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
  1858. enum cdns_torrent_phy_type phy_type = inst->phy_type;
  1859. enum cdns_torrent_ssc_mode ssc = inst->ssc_mode;
  1860. struct cdns_torrent_vals *pcs_cmn_vals;
  1861. struct cdns_reg_pairs *reg_pairs;
  1862. struct regmap *regmap;
  1863. u32 num_regs;
  1864. int i, j;
  1865. if (cdns_phy->nsubnodes > 1)
  1866. return 0;
  1867. /**
  1868. * Spread spectrum generation is not required or supported
  1869. * for SGMII/QSGMII
  1870. */
  1871. if (phy_type == TYPE_SGMII || phy_type == TYPE_QSGMII)
  1872. ssc = NO_SSC;
  1873. /* PHY configuration specific registers for single link */
  1874. link_cmn_vals = init_data->link_cmn_vals[phy_type][TYPE_NONE][ssc];
  1875. if (link_cmn_vals) {
  1876. reg_pairs = link_cmn_vals->reg_pairs;
  1877. num_regs = link_cmn_vals->num_regs;
  1878. regmap = cdns_phy->regmap_common_cdb;
  1879. /**
  1880. * First array value in link_cmn_vals must be of
  1881. * PHY_PLL_CFG register
  1882. */
  1883. regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val);
  1884. for (i = 1; i < num_regs; i++)
  1885. regmap_write(regmap, reg_pairs[i].off,
  1886. reg_pairs[i].val);
  1887. }
  1888. xcvr_diag_vals = init_data->xcvr_diag_vals[phy_type][TYPE_NONE][ssc];
  1889. if (xcvr_diag_vals) {
  1890. reg_pairs = xcvr_diag_vals->reg_pairs;
  1891. num_regs = xcvr_diag_vals->num_regs;
  1892. for (i = 0; i < inst->num_lanes; i++) {
  1893. regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane];
  1894. for (j = 0; j < num_regs; j++)
  1895. regmap_write(regmap, reg_pairs[j].off,
  1896. reg_pairs[j].val);
  1897. }
  1898. }
  1899. /* PHY PCS common registers configurations */
  1900. pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc];
  1901. if (pcs_cmn_vals) {
  1902. reg_pairs = pcs_cmn_vals->reg_pairs;
  1903. num_regs = pcs_cmn_vals->num_regs;
  1904. regmap = cdns_phy->regmap_phy_pcs_common_cdb;
  1905. for (i = 0; i < num_regs; i++)
  1906. regmap_write(regmap, reg_pairs[i].off,
  1907. reg_pairs[i].val);
  1908. }
  1909. /* PMA common registers configurations */
  1910. cmn_vals = init_data->cmn_vals[ref_clk][phy_type][TYPE_NONE][ssc];
  1911. if (cmn_vals) {
  1912. reg_pairs = cmn_vals->reg_pairs;
  1913. num_regs = cmn_vals->num_regs;
  1914. regmap = cdns_phy->regmap_common_cdb;
  1915. for (i = 0; i < num_regs; i++)
  1916. regmap_write(regmap, reg_pairs[i].off,
  1917. reg_pairs[i].val);
  1918. }
  1919. /* PMA TX lane registers configurations */
  1920. tx_ln_vals = init_data->tx_ln_vals[ref_clk][phy_type][TYPE_NONE][ssc];
  1921. if (tx_ln_vals) {
  1922. reg_pairs = tx_ln_vals->reg_pairs;
  1923. num_regs = tx_ln_vals->num_regs;
  1924. for (i = 0; i < inst->num_lanes; i++) {
  1925. regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane];
  1926. for (j = 0; j < num_regs; j++)
  1927. regmap_write(regmap, reg_pairs[j].off,
  1928. reg_pairs[j].val);
  1929. }
  1930. }
  1931. /* PMA RX lane registers configurations */
  1932. rx_ln_vals = init_data->rx_ln_vals[ref_clk][phy_type][TYPE_NONE][ssc];
  1933. if (rx_ln_vals) {
  1934. reg_pairs = rx_ln_vals->reg_pairs;
  1935. num_regs = rx_ln_vals->num_regs;
  1936. for (i = 0; i < inst->num_lanes; i++) {
  1937. regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane];
  1938. for (j = 0; j < num_regs; j++)
  1939. regmap_write(regmap, reg_pairs[j].off,
  1940. reg_pairs[j].val);
  1941. }
  1942. }
  1943. if (phy_type == TYPE_DP)
  1944. return cdns_torrent_dp_init(phy);
  1945. return 0;
  1946. }
  1947. static const struct phy_ops cdns_torrent_phy_ops = {
  1948. .init = cdns_torrent_phy_init,
  1949. .configure = cdns_torrent_dp_configure,
  1950. .power_on = cdns_torrent_phy_on,
  1951. .power_off = cdns_torrent_phy_off,
  1952. .owner = THIS_MODULE,
  1953. };
  1954. static int cdns_torrent_noop_phy_on(struct phy *phy)
  1955. {
  1956. /* Give 5ms to 10ms delay for the PIPE clock to be stable */
  1957. usleep_range(5000, 10000);
  1958. return 0;
  1959. }
  1960. static const struct phy_ops noop_ops = {
  1961. .power_on = cdns_torrent_noop_phy_on,
  1962. .owner = THIS_MODULE,
  1963. };
  1964. static
  1965. int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy)
  1966. {
  1967. const struct cdns_torrent_data *init_data = cdns_phy->init_data;
  1968. struct cdns_torrent_vals *cmn_vals, *tx_ln_vals, *rx_ln_vals;
  1969. enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate;
  1970. struct cdns_torrent_vals *link_cmn_vals, *xcvr_diag_vals;
  1971. enum cdns_torrent_phy_type phy_t1, phy_t2;
  1972. struct cdns_torrent_vals *pcs_cmn_vals;
  1973. int i, j, node, mlane, num_lanes, ret;
  1974. struct cdns_reg_pairs *reg_pairs;
  1975. enum cdns_torrent_ssc_mode ssc;
  1976. struct regmap *regmap;
  1977. u32 num_regs;
  1978. /* Maximum 2 links (subnodes) are supported */
  1979. if (cdns_phy->nsubnodes != 2)
  1980. return -EINVAL;
  1981. phy_t1 = cdns_phy->phys[0].phy_type;
  1982. phy_t2 = cdns_phy->phys[1].phy_type;
  1983. /**
  1984. * First configure the PHY for first link with phy_t1. Get the array
  1985. * values as [phy_t1][phy_t2][ssc].
  1986. */
  1987. for (node = 0; node < cdns_phy->nsubnodes; node++) {
  1988. if (node == 1) {
  1989. /**
  1990. * If first link with phy_t1 is configured, then
  1991. * configure the PHY for second link with phy_t2.
  1992. * Get the array values as [phy_t2][phy_t1][ssc].
  1993. */
  1994. swap(phy_t1, phy_t2);
  1995. }
  1996. mlane = cdns_phy->phys[node].mlane;
  1997. ssc = cdns_phy->phys[node].ssc_mode;
  1998. num_lanes = cdns_phy->phys[node].num_lanes;
  1999. /**
  2000. * PHY configuration specific registers:
  2001. * link_cmn_vals depend on combination of PHY types being
  2002. * configured and are common for both PHY types, so array
  2003. * values should be same for [phy_t1][phy_t2][ssc] and
  2004. * [phy_t2][phy_t1][ssc].
  2005. * xcvr_diag_vals also depend on combination of PHY types
  2006. * being configured, but these can be different for particular
  2007. * PHY type and are per lane.
  2008. */
  2009. link_cmn_vals = init_data->link_cmn_vals[phy_t1][phy_t2][ssc];
  2010. if (link_cmn_vals) {
  2011. reg_pairs = link_cmn_vals->reg_pairs;
  2012. num_regs = link_cmn_vals->num_regs;
  2013. regmap = cdns_phy->regmap_common_cdb;
  2014. /**
  2015. * First array value in link_cmn_vals must be of
  2016. * PHY_PLL_CFG register
  2017. */
  2018. regmap_field_write(cdns_phy->phy_pll_cfg,
  2019. reg_pairs[0].val);
  2020. for (i = 1; i < num_regs; i++)
  2021. regmap_write(regmap, reg_pairs[i].off,
  2022. reg_pairs[i].val);
  2023. }
  2024. xcvr_diag_vals = init_data->xcvr_diag_vals[phy_t1][phy_t2][ssc];
  2025. if (xcvr_diag_vals) {
  2026. reg_pairs = xcvr_diag_vals->reg_pairs;
  2027. num_regs = xcvr_diag_vals->num_regs;
  2028. for (i = 0; i < num_lanes; i++) {
  2029. regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane];
  2030. for (j = 0; j < num_regs; j++)
  2031. regmap_write(regmap, reg_pairs[j].off,
  2032. reg_pairs[j].val);
  2033. }
  2034. }
  2035. /* PHY PCS common registers configurations */
  2036. pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc];
  2037. if (pcs_cmn_vals) {
  2038. reg_pairs = pcs_cmn_vals->reg_pairs;
  2039. num_regs = pcs_cmn_vals->num_regs;
  2040. regmap = cdns_phy->regmap_phy_pcs_common_cdb;
  2041. for (i = 0; i < num_regs; i++)
  2042. regmap_write(regmap, reg_pairs[i].off,
  2043. reg_pairs[i].val);
  2044. }
  2045. /* PMA common registers configurations */
  2046. cmn_vals = init_data->cmn_vals[ref_clk][phy_t1][phy_t2][ssc];
  2047. if (cmn_vals) {
  2048. reg_pairs = cmn_vals->reg_pairs;
  2049. num_regs = cmn_vals->num_regs;
  2050. regmap = cdns_phy->regmap_common_cdb;
  2051. for (i = 0; i < num_regs; i++)
  2052. regmap_write(regmap, reg_pairs[i].off,
  2053. reg_pairs[i].val);
  2054. }
  2055. /* PMA TX lane registers configurations */
  2056. tx_ln_vals = init_data->tx_ln_vals[ref_clk][phy_t1][phy_t2][ssc];
  2057. if (tx_ln_vals) {
  2058. reg_pairs = tx_ln_vals->reg_pairs;
  2059. num_regs = tx_ln_vals->num_regs;
  2060. for (i = 0; i < num_lanes; i++) {
  2061. regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane];
  2062. for (j = 0; j < num_regs; j++)
  2063. regmap_write(regmap, reg_pairs[j].off,
  2064. reg_pairs[j].val);
  2065. }
  2066. }
  2067. /* PMA RX lane registers configurations */
  2068. rx_ln_vals = init_data->rx_ln_vals[ref_clk][phy_t1][phy_t2][ssc];
  2069. if (rx_ln_vals) {
  2070. reg_pairs = rx_ln_vals->reg_pairs;
  2071. num_regs = rx_ln_vals->num_regs;
  2072. for (i = 0; i < num_lanes; i++) {
  2073. regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane];
  2074. for (j = 0; j < num_regs; j++)
  2075. regmap_write(regmap, reg_pairs[j].off,
  2076. reg_pairs[j].val);
  2077. }
  2078. }
  2079. reset_control_deassert(cdns_phy->phys[node].lnk_rst);
  2080. }
  2081. /* Take the PHY out of reset */
  2082. ret = reset_control_deassert(cdns_phy->phy_rst);
  2083. if (ret)
  2084. return ret;
  2085. return 0;
  2086. }
  2087. static void cdns_torrent_clk_cleanup(struct cdns_torrent_phy *cdns_phy)
  2088. {
  2089. struct device *dev = cdns_phy->dev;
  2090. of_clk_del_provider(dev->of_node);
  2091. }
  2092. static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy)
  2093. {
  2094. struct device *dev = cdns_phy->dev;
  2095. struct device_node *node = dev->of_node;
  2096. struct clk_hw_onecell_data *data;
  2097. int ret;
  2098. data = devm_kzalloc(dev, struct_size(data, hws, CDNS_TORRENT_OUTPUT_CLOCKS), GFP_KERNEL);
  2099. if (!data)
  2100. return -ENOMEM;
  2101. data->num = CDNS_TORRENT_OUTPUT_CLOCKS;
  2102. cdns_phy->clk_hw_data = data;
  2103. ret = cdns_torrent_derived_refclk_register(cdns_phy);
  2104. if (ret) {
  2105. dev_err(dev, "failed to register derived refclk\n");
  2106. return ret;
  2107. }
  2108. ret = cdns_torrent_received_refclk_register(cdns_phy);
  2109. if (ret) {
  2110. dev_err(dev, "failed to register received refclk\n");
  2111. return ret;
  2112. }
  2113. ret = cdns_torrent_refclk_driver_register(cdns_phy);
  2114. if (ret) {
  2115. dev_err(dev, "failed to register refclk driver\n");
  2116. return ret;
  2117. }
  2118. ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, data);
  2119. if (ret) {
  2120. dev_err(dev, "Failed to add clock provider: %s\n", node->name);
  2121. return ret;
  2122. }
  2123. return 0;
  2124. }
  2125. static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy)
  2126. {
  2127. struct device *dev = cdns_phy->dev;
  2128. cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0);
  2129. if (IS_ERR(cdns_phy->phy_rst)) {
  2130. dev_err(dev, "%s: failed to get reset\n",
  2131. dev->of_node->full_name);
  2132. return PTR_ERR(cdns_phy->phy_rst);
  2133. }
  2134. cdns_phy->apb_rst = devm_reset_control_get_optional_exclusive(dev, "torrent_apb");
  2135. if (IS_ERR(cdns_phy->apb_rst)) {
  2136. dev_err(dev, "%s: failed to get apb reset\n",
  2137. dev->of_node->full_name);
  2138. return PTR_ERR(cdns_phy->apb_rst);
  2139. }
  2140. return 0;
  2141. }
  2142. static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy)
  2143. {
  2144. struct device *dev = cdns_phy->dev;
  2145. unsigned long ref_clk_rate;
  2146. int ret;
  2147. cdns_phy->clk = devm_clk_get(dev, "refclk");
  2148. if (IS_ERR(cdns_phy->clk)) {
  2149. dev_err(dev, "phy ref clock not found\n");
  2150. return PTR_ERR(cdns_phy->clk);
  2151. }
  2152. ret = clk_prepare_enable(cdns_phy->clk);
  2153. if (ret) {
  2154. dev_err(cdns_phy->dev, "Failed to prepare ref clock\n");
  2155. return ret;
  2156. }
  2157. ref_clk_rate = clk_get_rate(cdns_phy->clk);
  2158. if (!ref_clk_rate) {
  2159. dev_err(cdns_phy->dev, "Failed to get ref clock rate\n");
  2160. clk_disable_unprepare(cdns_phy->clk);
  2161. return -EINVAL;
  2162. }
  2163. switch (ref_clk_rate) {
  2164. case REF_CLK_19_2MHZ:
  2165. cdns_phy->ref_clk_rate = CLK_19_2_MHZ;
  2166. break;
  2167. case REF_CLK_25MHZ:
  2168. cdns_phy->ref_clk_rate = CLK_25_MHZ;
  2169. break;
  2170. case REF_CLK_100MHZ:
  2171. cdns_phy->ref_clk_rate = CLK_100_MHZ;
  2172. break;
  2173. default:
  2174. dev_err(cdns_phy->dev, "Invalid Ref Clock Rate\n");
  2175. clk_disable_unprepare(cdns_phy->clk);
  2176. return -EINVAL;
  2177. }
  2178. return 0;
  2179. }
  2180. static int cdns_torrent_phy_probe(struct platform_device *pdev)
  2181. {
  2182. struct cdns_torrent_phy *cdns_phy;
  2183. struct device *dev = &pdev->dev;
  2184. struct phy_provider *phy_provider;
  2185. const struct cdns_torrent_data *data;
  2186. struct device_node *child;
  2187. int ret, subnodes, node = 0, i;
  2188. u32 total_num_lanes = 0;
  2189. int already_configured;
  2190. u8 init_dp_regmap = 0;
  2191. u32 phy_type;
  2192. /* Get init data for this PHY */
  2193. data = of_device_get_match_data(dev);
  2194. if (!data)
  2195. return -EINVAL;
  2196. cdns_phy = devm_kzalloc(dev, sizeof(*cdns_phy), GFP_KERNEL);
  2197. if (!cdns_phy)
  2198. return -ENOMEM;
  2199. dev_set_drvdata(dev, cdns_phy);
  2200. cdns_phy->dev = dev;
  2201. cdns_phy->init_data = data;
  2202. cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0);
  2203. if (IS_ERR(cdns_phy->sd_base))
  2204. return PTR_ERR(cdns_phy->sd_base);
  2205. subnodes = of_get_available_child_count(dev->of_node);
  2206. if (subnodes == 0) {
  2207. dev_err(dev, "No available link subnodes found\n");
  2208. return -EINVAL;
  2209. }
  2210. ret = cdns_torrent_regmap_init(cdns_phy);
  2211. if (ret)
  2212. return ret;
  2213. ret = cdns_torrent_regfield_init(cdns_phy);
  2214. if (ret)
  2215. return ret;
  2216. ret = cdns_torrent_clk_register(cdns_phy);
  2217. if (ret)
  2218. return ret;
  2219. regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured);
  2220. if (!already_configured) {
  2221. ret = cdns_torrent_reset(cdns_phy);
  2222. if (ret)
  2223. goto clk_cleanup;
  2224. ret = cdns_torrent_clk(cdns_phy);
  2225. if (ret)
  2226. goto clk_cleanup;
  2227. /* Enable APB */
  2228. reset_control_deassert(cdns_phy->apb_rst);
  2229. }
  2230. for_each_available_child_of_node(dev->of_node, child) {
  2231. struct phy *gphy;
  2232. /* PHY subnode name must be 'phy'. */
  2233. if (!(of_node_name_eq(child, "phy")))
  2234. continue;
  2235. cdns_phy->phys[node].lnk_rst =
  2236. of_reset_control_array_get_exclusive(child);
  2237. if (IS_ERR(cdns_phy->phys[node].lnk_rst)) {
  2238. dev_err(dev, "%s: failed to get reset\n",
  2239. child->full_name);
  2240. ret = PTR_ERR(cdns_phy->phys[node].lnk_rst);
  2241. goto put_lnk_rst;
  2242. }
  2243. if (of_property_read_u32(child, "reg",
  2244. &cdns_phy->phys[node].mlane)) {
  2245. dev_err(dev, "%s: No \"reg\"-property.\n",
  2246. child->full_name);
  2247. ret = -EINVAL;
  2248. goto put_child;
  2249. }
  2250. if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) {
  2251. dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n",
  2252. child->full_name);
  2253. ret = -EINVAL;
  2254. goto put_child;
  2255. }
  2256. switch (phy_type) {
  2257. case PHY_TYPE_PCIE:
  2258. cdns_phy->phys[node].phy_type = TYPE_PCIE;
  2259. break;
  2260. case PHY_TYPE_DP:
  2261. cdns_phy->phys[node].phy_type = TYPE_DP;
  2262. break;
  2263. case PHY_TYPE_SGMII:
  2264. cdns_phy->phys[node].phy_type = TYPE_SGMII;
  2265. break;
  2266. case PHY_TYPE_QSGMII:
  2267. cdns_phy->phys[node].phy_type = TYPE_QSGMII;
  2268. break;
  2269. case PHY_TYPE_USB3:
  2270. cdns_phy->phys[node].phy_type = TYPE_USB;
  2271. break;
  2272. default:
  2273. dev_err(dev, "Unsupported protocol\n");
  2274. ret = -EINVAL;
  2275. goto put_child;
  2276. }
  2277. if (of_property_read_u32(child, "cdns,num-lanes",
  2278. &cdns_phy->phys[node].num_lanes)) {
  2279. dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n",
  2280. child->full_name);
  2281. ret = -EINVAL;
  2282. goto put_child;
  2283. }
  2284. total_num_lanes += cdns_phy->phys[node].num_lanes;
  2285. /* Get SSC mode */
  2286. cdns_phy->phys[node].ssc_mode = NO_SSC;
  2287. of_property_read_u32(child, "cdns,ssc-mode",
  2288. &cdns_phy->phys[node].ssc_mode);
  2289. if (!already_configured)
  2290. gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops);
  2291. else
  2292. gphy = devm_phy_create(dev, child, &noop_ops);
  2293. if (IS_ERR(gphy)) {
  2294. ret = PTR_ERR(gphy);
  2295. goto put_child;
  2296. }
  2297. if (cdns_phy->phys[node].phy_type == TYPE_DP) {
  2298. switch (cdns_phy->phys[node].num_lanes) {
  2299. case 1:
  2300. case 2:
  2301. case 4:
  2302. /* valid number of lanes */
  2303. break;
  2304. default:
  2305. dev_err(dev, "unsupported number of lanes: %d\n",
  2306. cdns_phy->phys[node].num_lanes);
  2307. ret = -EINVAL;
  2308. goto put_child;
  2309. }
  2310. cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE;
  2311. of_property_read_u32(child, "cdns,max-bit-rate",
  2312. &cdns_phy->max_bit_rate);
  2313. switch (cdns_phy->max_bit_rate) {
  2314. case 1620:
  2315. case 2160:
  2316. case 2430:
  2317. case 2700:
  2318. case 3240:
  2319. case 4320:
  2320. case 5400:
  2321. case 8100:
  2322. /* valid bit rate */
  2323. break;
  2324. default:
  2325. dev_err(dev, "unsupported max bit rate: %dMbps\n",
  2326. cdns_phy->max_bit_rate);
  2327. ret = -EINVAL;
  2328. goto put_child;
  2329. }
  2330. /* DPTX registers */
  2331. cdns_phy->base = devm_platform_ioremap_resource(pdev, 1);
  2332. if (IS_ERR(cdns_phy->base)) {
  2333. ret = PTR_ERR(cdns_phy->base);
  2334. goto put_child;
  2335. }
  2336. if (!init_dp_regmap) {
  2337. ret = cdns_torrent_dp_regmap_init(cdns_phy);
  2338. if (ret)
  2339. goto put_child;
  2340. ret = cdns_torrent_dp_regfield_init(cdns_phy);
  2341. if (ret)
  2342. goto put_child;
  2343. init_dp_regmap++;
  2344. }
  2345. dev_dbg(dev, "DP max bit rate %d.%03d Gbps\n",
  2346. cdns_phy->max_bit_rate / 1000,
  2347. cdns_phy->max_bit_rate % 1000);
  2348. gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes;
  2349. gphy->attrs.max_link_rate = cdns_phy->max_bit_rate;
  2350. gphy->attrs.mode = PHY_MODE_DP;
  2351. }
  2352. cdns_phy->phys[node].phy = gphy;
  2353. phy_set_drvdata(gphy, &cdns_phy->phys[node]);
  2354. node++;
  2355. }
  2356. cdns_phy->nsubnodes = node;
  2357. if (total_num_lanes > MAX_NUM_LANES) {
  2358. dev_err(dev, "Invalid lane configuration\n");
  2359. ret = -EINVAL;
  2360. goto put_lnk_rst;
  2361. }
  2362. if (cdns_phy->nsubnodes > 1 && !already_configured) {
  2363. ret = cdns_torrent_phy_configure_multilink(cdns_phy);
  2364. if (ret)
  2365. goto put_lnk_rst;
  2366. }
  2367. phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
  2368. if (IS_ERR(phy_provider)) {
  2369. ret = PTR_ERR(phy_provider);
  2370. goto put_lnk_rst;
  2371. }
  2372. if (cdns_phy->nsubnodes > 1)
  2373. dev_dbg(dev, "Multi-link: %s (%d lanes) & %s (%d lanes)",
  2374. cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type),
  2375. cdns_phy->phys[0].num_lanes,
  2376. cdns_torrent_get_phy_type(cdns_phy->phys[1].phy_type),
  2377. cdns_phy->phys[1].num_lanes);
  2378. else
  2379. dev_dbg(dev, "Single link: %s (%d lanes)",
  2380. cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type),
  2381. cdns_phy->phys[0].num_lanes);
  2382. return 0;
  2383. put_child:
  2384. node++;
  2385. put_lnk_rst:
  2386. for (i = 0; i < node; i++)
  2387. reset_control_put(cdns_phy->phys[i].lnk_rst);
  2388. of_node_put(child);
  2389. reset_control_assert(cdns_phy->apb_rst);
  2390. clk_disable_unprepare(cdns_phy->clk);
  2391. clk_cleanup:
  2392. cdns_torrent_clk_cleanup(cdns_phy);
  2393. return ret;
  2394. }
  2395. static int cdns_torrent_phy_remove(struct platform_device *pdev)
  2396. {
  2397. struct cdns_torrent_phy *cdns_phy = platform_get_drvdata(pdev);
  2398. int i;
  2399. reset_control_assert(cdns_phy->phy_rst);
  2400. reset_control_assert(cdns_phy->apb_rst);
  2401. for (i = 0; i < cdns_phy->nsubnodes; i++) {
  2402. reset_control_assert(cdns_phy->phys[i].lnk_rst);
  2403. reset_control_put(cdns_phy->phys[i].lnk_rst);
  2404. }
  2405. clk_disable_unprepare(cdns_phy->clk);
  2406. cdns_torrent_clk_cleanup(cdns_phy);
  2407. return 0;
  2408. }
  2409. /* Single DisplayPort(DP) link configuration */
  2410. static struct cdns_reg_pairs sl_dp_link_cmn_regs[] = {
  2411. {0x0000, PHY_PLL_CFG},
  2412. };
  2413. static struct cdns_reg_pairs sl_dp_xcvr_diag_ln_regs[] = {
  2414. {0x0000, XCVR_DIAG_HSCLK_SEL},
  2415. {0x0001, XCVR_DIAG_PLLDRC_CTRL}
  2416. };
  2417. static struct cdns_torrent_vals sl_dp_link_cmn_vals = {
  2418. .reg_pairs = sl_dp_link_cmn_regs,
  2419. .num_regs = ARRAY_SIZE(sl_dp_link_cmn_regs),
  2420. };
  2421. static struct cdns_torrent_vals sl_dp_xcvr_diag_ln_vals = {
  2422. .reg_pairs = sl_dp_xcvr_diag_ln_regs,
  2423. .num_regs = ARRAY_SIZE(sl_dp_xcvr_diag_ln_regs),
  2424. };
  2425. /* Single DP, 19.2 MHz Ref clk, no SSC */
  2426. static struct cdns_reg_pairs sl_dp_19_2_no_ssc_cmn_regs[] = {
  2427. {0x0014, CMN_SSM_BIAS_TMR},
  2428. {0x0027, CMN_PLLSM0_PLLPRE_TMR},
  2429. {0x00A1, CMN_PLLSM0_PLLLOCK_TMR},
  2430. {0x0027, CMN_PLLSM1_PLLPRE_TMR},
  2431. {0x00A1, CMN_PLLSM1_PLLLOCK_TMR},
  2432. {0x0060, CMN_BGCAL_INIT_TMR},
  2433. {0x0060, CMN_BGCAL_ITER_TMR},
  2434. {0x0014, CMN_IBCAL_INIT_TMR},
  2435. {0x0018, CMN_TXPUCAL_INIT_TMR},
  2436. {0x0005, CMN_TXPUCAL_ITER_TMR},
  2437. {0x0018, CMN_TXPDCAL_INIT_TMR},
  2438. {0x0005, CMN_TXPDCAL_ITER_TMR},
  2439. {0x0240, CMN_RXCAL_INIT_TMR},
  2440. {0x0005, CMN_RXCAL_ITER_TMR},
  2441. {0x0002, CMN_SD_CAL_INIT_TMR},
  2442. {0x0002, CMN_SD_CAL_ITER_TMR},
  2443. {0x000B, CMN_SD_CAL_REFTIM_START},
  2444. {0x0137, CMN_SD_CAL_PLLCNT_START},
  2445. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
  2446. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
  2447. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
  2448. {0x0004, CMN_PLL0_DSM_DIAG_M0},
  2449. {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
  2450. {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
  2451. {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
  2452. {0x0004, CMN_PLL1_DSM_DIAG_M0},
  2453. {0x00C0, CMN_PLL0_VCOCAL_INIT_TMR},
  2454. {0x0004, CMN_PLL0_VCOCAL_ITER_TMR},
  2455. {0x00C0, CMN_PLL1_VCOCAL_INIT_TMR},
  2456. {0x0004, CMN_PLL1_VCOCAL_ITER_TMR},
  2457. {0x0260, CMN_PLL0_VCOCAL_REFTIM_START},
  2458. {0x0003, CMN_PLL0_VCOCAL_TCTRL},
  2459. {0x0260, CMN_PLL1_VCOCAL_REFTIM_START},
  2460. {0x0003, CMN_PLL1_VCOCAL_TCTRL}
  2461. };
  2462. static struct cdns_reg_pairs sl_dp_19_2_no_ssc_tx_ln_regs[] = {
  2463. {0x0780, TX_RCVDET_ST_TMR},
  2464. {0x00FB, TX_PSC_A0},
  2465. {0x04AA, TX_PSC_A2},
  2466. {0x04AA, TX_PSC_A3},
  2467. {0x000F, XCVR_DIAG_BIDI_CTRL}
  2468. };
  2469. static struct cdns_reg_pairs sl_dp_19_2_no_ssc_rx_ln_regs[] = {
  2470. {0x0000, RX_PSC_A0},
  2471. {0x0000, RX_PSC_A2},
  2472. {0x0000, RX_PSC_A3},
  2473. {0x0000, RX_PSC_CAL},
  2474. {0x0000, RX_REE_GCSM1_CTRL},
  2475. {0x0000, RX_REE_GCSM2_CTRL},
  2476. {0x0000, RX_REE_PERGCSM_CTRL}
  2477. };
  2478. static struct cdns_torrent_vals sl_dp_19_2_no_ssc_cmn_vals = {
  2479. .reg_pairs = sl_dp_19_2_no_ssc_cmn_regs,
  2480. .num_regs = ARRAY_SIZE(sl_dp_19_2_no_ssc_cmn_regs),
  2481. };
  2482. static struct cdns_torrent_vals sl_dp_19_2_no_ssc_tx_ln_vals = {
  2483. .reg_pairs = sl_dp_19_2_no_ssc_tx_ln_regs,
  2484. .num_regs = ARRAY_SIZE(sl_dp_19_2_no_ssc_tx_ln_regs),
  2485. };
  2486. static struct cdns_torrent_vals sl_dp_19_2_no_ssc_rx_ln_vals = {
  2487. .reg_pairs = sl_dp_19_2_no_ssc_rx_ln_regs,
  2488. .num_regs = ARRAY_SIZE(sl_dp_19_2_no_ssc_rx_ln_regs),
  2489. };
  2490. /* Single DP, 25 MHz Ref clk, no SSC */
  2491. static struct cdns_reg_pairs sl_dp_25_no_ssc_cmn_regs[] = {
  2492. {0x0019, CMN_SSM_BIAS_TMR},
  2493. {0x0032, CMN_PLLSM0_PLLPRE_TMR},
  2494. {0x00D1, CMN_PLLSM0_PLLLOCK_TMR},
  2495. {0x0032, CMN_PLLSM1_PLLPRE_TMR},
  2496. {0x00D1, CMN_PLLSM1_PLLLOCK_TMR},
  2497. {0x007D, CMN_BGCAL_INIT_TMR},
  2498. {0x007D, CMN_BGCAL_ITER_TMR},
  2499. {0x0019, CMN_IBCAL_INIT_TMR},
  2500. {0x001E, CMN_TXPUCAL_INIT_TMR},
  2501. {0x0006, CMN_TXPUCAL_ITER_TMR},
  2502. {0x001E, CMN_TXPDCAL_INIT_TMR},
  2503. {0x0006, CMN_TXPDCAL_ITER_TMR},
  2504. {0x02EE, CMN_RXCAL_INIT_TMR},
  2505. {0x0006, CMN_RXCAL_ITER_TMR},
  2506. {0x0002, CMN_SD_CAL_INIT_TMR},
  2507. {0x0002, CMN_SD_CAL_ITER_TMR},
  2508. {0x000E, CMN_SD_CAL_REFTIM_START},
  2509. {0x012B, CMN_SD_CAL_PLLCNT_START},
  2510. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
  2511. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
  2512. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
  2513. {0x0004, CMN_PLL0_DSM_DIAG_M0},
  2514. {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
  2515. {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
  2516. {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
  2517. {0x0004, CMN_PLL1_DSM_DIAG_M0},
  2518. {0x00FA, CMN_PLL0_VCOCAL_INIT_TMR},
  2519. {0x0004, CMN_PLL0_VCOCAL_ITER_TMR},
  2520. {0x00FA, CMN_PLL1_VCOCAL_INIT_TMR},
  2521. {0x0004, CMN_PLL1_VCOCAL_ITER_TMR},
  2522. {0x0317, CMN_PLL0_VCOCAL_REFTIM_START},
  2523. {0x0003, CMN_PLL0_VCOCAL_TCTRL},
  2524. {0x0317, CMN_PLL1_VCOCAL_REFTIM_START},
  2525. {0x0003, CMN_PLL1_VCOCAL_TCTRL}
  2526. };
  2527. static struct cdns_reg_pairs sl_dp_25_no_ssc_tx_ln_regs[] = {
  2528. {0x09C4, TX_RCVDET_ST_TMR},
  2529. {0x00FB, TX_PSC_A0},
  2530. {0x04AA, TX_PSC_A2},
  2531. {0x04AA, TX_PSC_A3},
  2532. {0x000F, XCVR_DIAG_BIDI_CTRL}
  2533. };
  2534. static struct cdns_reg_pairs sl_dp_25_no_ssc_rx_ln_regs[] = {
  2535. {0x0000, RX_PSC_A0},
  2536. {0x0000, RX_PSC_A2},
  2537. {0x0000, RX_PSC_A3},
  2538. {0x0000, RX_PSC_CAL},
  2539. {0x0000, RX_REE_GCSM1_CTRL},
  2540. {0x0000, RX_REE_GCSM2_CTRL},
  2541. {0x0000, RX_REE_PERGCSM_CTRL}
  2542. };
  2543. static struct cdns_torrent_vals sl_dp_25_no_ssc_cmn_vals = {
  2544. .reg_pairs = sl_dp_25_no_ssc_cmn_regs,
  2545. .num_regs = ARRAY_SIZE(sl_dp_25_no_ssc_cmn_regs),
  2546. };
  2547. static struct cdns_torrent_vals sl_dp_25_no_ssc_tx_ln_vals = {
  2548. .reg_pairs = sl_dp_25_no_ssc_tx_ln_regs,
  2549. .num_regs = ARRAY_SIZE(sl_dp_25_no_ssc_tx_ln_regs),
  2550. };
  2551. static struct cdns_torrent_vals sl_dp_25_no_ssc_rx_ln_vals = {
  2552. .reg_pairs = sl_dp_25_no_ssc_rx_ln_regs,
  2553. .num_regs = ARRAY_SIZE(sl_dp_25_no_ssc_rx_ln_regs),
  2554. };
  2555. /* Single DP, 100 MHz Ref clk, no SSC */
  2556. static struct cdns_reg_pairs sl_dp_100_no_ssc_cmn_regs[] = {
  2557. {0x0003, CMN_PLL0_VCOCAL_TCTRL},
  2558. {0x0003, CMN_PLL1_VCOCAL_TCTRL}
  2559. };
  2560. static struct cdns_reg_pairs sl_dp_100_no_ssc_tx_ln_regs[] = {
  2561. {0x00FB, TX_PSC_A0},
  2562. {0x04AA, TX_PSC_A2},
  2563. {0x04AA, TX_PSC_A3},
  2564. {0x000F, XCVR_DIAG_BIDI_CTRL}
  2565. };
  2566. static struct cdns_reg_pairs sl_dp_100_no_ssc_rx_ln_regs[] = {
  2567. {0x0000, RX_PSC_A0},
  2568. {0x0000, RX_PSC_A2},
  2569. {0x0000, RX_PSC_A3},
  2570. {0x0000, RX_PSC_CAL},
  2571. {0x0000, RX_REE_GCSM1_CTRL},
  2572. {0x0000, RX_REE_GCSM2_CTRL},
  2573. {0x0000, RX_REE_PERGCSM_CTRL}
  2574. };
  2575. static struct cdns_torrent_vals sl_dp_100_no_ssc_cmn_vals = {
  2576. .reg_pairs = sl_dp_100_no_ssc_cmn_regs,
  2577. .num_regs = ARRAY_SIZE(sl_dp_100_no_ssc_cmn_regs),
  2578. };
  2579. static struct cdns_torrent_vals sl_dp_100_no_ssc_tx_ln_vals = {
  2580. .reg_pairs = sl_dp_100_no_ssc_tx_ln_regs,
  2581. .num_regs = ARRAY_SIZE(sl_dp_100_no_ssc_tx_ln_regs),
  2582. };
  2583. static struct cdns_torrent_vals sl_dp_100_no_ssc_rx_ln_vals = {
  2584. .reg_pairs = sl_dp_100_no_ssc_rx_ln_regs,
  2585. .num_regs = ARRAY_SIZE(sl_dp_100_no_ssc_rx_ln_regs),
  2586. };
  2587. /* USB and SGMII/QSGMII link configuration */
  2588. static struct cdns_reg_pairs usb_sgmii_link_cmn_regs[] = {
  2589. {0x0002, PHY_PLL_CFG},
  2590. {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0},
  2591. {0x0601, CMN_PDIAG_PLL1_CLK_SEL_M0}
  2592. };
  2593. static struct cdns_reg_pairs usb_sgmii_xcvr_diag_ln_regs[] = {
  2594. {0x0000, XCVR_DIAG_HSCLK_SEL},
  2595. {0x0001, XCVR_DIAG_HSCLK_DIV},
  2596. {0x0041, XCVR_DIAG_PLLDRC_CTRL}
  2597. };
  2598. static struct cdns_reg_pairs sgmii_usb_xcvr_diag_ln_regs[] = {
  2599. {0x0011, XCVR_DIAG_HSCLK_SEL},
  2600. {0x0003, XCVR_DIAG_HSCLK_DIV},
  2601. {0x009B, XCVR_DIAG_PLLDRC_CTRL}
  2602. };
  2603. static struct cdns_torrent_vals usb_sgmii_link_cmn_vals = {
  2604. .reg_pairs = usb_sgmii_link_cmn_regs,
  2605. .num_regs = ARRAY_SIZE(usb_sgmii_link_cmn_regs),
  2606. };
  2607. static struct cdns_torrent_vals usb_sgmii_xcvr_diag_ln_vals = {
  2608. .reg_pairs = usb_sgmii_xcvr_diag_ln_regs,
  2609. .num_regs = ARRAY_SIZE(usb_sgmii_xcvr_diag_ln_regs),
  2610. };
  2611. static struct cdns_torrent_vals sgmii_usb_xcvr_diag_ln_vals = {
  2612. .reg_pairs = sgmii_usb_xcvr_diag_ln_regs,
  2613. .num_regs = ARRAY_SIZE(sgmii_usb_xcvr_diag_ln_regs),
  2614. };
  2615. /* PCIe and USB Unique SSC link configuration */
  2616. static struct cdns_reg_pairs pcie_usb_link_cmn_regs[] = {
  2617. {0x0003, PHY_PLL_CFG},
  2618. {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
  2619. {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1},
  2620. {0x8600, CMN_PDIAG_PLL1_CLK_SEL_M0}
  2621. };
  2622. static struct cdns_reg_pairs pcie_usb_xcvr_diag_ln_regs[] = {
  2623. {0x0000, XCVR_DIAG_HSCLK_SEL},
  2624. {0x0001, XCVR_DIAG_HSCLK_DIV},
  2625. {0x0012, XCVR_DIAG_PLLDRC_CTRL}
  2626. };
  2627. static struct cdns_reg_pairs usb_pcie_xcvr_diag_ln_regs[] = {
  2628. {0x0011, XCVR_DIAG_HSCLK_SEL},
  2629. {0x0001, XCVR_DIAG_HSCLK_DIV},
  2630. {0x00C9, XCVR_DIAG_PLLDRC_CTRL}
  2631. };
  2632. static struct cdns_torrent_vals pcie_usb_link_cmn_vals = {
  2633. .reg_pairs = pcie_usb_link_cmn_regs,
  2634. .num_regs = ARRAY_SIZE(pcie_usb_link_cmn_regs),
  2635. };
  2636. static struct cdns_torrent_vals pcie_usb_xcvr_diag_ln_vals = {
  2637. .reg_pairs = pcie_usb_xcvr_diag_ln_regs,
  2638. .num_regs = ARRAY_SIZE(pcie_usb_xcvr_diag_ln_regs),
  2639. };
  2640. static struct cdns_torrent_vals usb_pcie_xcvr_diag_ln_vals = {
  2641. .reg_pairs = usb_pcie_xcvr_diag_ln_regs,
  2642. .num_regs = ARRAY_SIZE(usb_pcie_xcvr_diag_ln_regs),
  2643. };
  2644. /* USB 100 MHz Ref clk, internal SSC */
  2645. static struct cdns_reg_pairs usb_100_int_ssc_cmn_regs[] = {
  2646. {0x0004, CMN_PLL0_DSM_DIAG_M0},
  2647. {0x0004, CMN_PLL0_DSM_DIAG_M1},
  2648. {0x0004, CMN_PLL1_DSM_DIAG_M0},
  2649. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
  2650. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
  2651. {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
  2652. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
  2653. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
  2654. {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
  2655. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
  2656. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
  2657. {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
  2658. {0x0064, CMN_PLL0_INTDIV_M0},
  2659. {0x0050, CMN_PLL0_INTDIV_M1},
  2660. {0x0064, CMN_PLL1_INTDIV_M0},
  2661. {0x0002, CMN_PLL0_FRACDIVH_M0},
  2662. {0x0002, CMN_PLL0_FRACDIVH_M1},
  2663. {0x0002, CMN_PLL1_FRACDIVH_M0},
  2664. {0x0044, CMN_PLL0_HIGH_THR_M0},
  2665. {0x0036, CMN_PLL0_HIGH_THR_M1},
  2666. {0x0044, CMN_PLL1_HIGH_THR_M0},
  2667. {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
  2668. {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
  2669. {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
  2670. {0x0001, CMN_PLL0_SS_CTRL1_M0},
  2671. {0x0001, CMN_PLL0_SS_CTRL1_M1},
  2672. {0x0001, CMN_PLL1_SS_CTRL1_M0},
  2673. {0x011B, CMN_PLL0_SS_CTRL2_M0},
  2674. {0x011B, CMN_PLL0_SS_CTRL2_M1},
  2675. {0x011B, CMN_PLL1_SS_CTRL2_M0},
  2676. {0x006E, CMN_PLL0_SS_CTRL3_M0},
  2677. {0x0058, CMN_PLL0_SS_CTRL3_M1},
  2678. {0x006E, CMN_PLL1_SS_CTRL3_M0},
  2679. {0x000E, CMN_PLL0_SS_CTRL4_M0},
  2680. {0x0012, CMN_PLL0_SS_CTRL4_M1},
  2681. {0x000E, CMN_PLL1_SS_CTRL4_M0},
  2682. {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
  2683. {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
  2684. {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
  2685. {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
  2686. {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
  2687. {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
  2688. {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
  2689. {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
  2690. {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
  2691. {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
  2692. {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
  2693. {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD},
  2694. {0x007F, CMN_TXPUCAL_TUNE},
  2695. {0x007F, CMN_TXPDCAL_TUNE}
  2696. };
  2697. static struct cdns_torrent_vals usb_100_int_ssc_cmn_vals = {
  2698. .reg_pairs = usb_100_int_ssc_cmn_regs,
  2699. .num_regs = ARRAY_SIZE(usb_100_int_ssc_cmn_regs),
  2700. };
  2701. /* Single USB link configuration */
  2702. static struct cdns_reg_pairs sl_usb_link_cmn_regs[] = {
  2703. {0x0000, PHY_PLL_CFG},
  2704. {0x8600, CMN_PDIAG_PLL0_CLK_SEL_M0}
  2705. };
  2706. static struct cdns_reg_pairs sl_usb_xcvr_diag_ln_regs[] = {
  2707. {0x0000, XCVR_DIAG_HSCLK_SEL},
  2708. {0x0001, XCVR_DIAG_HSCLK_DIV},
  2709. {0x0041, XCVR_DIAG_PLLDRC_CTRL}
  2710. };
  2711. static struct cdns_torrent_vals sl_usb_link_cmn_vals = {
  2712. .reg_pairs = sl_usb_link_cmn_regs,
  2713. .num_regs = ARRAY_SIZE(sl_usb_link_cmn_regs),
  2714. };
  2715. static struct cdns_torrent_vals sl_usb_xcvr_diag_ln_vals = {
  2716. .reg_pairs = sl_usb_xcvr_diag_ln_regs,
  2717. .num_regs = ARRAY_SIZE(sl_usb_xcvr_diag_ln_regs),
  2718. };
  2719. /* USB PHY PCS common configuration */
  2720. static struct cdns_reg_pairs usb_phy_pcs_cmn_regs[] = {
  2721. {0x0A0A, PHY_PIPE_USB3_GEN2_PRE_CFG0},
  2722. {0x1000, PHY_PIPE_USB3_GEN2_POST_CFG0},
  2723. {0x0010, PHY_PIPE_USB3_GEN2_POST_CFG1}
  2724. };
  2725. static struct cdns_torrent_vals usb_phy_pcs_cmn_vals = {
  2726. .reg_pairs = usb_phy_pcs_cmn_regs,
  2727. .num_regs = ARRAY_SIZE(usb_phy_pcs_cmn_regs),
  2728. };
  2729. /* USB 100 MHz Ref clk, no SSC */
  2730. static struct cdns_reg_pairs sl_usb_100_no_ssc_cmn_regs[] = {
  2731. {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
  2732. {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
  2733. {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
  2734. {0x0003, CMN_PLL0_VCOCAL_TCTRL},
  2735. {0x0003, CMN_PLL1_VCOCAL_TCTRL},
  2736. {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
  2737. {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD}
  2738. };
  2739. static struct cdns_torrent_vals sl_usb_100_no_ssc_cmn_vals = {
  2740. .reg_pairs = sl_usb_100_no_ssc_cmn_regs,
  2741. .num_regs = ARRAY_SIZE(sl_usb_100_no_ssc_cmn_regs),
  2742. };
  2743. static struct cdns_reg_pairs usb_100_no_ssc_cmn_regs[] = {
  2744. {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
  2745. {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD},
  2746. {0x007F, CMN_TXPUCAL_TUNE},
  2747. {0x007F, CMN_TXPDCAL_TUNE}
  2748. };
  2749. static struct cdns_reg_pairs usb_100_no_ssc_tx_ln_regs[] = {
  2750. {0x02FF, TX_PSC_A0},
  2751. {0x06AF, TX_PSC_A1},
  2752. {0x06AE, TX_PSC_A2},
  2753. {0x06AE, TX_PSC_A3},
  2754. {0x2A82, TX_TXCC_CTRL},
  2755. {0x0014, TX_TXCC_CPOST_MULT_01},
  2756. {0x0003, XCVR_DIAG_PSC_OVRD}
  2757. };
  2758. static struct cdns_reg_pairs usb_100_no_ssc_rx_ln_regs[] = {
  2759. {0x0D1D, RX_PSC_A0},
  2760. {0x0D1D, RX_PSC_A1},
  2761. {0x0D00, RX_PSC_A2},
  2762. {0x0500, RX_PSC_A3},
  2763. {0x0013, RX_SIGDET_HL_FILT_TMR},
  2764. {0x0000, RX_REE_GCSM1_CTRL},
  2765. {0x0C02, RX_REE_ATTEN_THR},
  2766. {0x0330, RX_REE_SMGM_CTRL1},
  2767. {0x0300, RX_REE_SMGM_CTRL2},
  2768. {0x0019, RX_REE_TAP1_CLIP},
  2769. {0x0019, RX_REE_TAP2TON_CLIP},
  2770. {0x1004, RX_DIAG_SIGDET_TUNE},
  2771. {0x00F9, RX_DIAG_NQST_CTRL},
  2772. {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
  2773. {0x0002, RX_DIAG_DFE_AMP_TUNE_3},
  2774. {0x0000, RX_DIAG_PI_CAP},
  2775. {0x0031, RX_DIAG_PI_RATE},
  2776. {0x0001, RX_DIAG_ACYA},
  2777. {0x018C, RX_CDRLF_CNFG},
  2778. {0x0003, RX_CDRLF_CNFG3}
  2779. };
  2780. static struct cdns_torrent_vals usb_100_no_ssc_cmn_vals = {
  2781. .reg_pairs = usb_100_no_ssc_cmn_regs,
  2782. .num_regs = ARRAY_SIZE(usb_100_no_ssc_cmn_regs),
  2783. };
  2784. static struct cdns_torrent_vals usb_100_no_ssc_tx_ln_vals = {
  2785. .reg_pairs = usb_100_no_ssc_tx_ln_regs,
  2786. .num_regs = ARRAY_SIZE(usb_100_no_ssc_tx_ln_regs),
  2787. };
  2788. static struct cdns_torrent_vals usb_100_no_ssc_rx_ln_vals = {
  2789. .reg_pairs = usb_100_no_ssc_rx_ln_regs,
  2790. .num_regs = ARRAY_SIZE(usb_100_no_ssc_rx_ln_regs),
  2791. };
  2792. /* Single link USB, 100 MHz Ref clk, internal SSC */
  2793. static struct cdns_reg_pairs sl_usb_100_int_ssc_cmn_regs[] = {
  2794. {0x0004, CMN_PLL0_DSM_DIAG_M0},
  2795. {0x0004, CMN_PLL1_DSM_DIAG_M0},
  2796. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
  2797. {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
  2798. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
  2799. {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
  2800. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
  2801. {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
  2802. {0x0064, CMN_PLL0_INTDIV_M0},
  2803. {0x0064, CMN_PLL1_INTDIV_M0},
  2804. {0x0002, CMN_PLL0_FRACDIVH_M0},
  2805. {0x0002, CMN_PLL1_FRACDIVH_M0},
  2806. {0x0044, CMN_PLL0_HIGH_THR_M0},
  2807. {0x0044, CMN_PLL1_HIGH_THR_M0},
  2808. {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
  2809. {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
  2810. {0x0001, CMN_PLL0_SS_CTRL1_M0},
  2811. {0x0001, CMN_PLL1_SS_CTRL1_M0},
  2812. {0x011B, CMN_PLL0_SS_CTRL2_M0},
  2813. {0x011B, CMN_PLL1_SS_CTRL2_M0},
  2814. {0x006E, CMN_PLL0_SS_CTRL3_M0},
  2815. {0x006E, CMN_PLL1_SS_CTRL3_M0},
  2816. {0x000E, CMN_PLL0_SS_CTRL4_M0},
  2817. {0x000E, CMN_PLL1_SS_CTRL4_M0},
  2818. {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
  2819. {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
  2820. {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
  2821. {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
  2822. {0x0003, CMN_PLL0_VCOCAL_TCTRL},
  2823. {0x0003, CMN_PLL1_VCOCAL_TCTRL},
  2824. {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
  2825. {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
  2826. {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
  2827. {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
  2828. {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
  2829. {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
  2830. {0x8200, CMN_CDIAG_CDB_PWRI_OVRD},
  2831. {0x8200, CMN_CDIAG_XCVRC_PWRI_OVRD}
  2832. };
  2833. static struct cdns_torrent_vals sl_usb_100_int_ssc_cmn_vals = {
  2834. .reg_pairs = sl_usb_100_int_ssc_cmn_regs,
  2835. .num_regs = ARRAY_SIZE(sl_usb_100_int_ssc_cmn_regs),
  2836. };
  2837. /* PCIe and SGMII/QSGMII Unique SSC link configuration */
  2838. static struct cdns_reg_pairs pcie_sgmii_link_cmn_regs[] = {
  2839. {0x0003, PHY_PLL_CFG},
  2840. {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0},
  2841. {0x0400, CMN_PDIAG_PLL0_CLK_SEL_M1},
  2842. {0x0601, CMN_PDIAG_PLL1_CLK_SEL_M0}
  2843. };
  2844. static struct cdns_reg_pairs pcie_sgmii_xcvr_diag_ln_regs[] = {
  2845. {0x0000, XCVR_DIAG_HSCLK_SEL},
  2846. {0x0001, XCVR_DIAG_HSCLK_DIV},
  2847. {0x0012, XCVR_DIAG_PLLDRC_CTRL}
  2848. };
  2849. static struct cdns_reg_pairs sgmii_pcie_xcvr_diag_ln_regs[] = {
  2850. {0x0011, XCVR_DIAG_HSCLK_SEL},
  2851. {0x0003, XCVR_DIAG_HSCLK_DIV},
  2852. {0x009B, XCVR_DIAG_PLLDRC_CTRL}
  2853. };
  2854. static struct cdns_torrent_vals pcie_sgmii_link_cmn_vals = {
  2855. .reg_pairs = pcie_sgmii_link_cmn_regs,
  2856. .num_regs = ARRAY_SIZE(pcie_sgmii_link_cmn_regs),
  2857. };
  2858. static struct cdns_torrent_vals pcie_sgmii_xcvr_diag_ln_vals = {
  2859. .reg_pairs = pcie_sgmii_xcvr_diag_ln_regs,
  2860. .num_regs = ARRAY_SIZE(pcie_sgmii_xcvr_diag_ln_regs),
  2861. };
  2862. static struct cdns_torrent_vals sgmii_pcie_xcvr_diag_ln_vals = {
  2863. .reg_pairs = sgmii_pcie_xcvr_diag_ln_regs,
  2864. .num_regs = ARRAY_SIZE(sgmii_pcie_xcvr_diag_ln_regs),
  2865. };
  2866. /* SGMII 100 MHz Ref clk, no SSC */
  2867. static struct cdns_reg_pairs sl_sgmii_100_no_ssc_cmn_regs[] = {
  2868. {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
  2869. {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
  2870. {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
  2871. {0x0003, CMN_PLL0_VCOCAL_TCTRL},
  2872. {0x0003, CMN_PLL1_VCOCAL_TCTRL}
  2873. };
  2874. static struct cdns_torrent_vals sl_sgmii_100_no_ssc_cmn_vals = {
  2875. .reg_pairs = sl_sgmii_100_no_ssc_cmn_regs,
  2876. .num_regs = ARRAY_SIZE(sl_sgmii_100_no_ssc_cmn_regs),
  2877. };
  2878. static struct cdns_reg_pairs sgmii_100_no_ssc_cmn_regs[] = {
  2879. {0x007F, CMN_TXPUCAL_TUNE},
  2880. {0x007F, CMN_TXPDCAL_TUNE}
  2881. };
  2882. static struct cdns_reg_pairs sgmii_100_no_ssc_tx_ln_regs[] = {
  2883. {0x00F3, TX_PSC_A0},
  2884. {0x04A2, TX_PSC_A2},
  2885. {0x04A2, TX_PSC_A3},
  2886. {0x0000, TX_TXCC_CPOST_MULT_00},
  2887. {0x00B3, DRV_DIAG_TX_DRV}
  2888. };
  2889. static struct cdns_reg_pairs ti_sgmii_100_no_ssc_tx_ln_regs[] = {
  2890. {0x00F3, TX_PSC_A0},
  2891. {0x04A2, TX_PSC_A2},
  2892. {0x04A2, TX_PSC_A3},
  2893. {0x0000, TX_TXCC_CPOST_MULT_00},
  2894. {0x00B3, DRV_DIAG_TX_DRV},
  2895. {0x4000, XCVR_DIAG_RXCLK_CTRL},
  2896. };
  2897. static struct cdns_reg_pairs sgmii_100_no_ssc_rx_ln_regs[] = {
  2898. {0x091D, RX_PSC_A0},
  2899. {0x0900, RX_PSC_A2},
  2900. {0x0100, RX_PSC_A3},
  2901. {0x03C7, RX_REE_GCSM1_EQENM_PH1},
  2902. {0x01C7, RX_REE_GCSM1_EQENM_PH2},
  2903. {0x0000, RX_DIAG_DFE_CTRL},
  2904. {0x0019, RX_REE_TAP1_CLIP},
  2905. {0x0019, RX_REE_TAP2TON_CLIP},
  2906. {0x0098, RX_DIAG_NQST_CTRL},
  2907. {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
  2908. {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
  2909. {0x0000, RX_DIAG_PI_CAP},
  2910. {0x0010, RX_DIAG_PI_RATE},
  2911. {0x0001, RX_DIAG_ACYA},
  2912. {0x018C, RX_CDRLF_CNFG},
  2913. };
  2914. static struct cdns_torrent_vals sgmii_100_no_ssc_cmn_vals = {
  2915. .reg_pairs = sgmii_100_no_ssc_cmn_regs,
  2916. .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_cmn_regs),
  2917. };
  2918. static struct cdns_torrent_vals sgmii_100_no_ssc_tx_ln_vals = {
  2919. .reg_pairs = sgmii_100_no_ssc_tx_ln_regs,
  2920. .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_tx_ln_regs),
  2921. };
  2922. static struct cdns_torrent_vals ti_sgmii_100_no_ssc_tx_ln_vals = {
  2923. .reg_pairs = ti_sgmii_100_no_ssc_tx_ln_regs,
  2924. .num_regs = ARRAY_SIZE(ti_sgmii_100_no_ssc_tx_ln_regs),
  2925. };
  2926. static struct cdns_torrent_vals sgmii_100_no_ssc_rx_ln_vals = {
  2927. .reg_pairs = sgmii_100_no_ssc_rx_ln_regs,
  2928. .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_rx_ln_regs),
  2929. };
  2930. /* SGMII 100 MHz Ref clk, internal SSC */
  2931. static struct cdns_reg_pairs sgmii_100_int_ssc_cmn_regs[] = {
  2932. {0x0004, CMN_PLL0_DSM_DIAG_M0},
  2933. {0x0004, CMN_PLL0_DSM_DIAG_M1},
  2934. {0x0004, CMN_PLL1_DSM_DIAG_M0},
  2935. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
  2936. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
  2937. {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
  2938. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
  2939. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
  2940. {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
  2941. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
  2942. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
  2943. {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
  2944. {0x0064, CMN_PLL0_INTDIV_M0},
  2945. {0x0050, CMN_PLL0_INTDIV_M1},
  2946. {0x0064, CMN_PLL1_INTDIV_M0},
  2947. {0x0002, CMN_PLL0_FRACDIVH_M0},
  2948. {0x0002, CMN_PLL0_FRACDIVH_M1},
  2949. {0x0002, CMN_PLL1_FRACDIVH_M0},
  2950. {0x0044, CMN_PLL0_HIGH_THR_M0},
  2951. {0x0036, CMN_PLL0_HIGH_THR_M1},
  2952. {0x0044, CMN_PLL1_HIGH_THR_M0},
  2953. {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
  2954. {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
  2955. {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
  2956. {0x0001, CMN_PLL0_SS_CTRL1_M0},
  2957. {0x0001, CMN_PLL0_SS_CTRL1_M1},
  2958. {0x0001, CMN_PLL1_SS_CTRL1_M0},
  2959. {0x011B, CMN_PLL0_SS_CTRL2_M0},
  2960. {0x011B, CMN_PLL0_SS_CTRL2_M1},
  2961. {0x011B, CMN_PLL1_SS_CTRL2_M0},
  2962. {0x006E, CMN_PLL0_SS_CTRL3_M0},
  2963. {0x0058, CMN_PLL0_SS_CTRL3_M1},
  2964. {0x006E, CMN_PLL1_SS_CTRL3_M0},
  2965. {0x000E, CMN_PLL0_SS_CTRL4_M0},
  2966. {0x0012, CMN_PLL0_SS_CTRL4_M1},
  2967. {0x000E, CMN_PLL1_SS_CTRL4_M0},
  2968. {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
  2969. {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
  2970. {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
  2971. {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
  2972. {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
  2973. {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
  2974. {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
  2975. {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
  2976. {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
  2977. {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
  2978. {0x007F, CMN_TXPUCAL_TUNE},
  2979. {0x007F, CMN_TXPDCAL_TUNE}
  2980. };
  2981. static struct cdns_torrent_vals sgmii_100_int_ssc_cmn_vals = {
  2982. .reg_pairs = sgmii_100_int_ssc_cmn_regs,
  2983. .num_regs = ARRAY_SIZE(sgmii_100_int_ssc_cmn_regs),
  2984. };
  2985. /* QSGMII 100 MHz Ref clk, no SSC */
  2986. static struct cdns_reg_pairs sl_qsgmii_100_no_ssc_cmn_regs[] = {
  2987. {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
  2988. {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
  2989. {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0},
  2990. {0x0003, CMN_PLL0_VCOCAL_TCTRL},
  2991. {0x0003, CMN_PLL1_VCOCAL_TCTRL}
  2992. };
  2993. static struct cdns_torrent_vals sl_qsgmii_100_no_ssc_cmn_vals = {
  2994. .reg_pairs = sl_qsgmii_100_no_ssc_cmn_regs,
  2995. .num_regs = ARRAY_SIZE(sl_qsgmii_100_no_ssc_cmn_regs),
  2996. };
  2997. static struct cdns_reg_pairs qsgmii_100_no_ssc_cmn_regs[] = {
  2998. {0x007F, CMN_TXPUCAL_TUNE},
  2999. {0x007F, CMN_TXPDCAL_TUNE}
  3000. };
  3001. static struct cdns_reg_pairs qsgmii_100_no_ssc_tx_ln_regs[] = {
  3002. {0x00F3, TX_PSC_A0},
  3003. {0x04A2, TX_PSC_A2},
  3004. {0x04A2, TX_PSC_A3},
  3005. {0x0000, TX_TXCC_CPOST_MULT_00},
  3006. {0x0011, TX_TXCC_MGNFS_MULT_100},
  3007. {0x0003, DRV_DIAG_TX_DRV}
  3008. };
  3009. static struct cdns_reg_pairs ti_qsgmii_100_no_ssc_tx_ln_regs[] = {
  3010. {0x00F3, TX_PSC_A0},
  3011. {0x04A2, TX_PSC_A2},
  3012. {0x04A2, TX_PSC_A3},
  3013. {0x0000, TX_TXCC_CPOST_MULT_00},
  3014. {0x0011, TX_TXCC_MGNFS_MULT_100},
  3015. {0x0003, DRV_DIAG_TX_DRV},
  3016. {0x4000, XCVR_DIAG_RXCLK_CTRL},
  3017. };
  3018. static struct cdns_reg_pairs qsgmii_100_no_ssc_rx_ln_regs[] = {
  3019. {0x091D, RX_PSC_A0},
  3020. {0x0900, RX_PSC_A2},
  3021. {0x0100, RX_PSC_A3},
  3022. {0x03C7, RX_REE_GCSM1_EQENM_PH1},
  3023. {0x01C7, RX_REE_GCSM1_EQENM_PH2},
  3024. {0x0000, RX_DIAG_DFE_CTRL},
  3025. {0x0019, RX_REE_TAP1_CLIP},
  3026. {0x0019, RX_REE_TAP2TON_CLIP},
  3027. {0x0098, RX_DIAG_NQST_CTRL},
  3028. {0x0C01, RX_DIAG_DFE_AMP_TUNE_2},
  3029. {0x0000, RX_DIAG_DFE_AMP_TUNE_3},
  3030. {0x0000, RX_DIAG_PI_CAP},
  3031. {0x0010, RX_DIAG_PI_RATE},
  3032. {0x0001, RX_DIAG_ACYA},
  3033. {0x018C, RX_CDRLF_CNFG},
  3034. };
  3035. static struct cdns_torrent_vals qsgmii_100_no_ssc_cmn_vals = {
  3036. .reg_pairs = qsgmii_100_no_ssc_cmn_regs,
  3037. .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_cmn_regs),
  3038. };
  3039. static struct cdns_torrent_vals qsgmii_100_no_ssc_tx_ln_vals = {
  3040. .reg_pairs = qsgmii_100_no_ssc_tx_ln_regs,
  3041. .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_tx_ln_regs),
  3042. };
  3043. static struct cdns_torrent_vals ti_qsgmii_100_no_ssc_tx_ln_vals = {
  3044. .reg_pairs = ti_qsgmii_100_no_ssc_tx_ln_regs,
  3045. .num_regs = ARRAY_SIZE(ti_qsgmii_100_no_ssc_tx_ln_regs),
  3046. };
  3047. static struct cdns_torrent_vals qsgmii_100_no_ssc_rx_ln_vals = {
  3048. .reg_pairs = qsgmii_100_no_ssc_rx_ln_regs,
  3049. .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_rx_ln_regs),
  3050. };
  3051. /* QSGMII 100 MHz Ref clk, internal SSC */
  3052. static struct cdns_reg_pairs qsgmii_100_int_ssc_cmn_regs[] = {
  3053. {0x0004, CMN_PLL0_DSM_DIAG_M0},
  3054. {0x0004, CMN_PLL0_DSM_DIAG_M1},
  3055. {0x0004, CMN_PLL1_DSM_DIAG_M0},
  3056. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
  3057. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
  3058. {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
  3059. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
  3060. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
  3061. {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
  3062. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
  3063. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
  3064. {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
  3065. {0x0064, CMN_PLL0_INTDIV_M0},
  3066. {0x0050, CMN_PLL0_INTDIV_M1},
  3067. {0x0064, CMN_PLL1_INTDIV_M0},
  3068. {0x0002, CMN_PLL0_FRACDIVH_M0},
  3069. {0x0002, CMN_PLL0_FRACDIVH_M1},
  3070. {0x0002, CMN_PLL1_FRACDIVH_M0},
  3071. {0x0044, CMN_PLL0_HIGH_THR_M0},
  3072. {0x0036, CMN_PLL0_HIGH_THR_M1},
  3073. {0x0044, CMN_PLL1_HIGH_THR_M0},
  3074. {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
  3075. {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
  3076. {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
  3077. {0x0001, CMN_PLL0_SS_CTRL1_M0},
  3078. {0x0001, CMN_PLL0_SS_CTRL1_M1},
  3079. {0x0001, CMN_PLL1_SS_CTRL1_M0},
  3080. {0x011B, CMN_PLL0_SS_CTRL2_M0},
  3081. {0x011B, CMN_PLL0_SS_CTRL2_M1},
  3082. {0x011B, CMN_PLL1_SS_CTRL2_M0},
  3083. {0x006E, CMN_PLL0_SS_CTRL3_M0},
  3084. {0x0058, CMN_PLL0_SS_CTRL3_M1},
  3085. {0x006E, CMN_PLL1_SS_CTRL3_M0},
  3086. {0x000E, CMN_PLL0_SS_CTRL4_M0},
  3087. {0x0012, CMN_PLL0_SS_CTRL4_M1},
  3088. {0x000E, CMN_PLL1_SS_CTRL4_M0},
  3089. {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
  3090. {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
  3091. {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
  3092. {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
  3093. {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
  3094. {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
  3095. {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
  3096. {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
  3097. {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
  3098. {0x0005, CMN_PLL1_LOCK_PLLCNT_THR},
  3099. {0x007F, CMN_TXPUCAL_TUNE},
  3100. {0x007F, CMN_TXPDCAL_TUNE}
  3101. };
  3102. static struct cdns_torrent_vals qsgmii_100_int_ssc_cmn_vals = {
  3103. .reg_pairs = qsgmii_100_int_ssc_cmn_regs,
  3104. .num_regs = ARRAY_SIZE(qsgmii_100_int_ssc_cmn_regs),
  3105. };
  3106. /* Single SGMII/QSGMII link configuration */
  3107. static struct cdns_reg_pairs sl_sgmii_link_cmn_regs[] = {
  3108. {0x0000, PHY_PLL_CFG},
  3109. {0x0601, CMN_PDIAG_PLL0_CLK_SEL_M0}
  3110. };
  3111. static struct cdns_reg_pairs sl_sgmii_xcvr_diag_ln_regs[] = {
  3112. {0x0000, XCVR_DIAG_HSCLK_SEL},
  3113. {0x0003, XCVR_DIAG_HSCLK_DIV},
  3114. {0x0013, XCVR_DIAG_PLLDRC_CTRL}
  3115. };
  3116. static struct cdns_torrent_vals sl_sgmii_link_cmn_vals = {
  3117. .reg_pairs = sl_sgmii_link_cmn_regs,
  3118. .num_regs = ARRAY_SIZE(sl_sgmii_link_cmn_regs),
  3119. };
  3120. static struct cdns_torrent_vals sl_sgmii_xcvr_diag_ln_vals = {
  3121. .reg_pairs = sl_sgmii_xcvr_diag_ln_regs,
  3122. .num_regs = ARRAY_SIZE(sl_sgmii_xcvr_diag_ln_regs),
  3123. };
  3124. /* Multi link PCIe, 100 MHz Ref clk, internal SSC */
  3125. static struct cdns_reg_pairs pcie_100_int_ssc_cmn_regs[] = {
  3126. {0x0004, CMN_PLL0_DSM_DIAG_M0},
  3127. {0x0004, CMN_PLL0_DSM_DIAG_M1},
  3128. {0x0004, CMN_PLL1_DSM_DIAG_M0},
  3129. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
  3130. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
  3131. {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
  3132. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
  3133. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
  3134. {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
  3135. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
  3136. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
  3137. {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
  3138. {0x0064, CMN_PLL0_INTDIV_M0},
  3139. {0x0050, CMN_PLL0_INTDIV_M1},
  3140. {0x0064, CMN_PLL1_INTDIV_M0},
  3141. {0x0002, CMN_PLL0_FRACDIVH_M0},
  3142. {0x0002, CMN_PLL0_FRACDIVH_M1},
  3143. {0x0002, CMN_PLL1_FRACDIVH_M0},
  3144. {0x0044, CMN_PLL0_HIGH_THR_M0},
  3145. {0x0036, CMN_PLL0_HIGH_THR_M1},
  3146. {0x0044, CMN_PLL1_HIGH_THR_M0},
  3147. {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
  3148. {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
  3149. {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
  3150. {0x0001, CMN_PLL0_SS_CTRL1_M0},
  3151. {0x0001, CMN_PLL0_SS_CTRL1_M1},
  3152. {0x0001, CMN_PLL1_SS_CTRL1_M0},
  3153. {0x011B, CMN_PLL0_SS_CTRL2_M0},
  3154. {0x011B, CMN_PLL0_SS_CTRL2_M1},
  3155. {0x011B, CMN_PLL1_SS_CTRL2_M0},
  3156. {0x006E, CMN_PLL0_SS_CTRL3_M0},
  3157. {0x0058, CMN_PLL0_SS_CTRL3_M1},
  3158. {0x006E, CMN_PLL1_SS_CTRL3_M0},
  3159. {0x000E, CMN_PLL0_SS_CTRL4_M0},
  3160. {0x0012, CMN_PLL0_SS_CTRL4_M1},
  3161. {0x000E, CMN_PLL1_SS_CTRL4_M0},
  3162. {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
  3163. {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
  3164. {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
  3165. {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
  3166. {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
  3167. {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
  3168. {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
  3169. {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
  3170. {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
  3171. {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
  3172. };
  3173. static struct cdns_torrent_vals pcie_100_int_ssc_cmn_vals = {
  3174. .reg_pairs = pcie_100_int_ssc_cmn_regs,
  3175. .num_regs = ARRAY_SIZE(pcie_100_int_ssc_cmn_regs),
  3176. };
  3177. /* Single link PCIe, 100 MHz Ref clk, internal SSC */
  3178. static struct cdns_reg_pairs sl_pcie_100_int_ssc_cmn_regs[] = {
  3179. {0x0004, CMN_PLL0_DSM_DIAG_M0},
  3180. {0x0004, CMN_PLL0_DSM_DIAG_M1},
  3181. {0x0004, CMN_PLL1_DSM_DIAG_M0},
  3182. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M0},
  3183. {0x0509, CMN_PDIAG_PLL0_CP_PADJ_M1},
  3184. {0x0509, CMN_PDIAG_PLL1_CP_PADJ_M0},
  3185. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M0},
  3186. {0x0F00, CMN_PDIAG_PLL0_CP_IADJ_M1},
  3187. {0x0F00, CMN_PDIAG_PLL1_CP_IADJ_M0},
  3188. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M0},
  3189. {0x0F08, CMN_PDIAG_PLL0_FILT_PADJ_M1},
  3190. {0x0F08, CMN_PDIAG_PLL1_FILT_PADJ_M0},
  3191. {0x0064, CMN_PLL0_INTDIV_M0},
  3192. {0x0050, CMN_PLL0_INTDIV_M1},
  3193. {0x0050, CMN_PLL1_INTDIV_M0},
  3194. {0x0002, CMN_PLL0_FRACDIVH_M0},
  3195. {0x0002, CMN_PLL0_FRACDIVH_M1},
  3196. {0x0002, CMN_PLL1_FRACDIVH_M0},
  3197. {0x0044, CMN_PLL0_HIGH_THR_M0},
  3198. {0x0036, CMN_PLL0_HIGH_THR_M1},
  3199. {0x0036, CMN_PLL1_HIGH_THR_M0},
  3200. {0x0002, CMN_PDIAG_PLL0_CTRL_M0},
  3201. {0x0002, CMN_PDIAG_PLL0_CTRL_M1},
  3202. {0x0002, CMN_PDIAG_PLL1_CTRL_M0},
  3203. {0x0001, CMN_PLL0_SS_CTRL1_M0},
  3204. {0x0001, CMN_PLL0_SS_CTRL1_M1},
  3205. {0x0001, CMN_PLL1_SS_CTRL1_M0},
  3206. {0x011B, CMN_PLL0_SS_CTRL2_M0},
  3207. {0x011B, CMN_PLL0_SS_CTRL2_M1},
  3208. {0x011B, CMN_PLL1_SS_CTRL2_M0},
  3209. {0x006E, CMN_PLL0_SS_CTRL3_M0},
  3210. {0x0058, CMN_PLL0_SS_CTRL3_M1},
  3211. {0x0058, CMN_PLL1_SS_CTRL3_M0},
  3212. {0x000E, CMN_PLL0_SS_CTRL4_M0},
  3213. {0x0012, CMN_PLL0_SS_CTRL4_M1},
  3214. {0x0012, CMN_PLL1_SS_CTRL4_M0},
  3215. {0x0C5E, CMN_PLL0_VCOCAL_REFTIM_START},
  3216. {0x0C5E, CMN_PLL1_VCOCAL_REFTIM_START},
  3217. {0x0C56, CMN_PLL0_VCOCAL_PLLCNT_START},
  3218. {0x0C56, CMN_PLL1_VCOCAL_PLLCNT_START},
  3219. {0x00C7, CMN_PLL0_LOCK_REFCNT_START},
  3220. {0x00C7, CMN_PLL1_LOCK_REFCNT_START},
  3221. {0x00C7, CMN_PLL0_LOCK_PLLCNT_START},
  3222. {0x00C7, CMN_PLL1_LOCK_PLLCNT_START},
  3223. {0x0005, CMN_PLL0_LOCK_PLLCNT_THR},
  3224. {0x0005, CMN_PLL1_LOCK_PLLCNT_THR}
  3225. };
  3226. static struct cdns_torrent_vals sl_pcie_100_int_ssc_cmn_vals = {
  3227. .reg_pairs = sl_pcie_100_int_ssc_cmn_regs,
  3228. .num_regs = ARRAY_SIZE(sl_pcie_100_int_ssc_cmn_regs),
  3229. };
  3230. /* PCIe, 100 MHz Ref clk, no SSC & external SSC */
  3231. static struct cdns_reg_pairs pcie_100_ext_no_ssc_cmn_regs[] = {
  3232. {0x0028, CMN_PDIAG_PLL1_CP_PADJ_M0},
  3233. {0x001E, CMN_PLL1_DSM_FBH_OVRD_M0},
  3234. {0x000C, CMN_PLL1_DSM_FBL_OVRD_M0}
  3235. };
  3236. static struct cdns_reg_pairs pcie_100_ext_no_ssc_rx_ln_regs[] = {
  3237. {0x0019, RX_REE_TAP1_CLIP},
  3238. {0x0019, RX_REE_TAP2TON_CLIP},
  3239. {0x0001, RX_DIAG_ACYA}
  3240. };
  3241. static struct cdns_torrent_vals pcie_100_no_ssc_cmn_vals = {
  3242. .reg_pairs = pcie_100_ext_no_ssc_cmn_regs,
  3243. .num_regs = ARRAY_SIZE(pcie_100_ext_no_ssc_cmn_regs),
  3244. };
  3245. static struct cdns_torrent_vals pcie_100_no_ssc_rx_ln_vals = {
  3246. .reg_pairs = pcie_100_ext_no_ssc_rx_ln_regs,
  3247. .num_regs = ARRAY_SIZE(pcie_100_ext_no_ssc_rx_ln_regs),
  3248. };
  3249. static const struct cdns_torrent_data cdns_map_torrent = {
  3250. .block_offset_shift = 0x2,
  3251. .reg_offset_shift = 0x2,
  3252. .link_cmn_vals = {
  3253. [TYPE_DP] = {
  3254. [TYPE_NONE] = {
  3255. [NO_SSC] = &sl_dp_link_cmn_vals,
  3256. },
  3257. },
  3258. [TYPE_PCIE] = {
  3259. [TYPE_NONE] = {
  3260. [NO_SSC] = NULL,
  3261. [EXTERNAL_SSC] = NULL,
  3262. [INTERNAL_SSC] = NULL,
  3263. },
  3264. [TYPE_SGMII] = {
  3265. [NO_SSC] = &pcie_sgmii_link_cmn_vals,
  3266. [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3267. [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3268. },
  3269. [TYPE_QSGMII] = {
  3270. [NO_SSC] = &pcie_sgmii_link_cmn_vals,
  3271. [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3272. [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3273. },
  3274. [TYPE_USB] = {
  3275. [NO_SSC] = &pcie_usb_link_cmn_vals,
  3276. [EXTERNAL_SSC] = &pcie_usb_link_cmn_vals,
  3277. [INTERNAL_SSC] = &pcie_usb_link_cmn_vals,
  3278. },
  3279. },
  3280. [TYPE_SGMII] = {
  3281. [TYPE_NONE] = {
  3282. [NO_SSC] = &sl_sgmii_link_cmn_vals,
  3283. },
  3284. [TYPE_PCIE] = {
  3285. [NO_SSC] = &pcie_sgmii_link_cmn_vals,
  3286. [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3287. [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3288. },
  3289. [TYPE_USB] = {
  3290. [NO_SSC] = &usb_sgmii_link_cmn_vals,
  3291. [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3292. [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3293. },
  3294. },
  3295. [TYPE_QSGMII] = {
  3296. [TYPE_NONE] = {
  3297. [NO_SSC] = &sl_sgmii_link_cmn_vals,
  3298. },
  3299. [TYPE_PCIE] = {
  3300. [NO_SSC] = &pcie_sgmii_link_cmn_vals,
  3301. [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3302. [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3303. },
  3304. [TYPE_USB] = {
  3305. [NO_SSC] = &usb_sgmii_link_cmn_vals,
  3306. [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3307. [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3308. },
  3309. },
  3310. [TYPE_USB] = {
  3311. [TYPE_NONE] = {
  3312. [NO_SSC] = &sl_usb_link_cmn_vals,
  3313. [EXTERNAL_SSC] = &sl_usb_link_cmn_vals,
  3314. [INTERNAL_SSC] = &sl_usb_link_cmn_vals,
  3315. },
  3316. [TYPE_PCIE] = {
  3317. [NO_SSC] = &pcie_usb_link_cmn_vals,
  3318. [EXTERNAL_SSC] = &pcie_usb_link_cmn_vals,
  3319. [INTERNAL_SSC] = &pcie_usb_link_cmn_vals,
  3320. },
  3321. [TYPE_SGMII] = {
  3322. [NO_SSC] = &usb_sgmii_link_cmn_vals,
  3323. [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3324. [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3325. },
  3326. [TYPE_QSGMII] = {
  3327. [NO_SSC] = &usb_sgmii_link_cmn_vals,
  3328. [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3329. [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3330. },
  3331. },
  3332. },
  3333. .xcvr_diag_vals = {
  3334. [TYPE_DP] = {
  3335. [TYPE_NONE] = {
  3336. [NO_SSC] = &sl_dp_xcvr_diag_ln_vals,
  3337. },
  3338. },
  3339. [TYPE_PCIE] = {
  3340. [TYPE_NONE] = {
  3341. [NO_SSC] = NULL,
  3342. [EXTERNAL_SSC] = NULL,
  3343. [INTERNAL_SSC] = NULL,
  3344. },
  3345. [TYPE_SGMII] = {
  3346. [NO_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3347. [EXTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3348. [INTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3349. },
  3350. [TYPE_QSGMII] = {
  3351. [NO_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3352. [EXTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3353. [INTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3354. },
  3355. [TYPE_USB] = {
  3356. [NO_SSC] = &pcie_usb_xcvr_diag_ln_vals,
  3357. [EXTERNAL_SSC] = &pcie_usb_xcvr_diag_ln_vals,
  3358. [INTERNAL_SSC] = &pcie_usb_xcvr_diag_ln_vals,
  3359. },
  3360. },
  3361. [TYPE_SGMII] = {
  3362. [TYPE_NONE] = {
  3363. [NO_SSC] = &sl_sgmii_xcvr_diag_ln_vals,
  3364. },
  3365. [TYPE_PCIE] = {
  3366. [NO_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3367. [EXTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3368. [INTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3369. },
  3370. [TYPE_USB] = {
  3371. [NO_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3372. [EXTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3373. [INTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3374. },
  3375. },
  3376. [TYPE_QSGMII] = {
  3377. [TYPE_NONE] = {
  3378. [NO_SSC] = &sl_sgmii_xcvr_diag_ln_vals,
  3379. },
  3380. [TYPE_PCIE] = {
  3381. [NO_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3382. [EXTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3383. [INTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3384. },
  3385. [TYPE_USB] = {
  3386. [NO_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3387. [EXTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3388. [INTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3389. },
  3390. },
  3391. [TYPE_USB] = {
  3392. [TYPE_NONE] = {
  3393. [NO_SSC] = &sl_usb_xcvr_diag_ln_vals,
  3394. [EXTERNAL_SSC] = &sl_usb_xcvr_diag_ln_vals,
  3395. [INTERNAL_SSC] = &sl_usb_xcvr_diag_ln_vals,
  3396. },
  3397. [TYPE_PCIE] = {
  3398. [NO_SSC] = &usb_pcie_xcvr_diag_ln_vals,
  3399. [EXTERNAL_SSC] = &usb_pcie_xcvr_diag_ln_vals,
  3400. [INTERNAL_SSC] = &usb_pcie_xcvr_diag_ln_vals,
  3401. },
  3402. [TYPE_SGMII] = {
  3403. [NO_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3404. [EXTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3405. [INTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3406. },
  3407. [TYPE_QSGMII] = {
  3408. [NO_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3409. [EXTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3410. [INTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3411. },
  3412. },
  3413. },
  3414. .pcs_cmn_vals = {
  3415. [TYPE_USB] = {
  3416. [TYPE_NONE] = {
  3417. [NO_SSC] = &usb_phy_pcs_cmn_vals,
  3418. [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3419. [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3420. },
  3421. [TYPE_PCIE] = {
  3422. [NO_SSC] = &usb_phy_pcs_cmn_vals,
  3423. [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3424. [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3425. },
  3426. [TYPE_SGMII] = {
  3427. [NO_SSC] = &usb_phy_pcs_cmn_vals,
  3428. [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3429. [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3430. },
  3431. [TYPE_QSGMII] = {
  3432. [NO_SSC] = &usb_phy_pcs_cmn_vals,
  3433. [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3434. [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3435. },
  3436. },
  3437. },
  3438. .cmn_vals = {
  3439. [CLK_19_2_MHZ] = {
  3440. [TYPE_DP] = {
  3441. [TYPE_NONE] = {
  3442. [NO_SSC] = &sl_dp_19_2_no_ssc_cmn_vals,
  3443. },
  3444. },
  3445. },
  3446. [CLK_25_MHZ] = {
  3447. [TYPE_DP] = {
  3448. [TYPE_NONE] = {
  3449. [NO_SSC] = &sl_dp_25_no_ssc_cmn_vals,
  3450. },
  3451. },
  3452. },
  3453. [CLK_100_MHZ] = {
  3454. [TYPE_DP] = {
  3455. [TYPE_NONE] = {
  3456. [NO_SSC] = &sl_dp_100_no_ssc_cmn_vals,
  3457. },
  3458. },
  3459. [TYPE_PCIE] = {
  3460. [TYPE_NONE] = {
  3461. [NO_SSC] = NULL,
  3462. [EXTERNAL_SSC] = NULL,
  3463. [INTERNAL_SSC] = &sl_pcie_100_int_ssc_cmn_vals,
  3464. },
  3465. [TYPE_SGMII] = {
  3466. [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
  3467. [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
  3468. [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
  3469. },
  3470. [TYPE_QSGMII] = {
  3471. [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
  3472. [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
  3473. [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
  3474. },
  3475. [TYPE_USB] = {
  3476. [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
  3477. [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
  3478. [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
  3479. },
  3480. },
  3481. [TYPE_SGMII] = {
  3482. [TYPE_NONE] = {
  3483. [NO_SSC] = &sl_sgmii_100_no_ssc_cmn_vals,
  3484. },
  3485. [TYPE_PCIE] = {
  3486. [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3487. [EXTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3488. [INTERNAL_SSC] = &sgmii_100_int_ssc_cmn_vals,
  3489. },
  3490. [TYPE_USB] = {
  3491. [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3492. [EXTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3493. [INTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3494. },
  3495. },
  3496. [TYPE_QSGMII] = {
  3497. [TYPE_NONE] = {
  3498. [NO_SSC] = &sl_qsgmii_100_no_ssc_cmn_vals,
  3499. },
  3500. [TYPE_PCIE] = {
  3501. [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3502. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3503. [INTERNAL_SSC] = &qsgmii_100_int_ssc_cmn_vals,
  3504. },
  3505. [TYPE_USB] = {
  3506. [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3507. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3508. [INTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3509. },
  3510. },
  3511. [TYPE_USB] = {
  3512. [TYPE_NONE] = {
  3513. [NO_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  3514. [EXTERNAL_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  3515. [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
  3516. },
  3517. [TYPE_PCIE] = {
  3518. [NO_SSC] = &usb_100_no_ssc_cmn_vals,
  3519. [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
  3520. [INTERNAL_SSC] = &usb_100_int_ssc_cmn_vals,
  3521. },
  3522. [TYPE_SGMII] = {
  3523. [NO_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  3524. [EXTERNAL_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  3525. [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
  3526. },
  3527. [TYPE_QSGMII] = {
  3528. [NO_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  3529. [EXTERNAL_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  3530. [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
  3531. },
  3532. },
  3533. },
  3534. },
  3535. .tx_ln_vals = {
  3536. [CLK_19_2_MHZ] = {
  3537. [TYPE_DP] = {
  3538. [TYPE_NONE] = {
  3539. [NO_SSC] = &sl_dp_19_2_no_ssc_tx_ln_vals,
  3540. },
  3541. },
  3542. },
  3543. [CLK_25_MHZ] = {
  3544. [TYPE_DP] = {
  3545. [TYPE_NONE] = {
  3546. [NO_SSC] = &sl_dp_25_no_ssc_tx_ln_vals,
  3547. },
  3548. },
  3549. },
  3550. [CLK_100_MHZ] = {
  3551. [TYPE_DP] = {
  3552. [TYPE_NONE] = {
  3553. [NO_SSC] = &sl_dp_100_no_ssc_tx_ln_vals,
  3554. },
  3555. },
  3556. [TYPE_PCIE] = {
  3557. [TYPE_NONE] = {
  3558. [NO_SSC] = NULL,
  3559. [EXTERNAL_SSC] = NULL,
  3560. [INTERNAL_SSC] = NULL,
  3561. },
  3562. [TYPE_SGMII] = {
  3563. [NO_SSC] = NULL,
  3564. [EXTERNAL_SSC] = NULL,
  3565. [INTERNAL_SSC] = NULL,
  3566. },
  3567. [TYPE_QSGMII] = {
  3568. [NO_SSC] = NULL,
  3569. [EXTERNAL_SSC] = NULL,
  3570. [INTERNAL_SSC] = NULL,
  3571. },
  3572. [TYPE_USB] = {
  3573. [NO_SSC] = NULL,
  3574. [EXTERNAL_SSC] = NULL,
  3575. [INTERNAL_SSC] = NULL,
  3576. },
  3577. },
  3578. [TYPE_SGMII] = {
  3579. [TYPE_NONE] = {
  3580. [NO_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
  3581. },
  3582. [TYPE_PCIE] = {
  3583. [NO_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
  3584. [EXTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
  3585. [INTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
  3586. },
  3587. [TYPE_USB] = {
  3588. [NO_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
  3589. [EXTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
  3590. [INTERNAL_SSC] = &sgmii_100_no_ssc_tx_ln_vals,
  3591. },
  3592. },
  3593. [TYPE_QSGMII] = {
  3594. [TYPE_NONE] = {
  3595. [NO_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
  3596. },
  3597. [TYPE_PCIE] = {
  3598. [NO_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
  3599. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
  3600. [INTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
  3601. },
  3602. [TYPE_USB] = {
  3603. [NO_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
  3604. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
  3605. [INTERNAL_SSC] = &qsgmii_100_no_ssc_tx_ln_vals,
  3606. },
  3607. },
  3608. [TYPE_USB] = {
  3609. [TYPE_NONE] = {
  3610. [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3611. [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3612. [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3613. },
  3614. [TYPE_PCIE] = {
  3615. [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3616. [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3617. [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3618. },
  3619. [TYPE_SGMII] = {
  3620. [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3621. [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3622. [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3623. },
  3624. [TYPE_QSGMII] = {
  3625. [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3626. [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3627. [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  3628. },
  3629. },
  3630. },
  3631. },
  3632. .rx_ln_vals = {
  3633. [CLK_19_2_MHZ] = {
  3634. [TYPE_DP] = {
  3635. [TYPE_NONE] = {
  3636. [NO_SSC] = &sl_dp_19_2_no_ssc_rx_ln_vals,
  3637. },
  3638. },
  3639. },
  3640. [CLK_25_MHZ] = {
  3641. [TYPE_DP] = {
  3642. [TYPE_NONE] = {
  3643. [NO_SSC] = &sl_dp_25_no_ssc_rx_ln_vals,
  3644. },
  3645. },
  3646. },
  3647. [CLK_100_MHZ] = {
  3648. [TYPE_DP] = {
  3649. [TYPE_NONE] = {
  3650. [NO_SSC] = &sl_dp_100_no_ssc_rx_ln_vals,
  3651. },
  3652. },
  3653. [TYPE_PCIE] = {
  3654. [TYPE_NONE] = {
  3655. [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3656. [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3657. [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3658. },
  3659. [TYPE_SGMII] = {
  3660. [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3661. [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3662. [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3663. },
  3664. [TYPE_QSGMII] = {
  3665. [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3666. [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3667. [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3668. },
  3669. [TYPE_USB] = {
  3670. [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3671. [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3672. [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  3673. },
  3674. },
  3675. [TYPE_SGMII] = {
  3676. [TYPE_NONE] = {
  3677. [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  3678. },
  3679. [TYPE_PCIE] = {
  3680. [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  3681. [EXTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  3682. [INTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  3683. },
  3684. [TYPE_USB] = {
  3685. [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  3686. [EXTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  3687. [INTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  3688. },
  3689. },
  3690. [TYPE_QSGMII] = {
  3691. [TYPE_NONE] = {
  3692. [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  3693. },
  3694. [TYPE_PCIE] = {
  3695. [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  3696. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  3697. [INTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  3698. },
  3699. [TYPE_USB] = {
  3700. [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  3701. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  3702. [INTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  3703. },
  3704. },
  3705. [TYPE_USB] = {
  3706. [TYPE_NONE] = {
  3707. [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3708. [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3709. [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3710. },
  3711. [TYPE_PCIE] = {
  3712. [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3713. [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3714. [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3715. },
  3716. [TYPE_SGMII] = {
  3717. [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3718. [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3719. [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3720. },
  3721. [TYPE_QSGMII] = {
  3722. [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3723. [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3724. [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  3725. },
  3726. },
  3727. },
  3728. },
  3729. };
  3730. static const struct cdns_torrent_data ti_j721e_map_torrent = {
  3731. .block_offset_shift = 0x0,
  3732. .reg_offset_shift = 0x1,
  3733. .link_cmn_vals = {
  3734. [TYPE_DP] = {
  3735. [TYPE_NONE] = {
  3736. [NO_SSC] = &sl_dp_link_cmn_vals,
  3737. },
  3738. },
  3739. [TYPE_PCIE] = {
  3740. [TYPE_NONE] = {
  3741. [NO_SSC] = NULL,
  3742. [EXTERNAL_SSC] = NULL,
  3743. [INTERNAL_SSC] = NULL,
  3744. },
  3745. [TYPE_SGMII] = {
  3746. [NO_SSC] = &pcie_sgmii_link_cmn_vals,
  3747. [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3748. [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3749. },
  3750. [TYPE_QSGMII] = {
  3751. [NO_SSC] = &pcie_sgmii_link_cmn_vals,
  3752. [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3753. [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3754. },
  3755. [TYPE_USB] = {
  3756. [NO_SSC] = &pcie_usb_link_cmn_vals,
  3757. [EXTERNAL_SSC] = &pcie_usb_link_cmn_vals,
  3758. [INTERNAL_SSC] = &pcie_usb_link_cmn_vals,
  3759. },
  3760. },
  3761. [TYPE_SGMII] = {
  3762. [TYPE_NONE] = {
  3763. [NO_SSC] = &sl_sgmii_link_cmn_vals,
  3764. },
  3765. [TYPE_PCIE] = {
  3766. [NO_SSC] = &pcie_sgmii_link_cmn_vals,
  3767. [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3768. [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3769. },
  3770. [TYPE_USB] = {
  3771. [NO_SSC] = &usb_sgmii_link_cmn_vals,
  3772. [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3773. [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3774. },
  3775. },
  3776. [TYPE_QSGMII] = {
  3777. [TYPE_NONE] = {
  3778. [NO_SSC] = &sl_sgmii_link_cmn_vals,
  3779. },
  3780. [TYPE_PCIE] = {
  3781. [NO_SSC] = &pcie_sgmii_link_cmn_vals,
  3782. [EXTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3783. [INTERNAL_SSC] = &pcie_sgmii_link_cmn_vals,
  3784. },
  3785. [TYPE_USB] = {
  3786. [NO_SSC] = &usb_sgmii_link_cmn_vals,
  3787. [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3788. [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3789. },
  3790. },
  3791. [TYPE_USB] = {
  3792. [TYPE_NONE] = {
  3793. [NO_SSC] = &sl_usb_link_cmn_vals,
  3794. [EXTERNAL_SSC] = &sl_usb_link_cmn_vals,
  3795. [INTERNAL_SSC] = &sl_usb_link_cmn_vals,
  3796. },
  3797. [TYPE_PCIE] = {
  3798. [NO_SSC] = &pcie_usb_link_cmn_vals,
  3799. [EXTERNAL_SSC] = &pcie_usb_link_cmn_vals,
  3800. [INTERNAL_SSC] = &pcie_usb_link_cmn_vals,
  3801. },
  3802. [TYPE_SGMII] = {
  3803. [NO_SSC] = &usb_sgmii_link_cmn_vals,
  3804. [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3805. [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3806. },
  3807. [TYPE_QSGMII] = {
  3808. [NO_SSC] = &usb_sgmii_link_cmn_vals,
  3809. [EXTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3810. [INTERNAL_SSC] = &usb_sgmii_link_cmn_vals,
  3811. },
  3812. },
  3813. },
  3814. .xcvr_diag_vals = {
  3815. [TYPE_DP] = {
  3816. [TYPE_NONE] = {
  3817. [NO_SSC] = &sl_dp_xcvr_diag_ln_vals,
  3818. },
  3819. },
  3820. [TYPE_PCIE] = {
  3821. [TYPE_NONE] = {
  3822. [NO_SSC] = NULL,
  3823. [EXTERNAL_SSC] = NULL,
  3824. [INTERNAL_SSC] = NULL,
  3825. },
  3826. [TYPE_SGMII] = {
  3827. [NO_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3828. [EXTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3829. [INTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3830. },
  3831. [TYPE_QSGMII] = {
  3832. [NO_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3833. [EXTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3834. [INTERNAL_SSC] = &pcie_sgmii_xcvr_diag_ln_vals,
  3835. },
  3836. [TYPE_USB] = {
  3837. [NO_SSC] = &pcie_usb_xcvr_diag_ln_vals,
  3838. [EXTERNAL_SSC] = &pcie_usb_xcvr_diag_ln_vals,
  3839. [INTERNAL_SSC] = &pcie_usb_xcvr_diag_ln_vals,
  3840. },
  3841. },
  3842. [TYPE_SGMII] = {
  3843. [TYPE_NONE] = {
  3844. [NO_SSC] = &sl_sgmii_xcvr_diag_ln_vals,
  3845. },
  3846. [TYPE_PCIE] = {
  3847. [NO_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3848. [EXTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3849. [INTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3850. },
  3851. [TYPE_USB] = {
  3852. [NO_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3853. [EXTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3854. [INTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3855. },
  3856. },
  3857. [TYPE_QSGMII] = {
  3858. [TYPE_NONE] = {
  3859. [NO_SSC] = &sl_sgmii_xcvr_diag_ln_vals,
  3860. },
  3861. [TYPE_PCIE] = {
  3862. [NO_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3863. [EXTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3864. [INTERNAL_SSC] = &sgmii_pcie_xcvr_diag_ln_vals,
  3865. },
  3866. [TYPE_USB] = {
  3867. [NO_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3868. [EXTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3869. [INTERNAL_SSC] = &sgmii_usb_xcvr_diag_ln_vals,
  3870. },
  3871. },
  3872. [TYPE_USB] = {
  3873. [TYPE_NONE] = {
  3874. [NO_SSC] = &sl_usb_xcvr_diag_ln_vals,
  3875. [EXTERNAL_SSC] = &sl_usb_xcvr_diag_ln_vals,
  3876. [INTERNAL_SSC] = &sl_usb_xcvr_diag_ln_vals,
  3877. },
  3878. [TYPE_PCIE] = {
  3879. [NO_SSC] = &usb_pcie_xcvr_diag_ln_vals,
  3880. [EXTERNAL_SSC] = &usb_pcie_xcvr_diag_ln_vals,
  3881. [INTERNAL_SSC] = &usb_pcie_xcvr_diag_ln_vals,
  3882. },
  3883. [TYPE_SGMII] = {
  3884. [NO_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3885. [EXTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3886. [INTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3887. },
  3888. [TYPE_QSGMII] = {
  3889. [NO_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3890. [EXTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3891. [INTERNAL_SSC] = &usb_sgmii_xcvr_diag_ln_vals,
  3892. },
  3893. },
  3894. },
  3895. .pcs_cmn_vals = {
  3896. [TYPE_USB] = {
  3897. [TYPE_NONE] = {
  3898. [NO_SSC] = &usb_phy_pcs_cmn_vals,
  3899. [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3900. [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3901. },
  3902. [TYPE_PCIE] = {
  3903. [NO_SSC] = &usb_phy_pcs_cmn_vals,
  3904. [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3905. [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3906. },
  3907. [TYPE_SGMII] = {
  3908. [NO_SSC] = &usb_phy_pcs_cmn_vals,
  3909. [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3910. [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3911. },
  3912. [TYPE_QSGMII] = {
  3913. [NO_SSC] = &usb_phy_pcs_cmn_vals,
  3914. [EXTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3915. [INTERNAL_SSC] = &usb_phy_pcs_cmn_vals,
  3916. },
  3917. },
  3918. },
  3919. .cmn_vals = {
  3920. [CLK_19_2_MHZ] = {
  3921. [TYPE_DP] = {
  3922. [TYPE_NONE] = {
  3923. [NO_SSC] = &sl_dp_19_2_no_ssc_cmn_vals,
  3924. },
  3925. },
  3926. },
  3927. [CLK_25_MHZ] = {
  3928. [TYPE_DP] = {
  3929. [TYPE_NONE] = {
  3930. [NO_SSC] = &sl_dp_25_no_ssc_cmn_vals,
  3931. },
  3932. },
  3933. },
  3934. [CLK_100_MHZ] = {
  3935. [TYPE_DP] = {
  3936. [TYPE_NONE] = {
  3937. [NO_SSC] = &sl_dp_100_no_ssc_cmn_vals,
  3938. },
  3939. },
  3940. [TYPE_PCIE] = {
  3941. [TYPE_NONE] = {
  3942. [NO_SSC] = NULL,
  3943. [EXTERNAL_SSC] = NULL,
  3944. [INTERNAL_SSC] = &sl_pcie_100_int_ssc_cmn_vals,
  3945. },
  3946. [TYPE_SGMII] = {
  3947. [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
  3948. [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
  3949. [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
  3950. },
  3951. [TYPE_QSGMII] = {
  3952. [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
  3953. [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
  3954. [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
  3955. },
  3956. [TYPE_USB] = {
  3957. [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
  3958. [EXTERNAL_SSC] = &pcie_100_no_ssc_cmn_vals,
  3959. [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
  3960. },
  3961. },
  3962. [TYPE_SGMII] = {
  3963. [TYPE_NONE] = {
  3964. [NO_SSC] = &sl_sgmii_100_no_ssc_cmn_vals,
  3965. },
  3966. [TYPE_PCIE] = {
  3967. [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3968. [EXTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3969. [INTERNAL_SSC] = &sgmii_100_int_ssc_cmn_vals,
  3970. },
  3971. [TYPE_USB] = {
  3972. [NO_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3973. [EXTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3974. [INTERNAL_SSC] = &sgmii_100_no_ssc_cmn_vals,
  3975. },
  3976. },
  3977. [TYPE_QSGMII] = {
  3978. [TYPE_NONE] = {
  3979. [NO_SSC] = &sl_qsgmii_100_no_ssc_cmn_vals,
  3980. },
  3981. [TYPE_PCIE] = {
  3982. [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3983. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3984. [INTERNAL_SSC] = &qsgmii_100_int_ssc_cmn_vals,
  3985. },
  3986. [TYPE_USB] = {
  3987. [NO_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3988. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3989. [INTERNAL_SSC] = &qsgmii_100_no_ssc_cmn_vals,
  3990. },
  3991. },
  3992. [TYPE_USB] = {
  3993. [TYPE_NONE] = {
  3994. [NO_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  3995. [EXTERNAL_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  3996. [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
  3997. },
  3998. [TYPE_PCIE] = {
  3999. [NO_SSC] = &usb_100_no_ssc_cmn_vals,
  4000. [EXTERNAL_SSC] = &usb_100_no_ssc_cmn_vals,
  4001. [INTERNAL_SSC] = &usb_100_int_ssc_cmn_vals,
  4002. },
  4003. [TYPE_SGMII] = {
  4004. [NO_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  4005. [EXTERNAL_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  4006. [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
  4007. },
  4008. [TYPE_QSGMII] = {
  4009. [NO_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  4010. [EXTERNAL_SSC] = &sl_usb_100_no_ssc_cmn_vals,
  4011. [INTERNAL_SSC] = &sl_usb_100_int_ssc_cmn_vals,
  4012. },
  4013. },
  4014. },
  4015. },
  4016. .tx_ln_vals = {
  4017. [CLK_19_2_MHZ] = {
  4018. [TYPE_DP] = {
  4019. [TYPE_NONE] = {
  4020. [NO_SSC] = &sl_dp_19_2_no_ssc_tx_ln_vals,
  4021. },
  4022. },
  4023. },
  4024. [CLK_25_MHZ] = {
  4025. [TYPE_DP] = {
  4026. [TYPE_NONE] = {
  4027. [NO_SSC] = &sl_dp_25_no_ssc_tx_ln_vals,
  4028. },
  4029. },
  4030. },
  4031. [CLK_100_MHZ] = {
  4032. [TYPE_DP] = {
  4033. [TYPE_NONE] = {
  4034. [NO_SSC] = &sl_dp_100_no_ssc_tx_ln_vals,
  4035. },
  4036. },
  4037. [TYPE_PCIE] = {
  4038. [TYPE_NONE] = {
  4039. [NO_SSC] = NULL,
  4040. [EXTERNAL_SSC] = NULL,
  4041. [INTERNAL_SSC] = NULL,
  4042. },
  4043. [TYPE_SGMII] = {
  4044. [NO_SSC] = NULL,
  4045. [EXTERNAL_SSC] = NULL,
  4046. [INTERNAL_SSC] = NULL,
  4047. },
  4048. [TYPE_QSGMII] = {
  4049. [NO_SSC] = NULL,
  4050. [EXTERNAL_SSC] = NULL,
  4051. [INTERNAL_SSC] = NULL,
  4052. },
  4053. [TYPE_USB] = {
  4054. [NO_SSC] = NULL,
  4055. [EXTERNAL_SSC] = NULL,
  4056. [INTERNAL_SSC] = NULL,
  4057. },
  4058. },
  4059. [TYPE_SGMII] = {
  4060. [TYPE_NONE] = {
  4061. [NO_SSC] = &ti_sgmii_100_no_ssc_tx_ln_vals,
  4062. },
  4063. [TYPE_PCIE] = {
  4064. [NO_SSC] = &ti_sgmii_100_no_ssc_tx_ln_vals,
  4065. [EXTERNAL_SSC] = &ti_sgmii_100_no_ssc_tx_ln_vals,
  4066. [INTERNAL_SSC] = &ti_sgmii_100_no_ssc_tx_ln_vals,
  4067. },
  4068. [TYPE_USB] = {
  4069. [NO_SSC] = &ti_sgmii_100_no_ssc_tx_ln_vals,
  4070. [EXTERNAL_SSC] = &ti_sgmii_100_no_ssc_tx_ln_vals,
  4071. [INTERNAL_SSC] = &ti_sgmii_100_no_ssc_tx_ln_vals,
  4072. },
  4073. },
  4074. [TYPE_QSGMII] = {
  4075. [TYPE_NONE] = {
  4076. [NO_SSC] = &ti_qsgmii_100_no_ssc_tx_ln_vals,
  4077. },
  4078. [TYPE_PCIE] = {
  4079. [NO_SSC] = &ti_qsgmii_100_no_ssc_tx_ln_vals,
  4080. [EXTERNAL_SSC] = &ti_qsgmii_100_no_ssc_tx_ln_vals,
  4081. [INTERNAL_SSC] = &ti_qsgmii_100_no_ssc_tx_ln_vals,
  4082. },
  4083. [TYPE_USB] = {
  4084. [NO_SSC] = &ti_qsgmii_100_no_ssc_tx_ln_vals,
  4085. [EXTERNAL_SSC] = &ti_qsgmii_100_no_ssc_tx_ln_vals,
  4086. [INTERNAL_SSC] = &ti_qsgmii_100_no_ssc_tx_ln_vals,
  4087. },
  4088. },
  4089. [TYPE_USB] = {
  4090. [TYPE_NONE] = {
  4091. [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4092. [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4093. [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4094. },
  4095. [TYPE_PCIE] = {
  4096. [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4097. [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4098. [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4099. },
  4100. [TYPE_SGMII] = {
  4101. [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4102. [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4103. [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4104. },
  4105. [TYPE_QSGMII] = {
  4106. [NO_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4107. [EXTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4108. [INTERNAL_SSC] = &usb_100_no_ssc_tx_ln_vals,
  4109. },
  4110. },
  4111. },
  4112. },
  4113. .rx_ln_vals = {
  4114. [CLK_19_2_MHZ] = {
  4115. [TYPE_DP] = {
  4116. [TYPE_NONE] = {
  4117. [NO_SSC] = &sl_dp_19_2_no_ssc_rx_ln_vals,
  4118. },
  4119. },
  4120. },
  4121. [CLK_25_MHZ] = {
  4122. [TYPE_DP] = {
  4123. [TYPE_NONE] = {
  4124. [NO_SSC] = &sl_dp_25_no_ssc_rx_ln_vals,
  4125. },
  4126. },
  4127. },
  4128. [CLK_100_MHZ] = {
  4129. [TYPE_DP] = {
  4130. [TYPE_NONE] = {
  4131. [NO_SSC] = &sl_dp_100_no_ssc_rx_ln_vals,
  4132. },
  4133. },
  4134. [TYPE_PCIE] = {
  4135. [TYPE_NONE] = {
  4136. [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4137. [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4138. [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4139. },
  4140. [TYPE_SGMII] = {
  4141. [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4142. [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4143. [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4144. },
  4145. [TYPE_QSGMII] = {
  4146. [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4147. [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4148. [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4149. },
  4150. [TYPE_USB] = {
  4151. [NO_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4152. [EXTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4153. [INTERNAL_SSC] = &pcie_100_no_ssc_rx_ln_vals,
  4154. },
  4155. },
  4156. [TYPE_SGMII] = {
  4157. [TYPE_NONE] = {
  4158. [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  4159. },
  4160. [TYPE_PCIE] = {
  4161. [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  4162. [EXTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  4163. [INTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  4164. },
  4165. [TYPE_USB] = {
  4166. [NO_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  4167. [EXTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  4168. [INTERNAL_SSC] = &sgmii_100_no_ssc_rx_ln_vals,
  4169. },
  4170. },
  4171. [TYPE_QSGMII] = {
  4172. [TYPE_NONE] = {
  4173. [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  4174. },
  4175. [TYPE_PCIE] = {
  4176. [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  4177. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  4178. [INTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  4179. },
  4180. [TYPE_USB] = {
  4181. [NO_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  4182. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  4183. [INTERNAL_SSC] = &qsgmii_100_no_ssc_rx_ln_vals,
  4184. },
  4185. },
  4186. [TYPE_USB] = {
  4187. [TYPE_NONE] = {
  4188. [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4189. [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4190. [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4191. },
  4192. [TYPE_PCIE] = {
  4193. [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4194. [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4195. [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4196. },
  4197. [TYPE_SGMII] = {
  4198. [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4199. [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4200. [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4201. },
  4202. [TYPE_QSGMII] = {
  4203. [NO_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4204. [EXTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4205. [INTERNAL_SSC] = &usb_100_no_ssc_rx_ln_vals,
  4206. },
  4207. },
  4208. },
  4209. },
  4210. };
  4211. static const struct of_device_id cdns_torrent_phy_of_match[] = {
  4212. {
  4213. .compatible = "cdns,torrent-phy",
  4214. .data = &cdns_map_torrent,
  4215. },
  4216. {
  4217. .compatible = "ti,j721e-serdes-10g",
  4218. .data = &ti_j721e_map_torrent,
  4219. },
  4220. {}
  4221. };
  4222. MODULE_DEVICE_TABLE(of, cdns_torrent_phy_of_match);
  4223. static struct platform_driver cdns_torrent_phy_driver = {
  4224. .probe = cdns_torrent_phy_probe,
  4225. .remove = cdns_torrent_phy_remove,
  4226. .driver = {
  4227. .name = "cdns-torrent-phy",
  4228. .of_match_table = cdns_torrent_phy_of_match,
  4229. }
  4230. };
  4231. module_platform_driver(cdns_torrent_phy_driver);
  4232. MODULE_AUTHOR("Cadence Design Systems, Inc.");
  4233. MODULE_DESCRIPTION("Cadence Torrent PHY driver");
  4234. MODULE_LICENSE("GPL v2");