phy-qcom-qmp-combo.c 136 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2017, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/clk.h>
  6. #include <linux/clk-provider.h>
  7. #include <linux/delay.h>
  8. #include <linux/err.h>
  9. #include <linux/io.h>
  10. #include <linux/iopoll.h>
  11. #include <linux/kernel.h>
  12. #include <linux/module.h>
  13. #include <linux/of.h>
  14. #include <linux/of_address.h>
  15. #include <linux/phy/phy.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/regulator/consumer.h>
  18. #include <linux/reset.h>
  19. #include <linux/slab.h>
  20. #include <linux/usb/typec.h>
  21. #include <linux/usb/typec_mux.h>
  22. #include <drm/bridge/aux-bridge.h>
  23. #include <dt-bindings/phy/phy-qcom-qmp.h>
  24. #include "phy-qcom-qmp-common.h"
  25. #include "phy-qcom-qmp.h"
  26. #include "phy-qcom-qmp-pcs-misc-v3.h"
  27. #include "phy-qcom-qmp-pcs-usb-v4.h"
  28. #include "phy-qcom-qmp-pcs-usb-v5.h"
  29. #include "phy-qcom-qmp-pcs-usb-v6.h"
  30. #include "phy-qcom-qmp-dp-com-v3.h"
  31. #include "phy-qcom-qmp-dp-phy.h"
  32. #include "phy-qcom-qmp-dp-phy-v3.h"
  33. #include "phy-qcom-qmp-dp-phy-v4.h"
  34. #include "phy-qcom-qmp-dp-phy-v5.h"
  35. #include "phy-qcom-qmp-dp-phy-v6.h"
  36. /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */
  37. /* DP PHY soft reset */
  38. #define SW_DPPHY_RESET BIT(0)
  39. /* mux to select DP PHY reset control, 0:HW control, 1: software reset */
  40. #define SW_DPPHY_RESET_MUX BIT(1)
  41. /* USB3 PHY soft reset */
  42. #define SW_USB3PHY_RESET BIT(2)
  43. /* mux to select USB3 PHY reset control, 0:HW control, 1: software reset */
  44. #define SW_USB3PHY_RESET_MUX BIT(3)
  45. /* QPHY_V3_DP_COM_PHY_MODE_CTRL register bits */
  46. #define USB3_MODE BIT(0) /* enables USB3 mode */
  47. #define DP_MODE BIT(1) /* enables DP mode */
  48. /* QPHY_V3_DP_COM_TYPEC_CTRL register bits */
  49. #define SW_PORTSELECT_VAL BIT(0)
  50. #define SW_PORTSELECT_MUX BIT(1)
  51. #define PHY_INIT_COMPLETE_TIMEOUT 10000
  52. /* set of registers with offsets different per-PHY */
  53. enum qphy_reg_layout {
  54. /* PCS registers */
  55. QPHY_SW_RESET,
  56. QPHY_START_CTRL,
  57. QPHY_PCS_STATUS,
  58. QPHY_PCS_AUTONOMOUS_MODE_CTRL,
  59. QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR,
  60. QPHY_PCS_POWER_DOWN_CONTROL,
  61. QPHY_COM_RESETSM_CNTRL,
  62. QPHY_COM_C_READY_STATUS,
  63. QPHY_COM_CMN_STATUS,
  64. QPHY_COM_BIAS_EN_CLKBUFLR_EN,
  65. QPHY_DP_PHY_STATUS,
  66. QPHY_DP_PHY_VCO_DIV,
  67. QPHY_TX_TX_POL_INV,
  68. QPHY_TX_TX_DRV_LVL,
  69. QPHY_TX_TX_EMP_POST1_LVL,
  70. QPHY_TX_HIGHZ_DRVR_EN,
  71. QPHY_TX_TRANSCEIVER_BIAS_EN,
  72. /* Keep last to ensure regs_layout arrays are properly initialized */
  73. QPHY_LAYOUT_SIZE
  74. };
  75. static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
  76. [QPHY_SW_RESET] = QPHY_V3_PCS_SW_RESET,
  77. [QPHY_START_CTRL] = QPHY_V3_PCS_START_CONTROL,
  78. [QPHY_PCS_STATUS] = QPHY_V3_PCS_PCS_STATUS,
  79. [QPHY_PCS_POWER_DOWN_CONTROL] = QPHY_V3_PCS_POWER_DOWN_CONTROL,
  80. [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V3_PCS_AUTONOMOUS_MODE_CTRL,
  81. [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V3_PCS_LFPS_RXTERM_IRQ_CLEAR,
  82. [QPHY_COM_RESETSM_CNTRL] = QSERDES_V3_COM_RESETSM_CNTRL,
  83. [QPHY_COM_C_READY_STATUS] = QSERDES_V3_COM_C_READY_STATUS,
  84. [QPHY_COM_CMN_STATUS] = QSERDES_V3_COM_CMN_STATUS,
  85. [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN,
  86. [QPHY_DP_PHY_STATUS] = QSERDES_V3_DP_PHY_STATUS,
  87. [QPHY_DP_PHY_VCO_DIV] = QSERDES_V3_DP_PHY_VCO_DIV,
  88. [QPHY_TX_TX_POL_INV] = QSERDES_V3_TX_TX_POL_INV,
  89. [QPHY_TX_TX_DRV_LVL] = QSERDES_V3_TX_TX_DRV_LVL,
  90. [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V3_TX_TX_EMP_POST1_LVL,
  91. [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V3_TX_HIGHZ_DRVR_EN,
  92. [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V3_TX_TRANSCEIVER_BIAS_EN,
  93. };
  94. static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
  95. [QPHY_SW_RESET] = QPHY_V4_PCS_SW_RESET,
  96. [QPHY_START_CTRL] = QPHY_V4_PCS_START_CONTROL,
  97. [QPHY_PCS_STATUS] = QPHY_V4_PCS_PCS_STATUS1,
  98. [QPHY_PCS_POWER_DOWN_CONTROL] = QPHY_V4_PCS_POWER_DOWN_CONTROL,
  99. /* In PCS_USB */
  100. [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V4_PCS_USB3_AUTONOMOUS_MODE_CTRL,
  101. [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V4_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR,
  102. [QPHY_COM_RESETSM_CNTRL] = QSERDES_V4_COM_RESETSM_CNTRL,
  103. [QPHY_COM_C_READY_STATUS] = QSERDES_V4_COM_C_READY_STATUS,
  104. [QPHY_COM_CMN_STATUS] = QSERDES_V4_COM_CMN_STATUS,
  105. [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN,
  106. [QPHY_DP_PHY_STATUS] = QSERDES_V4_DP_PHY_STATUS,
  107. [QPHY_DP_PHY_VCO_DIV] = QSERDES_V4_DP_PHY_VCO_DIV,
  108. [QPHY_TX_TX_POL_INV] = QSERDES_V4_TX_TX_POL_INV,
  109. [QPHY_TX_TX_DRV_LVL] = QSERDES_V4_TX_TX_DRV_LVL,
  110. [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V4_TX_TX_EMP_POST1_LVL,
  111. [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V4_TX_HIGHZ_DRVR_EN,
  112. [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V4_TX_TRANSCEIVER_BIAS_EN,
  113. };
  114. static const unsigned int qmp_v5_5nm_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
  115. [QPHY_SW_RESET] = QPHY_V5_PCS_SW_RESET,
  116. [QPHY_START_CTRL] = QPHY_V5_PCS_START_CONTROL,
  117. [QPHY_PCS_STATUS] = QPHY_V5_PCS_PCS_STATUS1,
  118. [QPHY_PCS_POWER_DOWN_CONTROL] = QPHY_V5_PCS_POWER_DOWN_CONTROL,
  119. /* In PCS_USB */
  120. [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V5_PCS_USB3_AUTONOMOUS_MODE_CTRL,
  121. [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V5_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR,
  122. [QPHY_COM_RESETSM_CNTRL] = QSERDES_V5_COM_RESETSM_CNTRL,
  123. [QPHY_COM_C_READY_STATUS] = QSERDES_V5_COM_C_READY_STATUS,
  124. [QPHY_COM_CMN_STATUS] = QSERDES_V5_COM_CMN_STATUS,
  125. [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN,
  126. [QPHY_DP_PHY_STATUS] = QSERDES_V5_DP_PHY_STATUS,
  127. [QPHY_DP_PHY_VCO_DIV] = QSERDES_V5_DP_PHY_VCO_DIV,
  128. [QPHY_TX_TX_POL_INV] = QSERDES_V5_5NM_TX_TX_POL_INV,
  129. [QPHY_TX_TX_DRV_LVL] = QSERDES_V5_5NM_TX_TX_DRV_LVL,
  130. [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V5_5NM_TX_TX_EMP_POST1_LVL,
  131. [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V5_5NM_TX_HIGHZ_DRVR_EN,
  132. [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V5_5NM_TX_TRANSCEIVER_BIAS_EN,
  133. };
  134. static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
  135. [QPHY_SW_RESET] = QPHY_V6_PCS_SW_RESET,
  136. [QPHY_START_CTRL] = QPHY_V6_PCS_START_CONTROL,
  137. [QPHY_PCS_STATUS] = QPHY_V6_PCS_PCS_STATUS1,
  138. [QPHY_PCS_POWER_DOWN_CONTROL] = QPHY_V6_PCS_POWER_DOWN_CONTROL,
  139. /* In PCS_USB */
  140. [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V6_PCS_USB3_AUTONOMOUS_MODE_CTRL,
  141. [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V6_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR,
  142. [QPHY_COM_RESETSM_CNTRL] = QSERDES_V6_COM_RESETSM_CNTRL,
  143. [QPHY_COM_C_READY_STATUS] = QSERDES_V6_COM_C_READY_STATUS,
  144. [QPHY_COM_CMN_STATUS] = QSERDES_V6_COM_CMN_STATUS,
  145. [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V6_COM_PLL_BIAS_EN_CLK_BUFLR_EN,
  146. [QPHY_DP_PHY_STATUS] = QSERDES_V6_DP_PHY_STATUS,
  147. [QPHY_DP_PHY_VCO_DIV] = QSERDES_V6_DP_PHY_VCO_DIV,
  148. [QPHY_TX_TX_POL_INV] = QSERDES_V6_TX_TX_POL_INV,
  149. [QPHY_TX_TX_DRV_LVL] = QSERDES_V6_TX_TX_DRV_LVL,
  150. [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V6_TX_TX_EMP_POST1_LVL,
  151. [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V6_TX_HIGHZ_DRVR_EN,
  152. [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V6_TX_TRANSCEIVER_BIAS_EN,
  153. };
  154. static const unsigned int qmp_v6_n4_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
  155. [QPHY_SW_RESET] = QPHY_V6_N4_PCS_SW_RESET,
  156. [QPHY_START_CTRL] = QPHY_V6_N4_PCS_START_CONTROL,
  157. [QPHY_PCS_STATUS] = QPHY_V6_N4_PCS_PCS_STATUS1,
  158. [QPHY_PCS_POWER_DOWN_CONTROL] = QPHY_V6_N4_PCS_POWER_DOWN_CONTROL,
  159. /* In PCS_USB */
  160. [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V6_PCS_USB3_AUTONOMOUS_MODE_CTRL,
  161. [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V6_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR,
  162. [QPHY_COM_RESETSM_CNTRL] = QSERDES_V6_COM_RESETSM_CNTRL,
  163. [QPHY_COM_C_READY_STATUS] = QSERDES_V6_COM_C_READY_STATUS,
  164. [QPHY_COM_CMN_STATUS] = QSERDES_V6_COM_CMN_STATUS,
  165. [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V6_COM_PLL_BIAS_EN_CLK_BUFLR_EN,
  166. [QPHY_DP_PHY_STATUS] = QSERDES_V6_DP_PHY_STATUS,
  167. [QPHY_DP_PHY_VCO_DIV] = QSERDES_V6_DP_PHY_VCO_DIV,
  168. [QPHY_TX_TX_POL_INV] = QSERDES_V6_N4_TX_TX_POL_INV,
  169. [QPHY_TX_TX_DRV_LVL] = QSERDES_V6_N4_TX_TX_DRV_LVL,
  170. [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V6_N4_TX_TX_EMP_POST1_LVL,
  171. [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V6_N4_TX_HIGHZ_DRVR_EN,
  172. [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V6_N4_TX_TRANSCEIVER_BIAS_EN,
  173. };
  174. static const struct qmp_phy_init_tbl qmp_v3_usb3_serdes_tbl[] = {
  175. QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07),
  176. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x14),
  177. QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x08),
  178. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
  179. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
  180. QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL2, 0x08),
  181. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x16),
  182. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
  183. QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x80),
  184. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
  185. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0xab),
  186. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0xea),
  187. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x02),
  188. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
  189. QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
  190. QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
  191. QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
  192. QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
  193. QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
  194. QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
  195. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
  196. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
  197. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x34),
  198. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x15),
  199. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x04),
  200. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
  201. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_CFG, 0x00),
  202. QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
  203. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x0a),
  204. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
  205. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x31),
  206. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
  207. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x00),
  208. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
  209. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x85),
  210. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x07),
  211. };
  212. static const struct qmp_phy_init_tbl qmp_v3_usb3_tx_tbl[] = {
  213. QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
  214. QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
  215. QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x16),
  216. QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x09),
  217. QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x06),
  218. };
  219. static const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl[] = {
  220. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
  221. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x37),
  222. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
  223. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x0e),
  224. QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x06),
  225. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
  226. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x02),
  227. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x00),
  228. QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
  229. QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
  230. QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
  231. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
  232. QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x0a),
  233. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
  234. QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_CTRL, 0x00),
  235. QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x3f),
  236. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x1f),
  237. QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x07),
  238. QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x36),
  239. QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
  240. QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x06),
  241. };
  242. static const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl_rbr[] = {
  243. QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x0c),
  244. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x69),
  245. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x80),
  246. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x07),
  247. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x6f),
  248. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x08),
  249. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x00),
  250. };
  251. static const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl_hbr[] = {
  252. QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x04),
  253. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x69),
  254. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x80),
  255. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x07),
  256. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x0f),
  257. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0e),
  258. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x00),
  259. };
  260. static const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl_hbr2[] = {
  261. QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
  262. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x8c),
  263. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x00),
  264. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x0a),
  265. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x1f),
  266. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x1c),
  267. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x00),
  268. };
  269. static const struct qmp_phy_init_tbl qmp_v3_dp_serdes_tbl_hbr3[] = {
  270. QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x03),
  271. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x69),
  272. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x80),
  273. QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x07),
  274. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x2f),
  275. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x2a),
  276. QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x08),
  277. };
  278. static const struct qmp_phy_init_tbl qmp_v3_dp_tx_tbl[] = {
  279. QMP_PHY_INIT_CFG(QSERDES_V3_TX_TRANSCEIVER_BIAS_EN, 0x1a),
  280. QMP_PHY_INIT_CFG(QSERDES_V3_TX_VMODE_CTRL1, 0x40),
  281. QMP_PHY_INIT_CFG(QSERDES_V3_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
  282. QMP_PHY_INIT_CFG(QSERDES_V3_TX_INTERFACE_SELECT, 0x3d),
  283. QMP_PHY_INIT_CFG(QSERDES_V3_TX_CLKBUF_ENABLE, 0x0f),
  284. QMP_PHY_INIT_CFG(QSERDES_V3_TX_RESET_TSYNC_EN, 0x03),
  285. QMP_PHY_INIT_CFG(QSERDES_V3_TX_TRAN_DRVR_EMP_EN, 0x03),
  286. QMP_PHY_INIT_CFG(QSERDES_V3_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
  287. QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_INTERFACE_MODE, 0x00),
  288. QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_BAND, 0x4),
  289. QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_POL_INV, 0x0a),
  290. QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_DRV_LVL, 0x38),
  291. QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_EMP_POST1_LVL, 0x20),
  292. QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x06),
  293. QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x07),
  294. };
  295. static const struct qmp_phy_init_tbl qmp_v3_usb3_rx_tbl[] = {
  296. QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b),
  297. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
  298. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e),
  299. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18),
  300. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
  301. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
  302. QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
  303. QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x16),
  304. QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75),
  305. };
  306. static const struct qmp_phy_init_tbl qmp_v3_usb3_pcs_tbl[] = {
  307. /* FLL settings */
  308. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
  309. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
  310. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
  311. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40),
  312. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
  313. /* Lock Det settings */
  314. QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1),
  315. QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f),
  316. QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47),
  317. QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b),
  318. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xba),
  319. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f),
  320. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f),
  321. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7),
  322. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e),
  323. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65),
  324. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b),
  325. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15),
  326. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d),
  327. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V1, 0x15),
  328. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d),
  329. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15),
  330. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d),
  331. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15),
  332. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x1d),
  333. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15),
  334. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d),
  335. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15),
  336. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d),
  337. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02),
  338. QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
  339. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44),
  340. QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
  341. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
  342. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
  343. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40),
  344. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00),
  345. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75),
  346. QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86),
  347. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13),
  348. };
  349. static const struct qmp_phy_init_tbl sm6350_usb3_rx_tbl[] = {
  350. QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN, 0x0b),
  351. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
  352. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4e),
  353. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x18),
  354. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
  355. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
  356. QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
  357. QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x16),
  358. QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_MODE_00, 0x05),
  359. QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x75),
  360. };
  361. static const struct qmp_phy_init_tbl sm6350_usb3_pcs_tbl[] = {
  362. /* FLL settings */
  363. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL2, 0x83),
  364. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_L, 0x09),
  365. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNT_VAL_H_TOL, 0xa2),
  366. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_MAN_CODE, 0x40),
  367. QMP_PHY_INIT_CFG(QPHY_V3_PCS_FLL_CNTRL1, 0x02),
  368. /* Lock Det settings */
  369. QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG1, 0xd1),
  370. QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG2, 0x1f),
  371. QMP_PHY_INIT_CFG(QPHY_V3_PCS_LOCK_DETECT_CONFIG3, 0x47),
  372. QMP_PHY_INIT_CFG(QPHY_V3_PCS_POWER_STATE_CONFIG2, 0x1b),
  373. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0xcc),
  374. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V0, 0x9f),
  375. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V1, 0x9f),
  376. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V2, 0xb7),
  377. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V3, 0x4e),
  378. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_V4, 0x65),
  379. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXMGN_LS, 0x6b),
  380. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V0, 0x15),
  381. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0d),
  382. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V1, 0x15),
  383. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1, 0x0d),
  384. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V2, 0x15),
  385. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2, 0x0d),
  386. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V3, 0x15),
  387. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3, 0x1d),
  388. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_V4, 0x15),
  389. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4, 0x0d),
  390. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M6DB_LS, 0x15),
  391. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS, 0x0d),
  392. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RATE_SLEW_CNTRL, 0x02),
  393. QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
  394. QMP_PHY_INIT_CFG(QPHY_V3_PCS_TSYNC_RSYNC_TIME, 0x44),
  395. QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x04),
  396. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
  397. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
  398. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L, 0x40),
  399. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H, 0x00),
  400. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME, 0x75),
  401. QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK, 0x86),
  402. QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13),
  403. QMP_PHY_INIT_CFG(QPHY_V3_PCS_LFPS_DET_HIGH_COUNT_VAL, 0x04),
  404. QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG1, 0x21),
  405. QMP_PHY_INIT_CFG(QPHY_V3_PCS_REFGEN_REQ_CONFIG2, 0x60),
  406. };
  407. static const struct qmp_phy_init_tbl sm8150_usb3_serdes_tbl[] = {
  408. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_EN_CENTER, 0x01),
  409. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER1, 0x31),
  410. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_PER2, 0x01),
  411. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0, 0xde),
  412. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0, 0x07),
  413. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1, 0xde),
  414. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1, 0x07),
  415. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x0a),
  416. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_IPTRIM, 0x20),
  417. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
  418. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06),
  419. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
  420. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16),
  421. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
  422. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36),
  423. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x1a),
  424. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04),
  425. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x14),
  426. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x34),
  427. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE1, 0x34),
  428. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE1, 0x82),
  429. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x82),
  430. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE1, 0x82),
  431. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0xab),
  432. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0xea),
  433. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x02),
  434. QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
  435. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE1, 0xab),
  436. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE1, 0xea),
  437. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE1, 0x02),
  438. QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE0, 0x24),
  439. QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE1_MODE1, 0x24),
  440. QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE2_MODE1, 0x02),
  441. QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
  442. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE1, 0x08),
  443. QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca),
  444. QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e),
  445. QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xca),
  446. QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1e),
  447. QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL, 0x11),
  448. };
  449. static const struct qmp_phy_init_tbl sm8150_usb3_tx_tbl[] = {
  450. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_TX, 0x00),
  451. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_RX, 0x00),
  452. QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0xd5),
  453. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
  454. QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x20),
  455. };
  456. static const struct qmp_phy_init_tbl sm8150_usb3_rx_tbl[] = {
  457. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x05),
  458. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f),
  459. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
  460. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff),
  461. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f),
  462. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x99),
  463. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH1, 0x04),
  464. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH2, 0x08),
  465. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN1, 0x05),
  466. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN2, 0x05),
  467. QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54),
  468. QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x0e),
  469. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
  470. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
  471. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a),
  472. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
  473. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
  474. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
  475. QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x04),
  476. QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
  477. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0xbf),
  478. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xbf),
  479. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x3f),
  480. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f),
  481. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x94),
  482. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xdc),
  483. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xdc),
  484. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0x5c),
  485. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x0b),
  486. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb3),
  487. QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
  488. QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
  489. QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0),
  490. QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
  491. QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1f),
  492. QMP_PHY_INIT_CFG(QSERDES_V4_RX_VTH_CODE, 0x10),
  493. };
  494. static const struct qmp_phy_init_tbl sm8150_usb3_pcs_tbl[] = {
  495. /* Lock Det settings */
  496. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG1, 0xd0),
  497. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG2, 0x07),
  498. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG6, 0x13),
  499. QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
  500. QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
  501. QMP_PHY_INIT_CFG(QPHY_V4_PCS_CDR_RESET_TIME, 0x0a),
  502. QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG1, 0x88),
  503. QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG2, 0x13),
  504. QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCS_TX_RX_CONFIG, 0x0c),
  505. QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG1, 0x4b),
  506. QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x10),
  507. };
  508. static const struct qmp_phy_init_tbl sm8150_usb3_pcs_usb_tbl[] = {
  509. QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
  510. QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07),
  511. };
  512. static const struct qmp_phy_init_tbl sm8250_usb3_tx_tbl[] = {
  513. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_TX, 0x60),
  514. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_RX, 0x60),
  515. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
  516. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX, 0x02),
  517. QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0xd5),
  518. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
  519. QMP_PHY_INIT_CFG_LANE(QSERDES_V4_TX_PI_QEC_CTRL, 0x40, 1),
  520. QMP_PHY_INIT_CFG_LANE(QSERDES_V4_TX_PI_QEC_CTRL, 0x54, 2),
  521. };
  522. static const struct qmp_phy_init_tbl sm8250_usb3_rx_tbl[] = {
  523. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x06),
  524. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f),
  525. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
  526. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff),
  527. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f),
  528. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x99),
  529. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH1, 0x04),
  530. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH2, 0x08),
  531. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN1, 0x05),
  532. QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN2, 0x05),
  533. QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54),
  534. QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x0c),
  535. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
  536. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
  537. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a),
  538. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
  539. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
  540. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x77),
  541. QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x04),
  542. QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
  543. QMP_PHY_INIT_CFG_LANE(QSERDES_V4_RX_RX_MODE_00_LOW, 0xff, 1),
  544. QMP_PHY_INIT_CFG_LANE(QSERDES_V4_RX_RX_MODE_00_LOW, 0x7f, 2),
  545. QMP_PHY_INIT_CFG_LANE(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x7f, 1),
  546. QMP_PHY_INIT_CFG_LANE(QSERDES_V4_RX_RX_MODE_00_HIGH, 0xff, 2),
  547. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0x7f),
  548. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f),
  549. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x97),
  550. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xdc),
  551. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xdc),
  552. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0x5c),
  553. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x7b),
  554. QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb4),
  555. QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
  556. QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
  557. QMP_PHY_INIT_CFG(QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE, 0xa0),
  558. QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
  559. QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1f),
  560. QMP_PHY_INIT_CFG(QSERDES_V4_RX_VTH_CODE, 0x10),
  561. };
  562. static const struct qmp_phy_init_tbl sm8250_usb3_pcs_tbl[] = {
  563. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG1, 0xd0),
  564. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG2, 0x07),
  565. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG3, 0x20),
  566. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG6, 0x13),
  567. QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
  568. QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xa9),
  569. QMP_PHY_INIT_CFG(QPHY_V4_PCS_CDR_RESET_TIME, 0x0a),
  570. QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG1, 0x88),
  571. QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG2, 0x13),
  572. QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCS_TX_RX_CONFIG, 0x0c),
  573. QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG1, 0x4b),
  574. QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x10),
  575. };
  576. static const struct qmp_phy_init_tbl sm8250_usb3_pcs_usb_tbl[] = {
  577. QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
  578. QMP_PHY_INIT_CFG(QPHY_V4_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07),
  579. };
  580. static const struct qmp_phy_init_tbl sm8350_usb3_tx_tbl[] = {
  581. QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_TX, 0x00),
  582. QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_RX, 0x00),
  583. QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX, 0x16),
  584. QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX, 0x0e),
  585. QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_1, 0x35),
  586. QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_3, 0x3f),
  587. QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_4, 0x7f),
  588. QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_5, 0x3f),
  589. QMP_PHY_INIT_CFG(QSERDES_V5_TX_RCV_DETECT_LVL_2, 0x12),
  590. QMP_PHY_INIT_CFG(QSERDES_V5_TX_PI_QEC_CTRL, 0x21),
  591. };
  592. static const struct qmp_phy_init_tbl sm8350_usb3_rx_tbl[] = {
  593. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FO_GAIN, 0x0a),
  594. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SO_GAIN, 0x05),
  595. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f),
  596. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
  597. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff),
  598. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f),
  599. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_PI_CONTROLS, 0x99),
  600. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH1, 0x08),
  601. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH2, 0x08),
  602. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_GAIN1, 0x00),
  603. QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_GAIN2, 0x04),
  604. QMP_PHY_INIT_CFG(QSERDES_V5_RX_VGA_CAL_CNTRL1, 0x54),
  605. QMP_PHY_INIT_CFG(QSERDES_V5_RX_VGA_CAL_CNTRL2, 0x0f),
  606. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
  607. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
  608. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a),
  609. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
  610. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
  611. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x47),
  612. QMP_PHY_INIT_CFG(QSERDES_V5_RX_SIGDET_CNTRL, 0x04),
  613. QMP_PHY_INIT_CFG(QSERDES_V5_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
  614. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_LOW, 0xbb),
  615. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH, 0x7b),
  616. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH2, 0xbb),
  617. QMP_PHY_INIT_CFG_LANE(QSERDES_V5_RX_RX_MODE_00_HIGH3, 0x3d, 1),
  618. QMP_PHY_INIT_CFG_LANE(QSERDES_V5_RX_RX_MODE_00_HIGH3, 0x3c, 2),
  619. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH4, 0xdb),
  620. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_LOW, 0x64),
  621. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH, 0x24),
  622. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH2, 0xd2),
  623. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH3, 0x13),
  624. QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH4, 0xa9),
  625. QMP_PHY_INIT_CFG(QSERDES_V5_RX_DFE_EN_TIMER, 0x04),
  626. QMP_PHY_INIT_CFG(QSERDES_V5_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
  627. QMP_PHY_INIT_CFG(QSERDES_V5_RX_AUX_DATA_TCOARSE_TFINE, 0xa0),
  628. QMP_PHY_INIT_CFG(QSERDES_V5_RX_DCC_CTRL1, 0x0c),
  629. QMP_PHY_INIT_CFG(QSERDES_V5_RX_GM_CAL, 0x00),
  630. QMP_PHY_INIT_CFG(QSERDES_V5_RX_VTH_CODE, 0x10),
  631. };
  632. static const struct qmp_phy_init_tbl sm8350_usb3_pcs_tbl[] = {
  633. QMP_PHY_INIT_CFG(QPHY_V4_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
  634. QMP_PHY_INIT_CFG(QPHY_V4_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
  635. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG1, 0xd0),
  636. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG2, 0x07),
  637. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG3, 0x20),
  638. QMP_PHY_INIT_CFG(QPHY_V4_PCS_LOCK_DETECT_CONFIG6, 0x13),
  639. QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
  640. QMP_PHY_INIT_CFG(QPHY_V4_PCS_RX_SIGDET_LVL, 0xaa),
  641. QMP_PHY_INIT_CFG(QPHY_V4_PCS_CDR_RESET_TIME, 0x0a),
  642. QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG1, 0x88),
  643. QMP_PHY_INIT_CFG(QPHY_V4_PCS_ALIGN_DETECT_CONFIG2, 0x13),
  644. QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCS_TX_RX_CONFIG, 0x0c),
  645. QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG1, 0x4b),
  646. QMP_PHY_INIT_CFG(QPHY_V4_PCS_EQ_CONFIG5, 0x10),
  647. };
  648. static const struct qmp_phy_init_tbl sm8350_usb3_pcs_usb_tbl[] = {
  649. QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_RCVR_DTCT_DLY_U3_L, 0x40),
  650. QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_RCVR_DTCT_DLY_U3_H, 0x00),
  651. QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
  652. QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07),
  653. };
  654. static const struct qmp_phy_init_tbl sm8550_usb3_serdes_tbl[] = {
  655. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE1_MODE1, 0xc0),
  656. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE2_MODE1, 0x01),
  657. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CP_CTRL_MODE1, 0x02),
  658. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_RCTRL_MODE1, 0x16),
  659. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_CCTRL_MODE1, 0x36),
  660. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CORECLK_DIV_MODE1, 0x04),
  661. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE1, 0x16),
  662. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE1, 0x41),
  663. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE1, 0x41),
  664. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MSB_MODE1, 0x00),
  665. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START1_MODE1, 0x55),
  666. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START2_MODE1, 0x75),
  667. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE1, 0x01),
  668. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x01),
  669. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE1_MODE1, 0x25),
  670. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE2_MODE1, 0x02),
  671. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0x5c),
  672. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x0f),
  673. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x5c),
  674. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x0f),
  675. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE1_MODE0, 0xc0),
  676. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE2_MODE0, 0x01),
  677. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CP_CTRL_MODE0, 0x02),
  678. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_RCTRL_MODE0, 0x16),
  679. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_CCTRL_MODE0, 0x36),
  680. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x08),
  681. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x1a),
  682. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x41),
  683. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MSB_MODE0, 0x00),
  684. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START1_MODE0, 0x55),
  685. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START2_MODE0, 0x75),
  686. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x01),
  687. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE1_MODE0, 0x25),
  688. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE2_MODE0, 0x02),
  689. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BG_TIMER, 0x0a),
  690. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_EN_CENTER, 0x01),
  691. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER1, 0x62),
  692. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER2, 0x02),
  693. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYSCLK_BUF_ENABLE, 0x0c),
  694. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYSCLK_EN_SEL, 0x1a),
  695. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_CFG, 0x14),
  696. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE_MAP, 0x04),
  697. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CORE_CLK_EN, 0x20),
  698. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CMN_CONFIG_1, 0x16),
  699. QMP_PHY_INIT_CFG(QSERDES_V6_COM_AUTO_GAIN_ADJ_CTRL_1, 0xb6),
  700. QMP_PHY_INIT_CFG(QSERDES_V6_COM_AUTO_GAIN_ADJ_CTRL_2, 0x4b),
  701. QMP_PHY_INIT_CFG(QSERDES_V6_COM_AUTO_GAIN_ADJ_CTRL_3, 0x37),
  702. QMP_PHY_INIT_CFG(QSERDES_V6_COM_ADDITIONAL_MISC, 0x0c),
  703. };
  704. static const struct qmp_phy_init_tbl sm8550_usb3_tx_tbl[] = {
  705. QMP_PHY_INIT_CFG(QSERDES_V6_TX_RES_CODE_LANE_TX, 0x00),
  706. QMP_PHY_INIT_CFG(QSERDES_V6_TX_RES_CODE_LANE_RX, 0x00),
  707. QMP_PHY_INIT_CFG(QSERDES_V6_TX_RES_CODE_LANE_OFFSET_TX, 0x1f),
  708. QMP_PHY_INIT_CFG(QSERDES_V6_TX_RES_CODE_LANE_OFFSET_RX, 0x09),
  709. QMP_PHY_INIT_CFG(QSERDES_V6_TX_LANE_MODE_1, 0xf5),
  710. QMP_PHY_INIT_CFG(QSERDES_V6_TX_LANE_MODE_3, 0x3f),
  711. QMP_PHY_INIT_CFG(QSERDES_V6_TX_LANE_MODE_4, 0x3f),
  712. QMP_PHY_INIT_CFG(QSERDES_V6_TX_LANE_MODE_5, 0x5f),
  713. QMP_PHY_INIT_CFG(QSERDES_V6_TX_RCV_DETECT_LVL_2, 0x12),
  714. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_TX_PI_QEC_CTRL, 0x21, 1),
  715. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_TX_PI_QEC_CTRL, 0x05, 2),
  716. };
  717. static const struct qmp_phy_init_tbl sm8550_usb3_rx_tbl[] = {
  718. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_FO_GAIN, 0x0a),
  719. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_SO_GAIN, 0x06),
  720. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f),
  721. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
  722. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff),
  723. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f),
  724. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_PI_CONTROLS, 0x99),
  725. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_SB2_THRESH1, 0x08),
  726. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_SB2_THRESH2, 0x08),
  727. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_SB2_GAIN1, 0x00),
  728. QMP_PHY_INIT_CFG(QSERDES_V6_RX_UCDR_SB2_GAIN2, 0x0a),
  729. QMP_PHY_INIT_CFG(QSERDES_V6_RX_AUX_DATA_TCOARSE_TFINE, 0xa0),
  730. QMP_PHY_INIT_CFG(QSERDES_V6_RX_VGA_CAL_CNTRL1, 0x54),
  731. QMP_PHY_INIT_CFG(QSERDES_V6_RX_VGA_CAL_CNTRL2, 0x0f),
  732. QMP_PHY_INIT_CFG(QSERDES_V6_RX_GM_CAL, 0x13),
  733. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
  734. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
  735. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a),
  736. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_IDAC_TSETTLE_LOW, 0x07),
  737. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
  738. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x47),
  739. QMP_PHY_INIT_CFG(QSERDES_V6_RX_SIGDET_CNTRL, 0x04),
  740. QMP_PHY_INIT_CFG(QSERDES_V6_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
  741. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_MODE_01_LOW, 0xdc),
  742. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_MODE_01_HIGH, 0x5c),
  743. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_MODE_01_HIGH2, 0x9c),
  744. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_MODE_01_HIGH3, 0x1d),
  745. QMP_PHY_INIT_CFG(QSERDES_V6_RX_RX_MODE_01_HIGH4, 0x09),
  746. QMP_PHY_INIT_CFG(QSERDES_V6_RX_DFE_EN_TIMER, 0x04),
  747. QMP_PHY_INIT_CFG(QSERDES_V6_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
  748. QMP_PHY_INIT_CFG(QSERDES_V6_RX_DCC_CTRL1, 0x0c),
  749. QMP_PHY_INIT_CFG(QSERDES_V6_RX_VTH_CODE, 0x10),
  750. QMP_PHY_INIT_CFG(QSERDES_V6_RX_SIGDET_CAL_CTRL1, 0x14),
  751. QMP_PHY_INIT_CFG(QSERDES_V6_RX_SIGDET_CAL_TRIM, 0x08),
  752. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_LOW, 0x3f, 1),
  753. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_HIGH, 0xbf, 1),
  754. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_HIGH2, 0xff, 1),
  755. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_HIGH3, 0xdf, 1),
  756. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_HIGH4, 0xed, 1),
  757. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_LOW, 0xbf, 2),
  758. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_HIGH, 0xbf, 2),
  759. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_HIGH2, 0xbf, 2),
  760. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_HIGH3, 0xdf, 2),
  761. QMP_PHY_INIT_CFG_LANE(QSERDES_V6_RX_RX_MODE_00_HIGH4, 0xfd, 2),
  762. };
  763. static const struct qmp_phy_init_tbl sm8550_usb3_pcs_tbl[] = {
  764. QMP_PHY_INIT_CFG(QPHY_V6_PCS_LOCK_DETECT_CONFIG1, 0xc4),
  765. QMP_PHY_INIT_CFG(QPHY_V6_PCS_LOCK_DETECT_CONFIG2, 0x89),
  766. QMP_PHY_INIT_CFG(QPHY_V6_PCS_LOCK_DETECT_CONFIG3, 0x20),
  767. QMP_PHY_INIT_CFG(QPHY_V6_PCS_LOCK_DETECT_CONFIG6, 0x13),
  768. QMP_PHY_INIT_CFG(QPHY_V6_PCS_REFGEN_REQ_CONFIG1, 0x21),
  769. QMP_PHY_INIT_CFG(QPHY_V6_PCS_RX_SIGDET_LVL, 0x99),
  770. QMP_PHY_INIT_CFG(QPHY_V6_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
  771. QMP_PHY_INIT_CFG(QPHY_V6_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
  772. QMP_PHY_INIT_CFG(QPHY_V6_PCS_CDR_RESET_TIME, 0x0a),
  773. QMP_PHY_INIT_CFG(QPHY_V6_PCS_ALIGN_DETECT_CONFIG1, 0x88),
  774. QMP_PHY_INIT_CFG(QPHY_V6_PCS_ALIGN_DETECT_CONFIG2, 0x13),
  775. QMP_PHY_INIT_CFG(QPHY_V6_PCS_PCS_TX_RX_CONFIG, 0x0c),
  776. QMP_PHY_INIT_CFG(QPHY_V6_PCS_EQ_CONFIG1, 0x4b),
  777. QMP_PHY_INIT_CFG(QPHY_V6_PCS_EQ_CONFIG5, 0x10),
  778. };
  779. static const struct qmp_phy_init_tbl sm8550_usb3_pcs_usb_tbl[] = {
  780. QMP_PHY_INIT_CFG(QPHY_V6_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
  781. QMP_PHY_INIT_CFG(QPHY_V6_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07),
  782. QMP_PHY_INIT_CFG(QPHY_V6_PCS_USB3_RCVR_DTCT_DLY_U3_L, 0x40),
  783. QMP_PHY_INIT_CFG(QPHY_V6_PCS_USB3_RCVR_DTCT_DLY_U3_H, 0x00),
  784. QMP_PHY_INIT_CFG(QPHY_V6_PCS_USB3_POWER_STATE_CONFIG1, 0x68),
  785. };
  786. static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl[] = {
  787. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SVS_MODE_CLK_SEL, 0x05),
  788. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x3b),
  789. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x02),
  790. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x0c),
  791. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x06),
  792. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x30),
  793. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
  794. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
  795. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
  796. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
  797. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x02),
  798. QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
  799. QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
  800. QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x00),
  801. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x00),
  802. QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x0a),
  803. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x0a),
  804. QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_CTRL, 0x00),
  805. QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x17),
  806. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORE_CLK_EN, 0x1f),
  807. };
  808. static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_rbr[] = {
  809. QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x05),
  810. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
  811. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
  812. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
  813. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x6f),
  814. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x08),
  815. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04),
  816. };
  817. static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr[] = {
  818. QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x03),
  819. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
  820. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
  821. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
  822. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0f),
  823. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x0e),
  824. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
  825. };
  826. static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr2[] = {
  827. QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
  828. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x8c),
  829. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x00),
  830. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x0a),
  831. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x1f),
  832. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1c),
  833. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
  834. };
  835. static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr3[] = {
  836. QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x00),
  837. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
  838. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
  839. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
  840. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x2f),
  841. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x2a),
  842. QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
  843. };
  844. static const struct qmp_phy_init_tbl qmp_v4_dp_tx_tbl[] = {
  845. QMP_PHY_INIT_CFG(QSERDES_V4_TX_VMODE_CTRL1, 0x40),
  846. QMP_PHY_INIT_CFG(QSERDES_V4_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
  847. QMP_PHY_INIT_CFG(QSERDES_V4_TX_INTERFACE_SELECT, 0x3b),
  848. QMP_PHY_INIT_CFG(QSERDES_V4_TX_CLKBUF_ENABLE, 0x0f),
  849. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RESET_TSYNC_EN, 0x03),
  850. QMP_PHY_INIT_CFG(QSERDES_V4_TX_TRAN_DRVR_EMP_EN, 0x0f),
  851. QMP_PHY_INIT_CFG(QSERDES_V4_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
  852. QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_INTERFACE_MODE, 0x00),
  853. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
  854. QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX, 0x11),
  855. QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_BAND, 0x4),
  856. QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_POL_INV, 0x0a),
  857. QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_DRV_LVL, 0x2a),
  858. QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_EMP_POST1_LVL, 0x20),
  859. };
  860. static const struct qmp_phy_init_tbl qmp_v5_dp_serdes_tbl[] = {
  861. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SVS_MODE_CLK_SEL, 0x05),
  862. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x3b),
  863. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x02),
  864. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x0c),
  865. QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x06),
  866. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x30),
  867. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
  868. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
  869. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36),
  870. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
  871. QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16),
  872. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
  873. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06),
  874. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x02),
  875. QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
  876. QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
  877. QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02),
  878. QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x00),
  879. QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x0a),
  880. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x0a),
  881. QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_CTRL, 0x00),
  882. QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x17),
  883. QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORE_CLK_EN, 0x1f),
  884. };
  885. static const struct qmp_phy_init_tbl qmp_v5_dp_tx_tbl[] = {
  886. QMP_PHY_INIT_CFG(QSERDES_V5_TX_VMODE_CTRL1, 0x40),
  887. QMP_PHY_INIT_CFG(QSERDES_V5_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
  888. QMP_PHY_INIT_CFG(QSERDES_V5_TX_INTERFACE_SELECT, 0x3b),
  889. QMP_PHY_INIT_CFG(QSERDES_V5_TX_CLKBUF_ENABLE, 0x0f),
  890. QMP_PHY_INIT_CFG(QSERDES_V5_TX_RESET_TSYNC_EN, 0x03),
  891. QMP_PHY_INIT_CFG(QSERDES_V5_TX_TRAN_DRVR_EMP_EN, 0x0f),
  892. QMP_PHY_INIT_CFG(QSERDES_V5_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
  893. QMP_PHY_INIT_CFG(QSERDES_V5_TX_TX_INTERFACE_MODE, 0x00),
  894. QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
  895. QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX, 0x11),
  896. QMP_PHY_INIT_CFG(QSERDES_V5_TX_TX_BAND, 0x04),
  897. };
  898. static const struct qmp_phy_init_tbl qmp_v5_5nm_dp_tx_tbl[] = {
  899. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_LANE_MODE_3, 0x51),
  900. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_TRANSCEIVER_BIAS_EN, 0x1a),
  901. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_VMODE_CTRL1, 0x40),
  902. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_PRE_STALL_LDO_BOOST_EN, 0x0),
  903. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_INTERFACE_SELECT, 0xff),
  904. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_CLKBUF_ENABLE, 0x0f),
  905. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RESET_TSYNC_EN, 0x03),
  906. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_TRAN_DRVR_EMP_EN, 0xf),
  907. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
  908. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
  909. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_RX, 0x11),
  910. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_TX_BAND, 0x01),
  911. };
  912. static const struct qmp_phy_init_tbl qmp_v6_dp_serdes_tbl[] = {
  913. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SVS_MODE_CLK_SEL, 0x15),
  914. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYSCLK_EN_SEL, 0x3b),
  915. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYS_CLK_CTRL, 0x02),
  916. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CLK_ENABLE1, 0x0c),
  917. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYSCLK_BUF_ENABLE, 0x06),
  918. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CLK_SELECT, 0x30),
  919. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_IVCO, 0x0f),
  920. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_CCTRL_MODE0, 0x36),
  921. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_RCTRL_MODE0, 0x16),
  922. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CP_CTRL_MODE0, 0x06),
  923. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START1_MODE0, 0x00),
  924. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CMN_CONFIG_1, 0x12),
  925. QMP_PHY_INIT_CFG(QSERDES_V6_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
  926. QMP_PHY_INIT_CFG(QSERDES_V6_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
  927. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE_MAP, 0x00),
  928. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BG_TIMER, 0x0a),
  929. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_CORE_CLK_DIV_MODE0, 0x14),
  930. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE_CTRL, 0x00),
  931. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_BIAS_EN_CLK_BUFLR_EN, 0x17),
  932. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CORE_CLK_EN, 0x0f),
  933. };
  934. static const struct qmp_phy_init_tbl qmp_v6_n4_dp_serdes_tbl[] = {
  935. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SVS_MODE_CLK_SEL, 0x15),
  936. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYSCLK_EN_SEL, 0x3b),
  937. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYS_CLK_CTRL, 0x02),
  938. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CLK_ENABLE1, 0x0c),
  939. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYSCLK_BUF_ENABLE, 0x06),
  940. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CLK_SELECT, 0x30),
  941. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_IVCO, 0x07),
  942. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_CCTRL_MODE0, 0x36),
  943. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_RCTRL_MODE0, 0x16),
  944. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CP_CTRL_MODE0, 0x06),
  945. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x34),
  946. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START1_MODE0, 0x00),
  947. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START2_MODE0, 0xc0),
  948. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CMN_CONFIG_1, 0x12),
  949. QMP_PHY_INIT_CFG(QSERDES_V6_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
  950. QMP_PHY_INIT_CFG(QSERDES_V6_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
  951. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE_MAP, 0x00),
  952. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BG_TIMER, 0x0a),
  953. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_CORE_CLK_DIV_MODE0, 0x14),
  954. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE_CTRL, 0x00),
  955. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_BIAS_EN_CLK_BUFLR_EN, 0x17),
  956. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CORE_CLK_EN, 0x0f),
  957. };
  958. static const struct qmp_phy_init_tbl qmp_v6_dp_tx_tbl[] = {
  959. QMP_PHY_INIT_CFG(QSERDES_V6_TX_VMODE_CTRL1, 0x40),
  960. QMP_PHY_INIT_CFG(QSERDES_V6_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
  961. QMP_PHY_INIT_CFG(QSERDES_V6_TX_INTERFACE_SELECT, 0x3b),
  962. QMP_PHY_INIT_CFG(QSERDES_V6_TX_CLKBUF_ENABLE, 0x0f),
  963. QMP_PHY_INIT_CFG(QSERDES_V6_TX_RESET_TSYNC_EN, 0x03),
  964. QMP_PHY_INIT_CFG(QSERDES_V6_TX_TRAN_DRVR_EMP_EN, 0x0f),
  965. QMP_PHY_INIT_CFG(QSERDES_V6_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
  966. QMP_PHY_INIT_CFG(QSERDES_V6_TX_TX_INTERFACE_MODE, 0x00),
  967. QMP_PHY_INIT_CFG(QSERDES_V6_TX_RES_CODE_LANE_OFFSET_TX, 0x0c),
  968. QMP_PHY_INIT_CFG(QSERDES_V6_TX_RES_CODE_LANE_OFFSET_RX, 0x0c),
  969. QMP_PHY_INIT_CFG(QSERDES_V6_TX_TX_BAND, 0x4),
  970. };
  971. static const struct qmp_phy_init_tbl qmp_v6_n4_dp_tx_tbl[] = {
  972. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_VMODE_CTRL1, 0x40),
  973. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_PRE_STALL_LDO_BOOST_EN, 0x00),
  974. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_INTERFACE_SELECT, 0xff),
  975. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_CLKBUF_ENABLE, 0x0f),
  976. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_RESET_TSYNC_EN, 0x03),
  977. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_TRAN_DRVR_EMP_EN, 0x0f),
  978. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
  979. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
  980. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_RES_CODE_LANE_OFFSET_RX, 0x11),
  981. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_TX_BAND, 0x1),
  982. };
  983. static const struct qmp_phy_init_tbl qmp_v6_dp_serdes_tbl_rbr[] = {
  984. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x05),
  985. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x34),
  986. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START2_MODE0, 0xc0),
  987. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x0b),
  988. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x37),
  989. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x04),
  990. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_EN, 0x04),
  991. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x71),
  992. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x0c),
  993. };
  994. static const struct qmp_phy_init_tbl qmp_v6_dp_serdes_tbl_hbr[] = {
  995. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x03),
  996. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x34),
  997. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START2_MODE0, 0xc0),
  998. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x0b),
  999. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x07),
  1000. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x07),
  1001. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_EN, 0x08),
  1002. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x71),
  1003. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x0c),
  1004. };
  1005. static const struct qmp_phy_init_tbl qmp_v6_dp_serdes_tbl_hbr2[] = {
  1006. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x01),
  1007. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x46),
  1008. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START2_MODE0, 0x00),
  1009. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x05),
  1010. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x0f),
  1011. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x0e),
  1012. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_EN, 0x08),
  1013. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x97),
  1014. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x10),
  1015. };
  1016. static const struct qmp_phy_init_tbl qmp_v6_dp_serdes_tbl_hbr3[] = {
  1017. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x00),
  1018. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x34),
  1019. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START2_MODE0, 0xc0),
  1020. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x0b),
  1021. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x17),
  1022. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x15),
  1023. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_EN, 0x08),
  1024. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x71),
  1025. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x0c),
  1026. };
  1027. static const struct qmp_phy_init_tbl qmp_v6_n4_dp_serdes_tbl_rbr[] = {
  1028. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x05),
  1029. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x34),
  1030. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_EN, 0x04),
  1031. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x0b),
  1032. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x37),
  1033. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x04),
  1034. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x71),
  1035. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x0c),
  1036. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_EN_CENTER, 0x01),
  1037. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_ADJ_PER1, 0x00),
  1038. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER1, 0x6b),
  1039. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER2, 0x02),
  1040. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE1_MODE0, 0x92),
  1041. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE2_MODE0, 0x01),
  1042. };
  1043. static const struct qmp_phy_init_tbl qmp_v6_n4_dp_serdes_tbl_hbr[] = {
  1044. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x03),
  1045. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x34),
  1046. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_EN, 0x08),
  1047. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x0b),
  1048. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x07),
  1049. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x07),
  1050. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x71),
  1051. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x0c),
  1052. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_EN_CENTER, 0x01),
  1053. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_ADJ_PER1, 0x00),
  1054. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER1, 0x6b),
  1055. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER2, 0x02),
  1056. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE1_MODE0, 0x92),
  1057. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE2_MODE0, 0x01),
  1058. };
  1059. static const struct qmp_phy_init_tbl qmp_v6_n4_dp_serdes_tbl_hbr2[] = {
  1060. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x01),
  1061. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x46),
  1062. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_EN, 0x08),
  1063. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x05),
  1064. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x0f),
  1065. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x0e),
  1066. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x97),
  1067. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x10),
  1068. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_EN_CENTER, 0x01),
  1069. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_ADJ_PER1, 0x00),
  1070. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER1, 0x6b),
  1071. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER2, 0x02),
  1072. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE1_MODE0, 0x18),
  1073. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE2_MODE0, 0x02),
  1074. };
  1075. static const struct qmp_phy_init_tbl qmp_v6_n4_dp_serdes_tbl_hbr3[] = {
  1076. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x00),
  1077. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x34),
  1078. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_EN, 0x08),
  1079. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x0b),
  1080. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x17),
  1081. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x15),
  1082. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0x71),
  1083. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x0c),
  1084. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_EN_CENTER, 0x01),
  1085. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_ADJ_PER1, 0x00),
  1086. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER1, 0x6b),
  1087. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER2, 0x02),
  1088. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE1_MODE0, 0x92),
  1089. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE2_MODE0, 0x01),
  1090. };
  1091. static const struct qmp_phy_init_tbl sc8280xp_usb43dp_serdes_tbl[] = {
  1092. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_EN_CENTER, 0x01),
  1093. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31),
  1094. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01),
  1095. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xfd),
  1096. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x0d),
  1097. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0xfd),
  1098. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x0d),
  1099. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_BUF_ENABLE, 0x0a),
  1100. QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x02),
  1101. QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x02),
  1102. QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16),
  1103. QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16),
  1104. QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36),
  1105. QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36),
  1106. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x1a),
  1107. QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x04),
  1108. QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x14),
  1109. QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x34),
  1110. QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x34),
  1111. QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x82),
  1112. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x04),
  1113. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MSB_MODE0, 0x01),
  1114. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x04),
  1115. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MSB_MODE1, 0x01),
  1116. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55),
  1117. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0xd5),
  1118. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x05),
  1119. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0x55),
  1120. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0xd5),
  1121. QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x05),
  1122. QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02),
  1123. QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE0, 0xd4),
  1124. QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE0, 0x00),
  1125. QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE1, 0xd4),
  1126. QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE1, 0x00),
  1127. QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x13),
  1128. QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_HS_SWITCH_SEL, 0x00),
  1129. QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE0, 0x0a),
  1130. QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x04),
  1131. QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x60),
  1132. QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_CONFIG, 0x76),
  1133. QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0xff),
  1134. QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE0, 0x20),
  1135. QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE1, 0x20),
  1136. QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_INITVAL2, 0x00),
  1137. QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAXVAL2, 0x01),
  1138. QMP_PHY_INIT_CFG(QSERDES_V5_COM_SVS_MODE_CLK_SEL, 0x0a),
  1139. };
  1140. static const struct qmp_phy_init_tbl sc8280xp_usb43dp_tx_tbl[] = {
  1141. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_LANE_MODE_1, 0x05),
  1142. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_LANE_MODE_2, 0xc2),
  1143. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_LANE_MODE_3, 0x10),
  1144. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_TX, 0x1f),
  1145. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_RX, 0x0a),
  1146. };
  1147. static const struct qmp_phy_init_tbl sc8280xp_usb43dp_rx_tbl[] = {
  1148. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_SIGDET_CNTRL, 0x04),
  1149. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
  1150. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_SIGDET_ENABLES, 0x00),
  1151. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B0, 0xd2),
  1152. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B1, 0xd2),
  1153. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B2, 0xdb),
  1154. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B3, 0x21),
  1155. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B4, 0x3f),
  1156. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B5, 0x80),
  1157. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B6, 0x45),
  1158. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B7, 0x00),
  1159. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B0, 0x6b),
  1160. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B1, 0x63),
  1161. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B2, 0xb6),
  1162. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B3, 0x23),
  1163. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B4, 0x35),
  1164. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B5, 0x30),
  1165. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B6, 0x8e),
  1166. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B7, 0x00),
  1167. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_IVCM_CAL_CODE_OVERRIDE, 0x00),
  1168. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_IVCM_CAL_CTRL2, 0x80),
  1169. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_SUMMER_CAL_SPD_MODE, 0x1b),
  1170. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
  1171. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_UCDR_PI_CONTROLS, 0x15),
  1172. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_UCDR_SB2_GAIN2_RATE2, 0x0a),
  1173. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_IVCM_POSTCAL_OFFSET, 0x7c),
  1174. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_VGA_CAL_CNTRL1, 0x00),
  1175. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_VGA_CAL_MAN_VAL, 0x0d),
  1176. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_DFE_DAC_ENABLE1, 0x00),
  1177. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_DFE_3, 0x45),
  1178. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_GM_CAL, 0x09),
  1179. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_UCDR_FO_GAIN_RATE2, 0x09),
  1180. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_UCDR_SO_GAIN_RATE2, 0x05),
  1181. QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_Q_PI_INTRINSIC_BIAS_RATE32, 0x3f),
  1182. };
  1183. static const struct qmp_phy_init_tbl sc8280xp_usb43dp_pcs_tbl[] = {
  1184. QMP_PHY_INIT_CFG(QPHY_V5_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
  1185. QMP_PHY_INIT_CFG(QPHY_V5_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
  1186. QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG1, 0xd0),
  1187. QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG2, 0x07),
  1188. QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG3, 0x20),
  1189. QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG6, 0x13),
  1190. QMP_PHY_INIT_CFG(QPHY_V5_PCS_REFGEN_REQ_CONFIG1, 0x21),
  1191. QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0xaa),
  1192. QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_CONFIG, 0x0a),
  1193. QMP_PHY_INIT_CFG(QPHY_V5_PCS_ALIGN_DETECT_CONFIG1, 0x88),
  1194. QMP_PHY_INIT_CFG(QPHY_V5_PCS_ALIGN_DETECT_CONFIG2, 0x13),
  1195. QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCS_TX_RX_CONFIG, 0x0c),
  1196. QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG1, 0x4b),
  1197. QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG5, 0x10),
  1198. QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
  1199. QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07),
  1200. };
  1201. static const struct qmp_phy_init_tbl x1e80100_usb43dp_serdes_tbl[] = {
  1202. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_EN_CENTER, 0x01),
  1203. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER1, 0x62),
  1204. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_PER2, 0x02),
  1205. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE1_MODE0, 0xc2),
  1206. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE2_MODE0, 0x03),
  1207. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE1_MODE1, 0xc2),
  1208. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE2_MODE1, 0x03),
  1209. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYSCLK_BUF_ENABLE, 0x0a),
  1210. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CP_CTRL_MODE0, 0x02),
  1211. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CP_CTRL_MODE1, 0x02),
  1212. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_RCTRL_MODE0, 0x16),
  1213. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_RCTRL_MODE1, 0x16),
  1214. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_CCTRL_MODE0, 0x36),
  1215. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_CCTRL_MODE1, 0x36),
  1216. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SYSCLK_EN_SEL, 0x1a),
  1217. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_EN, 0x04),
  1218. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP_CFG, 0x04),
  1219. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE0, 0x08),
  1220. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE0, 0x1a),
  1221. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP1_MODE1, 0x16),
  1222. QMP_PHY_INIT_CFG(QSERDES_V6_COM_LOCK_CMP2_MODE1, 0x41),
  1223. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE0, 0x82),
  1224. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MSB_MODE0, 0x00),
  1225. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MODE1, 0x82),
  1226. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DEC_START_MSB_MODE1, 0x00),
  1227. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START1_MODE0, 0x55),
  1228. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START2_MODE0, 0x55),
  1229. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE0, 0x03),
  1230. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START1_MODE1, 0x55),
  1231. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START2_MODE1, 0x55),
  1232. QMP_PHY_INIT_CFG(QSERDES_V6_COM_DIV_FRAC_START3_MODE1, 0x03),
  1233. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE_MAP, 0x14),
  1234. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE1_MODE0, 0xba),
  1235. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE2_MODE0, 0x00),
  1236. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE1_MODE1, 0xba),
  1237. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE2_MODE1, 0x00),
  1238. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_SEL_1, 0x13),
  1239. QMP_PHY_INIT_CFG(QSERDES_V6_COM_HSCLK_HS_SWITCH_SEL_1, 0x00),
  1240. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_CORE_CLK_DIV_MODE0, 0x0a),
  1241. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CORECLK_DIV_MODE1, 0x04),
  1242. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CORE_CLK_EN, 0xa0),
  1243. QMP_PHY_INIT_CFG(QSERDES_V6_COM_CMN_CONFIG_1, 0x76),
  1244. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_IVCO, 0x0f),
  1245. QMP_PHY_INIT_CFG(QSERDES_V6_COM_PLL_IVCO_MODE1, 0x0f),
  1246. QMP_PHY_INIT_CFG(QSERDES_V6_COM_INTEGLOOP_GAIN0_MODE0, 0x20),
  1247. QMP_PHY_INIT_CFG(QSERDES_V6_COM_INTEGLOOP_GAIN0_MODE1, 0x20),
  1248. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE_INITVAL2, 0x00),
  1249. QMP_PHY_INIT_CFG(QSERDES_V6_COM_VCO_TUNE_MAXVAL2, 0x01),
  1250. QMP_PHY_INIT_CFG(QSERDES_V6_COM_SVS_MODE_CLK_SEL, 0x0a),
  1251. QMP_PHY_INIT_CFG(QSERDES_V6_COM_BG_TIMER, 0x0a),
  1252. };
  1253. static const struct qmp_phy_init_tbl x1e80100_usb43dp_tx_tbl[] = {
  1254. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_LANE_MODE_1, 0x05),
  1255. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_LANE_MODE_2, 0x50),
  1256. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_LANE_MODE_3, 0x50),
  1257. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_RES_CODE_LANE_OFFSET_TX, 0x1f),
  1258. QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_RES_CODE_LANE_OFFSET_RX, 0x0a),
  1259. };
  1260. static const struct qmp_phy_init_tbl x1e80100_usb43dp_rx_tbl[] = {
  1261. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_SIGDET_CNTRL, 0x04),
  1262. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
  1263. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_SIGDET_ENABLES, 0x00),
  1264. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE_0_1_B0, 0xc3),
  1265. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE_0_1_B1, 0xc3),
  1266. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE_0_1_B2, 0xd8),
  1267. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE_0_1_B3, 0x9e),
  1268. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE_0_1_B4, 0x36),
  1269. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE_0_1_B5, 0xb6),
  1270. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE_0_1_B6, 0x64),
  1271. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE2_B0, 0xd6),
  1272. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE2_B1, 0xee),
  1273. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE2_B2, 0x18),
  1274. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE2_B3, 0x9a),
  1275. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE2_B4, 0x04),
  1276. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE2_B5, 0x36),
  1277. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_MODE_RATE2_B6, 0xe3),
  1278. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_IVCM_CAL_CODE_OVERRIDE, 0x00),
  1279. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_RX_IVCM_CAL_CTRL2, 0x80),
  1280. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_RX_SUMMER_CAL_SPD_MODE, 0x2f),
  1281. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x08),
  1282. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_UCDR_PI_CONTROLS, 0x15),
  1283. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_UCDR_PI_CTRL1, 0xd0),
  1284. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_UCDR_PI_CTRL2, 0x48),
  1285. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_UCDR_SB2_GAIN2_RATE2, 0x0a),
  1286. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_RX_IVCM_POSTCAL_OFFSET, 0x7c),
  1287. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_VGA_CAL_CNTRL1, 0x00),
  1288. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_VGA_CAL_MAN_VAL, 0x04),
  1289. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_DFE_DAC_ENABLE1, 0x88),
  1290. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_DFE_3, 0x45),
  1291. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_GM_CAL, 0x0d),
  1292. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_UCDR_FO_GAIN_RATE2, 0x09),
  1293. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_UCDR_SO_GAIN_RATE2, 0x05),
  1294. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_Q_PI_INTRINSIC_BIAS_RATE32, 0x2f),
  1295. QMP_PHY_INIT_CFG(QSERDES_V6_N4_RX_RX_BKUP_CTRL1, 0x14),
  1296. };
  1297. static const struct qmp_phy_init_tbl x1e80100_usb43dp_pcs_tbl[] = {
  1298. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7),
  1299. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03),
  1300. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_LOCK_DETECT_CONFIG1, 0xc4),
  1301. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_LOCK_DETECT_CONFIG2, 0x89),
  1302. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_LOCK_DETECT_CONFIG3, 0x20),
  1303. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_LOCK_DETECT_CONFIG6, 0x13),
  1304. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_REFGEN_REQ_CONFIG1, 0x21),
  1305. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_RX_SIGDET_LVL, 0x55),
  1306. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_RX_CONFIG, 0x0a),
  1307. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_ALIGN_DETECT_CONFIG1, 0xd4),
  1308. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_ALIGN_DETECT_CONFIG2, 0x30),
  1309. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_PCS_TX_RX_CONFIG, 0x0c),
  1310. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_EQ_CONFIG1, 0x4b),
  1311. QMP_PHY_INIT_CFG(QPHY_V6_N4_PCS_EQ_CONFIG5, 0x10),
  1312. };
  1313. static const struct qmp_phy_init_tbl x1e80100_usb43dp_pcs_usb_tbl[] = {
  1314. QMP_PHY_INIT_CFG(QPHY_V6_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8),
  1315. QMP_PHY_INIT_CFG(QPHY_V6_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07),
  1316. };
  1317. /* list of regulators */
  1318. struct qmp_regulator_data {
  1319. const char *name;
  1320. unsigned int enable_load;
  1321. };
  1322. static struct qmp_regulator_data qmp_phy_vreg_l[] = {
  1323. { .name = "vdda-phy", .enable_load = 21800 },
  1324. { .name = "vdda-pll", .enable_load = 36000 },
  1325. };
  1326. static const u8 qmp_dp_v3_pre_emphasis_hbr3_hbr2[4][4] = {
  1327. { 0x00, 0x0c, 0x15, 0x1a },
  1328. { 0x02, 0x0e, 0x16, 0xff },
  1329. { 0x02, 0x11, 0xff, 0xff },
  1330. { 0x04, 0xff, 0xff, 0xff }
  1331. };
  1332. static const u8 qmp_dp_v3_voltage_swing_hbr3_hbr2[4][4] = {
  1333. { 0x02, 0x12, 0x16, 0x1a },
  1334. { 0x09, 0x19, 0x1f, 0xff },
  1335. { 0x10, 0x1f, 0xff, 0xff },
  1336. { 0x1f, 0xff, 0xff, 0xff }
  1337. };
  1338. static const u8 qmp_dp_v3_pre_emphasis_hbr_rbr[4][4] = {
  1339. { 0x00, 0x0c, 0x14, 0x19 },
  1340. { 0x00, 0x0b, 0x12, 0xff },
  1341. { 0x00, 0x0b, 0xff, 0xff },
  1342. { 0x04, 0xff, 0xff, 0xff }
  1343. };
  1344. static const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = {
  1345. { 0x08, 0x0f, 0x16, 0x1f },
  1346. { 0x11, 0x1e, 0x1f, 0xff },
  1347. { 0x19, 0x1f, 0xff, 0xff },
  1348. { 0x1f, 0xff, 0xff, 0xff }
  1349. };
  1350. static const u8 qmp_dp_v4_pre_emphasis_hbr3_hbr2[4][4] = {
  1351. { 0x00, 0x0c, 0x15, 0x1b },
  1352. { 0x02, 0x0e, 0x16, 0xff },
  1353. { 0x02, 0x11, 0xff, 0xff },
  1354. { 0x04, 0xff, 0xff, 0xff }
  1355. };
  1356. static const u8 qmp_dp_v4_pre_emphasis_hbr_rbr[4][4] = {
  1357. { 0x00, 0x0d, 0x14, 0x1a },
  1358. { 0x00, 0x0e, 0x15, 0xff },
  1359. { 0x00, 0x0d, 0xff, 0xff },
  1360. { 0x03, 0xff, 0xff, 0xff }
  1361. };
  1362. static const u8 qmp_dp_v4_voltage_swing_hbr_rbr[4][4] = {
  1363. { 0x08, 0x0f, 0x16, 0x1f },
  1364. { 0x11, 0x1e, 0x1f, 0xff },
  1365. { 0x16, 0x1f, 0xff, 0xff },
  1366. { 0x1f, 0xff, 0xff, 0xff }
  1367. };
  1368. static const u8 qmp_dp_v5_pre_emphasis_hbr3_hbr2[4][4] = {
  1369. { 0x20, 0x2c, 0x35, 0x3b },
  1370. { 0x22, 0x2e, 0x36, 0xff },
  1371. { 0x22, 0x31, 0xff, 0xff },
  1372. { 0x24, 0xff, 0xff, 0xff }
  1373. };
  1374. static const u8 qmp_dp_v5_voltage_swing_hbr3_hbr2[4][4] = {
  1375. { 0x22, 0x32, 0x36, 0x3a },
  1376. { 0x29, 0x39, 0x3f, 0xff },
  1377. { 0x30, 0x3f, 0xff, 0xff },
  1378. { 0x3f, 0xff, 0xff, 0xff }
  1379. };
  1380. static const u8 qmp_dp_v5_pre_emphasis_hbr_rbr[4][4] = {
  1381. { 0x20, 0x2d, 0x34, 0x3a },
  1382. { 0x20, 0x2e, 0x35, 0xff },
  1383. { 0x20, 0x2e, 0xff, 0xff },
  1384. { 0x24, 0xff, 0xff, 0xff }
  1385. };
  1386. static const u8 qmp_dp_v5_voltage_swing_hbr_rbr[4][4] = {
  1387. { 0x28, 0x2f, 0x36, 0x3f },
  1388. { 0x31, 0x3e, 0x3f, 0xff },
  1389. { 0x36, 0x3f, 0xff, 0xff },
  1390. { 0x3f, 0xff, 0xff, 0xff }
  1391. };
  1392. static const u8 qmp_dp_v6_voltage_swing_hbr_rbr[4][4] = {
  1393. { 0x27, 0x2f, 0x36, 0x3f },
  1394. { 0x31, 0x3e, 0x3f, 0xff },
  1395. { 0x36, 0x3f, 0xff, 0xff },
  1396. { 0x3f, 0xff, 0xff, 0xff }
  1397. };
  1398. static const u8 qmp_dp_v6_pre_emphasis_hbr_rbr[4][4] = {
  1399. { 0x20, 0x2d, 0x34, 0x3a },
  1400. { 0x20, 0x2e, 0x35, 0xff },
  1401. { 0x20, 0x2e, 0xff, 0xff },
  1402. { 0x22, 0xff, 0xff, 0xff }
  1403. };
  1404. struct qmp_combo;
  1405. struct qmp_combo_offsets {
  1406. u16 com;
  1407. u16 txa;
  1408. u16 rxa;
  1409. u16 txb;
  1410. u16 rxb;
  1411. u16 usb3_serdes;
  1412. u16 usb3_pcs_misc;
  1413. u16 usb3_pcs;
  1414. u16 usb3_pcs_usb;
  1415. u16 dp_serdes;
  1416. u16 dp_txa;
  1417. u16 dp_txb;
  1418. u16 dp_dp_phy;
  1419. };
  1420. struct qmp_phy_cfg {
  1421. const struct qmp_combo_offsets *offsets;
  1422. /* Init sequence for PHY blocks - serdes, tx, rx, pcs */
  1423. const struct qmp_phy_init_tbl *serdes_tbl;
  1424. int serdes_tbl_num;
  1425. const struct qmp_phy_init_tbl *tx_tbl;
  1426. int tx_tbl_num;
  1427. const struct qmp_phy_init_tbl *rx_tbl;
  1428. int rx_tbl_num;
  1429. const struct qmp_phy_init_tbl *pcs_tbl;
  1430. int pcs_tbl_num;
  1431. const struct qmp_phy_init_tbl *pcs_usb_tbl;
  1432. int pcs_usb_tbl_num;
  1433. const struct qmp_phy_init_tbl *dp_serdes_tbl;
  1434. int dp_serdes_tbl_num;
  1435. const struct qmp_phy_init_tbl *dp_tx_tbl;
  1436. int dp_tx_tbl_num;
  1437. /* Init sequence for DP PHY block link rates */
  1438. const struct qmp_phy_init_tbl *serdes_tbl_rbr;
  1439. int serdes_tbl_rbr_num;
  1440. const struct qmp_phy_init_tbl *serdes_tbl_hbr;
  1441. int serdes_tbl_hbr_num;
  1442. const struct qmp_phy_init_tbl *serdes_tbl_hbr2;
  1443. int serdes_tbl_hbr2_num;
  1444. const struct qmp_phy_init_tbl *serdes_tbl_hbr3;
  1445. int serdes_tbl_hbr3_num;
  1446. /* DP PHY swing and pre_emphasis tables */
  1447. const u8 (*swing_hbr_rbr)[4][4];
  1448. const u8 (*swing_hbr3_hbr2)[4][4];
  1449. const u8 (*pre_emphasis_hbr_rbr)[4][4];
  1450. const u8 (*pre_emphasis_hbr3_hbr2)[4][4];
  1451. /* DP PHY callbacks */
  1452. int (*configure_dp_phy)(struct qmp_combo *qmp);
  1453. void (*configure_dp_tx)(struct qmp_combo *qmp);
  1454. int (*calibrate_dp_phy)(struct qmp_combo *qmp);
  1455. void (*dp_aux_init)(struct qmp_combo *qmp);
  1456. /* resets to be requested */
  1457. const char * const *reset_list;
  1458. int num_resets;
  1459. /* regulators to be requested */
  1460. const struct qmp_regulator_data *vreg_list;
  1461. int num_vregs;
  1462. /* array of registers with different offsets */
  1463. const unsigned int *regs;
  1464. /* true, if PHY needs delay after POWER_DOWN */
  1465. bool has_pwrdn_delay;
  1466. /* Offset from PCS to PCS_USB region */
  1467. unsigned int pcs_usb_offset;
  1468. };
  1469. struct qmp_combo {
  1470. struct device *dev;
  1471. const struct qmp_phy_cfg *cfg;
  1472. void __iomem *com;
  1473. void __iomem *serdes;
  1474. void __iomem *tx;
  1475. void __iomem *rx;
  1476. void __iomem *pcs;
  1477. void __iomem *tx2;
  1478. void __iomem *rx2;
  1479. void __iomem *pcs_misc;
  1480. void __iomem *pcs_usb;
  1481. void __iomem *dp_serdes;
  1482. void __iomem *dp_tx;
  1483. void __iomem *dp_tx2;
  1484. void __iomem *dp_dp_phy;
  1485. struct clk *pipe_clk;
  1486. struct clk_bulk_data *clks;
  1487. int num_clks;
  1488. struct reset_control_bulk_data *resets;
  1489. struct regulator_bulk_data *vregs;
  1490. struct mutex phy_mutex;
  1491. int init_count;
  1492. struct phy *usb_phy;
  1493. enum phy_mode mode;
  1494. unsigned int usb_init_count;
  1495. struct phy *dp_phy;
  1496. unsigned int dp_aux_cfg;
  1497. struct phy_configure_opts_dp dp_opts;
  1498. unsigned int dp_init_count;
  1499. struct clk_fixed_rate pipe_clk_fixed;
  1500. struct clk_hw dp_link_hw;
  1501. struct clk_hw dp_pixel_hw;
  1502. struct typec_switch_dev *sw;
  1503. enum typec_orientation orientation;
  1504. };
  1505. static void qmp_v3_dp_aux_init(struct qmp_combo *qmp);
  1506. static void qmp_v3_configure_dp_tx(struct qmp_combo *qmp);
  1507. static int qmp_v3_configure_dp_phy(struct qmp_combo *qmp);
  1508. static int qmp_v3_calibrate_dp_phy(struct qmp_combo *qmp);
  1509. static void qmp_v4_dp_aux_init(struct qmp_combo *qmp);
  1510. static void qmp_v4_configure_dp_tx(struct qmp_combo *qmp);
  1511. static int qmp_v4_configure_dp_phy(struct qmp_combo *qmp);
  1512. static int qmp_v4_calibrate_dp_phy(struct qmp_combo *qmp);
  1513. static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val)
  1514. {
  1515. u32 reg;
  1516. reg = readl(base + offset);
  1517. reg |= val;
  1518. writel(reg, base + offset);
  1519. /* ensure that above write is through */
  1520. readl(base + offset);
  1521. }
  1522. static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val)
  1523. {
  1524. u32 reg;
  1525. reg = readl(base + offset);
  1526. reg &= ~val;
  1527. writel(reg, base + offset);
  1528. /* ensure that above write is through */
  1529. readl(base + offset);
  1530. }
  1531. /* list of clocks required by phy */
  1532. static const char * const qmp_combo_phy_clk_l[] = {
  1533. "aux", "cfg_ahb", "ref", "com_aux",
  1534. };
  1535. /* list of resets */
  1536. static const char * const msm8996_usb3phy_reset_l[] = {
  1537. "phy", "common",
  1538. };
  1539. static const char * const sc7180_usb3phy_reset_l[] = {
  1540. "phy",
  1541. };
  1542. static const struct qmp_combo_offsets qmp_combo_offsets_v3 = {
  1543. .com = 0x0000,
  1544. .txa = 0x1200,
  1545. .rxa = 0x1400,
  1546. .txb = 0x1600,
  1547. .rxb = 0x1800,
  1548. .usb3_serdes = 0x1000,
  1549. .usb3_pcs_misc = 0x1a00,
  1550. .usb3_pcs = 0x1c00,
  1551. .usb3_pcs_usb = 0x1f00,
  1552. .dp_serdes = 0x2000,
  1553. .dp_txa = 0x2200,
  1554. .dp_txb = 0x2600,
  1555. .dp_dp_phy = 0x2a00,
  1556. };
  1557. static const struct qmp_combo_offsets qmp_combo_offsets_v5 = {
  1558. .com = 0x0000,
  1559. .txa = 0x0400,
  1560. .rxa = 0x0600,
  1561. .txb = 0x0a00,
  1562. .rxb = 0x0c00,
  1563. .usb3_serdes = 0x1000,
  1564. .usb3_pcs_misc = 0x1200,
  1565. .usb3_pcs = 0x1400,
  1566. .usb3_pcs_usb = 0x1700,
  1567. .dp_serdes = 0x2000,
  1568. .dp_dp_phy = 0x2200,
  1569. };
  1570. static const struct qmp_phy_cfg sc7180_usb3dpphy_cfg = {
  1571. .offsets = &qmp_combo_offsets_v3,
  1572. .serdes_tbl = qmp_v3_usb3_serdes_tbl,
  1573. .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_serdes_tbl),
  1574. .tx_tbl = qmp_v3_usb3_tx_tbl,
  1575. .tx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_tx_tbl),
  1576. .rx_tbl = qmp_v3_usb3_rx_tbl,
  1577. .rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_rx_tbl),
  1578. .pcs_tbl = qmp_v3_usb3_pcs_tbl,
  1579. .pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_pcs_tbl),
  1580. .dp_serdes_tbl = qmp_v3_dp_serdes_tbl,
  1581. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl),
  1582. .dp_tx_tbl = qmp_v3_dp_tx_tbl,
  1583. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v3_dp_tx_tbl),
  1584. .serdes_tbl_rbr = qmp_v3_dp_serdes_tbl_rbr,
  1585. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_rbr),
  1586. .serdes_tbl_hbr = qmp_v3_dp_serdes_tbl_hbr,
  1587. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr),
  1588. .serdes_tbl_hbr2 = qmp_v3_dp_serdes_tbl_hbr2,
  1589. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr2),
  1590. .serdes_tbl_hbr3 = qmp_v3_dp_serdes_tbl_hbr3,
  1591. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr3),
  1592. .swing_hbr_rbr = &qmp_dp_v3_voltage_swing_hbr_rbr,
  1593. .pre_emphasis_hbr_rbr = &qmp_dp_v3_pre_emphasis_hbr_rbr,
  1594. .swing_hbr3_hbr2 = &qmp_dp_v3_voltage_swing_hbr3_hbr2,
  1595. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v3_pre_emphasis_hbr3_hbr2,
  1596. .dp_aux_init = qmp_v3_dp_aux_init,
  1597. .configure_dp_tx = qmp_v3_configure_dp_tx,
  1598. .configure_dp_phy = qmp_v3_configure_dp_phy,
  1599. .calibrate_dp_phy = qmp_v3_calibrate_dp_phy,
  1600. .reset_list = sc7180_usb3phy_reset_l,
  1601. .num_resets = ARRAY_SIZE(sc7180_usb3phy_reset_l),
  1602. .vreg_list = qmp_phy_vreg_l,
  1603. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1604. .regs = qmp_v3_usb3phy_regs_layout,
  1605. .has_pwrdn_delay = true,
  1606. };
  1607. static const struct qmp_phy_cfg sdm845_usb3dpphy_cfg = {
  1608. .offsets = &qmp_combo_offsets_v3,
  1609. .serdes_tbl = qmp_v3_usb3_serdes_tbl,
  1610. .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_serdes_tbl),
  1611. .tx_tbl = qmp_v3_usb3_tx_tbl,
  1612. .tx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_tx_tbl),
  1613. .rx_tbl = qmp_v3_usb3_rx_tbl,
  1614. .rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_rx_tbl),
  1615. .pcs_tbl = qmp_v3_usb3_pcs_tbl,
  1616. .pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_pcs_tbl),
  1617. .dp_serdes_tbl = qmp_v3_dp_serdes_tbl,
  1618. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl),
  1619. .dp_tx_tbl = qmp_v3_dp_tx_tbl,
  1620. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v3_dp_tx_tbl),
  1621. .serdes_tbl_rbr = qmp_v3_dp_serdes_tbl_rbr,
  1622. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_rbr),
  1623. .serdes_tbl_hbr = qmp_v3_dp_serdes_tbl_hbr,
  1624. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr),
  1625. .serdes_tbl_hbr2 = qmp_v3_dp_serdes_tbl_hbr2,
  1626. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr2),
  1627. .serdes_tbl_hbr3 = qmp_v3_dp_serdes_tbl_hbr3,
  1628. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr3),
  1629. .swing_hbr_rbr = &qmp_dp_v3_voltage_swing_hbr_rbr,
  1630. .pre_emphasis_hbr_rbr = &qmp_dp_v3_pre_emphasis_hbr_rbr,
  1631. .swing_hbr3_hbr2 = &qmp_dp_v3_voltage_swing_hbr3_hbr2,
  1632. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v3_pre_emphasis_hbr3_hbr2,
  1633. .dp_aux_init = qmp_v3_dp_aux_init,
  1634. .configure_dp_tx = qmp_v3_configure_dp_tx,
  1635. .configure_dp_phy = qmp_v3_configure_dp_phy,
  1636. .calibrate_dp_phy = qmp_v3_calibrate_dp_phy,
  1637. .reset_list = msm8996_usb3phy_reset_l,
  1638. .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
  1639. .vreg_list = qmp_phy_vreg_l,
  1640. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1641. .regs = qmp_v3_usb3phy_regs_layout,
  1642. .has_pwrdn_delay = true,
  1643. };
  1644. static const struct qmp_phy_cfg sc8180x_usb3dpphy_cfg = {
  1645. .offsets = &qmp_combo_offsets_v3,
  1646. .serdes_tbl = sm8150_usb3_serdes_tbl,
  1647. .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_serdes_tbl),
  1648. .tx_tbl = sm8150_usb3_tx_tbl,
  1649. .tx_tbl_num = ARRAY_SIZE(sm8150_usb3_tx_tbl),
  1650. .rx_tbl = sm8150_usb3_rx_tbl,
  1651. .rx_tbl_num = ARRAY_SIZE(sm8150_usb3_rx_tbl),
  1652. .pcs_tbl = sm8150_usb3_pcs_tbl,
  1653. .pcs_tbl_num = ARRAY_SIZE(sm8150_usb3_pcs_tbl),
  1654. .pcs_usb_tbl = sm8150_usb3_pcs_usb_tbl,
  1655. .pcs_usb_tbl_num = ARRAY_SIZE(sm8150_usb3_pcs_usb_tbl),
  1656. .dp_serdes_tbl = qmp_v4_dp_serdes_tbl,
  1657. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl),
  1658. .dp_tx_tbl = qmp_v4_dp_tx_tbl,
  1659. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v4_dp_tx_tbl),
  1660. .serdes_tbl_rbr = qmp_v4_dp_serdes_tbl_rbr,
  1661. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_rbr),
  1662. .serdes_tbl_hbr = qmp_v4_dp_serdes_tbl_hbr,
  1663. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr),
  1664. .serdes_tbl_hbr2 = qmp_v4_dp_serdes_tbl_hbr2,
  1665. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr2),
  1666. .serdes_tbl_hbr3 = qmp_v4_dp_serdes_tbl_hbr3,
  1667. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr3),
  1668. .swing_hbr_rbr = &qmp_dp_v3_voltage_swing_hbr_rbr,
  1669. .pre_emphasis_hbr_rbr = &qmp_dp_v3_pre_emphasis_hbr_rbr,
  1670. .swing_hbr3_hbr2 = &qmp_dp_v3_voltage_swing_hbr3_hbr2,
  1671. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v3_pre_emphasis_hbr3_hbr2,
  1672. .dp_aux_init = qmp_v4_dp_aux_init,
  1673. .configure_dp_tx = qmp_v4_configure_dp_tx,
  1674. .configure_dp_phy = qmp_v4_configure_dp_phy,
  1675. .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
  1676. .reset_list = msm8996_usb3phy_reset_l,
  1677. .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
  1678. .vreg_list = qmp_phy_vreg_l,
  1679. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1680. .regs = qmp_v45_usb3phy_regs_layout,
  1681. .pcs_usb_offset = 0x300,
  1682. .has_pwrdn_delay = true,
  1683. };
  1684. static const struct qmp_phy_cfg sc8280xp_usb43dpphy_cfg = {
  1685. .offsets = &qmp_combo_offsets_v5,
  1686. .serdes_tbl = sc8280xp_usb43dp_serdes_tbl,
  1687. .serdes_tbl_num = ARRAY_SIZE(sc8280xp_usb43dp_serdes_tbl),
  1688. .tx_tbl = sc8280xp_usb43dp_tx_tbl,
  1689. .tx_tbl_num = ARRAY_SIZE(sc8280xp_usb43dp_tx_tbl),
  1690. .rx_tbl = sc8280xp_usb43dp_rx_tbl,
  1691. .rx_tbl_num = ARRAY_SIZE(sc8280xp_usb43dp_rx_tbl),
  1692. .pcs_tbl = sc8280xp_usb43dp_pcs_tbl,
  1693. .pcs_tbl_num = ARRAY_SIZE(sc8280xp_usb43dp_pcs_tbl),
  1694. .dp_serdes_tbl = qmp_v5_dp_serdes_tbl,
  1695. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v5_dp_serdes_tbl),
  1696. .dp_tx_tbl = qmp_v5_5nm_dp_tx_tbl,
  1697. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v5_5nm_dp_tx_tbl),
  1698. .serdes_tbl_rbr = qmp_v4_dp_serdes_tbl_rbr,
  1699. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_rbr),
  1700. .serdes_tbl_hbr = qmp_v4_dp_serdes_tbl_hbr,
  1701. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr),
  1702. .serdes_tbl_hbr2 = qmp_v4_dp_serdes_tbl_hbr2,
  1703. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr2),
  1704. .serdes_tbl_hbr3 = qmp_v4_dp_serdes_tbl_hbr3,
  1705. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr3),
  1706. .swing_hbr_rbr = &qmp_dp_v5_voltage_swing_hbr_rbr,
  1707. .pre_emphasis_hbr_rbr = &qmp_dp_v5_pre_emphasis_hbr_rbr,
  1708. .swing_hbr3_hbr2 = &qmp_dp_v5_voltage_swing_hbr3_hbr2,
  1709. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v5_pre_emphasis_hbr3_hbr2,
  1710. .dp_aux_init = qmp_v4_dp_aux_init,
  1711. .configure_dp_tx = qmp_v4_configure_dp_tx,
  1712. .configure_dp_phy = qmp_v4_configure_dp_phy,
  1713. .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
  1714. .reset_list = msm8996_usb3phy_reset_l,
  1715. .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
  1716. .vreg_list = qmp_phy_vreg_l,
  1717. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1718. .regs = qmp_v5_5nm_usb3phy_regs_layout,
  1719. };
  1720. static const struct qmp_phy_cfg x1e80100_usb3dpphy_cfg = {
  1721. .offsets = &qmp_combo_offsets_v5,
  1722. .serdes_tbl = x1e80100_usb43dp_serdes_tbl,
  1723. .serdes_tbl_num = ARRAY_SIZE(x1e80100_usb43dp_serdes_tbl),
  1724. .tx_tbl = x1e80100_usb43dp_tx_tbl,
  1725. .tx_tbl_num = ARRAY_SIZE(x1e80100_usb43dp_tx_tbl),
  1726. .rx_tbl = x1e80100_usb43dp_rx_tbl,
  1727. .rx_tbl_num = ARRAY_SIZE(x1e80100_usb43dp_rx_tbl),
  1728. .pcs_tbl = x1e80100_usb43dp_pcs_tbl,
  1729. .pcs_tbl_num = ARRAY_SIZE(x1e80100_usb43dp_pcs_tbl),
  1730. .pcs_usb_tbl = x1e80100_usb43dp_pcs_usb_tbl,
  1731. .pcs_usb_tbl_num = ARRAY_SIZE(x1e80100_usb43dp_pcs_usb_tbl),
  1732. .dp_serdes_tbl = qmp_v6_n4_dp_serdes_tbl,
  1733. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v6_n4_dp_serdes_tbl),
  1734. .dp_tx_tbl = qmp_v6_n4_dp_tx_tbl,
  1735. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v6_n4_dp_tx_tbl),
  1736. .serdes_tbl_rbr = qmp_v6_n4_dp_serdes_tbl_rbr,
  1737. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v6_n4_dp_serdes_tbl_rbr),
  1738. .serdes_tbl_hbr = qmp_v6_n4_dp_serdes_tbl_hbr,
  1739. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v6_n4_dp_serdes_tbl_hbr),
  1740. .serdes_tbl_hbr2 = qmp_v6_n4_dp_serdes_tbl_hbr2,
  1741. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v6_n4_dp_serdes_tbl_hbr2),
  1742. .serdes_tbl_hbr3 = qmp_v6_n4_dp_serdes_tbl_hbr3,
  1743. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v6_n4_dp_serdes_tbl_hbr3),
  1744. .swing_hbr_rbr = &qmp_dp_v6_voltage_swing_hbr_rbr,
  1745. .pre_emphasis_hbr_rbr = &qmp_dp_v6_pre_emphasis_hbr_rbr,
  1746. .swing_hbr3_hbr2 = &qmp_dp_v5_voltage_swing_hbr3_hbr2,
  1747. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v5_pre_emphasis_hbr3_hbr2,
  1748. .dp_aux_init = qmp_v4_dp_aux_init,
  1749. .configure_dp_tx = qmp_v4_configure_dp_tx,
  1750. .configure_dp_phy = qmp_v4_configure_dp_phy,
  1751. .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
  1752. .reset_list = msm8996_usb3phy_reset_l,
  1753. .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
  1754. .vreg_list = qmp_phy_vreg_l,
  1755. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1756. .regs = qmp_v6_n4_usb3phy_regs_layout,
  1757. };
  1758. static const struct qmp_phy_cfg sm6350_usb3dpphy_cfg = {
  1759. .offsets = &qmp_combo_offsets_v3,
  1760. .serdes_tbl = qmp_v3_usb3_serdes_tbl,
  1761. .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_serdes_tbl),
  1762. .tx_tbl = qmp_v3_usb3_tx_tbl,
  1763. .tx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_tx_tbl),
  1764. .rx_tbl = sm6350_usb3_rx_tbl,
  1765. .rx_tbl_num = ARRAY_SIZE(sm6350_usb3_rx_tbl),
  1766. .pcs_tbl = sm6350_usb3_pcs_tbl,
  1767. .pcs_tbl_num = ARRAY_SIZE(sm6350_usb3_pcs_tbl),
  1768. .dp_serdes_tbl = qmp_v3_dp_serdes_tbl,
  1769. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl),
  1770. .dp_tx_tbl = qmp_v3_dp_tx_tbl,
  1771. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v3_dp_tx_tbl),
  1772. .serdes_tbl_rbr = qmp_v3_dp_serdes_tbl_rbr,
  1773. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_rbr),
  1774. .serdes_tbl_hbr = qmp_v3_dp_serdes_tbl_hbr,
  1775. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr),
  1776. .serdes_tbl_hbr2 = qmp_v3_dp_serdes_tbl_hbr2,
  1777. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr2),
  1778. .serdes_tbl_hbr3 = qmp_v3_dp_serdes_tbl_hbr3,
  1779. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr3),
  1780. .swing_hbr_rbr = &qmp_dp_v3_voltage_swing_hbr_rbr,
  1781. .pre_emphasis_hbr_rbr = &qmp_dp_v3_pre_emphasis_hbr_rbr,
  1782. .swing_hbr3_hbr2 = &qmp_dp_v3_voltage_swing_hbr3_hbr2,
  1783. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v3_pre_emphasis_hbr3_hbr2,
  1784. .dp_aux_init = qmp_v3_dp_aux_init,
  1785. .configure_dp_tx = qmp_v3_configure_dp_tx,
  1786. .configure_dp_phy = qmp_v3_configure_dp_phy,
  1787. .calibrate_dp_phy = qmp_v3_calibrate_dp_phy,
  1788. .reset_list = msm8996_usb3phy_reset_l,
  1789. .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
  1790. .vreg_list = qmp_phy_vreg_l,
  1791. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1792. .regs = qmp_v3_usb3phy_regs_layout,
  1793. };
  1794. static const struct qmp_phy_cfg sm8250_usb3dpphy_cfg = {
  1795. .offsets = &qmp_combo_offsets_v3,
  1796. .serdes_tbl = sm8150_usb3_serdes_tbl,
  1797. .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_serdes_tbl),
  1798. .tx_tbl = sm8250_usb3_tx_tbl,
  1799. .tx_tbl_num = ARRAY_SIZE(sm8250_usb3_tx_tbl),
  1800. .rx_tbl = sm8250_usb3_rx_tbl,
  1801. .rx_tbl_num = ARRAY_SIZE(sm8250_usb3_rx_tbl),
  1802. .pcs_tbl = sm8250_usb3_pcs_tbl,
  1803. .pcs_tbl_num = ARRAY_SIZE(sm8250_usb3_pcs_tbl),
  1804. .pcs_usb_tbl = sm8250_usb3_pcs_usb_tbl,
  1805. .pcs_usb_tbl_num = ARRAY_SIZE(sm8250_usb3_pcs_usb_tbl),
  1806. .dp_serdes_tbl = qmp_v4_dp_serdes_tbl,
  1807. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl),
  1808. .dp_tx_tbl = qmp_v4_dp_tx_tbl,
  1809. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v4_dp_tx_tbl),
  1810. .serdes_tbl_rbr = qmp_v4_dp_serdes_tbl_rbr,
  1811. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_rbr),
  1812. .serdes_tbl_hbr = qmp_v4_dp_serdes_tbl_hbr,
  1813. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr),
  1814. .serdes_tbl_hbr2 = qmp_v4_dp_serdes_tbl_hbr2,
  1815. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr2),
  1816. .serdes_tbl_hbr3 = qmp_v4_dp_serdes_tbl_hbr3,
  1817. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr3),
  1818. .swing_hbr_rbr = &qmp_dp_v3_voltage_swing_hbr_rbr,
  1819. .pre_emphasis_hbr_rbr = &qmp_dp_v3_pre_emphasis_hbr_rbr,
  1820. .swing_hbr3_hbr2 = &qmp_dp_v3_voltage_swing_hbr3_hbr2,
  1821. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v3_pre_emphasis_hbr3_hbr2,
  1822. .dp_aux_init = qmp_v4_dp_aux_init,
  1823. .configure_dp_tx = qmp_v4_configure_dp_tx,
  1824. .configure_dp_phy = qmp_v4_configure_dp_phy,
  1825. .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
  1826. .reset_list = msm8996_usb3phy_reset_l,
  1827. .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
  1828. .vreg_list = qmp_phy_vreg_l,
  1829. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1830. .regs = qmp_v45_usb3phy_regs_layout,
  1831. .pcs_usb_offset = 0x300,
  1832. .has_pwrdn_delay = true,
  1833. };
  1834. static const struct qmp_phy_cfg sm8350_usb3dpphy_cfg = {
  1835. .offsets = &qmp_combo_offsets_v3,
  1836. .serdes_tbl = sm8150_usb3_serdes_tbl,
  1837. .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_serdes_tbl),
  1838. .tx_tbl = sm8350_usb3_tx_tbl,
  1839. .tx_tbl_num = ARRAY_SIZE(sm8350_usb3_tx_tbl),
  1840. .rx_tbl = sm8350_usb3_rx_tbl,
  1841. .rx_tbl_num = ARRAY_SIZE(sm8350_usb3_rx_tbl),
  1842. .pcs_tbl = sm8350_usb3_pcs_tbl,
  1843. .pcs_tbl_num = ARRAY_SIZE(sm8350_usb3_pcs_tbl),
  1844. .pcs_usb_tbl = sm8350_usb3_pcs_usb_tbl,
  1845. .pcs_usb_tbl_num = ARRAY_SIZE(sm8350_usb3_pcs_usb_tbl),
  1846. .dp_serdes_tbl = qmp_v4_dp_serdes_tbl,
  1847. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl),
  1848. .dp_tx_tbl = qmp_v5_dp_tx_tbl,
  1849. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v5_dp_tx_tbl),
  1850. .serdes_tbl_rbr = qmp_v4_dp_serdes_tbl_rbr,
  1851. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_rbr),
  1852. .serdes_tbl_hbr = qmp_v4_dp_serdes_tbl_hbr,
  1853. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr),
  1854. .serdes_tbl_hbr2 = qmp_v4_dp_serdes_tbl_hbr2,
  1855. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr2),
  1856. .serdes_tbl_hbr3 = qmp_v4_dp_serdes_tbl_hbr3,
  1857. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr3),
  1858. .swing_hbr_rbr = &qmp_dp_v4_voltage_swing_hbr_rbr,
  1859. .pre_emphasis_hbr_rbr = &qmp_dp_v4_pre_emphasis_hbr_rbr,
  1860. .swing_hbr3_hbr2 = &qmp_dp_v3_voltage_swing_hbr3_hbr2,
  1861. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v4_pre_emphasis_hbr3_hbr2,
  1862. .dp_aux_init = qmp_v4_dp_aux_init,
  1863. .configure_dp_tx = qmp_v4_configure_dp_tx,
  1864. .configure_dp_phy = qmp_v4_configure_dp_phy,
  1865. .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
  1866. .reset_list = msm8996_usb3phy_reset_l,
  1867. .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
  1868. .vreg_list = qmp_phy_vreg_l,
  1869. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1870. .regs = qmp_v45_usb3phy_regs_layout,
  1871. .has_pwrdn_delay = true,
  1872. };
  1873. static const struct qmp_phy_cfg sm8550_usb3dpphy_cfg = {
  1874. .offsets = &qmp_combo_offsets_v3,
  1875. .serdes_tbl = sm8550_usb3_serdes_tbl,
  1876. .serdes_tbl_num = ARRAY_SIZE(sm8550_usb3_serdes_tbl),
  1877. .tx_tbl = sm8550_usb3_tx_tbl,
  1878. .tx_tbl_num = ARRAY_SIZE(sm8550_usb3_tx_tbl),
  1879. .rx_tbl = sm8550_usb3_rx_tbl,
  1880. .rx_tbl_num = ARRAY_SIZE(sm8550_usb3_rx_tbl),
  1881. .pcs_tbl = sm8550_usb3_pcs_tbl,
  1882. .pcs_tbl_num = ARRAY_SIZE(sm8550_usb3_pcs_tbl),
  1883. .pcs_usb_tbl = sm8550_usb3_pcs_usb_tbl,
  1884. .pcs_usb_tbl_num = ARRAY_SIZE(sm8550_usb3_pcs_usb_tbl),
  1885. .dp_serdes_tbl = qmp_v6_dp_serdes_tbl,
  1886. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl),
  1887. .dp_tx_tbl = qmp_v6_dp_tx_tbl,
  1888. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v6_dp_tx_tbl),
  1889. .serdes_tbl_rbr = qmp_v6_dp_serdes_tbl_rbr,
  1890. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl_rbr),
  1891. .serdes_tbl_hbr = qmp_v6_dp_serdes_tbl_hbr,
  1892. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl_hbr),
  1893. .serdes_tbl_hbr2 = qmp_v6_dp_serdes_tbl_hbr2,
  1894. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl_hbr2),
  1895. .serdes_tbl_hbr3 = qmp_v6_dp_serdes_tbl_hbr3,
  1896. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl_hbr3),
  1897. .swing_hbr_rbr = &qmp_dp_v5_voltage_swing_hbr_rbr,
  1898. .pre_emphasis_hbr_rbr = &qmp_dp_v6_pre_emphasis_hbr_rbr,
  1899. .swing_hbr3_hbr2 = &qmp_dp_v5_voltage_swing_hbr3_hbr2,
  1900. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v5_pre_emphasis_hbr3_hbr2,
  1901. .dp_aux_init = qmp_v4_dp_aux_init,
  1902. .configure_dp_tx = qmp_v4_configure_dp_tx,
  1903. .configure_dp_phy = qmp_v4_configure_dp_phy,
  1904. .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
  1905. .regs = qmp_v6_usb3phy_regs_layout,
  1906. .reset_list = msm8996_usb3phy_reset_l,
  1907. .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
  1908. .vreg_list = qmp_phy_vreg_l,
  1909. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1910. };
  1911. static const struct qmp_phy_cfg sm8650_usb3dpphy_cfg = {
  1912. .offsets = &qmp_combo_offsets_v3,
  1913. .serdes_tbl = sm8550_usb3_serdes_tbl,
  1914. .serdes_tbl_num = ARRAY_SIZE(sm8550_usb3_serdes_tbl),
  1915. .tx_tbl = sm8550_usb3_tx_tbl,
  1916. .tx_tbl_num = ARRAY_SIZE(sm8550_usb3_tx_tbl),
  1917. .rx_tbl = sm8550_usb3_rx_tbl,
  1918. .rx_tbl_num = ARRAY_SIZE(sm8550_usb3_rx_tbl),
  1919. .pcs_tbl = sm8550_usb3_pcs_tbl,
  1920. .pcs_tbl_num = ARRAY_SIZE(sm8550_usb3_pcs_tbl),
  1921. .pcs_usb_tbl = sm8550_usb3_pcs_usb_tbl,
  1922. .pcs_usb_tbl_num = ARRAY_SIZE(sm8550_usb3_pcs_usb_tbl),
  1923. .dp_serdes_tbl = qmp_v6_dp_serdes_tbl,
  1924. .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl),
  1925. .dp_tx_tbl = qmp_v6_dp_tx_tbl,
  1926. .dp_tx_tbl_num = ARRAY_SIZE(qmp_v6_dp_tx_tbl),
  1927. .serdes_tbl_rbr = qmp_v6_dp_serdes_tbl_rbr,
  1928. .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl_rbr),
  1929. .serdes_tbl_hbr = qmp_v6_dp_serdes_tbl_hbr,
  1930. .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl_hbr),
  1931. .serdes_tbl_hbr2 = qmp_v6_dp_serdes_tbl_hbr2,
  1932. .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl_hbr2),
  1933. .serdes_tbl_hbr3 = qmp_v6_dp_serdes_tbl_hbr3,
  1934. .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v6_dp_serdes_tbl_hbr3),
  1935. .swing_hbr_rbr = &qmp_dp_v6_voltage_swing_hbr_rbr,
  1936. .pre_emphasis_hbr_rbr = &qmp_dp_v6_pre_emphasis_hbr_rbr,
  1937. .swing_hbr3_hbr2 = &qmp_dp_v5_voltage_swing_hbr3_hbr2,
  1938. .pre_emphasis_hbr3_hbr2 = &qmp_dp_v5_pre_emphasis_hbr3_hbr2,
  1939. .dp_aux_init = qmp_v4_dp_aux_init,
  1940. .configure_dp_tx = qmp_v4_configure_dp_tx,
  1941. .configure_dp_phy = qmp_v4_configure_dp_phy,
  1942. .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
  1943. .regs = qmp_v6_usb3phy_regs_layout,
  1944. .reset_list = msm8996_usb3phy_reset_l,
  1945. .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
  1946. .vreg_list = qmp_phy_vreg_l,
  1947. .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
  1948. };
  1949. static int qmp_combo_dp_serdes_init(struct qmp_combo *qmp)
  1950. {
  1951. const struct qmp_phy_cfg *cfg = qmp->cfg;
  1952. void __iomem *serdes = qmp->dp_serdes;
  1953. const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;
  1954. qmp_configure(qmp->dev, serdes, cfg->dp_serdes_tbl,
  1955. cfg->dp_serdes_tbl_num);
  1956. switch (dp_opts->link_rate) {
  1957. case 1620:
  1958. qmp_configure(qmp->dev, serdes, cfg->serdes_tbl_rbr,
  1959. cfg->serdes_tbl_rbr_num);
  1960. break;
  1961. case 2700:
  1962. qmp_configure(qmp->dev, serdes, cfg->serdes_tbl_hbr,
  1963. cfg->serdes_tbl_hbr_num);
  1964. break;
  1965. case 5400:
  1966. qmp_configure(qmp->dev, serdes, cfg->serdes_tbl_hbr2,
  1967. cfg->serdes_tbl_hbr2_num);
  1968. break;
  1969. case 8100:
  1970. qmp_configure(qmp->dev, serdes, cfg->serdes_tbl_hbr3,
  1971. cfg->serdes_tbl_hbr3_num);
  1972. break;
  1973. default:
  1974. /* Other link rates aren't supported */
  1975. return -EINVAL;
  1976. }
  1977. return 0;
  1978. }
  1979. static void qmp_v3_dp_aux_init(struct qmp_combo *qmp)
  1980. {
  1981. const struct qmp_phy_cfg *cfg = qmp->cfg;
  1982. writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
  1983. DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
  1984. qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL);
  1985. /* Turn on BIAS current for PHY/PLL */
  1986. writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
  1987. QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
  1988. qmp->dp_serdes + cfg->regs[QPHY_COM_BIAS_EN_CLKBUFLR_EN]);
  1989. writel(DP_PHY_PD_CTL_PSR_PWRDN, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL);
  1990. writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
  1991. DP_PHY_PD_CTL_LANE_0_1_PWRDN |
  1992. DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
  1993. DP_PHY_PD_CTL_DP_CLAMP_EN,
  1994. qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL);
  1995. writel(QSERDES_V3_COM_BIAS_EN |
  1996. QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
  1997. QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL |
  1998. QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
  1999. qmp->dp_serdes + cfg->regs[QPHY_COM_BIAS_EN_CLKBUFLR_EN]);
  2000. writel(0x00, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG0);
  2001. writel(0x13, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG1);
  2002. writel(0x24, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG2);
  2003. writel(0x00, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG3);
  2004. writel(0x0a, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG4);
  2005. writel(0x26, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG5);
  2006. writel(0x0a, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG6);
  2007. writel(0x03, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG7);
  2008. writel(0xbb, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG8);
  2009. writel(0x03, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG9);
  2010. qmp->dp_aux_cfg = 0;
  2011. writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
  2012. PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
  2013. PHY_AUX_REQ_ERR_MASK,
  2014. qmp->dp_dp_phy + QSERDES_V3_DP_PHY_AUX_INTERRUPT_MASK);
  2015. }
  2016. static int qmp_combo_configure_dp_swing(struct qmp_combo *qmp)
  2017. {
  2018. const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;
  2019. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2020. unsigned int v_level = 0, p_level = 0;
  2021. u8 voltage_swing_cfg, pre_emphasis_cfg;
  2022. int i;
  2023. for (i = 0; i < dp_opts->lanes; i++) {
  2024. v_level = max(v_level, dp_opts->voltage[i]);
  2025. p_level = max(p_level, dp_opts->pre[i]);
  2026. }
  2027. if (dp_opts->link_rate <= 2700) {
  2028. voltage_swing_cfg = (*cfg->swing_hbr_rbr)[v_level][p_level];
  2029. pre_emphasis_cfg = (*cfg->pre_emphasis_hbr_rbr)[v_level][p_level];
  2030. } else {
  2031. voltage_swing_cfg = (*cfg->swing_hbr3_hbr2)[v_level][p_level];
  2032. pre_emphasis_cfg = (*cfg->pre_emphasis_hbr3_hbr2)[v_level][p_level];
  2033. }
  2034. /* TODO: Move check to config check */
  2035. if (voltage_swing_cfg == 0xFF && pre_emphasis_cfg == 0xFF)
  2036. return -EINVAL;
  2037. /* Enable MUX to use Cursor values from these registers */
  2038. voltage_swing_cfg |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN;
  2039. pre_emphasis_cfg |= DP_PHY_TXn_TX_EMP_POST1_LVL_MUX_EN;
  2040. writel(voltage_swing_cfg, qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL]);
  2041. writel(pre_emphasis_cfg, qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL]);
  2042. writel(voltage_swing_cfg, qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL]);
  2043. writel(pre_emphasis_cfg, qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL]);
  2044. return 0;
  2045. }
  2046. static void qmp_v3_configure_dp_tx(struct qmp_combo *qmp)
  2047. {
  2048. const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;
  2049. u32 bias_en, drvr_en;
  2050. if (qmp_combo_configure_dp_swing(qmp) < 0)
  2051. return;
  2052. if (dp_opts->lanes == 1) {
  2053. bias_en = 0x3e;
  2054. drvr_en = 0x13;
  2055. } else {
  2056. bias_en = 0x3f;
  2057. drvr_en = 0x10;
  2058. }
  2059. writel(drvr_en, qmp->dp_tx + QSERDES_V3_TX_HIGHZ_DRVR_EN);
  2060. writel(bias_en, qmp->dp_tx + QSERDES_V3_TX_TRANSCEIVER_BIAS_EN);
  2061. writel(drvr_en, qmp->dp_tx2 + QSERDES_V3_TX_HIGHZ_DRVR_EN);
  2062. writel(bias_en, qmp->dp_tx2 + QSERDES_V3_TX_TRANSCEIVER_BIAS_EN);
  2063. }
  2064. static bool qmp_combo_configure_dp_mode(struct qmp_combo *qmp)
  2065. {
  2066. bool reverse = (qmp->orientation == TYPEC_ORIENTATION_REVERSE);
  2067. const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;
  2068. u32 val;
  2069. val = DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
  2070. DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN;
  2071. if (dp_opts->lanes == 4 || reverse)
  2072. val |= DP_PHY_PD_CTL_LANE_0_1_PWRDN;
  2073. if (dp_opts->lanes == 4 || !reverse)
  2074. val |= DP_PHY_PD_CTL_LANE_2_3_PWRDN;
  2075. writel(val, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL);
  2076. if (reverse)
  2077. writel(0x4c, qmp->dp_dp_phy + QSERDES_DP_PHY_MODE);
  2078. else
  2079. writel(0x5c, qmp->dp_dp_phy + QSERDES_DP_PHY_MODE);
  2080. return reverse;
  2081. }
  2082. static int qmp_combo_configure_dp_clocks(struct qmp_combo *qmp)
  2083. {
  2084. const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;
  2085. u32 phy_vco_div;
  2086. unsigned long pixel_freq;
  2087. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2088. switch (dp_opts->link_rate) {
  2089. case 1620:
  2090. phy_vco_div = 0x1;
  2091. pixel_freq = 1620000000UL / 2;
  2092. break;
  2093. case 2700:
  2094. phy_vco_div = 0x1;
  2095. pixel_freq = 2700000000UL / 2;
  2096. break;
  2097. case 5400:
  2098. phy_vco_div = 0x2;
  2099. pixel_freq = 5400000000UL / 4;
  2100. break;
  2101. case 8100:
  2102. phy_vco_div = 0x0;
  2103. pixel_freq = 8100000000UL / 6;
  2104. break;
  2105. default:
  2106. /* Other link rates aren't supported */
  2107. return -EINVAL;
  2108. }
  2109. writel(phy_vco_div, qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_VCO_DIV]);
  2110. clk_set_rate(qmp->dp_link_hw.clk, dp_opts->link_rate * 100000);
  2111. clk_set_rate(qmp->dp_pixel_hw.clk, pixel_freq);
  2112. return 0;
  2113. }
  2114. static int qmp_v3_configure_dp_phy(struct qmp_combo *qmp)
  2115. {
  2116. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2117. u32 status;
  2118. int ret;
  2119. qmp_combo_configure_dp_mode(qmp);
  2120. writel(0x05, qmp->dp_dp_phy + QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL);
  2121. writel(0x05, qmp->dp_dp_phy + QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL);
  2122. ret = qmp_combo_configure_dp_clocks(qmp);
  2123. if (ret)
  2124. return ret;
  2125. writel(0x04, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG2);
  2126. writel(0x01, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2127. writel(0x05, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2128. writel(0x01, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2129. writel(0x09, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2130. writel(0x20, qmp->dp_serdes + cfg->regs[QPHY_COM_RESETSM_CNTRL]);
  2131. if (readl_poll_timeout(qmp->dp_serdes + cfg->regs[QPHY_COM_C_READY_STATUS],
  2132. status,
  2133. ((status & BIT(0)) > 0),
  2134. 500,
  2135. 10000))
  2136. return -ETIMEDOUT;
  2137. writel(0x19, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2138. if (readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS],
  2139. status,
  2140. ((status & BIT(1)) > 0),
  2141. 500,
  2142. 10000))
  2143. return -ETIMEDOUT;
  2144. writel(0x18, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2145. udelay(2000);
  2146. writel(0x19, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2147. return readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS],
  2148. status,
  2149. ((status & BIT(1)) > 0),
  2150. 500,
  2151. 10000);
  2152. }
  2153. /*
  2154. * We need to calibrate the aux setting here as many times
  2155. * as the caller tries
  2156. */
  2157. static int qmp_v3_calibrate_dp_phy(struct qmp_combo *qmp)
  2158. {
  2159. static const u8 cfg1_settings[] = { 0x13, 0x23, 0x1d };
  2160. u8 val;
  2161. qmp->dp_aux_cfg++;
  2162. qmp->dp_aux_cfg %= ARRAY_SIZE(cfg1_settings);
  2163. val = cfg1_settings[qmp->dp_aux_cfg];
  2164. writel(val, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG1);
  2165. return 0;
  2166. }
  2167. static void qmp_v4_dp_aux_init(struct qmp_combo *qmp)
  2168. {
  2169. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2170. writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_PSR_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
  2171. DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
  2172. qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL);
  2173. /* Turn on BIAS current for PHY/PLL */
  2174. writel(0x17, qmp->dp_serdes + cfg->regs[QPHY_COM_BIAS_EN_CLKBUFLR_EN]);
  2175. writel(0x00, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG0);
  2176. writel(0x13, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG1);
  2177. writel(0xa4, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG2);
  2178. writel(0x00, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG3);
  2179. writel(0x0a, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG4);
  2180. writel(0x26, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG5);
  2181. writel(0x0a, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG6);
  2182. writel(0x03, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG7);
  2183. writel(0xb7, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG8);
  2184. writel(0x03, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG9);
  2185. qmp->dp_aux_cfg = 0;
  2186. writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
  2187. PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
  2188. PHY_AUX_REQ_ERR_MASK,
  2189. qmp->dp_dp_phy + QSERDES_V4_DP_PHY_AUX_INTERRUPT_MASK);
  2190. }
  2191. static void qmp_v4_configure_dp_tx(struct qmp_combo *qmp)
  2192. {
  2193. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2194. /* Program default values before writing proper values */
  2195. writel(0x27, qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL]);
  2196. writel(0x27, qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL]);
  2197. writel(0x20, qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL]);
  2198. writel(0x20, qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL]);
  2199. qmp_combo_configure_dp_swing(qmp);
  2200. }
  2201. static int qmp_v456_configure_dp_phy(struct qmp_combo *qmp)
  2202. {
  2203. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2204. u32 status;
  2205. int ret;
  2206. writel(0x0f, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG_1);
  2207. qmp_combo_configure_dp_mode(qmp);
  2208. writel(0x13, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG1);
  2209. writel(0xa4, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG2);
  2210. writel(0x05, qmp->dp_dp_phy + QSERDES_V4_DP_PHY_TX0_TX1_LANE_CTL);
  2211. writel(0x05, qmp->dp_dp_phy + QSERDES_V4_DP_PHY_TX2_TX3_LANE_CTL);
  2212. ret = qmp_combo_configure_dp_clocks(qmp);
  2213. if (ret)
  2214. return ret;
  2215. writel(0x01, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2216. writel(0x05, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2217. writel(0x01, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2218. writel(0x09, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2219. writel(0x20, qmp->dp_serdes + cfg->regs[QPHY_COM_RESETSM_CNTRL]);
  2220. if (readl_poll_timeout(qmp->dp_serdes + cfg->regs[QPHY_COM_C_READY_STATUS],
  2221. status,
  2222. ((status & BIT(0)) > 0),
  2223. 500,
  2224. 10000))
  2225. return -ETIMEDOUT;
  2226. if (readl_poll_timeout(qmp->dp_serdes + cfg->regs[QPHY_COM_CMN_STATUS],
  2227. status,
  2228. ((status & BIT(0)) > 0),
  2229. 500,
  2230. 10000))
  2231. return -ETIMEDOUT;
  2232. if (readl_poll_timeout(qmp->dp_serdes + cfg->regs[QPHY_COM_CMN_STATUS],
  2233. status,
  2234. ((status & BIT(1)) > 0),
  2235. 500,
  2236. 10000))
  2237. return -ETIMEDOUT;
  2238. writel(0x19, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2239. if (readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS],
  2240. status,
  2241. ((status & BIT(0)) > 0),
  2242. 500,
  2243. 10000))
  2244. return -ETIMEDOUT;
  2245. if (readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS],
  2246. status,
  2247. ((status & BIT(1)) > 0),
  2248. 500,
  2249. 10000))
  2250. return -ETIMEDOUT;
  2251. return 0;
  2252. }
  2253. static int qmp_v4_configure_dp_phy(struct qmp_combo *qmp)
  2254. {
  2255. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2256. bool reverse = (qmp->orientation == TYPEC_ORIENTATION_REVERSE);
  2257. const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;
  2258. u32 bias0_en, drvr0_en, bias1_en, drvr1_en;
  2259. u32 status;
  2260. int ret;
  2261. ret = qmp_v456_configure_dp_phy(qmp);
  2262. if (ret < 0)
  2263. return ret;
  2264. /*
  2265. * At least for 7nm DP PHY this has to be done after enabling link
  2266. * clock.
  2267. */
  2268. if (dp_opts->lanes == 1) {
  2269. bias0_en = reverse ? 0x3e : 0x15;
  2270. bias1_en = reverse ? 0x15 : 0x3e;
  2271. drvr0_en = reverse ? 0x13 : 0x10;
  2272. drvr1_en = reverse ? 0x10 : 0x13;
  2273. } else if (dp_opts->lanes == 2) {
  2274. bias0_en = reverse ? 0x3f : 0x15;
  2275. bias1_en = reverse ? 0x15 : 0x3f;
  2276. drvr0_en = 0x10;
  2277. drvr1_en = 0x10;
  2278. } else {
  2279. bias0_en = 0x3f;
  2280. bias1_en = 0x3f;
  2281. drvr0_en = 0x10;
  2282. drvr1_en = 0x10;
  2283. }
  2284. writel(drvr0_en, qmp->dp_tx + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN]);
  2285. writel(bias0_en, qmp->dp_tx + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN]);
  2286. writel(drvr1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN]);
  2287. writel(bias1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN]);
  2288. writel(0x18, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2289. udelay(2000);
  2290. writel(0x19, qmp->dp_dp_phy + QSERDES_DP_PHY_CFG);
  2291. if (readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS],
  2292. status,
  2293. ((status & BIT(1)) > 0),
  2294. 500,
  2295. 10000))
  2296. return -ETIMEDOUT;
  2297. writel(0x0a, qmp->dp_tx + cfg->regs[QPHY_TX_TX_POL_INV]);
  2298. writel(0x0a, qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_POL_INV]);
  2299. writel(0x27, qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL]);
  2300. writel(0x27, qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL]);
  2301. writel(0x20, qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL]);
  2302. writel(0x20, qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL]);
  2303. return 0;
  2304. }
  2305. /*
  2306. * We need to calibrate the aux setting here as many times
  2307. * as the caller tries
  2308. */
  2309. static int qmp_v4_calibrate_dp_phy(struct qmp_combo *qmp)
  2310. {
  2311. static const u8 cfg1_settings[] = { 0x20, 0x13, 0x23, 0x1d };
  2312. u8 val;
  2313. qmp->dp_aux_cfg++;
  2314. qmp->dp_aux_cfg %= ARRAY_SIZE(cfg1_settings);
  2315. val = cfg1_settings[qmp->dp_aux_cfg];
  2316. writel(val, qmp->dp_dp_phy + QSERDES_DP_PHY_AUX_CFG1);
  2317. return 0;
  2318. }
  2319. static int qmp_combo_dp_configure(struct phy *phy, union phy_configure_opts *opts)
  2320. {
  2321. const struct phy_configure_opts_dp *dp_opts = &opts->dp;
  2322. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2323. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2324. mutex_lock(&qmp->phy_mutex);
  2325. memcpy(&qmp->dp_opts, dp_opts, sizeof(*dp_opts));
  2326. if (qmp->dp_opts.set_voltages) {
  2327. cfg->configure_dp_tx(qmp);
  2328. qmp->dp_opts.set_voltages = 0;
  2329. }
  2330. mutex_unlock(&qmp->phy_mutex);
  2331. return 0;
  2332. }
  2333. static int qmp_combo_dp_calibrate(struct phy *phy)
  2334. {
  2335. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2336. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2337. int ret = 0;
  2338. mutex_lock(&qmp->phy_mutex);
  2339. if (cfg->calibrate_dp_phy)
  2340. ret = cfg->calibrate_dp_phy(qmp);
  2341. mutex_unlock(&qmp->phy_mutex);
  2342. return ret;
  2343. }
  2344. static int qmp_combo_com_init(struct qmp_combo *qmp, bool force)
  2345. {
  2346. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2347. void __iomem *com = qmp->com;
  2348. int ret;
  2349. u32 val;
  2350. if (!force && qmp->init_count++)
  2351. return 0;
  2352. ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs);
  2353. if (ret) {
  2354. dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret);
  2355. goto err_decrement_count;
  2356. }
  2357. ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
  2358. if (ret) {
  2359. dev_err(qmp->dev, "reset assert failed\n");
  2360. goto err_disable_regulators;
  2361. }
  2362. ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets);
  2363. if (ret) {
  2364. dev_err(qmp->dev, "reset deassert failed\n");
  2365. goto err_disable_regulators;
  2366. }
  2367. ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks);
  2368. if (ret)
  2369. goto err_assert_reset;
  2370. qphy_setbits(com, QPHY_V3_DP_COM_POWER_DOWN_CTRL, SW_PWRDN);
  2371. /* override hardware control for reset of qmp phy */
  2372. qphy_setbits(com, QPHY_V3_DP_COM_RESET_OVRD_CTRL,
  2373. SW_DPPHY_RESET_MUX | SW_DPPHY_RESET |
  2374. SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET);
  2375. /* Use software based port select and switch on typec orientation */
  2376. val = SW_PORTSELECT_MUX;
  2377. if (qmp->orientation == TYPEC_ORIENTATION_REVERSE)
  2378. val |= SW_PORTSELECT_VAL;
  2379. writel(val, com + QPHY_V3_DP_COM_TYPEC_CTRL);
  2380. writel(USB3_MODE | DP_MODE, com + QPHY_V3_DP_COM_PHY_MODE_CTRL);
  2381. /* bring both QMP USB and QMP DP PHYs PCS block out of reset */
  2382. qphy_clrbits(com, QPHY_V3_DP_COM_RESET_OVRD_CTRL,
  2383. SW_DPPHY_RESET_MUX | SW_DPPHY_RESET |
  2384. SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET);
  2385. qphy_clrbits(com, QPHY_V3_DP_COM_SWI_CTRL, 0x03);
  2386. qphy_clrbits(com, QPHY_V3_DP_COM_SW_RESET, SW_RESET);
  2387. qphy_setbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
  2388. SW_PWRDN);
  2389. return 0;
  2390. err_assert_reset:
  2391. reset_control_bulk_assert(cfg->num_resets, qmp->resets);
  2392. err_disable_regulators:
  2393. regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
  2394. err_decrement_count:
  2395. qmp->init_count--;
  2396. return ret;
  2397. }
  2398. static int qmp_combo_com_exit(struct qmp_combo *qmp, bool force)
  2399. {
  2400. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2401. if (!force && --qmp->init_count)
  2402. return 0;
  2403. reset_control_bulk_assert(cfg->num_resets, qmp->resets);
  2404. clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks);
  2405. regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
  2406. return 0;
  2407. }
  2408. static int qmp_combo_dp_init(struct phy *phy)
  2409. {
  2410. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2411. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2412. int ret;
  2413. mutex_lock(&qmp->phy_mutex);
  2414. ret = qmp_combo_com_init(qmp, false);
  2415. if (ret)
  2416. goto out_unlock;
  2417. cfg->dp_aux_init(qmp);
  2418. qmp->dp_init_count++;
  2419. out_unlock:
  2420. mutex_unlock(&qmp->phy_mutex);
  2421. return ret;
  2422. }
  2423. static int qmp_combo_dp_exit(struct phy *phy)
  2424. {
  2425. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2426. mutex_lock(&qmp->phy_mutex);
  2427. qmp_combo_com_exit(qmp, false);
  2428. qmp->dp_init_count--;
  2429. mutex_unlock(&qmp->phy_mutex);
  2430. return 0;
  2431. }
  2432. static int qmp_combo_dp_power_on(struct phy *phy)
  2433. {
  2434. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2435. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2436. void __iomem *tx = qmp->dp_tx;
  2437. void __iomem *tx2 = qmp->dp_tx2;
  2438. mutex_lock(&qmp->phy_mutex);
  2439. qmp_combo_dp_serdes_init(qmp);
  2440. qmp_configure_lane(qmp->dev, tx, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 1);
  2441. qmp_configure_lane(qmp->dev, tx2, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 2);
  2442. /* Configure special DP tx tunings */
  2443. cfg->configure_dp_tx(qmp);
  2444. /* Configure link rate, swing, etc. */
  2445. cfg->configure_dp_phy(qmp);
  2446. mutex_unlock(&qmp->phy_mutex);
  2447. return 0;
  2448. }
  2449. static int qmp_combo_dp_power_off(struct phy *phy)
  2450. {
  2451. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2452. mutex_lock(&qmp->phy_mutex);
  2453. /* Assert DP PHY power down */
  2454. writel(DP_PHY_PD_CTL_PSR_PWRDN, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL);
  2455. mutex_unlock(&qmp->phy_mutex);
  2456. return 0;
  2457. }
  2458. static int qmp_combo_usb_power_on(struct phy *phy)
  2459. {
  2460. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2461. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2462. void __iomem *serdes = qmp->serdes;
  2463. void __iomem *tx = qmp->tx;
  2464. void __iomem *rx = qmp->rx;
  2465. void __iomem *tx2 = qmp->tx2;
  2466. void __iomem *rx2 = qmp->rx2;
  2467. void __iomem *pcs = qmp->pcs;
  2468. void __iomem *pcs_usb = qmp->pcs_usb;
  2469. void __iomem *status;
  2470. unsigned int val;
  2471. int ret;
  2472. qmp_configure(qmp->dev, serdes, cfg->serdes_tbl, cfg->serdes_tbl_num);
  2473. ret = clk_prepare_enable(qmp->pipe_clk);
  2474. if (ret) {
  2475. dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret);
  2476. return ret;
  2477. }
  2478. /* Tx, Rx, and PCS configurations */
  2479. qmp_configure_lane(qmp->dev, tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
  2480. qmp_configure_lane(qmp->dev, tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2);
  2481. qmp_configure_lane(qmp->dev, rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);
  2482. qmp_configure_lane(qmp->dev, rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2);
  2483. qmp_configure(qmp->dev, pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);
  2484. if (pcs_usb)
  2485. qmp_configure(qmp->dev, pcs_usb, cfg->pcs_usb_tbl,
  2486. cfg->pcs_usb_tbl_num);
  2487. if (cfg->has_pwrdn_delay)
  2488. usleep_range(10, 20);
  2489. /* Pull PHY out of reset state */
  2490. qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
  2491. /* start SerDes and Phy-Coding-Sublayer */
  2492. qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], SERDES_START | PCS_START);
  2493. status = pcs + cfg->regs[QPHY_PCS_STATUS];
  2494. ret = readl_poll_timeout(status, val, !(val & PHYSTATUS), 200,
  2495. PHY_INIT_COMPLETE_TIMEOUT);
  2496. if (ret) {
  2497. dev_err(qmp->dev, "phy initialization timed-out\n");
  2498. goto err_disable_pipe_clk;
  2499. }
  2500. return 0;
  2501. err_disable_pipe_clk:
  2502. clk_disable_unprepare(qmp->pipe_clk);
  2503. return ret;
  2504. }
  2505. static int qmp_combo_usb_power_off(struct phy *phy)
  2506. {
  2507. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2508. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2509. clk_disable_unprepare(qmp->pipe_clk);
  2510. /* PHY reset */
  2511. qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
  2512. /* stop SerDes and Phy-Coding-Sublayer */
  2513. qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL],
  2514. SERDES_START | PCS_START);
  2515. /* Put PHY into POWER DOWN state: active low */
  2516. qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
  2517. SW_PWRDN);
  2518. return 0;
  2519. }
  2520. static int qmp_combo_usb_init(struct phy *phy)
  2521. {
  2522. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2523. int ret;
  2524. mutex_lock(&qmp->phy_mutex);
  2525. ret = qmp_combo_com_init(qmp, false);
  2526. if (ret)
  2527. goto out_unlock;
  2528. ret = qmp_combo_usb_power_on(phy);
  2529. if (ret) {
  2530. qmp_combo_com_exit(qmp, false);
  2531. goto out_unlock;
  2532. }
  2533. qmp->usb_init_count++;
  2534. out_unlock:
  2535. mutex_unlock(&qmp->phy_mutex);
  2536. return ret;
  2537. }
  2538. static int qmp_combo_usb_exit(struct phy *phy)
  2539. {
  2540. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2541. int ret;
  2542. mutex_lock(&qmp->phy_mutex);
  2543. ret = qmp_combo_usb_power_off(phy);
  2544. if (ret)
  2545. goto out_unlock;
  2546. ret = qmp_combo_com_exit(qmp, false);
  2547. if (ret)
  2548. goto out_unlock;
  2549. qmp->usb_init_count--;
  2550. out_unlock:
  2551. mutex_unlock(&qmp->phy_mutex);
  2552. return ret;
  2553. }
  2554. static int qmp_combo_usb_set_mode(struct phy *phy, enum phy_mode mode, int submode)
  2555. {
  2556. struct qmp_combo *qmp = phy_get_drvdata(phy);
  2557. qmp->mode = mode;
  2558. return 0;
  2559. }
  2560. static const struct phy_ops qmp_combo_usb_phy_ops = {
  2561. .init = qmp_combo_usb_init,
  2562. .exit = qmp_combo_usb_exit,
  2563. .set_mode = qmp_combo_usb_set_mode,
  2564. .owner = THIS_MODULE,
  2565. };
  2566. static const struct phy_ops qmp_combo_dp_phy_ops = {
  2567. .init = qmp_combo_dp_init,
  2568. .configure = qmp_combo_dp_configure,
  2569. .power_on = qmp_combo_dp_power_on,
  2570. .calibrate = qmp_combo_dp_calibrate,
  2571. .power_off = qmp_combo_dp_power_off,
  2572. .exit = qmp_combo_dp_exit,
  2573. .owner = THIS_MODULE,
  2574. };
  2575. static void qmp_combo_enable_autonomous_mode(struct qmp_combo *qmp)
  2576. {
  2577. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2578. void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs;
  2579. void __iomem *pcs_misc = qmp->pcs_misc;
  2580. u32 intr_mask;
  2581. if (qmp->mode == PHY_MODE_USB_HOST_SS ||
  2582. qmp->mode == PHY_MODE_USB_DEVICE_SS)
  2583. intr_mask = ARCVR_DTCT_EN | ALFPS_DTCT_EN;
  2584. else
  2585. intr_mask = ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL;
  2586. /* Clear any pending interrupts status */
  2587. qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR);
  2588. /* Writing 1 followed by 0 clears the interrupt */
  2589. qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR);
  2590. qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL],
  2591. ARCVR_DTCT_EN | ALFPS_DTCT_EN | ARCVR_DTCT_EVENT_SEL);
  2592. /* Enable required PHY autonomous mode interrupts */
  2593. qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], intr_mask);
  2594. /* Enable i/o clamp_n for autonomous mode */
  2595. if (pcs_misc)
  2596. qphy_clrbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN);
  2597. }
  2598. static void qmp_combo_disable_autonomous_mode(struct qmp_combo *qmp)
  2599. {
  2600. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2601. void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs;
  2602. void __iomem *pcs_misc = qmp->pcs_misc;
  2603. /* Disable i/o clamp_n on resume for normal mode */
  2604. if (pcs_misc)
  2605. qphy_setbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN);
  2606. qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL],
  2607. ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL | ALFPS_DTCT_EN);
  2608. qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR);
  2609. /* Writing 1 followed by 0 clears the interrupt */
  2610. qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR);
  2611. }
  2612. static int __maybe_unused qmp_combo_runtime_suspend(struct device *dev)
  2613. {
  2614. struct qmp_combo *qmp = dev_get_drvdata(dev);
  2615. dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode);
  2616. if (!qmp->init_count) {
  2617. dev_vdbg(dev, "PHY not initialized, bailing out\n");
  2618. return 0;
  2619. }
  2620. qmp_combo_enable_autonomous_mode(qmp);
  2621. clk_disable_unprepare(qmp->pipe_clk);
  2622. clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks);
  2623. return 0;
  2624. }
  2625. static int __maybe_unused qmp_combo_runtime_resume(struct device *dev)
  2626. {
  2627. struct qmp_combo *qmp = dev_get_drvdata(dev);
  2628. int ret = 0;
  2629. dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode);
  2630. if (!qmp->init_count) {
  2631. dev_vdbg(dev, "PHY not initialized, bailing out\n");
  2632. return 0;
  2633. }
  2634. ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks);
  2635. if (ret)
  2636. return ret;
  2637. ret = clk_prepare_enable(qmp->pipe_clk);
  2638. if (ret) {
  2639. dev_err(dev, "pipe_clk enable failed, err=%d\n", ret);
  2640. clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks);
  2641. return ret;
  2642. }
  2643. qmp_combo_disable_autonomous_mode(qmp);
  2644. return 0;
  2645. }
  2646. static const struct dev_pm_ops qmp_combo_pm_ops = {
  2647. SET_RUNTIME_PM_OPS(qmp_combo_runtime_suspend,
  2648. qmp_combo_runtime_resume, NULL)
  2649. };
  2650. static int qmp_combo_vreg_init(struct qmp_combo *qmp)
  2651. {
  2652. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2653. struct device *dev = qmp->dev;
  2654. int num = cfg->num_vregs;
  2655. int ret, i;
  2656. qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
  2657. if (!qmp->vregs)
  2658. return -ENOMEM;
  2659. for (i = 0; i < num; i++)
  2660. qmp->vregs[i].supply = cfg->vreg_list[i].name;
  2661. ret = devm_regulator_bulk_get(dev, num, qmp->vregs);
  2662. if (ret) {
  2663. dev_err(dev, "failed at devm_regulator_bulk_get\n");
  2664. return ret;
  2665. }
  2666. for (i = 0; i < num; i++) {
  2667. ret = regulator_set_load(qmp->vregs[i].consumer,
  2668. cfg->vreg_list[i].enable_load);
  2669. if (ret) {
  2670. dev_err(dev, "failed to set load at %s\n",
  2671. qmp->vregs[i].supply);
  2672. return ret;
  2673. }
  2674. }
  2675. return 0;
  2676. }
  2677. static int qmp_combo_reset_init(struct qmp_combo *qmp)
  2678. {
  2679. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2680. struct device *dev = qmp->dev;
  2681. int i;
  2682. int ret;
  2683. qmp->resets = devm_kcalloc(dev, cfg->num_resets,
  2684. sizeof(*qmp->resets), GFP_KERNEL);
  2685. if (!qmp->resets)
  2686. return -ENOMEM;
  2687. for (i = 0; i < cfg->num_resets; i++)
  2688. qmp->resets[i].id = cfg->reset_list[i];
  2689. ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets);
  2690. if (ret)
  2691. return dev_err_probe(dev, ret, "failed to get resets\n");
  2692. return 0;
  2693. }
  2694. static int qmp_combo_clk_init(struct qmp_combo *qmp)
  2695. {
  2696. struct device *dev = qmp->dev;
  2697. int num = ARRAY_SIZE(qmp_combo_phy_clk_l);
  2698. int i;
  2699. qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL);
  2700. if (!qmp->clks)
  2701. return -ENOMEM;
  2702. for (i = 0; i < num; i++)
  2703. qmp->clks[i].id = qmp_combo_phy_clk_l[i];
  2704. qmp->num_clks = num;
  2705. return devm_clk_bulk_get_optional(dev, num, qmp->clks);
  2706. }
  2707. static void phy_clk_release_provider(void *res)
  2708. {
  2709. of_clk_del_provider(res);
  2710. }
  2711. /*
  2712. * Register a fixed rate pipe clock.
  2713. *
  2714. * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate
  2715. * controls it. The <s>_pipe_clk coming out of the GCC is requested
  2716. * by the PHY driver for its operations.
  2717. * We register the <s>_pipe_clksrc here. The gcc driver takes care
  2718. * of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk.
  2719. * Below picture shows this relationship.
  2720. *
  2721. * +---------------+
  2722. * | PHY block |<<---------------------------------------+
  2723. * | | |
  2724. * | +-------+ | +-----+ |
  2725. * I/P---^-->| PLL |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+
  2726. * clk | +-------+ | +-----+
  2727. * +---------------+
  2728. */
  2729. static int phy_pipe_clk_register(struct qmp_combo *qmp, struct device_node *np)
  2730. {
  2731. struct clk_fixed_rate *fixed = &qmp->pipe_clk_fixed;
  2732. struct clk_init_data init = { };
  2733. char name[64];
  2734. snprintf(name, sizeof(name), "%s::pipe_clk", dev_name(qmp->dev));
  2735. init.name = name;
  2736. init.ops = &clk_fixed_rate_ops;
  2737. /* controllers using QMP phys use 125MHz pipe clock interface */
  2738. fixed->fixed_rate = 125000000;
  2739. fixed->hw.init = &init;
  2740. return devm_clk_hw_register(qmp->dev, &fixed->hw);
  2741. }
  2742. /*
  2743. * Display Port PLL driver block diagram for branch clocks
  2744. *
  2745. * +------------------------------+
  2746. * | DP_VCO_CLK |
  2747. * | |
  2748. * | +-------------------+ |
  2749. * | | (DP PLL/VCO) | |
  2750. * | +---------+---------+ |
  2751. * | v |
  2752. * | +----------+-----------+ |
  2753. * | | hsclk_divsel_clk_src | |
  2754. * | +----------+-----------+ |
  2755. * +------------------------------+
  2756. * |
  2757. * +---------<---------v------------>----------+
  2758. * | |
  2759. * +--------v----------------+ |
  2760. * | dp_phy_pll_link_clk | |
  2761. * | link_clk | |
  2762. * +--------+----------------+ |
  2763. * | |
  2764. * | |
  2765. * v v
  2766. * Input to DISPCC block |
  2767. * for link clk, crypto clk |
  2768. * and interface clock |
  2769. * |
  2770. * |
  2771. * +--------<------------+-----------------+---<---+
  2772. * | | |
  2773. * +----v---------+ +--------v-----+ +--------v------+
  2774. * | vco_divided | | vco_divided | | vco_divided |
  2775. * | _clk_src | | _clk_src | | _clk_src |
  2776. * | | | | | |
  2777. * |divsel_six | | divsel_two | | divsel_four |
  2778. * +-------+------+ +-----+--------+ +--------+------+
  2779. * | | |
  2780. * v---->----------v-------------<------v
  2781. * |
  2782. * +----------+-----------------+
  2783. * | dp_phy_pll_vco_div_clk |
  2784. * +---------+------------------+
  2785. * |
  2786. * v
  2787. * Input to DISPCC block
  2788. * for DP pixel clock
  2789. *
  2790. */
  2791. static int qmp_dp_pixel_clk_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
  2792. {
  2793. switch (req->rate) {
  2794. case 1620000000UL / 2:
  2795. case 2700000000UL / 2:
  2796. /* 5.4 and 8.1 GHz are same link rate as 2.7GHz, i.e. div 4 and div 6 */
  2797. return 0;
  2798. default:
  2799. return -EINVAL;
  2800. }
  2801. }
  2802. static unsigned long qmp_dp_pixel_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
  2803. {
  2804. const struct qmp_combo *qmp;
  2805. const struct phy_configure_opts_dp *dp_opts;
  2806. qmp = container_of(hw, struct qmp_combo, dp_pixel_hw);
  2807. dp_opts = &qmp->dp_opts;
  2808. switch (dp_opts->link_rate) {
  2809. case 1620:
  2810. return 1620000000UL / 2;
  2811. case 2700:
  2812. return 2700000000UL / 2;
  2813. case 5400:
  2814. return 5400000000UL / 4;
  2815. case 8100:
  2816. return 8100000000UL / 6;
  2817. default:
  2818. return 0;
  2819. }
  2820. }
  2821. static const struct clk_ops qmp_dp_pixel_clk_ops = {
  2822. .determine_rate = qmp_dp_pixel_clk_determine_rate,
  2823. .recalc_rate = qmp_dp_pixel_clk_recalc_rate,
  2824. };
  2825. static int qmp_dp_link_clk_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
  2826. {
  2827. switch (req->rate) {
  2828. case 162000000:
  2829. case 270000000:
  2830. case 540000000:
  2831. case 810000000:
  2832. return 0;
  2833. default:
  2834. return -EINVAL;
  2835. }
  2836. }
  2837. static unsigned long qmp_dp_link_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
  2838. {
  2839. const struct qmp_combo *qmp;
  2840. const struct phy_configure_opts_dp *dp_opts;
  2841. qmp = container_of(hw, struct qmp_combo, dp_link_hw);
  2842. dp_opts = &qmp->dp_opts;
  2843. switch (dp_opts->link_rate) {
  2844. case 1620:
  2845. case 2700:
  2846. case 5400:
  2847. case 8100:
  2848. return dp_opts->link_rate * 100000;
  2849. default:
  2850. return 0;
  2851. }
  2852. }
  2853. static const struct clk_ops qmp_dp_link_clk_ops = {
  2854. .determine_rate = qmp_dp_link_clk_determine_rate,
  2855. .recalc_rate = qmp_dp_link_clk_recalc_rate,
  2856. };
  2857. static struct clk_hw *qmp_dp_clks_hw_get(struct of_phandle_args *clkspec, void *data)
  2858. {
  2859. struct qmp_combo *qmp = data;
  2860. unsigned int idx = clkspec->args[0];
  2861. if (idx >= 2) {
  2862. pr_err("%s: invalid index %u\n", __func__, idx);
  2863. return ERR_PTR(-EINVAL);
  2864. }
  2865. if (idx == 0)
  2866. return &qmp->dp_link_hw;
  2867. return &qmp->dp_pixel_hw;
  2868. }
  2869. static int phy_dp_clks_register(struct qmp_combo *qmp, struct device_node *np)
  2870. {
  2871. struct clk_init_data init = { };
  2872. char name[64];
  2873. int ret;
  2874. snprintf(name, sizeof(name), "%s::link_clk", dev_name(qmp->dev));
  2875. init.ops = &qmp_dp_link_clk_ops;
  2876. init.name = name;
  2877. qmp->dp_link_hw.init = &init;
  2878. ret = devm_clk_hw_register(qmp->dev, &qmp->dp_link_hw);
  2879. if (ret)
  2880. return ret;
  2881. snprintf(name, sizeof(name), "%s::vco_div_clk", dev_name(qmp->dev));
  2882. init.ops = &qmp_dp_pixel_clk_ops;
  2883. init.name = name;
  2884. qmp->dp_pixel_hw.init = &init;
  2885. ret = devm_clk_hw_register(qmp->dev, &qmp->dp_pixel_hw);
  2886. if (ret)
  2887. return ret;
  2888. return 0;
  2889. }
  2890. static struct clk_hw *qmp_combo_clk_hw_get(struct of_phandle_args *clkspec, void *data)
  2891. {
  2892. struct qmp_combo *qmp = data;
  2893. switch (clkspec->args[0]) {
  2894. case QMP_USB43DP_USB3_PIPE_CLK:
  2895. return &qmp->pipe_clk_fixed.hw;
  2896. case QMP_USB43DP_DP_LINK_CLK:
  2897. return &qmp->dp_link_hw;
  2898. case QMP_USB43DP_DP_VCO_DIV_CLK:
  2899. return &qmp->dp_pixel_hw;
  2900. }
  2901. return ERR_PTR(-EINVAL);
  2902. }
  2903. static int qmp_combo_register_clocks(struct qmp_combo *qmp, struct device_node *usb_np,
  2904. struct device_node *dp_np)
  2905. {
  2906. int ret;
  2907. ret = phy_pipe_clk_register(qmp, usb_np);
  2908. if (ret)
  2909. return ret;
  2910. ret = phy_dp_clks_register(qmp, dp_np);
  2911. if (ret)
  2912. return ret;
  2913. /*
  2914. * Register a single provider for bindings without child nodes.
  2915. */
  2916. if (usb_np == qmp->dev->of_node)
  2917. return devm_of_clk_add_hw_provider(qmp->dev, qmp_combo_clk_hw_get, qmp);
  2918. /*
  2919. * Register multiple providers for legacy bindings with child nodes.
  2920. */
  2921. ret = of_clk_add_hw_provider(usb_np, of_clk_hw_simple_get,
  2922. &qmp->pipe_clk_fixed.hw);
  2923. if (ret)
  2924. return ret;
  2925. /*
  2926. * Roll a devm action because the clock provider is the child node, but
  2927. * the child node is not actually a device.
  2928. */
  2929. ret = devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, usb_np);
  2930. if (ret)
  2931. return ret;
  2932. ret = of_clk_add_hw_provider(dp_np, qmp_dp_clks_hw_get, qmp);
  2933. if (ret)
  2934. return ret;
  2935. return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, dp_np);
  2936. }
  2937. #if IS_ENABLED(CONFIG_TYPEC)
  2938. static int qmp_combo_typec_switch_set(struct typec_switch_dev *sw,
  2939. enum typec_orientation orientation)
  2940. {
  2941. struct qmp_combo *qmp = typec_switch_get_drvdata(sw);
  2942. const struct qmp_phy_cfg *cfg = qmp->cfg;
  2943. if (orientation == qmp->orientation || orientation == TYPEC_ORIENTATION_NONE)
  2944. return 0;
  2945. mutex_lock(&qmp->phy_mutex);
  2946. qmp->orientation = orientation;
  2947. if (qmp->init_count) {
  2948. if (qmp->usb_init_count)
  2949. qmp_combo_usb_power_off(qmp->usb_phy);
  2950. qmp_combo_com_exit(qmp, true);
  2951. qmp_combo_com_init(qmp, true);
  2952. if (qmp->usb_init_count)
  2953. qmp_combo_usb_power_on(qmp->usb_phy);
  2954. if (qmp->dp_init_count)
  2955. cfg->dp_aux_init(qmp);
  2956. }
  2957. mutex_unlock(&qmp->phy_mutex);
  2958. return 0;
  2959. }
  2960. static void qmp_combo_typec_unregister(void *data)
  2961. {
  2962. struct qmp_combo *qmp = data;
  2963. typec_switch_unregister(qmp->sw);
  2964. }
  2965. static int qmp_combo_typec_switch_register(struct qmp_combo *qmp)
  2966. {
  2967. struct typec_switch_desc sw_desc = {};
  2968. struct device *dev = qmp->dev;
  2969. sw_desc.drvdata = qmp;
  2970. sw_desc.fwnode = dev->fwnode;
  2971. sw_desc.set = qmp_combo_typec_switch_set;
  2972. qmp->sw = typec_switch_register(dev, &sw_desc);
  2973. if (IS_ERR(qmp->sw)) {
  2974. dev_err(dev, "Unable to register typec switch: %pe\n", qmp->sw);
  2975. return PTR_ERR(qmp->sw);
  2976. }
  2977. return devm_add_action_or_reset(dev, qmp_combo_typec_unregister, qmp);
  2978. }
  2979. #else
  2980. static int qmp_combo_typec_switch_register(struct qmp_combo *qmp)
  2981. {
  2982. return 0;
  2983. }
  2984. #endif
  2985. static int qmp_combo_parse_dt_lecacy_dp(struct qmp_combo *qmp, struct device_node *np)
  2986. {
  2987. struct device *dev = qmp->dev;
  2988. /*
  2989. * Get memory resources from the DP child node:
  2990. * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2;
  2991. * tx2 -> 3; rx2 -> 4
  2992. *
  2993. * Note that only tx/tx2 and pcs (dp_phy) are used by the DP
  2994. * implementation.
  2995. */
  2996. qmp->dp_tx = devm_of_iomap(dev, np, 0, NULL);
  2997. if (IS_ERR(qmp->dp_tx))
  2998. return PTR_ERR(qmp->dp_tx);
  2999. qmp->dp_dp_phy = devm_of_iomap(dev, np, 2, NULL);
  3000. if (IS_ERR(qmp->dp_dp_phy))
  3001. return PTR_ERR(qmp->dp_dp_phy);
  3002. qmp->dp_tx2 = devm_of_iomap(dev, np, 3, NULL);
  3003. if (IS_ERR(qmp->dp_tx2))
  3004. return PTR_ERR(qmp->dp_tx2);
  3005. return 0;
  3006. }
  3007. static int qmp_combo_parse_dt_lecacy_usb(struct qmp_combo *qmp, struct device_node *np)
  3008. {
  3009. const struct qmp_phy_cfg *cfg = qmp->cfg;
  3010. struct device *dev = qmp->dev;
  3011. /*
  3012. * Get memory resources from the USB child node:
  3013. * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2;
  3014. * tx2 -> 3; rx2 -> 4; pcs_misc (optional) -> 5
  3015. */
  3016. qmp->tx = devm_of_iomap(dev, np, 0, NULL);
  3017. if (IS_ERR(qmp->tx))
  3018. return PTR_ERR(qmp->tx);
  3019. qmp->rx = devm_of_iomap(dev, np, 1, NULL);
  3020. if (IS_ERR(qmp->rx))
  3021. return PTR_ERR(qmp->rx);
  3022. qmp->pcs = devm_of_iomap(dev, np, 2, NULL);
  3023. if (IS_ERR(qmp->pcs))
  3024. return PTR_ERR(qmp->pcs);
  3025. if (cfg->pcs_usb_offset)
  3026. qmp->pcs_usb = qmp->pcs + cfg->pcs_usb_offset;
  3027. qmp->tx2 = devm_of_iomap(dev, np, 3, NULL);
  3028. if (IS_ERR(qmp->tx2))
  3029. return PTR_ERR(qmp->tx2);
  3030. qmp->rx2 = devm_of_iomap(dev, np, 4, NULL);
  3031. if (IS_ERR(qmp->rx2))
  3032. return PTR_ERR(qmp->rx2);
  3033. qmp->pcs_misc = devm_of_iomap(dev, np, 5, NULL);
  3034. if (IS_ERR(qmp->pcs_misc)) {
  3035. dev_vdbg(dev, "PHY pcs_misc-reg not used\n");
  3036. qmp->pcs_misc = NULL;
  3037. }
  3038. qmp->pipe_clk = devm_get_clk_from_child(dev, np, NULL);
  3039. if (IS_ERR(qmp->pipe_clk)) {
  3040. return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk),
  3041. "failed to get pipe clock\n");
  3042. }
  3043. return 0;
  3044. }
  3045. static int qmp_combo_parse_dt_legacy(struct qmp_combo *qmp, struct device_node *usb_np,
  3046. struct device_node *dp_np)
  3047. {
  3048. struct platform_device *pdev = to_platform_device(qmp->dev);
  3049. int ret;
  3050. qmp->serdes = devm_platform_ioremap_resource(pdev, 0);
  3051. if (IS_ERR(qmp->serdes))
  3052. return PTR_ERR(qmp->serdes);
  3053. qmp->com = devm_platform_ioremap_resource(pdev, 1);
  3054. if (IS_ERR(qmp->com))
  3055. return PTR_ERR(qmp->com);
  3056. qmp->dp_serdes = devm_platform_ioremap_resource(pdev, 2);
  3057. if (IS_ERR(qmp->dp_serdes))
  3058. return PTR_ERR(qmp->dp_serdes);
  3059. ret = qmp_combo_parse_dt_lecacy_usb(qmp, usb_np);
  3060. if (ret)
  3061. return ret;
  3062. ret = qmp_combo_parse_dt_lecacy_dp(qmp, dp_np);
  3063. if (ret)
  3064. return ret;
  3065. ret = devm_clk_bulk_get_all(qmp->dev, &qmp->clks);
  3066. if (ret < 0)
  3067. return ret;
  3068. qmp->num_clks = ret;
  3069. return 0;
  3070. }
  3071. static int qmp_combo_parse_dt(struct qmp_combo *qmp)
  3072. {
  3073. struct platform_device *pdev = to_platform_device(qmp->dev);
  3074. const struct qmp_phy_cfg *cfg = qmp->cfg;
  3075. const struct qmp_combo_offsets *offs = cfg->offsets;
  3076. struct device *dev = qmp->dev;
  3077. void __iomem *base;
  3078. int ret;
  3079. if (!offs)
  3080. return -EINVAL;
  3081. base = devm_platform_ioremap_resource(pdev, 0);
  3082. if (IS_ERR(base))
  3083. return PTR_ERR(base);
  3084. qmp->com = base + offs->com;
  3085. qmp->tx = base + offs->txa;
  3086. qmp->rx = base + offs->rxa;
  3087. qmp->tx2 = base + offs->txb;
  3088. qmp->rx2 = base + offs->rxb;
  3089. qmp->serdes = base + offs->usb3_serdes;
  3090. qmp->pcs_misc = base + offs->usb3_pcs_misc;
  3091. qmp->pcs = base + offs->usb3_pcs;
  3092. qmp->pcs_usb = base + offs->usb3_pcs_usb;
  3093. qmp->dp_serdes = base + offs->dp_serdes;
  3094. if (offs->dp_txa) {
  3095. qmp->dp_tx = base + offs->dp_txa;
  3096. qmp->dp_tx2 = base + offs->dp_txb;
  3097. } else {
  3098. qmp->dp_tx = base + offs->txa;
  3099. qmp->dp_tx2 = base + offs->txb;
  3100. }
  3101. qmp->dp_dp_phy = base + offs->dp_dp_phy;
  3102. ret = qmp_combo_clk_init(qmp);
  3103. if (ret)
  3104. return ret;
  3105. qmp->pipe_clk = devm_clk_get(dev, "usb3_pipe");
  3106. if (IS_ERR(qmp->pipe_clk)) {
  3107. return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk),
  3108. "failed to get usb3_pipe clock\n");
  3109. }
  3110. return 0;
  3111. }
  3112. static struct phy *qmp_combo_phy_xlate(struct device *dev, const struct of_phandle_args *args)
  3113. {
  3114. struct qmp_combo *qmp = dev_get_drvdata(dev);
  3115. if (args->args_count == 0)
  3116. return ERR_PTR(-EINVAL);
  3117. switch (args->args[0]) {
  3118. case QMP_USB43DP_USB3_PHY:
  3119. return qmp->usb_phy;
  3120. case QMP_USB43DP_DP_PHY:
  3121. return qmp->dp_phy;
  3122. }
  3123. return ERR_PTR(-EINVAL);
  3124. }
  3125. static int qmp_combo_probe(struct platform_device *pdev)
  3126. {
  3127. struct qmp_combo *qmp;
  3128. struct device *dev = &pdev->dev;
  3129. struct device_node *dp_np, *usb_np;
  3130. struct phy_provider *phy_provider;
  3131. int ret;
  3132. qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL);
  3133. if (!qmp)
  3134. return -ENOMEM;
  3135. qmp->dev = dev;
  3136. dev_set_drvdata(dev, qmp);
  3137. qmp->orientation = TYPEC_ORIENTATION_NORMAL;
  3138. qmp->cfg = of_device_get_match_data(dev);
  3139. if (!qmp->cfg)
  3140. return -EINVAL;
  3141. mutex_init(&qmp->phy_mutex);
  3142. ret = qmp_combo_reset_init(qmp);
  3143. if (ret)
  3144. return ret;
  3145. ret = qmp_combo_vreg_init(qmp);
  3146. if (ret)
  3147. return ret;
  3148. /* Check for legacy binding with child nodes. */
  3149. usb_np = of_get_child_by_name(dev->of_node, "usb3-phy");
  3150. if (usb_np) {
  3151. dp_np = of_get_child_by_name(dev->of_node, "dp-phy");
  3152. if (!dp_np) {
  3153. of_node_put(usb_np);
  3154. return -EINVAL;
  3155. }
  3156. ret = qmp_combo_parse_dt_legacy(qmp, usb_np, dp_np);
  3157. } else {
  3158. usb_np = of_node_get(dev->of_node);
  3159. dp_np = of_node_get(dev->of_node);
  3160. ret = qmp_combo_parse_dt(qmp);
  3161. }
  3162. if (ret)
  3163. goto err_node_put;
  3164. ret = qmp_combo_typec_switch_register(qmp);
  3165. if (ret)
  3166. goto err_node_put;
  3167. ret = drm_aux_bridge_register(dev);
  3168. if (ret)
  3169. goto err_node_put;
  3170. pm_runtime_set_active(dev);
  3171. ret = devm_pm_runtime_enable(dev);
  3172. if (ret)
  3173. goto err_node_put;
  3174. /*
  3175. * Prevent runtime pm from being ON by default. Users can enable
  3176. * it using power/control in sysfs.
  3177. */
  3178. pm_runtime_forbid(dev);
  3179. ret = qmp_combo_register_clocks(qmp, usb_np, dp_np);
  3180. if (ret)
  3181. goto err_node_put;
  3182. qmp->usb_phy = devm_phy_create(dev, usb_np, &qmp_combo_usb_phy_ops);
  3183. if (IS_ERR(qmp->usb_phy)) {
  3184. ret = PTR_ERR(qmp->usb_phy);
  3185. dev_err(dev, "failed to create USB PHY: %d\n", ret);
  3186. goto err_node_put;
  3187. }
  3188. phy_set_drvdata(qmp->usb_phy, qmp);
  3189. qmp->dp_phy = devm_phy_create(dev, dp_np, &qmp_combo_dp_phy_ops);
  3190. if (IS_ERR(qmp->dp_phy)) {
  3191. ret = PTR_ERR(qmp->dp_phy);
  3192. dev_err(dev, "failed to create DP PHY: %d\n", ret);
  3193. goto err_node_put;
  3194. }
  3195. phy_set_drvdata(qmp->dp_phy, qmp);
  3196. if (usb_np == dev->of_node)
  3197. phy_provider = devm_of_phy_provider_register(dev, qmp_combo_phy_xlate);
  3198. else
  3199. phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
  3200. of_node_put(usb_np);
  3201. of_node_put(dp_np);
  3202. return PTR_ERR_OR_ZERO(phy_provider);
  3203. err_node_put:
  3204. of_node_put(usb_np);
  3205. of_node_put(dp_np);
  3206. return ret;
  3207. }
  3208. static const struct of_device_id qmp_combo_of_match_table[] = {
  3209. {
  3210. .compatible = "qcom,sc7180-qmp-usb3-dp-phy",
  3211. .data = &sc7180_usb3dpphy_cfg,
  3212. },
  3213. {
  3214. .compatible = "qcom,sc7280-qmp-usb3-dp-phy",
  3215. .data = &sm8250_usb3dpphy_cfg,
  3216. },
  3217. {
  3218. .compatible = "qcom,sc8180x-qmp-usb3-dp-phy",
  3219. .data = &sc8180x_usb3dpphy_cfg,
  3220. },
  3221. {
  3222. .compatible = "qcom,sc8280xp-qmp-usb43dp-phy",
  3223. .data = &sc8280xp_usb43dpphy_cfg,
  3224. },
  3225. {
  3226. .compatible = "qcom,sdm845-qmp-usb3-dp-phy",
  3227. .data = &sdm845_usb3dpphy_cfg,
  3228. },
  3229. {
  3230. .compatible = "qcom,sm6350-qmp-usb3-dp-phy",
  3231. .data = &sm6350_usb3dpphy_cfg,
  3232. },
  3233. {
  3234. .compatible = "qcom,sm8150-qmp-usb3-dp-phy",
  3235. .data = &sc8180x_usb3dpphy_cfg,
  3236. },
  3237. {
  3238. .compatible = "qcom,sm8250-qmp-usb3-dp-phy",
  3239. .data = &sm8250_usb3dpphy_cfg,
  3240. },
  3241. {
  3242. .compatible = "qcom,sm8350-qmp-usb3-dp-phy",
  3243. .data = &sm8350_usb3dpphy_cfg,
  3244. },
  3245. {
  3246. .compatible = "qcom,sm8450-qmp-usb3-dp-phy",
  3247. .data = &sm8350_usb3dpphy_cfg,
  3248. },
  3249. {
  3250. .compatible = "qcom,sm8550-qmp-usb3-dp-phy",
  3251. .data = &sm8550_usb3dpphy_cfg,
  3252. },
  3253. {
  3254. .compatible = "qcom,sm8650-qmp-usb3-dp-phy",
  3255. .data = &sm8650_usb3dpphy_cfg,
  3256. },
  3257. {
  3258. .compatible = "qcom,x1e80100-qmp-usb3-dp-phy",
  3259. .data = &x1e80100_usb3dpphy_cfg,
  3260. },
  3261. { }
  3262. };
  3263. MODULE_DEVICE_TABLE(of, qmp_combo_of_match_table);
  3264. static struct platform_driver qmp_combo_driver = {
  3265. .probe = qmp_combo_probe,
  3266. .driver = {
  3267. .name = "qcom-qmp-combo-phy",
  3268. .pm = &qmp_combo_pm_ops,
  3269. .of_match_table = qmp_combo_of_match_table,
  3270. },
  3271. };
  3272. module_platform_driver(qmp_combo_driver);
  3273. MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>");
  3274. MODULE_DESCRIPTION("Qualcomm QMP USB+DP combo PHY driver");
  3275. MODULE_LICENSE("GPL v2");