phy-cadence-sierra.c 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Cadence Sierra PHY Driver
  4. *
  5. * Copyright (c) 2018 Cadence Design Systems
  6. * Author: Alan Douglas <adouglas@cadence.com>
  7. *
  8. */
  9. #include <linux/clk.h>
  10. #include <linux/clk-provider.h>
  11. #include <linux/delay.h>
  12. #include <linux/err.h>
  13. #include <linux/io.h>
  14. #include <linux/module.h>
  15. #include <linux/phy/phy.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/pm_runtime.h>
  18. #include <linux/regmap.h>
  19. #include <linux/reset.h>
  20. #include <linux/slab.h>
  21. #include <linux/of.h>
  22. #include <linux/of_platform.h>
  23. #include <dt-bindings/phy/phy.h>
  24. #include <dt-bindings/phy/phy-cadence.h>
  25. #define NUM_SSC_MODE 3
  26. #define NUM_PHY_TYPE 5
  27. /* PHY register offsets */
  28. #define SIERRA_COMMON_CDB_OFFSET 0x0
  29. #define SIERRA_MACRO_ID_REG 0x0
  30. #define SIERRA_CMN_PLLLC_GEN_PREG 0x42
  31. #define SIERRA_CMN_PLLLC_FBDIV_INT_MODE0_PREG 0x43
  32. #define SIERRA_CMN_PLLLC_DCOCAL_CTRL_PREG 0x45
  33. #define SIERRA_CMN_PLLLC_INIT_PREG 0x46
  34. #define SIERRA_CMN_PLLLC_ITERTMR_PREG 0x47
  35. #define SIERRA_CMN_PLLLC_MODE_PREG 0x48
  36. #define SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG 0x49
  37. #define SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG 0x4A
  38. #define SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG 0x4B
  39. #define SIERRA_CMN_PLLLC_LOCKSEARCH_PREG 0x4C
  40. #define SIERRA_CMN_PLLLC_CLK1_PREG 0x4D
  41. #define SIERRA_CMN_PLLLC_CLK0_PREG 0x4E
  42. #define SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG 0x4F
  43. #define SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG 0x50
  44. #define SIERRA_CMN_PLLLC_DSMCORR_PREG 0x51
  45. #define SIERRA_CMN_PLLLC_SS_PREG 0x52
  46. #define SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG 0x53
  47. #define SIERRA_CMN_PLLLC_SSTWOPT_PREG 0x54
  48. #define SIERRA_CMN_PLLCSM_PLLEN_TMR_PREG 0x5D
  49. #define SIERRA_CMN_PLLCSM_PLLPRE_TMR_PREG 0x5E
  50. #define SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG 0x62
  51. #define SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG 0x63
  52. #define SIERRA_SDOSCCAL_CLK_CNT_PREG 0x6E
  53. #define SIERRA_CMN_REFRCV_PREG 0x98
  54. #define SIERRA_CMN_RESCAL_CTRLA_PREG 0xA0
  55. #define SIERRA_CMN_REFRCV1_PREG 0xB8
  56. #define SIERRA_CMN_PLLLC1_GEN_PREG 0xC2
  57. #define SIERRA_CMN_PLLLC1_FBDIV_INT_PREG 0xC3
  58. #define SIERRA_CMN_PLLLC1_DCOCAL_CTRL_PREG 0xC5
  59. #define SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG 0xCA
  60. #define SIERRA_CMN_PLLLC1_CLK0_PREG 0xCE
  61. #define SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG 0xD0
  62. #define SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG 0xE2
  63. #define SIERRA_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
  64. ((0x4000 << (block_offset)) + \
  65. (((ln) << 9) << (reg_offset)))
  66. #define SIERRA_DET_STANDEC_A_PREG 0x000
  67. #define SIERRA_DET_STANDEC_B_PREG 0x001
  68. #define SIERRA_DET_STANDEC_C_PREG 0x002
  69. #define SIERRA_DET_STANDEC_D_PREG 0x003
  70. #define SIERRA_DET_STANDEC_E_PREG 0x004
  71. #define SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG 0x008
  72. #define SIERRA_PSM_A0IN_TMR_PREG 0x009
  73. #define SIERRA_PSM_A3IN_TMR_PREG 0x00C
  74. #define SIERRA_PSM_DIAG_PREG 0x015
  75. #define SIERRA_PSC_LN_A3_PREG 0x023
  76. #define SIERRA_PSC_LN_A4_PREG 0x024
  77. #define SIERRA_PSC_LN_IDLE_PREG 0x026
  78. #define SIERRA_PSC_TX_A0_PREG 0x028
  79. #define SIERRA_PSC_TX_A1_PREG 0x029
  80. #define SIERRA_PSC_TX_A2_PREG 0x02A
  81. #define SIERRA_PSC_TX_A3_PREG 0x02B
  82. #define SIERRA_PSC_RX_A0_PREG 0x030
  83. #define SIERRA_PSC_RX_A1_PREG 0x031
  84. #define SIERRA_PSC_RX_A2_PREG 0x032
  85. #define SIERRA_PSC_RX_A3_PREG 0x033
  86. #define SIERRA_PLLCTRL_FBDIV_MODE01_PREG 0x039
  87. #define SIERRA_PLLCTRL_SUBRATE_PREG 0x03A
  88. #define SIERRA_PLLCTRL_GEN_A_PREG 0x03B
  89. #define SIERRA_PLLCTRL_GEN_D_PREG 0x03E
  90. #define SIERRA_PLLCTRL_CPGAIN_MODE_PREG 0x03F
  91. #define SIERRA_PLLCTRL_STATUS_PREG 0x044
  92. #define SIERRA_CLKPATH_BIASTRIM_PREG 0x04B
  93. #define SIERRA_DFE_BIASTRIM_PREG 0x04C
  94. #define SIERRA_DRVCTRL_ATTEN_PREG 0x06A
  95. #define SIERRA_DRVCTRL_BOOST_PREG 0x06F
  96. #define SIERRA_LANE_TX_RECEIVER_DETECT_PREG 0x071
  97. #define SIERRA_TX_RCVDET_OVRD_PREG 0x072
  98. #define SIERRA_CLKPATHCTRL_TMR_PREG 0x081
  99. #define SIERRA_RX_CREQ_FLTR_A_MODE3_PREG 0x085
  100. #define SIERRA_RX_CREQ_FLTR_A_MODE2_PREG 0x086
  101. #define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG 0x087
  102. #define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG 0x088
  103. #define SIERRA_CREQ_DCBIASATTEN_OVR_PREG 0x08C
  104. #define SIERRA_CREQ_CCLKDET_MODE01_PREG 0x08E
  105. #define SIERRA_RX_CTLE_CAL_PREG 0x08F
  106. #define SIERRA_RX_CTLE_MAINTENANCE_PREG 0x091
  107. #define SIERRA_CREQ_FSMCLK_SEL_PREG 0x092
  108. #define SIERRA_CREQ_EQ_CTRL_PREG 0x093
  109. #define SIERRA_CREQ_SPARE_PREG 0x096
  110. #define SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG 0x097
  111. #define SIERRA_CTLELUT_CTRL_PREG 0x098
  112. #define SIERRA_DEQ_BLK_TAU_CTRL1_PREG 0x0AC
  113. #define SIERRA_DEQ_BLK_TAU_CTRL4_PREG 0x0AF
  114. #define SIERRA_DFE_ECMP_RATESEL_PREG 0x0C0
  115. #define SIERRA_DFE_SMP_RATESEL_PREG 0x0C1
  116. #define SIERRA_DEQ_PHALIGN_CTRL 0x0C4
  117. #define SIERRA_DEQ_CONCUR_CTRL1_PREG 0x0C8
  118. #define SIERRA_DEQ_CONCUR_CTRL2_PREG 0x0C9
  119. #define SIERRA_DEQ_EPIPWR_CTRL2_PREG 0x0CD
  120. #define SIERRA_DEQ_FAST_MAINT_CYCLES_PREG 0x0CE
  121. #define SIERRA_DEQ_ERRCMP_CTRL_PREG 0x0D0
  122. #define SIERRA_DEQ_OFFSET_CTRL_PREG 0x0D8
  123. #define SIERRA_DEQ_GAIN_CTRL_PREG 0x0E0
  124. #define SIERRA_DEQ_VGATUNE_CTRL_PREG 0x0E1
  125. #define SIERRA_DEQ_GLUT0 0x0E8
  126. #define SIERRA_DEQ_GLUT1 0x0E9
  127. #define SIERRA_DEQ_GLUT2 0x0EA
  128. #define SIERRA_DEQ_GLUT3 0x0EB
  129. #define SIERRA_DEQ_GLUT4 0x0EC
  130. #define SIERRA_DEQ_GLUT5 0x0ED
  131. #define SIERRA_DEQ_GLUT6 0x0EE
  132. #define SIERRA_DEQ_GLUT7 0x0EF
  133. #define SIERRA_DEQ_GLUT8 0x0F0
  134. #define SIERRA_DEQ_GLUT9 0x0F1
  135. #define SIERRA_DEQ_GLUT10 0x0F2
  136. #define SIERRA_DEQ_GLUT11 0x0F3
  137. #define SIERRA_DEQ_GLUT12 0x0F4
  138. #define SIERRA_DEQ_GLUT13 0x0F5
  139. #define SIERRA_DEQ_GLUT14 0x0F6
  140. #define SIERRA_DEQ_GLUT15 0x0F7
  141. #define SIERRA_DEQ_GLUT16 0x0F8
  142. #define SIERRA_POSTPRECUR_EN_CEPH_CTRL_PREG 0x0F9
  143. #define SIERRA_TAU_EN_CEPH2TO0_PREG 0x0FB
  144. #define SIERRA_TAU_EN_CEPH5TO3_PREG 0x0FC
  145. #define SIERRA_DEQ_ALUT0 0x108
  146. #define SIERRA_DEQ_ALUT1 0x109
  147. #define SIERRA_DEQ_ALUT2 0x10A
  148. #define SIERRA_DEQ_ALUT3 0x10B
  149. #define SIERRA_DEQ_ALUT4 0x10C
  150. #define SIERRA_DEQ_ALUT5 0x10D
  151. #define SIERRA_DEQ_ALUT6 0x10E
  152. #define SIERRA_DEQ_ALUT7 0x10F
  153. #define SIERRA_DEQ_ALUT8 0x110
  154. #define SIERRA_DEQ_ALUT9 0x111
  155. #define SIERRA_DEQ_ALUT10 0x112
  156. #define SIERRA_DEQ_ALUT11 0x113
  157. #define SIERRA_DEQ_ALUT12 0x114
  158. #define SIERRA_DEQ_ALUT13 0x115
  159. #define SIERRA_OEPH_EN_CTRL_PREG 0x124
  160. #define SIERRA_DEQ_DFETAP_CTRL_PREG 0x128
  161. #define SIERRA_DEQ_DFETAP0 0x129
  162. #define SIERRA_DEQ_DFETAP1 0x12B
  163. #define SIERRA_DEQ_DFETAP2 0x12D
  164. #define SIERRA_DEQ_DFETAP3 0x12F
  165. #define SIERRA_DEQ_DFETAP4 0x131
  166. #define SIERRA_DFE_EN_1010_IGNORE_PREG 0x134
  167. #define SIERRA_DEQ_PRECUR_PREG 0x138
  168. #define SIERRA_DEQ_POSTCUR_PREG 0x140
  169. #define SIERRA_DEQ_POSTCUR_DECR_PREG 0x142
  170. #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150
  171. #define SIERRA_DEQ_TAU_CTRL2_PREG 0x151
  172. #define SIERRA_DEQ_TAU_CTRL3_PREG 0x152
  173. #define SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG 0x158
  174. #define SIERRA_DEQ_CONCUR_EPIOFFSET_MODE_PREG 0x159
  175. #define SIERRA_DEQ_OPENEYE_CTRL_PREG 0x15C
  176. #define SIERRA_DEQ_PICTRL_PREG 0x161
  177. #define SIERRA_CPICAL_TMRVAL_MODE1_PREG 0x170
  178. #define SIERRA_CPICAL_TMRVAL_MODE0_PREG 0x171
  179. #define SIERRA_CPICAL_PICNT_MODE1_PREG 0x174
  180. #define SIERRA_CPI_OUTBUF_RATESEL_PREG 0x17C
  181. #define SIERRA_CPI_RESBIAS_BIN_PREG 0x17E
  182. #define SIERRA_CPI_TRIM_PREG 0x17F
  183. #define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG 0x183
  184. #define SIERRA_CPICAL_RES_STARTCODE_MODE01_PREG 0x184
  185. #define SIERRA_EPI_CTRL_PREG 0x187
  186. #define SIERRA_LFPSDET_SUPPORT_PREG 0x188
  187. #define SIERRA_LFPSFILT_NS_PREG 0x18A
  188. #define SIERRA_LFPSFILT_RD_PREG 0x18B
  189. #define SIERRA_LFPSFILT_MP_PREG 0x18C
  190. #define SIERRA_SIGDET_SUPPORT_PREG 0x190
  191. #define SIERRA_SDFILT_H2L_A_PREG 0x191
  192. #define SIERRA_SDFILT_L2H_PREG 0x193
  193. #define SIERRA_RXBUFFER_CTLECTRL_PREG 0x19E
  194. #define SIERRA_RXBUFFER_RCDFECTRL_PREG 0x19F
  195. #define SIERRA_RXBUFFER_DFECTRL_PREG 0x1A0
  196. #define SIERRA_LN_SPARE_REG_PREG 0x1B0
  197. #define SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG 0x14F
  198. #define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150
  199. /* PHY PCS common registers */
  200. #define SIERRA_PHY_PCS_COMMON_OFFSET(block_offset) \
  201. (0xc000 << (block_offset))
  202. #define SIERRA_PHY_PIPE_CMN_CTRL1 0x0
  203. #define SIERRA_PHY_PLL_CFG 0xe
  204. /* PHY PCS lane registers */
  205. #define SIERRA_PHY_PCS_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
  206. ((0xD000 << (block_offset)) + \
  207. (((ln) << 8) << (reg_offset)))
  208. #define SIERRA_PHY_ISO_LINK_CTRL 0xB
  209. /* PHY PMA common registers */
  210. #define SIERRA_PHY_PMA_COMMON_OFFSET(block_offset) \
  211. (0xE000 << (block_offset))
  212. #define SIERRA_PHY_PMA_CMN_CTRL 0x000
  213. /* PHY PMA lane registers */
  214. #define SIERRA_PHY_PMA_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
  215. ((0xF000 << (block_offset)) + \
  216. (((ln) << 8) << (reg_offset)))
  217. #define SIERRA_PHY_PMA_XCVR_CTRL 0x000
  218. #define SIERRA_MACRO_ID 0x00007364
  219. #define SIERRA_MAX_LANES 16
  220. #define PLL_LOCK_TIME 100000
  221. #define CDNS_SIERRA_OUTPUT_CLOCKS 3
  222. #define CDNS_SIERRA_INPUT_CLOCKS 3
  223. enum cdns_sierra_clock_input {
  224. PHY_CLK,
  225. CMN_REFCLK_DIG_DIV,
  226. CMN_REFCLK1_DIG_DIV,
  227. };
  228. #define SIERRA_NUM_CMN_PLLC 2
  229. #define SIERRA_NUM_CMN_PLLC_PARENTS 2
  230. static const struct reg_field macro_id_type =
  231. REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
  232. static const struct reg_field phy_pll_cfg_1 =
  233. REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1);
  234. static const struct reg_field pma_cmn_ready =
  235. REG_FIELD(SIERRA_PHY_PMA_CMN_CTRL, 0, 0);
  236. static const struct reg_field pllctrl_lock =
  237. REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0);
  238. static const struct reg_field phy_iso_link_ctrl_1 =
  239. REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1);
  240. static const struct reg_field cmn_plllc_clk1outdiv_preg =
  241. REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 0, 6);
  242. static const struct reg_field cmn_plllc_clk1_en_preg =
  243. REG_FIELD(SIERRA_CMN_PLLLC_CLK1_PREG, 12, 12);
  244. static const char * const clk_names[] = {
  245. [CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc",
  246. [CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1",
  247. [CDNS_SIERRA_DERIVED_REFCLK] = "refclk_der",
  248. };
  249. enum cdns_sierra_cmn_plllc {
  250. CMN_PLLLC,
  251. CMN_PLLLC1,
  252. };
  253. struct cdns_sierra_pll_mux_reg_fields {
  254. struct reg_field pfdclk_sel_preg;
  255. struct reg_field plllc1en_field;
  256. struct reg_field termen_field;
  257. };
  258. static const struct cdns_sierra_pll_mux_reg_fields cmn_plllc_pfdclk1_sel_preg[] = {
  259. [CMN_PLLLC] = {
  260. .pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC_GEN_PREG, 1, 1),
  261. .plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 8, 8),
  262. .termen_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 0, 0),
  263. },
  264. [CMN_PLLLC1] = {
  265. .pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC1_GEN_PREG, 1, 1),
  266. .plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 8, 8),
  267. .termen_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 0, 0),
  268. },
  269. };
  270. struct cdns_sierra_pll_mux {
  271. struct clk_hw hw;
  272. struct regmap_field *pfdclk_sel_preg;
  273. struct regmap_field *plllc1en_field;
  274. struct regmap_field *termen_field;
  275. struct clk_init_data clk_data;
  276. };
  277. #define to_cdns_sierra_pll_mux(_hw) \
  278. container_of(_hw, struct cdns_sierra_pll_mux, hw)
  279. #define PLL0_REFCLK_NAME "pll0_refclk"
  280. #define PLL1_REFCLK_NAME "pll1_refclk"
  281. static const struct clk_parent_data pll_mux_parent_data[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
  282. [CMN_PLLLC] = {
  283. { .fw_name = PLL0_REFCLK_NAME },
  284. { .fw_name = PLL1_REFCLK_NAME }
  285. },
  286. [CMN_PLLLC1] = {
  287. { .fw_name = PLL1_REFCLK_NAME },
  288. { .fw_name = PLL0_REFCLK_NAME }
  289. },
  290. };
  291. static const u32 cdns_sierra_pll_mux_table[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
  292. [CMN_PLLLC] = { 0, 1 },
  293. [CMN_PLLLC1] = { 1, 0 },
  294. };
  295. struct cdns_sierra_derived_refclk {
  296. struct clk_hw hw;
  297. struct regmap_field *cmn_plllc_clk1outdiv_preg;
  298. struct regmap_field *cmn_plllc_clk1_en_preg;
  299. struct clk_init_data clk_data;
  300. };
  301. #define to_cdns_sierra_derived_refclk(_hw) \
  302. container_of(_hw, struct cdns_sierra_derived_refclk, hw)
  303. enum cdns_sierra_phy_type {
  304. TYPE_NONE,
  305. TYPE_PCIE,
  306. TYPE_USB,
  307. TYPE_SGMII,
  308. TYPE_QSGMII
  309. };
  310. enum cdns_sierra_ssc_mode {
  311. NO_SSC,
  312. EXTERNAL_SSC,
  313. INTERNAL_SSC
  314. };
  315. struct cdns_sierra_inst {
  316. struct phy *phy;
  317. enum cdns_sierra_phy_type phy_type;
  318. u32 num_lanes;
  319. u32 mlane;
  320. struct reset_control *lnk_rst;
  321. enum cdns_sierra_ssc_mode ssc_mode;
  322. };
  323. struct cdns_reg_pairs {
  324. u16 val;
  325. u32 off;
  326. };
  327. struct cdns_sierra_vals {
  328. const struct cdns_reg_pairs *reg_pairs;
  329. u32 num_regs;
  330. };
  331. struct cdns_sierra_data {
  332. u32 id_value;
  333. u8 block_offset_shift;
  334. u8 reg_offset_shift;
  335. const struct cdns_sierra_vals *pcs_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
  336. [NUM_SSC_MODE];
  337. const struct cdns_sierra_vals *phy_pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
  338. [NUM_SSC_MODE];
  339. const struct cdns_sierra_vals *pma_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
  340. [NUM_SSC_MODE];
  341. const struct cdns_sierra_vals *pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
  342. [NUM_SSC_MODE];
  343. };
  344. struct cdns_regmap_cdb_context {
  345. struct device *dev;
  346. void __iomem *base;
  347. u8 reg_offset_shift;
  348. };
  349. struct cdns_sierra_phy {
  350. struct device *dev;
  351. const struct cdns_sierra_data *init_data;
  352. struct cdns_sierra_inst phys[SIERRA_MAX_LANES];
  353. struct reset_control *phy_rst;
  354. struct reset_control *apb_rst;
  355. struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES];
  356. struct regmap *regmap_phy_pcs_common_cdb;
  357. struct regmap *regmap_phy_pcs_lane_cdb[SIERRA_MAX_LANES];
  358. struct regmap *regmap_phy_pma_common_cdb;
  359. struct regmap *regmap_phy_pma_lane_cdb[SIERRA_MAX_LANES];
  360. struct regmap *regmap_common_cdb;
  361. struct regmap_field *macro_id_type;
  362. struct regmap_field *phy_pll_cfg_1;
  363. struct regmap_field *pma_cmn_ready;
  364. struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
  365. struct regmap_field *phy_iso_link_ctrl_1[SIERRA_MAX_LANES];
  366. struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC];
  367. struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC];
  368. struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC];
  369. struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS];
  370. int nsubnodes;
  371. u32 num_lanes;
  372. bool autoconf;
  373. int already_configured;
  374. struct clk *pll_clks[SIERRA_NUM_CMN_PLLC];
  375. struct clk_hw_onecell_data clk_data;
  376. };
  377. static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
  378. {
  379. struct cdns_regmap_cdb_context *ctx = context;
  380. u32 offset = reg << ctx->reg_offset_shift;
  381. writew(val, ctx->base + offset);
  382. return 0;
  383. }
  384. static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
  385. {
  386. struct cdns_regmap_cdb_context *ctx = context;
  387. u32 offset = reg << ctx->reg_offset_shift;
  388. *val = readw(ctx->base + offset);
  389. return 0;
  390. }
  391. #define SIERRA_LANE_CDB_REGMAP_CONF(n) \
  392. { \
  393. .name = "sierra_lane" n "_cdb", \
  394. .reg_stride = 1, \
  395. .fast_io = true, \
  396. .reg_write = cdns_regmap_write, \
  397. .reg_read = cdns_regmap_read, \
  398. }
  399. static const struct regmap_config cdns_sierra_lane_cdb_config[] = {
  400. SIERRA_LANE_CDB_REGMAP_CONF("0"),
  401. SIERRA_LANE_CDB_REGMAP_CONF("1"),
  402. SIERRA_LANE_CDB_REGMAP_CONF("2"),
  403. SIERRA_LANE_CDB_REGMAP_CONF("3"),
  404. SIERRA_LANE_CDB_REGMAP_CONF("4"),
  405. SIERRA_LANE_CDB_REGMAP_CONF("5"),
  406. SIERRA_LANE_CDB_REGMAP_CONF("6"),
  407. SIERRA_LANE_CDB_REGMAP_CONF("7"),
  408. SIERRA_LANE_CDB_REGMAP_CONF("8"),
  409. SIERRA_LANE_CDB_REGMAP_CONF("9"),
  410. SIERRA_LANE_CDB_REGMAP_CONF("10"),
  411. SIERRA_LANE_CDB_REGMAP_CONF("11"),
  412. SIERRA_LANE_CDB_REGMAP_CONF("12"),
  413. SIERRA_LANE_CDB_REGMAP_CONF("13"),
  414. SIERRA_LANE_CDB_REGMAP_CONF("14"),
  415. SIERRA_LANE_CDB_REGMAP_CONF("15"),
  416. };
  417. static const struct regmap_config cdns_sierra_common_cdb_config = {
  418. .name = "sierra_common_cdb",
  419. .reg_stride = 1,
  420. .fast_io = true,
  421. .reg_write = cdns_regmap_write,
  422. .reg_read = cdns_regmap_read,
  423. };
  424. static const struct regmap_config cdns_sierra_phy_pcs_cmn_cdb_config = {
  425. .name = "sierra_phy_pcs_cmn_cdb",
  426. .reg_stride = 1,
  427. .fast_io = true,
  428. .reg_write = cdns_regmap_write,
  429. .reg_read = cdns_regmap_read,
  430. };
  431. #define SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF(n) \
  432. { \
  433. .name = "sierra_phy_pcs_lane" n "_cdb", \
  434. .reg_stride = 1, \
  435. .fast_io = true, \
  436. .reg_write = cdns_regmap_write, \
  437. .reg_read = cdns_regmap_read, \
  438. }
  439. static const struct regmap_config cdns_sierra_phy_pcs_lane_cdb_config[] = {
  440. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("0"),
  441. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("1"),
  442. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("2"),
  443. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("3"),
  444. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("4"),
  445. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("5"),
  446. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("6"),
  447. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("7"),
  448. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("8"),
  449. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("9"),
  450. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("10"),
  451. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("11"),
  452. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("12"),
  453. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("13"),
  454. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("14"),
  455. SIERRA_PHY_PCS_LANE_CDB_REGMAP_CONF("15"),
  456. };
  457. static const struct regmap_config cdns_sierra_phy_pma_cmn_cdb_config = {
  458. .name = "sierra_phy_pma_cmn_cdb",
  459. .reg_stride = 1,
  460. .fast_io = true,
  461. .reg_write = cdns_regmap_write,
  462. .reg_read = cdns_regmap_read,
  463. };
  464. #define SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF(n) \
  465. { \
  466. .name = "sierra_phy_pma_lane" n "_cdb", \
  467. .reg_stride = 1, \
  468. .fast_io = true, \
  469. .reg_write = cdns_regmap_write, \
  470. .reg_read = cdns_regmap_read, \
  471. }
  472. static const struct regmap_config cdns_sierra_phy_pma_lane_cdb_config[] = {
  473. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("0"),
  474. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("1"),
  475. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("2"),
  476. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("3"),
  477. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("4"),
  478. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("5"),
  479. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("6"),
  480. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("7"),
  481. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("8"),
  482. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("9"),
  483. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("10"),
  484. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("11"),
  485. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("12"),
  486. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("13"),
  487. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("14"),
  488. SIERRA_PHY_PMA_LANE_CDB_REGMAP_CONF("15"),
  489. };
  490. static int cdns_sierra_phy_init(struct phy *gphy)
  491. {
  492. struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
  493. struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
  494. const struct cdns_sierra_data *init_data = phy->init_data;
  495. const struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
  496. enum cdns_sierra_phy_type phy_type = ins->phy_type;
  497. const struct cdns_sierra_vals *phy_pma_ln_vals;
  498. enum cdns_sierra_ssc_mode ssc = ins->ssc_mode;
  499. const struct cdns_sierra_vals *pcs_cmn_vals;
  500. const struct cdns_reg_pairs *reg_pairs;
  501. struct regmap *regmap;
  502. u32 num_regs;
  503. int i, j;
  504. /* Initialise the PHY registers, unless auto configured */
  505. if (phy->autoconf || phy->already_configured || phy->nsubnodes > 1)
  506. return 0;
  507. clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
  508. clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
  509. /* PHY PCS common registers configurations */
  510. pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc];
  511. if (pcs_cmn_vals) {
  512. reg_pairs = pcs_cmn_vals->reg_pairs;
  513. num_regs = pcs_cmn_vals->num_regs;
  514. regmap = phy->regmap_phy_pcs_common_cdb;
  515. for (i = 0; i < num_regs; i++)
  516. regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
  517. }
  518. /* PHY PMA lane registers configurations */
  519. phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_type][TYPE_NONE][ssc];
  520. if (phy_pma_ln_vals) {
  521. reg_pairs = phy_pma_ln_vals->reg_pairs;
  522. num_regs = phy_pma_ln_vals->num_regs;
  523. for (i = 0; i < ins->num_lanes; i++) {
  524. regmap = phy->regmap_phy_pma_lane_cdb[i + ins->mlane];
  525. for (j = 0; j < num_regs; j++)
  526. regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
  527. }
  528. }
  529. /* PMA common registers configurations */
  530. pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc];
  531. if (pma_cmn_vals) {
  532. reg_pairs = pma_cmn_vals->reg_pairs;
  533. num_regs = pma_cmn_vals->num_regs;
  534. regmap = phy->regmap_common_cdb;
  535. for (i = 0; i < num_regs; i++)
  536. regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
  537. }
  538. /* PMA lane registers configurations */
  539. pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc];
  540. if (pma_ln_vals) {
  541. reg_pairs = pma_ln_vals->reg_pairs;
  542. num_regs = pma_ln_vals->num_regs;
  543. for (i = 0; i < ins->num_lanes; i++) {
  544. regmap = phy->regmap_lane_cdb[i + ins->mlane];
  545. for (j = 0; j < num_regs; j++)
  546. regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
  547. }
  548. }
  549. return 0;
  550. }
  551. static int cdns_sierra_phy_on(struct phy *gphy)
  552. {
  553. struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
  554. struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
  555. struct device *dev = sp->dev;
  556. u32 val;
  557. int ret;
  558. if (sp->nsubnodes == 1) {
  559. /* Take the PHY out of reset */
  560. ret = reset_control_deassert(sp->phy_rst);
  561. if (ret) {
  562. dev_err(dev, "Failed to take the PHY out of reset\n");
  563. return ret;
  564. }
  565. }
  566. /* Take the PHY lane group out of reset */
  567. ret = reset_control_deassert(ins->lnk_rst);
  568. if (ret) {
  569. dev_err(dev, "Failed to take the PHY lane out of reset\n");
  570. return ret;
  571. }
  572. if (ins->phy_type == TYPE_PCIE || ins->phy_type == TYPE_USB) {
  573. ret = regmap_field_read_poll_timeout(sp->phy_iso_link_ctrl_1[ins->mlane],
  574. val, !val, 1000, PLL_LOCK_TIME);
  575. if (ret) {
  576. dev_err(dev, "Timeout waiting for PHY status ready\n");
  577. return ret;
  578. }
  579. }
  580. /*
  581. * Wait for cmn_ready assertion
  582. * PHY_PMA_CMN_CTRL[0] == 1
  583. */
  584. ret = regmap_field_read_poll_timeout(sp->pma_cmn_ready, val, val,
  585. 1000, PLL_LOCK_TIME);
  586. if (ret) {
  587. dev_err(dev, "Timeout waiting for CMN ready\n");
  588. return ret;
  589. }
  590. ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
  591. val, val, 1000, PLL_LOCK_TIME);
  592. if (ret < 0)
  593. dev_err(dev, "PLL lock of lane failed\n");
  594. return ret;
  595. }
  596. static int cdns_sierra_phy_off(struct phy *gphy)
  597. {
  598. struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
  599. return reset_control_assert(ins->lnk_rst);
  600. }
  601. static int cdns_sierra_phy_reset(struct phy *gphy)
  602. {
  603. struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
  604. reset_control_assert(sp->phy_rst);
  605. reset_control_deassert(sp->phy_rst);
  606. return 0;
  607. };
  608. static const struct phy_ops ops = {
  609. .init = cdns_sierra_phy_init,
  610. .power_on = cdns_sierra_phy_on,
  611. .power_off = cdns_sierra_phy_off,
  612. .reset = cdns_sierra_phy_reset,
  613. .owner = THIS_MODULE,
  614. };
  615. static int cdns_sierra_noop_phy_on(struct phy *gphy)
  616. {
  617. usleep_range(5000, 10000);
  618. return 0;
  619. }
  620. static const struct phy_ops noop_ops = {
  621. .power_on = cdns_sierra_noop_phy_on,
  622. .owner = THIS_MODULE,
  623. };
  624. static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw)
  625. {
  626. struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
  627. struct regmap_field *plllc1en_field = mux->plllc1en_field;
  628. struct regmap_field *termen_field = mux->termen_field;
  629. struct regmap_field *field = mux->pfdclk_sel_preg;
  630. unsigned int val;
  631. int index;
  632. regmap_field_read(field, &val);
  633. if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) {
  634. index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val);
  635. if (index == 1) {
  636. regmap_field_write(plllc1en_field, 1);
  637. regmap_field_write(termen_field, 1);
  638. }
  639. } else {
  640. index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val);
  641. }
  642. return index;
  643. }
  644. static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
  645. {
  646. struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
  647. struct regmap_field *plllc1en_field = mux->plllc1en_field;
  648. struct regmap_field *termen_field = mux->termen_field;
  649. struct regmap_field *field = mux->pfdclk_sel_preg;
  650. int val, ret;
  651. ret = regmap_field_write(plllc1en_field, 0);
  652. ret |= regmap_field_write(termen_field, 0);
  653. if (index == 1) {
  654. ret |= regmap_field_write(plllc1en_field, 1);
  655. ret |= regmap_field_write(termen_field, 1);
  656. }
  657. if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1]))
  658. val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index];
  659. else
  660. val = cdns_sierra_pll_mux_table[CMN_PLLLC][index];
  661. ret |= regmap_field_write(field, val);
  662. return ret;
  663. }
  664. static const struct clk_ops cdns_sierra_pll_mux_ops = {
  665. .determine_rate = __clk_mux_determine_rate,
  666. .set_parent = cdns_sierra_pll_mux_set_parent,
  667. .get_parent = cdns_sierra_pll_mux_get_parent,
  668. };
  669. static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
  670. struct regmap_field *pfdclk1_sel_field,
  671. struct regmap_field *plllc1en_field,
  672. struct regmap_field *termen_field,
  673. int clk_index)
  674. {
  675. struct cdns_sierra_pll_mux *mux;
  676. struct device *dev = sp->dev;
  677. struct clk_init_data *init;
  678. char clk_name[100];
  679. int ret;
  680. mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
  681. if (!mux)
  682. return -ENOMEM;
  683. snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]);
  684. init = &mux->clk_data;
  685. init->ops = &cdns_sierra_pll_mux_ops;
  686. init->flags = CLK_SET_RATE_NO_REPARENT;
  687. init->parent_data = pll_mux_parent_data[clk_index];
  688. init->num_parents = SIERRA_NUM_CMN_PLLC_PARENTS;
  689. init->name = clk_name;
  690. mux->pfdclk_sel_preg = pfdclk1_sel_field;
  691. mux->plllc1en_field = plllc1en_field;
  692. mux->termen_field = termen_field;
  693. mux->hw.init = init;
  694. ret = devm_clk_hw_register(dev, &mux->hw);
  695. if (ret)
  696. return ret;
  697. sp->clk_data.hws[clk_index] = &mux->hw;
  698. sp->pll_clks[clk_index] = devm_clk_hw_get_clk(dev, &mux->hw,
  699. clk_names[clk_index]);
  700. return 0;
  701. }
  702. static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp)
  703. {
  704. struct regmap_field *pfdclk1_sel_field;
  705. struct regmap_field *plllc1en_field;
  706. struct regmap_field *termen_field;
  707. struct device *dev = sp->dev;
  708. int ret = 0, i, clk_index;
  709. clk_index = CDNS_SIERRA_PLL_CMNLC;
  710. for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) {
  711. pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i];
  712. plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i];
  713. termen_field = sp->cmn_refrcv_refclk_termen_preg[i];
  714. ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field,
  715. termen_field, clk_index);
  716. if (ret) {
  717. dev_err(dev, "Fail to register cmn plllc mux\n");
  718. return ret;
  719. }
  720. }
  721. return 0;
  722. }
  723. static int cdns_sierra_derived_refclk_enable(struct clk_hw *hw)
  724. {
  725. struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
  726. regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0x1);
  727. /* Programming to get 100Mhz clock output in ref_der_clk_out 5GHz VCO/50 = 100MHz */
  728. regmap_field_write(derived_refclk->cmn_plllc_clk1outdiv_preg, 0x2E);
  729. return 0;
  730. }
  731. static void cdns_sierra_derived_refclk_disable(struct clk_hw *hw)
  732. {
  733. struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
  734. regmap_field_write(derived_refclk->cmn_plllc_clk1_en_preg, 0);
  735. }
  736. static int cdns_sierra_derived_refclk_is_enabled(struct clk_hw *hw)
  737. {
  738. struct cdns_sierra_derived_refclk *derived_refclk = to_cdns_sierra_derived_refclk(hw);
  739. int val;
  740. regmap_field_read(derived_refclk->cmn_plllc_clk1_en_preg, &val);
  741. return !!val;
  742. }
  743. static const struct clk_ops cdns_sierra_derived_refclk_ops = {
  744. .enable = cdns_sierra_derived_refclk_enable,
  745. .disable = cdns_sierra_derived_refclk_disable,
  746. .is_enabled = cdns_sierra_derived_refclk_is_enabled,
  747. };
  748. static int cdns_sierra_derived_refclk_register(struct cdns_sierra_phy *sp)
  749. {
  750. struct cdns_sierra_derived_refclk *derived_refclk;
  751. struct device *dev = sp->dev;
  752. struct regmap_field *field;
  753. struct clk_init_data *init;
  754. struct regmap *regmap;
  755. char clk_name[100];
  756. int ret;
  757. derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
  758. if (!derived_refclk)
  759. return -ENOMEM;
  760. snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
  761. clk_names[CDNS_SIERRA_DERIVED_REFCLK]);
  762. init = &derived_refclk->clk_data;
  763. init->ops = &cdns_sierra_derived_refclk_ops;
  764. init->flags = 0;
  765. init->name = clk_name;
  766. regmap = sp->regmap_common_cdb;
  767. field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1outdiv_preg);
  768. if (IS_ERR(field)) {
  769. dev_err(dev, "cmn_plllc_clk1outdiv_preg reg field init failed\n");
  770. return PTR_ERR(field);
  771. }
  772. derived_refclk->cmn_plllc_clk1outdiv_preg = field;
  773. field = devm_regmap_field_alloc(dev, regmap, cmn_plllc_clk1_en_preg);
  774. if (IS_ERR(field)) {
  775. dev_err(dev, "cmn_plllc_clk1_en_preg reg field init failed\n");
  776. return PTR_ERR(field);
  777. }
  778. derived_refclk->cmn_plllc_clk1_en_preg = field;
  779. derived_refclk->hw.init = init;
  780. ret = devm_clk_hw_register(dev, &derived_refclk->hw);
  781. if (ret)
  782. return ret;
  783. sp->clk_data.hws[CDNS_SIERRA_DERIVED_REFCLK] = &derived_refclk->hw;
  784. return 0;
  785. }
  786. static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp)
  787. {
  788. struct device *dev = sp->dev;
  789. struct device_node *node = dev->of_node;
  790. of_clk_del_provider(node);
  791. }
  792. static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp)
  793. {
  794. struct device *dev = sp->dev;
  795. struct device_node *node = dev->of_node;
  796. int ret;
  797. ret = cdns_sierra_phy_register_pll_mux(sp);
  798. if (ret) {
  799. dev_err(dev, "Failed to pll mux clocks\n");
  800. return ret;
  801. }
  802. ret = cdns_sierra_derived_refclk_register(sp);
  803. if (ret) {
  804. dev_err(dev, "Failed to register derived refclk\n");
  805. return ret;
  806. }
  807. sp->clk_data.num = CDNS_SIERRA_OUTPUT_CLOCKS;
  808. ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
  809. &sp->clk_data);
  810. if (ret)
  811. dev_err(dev, "Failed to add clock provider: %s\n", node->name);
  812. return ret;
  813. }
  814. static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst,
  815. struct device_node *child)
  816. {
  817. u32 phy_type;
  818. if (of_property_read_u32(child, "reg", &inst->mlane))
  819. return -EINVAL;
  820. if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes))
  821. return -EINVAL;
  822. if (of_property_read_u32(child, "cdns,phy-type", &phy_type))
  823. return -EINVAL;
  824. switch (phy_type) {
  825. case PHY_TYPE_PCIE:
  826. inst->phy_type = TYPE_PCIE;
  827. break;
  828. case PHY_TYPE_USB3:
  829. inst->phy_type = TYPE_USB;
  830. break;
  831. case PHY_TYPE_SGMII:
  832. inst->phy_type = TYPE_SGMII;
  833. break;
  834. case PHY_TYPE_QSGMII:
  835. inst->phy_type = TYPE_QSGMII;
  836. break;
  837. default:
  838. return -EINVAL;
  839. }
  840. inst->ssc_mode = EXTERNAL_SSC;
  841. of_property_read_u32(child, "cdns,ssc-mode", &inst->ssc_mode);
  842. return 0;
  843. }
  844. static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
  845. u32 block_offset, u8 reg_offset_shift,
  846. const struct regmap_config *config)
  847. {
  848. struct cdns_regmap_cdb_context *ctx;
  849. ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
  850. if (!ctx)
  851. return ERR_PTR(-ENOMEM);
  852. ctx->dev = dev;
  853. ctx->base = base + block_offset;
  854. ctx->reg_offset_shift = reg_offset_shift;
  855. return devm_regmap_init(dev, NULL, ctx, config);
  856. }
  857. static int cdns_regfield_init(struct cdns_sierra_phy *sp)
  858. {
  859. struct device *dev = sp->dev;
  860. struct regmap_field *field;
  861. struct reg_field reg_field;
  862. struct regmap *regmap;
  863. int i;
  864. regmap = sp->regmap_common_cdb;
  865. field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
  866. if (IS_ERR(field)) {
  867. dev_err(dev, "MACRO_ID_TYPE reg field init failed\n");
  868. return PTR_ERR(field);
  869. }
  870. sp->macro_id_type = field;
  871. for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) {
  872. reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg;
  873. field = devm_regmap_field_alloc(dev, regmap, reg_field);
  874. if (IS_ERR(field)) {
  875. dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i);
  876. return PTR_ERR(field);
  877. }
  878. sp->cmn_plllc_pfdclk1_sel_preg[i] = field;
  879. reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field;
  880. field = devm_regmap_field_alloc(dev, regmap, reg_field);
  881. if (IS_ERR(field)) {
  882. dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i);
  883. return PTR_ERR(field);
  884. }
  885. sp->cmn_refrcv_refclk_plllc1en_preg[i] = field;
  886. reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field;
  887. field = devm_regmap_field_alloc(dev, regmap, reg_field);
  888. if (IS_ERR(field)) {
  889. dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i);
  890. return PTR_ERR(field);
  891. }
  892. sp->cmn_refrcv_refclk_termen_preg[i] = field;
  893. }
  894. regmap = sp->regmap_phy_pcs_common_cdb;
  895. field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1);
  896. if (IS_ERR(field)) {
  897. dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n");
  898. return PTR_ERR(field);
  899. }
  900. sp->phy_pll_cfg_1 = field;
  901. regmap = sp->regmap_phy_pma_common_cdb;
  902. field = devm_regmap_field_alloc(dev, regmap, pma_cmn_ready);
  903. if (IS_ERR(field)) {
  904. dev_err(dev, "PHY_PMA_CMN_CTRL reg field init failed\n");
  905. return PTR_ERR(field);
  906. }
  907. sp->pma_cmn_ready = field;
  908. for (i = 0; i < SIERRA_MAX_LANES; i++) {
  909. regmap = sp->regmap_lane_cdb[i];
  910. field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
  911. if (IS_ERR(field)) {
  912. dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
  913. return PTR_ERR(field);
  914. }
  915. sp->pllctrl_lock[i] = field;
  916. }
  917. for (i = 0; i < SIERRA_MAX_LANES; i++) {
  918. regmap = sp->regmap_phy_pcs_lane_cdb[i];
  919. field = devm_regmap_field_alloc(dev, regmap, phy_iso_link_ctrl_1);
  920. if (IS_ERR(field)) {
  921. dev_err(dev, "PHY_ISO_LINK_CTRL reg field init for lane %d failed\n", i);
  922. return PTR_ERR(field);
  923. }
  924. sp->phy_iso_link_ctrl_1[i] = field;
  925. }
  926. return 0;
  927. }
  928. static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
  929. void __iomem *base, u8 block_offset_shift,
  930. u8 reg_offset_shift)
  931. {
  932. struct device *dev = sp->dev;
  933. struct regmap *regmap;
  934. u32 block_offset;
  935. int i;
  936. for (i = 0; i < SIERRA_MAX_LANES; i++) {
  937. block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift,
  938. reg_offset_shift);
  939. regmap = cdns_regmap_init(dev, base, block_offset,
  940. reg_offset_shift,
  941. &cdns_sierra_lane_cdb_config[i]);
  942. if (IS_ERR(regmap)) {
  943. dev_err(dev, "Failed to init lane CDB regmap\n");
  944. return PTR_ERR(regmap);
  945. }
  946. sp->regmap_lane_cdb[i] = regmap;
  947. }
  948. regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET,
  949. reg_offset_shift,
  950. &cdns_sierra_common_cdb_config);
  951. if (IS_ERR(regmap)) {
  952. dev_err(dev, "Failed to init common CDB regmap\n");
  953. return PTR_ERR(regmap);
  954. }
  955. sp->regmap_common_cdb = regmap;
  956. block_offset = SIERRA_PHY_PCS_COMMON_OFFSET(block_offset_shift);
  957. regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
  958. &cdns_sierra_phy_pcs_cmn_cdb_config);
  959. if (IS_ERR(regmap)) {
  960. dev_err(dev, "Failed to init PHY PCS common CDB regmap\n");
  961. return PTR_ERR(regmap);
  962. }
  963. sp->regmap_phy_pcs_common_cdb = regmap;
  964. for (i = 0; i < SIERRA_MAX_LANES; i++) {
  965. block_offset = SIERRA_PHY_PCS_LANE_CDB_OFFSET(i, block_offset_shift,
  966. reg_offset_shift);
  967. regmap = cdns_regmap_init(dev, base, block_offset,
  968. reg_offset_shift,
  969. &cdns_sierra_phy_pcs_lane_cdb_config[i]);
  970. if (IS_ERR(regmap)) {
  971. dev_err(dev, "Failed to init PHY PCS lane CDB regmap\n");
  972. return PTR_ERR(regmap);
  973. }
  974. sp->regmap_phy_pcs_lane_cdb[i] = regmap;
  975. }
  976. block_offset = SIERRA_PHY_PMA_COMMON_OFFSET(block_offset_shift);
  977. regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
  978. &cdns_sierra_phy_pma_cmn_cdb_config);
  979. if (IS_ERR(regmap)) {
  980. dev_err(dev, "Failed to init PHY PMA common CDB regmap\n");
  981. return PTR_ERR(regmap);
  982. }
  983. sp->regmap_phy_pma_common_cdb = regmap;
  984. for (i = 0; i < SIERRA_MAX_LANES; i++) {
  985. block_offset = SIERRA_PHY_PMA_LANE_CDB_OFFSET(i, block_offset_shift,
  986. reg_offset_shift);
  987. regmap = cdns_regmap_init(dev, base, block_offset,
  988. reg_offset_shift,
  989. &cdns_sierra_phy_pma_lane_cdb_config[i]);
  990. if (IS_ERR(regmap)) {
  991. dev_err(dev, "Failed to init PHY PMA lane CDB regmap\n");
  992. return PTR_ERR(regmap);
  993. }
  994. sp->regmap_phy_pma_lane_cdb[i] = regmap;
  995. }
  996. return 0;
  997. }
  998. static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,
  999. struct device *dev)
  1000. {
  1001. struct clk *clk;
  1002. int ret;
  1003. clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
  1004. if (IS_ERR(clk)) {
  1005. dev_err(dev, "cmn_refclk_dig_div clock not found\n");
  1006. ret = PTR_ERR(clk);
  1007. return ret;
  1008. }
  1009. sp->input_clks[CMN_REFCLK_DIG_DIV] = clk;
  1010. clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
  1011. if (IS_ERR(clk)) {
  1012. dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
  1013. ret = PTR_ERR(clk);
  1014. return ret;
  1015. }
  1016. sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk;
  1017. return 0;
  1018. }
  1019. static int cdns_sierra_phy_clk(struct cdns_sierra_phy *sp)
  1020. {
  1021. struct device *dev = sp->dev;
  1022. struct clk *clk;
  1023. int ret;
  1024. clk = devm_clk_get_optional(dev, "phy_clk");
  1025. if (IS_ERR(clk)) {
  1026. dev_err(dev, "failed to get clock phy_clk\n");
  1027. return PTR_ERR(clk);
  1028. }
  1029. sp->input_clks[PHY_CLK] = clk;
  1030. ret = clk_prepare_enable(sp->input_clks[PHY_CLK]);
  1031. if (ret)
  1032. return ret;
  1033. return 0;
  1034. }
  1035. static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp)
  1036. {
  1037. int ret;
  1038. ret = clk_prepare_enable(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC]);
  1039. if (ret)
  1040. return ret;
  1041. ret = clk_prepare_enable(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC1]);
  1042. if (ret)
  1043. goto err_pll_cmnlc1;
  1044. return 0;
  1045. err_pll_cmnlc1:
  1046. clk_disable_unprepare(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC]);
  1047. return ret;
  1048. }
  1049. static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp)
  1050. {
  1051. clk_disable_unprepare(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC1]);
  1052. clk_disable_unprepare(sp->pll_clks[CDNS_SIERRA_PLL_CMNLC]);
  1053. if (!sp->already_configured)
  1054. clk_disable_unprepare(sp->input_clks[PHY_CLK]);
  1055. }
  1056. static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp,
  1057. struct device *dev)
  1058. {
  1059. struct reset_control *rst;
  1060. rst = devm_reset_control_get_exclusive(dev, "sierra_reset");
  1061. if (IS_ERR(rst)) {
  1062. dev_err(dev, "failed to get reset\n");
  1063. return PTR_ERR(rst);
  1064. }
  1065. sp->phy_rst = rst;
  1066. rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb");
  1067. if (IS_ERR(rst)) {
  1068. dev_err(dev, "failed to get apb reset\n");
  1069. return PTR_ERR(rst);
  1070. }
  1071. sp->apb_rst = rst;
  1072. return 0;
  1073. }
  1074. static int cdns_sierra_phy_configure_multilink(struct cdns_sierra_phy *sp)
  1075. {
  1076. const struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
  1077. const struct cdns_sierra_data *init_data = sp->init_data;
  1078. const struct cdns_sierra_vals *phy_pma_ln_vals;
  1079. const struct cdns_sierra_vals *pcs_cmn_vals;
  1080. enum cdns_sierra_phy_type phy_t1, phy_t2;
  1081. const struct cdns_reg_pairs *reg_pairs;
  1082. int i, j, node, mlane, num_lanes, ret;
  1083. enum cdns_sierra_ssc_mode ssc;
  1084. struct regmap *regmap;
  1085. u32 num_regs;
  1086. /* Maximum 2 links (subnodes) are supported */
  1087. if (sp->nsubnodes != 2)
  1088. return -EINVAL;
  1089. clk_set_rate(sp->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
  1090. clk_set_rate(sp->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
  1091. /* PHY configured to use both PLL LC and LC1 */
  1092. regmap_field_write(sp->phy_pll_cfg_1, 0x1);
  1093. phy_t1 = sp->phys[0].phy_type;
  1094. phy_t2 = sp->phys[1].phy_type;
  1095. /*
  1096. * PHY configuration for multi-link operation is done in two steps.
  1097. * e.g. Consider a case for a 4 lane PHY with PCIe using 2 lanes and QSGMII other 2 lanes.
  1098. * Sierra PHY has 2 PLLs, viz. PLLLC and PLLLC1. So in this case, PLLLC is used for PCIe
  1099. * and PLLLC1 is used for QSGMII. PHY is configured in two steps as described below.
  1100. *
  1101. * [1] For first step, phy_t1 = TYPE_PCIE and phy_t2 = TYPE_QSGMII
  1102. * So the register values are selected as [TYPE_PCIE][TYPE_QSGMII][ssc].
  1103. * This will configure PHY registers associated for PCIe (i.e. first protocol)
  1104. * involving PLLLC registers and registers for first 2 lanes of PHY.
  1105. * [2] In second step, the variables phy_t1 and phy_t2 are swapped. So now,
  1106. * phy_t1 = TYPE_QSGMII and phy_t2 = TYPE_PCIE. And the register values are selected as
  1107. * [TYPE_QSGMII][TYPE_PCIE][ssc].
  1108. * This will configure PHY registers associated for QSGMII (i.e. second protocol)
  1109. * involving PLLLC1 registers and registers for other 2 lanes of PHY.
  1110. *
  1111. * This completes the PHY configuration for multilink operation. This approach enables
  1112. * dividing the large number of PHY register configurations into protocol specific
  1113. * smaller groups.
  1114. */
  1115. for (node = 0; node < sp->nsubnodes; node++) {
  1116. if (node == 1) {
  1117. /*
  1118. * If first link with phy_t1 is configured, then configure the PHY for
  1119. * second link with phy_t2. Get the array values as [phy_t2][phy_t1][ssc].
  1120. */
  1121. swap(phy_t1, phy_t2);
  1122. }
  1123. mlane = sp->phys[node].mlane;
  1124. ssc = sp->phys[node].ssc_mode;
  1125. num_lanes = sp->phys[node].num_lanes;
  1126. /* PHY PCS common registers configurations */
  1127. pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc];
  1128. if (pcs_cmn_vals) {
  1129. reg_pairs = pcs_cmn_vals->reg_pairs;
  1130. num_regs = pcs_cmn_vals->num_regs;
  1131. regmap = sp->regmap_phy_pcs_common_cdb;
  1132. for (i = 0; i < num_regs; i++)
  1133. regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
  1134. }
  1135. /* PHY PMA lane registers configurations */
  1136. phy_pma_ln_vals = init_data->phy_pma_ln_vals[phy_t1][phy_t2][ssc];
  1137. if (phy_pma_ln_vals) {
  1138. reg_pairs = phy_pma_ln_vals->reg_pairs;
  1139. num_regs = phy_pma_ln_vals->num_regs;
  1140. for (i = 0; i < num_lanes; i++) {
  1141. regmap = sp->regmap_phy_pma_lane_cdb[i + mlane];
  1142. for (j = 0; j < num_regs; j++)
  1143. regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
  1144. }
  1145. }
  1146. /* PMA common registers configurations */
  1147. pma_cmn_vals = init_data->pma_cmn_vals[phy_t1][phy_t2][ssc];
  1148. if (pma_cmn_vals) {
  1149. reg_pairs = pma_cmn_vals->reg_pairs;
  1150. num_regs = pma_cmn_vals->num_regs;
  1151. regmap = sp->regmap_common_cdb;
  1152. for (i = 0; i < num_regs; i++)
  1153. regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
  1154. }
  1155. /* PMA lane registers configurations */
  1156. pma_ln_vals = init_data->pma_ln_vals[phy_t1][phy_t2][ssc];
  1157. if (pma_ln_vals) {
  1158. reg_pairs = pma_ln_vals->reg_pairs;
  1159. num_regs = pma_ln_vals->num_regs;
  1160. for (i = 0; i < num_lanes; i++) {
  1161. regmap = sp->regmap_lane_cdb[i + mlane];
  1162. for (j = 0; j < num_regs; j++)
  1163. regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
  1164. }
  1165. }
  1166. if (phy_t1 == TYPE_SGMII || phy_t1 == TYPE_QSGMII)
  1167. reset_control_deassert(sp->phys[node].lnk_rst);
  1168. }
  1169. /* Take the PHY out of reset */
  1170. ret = reset_control_deassert(sp->phy_rst);
  1171. if (ret)
  1172. return ret;
  1173. return 0;
  1174. }
  1175. static int cdns_sierra_phy_probe(struct platform_device *pdev)
  1176. {
  1177. struct cdns_sierra_phy *sp;
  1178. struct phy_provider *phy_provider;
  1179. struct device *dev = &pdev->dev;
  1180. const struct cdns_sierra_data *data;
  1181. unsigned int id_value;
  1182. int ret, node = 0;
  1183. void __iomem *base;
  1184. struct device_node *dn = dev->of_node;
  1185. if (of_get_child_count(dn) == 0)
  1186. return -ENODEV;
  1187. /* Get init data for this PHY */
  1188. data = of_device_get_match_data(dev);
  1189. if (!data)
  1190. return -EINVAL;
  1191. sp = devm_kzalloc(dev, struct_size(sp, clk_data.hws,
  1192. CDNS_SIERRA_OUTPUT_CLOCKS),
  1193. GFP_KERNEL);
  1194. if (!sp)
  1195. return -ENOMEM;
  1196. dev_set_drvdata(dev, sp);
  1197. sp->dev = dev;
  1198. sp->init_data = data;
  1199. base = devm_platform_ioremap_resource(pdev, 0);
  1200. if (IS_ERR(base)) {
  1201. dev_err(dev, "missing \"reg\"\n");
  1202. return PTR_ERR(base);
  1203. }
  1204. ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift,
  1205. data->reg_offset_shift);
  1206. if (ret)
  1207. return ret;
  1208. ret = cdns_regfield_init(sp);
  1209. if (ret)
  1210. return ret;
  1211. platform_set_drvdata(pdev, sp);
  1212. ret = cdns_sierra_phy_get_clocks(sp, dev);
  1213. if (ret)
  1214. return ret;
  1215. ret = cdns_sierra_clk_register(sp);
  1216. if (ret)
  1217. return ret;
  1218. ret = cdns_sierra_phy_enable_clocks(sp);
  1219. if (ret)
  1220. goto unregister_clk;
  1221. regmap_field_read(sp->pma_cmn_ready, &sp->already_configured);
  1222. if (!sp->already_configured) {
  1223. ret = cdns_sierra_phy_clk(sp);
  1224. if (ret)
  1225. goto clk_disable;
  1226. ret = cdns_sierra_phy_get_resets(sp, dev);
  1227. if (ret)
  1228. goto clk_disable;
  1229. /* Enable APB */
  1230. reset_control_deassert(sp->apb_rst);
  1231. }
  1232. /* Check that PHY is present */
  1233. regmap_field_read(sp->macro_id_type, &id_value);
  1234. if (sp->init_data->id_value != id_value) {
  1235. ret = -EINVAL;
  1236. goto ctrl_assert;
  1237. }
  1238. sp->autoconf = of_property_read_bool(dn, "cdns,autoconf");
  1239. for_each_available_child_of_node_scoped(dn, child) {
  1240. struct phy *gphy;
  1241. if (!(of_node_name_eq(child, "phy") ||
  1242. of_node_name_eq(child, "link")))
  1243. continue;
  1244. sp->phys[node].lnk_rst =
  1245. of_reset_control_array_get_exclusive(child);
  1246. if (IS_ERR(sp->phys[node].lnk_rst)) {
  1247. dev_err(dev, "failed to get reset %s\n",
  1248. child->full_name);
  1249. ret = PTR_ERR(sp->phys[node].lnk_rst);
  1250. goto put_control;
  1251. }
  1252. if (!sp->autoconf) {
  1253. ret = cdns_sierra_get_optional(&sp->phys[node], child);
  1254. if (ret) {
  1255. dev_err(dev, "missing property in node %s\n",
  1256. child->name);
  1257. reset_control_put(sp->phys[node].lnk_rst);
  1258. goto put_control;
  1259. }
  1260. }
  1261. sp->num_lanes += sp->phys[node].num_lanes;
  1262. if (!sp->already_configured)
  1263. gphy = devm_phy_create(dev, child, &ops);
  1264. else
  1265. gphy = devm_phy_create(dev, child, &noop_ops);
  1266. if (IS_ERR(gphy)) {
  1267. ret = PTR_ERR(gphy);
  1268. reset_control_put(sp->phys[node].lnk_rst);
  1269. goto put_control;
  1270. }
  1271. sp->phys[node].phy = gphy;
  1272. phy_set_drvdata(gphy, &sp->phys[node]);
  1273. node++;
  1274. }
  1275. sp->nsubnodes = node;
  1276. if (sp->num_lanes > SIERRA_MAX_LANES) {
  1277. ret = -EINVAL;
  1278. dev_err(dev, "Invalid lane configuration\n");
  1279. goto put_control;
  1280. }
  1281. /* If more than one subnode, configure the PHY as multilink */
  1282. if (!sp->already_configured && !sp->autoconf && sp->nsubnodes > 1) {
  1283. ret = cdns_sierra_phy_configure_multilink(sp);
  1284. if (ret)
  1285. goto put_control;
  1286. }
  1287. pm_runtime_enable(dev);
  1288. phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
  1289. if (IS_ERR(phy_provider)) {
  1290. ret = PTR_ERR(phy_provider);
  1291. goto put_control;
  1292. }
  1293. return 0;
  1294. put_control:
  1295. while (--node >= 0)
  1296. reset_control_put(sp->phys[node].lnk_rst);
  1297. ctrl_assert:
  1298. if (!sp->already_configured)
  1299. reset_control_assert(sp->apb_rst);
  1300. clk_disable:
  1301. cdns_sierra_phy_disable_clocks(sp);
  1302. unregister_clk:
  1303. cdns_sierra_clk_unregister(sp);
  1304. return ret;
  1305. }
  1306. static void cdns_sierra_phy_remove(struct platform_device *pdev)
  1307. {
  1308. struct cdns_sierra_phy *phy = platform_get_drvdata(pdev);
  1309. int i;
  1310. reset_control_assert(phy->phy_rst);
  1311. reset_control_assert(phy->apb_rst);
  1312. pm_runtime_disable(&pdev->dev);
  1313. cdns_sierra_phy_disable_clocks(phy);
  1314. /*
  1315. * The device level resets will be put automatically.
  1316. * Need to put the subnode resets here though.
  1317. */
  1318. for (i = 0; i < phy->nsubnodes; i++) {
  1319. reset_control_assert(phy->phys[i].lnk_rst);
  1320. reset_control_put(phy->phys[i].lnk_rst);
  1321. }
  1322. cdns_sierra_clk_unregister(phy);
  1323. }
  1324. /* SGMII PHY PMA lane configuration */
  1325. static const struct cdns_reg_pairs sgmii_phy_pma_ln_regs[] = {
  1326. {0x9010, SIERRA_PHY_PMA_XCVR_CTRL}
  1327. };
  1328. static const struct cdns_sierra_vals sgmii_phy_pma_ln_vals = {
  1329. .reg_pairs = sgmii_phy_pma_ln_regs,
  1330. .num_regs = ARRAY_SIZE(sgmii_phy_pma_ln_regs),
  1331. };
  1332. /* SGMII refclk 100MHz, no ssc, opt3 and GE1 links using PLL LC1 */
  1333. static const struct cdns_reg_pairs sgmii_100_no_ssc_plllc1_opt3_cmn_regs[] = {
  1334. {0x002D, SIERRA_CMN_PLLLC1_FBDIV_INT_PREG},
  1335. {0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG},
  1336. {0x1005, SIERRA_CMN_PLLLC1_CLK0_PREG},
  1337. {0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG},
  1338. {0x0800, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG}
  1339. };
  1340. static const struct cdns_reg_pairs sgmii_100_no_ssc_plllc1_opt3_ln_regs[] = {
  1341. {0x688E, SIERRA_DET_STANDEC_D_PREG},
  1342. {0x0004, SIERRA_PSC_LN_IDLE_PREG},
  1343. {0x0FFE, SIERRA_PSC_RX_A0_PREG},
  1344. {0x0106, SIERRA_PLLCTRL_FBDIV_MODE01_PREG},
  1345. {0x0013, SIERRA_PLLCTRL_SUBRATE_PREG},
  1346. {0x0003, SIERRA_PLLCTRL_GEN_A_PREG},
  1347. {0x0106, SIERRA_PLLCTRL_GEN_D_PREG},
  1348. {0x5231, SIERRA_PLLCTRL_CPGAIN_MODE_PREG },
  1349. {0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
  1350. {0x9702, SIERRA_DRVCTRL_BOOST_PREG},
  1351. {0x0051, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1352. {0x3C0E, SIERRA_CREQ_CCLKDET_MODE01_PREG},
  1353. {0x3220, SIERRA_CREQ_FSMCLK_SEL_PREG},
  1354. {0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
  1355. {0x0002, SIERRA_DEQ_PHALIGN_CTRL},
  1356. {0x0186, SIERRA_DEQ_GLUT0},
  1357. {0x0186, SIERRA_DEQ_GLUT1},
  1358. {0x0186, SIERRA_DEQ_GLUT2},
  1359. {0x0186, SIERRA_DEQ_GLUT3},
  1360. {0x0186, SIERRA_DEQ_GLUT4},
  1361. {0x0861, SIERRA_DEQ_ALUT0},
  1362. {0x07E0, SIERRA_DEQ_ALUT1},
  1363. {0x079E, SIERRA_DEQ_ALUT2},
  1364. {0x071D, SIERRA_DEQ_ALUT3},
  1365. {0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG},
  1366. {0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
  1367. {0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1368. {0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG},
  1369. {0x0033, SIERRA_DEQ_PICTRL_PREG},
  1370. {0x0000, SIERRA_CPI_OUTBUF_RATESEL_PREG},
  1371. {0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG},
  1372. {0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1373. {0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG}
  1374. };
  1375. static const struct cdns_sierra_vals sgmii_100_no_ssc_plllc1_opt3_cmn_vals = {
  1376. .reg_pairs = sgmii_100_no_ssc_plllc1_opt3_cmn_regs,
  1377. .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_plllc1_opt3_cmn_regs),
  1378. };
  1379. static const struct cdns_sierra_vals sgmii_100_no_ssc_plllc1_opt3_ln_vals = {
  1380. .reg_pairs = sgmii_100_no_ssc_plllc1_opt3_ln_regs,
  1381. .num_regs = ARRAY_SIZE(sgmii_100_no_ssc_plllc1_opt3_ln_regs),
  1382. };
  1383. /* QSGMII PHY PMA lane configuration */
  1384. static const struct cdns_reg_pairs qsgmii_phy_pma_ln_regs[] = {
  1385. {0x9010, SIERRA_PHY_PMA_XCVR_CTRL}
  1386. };
  1387. static const struct cdns_sierra_vals qsgmii_phy_pma_ln_vals = {
  1388. .reg_pairs = qsgmii_phy_pma_ln_regs,
  1389. .num_regs = ARRAY_SIZE(qsgmii_phy_pma_ln_regs),
  1390. };
  1391. /* QSGMII refclk 100MHz, 20b, opt1, No BW cal, no ssc, PLL LC1 */
  1392. static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_cmn_regs[] = {
  1393. {0x2085, SIERRA_CMN_PLLLC1_LF_COEFF_MODE0_PREG},
  1394. {0x0000, SIERRA_CMN_PLLLC1_BWCAL_MODE0_PREG},
  1395. {0x0000, SIERRA_CMN_PLLLC1_SS_TIME_STEPSIZE_MODE_PREG}
  1396. };
  1397. static const struct cdns_reg_pairs qsgmii_100_no_ssc_plllc1_ln_regs[] = {
  1398. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1399. {0x0252, SIERRA_DET_STANDEC_E_PREG},
  1400. {0x0004, SIERRA_PSC_LN_IDLE_PREG},
  1401. {0x0FFE, SIERRA_PSC_RX_A0_PREG},
  1402. {0x0011, SIERRA_PLLCTRL_SUBRATE_PREG},
  1403. {0x0001, SIERRA_PLLCTRL_GEN_A_PREG},
  1404. {0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
  1405. {0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
  1406. {0x0089, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1407. {0x3C3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
  1408. {0x3222, SIERRA_CREQ_FSMCLK_SEL_PREG},
  1409. {0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
  1410. {0x8422, SIERRA_CTLELUT_CTRL_PREG},
  1411. {0x4111, SIERRA_DFE_ECMP_RATESEL_PREG},
  1412. {0x4111, SIERRA_DFE_SMP_RATESEL_PREG},
  1413. {0x0002, SIERRA_DEQ_PHALIGN_CTRL},
  1414. {0x9595, SIERRA_DEQ_VGATUNE_CTRL_PREG},
  1415. {0x0186, SIERRA_DEQ_GLUT0},
  1416. {0x0186, SIERRA_DEQ_GLUT1},
  1417. {0x0186, SIERRA_DEQ_GLUT2},
  1418. {0x0186, SIERRA_DEQ_GLUT3},
  1419. {0x0186, SIERRA_DEQ_GLUT4},
  1420. {0x0861, SIERRA_DEQ_ALUT0},
  1421. {0x07E0, SIERRA_DEQ_ALUT1},
  1422. {0x079E, SIERRA_DEQ_ALUT2},
  1423. {0x071D, SIERRA_DEQ_ALUT3},
  1424. {0x03F5, SIERRA_DEQ_DFETAP_CTRL_PREG},
  1425. {0x0C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
  1426. {0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1427. {0x1C04, SIERRA_DEQ_TAU_CTRL2_PREG},
  1428. {0x0033, SIERRA_DEQ_PICTRL_PREG},
  1429. {0x0660, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
  1430. {0x00D5, SIERRA_CPI_OUTBUF_RATESEL_PREG},
  1431. {0x0B6D, SIERRA_CPI_RESBIAS_BIN_PREG},
  1432. {0x0102, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1433. {0x0002, SIERRA_RXBUFFER_RCDFECTRL_PREG}
  1434. };
  1435. static const struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_cmn_vals = {
  1436. .reg_pairs = qsgmii_100_no_ssc_plllc1_cmn_regs,
  1437. .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_cmn_regs),
  1438. };
  1439. static const struct cdns_sierra_vals qsgmii_100_no_ssc_plllc1_ln_vals = {
  1440. .reg_pairs = qsgmii_100_no_ssc_plllc1_ln_regs,
  1441. .num_regs = ARRAY_SIZE(qsgmii_100_no_ssc_plllc1_ln_regs),
  1442. };
  1443. /* PCIE PHY PCS common configuration */
  1444. static const struct cdns_reg_pairs pcie_phy_pcs_cmn_regs[] = {
  1445. {0x0430, SIERRA_PHY_PIPE_CMN_CTRL1}
  1446. };
  1447. static const struct cdns_sierra_vals pcie_phy_pcs_cmn_vals = {
  1448. .reg_pairs = pcie_phy_pcs_cmn_regs,
  1449. .num_regs = ARRAY_SIZE(pcie_phy_pcs_cmn_regs),
  1450. };
  1451. /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc, pcie_links_using_plllc, pipe_bw_3 */
  1452. static const struct cdns_reg_pairs pcie_100_no_ssc_plllc_cmn_regs[] = {
  1453. {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
  1454. {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
  1455. {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
  1456. {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
  1457. };
  1458. /*
  1459. * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
  1460. * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
  1461. */
  1462. static const struct cdns_reg_pairs ml_pcie_100_no_ssc_ln_regs[] = {
  1463. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1464. {0x001D, SIERRA_PSM_A3IN_TMR_PREG},
  1465. {0x0004, SIERRA_PSC_LN_A3_PREG},
  1466. {0x0004, SIERRA_PSC_LN_A4_PREG},
  1467. {0x0004, SIERRA_PSC_LN_IDLE_PREG},
  1468. {0x1555, SIERRA_DFE_BIASTRIM_PREG},
  1469. {0x9703, SIERRA_DRVCTRL_BOOST_PREG},
  1470. {0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
  1471. {0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
  1472. {0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  1473. {0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1474. {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
  1475. {0x9800, SIERRA_RX_CTLE_CAL_PREG},
  1476. {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  1477. {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  1478. {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  1479. {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  1480. {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
  1481. {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
  1482. {0x0041, SIERRA_DEQ_GLUT0},
  1483. {0x0082, SIERRA_DEQ_GLUT1},
  1484. {0x00C3, SIERRA_DEQ_GLUT2},
  1485. {0x0145, SIERRA_DEQ_GLUT3},
  1486. {0x0186, SIERRA_DEQ_GLUT4},
  1487. {0x09E7, SIERRA_DEQ_ALUT0},
  1488. {0x09A6, SIERRA_DEQ_ALUT1},
  1489. {0x0965, SIERRA_DEQ_ALUT2},
  1490. {0x08E3, SIERRA_DEQ_ALUT3},
  1491. {0x00FA, SIERRA_DEQ_DFETAP0},
  1492. {0x00FA, SIERRA_DEQ_DFETAP1},
  1493. {0x00FA, SIERRA_DEQ_DFETAP2},
  1494. {0x00FA, SIERRA_DEQ_DFETAP3},
  1495. {0x00FA, SIERRA_DEQ_DFETAP4},
  1496. {0x000F, SIERRA_DEQ_PRECUR_PREG},
  1497. {0x0280, SIERRA_DEQ_POSTCUR_PREG},
  1498. {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
  1499. {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1500. {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
  1501. {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
  1502. {0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
  1503. {0x002B, SIERRA_CPI_TRIM_PREG},
  1504. {0x0003, SIERRA_EPI_CTRL_PREG},
  1505. {0x803F, SIERRA_SDFILT_H2L_A_PREG},
  1506. {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1507. {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  1508. {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
  1509. };
  1510. static const struct cdns_sierra_vals pcie_100_no_ssc_plllc_cmn_vals = {
  1511. .reg_pairs = pcie_100_no_ssc_plllc_cmn_regs,
  1512. .num_regs = ARRAY_SIZE(pcie_100_no_ssc_plllc_cmn_regs),
  1513. };
  1514. static const struct cdns_sierra_vals ml_pcie_100_no_ssc_ln_vals = {
  1515. .reg_pairs = ml_pcie_100_no_ssc_ln_regs,
  1516. .num_regs = ARRAY_SIZE(ml_pcie_100_no_ssc_ln_regs),
  1517. };
  1518. /*
  1519. * TI J721E:
  1520. * refclk100MHz_32b_PCIe_ln_no_ssc, multilink, using_plllc,
  1521. * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
  1522. */
  1523. static const struct cdns_reg_pairs ti_ml_pcie_100_no_ssc_ln_regs[] = {
  1524. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1525. {0x001D, SIERRA_PSM_A3IN_TMR_PREG},
  1526. {0x0004, SIERRA_PSC_LN_A3_PREG},
  1527. {0x0004, SIERRA_PSC_LN_A4_PREG},
  1528. {0x0004, SIERRA_PSC_LN_IDLE_PREG},
  1529. {0x1555, SIERRA_DFE_BIASTRIM_PREG},
  1530. {0x9703, SIERRA_DRVCTRL_BOOST_PREG},
  1531. {0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
  1532. {0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
  1533. {0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  1534. {0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1535. {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
  1536. {0x9800, SIERRA_RX_CTLE_CAL_PREG},
  1537. {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  1538. {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  1539. {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  1540. {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  1541. {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
  1542. {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
  1543. {0x0041, SIERRA_DEQ_GLUT0},
  1544. {0x0082, SIERRA_DEQ_GLUT1},
  1545. {0x00C3, SIERRA_DEQ_GLUT2},
  1546. {0x0145, SIERRA_DEQ_GLUT3},
  1547. {0x0186, SIERRA_DEQ_GLUT4},
  1548. {0x09E7, SIERRA_DEQ_ALUT0},
  1549. {0x09A6, SIERRA_DEQ_ALUT1},
  1550. {0x0965, SIERRA_DEQ_ALUT2},
  1551. {0x08E3, SIERRA_DEQ_ALUT3},
  1552. {0x00FA, SIERRA_DEQ_DFETAP0},
  1553. {0x00FA, SIERRA_DEQ_DFETAP1},
  1554. {0x00FA, SIERRA_DEQ_DFETAP2},
  1555. {0x00FA, SIERRA_DEQ_DFETAP3},
  1556. {0x00FA, SIERRA_DEQ_DFETAP4},
  1557. {0x000F, SIERRA_DEQ_PRECUR_PREG},
  1558. {0x0280, SIERRA_DEQ_POSTCUR_PREG},
  1559. {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
  1560. {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1561. {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
  1562. {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
  1563. {0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
  1564. {0x002B, SIERRA_CPI_TRIM_PREG},
  1565. {0x0003, SIERRA_EPI_CTRL_PREG},
  1566. {0x803F, SIERRA_SDFILT_H2L_A_PREG},
  1567. {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1568. {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  1569. {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
  1570. {0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
  1571. };
  1572. static const struct cdns_sierra_vals ti_ml_pcie_100_no_ssc_ln_vals = {
  1573. .reg_pairs = ti_ml_pcie_100_no_ssc_ln_regs,
  1574. .num_regs = ARRAY_SIZE(ti_ml_pcie_100_no_ssc_ln_regs),
  1575. };
  1576. /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc, pcie_links_using_plllc, pipe_bw_3 */
  1577. static const struct cdns_reg_pairs pcie_100_int_ssc_plllc_cmn_regs[] = {
  1578. {0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
  1579. {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
  1580. {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
  1581. {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
  1582. {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
  1583. {0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
  1584. {0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
  1585. {0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
  1586. {0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
  1587. {0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
  1588. {0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
  1589. };
  1590. /*
  1591. * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
  1592. * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
  1593. */
  1594. static const struct cdns_reg_pairs ml_pcie_100_int_ssc_ln_regs[] = {
  1595. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1596. {0x001D, SIERRA_PSM_A3IN_TMR_PREG},
  1597. {0x0004, SIERRA_PSC_LN_A3_PREG},
  1598. {0x0004, SIERRA_PSC_LN_A4_PREG},
  1599. {0x0004, SIERRA_PSC_LN_IDLE_PREG},
  1600. {0x1555, SIERRA_DFE_BIASTRIM_PREG},
  1601. {0x9703, SIERRA_DRVCTRL_BOOST_PREG},
  1602. {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
  1603. {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
  1604. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
  1605. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  1606. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1607. {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
  1608. {0x9800, SIERRA_RX_CTLE_CAL_PREG},
  1609. {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
  1610. {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
  1611. {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  1612. {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  1613. {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  1614. {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  1615. {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
  1616. {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
  1617. {0x0041, SIERRA_DEQ_GLUT0},
  1618. {0x0082, SIERRA_DEQ_GLUT1},
  1619. {0x00C3, SIERRA_DEQ_GLUT2},
  1620. {0x0145, SIERRA_DEQ_GLUT3},
  1621. {0x0186, SIERRA_DEQ_GLUT4},
  1622. {0x09E7, SIERRA_DEQ_ALUT0},
  1623. {0x09A6, SIERRA_DEQ_ALUT1},
  1624. {0x0965, SIERRA_DEQ_ALUT2},
  1625. {0x08E3, SIERRA_DEQ_ALUT3},
  1626. {0x00FA, SIERRA_DEQ_DFETAP0},
  1627. {0x00FA, SIERRA_DEQ_DFETAP1},
  1628. {0x00FA, SIERRA_DEQ_DFETAP2},
  1629. {0x00FA, SIERRA_DEQ_DFETAP3},
  1630. {0x00FA, SIERRA_DEQ_DFETAP4},
  1631. {0x000F, SIERRA_DEQ_PRECUR_PREG},
  1632. {0x0280, SIERRA_DEQ_POSTCUR_PREG},
  1633. {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
  1634. {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1635. {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
  1636. {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
  1637. {0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
  1638. {0x002B, SIERRA_CPI_TRIM_PREG},
  1639. {0x0003, SIERRA_EPI_CTRL_PREG},
  1640. {0x803F, SIERRA_SDFILT_H2L_A_PREG},
  1641. {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1642. {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  1643. {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
  1644. };
  1645. static const struct cdns_sierra_vals pcie_100_int_ssc_plllc_cmn_vals = {
  1646. .reg_pairs = pcie_100_int_ssc_plllc_cmn_regs,
  1647. .num_regs = ARRAY_SIZE(pcie_100_int_ssc_plllc_cmn_regs),
  1648. };
  1649. static const struct cdns_sierra_vals ml_pcie_100_int_ssc_ln_vals = {
  1650. .reg_pairs = ml_pcie_100_int_ssc_ln_regs,
  1651. .num_regs = ARRAY_SIZE(ml_pcie_100_int_ssc_ln_regs),
  1652. };
  1653. /*
  1654. * TI J721E:
  1655. * refclk100MHz_32b_PCIe_ln_int_ssc, multilink, using_plllc,
  1656. * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
  1657. */
  1658. static const struct cdns_reg_pairs ti_ml_pcie_100_int_ssc_ln_regs[] = {
  1659. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1660. {0x001D, SIERRA_PSM_A3IN_TMR_PREG},
  1661. {0x0004, SIERRA_PSC_LN_A3_PREG},
  1662. {0x0004, SIERRA_PSC_LN_A4_PREG},
  1663. {0x0004, SIERRA_PSC_LN_IDLE_PREG},
  1664. {0x1555, SIERRA_DFE_BIASTRIM_PREG},
  1665. {0x9703, SIERRA_DRVCTRL_BOOST_PREG},
  1666. {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
  1667. {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
  1668. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
  1669. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  1670. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1671. {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
  1672. {0x9800, SIERRA_RX_CTLE_CAL_PREG},
  1673. {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
  1674. {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
  1675. {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  1676. {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  1677. {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  1678. {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  1679. {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
  1680. {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
  1681. {0x0041, SIERRA_DEQ_GLUT0},
  1682. {0x0082, SIERRA_DEQ_GLUT1},
  1683. {0x00C3, SIERRA_DEQ_GLUT2},
  1684. {0x0145, SIERRA_DEQ_GLUT3},
  1685. {0x0186, SIERRA_DEQ_GLUT4},
  1686. {0x09E7, SIERRA_DEQ_ALUT0},
  1687. {0x09A6, SIERRA_DEQ_ALUT1},
  1688. {0x0965, SIERRA_DEQ_ALUT2},
  1689. {0x08E3, SIERRA_DEQ_ALUT3},
  1690. {0x00FA, SIERRA_DEQ_DFETAP0},
  1691. {0x00FA, SIERRA_DEQ_DFETAP1},
  1692. {0x00FA, SIERRA_DEQ_DFETAP2},
  1693. {0x00FA, SIERRA_DEQ_DFETAP3},
  1694. {0x00FA, SIERRA_DEQ_DFETAP4},
  1695. {0x000F, SIERRA_DEQ_PRECUR_PREG},
  1696. {0x0280, SIERRA_DEQ_POSTCUR_PREG},
  1697. {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
  1698. {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1699. {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
  1700. {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
  1701. {0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
  1702. {0x002B, SIERRA_CPI_TRIM_PREG},
  1703. {0x0003, SIERRA_EPI_CTRL_PREG},
  1704. {0x803F, SIERRA_SDFILT_H2L_A_PREG},
  1705. {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1706. {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  1707. {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
  1708. {0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
  1709. };
  1710. static const struct cdns_sierra_vals ti_ml_pcie_100_int_ssc_ln_vals = {
  1711. .reg_pairs = ti_ml_pcie_100_int_ssc_ln_regs,
  1712. .num_regs = ARRAY_SIZE(ti_ml_pcie_100_int_ssc_ln_regs),
  1713. };
  1714. /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc, pcie_links_using_plllc, pipe_bw_3 */
  1715. static const struct cdns_reg_pairs pcie_100_ext_ssc_plllc_cmn_regs[] = {
  1716. {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
  1717. {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
  1718. {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
  1719. {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
  1720. {0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
  1721. };
  1722. /*
  1723. * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
  1724. * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
  1725. */
  1726. static const struct cdns_reg_pairs ml_pcie_100_ext_ssc_ln_regs[] = {
  1727. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1728. {0x001D, SIERRA_PSM_A3IN_TMR_PREG},
  1729. {0x0004, SIERRA_PSC_LN_A3_PREG},
  1730. {0x0004, SIERRA_PSC_LN_A4_PREG},
  1731. {0x0004, SIERRA_PSC_LN_IDLE_PREG},
  1732. {0x1555, SIERRA_DFE_BIASTRIM_PREG},
  1733. {0x9703, SIERRA_DRVCTRL_BOOST_PREG},
  1734. {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
  1735. {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
  1736. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
  1737. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  1738. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1739. {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
  1740. {0x9800, SIERRA_RX_CTLE_CAL_PREG},
  1741. {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
  1742. {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
  1743. {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  1744. {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  1745. {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  1746. {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  1747. {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
  1748. {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
  1749. {0x0041, SIERRA_DEQ_GLUT0},
  1750. {0x0082, SIERRA_DEQ_GLUT1},
  1751. {0x00C3, SIERRA_DEQ_GLUT2},
  1752. {0x0145, SIERRA_DEQ_GLUT3},
  1753. {0x0186, SIERRA_DEQ_GLUT4},
  1754. {0x09E7, SIERRA_DEQ_ALUT0},
  1755. {0x09A6, SIERRA_DEQ_ALUT1},
  1756. {0x0965, SIERRA_DEQ_ALUT2},
  1757. {0x08E3, SIERRA_DEQ_ALUT3},
  1758. {0x00FA, SIERRA_DEQ_DFETAP0},
  1759. {0x00FA, SIERRA_DEQ_DFETAP1},
  1760. {0x00FA, SIERRA_DEQ_DFETAP2},
  1761. {0x00FA, SIERRA_DEQ_DFETAP3},
  1762. {0x00FA, SIERRA_DEQ_DFETAP4},
  1763. {0x000F, SIERRA_DEQ_PRECUR_PREG},
  1764. {0x0280, SIERRA_DEQ_POSTCUR_PREG},
  1765. {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
  1766. {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1767. {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
  1768. {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
  1769. {0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
  1770. {0x002B, SIERRA_CPI_TRIM_PREG},
  1771. {0x0003, SIERRA_EPI_CTRL_PREG},
  1772. {0x803F, SIERRA_SDFILT_H2L_A_PREG},
  1773. {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1774. {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  1775. {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
  1776. };
  1777. static const struct cdns_sierra_vals pcie_100_ext_ssc_plllc_cmn_vals = {
  1778. .reg_pairs = pcie_100_ext_ssc_plllc_cmn_regs,
  1779. .num_regs = ARRAY_SIZE(pcie_100_ext_ssc_plllc_cmn_regs),
  1780. };
  1781. static const struct cdns_sierra_vals ml_pcie_100_ext_ssc_ln_vals = {
  1782. .reg_pairs = ml_pcie_100_ext_ssc_ln_regs,
  1783. .num_regs = ARRAY_SIZE(ml_pcie_100_ext_ssc_ln_regs),
  1784. };
  1785. /*
  1786. * TI J721E:
  1787. * refclk100MHz_32b_PCIe_ln_ext_ssc, multilink, using_plllc,
  1788. * cmn_pllcy_anaclk0_1Ghz, xcvr_pllclk_fullrt_500mhz
  1789. */
  1790. static const struct cdns_reg_pairs ti_ml_pcie_100_ext_ssc_ln_regs[] = {
  1791. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1792. {0x001D, SIERRA_PSM_A3IN_TMR_PREG},
  1793. {0x0004, SIERRA_PSC_LN_A3_PREG},
  1794. {0x0004, SIERRA_PSC_LN_A4_PREG},
  1795. {0x0004, SIERRA_PSC_LN_IDLE_PREG},
  1796. {0x1555, SIERRA_DFE_BIASTRIM_PREG},
  1797. {0x9703, SIERRA_DRVCTRL_BOOST_PREG},
  1798. {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
  1799. {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
  1800. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
  1801. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  1802. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1803. {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
  1804. {0x9800, SIERRA_RX_CTLE_CAL_PREG},
  1805. {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
  1806. {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
  1807. {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  1808. {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  1809. {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  1810. {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  1811. {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
  1812. {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
  1813. {0x0041, SIERRA_DEQ_GLUT0},
  1814. {0x0082, SIERRA_DEQ_GLUT1},
  1815. {0x00C3, SIERRA_DEQ_GLUT2},
  1816. {0x0145, SIERRA_DEQ_GLUT3},
  1817. {0x0186, SIERRA_DEQ_GLUT4},
  1818. {0x09E7, SIERRA_DEQ_ALUT0},
  1819. {0x09A6, SIERRA_DEQ_ALUT1},
  1820. {0x0965, SIERRA_DEQ_ALUT2},
  1821. {0x08E3, SIERRA_DEQ_ALUT3},
  1822. {0x00FA, SIERRA_DEQ_DFETAP0},
  1823. {0x00FA, SIERRA_DEQ_DFETAP1},
  1824. {0x00FA, SIERRA_DEQ_DFETAP2},
  1825. {0x00FA, SIERRA_DEQ_DFETAP3},
  1826. {0x00FA, SIERRA_DEQ_DFETAP4},
  1827. {0x000F, SIERRA_DEQ_PRECUR_PREG},
  1828. {0x0280, SIERRA_DEQ_POSTCUR_PREG},
  1829. {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
  1830. {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1831. {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
  1832. {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
  1833. {0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
  1834. {0x002B, SIERRA_CPI_TRIM_PREG},
  1835. {0x0003, SIERRA_EPI_CTRL_PREG},
  1836. {0x803F, SIERRA_SDFILT_H2L_A_PREG},
  1837. {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1838. {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  1839. {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG},
  1840. {0x0002, SIERRA_TX_RCVDET_OVRD_PREG}
  1841. };
  1842. static const struct cdns_sierra_vals ti_ml_pcie_100_ext_ssc_ln_vals = {
  1843. .reg_pairs = ti_ml_pcie_100_ext_ssc_ln_regs,
  1844. .num_regs = ARRAY_SIZE(ti_ml_pcie_100_ext_ssc_ln_regs),
  1845. };
  1846. /* refclk100MHz_32b_PCIe_cmn_pll_no_ssc */
  1847. static const struct cdns_reg_pairs cdns_pcie_cmn_regs_no_ssc[] = {
  1848. {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
  1849. {0x2105, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
  1850. {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
  1851. {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG}
  1852. };
  1853. /* refclk100MHz_32b_PCIe_ln_no_ssc */
  1854. static const struct cdns_reg_pairs cdns_pcie_ln_regs_no_ssc[] = {
  1855. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1856. {0x001D, SIERRA_PSM_A3IN_TMR_PREG},
  1857. {0x1555, SIERRA_DFE_BIASTRIM_PREG},
  1858. {0x9703, SIERRA_DRVCTRL_BOOST_PREG},
  1859. {0x8055, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
  1860. {0x80BB, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
  1861. {0x8351, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  1862. {0x8349, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1863. {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
  1864. {0x9800, SIERRA_RX_CTLE_CAL_PREG},
  1865. {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  1866. {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  1867. {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  1868. {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  1869. {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
  1870. {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
  1871. {0x0041, SIERRA_DEQ_GLUT0},
  1872. {0x0082, SIERRA_DEQ_GLUT1},
  1873. {0x00C3, SIERRA_DEQ_GLUT2},
  1874. {0x0145, SIERRA_DEQ_GLUT3},
  1875. {0x0186, SIERRA_DEQ_GLUT4},
  1876. {0x09E7, SIERRA_DEQ_ALUT0},
  1877. {0x09A6, SIERRA_DEQ_ALUT1},
  1878. {0x0965, SIERRA_DEQ_ALUT2},
  1879. {0x08E3, SIERRA_DEQ_ALUT3},
  1880. {0x00FA, SIERRA_DEQ_DFETAP0},
  1881. {0x00FA, SIERRA_DEQ_DFETAP1},
  1882. {0x00FA, SIERRA_DEQ_DFETAP2},
  1883. {0x00FA, SIERRA_DEQ_DFETAP3},
  1884. {0x00FA, SIERRA_DEQ_DFETAP4},
  1885. {0x000F, SIERRA_DEQ_PRECUR_PREG},
  1886. {0x0280, SIERRA_DEQ_POSTCUR_PREG},
  1887. {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
  1888. {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1889. {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
  1890. {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
  1891. {0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
  1892. {0x002B, SIERRA_CPI_TRIM_PREG},
  1893. {0x0003, SIERRA_EPI_CTRL_PREG},
  1894. {0x803F, SIERRA_SDFILT_H2L_A_PREG},
  1895. {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1896. {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  1897. {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
  1898. };
  1899. static const struct cdns_sierra_vals pcie_100_no_ssc_cmn_vals = {
  1900. .reg_pairs = cdns_pcie_cmn_regs_no_ssc,
  1901. .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_no_ssc),
  1902. };
  1903. static const struct cdns_sierra_vals pcie_100_no_ssc_ln_vals = {
  1904. .reg_pairs = cdns_pcie_ln_regs_no_ssc,
  1905. .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_no_ssc),
  1906. };
  1907. /* refclk100MHz_32b_PCIe_cmn_pll_int_ssc */
  1908. static const struct cdns_reg_pairs cdns_pcie_cmn_regs_int_ssc[] = {
  1909. {0x000E, SIERRA_CMN_PLLLC_MODE_PREG},
  1910. {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
  1911. {0x4006, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
  1912. {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
  1913. {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
  1914. {0x0581, SIERRA_CMN_PLLLC_DSMCORR_PREG},
  1915. {0x7F80, SIERRA_CMN_PLLLC_SS_PREG},
  1916. {0x0041, SIERRA_CMN_PLLLC_SS_AMP_STEP_SIZE_PREG},
  1917. {0x0464, SIERRA_CMN_PLLLC_SSTWOPT_PREG},
  1918. {0x0D0D, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
  1919. {0x0060, SIERRA_CMN_PLLLC_LOCK_DELAY_CTRL_PREG}
  1920. };
  1921. /* refclk100MHz_32b_PCIe_ln_int_ssc */
  1922. static const struct cdns_reg_pairs cdns_pcie_ln_regs_int_ssc[] = {
  1923. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1924. {0x001D, SIERRA_PSM_A3IN_TMR_PREG},
  1925. {0x1555, SIERRA_DFE_BIASTRIM_PREG},
  1926. {0x9703, SIERRA_DRVCTRL_BOOST_PREG},
  1927. {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
  1928. {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
  1929. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
  1930. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  1931. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1932. {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
  1933. {0x9800, SIERRA_RX_CTLE_CAL_PREG},
  1934. {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
  1935. {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
  1936. {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  1937. {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  1938. {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  1939. {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  1940. {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
  1941. {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
  1942. {0x0041, SIERRA_DEQ_GLUT0},
  1943. {0x0082, SIERRA_DEQ_GLUT1},
  1944. {0x00C3, SIERRA_DEQ_GLUT2},
  1945. {0x0145, SIERRA_DEQ_GLUT3},
  1946. {0x0186, SIERRA_DEQ_GLUT4},
  1947. {0x09E7, SIERRA_DEQ_ALUT0},
  1948. {0x09A6, SIERRA_DEQ_ALUT1},
  1949. {0x0965, SIERRA_DEQ_ALUT2},
  1950. {0x08E3, SIERRA_DEQ_ALUT3},
  1951. {0x00FA, SIERRA_DEQ_DFETAP0},
  1952. {0x00FA, SIERRA_DEQ_DFETAP1},
  1953. {0x00FA, SIERRA_DEQ_DFETAP2},
  1954. {0x00FA, SIERRA_DEQ_DFETAP3},
  1955. {0x00FA, SIERRA_DEQ_DFETAP4},
  1956. {0x000F, SIERRA_DEQ_PRECUR_PREG},
  1957. {0x0280, SIERRA_DEQ_POSTCUR_PREG},
  1958. {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
  1959. {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  1960. {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
  1961. {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
  1962. {0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
  1963. {0x002B, SIERRA_CPI_TRIM_PREG},
  1964. {0x0003, SIERRA_EPI_CTRL_PREG},
  1965. {0x803F, SIERRA_SDFILT_H2L_A_PREG},
  1966. {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
  1967. {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  1968. {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
  1969. };
  1970. static const struct cdns_sierra_vals pcie_100_int_ssc_cmn_vals = {
  1971. .reg_pairs = cdns_pcie_cmn_regs_int_ssc,
  1972. .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_int_ssc),
  1973. };
  1974. static const struct cdns_sierra_vals pcie_100_int_ssc_ln_vals = {
  1975. .reg_pairs = cdns_pcie_ln_regs_int_ssc,
  1976. .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_int_ssc),
  1977. };
  1978. /* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */
  1979. static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = {
  1980. {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
  1981. {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
  1982. {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
  1983. {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
  1984. {0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
  1985. };
  1986. /* refclk100MHz_32b_PCIe_ln_ext_ssc */
  1987. static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = {
  1988. {0xFC08, SIERRA_DET_STANDEC_A_PREG},
  1989. {0x001D, SIERRA_PSM_A3IN_TMR_PREG},
  1990. {0x1555, SIERRA_DFE_BIASTRIM_PREG},
  1991. {0x9703, SIERRA_DRVCTRL_BOOST_PREG},
  1992. {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
  1993. {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
  1994. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
  1995. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  1996. {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  1997. {0x0002, SIERRA_CREQ_DCBIASATTEN_OVR_PREG},
  1998. {0x9800, SIERRA_RX_CTLE_CAL_PREG},
  1999. {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
  2000. {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
  2001. {0x5624, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  2002. {0x000F, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  2003. {0x00FF, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  2004. {0x4C4C, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  2005. {0x02FA, SIERRA_DEQ_OFFSET_CTRL_PREG},
  2006. {0x02FA, SIERRA_DEQ_GAIN_CTRL_PREG},
  2007. {0x0041, SIERRA_DEQ_GLUT0},
  2008. {0x0082, SIERRA_DEQ_GLUT1},
  2009. {0x00C3, SIERRA_DEQ_GLUT2},
  2010. {0x0145, SIERRA_DEQ_GLUT3},
  2011. {0x0186, SIERRA_DEQ_GLUT4},
  2012. {0x09E7, SIERRA_DEQ_ALUT0},
  2013. {0x09A6, SIERRA_DEQ_ALUT1},
  2014. {0x0965, SIERRA_DEQ_ALUT2},
  2015. {0x08E3, SIERRA_DEQ_ALUT3},
  2016. {0x00FA, SIERRA_DEQ_DFETAP0},
  2017. {0x00FA, SIERRA_DEQ_DFETAP1},
  2018. {0x00FA, SIERRA_DEQ_DFETAP2},
  2019. {0x00FA, SIERRA_DEQ_DFETAP3},
  2020. {0x00FA, SIERRA_DEQ_DFETAP4},
  2021. {0x000F, SIERRA_DEQ_PRECUR_PREG},
  2022. {0x0280, SIERRA_DEQ_POSTCUR_PREG},
  2023. {0x8F00, SIERRA_DEQ_POSTCUR_DECR_PREG},
  2024. {0x3C0F, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  2025. {0x1C0C, SIERRA_DEQ_TAU_CTRL2_PREG},
  2026. {0x0100, SIERRA_DEQ_TAU_CTRL3_PREG},
  2027. {0x5E82, SIERRA_DEQ_TAU_EPIOFFSET_MODE_PREG},
  2028. {0x002B, SIERRA_CPI_TRIM_PREG},
  2029. {0x0003, SIERRA_EPI_CTRL_PREG},
  2030. {0x803F, SIERRA_SDFILT_H2L_A_PREG},
  2031. {0x0004, SIERRA_RXBUFFER_CTLECTRL_PREG},
  2032. {0x2010, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  2033. {0x4432, SIERRA_RXBUFFER_DFECTRL_PREG}
  2034. };
  2035. static const struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = {
  2036. .reg_pairs = cdns_pcie_cmn_regs_ext_ssc,
  2037. .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
  2038. };
  2039. static const struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = {
  2040. .reg_pairs = cdns_pcie_ln_regs_ext_ssc,
  2041. .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
  2042. };
  2043. /* refclk100MHz_20b_USB_cmn_pll_ext_ssc */
  2044. static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
  2045. {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
  2046. {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
  2047. {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
  2048. {0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
  2049. };
  2050. /* refclk100MHz_20b_USB_ln_ext_ssc */
  2051. static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
  2052. {0xFE0A, SIERRA_DET_STANDEC_A_PREG},
  2053. {0x000F, SIERRA_DET_STANDEC_B_PREG},
  2054. {0x55A5, SIERRA_DET_STANDEC_C_PREG},
  2055. {0x69ad, SIERRA_DET_STANDEC_D_PREG},
  2056. {0x0241, SIERRA_DET_STANDEC_E_PREG},
  2057. {0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
  2058. {0x0014, SIERRA_PSM_A0IN_TMR_PREG},
  2059. {0xCF00, SIERRA_PSM_DIAG_PREG},
  2060. {0x001F, SIERRA_PSC_TX_A0_PREG},
  2061. {0x0007, SIERRA_PSC_TX_A1_PREG},
  2062. {0x0003, SIERRA_PSC_TX_A2_PREG},
  2063. {0x0003, SIERRA_PSC_TX_A3_PREG},
  2064. {0x0FFF, SIERRA_PSC_RX_A0_PREG},
  2065. {0x0003, SIERRA_PSC_RX_A1_PREG},
  2066. {0x0003, SIERRA_PSC_RX_A2_PREG},
  2067. {0x0001, SIERRA_PSC_RX_A3_PREG},
  2068. {0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
  2069. {0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
  2070. {0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
  2071. {0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
  2072. {0x2512, SIERRA_DFE_BIASTRIM_PREG},
  2073. {0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
  2074. {0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
  2075. {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
  2076. {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  2077. {0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
  2078. {0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
  2079. {0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
  2080. {0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
  2081. {0x0000, SIERRA_CREQ_SPARE_PREG},
  2082. {0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
  2083. {0x8452, SIERRA_CTLELUT_CTRL_PREG},
  2084. {0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
  2085. {0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
  2086. {0x0003, SIERRA_DEQ_PHALIGN_CTRL},
  2087. {0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
  2088. {0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  2089. {0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
  2090. {0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
  2091. {0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
  2092. {0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
  2093. {0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
  2094. {0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
  2095. {0x0014, SIERRA_DEQ_GLUT0},
  2096. {0x0014, SIERRA_DEQ_GLUT1},
  2097. {0x0014, SIERRA_DEQ_GLUT2},
  2098. {0x0014, SIERRA_DEQ_GLUT3},
  2099. {0x0014, SIERRA_DEQ_GLUT4},
  2100. {0x0014, SIERRA_DEQ_GLUT5},
  2101. {0x0014, SIERRA_DEQ_GLUT6},
  2102. {0x0014, SIERRA_DEQ_GLUT7},
  2103. {0x0014, SIERRA_DEQ_GLUT8},
  2104. {0x0014, SIERRA_DEQ_GLUT9},
  2105. {0x0014, SIERRA_DEQ_GLUT10},
  2106. {0x0014, SIERRA_DEQ_GLUT11},
  2107. {0x0014, SIERRA_DEQ_GLUT12},
  2108. {0x0014, SIERRA_DEQ_GLUT13},
  2109. {0x0014, SIERRA_DEQ_GLUT14},
  2110. {0x0014, SIERRA_DEQ_GLUT15},
  2111. {0x0014, SIERRA_DEQ_GLUT16},
  2112. {0x0BAE, SIERRA_DEQ_ALUT0},
  2113. {0x0AEB, SIERRA_DEQ_ALUT1},
  2114. {0x0A28, SIERRA_DEQ_ALUT2},
  2115. {0x0965, SIERRA_DEQ_ALUT3},
  2116. {0x08A2, SIERRA_DEQ_ALUT4},
  2117. {0x07DF, SIERRA_DEQ_ALUT5},
  2118. {0x071C, SIERRA_DEQ_ALUT6},
  2119. {0x0659, SIERRA_DEQ_ALUT7},
  2120. {0x0596, SIERRA_DEQ_ALUT8},
  2121. {0x0514, SIERRA_DEQ_ALUT9},
  2122. {0x0492, SIERRA_DEQ_ALUT10},
  2123. {0x0410, SIERRA_DEQ_ALUT11},
  2124. {0x038E, SIERRA_DEQ_ALUT12},
  2125. {0x030C, SIERRA_DEQ_ALUT13},
  2126. {0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG},
  2127. {0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG},
  2128. {0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
  2129. {0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
  2130. {0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG},
  2131. {0x0033, SIERRA_DEQ_PICTRL_PREG},
  2132. {0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG},
  2133. {0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
  2134. {0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG},
  2135. {0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
  2136. {0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
  2137. {0x0005, SIERRA_LFPSDET_SUPPORT_PREG},
  2138. {0x000F, SIERRA_LFPSFILT_NS_PREG},
  2139. {0x0009, SIERRA_LFPSFILT_RD_PREG},
  2140. {0x0001, SIERRA_LFPSFILT_MP_PREG},
  2141. {0x6013, SIERRA_SIGDET_SUPPORT_PREG},
  2142. {0x8013, SIERRA_SDFILT_H2L_A_PREG},
  2143. {0x8009, SIERRA_SDFILT_L2H_PREG},
  2144. {0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
  2145. {0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG},
  2146. {0x4243, SIERRA_RXBUFFER_DFECTRL_PREG}
  2147. };
  2148. static const struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = {
  2149. .reg_pairs = cdns_usb_cmn_regs_ext_ssc,
  2150. .num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
  2151. };
  2152. static const struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = {
  2153. .reg_pairs = cdns_usb_ln_regs_ext_ssc,
  2154. .num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
  2155. };
  2156. /* SGMII PHY common configuration */
  2157. static const struct cdns_reg_pairs sgmii_pma_cmn_vals[] = {
  2158. {0x0180, SIERRA_SDOSCCAL_CLK_CNT_PREG},
  2159. {0x6000, SIERRA_CMN_REFRCV_PREG},
  2160. {0x0031, SIERRA_CMN_RESCAL_CTRLA_PREG},
  2161. {0x001C, SIERRA_CMN_PLLLC_FBDIV_INT_MODE0_PREG},
  2162. {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
  2163. {0x0000, SIERRA_CMN_PLLLC_LOCKSEARCH_PREG},
  2164. {0x8103, SIERRA_CMN_PLLLC_CLK0_PREG},
  2165. {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
  2166. {0x0027, SIERRA_CMN_PLLCSM_PLLEN_TMR_PREG},
  2167. {0x0062, SIERRA_CMN_PLLCSM_PLLPRE_TMR_PREG},
  2168. {0x0800, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG},
  2169. {0x0000, SIERRA_CMN_PLLLC_INIT_PREG},
  2170. {0x0000, SIERRA_CMN_PLLLC_ITERTMR_PREG},
  2171. {0x0020, SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG},
  2172. {0x0013, SIERRA_CMN_PLLLC_DCOCAL_CTRL_PREG},
  2173. {0x0013, SIERRA_CMN_PLLLC1_DCOCAL_CTRL_PREG},
  2174. };
  2175. static const struct cdns_sierra_vals sgmii_cmn_vals = {
  2176. .reg_pairs = sgmii_pma_cmn_vals,
  2177. .num_regs = ARRAY_SIZE(sgmii_pma_cmn_vals),
  2178. };
  2179. /* SGMII PHY lane configuration */
  2180. static const struct cdns_reg_pairs sgmii_ln_regs[] = {
  2181. {0x691E, SIERRA_DET_STANDEC_D_PREG},
  2182. {0x0FFE, SIERRA_PSC_RX_A0_PREG},
  2183. {0x0104, SIERRA_PLLCTRL_FBDIV_MODE01_PREG},
  2184. {0x0013, SIERRA_PLLCTRL_SUBRATE_PREG},
  2185. {0x0106, SIERRA_PLLCTRL_GEN_D_PREG},
  2186. {0x5234, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
  2187. {0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
  2188. {0x00AB, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
  2189. {0x3C0E, SIERRA_CREQ_CCLKDET_MODE01_PREG},
  2190. {0x3220, SIERRA_CREQ_FSMCLK_SEL_PREG},
  2191. {0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
  2192. {0x6320, SIERRA_DEQ_CONCUR_EPIOFFSET_MODE_PREG},
  2193. {0x0000, SIERRA_CPI_OUTBUF_RATESEL_PREG},
  2194. {0x15A2, SIERRA_LN_SPARE_REG_PREG},
  2195. {0x7900, SIERRA_DEQ_BLK_TAU_CTRL1_PREG},
  2196. {0x2202, SIERRA_DEQ_BLK_TAU_CTRL4_PREG},
  2197. {0x2206, SIERRA_DEQ_TAU_CTRL2_PREG},
  2198. {0x0005, SIERRA_LANE_TX_RECEIVER_DETECT_PREG},
  2199. {0x8001, SIERRA_CREQ_SPARE_PREG},
  2200. {0x0000, SIERRA_DEQ_CONCUR_CTRL1_PREG},
  2201. {0xD004, SIERRA_DEQ_CONCUR_CTRL2_PREG},
  2202. {0x0101, SIERRA_DEQ_GLUT9},
  2203. {0x0101, SIERRA_DEQ_GLUT10},
  2204. {0x0101, SIERRA_DEQ_GLUT11},
  2205. {0x0101, SIERRA_DEQ_GLUT12},
  2206. {0x0000, SIERRA_DEQ_GLUT13},
  2207. {0x0000, SIERRA_DEQ_GLUT16},
  2208. {0x0000, SIERRA_POSTPRECUR_EN_CEPH_CTRL_PREG},
  2209. {0x0000, SIERRA_TAU_EN_CEPH2TO0_PREG},
  2210. {0x0003, SIERRA_TAU_EN_CEPH5TO3_PREG},
  2211. {0x0101, SIERRA_DEQ_ALUT8},
  2212. {0x0101, SIERRA_DEQ_ALUT9},
  2213. {0x0100, SIERRA_DEQ_ALUT10},
  2214. {0x0000, SIERRA_OEPH_EN_CTRL_PREG},
  2215. {0x5425, SIERRA_DEQ_OPENEYE_CTRL_PREG},
  2216. {0x7458, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
  2217. {0x321F, SIERRA_CPICAL_RES_STARTCODE_MODE01_PREG},
  2218. };
  2219. static const struct cdns_sierra_vals sgmii_pma_ln_vals = {
  2220. .reg_pairs = sgmii_ln_regs,
  2221. .num_regs = ARRAY_SIZE(sgmii_ln_regs),
  2222. };
  2223. static const struct cdns_sierra_data cdns_map_sierra = {
  2224. .id_value = SIERRA_MACRO_ID,
  2225. .block_offset_shift = 0x2,
  2226. .reg_offset_shift = 0x2,
  2227. .pcs_cmn_vals = {
  2228. [TYPE_PCIE] = {
  2229. [TYPE_NONE] = {
  2230. [NO_SSC] = &pcie_phy_pcs_cmn_vals,
  2231. [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2232. [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2233. },
  2234. [TYPE_SGMII] = {
  2235. [NO_SSC] = &pcie_phy_pcs_cmn_vals,
  2236. [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2237. [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2238. },
  2239. [TYPE_QSGMII] = {
  2240. [NO_SSC] = &pcie_phy_pcs_cmn_vals,
  2241. [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2242. [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2243. },
  2244. },
  2245. },
  2246. .pma_cmn_vals = {
  2247. [TYPE_PCIE] = {
  2248. [TYPE_NONE] = {
  2249. [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
  2250. [EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
  2251. [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
  2252. },
  2253. [TYPE_SGMII] = {
  2254. [NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
  2255. [EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
  2256. [INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
  2257. },
  2258. [TYPE_QSGMII] = {
  2259. [NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
  2260. [EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
  2261. [INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
  2262. },
  2263. },
  2264. [TYPE_USB] = {
  2265. [TYPE_NONE] = {
  2266. [EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
  2267. },
  2268. },
  2269. [TYPE_SGMII] = {
  2270. [TYPE_NONE] = {
  2271. [NO_SSC] = &sgmii_cmn_vals,
  2272. },
  2273. [TYPE_PCIE] = {
  2274. [NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
  2275. [EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
  2276. [INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
  2277. },
  2278. },
  2279. [TYPE_QSGMII] = {
  2280. [TYPE_PCIE] = {
  2281. [NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
  2282. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
  2283. [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
  2284. },
  2285. },
  2286. },
  2287. .pma_ln_vals = {
  2288. [TYPE_PCIE] = {
  2289. [TYPE_NONE] = {
  2290. [NO_SSC] = &pcie_100_no_ssc_ln_vals,
  2291. [EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
  2292. [INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
  2293. },
  2294. [TYPE_SGMII] = {
  2295. [NO_SSC] = &ml_pcie_100_no_ssc_ln_vals,
  2296. [EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals,
  2297. [INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals,
  2298. },
  2299. [TYPE_QSGMII] = {
  2300. [NO_SSC] = &ml_pcie_100_no_ssc_ln_vals,
  2301. [EXTERNAL_SSC] = &ml_pcie_100_ext_ssc_ln_vals,
  2302. [INTERNAL_SSC] = &ml_pcie_100_int_ssc_ln_vals,
  2303. },
  2304. },
  2305. [TYPE_USB] = {
  2306. [TYPE_NONE] = {
  2307. [EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
  2308. },
  2309. },
  2310. [TYPE_SGMII] = {
  2311. [TYPE_NONE] = {
  2312. [NO_SSC] = &sgmii_pma_ln_vals,
  2313. },
  2314. [TYPE_PCIE] = {
  2315. [NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
  2316. [EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
  2317. [INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
  2318. },
  2319. },
  2320. [TYPE_QSGMII] = {
  2321. [TYPE_PCIE] = {
  2322. [NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
  2323. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
  2324. [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
  2325. },
  2326. },
  2327. },
  2328. };
  2329. static const struct cdns_sierra_data cdns_ti_map_sierra = {
  2330. .id_value = SIERRA_MACRO_ID,
  2331. .block_offset_shift = 0x0,
  2332. .reg_offset_shift = 0x1,
  2333. .pcs_cmn_vals = {
  2334. [TYPE_PCIE] = {
  2335. [TYPE_NONE] = {
  2336. [NO_SSC] = &pcie_phy_pcs_cmn_vals,
  2337. [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2338. [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2339. },
  2340. [TYPE_SGMII] = {
  2341. [NO_SSC] = &pcie_phy_pcs_cmn_vals,
  2342. [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2343. [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2344. },
  2345. [TYPE_QSGMII] = {
  2346. [NO_SSC] = &pcie_phy_pcs_cmn_vals,
  2347. [EXTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2348. [INTERNAL_SSC] = &pcie_phy_pcs_cmn_vals,
  2349. },
  2350. },
  2351. },
  2352. .phy_pma_ln_vals = {
  2353. [TYPE_SGMII] = {
  2354. [TYPE_PCIE] = {
  2355. [NO_SSC] = &sgmii_phy_pma_ln_vals,
  2356. [EXTERNAL_SSC] = &sgmii_phy_pma_ln_vals,
  2357. [INTERNAL_SSC] = &sgmii_phy_pma_ln_vals,
  2358. },
  2359. },
  2360. [TYPE_QSGMII] = {
  2361. [TYPE_PCIE] = {
  2362. [NO_SSC] = &qsgmii_phy_pma_ln_vals,
  2363. [EXTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
  2364. [INTERNAL_SSC] = &qsgmii_phy_pma_ln_vals,
  2365. },
  2366. },
  2367. },
  2368. .pma_cmn_vals = {
  2369. [TYPE_PCIE] = {
  2370. [TYPE_NONE] = {
  2371. [NO_SSC] = &pcie_100_no_ssc_cmn_vals,
  2372. [EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
  2373. [INTERNAL_SSC] = &pcie_100_int_ssc_cmn_vals,
  2374. },
  2375. [TYPE_SGMII] = {
  2376. [NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
  2377. [EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
  2378. [INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
  2379. },
  2380. [TYPE_QSGMII] = {
  2381. [NO_SSC] = &pcie_100_no_ssc_plllc_cmn_vals,
  2382. [EXTERNAL_SSC] = &pcie_100_ext_ssc_plllc_cmn_vals,
  2383. [INTERNAL_SSC] = &pcie_100_int_ssc_plllc_cmn_vals,
  2384. },
  2385. },
  2386. [TYPE_USB] = {
  2387. [TYPE_NONE] = {
  2388. [EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
  2389. },
  2390. },
  2391. [TYPE_SGMII] = {
  2392. [TYPE_PCIE] = {
  2393. [NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
  2394. [EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
  2395. [INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_cmn_vals,
  2396. },
  2397. },
  2398. [TYPE_QSGMII] = {
  2399. [TYPE_PCIE] = {
  2400. [NO_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
  2401. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
  2402. [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_cmn_vals,
  2403. },
  2404. },
  2405. },
  2406. .pma_ln_vals = {
  2407. [TYPE_PCIE] = {
  2408. [TYPE_NONE] = {
  2409. [NO_SSC] = &pcie_100_no_ssc_ln_vals,
  2410. [EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
  2411. [INTERNAL_SSC] = &pcie_100_int_ssc_ln_vals,
  2412. },
  2413. [TYPE_SGMII] = {
  2414. [NO_SSC] = &ti_ml_pcie_100_no_ssc_ln_vals,
  2415. [EXTERNAL_SSC] = &ti_ml_pcie_100_ext_ssc_ln_vals,
  2416. [INTERNAL_SSC] = &ti_ml_pcie_100_int_ssc_ln_vals,
  2417. },
  2418. [TYPE_QSGMII] = {
  2419. [NO_SSC] = &ti_ml_pcie_100_no_ssc_ln_vals,
  2420. [EXTERNAL_SSC] = &ti_ml_pcie_100_ext_ssc_ln_vals,
  2421. [INTERNAL_SSC] = &ti_ml_pcie_100_int_ssc_ln_vals,
  2422. },
  2423. },
  2424. [TYPE_USB] = {
  2425. [TYPE_NONE] = {
  2426. [EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
  2427. },
  2428. },
  2429. [TYPE_SGMII] = {
  2430. [TYPE_PCIE] = {
  2431. [NO_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
  2432. [EXTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
  2433. [INTERNAL_SSC] = &sgmii_100_no_ssc_plllc1_opt3_ln_vals,
  2434. },
  2435. },
  2436. [TYPE_QSGMII] = {
  2437. [TYPE_PCIE] = {
  2438. [NO_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
  2439. [EXTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
  2440. [INTERNAL_SSC] = &qsgmii_100_no_ssc_plllc1_ln_vals,
  2441. },
  2442. },
  2443. },
  2444. };
  2445. static const struct of_device_id cdns_sierra_id_table[] = {
  2446. {
  2447. .compatible = "cdns,sierra-phy-t0",
  2448. .data = &cdns_map_sierra,
  2449. },
  2450. {
  2451. .compatible = "ti,sierra-phy-t0",
  2452. .data = &cdns_ti_map_sierra,
  2453. },
  2454. {}
  2455. };
  2456. MODULE_DEVICE_TABLE(of, cdns_sierra_id_table);
  2457. static struct platform_driver cdns_sierra_driver = {
  2458. .probe = cdns_sierra_phy_probe,
  2459. .remove_new = cdns_sierra_phy_remove,
  2460. .driver = {
  2461. .name = "cdns-sierra-phy",
  2462. .of_match_table = cdns_sierra_id_table,
  2463. },
  2464. };
  2465. module_platform_driver(cdns_sierra_driver);
  2466. MODULE_ALIAS("platform:cdns_sierra");
  2467. MODULE_AUTHOR("Cadence Design Systems");
  2468. MODULE_DESCRIPTION("CDNS sierra phy driver");
  2469. MODULE_LICENSE("GPL v2");