phy-cadence-sierra.c 77 KB

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