phy-rockchip-usbdp.c 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Rockchip USBDP Combo PHY with Samsung IP block driver
  4. *
  5. * Copyright (C) 2021-2024 Rockchip Electronics Co., Ltd
  6. * Copyright (C) 2024 Collabora Ltd
  7. */
  8. #include <dt-bindings/phy/phy.h>
  9. #include <linux/bitfield.h>
  10. #include <linux/bits.h>
  11. #include <linux/clk.h>
  12. #include <linux/delay.h>
  13. #include <linux/gpio.h>
  14. #include <linux/mfd/syscon.h>
  15. #include <linux/mod_devicetable.h>
  16. #include <linux/module.h>
  17. #include <linux/mutex.h>
  18. #include <linux/phy/phy.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/property.h>
  21. #include <linux/regmap.h>
  22. #include <linux/reset.h>
  23. #include <linux/usb/ch9.h>
  24. #include <linux/usb/typec_dp.h>
  25. #include <linux/usb/typec_mux.h>
  26. /* USBDP PHY Register Definitions */
  27. #define UDPHY_PCS 0x4000
  28. #define UDPHY_PMA 0x8000
  29. /* VO0 GRF Registers */
  30. #define DP_SINK_HPD_CFG BIT(11)
  31. #define DP_SINK_HPD_SEL BIT(10)
  32. #define DP_AUX_DIN_SEL BIT(9)
  33. #define DP_AUX_DOUT_SEL BIT(8)
  34. #define DP_LANE_SEL_N(n) GENMASK(2 * (n) + 1, 2 * (n))
  35. #define DP_LANE_SEL_ALL GENMASK(7, 0)
  36. /* PMA CMN Registers */
  37. #define CMN_LANE_MUX_AND_EN_OFFSET 0x0288 /* cmn_reg00A2 */
  38. #define CMN_DP_LANE_MUX_N(n) BIT((n) + 4)
  39. #define CMN_DP_LANE_EN_N(n) BIT(n)
  40. #define CMN_DP_LANE_MUX_ALL GENMASK(7, 4)
  41. #define CMN_DP_LANE_EN_ALL GENMASK(3, 0)
  42. #define CMN_DP_LINK_OFFSET 0x28c /* cmn_reg00A3 */
  43. #define CMN_DP_TX_LINK_BW GENMASK(6, 5)
  44. #define CMN_DP_TX_LANE_SWAP_EN BIT(2)
  45. #define CMN_SSC_EN_OFFSET 0x2d0 /* cmn_reg00B4 */
  46. #define CMN_ROPLL_SSC_EN BIT(1)
  47. #define CMN_LCPLL_SSC_EN BIT(0)
  48. #define CMN_ANA_LCPLL_DONE_OFFSET 0x0350 /* cmn_reg00D4 */
  49. #define CMN_ANA_LCPLL_LOCK_DONE BIT(7)
  50. #define CMN_ANA_LCPLL_AFC_DONE BIT(6)
  51. #define CMN_ANA_ROPLL_DONE_OFFSET 0x0354 /* cmn_reg00D5 */
  52. #define CMN_ANA_ROPLL_LOCK_DONE BIT(1)
  53. #define CMN_ANA_ROPLL_AFC_DONE BIT(0)
  54. #define CMN_DP_RSTN_OFFSET 0x038c /* cmn_reg00E3 */
  55. #define CMN_DP_INIT_RSTN BIT(3)
  56. #define CMN_DP_CMN_RSTN BIT(2)
  57. #define CMN_CDR_WTCHDG_EN BIT(1)
  58. #define CMN_CDR_WTCHDG_MSK_CDR_EN BIT(0)
  59. #define TRSV_ANA_TX_CLK_OFFSET_N(n) (0x854 + (n) * 0x800) /* trsv_reg0215 */
  60. #define LN_ANA_TX_SER_TXCLK_INV BIT(1)
  61. #define TRSV_LN0_MON_RX_CDR_DONE_OFFSET 0x0b84 /* trsv_reg02E1 */
  62. #define TRSV_LN0_MON_RX_CDR_LOCK_DONE BIT(0)
  63. #define TRSV_LN2_MON_RX_CDR_DONE_OFFSET 0x1b84 /* trsv_reg06E1 */
  64. #define TRSV_LN2_MON_RX_CDR_LOCK_DONE BIT(0)
  65. #define BIT_WRITEABLE_SHIFT 16
  66. #define PHY_AUX_DP_DATA_POL_NORMAL 0
  67. #define PHY_AUX_DP_DATA_POL_INVERT 1
  68. #define PHY_LANE_MUX_USB 0
  69. #define PHY_LANE_MUX_DP 1
  70. enum {
  71. DP_BW_RBR,
  72. DP_BW_HBR,
  73. DP_BW_HBR2,
  74. DP_BW_HBR3,
  75. };
  76. enum {
  77. UDPHY_MODE_NONE = 0,
  78. UDPHY_MODE_USB = BIT(0),
  79. UDPHY_MODE_DP = BIT(1),
  80. UDPHY_MODE_DP_USB = BIT(1) | BIT(0),
  81. };
  82. struct rk_udphy_grf_reg {
  83. unsigned int offset;
  84. unsigned int disable;
  85. unsigned int enable;
  86. };
  87. #define _RK_UDPHY_GEN_GRF_REG(offset, mask, disable, enable) \
  88. {\
  89. offset, \
  90. FIELD_PREP_CONST(mask, disable) | (mask << BIT_WRITEABLE_SHIFT), \
  91. FIELD_PREP_CONST(mask, enable) | (mask << BIT_WRITEABLE_SHIFT), \
  92. }
  93. #define RK_UDPHY_GEN_GRF_REG(offset, bitend, bitstart, disable, enable) \
  94. _RK_UDPHY_GEN_GRF_REG(offset, GENMASK(bitend, bitstart), disable, enable)
  95. struct rk_udphy_grf_cfg {
  96. /* u2phy-grf */
  97. struct rk_udphy_grf_reg bvalid_phy_con;
  98. struct rk_udphy_grf_reg bvalid_grf_con;
  99. /* usb-grf */
  100. struct rk_udphy_grf_reg usb3otg0_cfg;
  101. struct rk_udphy_grf_reg usb3otg1_cfg;
  102. /* usbdpphy-grf */
  103. struct rk_udphy_grf_reg low_pwrn;
  104. struct rk_udphy_grf_reg rx_lfps;
  105. };
  106. struct rk_udphy_vogrf_cfg {
  107. /* vo-grf */
  108. struct rk_udphy_grf_reg hpd_trigger;
  109. u32 dp_lane_reg;
  110. };
  111. struct rk_udphy_dp_tx_drv_ctrl {
  112. u32 trsv_reg0204;
  113. u32 trsv_reg0205;
  114. u32 trsv_reg0206;
  115. u32 trsv_reg0207;
  116. };
  117. struct rk_udphy_cfg {
  118. unsigned int num_phys;
  119. unsigned int phy_ids[2];
  120. /* resets to be requested */
  121. const char * const *rst_list;
  122. int num_rsts;
  123. struct rk_udphy_grf_cfg grfcfg;
  124. struct rk_udphy_vogrf_cfg vogrfcfg[2];
  125. const struct rk_udphy_dp_tx_drv_ctrl (*dp_tx_ctrl_cfg[4])[4];
  126. const struct rk_udphy_dp_tx_drv_ctrl (*dp_tx_ctrl_cfg_typec[4])[4];
  127. };
  128. struct rk_udphy {
  129. struct device *dev;
  130. struct regmap *pma_regmap;
  131. struct regmap *u2phygrf;
  132. struct regmap *udphygrf;
  133. struct regmap *usbgrf;
  134. struct regmap *vogrf;
  135. struct typec_switch_dev *sw;
  136. struct typec_mux_dev *mux;
  137. struct mutex mutex; /* mutex to protect access to individual PHYs */
  138. /* clocks and rests */
  139. int num_clks;
  140. struct clk_bulk_data *clks;
  141. struct clk *refclk;
  142. int num_rsts;
  143. struct reset_control_bulk_data *rsts;
  144. /* PHY status management */
  145. bool flip;
  146. bool mode_change;
  147. u8 mode;
  148. u8 status;
  149. /* utilized for USB */
  150. bool hs; /* flag for high-speed */
  151. /* utilized for DP */
  152. struct gpio_desc *sbu1_dc_gpio;
  153. struct gpio_desc *sbu2_dc_gpio;
  154. u32 lane_mux_sel[4];
  155. u32 dp_lane_sel[4];
  156. u32 dp_aux_dout_sel;
  157. u32 dp_aux_din_sel;
  158. bool dp_sink_hpd_sel;
  159. bool dp_sink_hpd_cfg;
  160. u8 bw;
  161. int id;
  162. bool dp_in_use;
  163. /* PHY const config */
  164. const struct rk_udphy_cfg *cfgs;
  165. /* PHY devices */
  166. struct phy *phy_dp;
  167. struct phy *phy_u3;
  168. };
  169. static const struct rk_udphy_dp_tx_drv_ctrl rk3588_dp_tx_drv_ctrl_rbr_hbr[4][4] = {
  170. /* voltage swing 0, pre-emphasis 0->3 */
  171. {
  172. { 0x20, 0x10, 0x42, 0xe5 },
  173. { 0x26, 0x14, 0x42, 0xe5 },
  174. { 0x29, 0x18, 0x42, 0xe5 },
  175. { 0x2b, 0x1c, 0x43, 0xe7 },
  176. },
  177. /* voltage swing 1, pre-emphasis 0->2 */
  178. {
  179. { 0x23, 0x10, 0x42, 0xe7 },
  180. { 0x2a, 0x17, 0x43, 0xe7 },
  181. { 0x2b, 0x1a, 0x43, 0xe7 },
  182. },
  183. /* voltage swing 2, pre-emphasis 0->1 */
  184. {
  185. { 0x27, 0x10, 0x42, 0xe7 },
  186. { 0x2b, 0x17, 0x43, 0xe7 },
  187. },
  188. /* voltage swing 3, pre-emphasis 0 */
  189. {
  190. { 0x29, 0x10, 0x43, 0xe7 },
  191. },
  192. };
  193. static const struct rk_udphy_dp_tx_drv_ctrl rk3588_dp_tx_drv_ctrl_rbr_hbr_typec[4][4] = {
  194. /* voltage swing 0, pre-emphasis 0->3 */
  195. {
  196. { 0x20, 0x10, 0x42, 0xe5 },
  197. { 0x26, 0x14, 0x42, 0xe5 },
  198. { 0x29, 0x18, 0x42, 0xe5 },
  199. { 0x2b, 0x1c, 0x43, 0xe7 },
  200. },
  201. /* voltage swing 1, pre-emphasis 0->2 */
  202. {
  203. { 0x23, 0x10, 0x42, 0xe7 },
  204. { 0x2a, 0x17, 0x43, 0xe7 },
  205. { 0x2b, 0x1a, 0x43, 0xe7 },
  206. },
  207. /* voltage swing 2, pre-emphasis 0->1 */
  208. {
  209. { 0x27, 0x10, 0x43, 0x67 },
  210. { 0x2b, 0x17, 0x43, 0xe7 },
  211. },
  212. /* voltage swing 3, pre-emphasis 0 */
  213. {
  214. { 0x29, 0x10, 0x43, 0xe7 },
  215. },
  216. };
  217. static const struct rk_udphy_dp_tx_drv_ctrl rk3588_dp_tx_drv_ctrl_hbr2[4][4] = {
  218. /* voltage swing 0, pre-emphasis 0->3 */
  219. {
  220. { 0x21, 0x10, 0x42, 0xe5 },
  221. { 0x26, 0x14, 0x42, 0xe5 },
  222. { 0x26, 0x16, 0x43, 0xe5 },
  223. { 0x2a, 0x19, 0x43, 0xe7 },
  224. },
  225. /* voltage swing 1, pre-emphasis 0->2 */
  226. {
  227. { 0x24, 0x10, 0x42, 0xe7 },
  228. { 0x2a, 0x17, 0x43, 0xe7 },
  229. { 0x2b, 0x1a, 0x43, 0xe7 },
  230. },
  231. /* voltage swing 2, pre-emphasis 0->1 */
  232. {
  233. { 0x28, 0x10, 0x42, 0xe7 },
  234. { 0x2b, 0x17, 0x43, 0xe7 },
  235. },
  236. /* voltage swing 3, pre-emphasis 0 */
  237. {
  238. { 0x28, 0x10, 0x43, 0xe7 },
  239. },
  240. };
  241. static const struct rk_udphy_dp_tx_drv_ctrl rk3588_dp_tx_drv_ctrl_hbr3[4][4] = {
  242. /* voltage swing 0, pre-emphasis 0->3 */
  243. {
  244. { 0x21, 0x10, 0x42, 0xe5 },
  245. { 0x26, 0x14, 0x42, 0xe5 },
  246. { 0x26, 0x16, 0x43, 0xe5 },
  247. { 0x29, 0x18, 0x43, 0xe7 },
  248. },
  249. /* voltage swing 1, pre-emphasis 0->2 */
  250. {
  251. { 0x24, 0x10, 0x42, 0xe7 },
  252. { 0x2a, 0x18, 0x43, 0xe7 },
  253. { 0x2b, 0x1b, 0x43, 0xe7 }
  254. },
  255. /* voltage swing 2, pre-emphasis 0->1 */
  256. {
  257. { 0x27, 0x10, 0x42, 0xe7 },
  258. { 0x2b, 0x18, 0x43, 0xe7 }
  259. },
  260. /* voltage swing 3, pre-emphasis 0 */
  261. {
  262. { 0x28, 0x10, 0x43, 0xe7 },
  263. },
  264. };
  265. static const struct reg_sequence rk_udphy_24m_refclk_cfg[] = {
  266. {0x0090, 0x68}, {0x0094, 0x68},
  267. {0x0128, 0x24}, {0x012c, 0x44},
  268. {0x0130, 0x3f}, {0x0134, 0x44},
  269. {0x015c, 0xa9}, {0x0160, 0x71},
  270. {0x0164, 0x71}, {0x0168, 0xa9},
  271. {0x0174, 0xa9}, {0x0178, 0x71},
  272. {0x017c, 0x71}, {0x0180, 0xa9},
  273. {0x018c, 0x41}, {0x0190, 0x00},
  274. {0x0194, 0x05}, {0x01ac, 0x2a},
  275. {0x01b0, 0x17}, {0x01b4, 0x17},
  276. {0x01b8, 0x2a}, {0x01c8, 0x04},
  277. {0x01cc, 0x08}, {0x01d0, 0x08},
  278. {0x01d4, 0x04}, {0x01d8, 0x20},
  279. {0x01dc, 0x01}, {0x01e0, 0x09},
  280. {0x01e4, 0x03}, {0x01f0, 0x29},
  281. {0x01f4, 0x02}, {0x01f8, 0x02},
  282. {0x01fc, 0x29}, {0x0208, 0x2a},
  283. {0x020c, 0x17}, {0x0210, 0x17},
  284. {0x0214, 0x2a}, {0x0224, 0x20},
  285. {0x03f0, 0x0a}, {0x03f4, 0x07},
  286. {0x03f8, 0x07}, {0x03fc, 0x0c},
  287. {0x0404, 0x12}, {0x0408, 0x1a},
  288. {0x040c, 0x1a}, {0x0410, 0x3f},
  289. {0x0ce0, 0x68}, {0x0ce8, 0xd0},
  290. {0x0cf0, 0x87}, {0x0cf8, 0x70},
  291. {0x0d00, 0x70}, {0x0d08, 0xa9},
  292. {0x1ce0, 0x68}, {0x1ce8, 0xd0},
  293. {0x1cf0, 0x87}, {0x1cf8, 0x70},
  294. {0x1d00, 0x70}, {0x1d08, 0xa9},
  295. {0x0a3c, 0xd0}, {0x0a44, 0xd0},
  296. {0x0a48, 0x01}, {0x0a4c, 0x0d},
  297. {0x0a54, 0xe0}, {0x0a5c, 0xe0},
  298. {0x0a64, 0xa8}, {0x1a3c, 0xd0},
  299. {0x1a44, 0xd0}, {0x1a48, 0x01},
  300. {0x1a4c, 0x0d}, {0x1a54, 0xe0},
  301. {0x1a5c, 0xe0}, {0x1a64, 0xa8}
  302. };
  303. static const struct reg_sequence rk_udphy_26m_refclk_cfg[] = {
  304. {0x0830, 0x07}, {0x085c, 0x80},
  305. {0x1030, 0x07}, {0x105c, 0x80},
  306. {0x1830, 0x07}, {0x185c, 0x80},
  307. {0x2030, 0x07}, {0x205c, 0x80},
  308. {0x0228, 0x38}, {0x0104, 0x44},
  309. {0x0248, 0x44}, {0x038c, 0x02},
  310. {0x0878, 0x04}, {0x1878, 0x04},
  311. {0x0898, 0x77}, {0x1898, 0x77},
  312. {0x0054, 0x01}, {0x00e0, 0x38},
  313. {0x0060, 0x24}, {0x0064, 0x77},
  314. {0x0070, 0x76}, {0x0234, 0xe8},
  315. {0x0af4, 0x15}, {0x1af4, 0x15},
  316. {0x081c, 0xe5}, {0x181c, 0xe5},
  317. {0x099c, 0x48}, {0x199c, 0x48},
  318. {0x09a4, 0x07}, {0x09a8, 0x22},
  319. {0x19a4, 0x07}, {0x19a8, 0x22},
  320. {0x09b8, 0x3e}, {0x19b8, 0x3e},
  321. {0x09e4, 0x02}, {0x19e4, 0x02},
  322. {0x0a34, 0x1e}, {0x1a34, 0x1e},
  323. {0x0a98, 0x2f}, {0x1a98, 0x2f},
  324. {0x0c30, 0x0e}, {0x0c48, 0x06},
  325. {0x1c30, 0x0e}, {0x1c48, 0x06},
  326. {0x028c, 0x18}, {0x0af0, 0x00},
  327. {0x1af0, 0x00}
  328. };
  329. static const struct reg_sequence rk_udphy_init_sequence[] = {
  330. {0x0104, 0x44}, {0x0234, 0xe8},
  331. {0x0248, 0x44}, {0x028c, 0x18},
  332. {0x081c, 0xe5}, {0x0878, 0x00},
  333. {0x0994, 0x1c}, {0x0af0, 0x00},
  334. {0x181c, 0xe5}, {0x1878, 0x00},
  335. {0x1994, 0x1c}, {0x1af0, 0x00},
  336. {0x0428, 0x60}, {0x0d58, 0x33},
  337. {0x1d58, 0x33}, {0x0990, 0x74},
  338. {0x0d64, 0x17}, {0x08c8, 0x13},
  339. {0x1990, 0x74}, {0x1d64, 0x17},
  340. {0x18c8, 0x13}, {0x0d90, 0x40},
  341. {0x0da8, 0x40}, {0x0dc0, 0x40},
  342. {0x0dd8, 0x40}, {0x1d90, 0x40},
  343. {0x1da8, 0x40}, {0x1dc0, 0x40},
  344. {0x1dd8, 0x40}, {0x03c0, 0x30},
  345. {0x03c4, 0x06}, {0x0e10, 0x00},
  346. {0x1e10, 0x00}, {0x043c, 0x0f},
  347. {0x0d2c, 0xff}, {0x1d2c, 0xff},
  348. {0x0d34, 0x0f}, {0x1d34, 0x0f},
  349. {0x08fc, 0x2a}, {0x0914, 0x28},
  350. {0x0a30, 0x03}, {0x0e38, 0x03},
  351. {0x0ecc, 0x27}, {0x0ed0, 0x22},
  352. {0x0ed4, 0x26}, {0x18fc, 0x2a},
  353. {0x1914, 0x28}, {0x1a30, 0x03},
  354. {0x1e38, 0x03}, {0x1ecc, 0x27},
  355. {0x1ed0, 0x22}, {0x1ed4, 0x26},
  356. {0x0048, 0x0f}, {0x0060, 0x3c},
  357. {0x0064, 0xf7}, {0x006c, 0x20},
  358. {0x0070, 0x7d}, {0x0074, 0x68},
  359. {0x0af4, 0x1a}, {0x1af4, 0x1a},
  360. {0x0440, 0x3f}, {0x10d4, 0x08},
  361. {0x20d4, 0x08}, {0x00d4, 0x30},
  362. {0x0024, 0x6e},
  363. };
  364. static inline int rk_udphy_grfreg_write(struct regmap *base,
  365. const struct rk_udphy_grf_reg *reg, bool en)
  366. {
  367. return regmap_write(base, reg->offset, en ? reg->enable : reg->disable);
  368. }
  369. static int rk_udphy_clk_init(struct rk_udphy *udphy, struct device *dev)
  370. {
  371. int i;
  372. udphy->num_clks = devm_clk_bulk_get_all(dev, &udphy->clks);
  373. if (udphy->num_clks < 1)
  374. return -ENODEV;
  375. /* used for configure phy reference clock frequency */
  376. for (i = 0; i < udphy->num_clks; i++) {
  377. if (!strncmp(udphy->clks[i].id, "refclk", 6)) {
  378. udphy->refclk = udphy->clks[i].clk;
  379. break;
  380. }
  381. }
  382. if (!udphy->refclk)
  383. return dev_err_probe(udphy->dev, -EINVAL, "no refclk found\n");
  384. return 0;
  385. }
  386. static int rk_udphy_reset_assert_all(struct rk_udphy *udphy)
  387. {
  388. return reset_control_bulk_assert(udphy->num_rsts, udphy->rsts);
  389. }
  390. static int rk_udphy_reset_deassert_all(struct rk_udphy *udphy)
  391. {
  392. return reset_control_bulk_deassert(udphy->num_rsts, udphy->rsts);
  393. }
  394. static int rk_udphy_reset_deassert(struct rk_udphy *udphy, char *name)
  395. {
  396. struct reset_control_bulk_data *list = udphy->rsts;
  397. int idx;
  398. for (idx = 0; idx < udphy->num_rsts; idx++) {
  399. if (!strcmp(list[idx].id, name))
  400. return reset_control_deassert(list[idx].rstc);
  401. }
  402. return -EINVAL;
  403. }
  404. static int rk_udphy_reset_init(struct rk_udphy *udphy, struct device *dev)
  405. {
  406. const struct rk_udphy_cfg *cfg = udphy->cfgs;
  407. int idx;
  408. udphy->num_rsts = cfg->num_rsts;
  409. udphy->rsts = devm_kcalloc(dev, udphy->num_rsts,
  410. sizeof(*udphy->rsts), GFP_KERNEL);
  411. if (!udphy->rsts)
  412. return -ENOMEM;
  413. for (idx = 0; idx < cfg->num_rsts; idx++)
  414. udphy->rsts[idx].id = cfg->rst_list[idx];
  415. return devm_reset_control_bulk_get_exclusive(dev, cfg->num_rsts,
  416. udphy->rsts);
  417. }
  418. static void rk_udphy_u3_port_disable(struct rk_udphy *udphy, u8 disable)
  419. {
  420. const struct rk_udphy_cfg *cfg = udphy->cfgs;
  421. const struct rk_udphy_grf_reg *preg;
  422. preg = udphy->id ? &cfg->grfcfg.usb3otg1_cfg : &cfg->grfcfg.usb3otg0_cfg;
  423. rk_udphy_grfreg_write(udphy->usbgrf, preg, disable);
  424. }
  425. static void rk_udphy_usb_bvalid_enable(struct rk_udphy *udphy, u8 enable)
  426. {
  427. const struct rk_udphy_cfg *cfg = udphy->cfgs;
  428. rk_udphy_grfreg_write(udphy->u2phygrf, &cfg->grfcfg.bvalid_phy_con, enable);
  429. rk_udphy_grfreg_write(udphy->u2phygrf, &cfg->grfcfg.bvalid_grf_con, enable);
  430. }
  431. /*
  432. * In usb/dp combo phy driver, here are 2 ways to mapping lanes.
  433. *
  434. * 1 Type-C Mapping table (DP_Alt_Mode V1.0b remove ABF pin mapping)
  435. * ---------------------------------------------------------------------------
  436. * Type-C Pin B11-B10 A2-A3 A11-A10 B2-B3
  437. * PHY Pad ln0(tx/rx) ln1(tx) ln2(tx/rx) ln3(tx)
  438. * C/E(Normal) dpln3 dpln2 dpln0 dpln1
  439. * C/E(Flip ) dpln0 dpln1 dpln3 dpln2
  440. * D/F(Normal) usbrx usbtx dpln0 dpln1
  441. * D/F(Flip ) dpln0 dpln1 usbrx usbtx
  442. * A(Normal ) dpln3 dpln1 dpln2 dpln0
  443. * A(Flip ) dpln2 dpln0 dpln3 dpln1
  444. * B(Normal ) usbrx usbtx dpln1 dpln0
  445. * B(Flip ) dpln1 dpln0 usbrx usbtx
  446. * ---------------------------------------------------------------------------
  447. *
  448. * 2 Mapping the lanes in dtsi
  449. * if all 4 lane assignment for dp function, define rockchip,dp-lane-mux = <x x x x>;
  450. * sample as follow:
  451. * ---------------------------------------------------------------------------
  452. * B11-B10 A2-A3 A11-A10 B2-B3
  453. * rockchip,dp-lane-mux ln0(tx/rx) ln1(tx) ln2(tx/rx) ln3(tx)
  454. * <0 1 2 3> dpln0 dpln1 dpln2 dpln3
  455. * <2 3 0 1> dpln2 dpln3 dpln0 dpln1
  456. * ---------------------------------------------------------------------------
  457. * if 2 lane for dp function, 2 lane for usb function, define rockchip,dp-lane-mux = <x x>;
  458. * sample as follow:
  459. * ---------------------------------------------------------------------------
  460. * B11-B10 A2-A3 A11-A10 B2-B3
  461. * rockchip,dp-lane-mux ln0(tx/rx) ln1(tx) ln2(tx/rx) ln3(tx)
  462. * <0 1> dpln0 dpln1 usbrx usbtx
  463. * <2 3> usbrx usbtx dpln0 dpln1
  464. * ---------------------------------------------------------------------------
  465. */
  466. static void rk_udphy_dplane_select(struct rk_udphy *udphy)
  467. {
  468. const struct rk_udphy_cfg *cfg = udphy->cfgs;
  469. u32 value = 0;
  470. switch (udphy->mode) {
  471. case UDPHY_MODE_DP:
  472. value |= 2 << udphy->dp_lane_sel[2] * 2;
  473. value |= 3 << udphy->dp_lane_sel[3] * 2;
  474. fallthrough;
  475. case UDPHY_MODE_DP_USB:
  476. value |= 0 << udphy->dp_lane_sel[0] * 2;
  477. value |= 1 << udphy->dp_lane_sel[1] * 2;
  478. break;
  479. case UDPHY_MODE_USB:
  480. break;
  481. default:
  482. break;
  483. }
  484. regmap_write(udphy->vogrf, cfg->vogrfcfg[udphy->id].dp_lane_reg,
  485. ((DP_AUX_DIN_SEL | DP_AUX_DOUT_SEL | DP_LANE_SEL_ALL) << 16) |
  486. FIELD_PREP(DP_AUX_DIN_SEL, udphy->dp_aux_din_sel) |
  487. FIELD_PREP(DP_AUX_DOUT_SEL, udphy->dp_aux_dout_sel) | value);
  488. }
  489. static int rk_udphy_dplane_get(struct rk_udphy *udphy)
  490. {
  491. int dp_lanes;
  492. switch (udphy->mode) {
  493. case UDPHY_MODE_DP:
  494. dp_lanes = 4;
  495. break;
  496. case UDPHY_MODE_DP_USB:
  497. dp_lanes = 2;
  498. break;
  499. case UDPHY_MODE_USB:
  500. default:
  501. dp_lanes = 0;
  502. break;
  503. }
  504. return dp_lanes;
  505. }
  506. static void rk_udphy_dplane_enable(struct rk_udphy *udphy, int dp_lanes)
  507. {
  508. u32 val = 0;
  509. int i;
  510. for (i = 0; i < dp_lanes; i++)
  511. val |= BIT(udphy->dp_lane_sel[i]);
  512. regmap_update_bits(udphy->pma_regmap, CMN_LANE_MUX_AND_EN_OFFSET, CMN_DP_LANE_EN_ALL,
  513. FIELD_PREP(CMN_DP_LANE_EN_ALL, val));
  514. if (!dp_lanes)
  515. regmap_update_bits(udphy->pma_regmap, CMN_DP_RSTN_OFFSET,
  516. CMN_DP_CMN_RSTN, FIELD_PREP(CMN_DP_CMN_RSTN, 0x0));
  517. }
  518. static void rk_udphy_dp_hpd_event_trigger(struct rk_udphy *udphy, bool hpd)
  519. {
  520. const struct rk_udphy_cfg *cfg = udphy->cfgs;
  521. udphy->dp_sink_hpd_sel = true;
  522. udphy->dp_sink_hpd_cfg = hpd;
  523. if (!udphy->dp_in_use)
  524. return;
  525. rk_udphy_grfreg_write(udphy->vogrf, &cfg->vogrfcfg[udphy->id].hpd_trigger, hpd);
  526. }
  527. static void rk_udphy_set_typec_default_mapping(struct rk_udphy *udphy)
  528. {
  529. if (udphy->flip) {
  530. udphy->dp_lane_sel[0] = 0;
  531. udphy->dp_lane_sel[1] = 1;
  532. udphy->dp_lane_sel[2] = 3;
  533. udphy->dp_lane_sel[3] = 2;
  534. udphy->lane_mux_sel[0] = PHY_LANE_MUX_DP;
  535. udphy->lane_mux_sel[1] = PHY_LANE_MUX_DP;
  536. udphy->lane_mux_sel[2] = PHY_LANE_MUX_USB;
  537. udphy->lane_mux_sel[3] = PHY_LANE_MUX_USB;
  538. udphy->dp_aux_dout_sel = PHY_AUX_DP_DATA_POL_INVERT;
  539. udphy->dp_aux_din_sel = PHY_AUX_DP_DATA_POL_INVERT;
  540. gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 1);
  541. gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 0);
  542. } else {
  543. udphy->dp_lane_sel[0] = 2;
  544. udphy->dp_lane_sel[1] = 3;
  545. udphy->dp_lane_sel[2] = 1;
  546. udphy->dp_lane_sel[3] = 0;
  547. udphy->lane_mux_sel[0] = PHY_LANE_MUX_USB;
  548. udphy->lane_mux_sel[1] = PHY_LANE_MUX_USB;
  549. udphy->lane_mux_sel[2] = PHY_LANE_MUX_DP;
  550. udphy->lane_mux_sel[3] = PHY_LANE_MUX_DP;
  551. udphy->dp_aux_dout_sel = PHY_AUX_DP_DATA_POL_NORMAL;
  552. udphy->dp_aux_din_sel = PHY_AUX_DP_DATA_POL_NORMAL;
  553. gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 0);
  554. gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 1);
  555. }
  556. udphy->mode = UDPHY_MODE_DP_USB;
  557. }
  558. static int rk_udphy_orien_sw_set(struct typec_switch_dev *sw,
  559. enum typec_orientation orien)
  560. {
  561. struct rk_udphy *udphy = typec_switch_get_drvdata(sw);
  562. mutex_lock(&udphy->mutex);
  563. if (orien == TYPEC_ORIENTATION_NONE) {
  564. gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 0);
  565. gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 0);
  566. /* unattached */
  567. rk_udphy_usb_bvalid_enable(udphy, false);
  568. goto unlock_ret;
  569. }
  570. udphy->flip = (orien == TYPEC_ORIENTATION_REVERSE) ? true : false;
  571. rk_udphy_set_typec_default_mapping(udphy);
  572. rk_udphy_usb_bvalid_enable(udphy, true);
  573. unlock_ret:
  574. mutex_unlock(&udphy->mutex);
  575. return 0;
  576. }
  577. static void rk_udphy_orien_switch_unregister(void *data)
  578. {
  579. struct rk_udphy *udphy = data;
  580. typec_switch_unregister(udphy->sw);
  581. }
  582. static int rk_udphy_setup_orien_switch(struct rk_udphy *udphy)
  583. {
  584. struct typec_switch_desc sw_desc = { };
  585. sw_desc.drvdata = udphy;
  586. sw_desc.fwnode = dev_fwnode(udphy->dev);
  587. sw_desc.set = rk_udphy_orien_sw_set;
  588. udphy->sw = typec_switch_register(udphy->dev, &sw_desc);
  589. if (IS_ERR(udphy->sw)) {
  590. dev_err(udphy->dev, "Error register typec orientation switch: %ld\n",
  591. PTR_ERR(udphy->sw));
  592. return PTR_ERR(udphy->sw);
  593. }
  594. return devm_add_action_or_reset(udphy->dev,
  595. rk_udphy_orien_switch_unregister, udphy);
  596. }
  597. static int rk_udphy_refclk_set(struct rk_udphy *udphy)
  598. {
  599. unsigned long rate;
  600. int ret;
  601. /* configure phy reference clock */
  602. rate = clk_get_rate(udphy->refclk);
  603. dev_dbg(udphy->dev, "refclk freq %ld\n", rate);
  604. switch (rate) {
  605. case 24000000:
  606. ret = regmap_multi_reg_write(udphy->pma_regmap, rk_udphy_24m_refclk_cfg,
  607. ARRAY_SIZE(rk_udphy_24m_refclk_cfg));
  608. if (ret)
  609. return ret;
  610. break;
  611. case 26000000:
  612. /* register default is 26MHz */
  613. ret = regmap_multi_reg_write(udphy->pma_regmap, rk_udphy_26m_refclk_cfg,
  614. ARRAY_SIZE(rk_udphy_26m_refclk_cfg));
  615. if (ret)
  616. return ret;
  617. break;
  618. default:
  619. dev_err(udphy->dev, "unsupported refclk freq %ld\n", rate);
  620. return -EINVAL;
  621. }
  622. return 0;
  623. }
  624. static int rk_udphy_status_check(struct rk_udphy *udphy)
  625. {
  626. unsigned int val;
  627. int ret;
  628. /* LCPLL check */
  629. if (udphy->mode & UDPHY_MODE_USB) {
  630. ret = regmap_read_poll_timeout(udphy->pma_regmap, CMN_ANA_LCPLL_DONE_OFFSET,
  631. val, (val & CMN_ANA_LCPLL_AFC_DONE) &&
  632. (val & CMN_ANA_LCPLL_LOCK_DONE), 200, 100000);
  633. if (ret) {
  634. dev_err(udphy->dev, "cmn ana lcpll lock timeout\n");
  635. /*
  636. * If earlier software (U-Boot) enabled USB once already
  637. * the PLL may have problems locking on the first try.
  638. * It will be successful on the second try, so for the
  639. * time being a -EPROBE_DEFER will solve the issue.
  640. *
  641. * This requires further investigation to understand the
  642. * root cause, especially considering that the driver is
  643. * asserting all reset lines at probe time.
  644. */
  645. return -EPROBE_DEFER;
  646. }
  647. if (!udphy->flip) {
  648. ret = regmap_read_poll_timeout(udphy->pma_regmap,
  649. TRSV_LN0_MON_RX_CDR_DONE_OFFSET, val,
  650. val & TRSV_LN0_MON_RX_CDR_LOCK_DONE,
  651. 200, 100000);
  652. if (ret)
  653. dev_err(udphy->dev, "trsv ln0 mon rx cdr lock timeout\n");
  654. } else {
  655. ret = regmap_read_poll_timeout(udphy->pma_regmap,
  656. TRSV_LN2_MON_RX_CDR_DONE_OFFSET, val,
  657. val & TRSV_LN2_MON_RX_CDR_LOCK_DONE,
  658. 200, 100000);
  659. if (ret)
  660. dev_err(udphy->dev, "trsv ln2 mon rx cdr lock timeout\n");
  661. }
  662. }
  663. return 0;
  664. }
  665. static int rk_udphy_init(struct rk_udphy *udphy)
  666. {
  667. const struct rk_udphy_cfg *cfg = udphy->cfgs;
  668. int ret;
  669. rk_udphy_reset_assert_all(udphy);
  670. usleep_range(10000, 11000);
  671. /* enable rx lfps for usb */
  672. if (udphy->mode & UDPHY_MODE_USB)
  673. rk_udphy_grfreg_write(udphy->udphygrf, &cfg->grfcfg.rx_lfps, true);
  674. /* Step 1: power on pma and deassert apb rstn */
  675. rk_udphy_grfreg_write(udphy->udphygrf, &cfg->grfcfg.low_pwrn, true);
  676. rk_udphy_reset_deassert(udphy, "pma_apb");
  677. rk_udphy_reset_deassert(udphy, "pcs_apb");
  678. /* Step 2: set init sequence and phy refclk */
  679. ret = regmap_multi_reg_write(udphy->pma_regmap, rk_udphy_init_sequence,
  680. ARRAY_SIZE(rk_udphy_init_sequence));
  681. if (ret) {
  682. dev_err(udphy->dev, "init sequence set error %d\n", ret);
  683. goto assert_resets;
  684. }
  685. ret = rk_udphy_refclk_set(udphy);
  686. if (ret) {
  687. dev_err(udphy->dev, "refclk set error %d\n", ret);
  688. goto assert_resets;
  689. }
  690. /* Step 3: configure lane mux */
  691. regmap_update_bits(udphy->pma_regmap, CMN_LANE_MUX_AND_EN_OFFSET,
  692. CMN_DP_LANE_MUX_ALL | CMN_DP_LANE_EN_ALL,
  693. FIELD_PREP(CMN_DP_LANE_MUX_N(3), udphy->lane_mux_sel[3]) |
  694. FIELD_PREP(CMN_DP_LANE_MUX_N(2), udphy->lane_mux_sel[2]) |
  695. FIELD_PREP(CMN_DP_LANE_MUX_N(1), udphy->lane_mux_sel[1]) |
  696. FIELD_PREP(CMN_DP_LANE_MUX_N(0), udphy->lane_mux_sel[0]) |
  697. FIELD_PREP(CMN_DP_LANE_EN_ALL, 0));
  698. /* Step 4: deassert init rstn and wait for 200ns from datasheet */
  699. if (udphy->mode & UDPHY_MODE_USB)
  700. rk_udphy_reset_deassert(udphy, "init");
  701. if (udphy->mode & UDPHY_MODE_DP) {
  702. regmap_update_bits(udphy->pma_regmap, CMN_DP_RSTN_OFFSET,
  703. CMN_DP_INIT_RSTN,
  704. FIELD_PREP(CMN_DP_INIT_RSTN, 0x1));
  705. }
  706. udelay(1);
  707. /* Step 5: deassert cmn/lane rstn */
  708. if (udphy->mode & UDPHY_MODE_USB) {
  709. rk_udphy_reset_deassert(udphy, "cmn");
  710. rk_udphy_reset_deassert(udphy, "lane");
  711. }
  712. /* Step 6: wait for lock done of pll */
  713. ret = rk_udphy_status_check(udphy);
  714. if (ret)
  715. goto assert_resets;
  716. return 0;
  717. assert_resets:
  718. rk_udphy_reset_assert_all(udphy);
  719. return ret;
  720. }
  721. static int rk_udphy_setup(struct rk_udphy *udphy)
  722. {
  723. int ret;
  724. ret = clk_bulk_prepare_enable(udphy->num_clks, udphy->clks);
  725. if (ret) {
  726. dev_err(udphy->dev, "failed to enable clk\n");
  727. return ret;
  728. }
  729. ret = rk_udphy_init(udphy);
  730. if (ret) {
  731. dev_err(udphy->dev, "failed to init combophy\n");
  732. clk_bulk_disable_unprepare(udphy->num_clks, udphy->clks);
  733. return ret;
  734. }
  735. return 0;
  736. }
  737. static void rk_udphy_disable(struct rk_udphy *udphy)
  738. {
  739. clk_bulk_disable_unprepare(udphy->num_clks, udphy->clks);
  740. rk_udphy_reset_assert_all(udphy);
  741. }
  742. static int rk_udphy_parse_lane_mux_data(struct rk_udphy *udphy)
  743. {
  744. int ret, i, num_lanes;
  745. num_lanes = device_property_count_u32(udphy->dev, "rockchip,dp-lane-mux");
  746. if (num_lanes < 0) {
  747. dev_dbg(udphy->dev, "no dp-lane-mux, following dp alt mode\n");
  748. udphy->mode = UDPHY_MODE_USB;
  749. return 0;
  750. }
  751. if (num_lanes != 2 && num_lanes != 4)
  752. return dev_err_probe(udphy->dev, -EINVAL,
  753. "invalid number of lane mux\n");
  754. ret = device_property_read_u32_array(udphy->dev, "rockchip,dp-lane-mux",
  755. udphy->dp_lane_sel, num_lanes);
  756. if (ret)
  757. return dev_err_probe(udphy->dev, ret, "get dp lane mux failed\n");
  758. for (i = 0; i < num_lanes; i++) {
  759. int j;
  760. if (udphy->dp_lane_sel[i] > 3)
  761. return dev_err_probe(udphy->dev, -EINVAL,
  762. "lane mux between 0 and 3, exceeding the range\n");
  763. udphy->lane_mux_sel[udphy->dp_lane_sel[i]] = PHY_LANE_MUX_DP;
  764. for (j = i + 1; j < num_lanes; j++) {
  765. if (udphy->dp_lane_sel[i] == udphy->dp_lane_sel[j])
  766. return dev_err_probe(udphy->dev, -EINVAL,
  767. "set repeat lane mux value\n");
  768. }
  769. }
  770. udphy->mode = UDPHY_MODE_DP;
  771. if (num_lanes == 2) {
  772. udphy->mode |= UDPHY_MODE_USB;
  773. udphy->flip = (udphy->lane_mux_sel[0] == PHY_LANE_MUX_DP);
  774. }
  775. return 0;
  776. }
  777. static int rk_udphy_get_initial_status(struct rk_udphy *udphy)
  778. {
  779. int ret;
  780. u32 value;
  781. ret = clk_bulk_prepare_enable(udphy->num_clks, udphy->clks);
  782. if (ret) {
  783. dev_err(udphy->dev, "failed to enable clk\n");
  784. return ret;
  785. }
  786. rk_udphy_reset_deassert_all(udphy);
  787. regmap_read(udphy->pma_regmap, CMN_LANE_MUX_AND_EN_OFFSET, &value);
  788. if (FIELD_GET(CMN_DP_LANE_MUX_ALL, value) && FIELD_GET(CMN_DP_LANE_EN_ALL, value))
  789. udphy->status = UDPHY_MODE_DP;
  790. else
  791. rk_udphy_disable(udphy);
  792. return 0;
  793. }
  794. static int rk_udphy_parse_dt(struct rk_udphy *udphy)
  795. {
  796. struct device *dev = udphy->dev;
  797. struct device_node *np = dev_of_node(dev);
  798. enum usb_device_speed maximum_speed;
  799. int ret;
  800. udphy->u2phygrf = syscon_regmap_lookup_by_phandle(np, "rockchip,u2phy-grf");
  801. if (IS_ERR(udphy->u2phygrf))
  802. return dev_err_probe(dev, PTR_ERR(udphy->u2phygrf), "failed to get u2phy-grf\n");
  803. udphy->udphygrf = syscon_regmap_lookup_by_phandle(np, "rockchip,usbdpphy-grf");
  804. if (IS_ERR(udphy->udphygrf))
  805. return dev_err_probe(dev, PTR_ERR(udphy->udphygrf), "failed to get usbdpphy-grf\n");
  806. udphy->usbgrf = syscon_regmap_lookup_by_phandle(np, "rockchip,usb-grf");
  807. if (IS_ERR(udphy->usbgrf))
  808. return dev_err_probe(dev, PTR_ERR(udphy->usbgrf), "failed to get usb-grf\n");
  809. udphy->vogrf = syscon_regmap_lookup_by_phandle(np, "rockchip,vo-grf");
  810. if (IS_ERR(udphy->vogrf))
  811. return dev_err_probe(dev, PTR_ERR(udphy->vogrf), "failed to get vo-grf\n");
  812. ret = rk_udphy_parse_lane_mux_data(udphy);
  813. if (ret)
  814. return ret;
  815. udphy->sbu1_dc_gpio = devm_gpiod_get_optional(dev, "sbu1-dc", GPIOD_OUT_LOW);
  816. if (IS_ERR(udphy->sbu1_dc_gpio))
  817. return PTR_ERR(udphy->sbu1_dc_gpio);
  818. udphy->sbu2_dc_gpio = devm_gpiod_get_optional(dev, "sbu2-dc", GPIOD_OUT_LOW);
  819. if (IS_ERR(udphy->sbu2_dc_gpio))
  820. return PTR_ERR(udphy->sbu2_dc_gpio);
  821. if (device_property_present(dev, "maximum-speed")) {
  822. maximum_speed = usb_get_maximum_speed(dev);
  823. udphy->hs = maximum_speed <= USB_SPEED_HIGH ? true : false;
  824. }
  825. ret = rk_udphy_clk_init(udphy, dev);
  826. if (ret)
  827. return ret;
  828. return rk_udphy_reset_init(udphy, dev);
  829. }
  830. static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)
  831. {
  832. int ret;
  833. if (!(udphy->mode & mode)) {
  834. dev_info(udphy->dev, "mode 0x%02x is not support\n", mode);
  835. return 0;
  836. }
  837. if (udphy->status == UDPHY_MODE_NONE) {
  838. udphy->mode_change = false;
  839. ret = rk_udphy_setup(udphy);
  840. if (ret)
  841. return ret;
  842. if (udphy->mode & UDPHY_MODE_USB)
  843. rk_udphy_u3_port_disable(udphy, false);
  844. } else if (udphy->mode_change) {
  845. udphy->mode_change = false;
  846. udphy->status = UDPHY_MODE_NONE;
  847. if (udphy->mode == UDPHY_MODE_DP)
  848. rk_udphy_u3_port_disable(udphy, true);
  849. rk_udphy_disable(udphy);
  850. ret = rk_udphy_setup(udphy);
  851. if (ret)
  852. return ret;
  853. }
  854. udphy->status |= mode;
  855. return 0;
  856. }
  857. static void rk_udphy_power_off(struct rk_udphy *udphy, u8 mode)
  858. {
  859. if (!(udphy->mode & mode)) {
  860. dev_info(udphy->dev, "mode 0x%02x is not support\n", mode);
  861. return;
  862. }
  863. if (!udphy->status)
  864. return;
  865. udphy->status &= ~mode;
  866. if (udphy->status == UDPHY_MODE_NONE)
  867. rk_udphy_disable(udphy);
  868. }
  869. static int rk_udphy_dp_phy_init(struct phy *phy)
  870. {
  871. struct rk_udphy *udphy = phy_get_drvdata(phy);
  872. mutex_lock(&udphy->mutex);
  873. udphy->dp_in_use = true;
  874. rk_udphy_dp_hpd_event_trigger(udphy, udphy->dp_sink_hpd_cfg);
  875. mutex_unlock(&udphy->mutex);
  876. return 0;
  877. }
  878. static int rk_udphy_dp_phy_exit(struct phy *phy)
  879. {
  880. struct rk_udphy *udphy = phy_get_drvdata(phy);
  881. mutex_lock(&udphy->mutex);
  882. udphy->dp_in_use = false;
  883. mutex_unlock(&udphy->mutex);
  884. return 0;
  885. }
  886. static int rk_udphy_dp_phy_power_on(struct phy *phy)
  887. {
  888. struct rk_udphy *udphy = phy_get_drvdata(phy);
  889. int ret, dp_lanes;
  890. mutex_lock(&udphy->mutex);
  891. dp_lanes = rk_udphy_dplane_get(udphy);
  892. phy_set_bus_width(phy, dp_lanes);
  893. ret = rk_udphy_power_on(udphy, UDPHY_MODE_DP);
  894. if (ret)
  895. goto unlock;
  896. rk_udphy_dplane_enable(udphy, dp_lanes);
  897. rk_udphy_dplane_select(udphy);
  898. unlock:
  899. mutex_unlock(&udphy->mutex);
  900. /*
  901. * If data send by aux channel too fast after phy power on,
  902. * the aux may be not ready which will cause aux error. Adding
  903. * delay to avoid this issue.
  904. */
  905. usleep_range(10000, 11000);
  906. return ret;
  907. }
  908. static int rk_udphy_dp_phy_power_off(struct phy *phy)
  909. {
  910. struct rk_udphy *udphy = phy_get_drvdata(phy);
  911. mutex_lock(&udphy->mutex);
  912. rk_udphy_dplane_enable(udphy, 0);
  913. rk_udphy_power_off(udphy, UDPHY_MODE_DP);
  914. mutex_unlock(&udphy->mutex);
  915. return 0;
  916. }
  917. static int rk_udphy_dp_phy_verify_link_rate(unsigned int link_rate)
  918. {
  919. switch (link_rate) {
  920. case 1620:
  921. case 2700:
  922. case 5400:
  923. case 8100:
  924. break;
  925. default:
  926. return -EINVAL;
  927. }
  928. return 0;
  929. }
  930. static int rk_udphy_dp_phy_verify_config(struct rk_udphy *udphy,
  931. struct phy_configure_opts_dp *dp)
  932. {
  933. int i, ret;
  934. /* If changing link rate was required, verify it's supported. */
  935. ret = rk_udphy_dp_phy_verify_link_rate(dp->link_rate);
  936. if (ret)
  937. return ret;
  938. /* Verify lane count. */
  939. switch (dp->lanes) {
  940. case 1:
  941. case 2:
  942. case 4:
  943. /* valid lane count. */
  944. break;
  945. default:
  946. return -EINVAL;
  947. }
  948. /*
  949. * If changing voltages is required, check swing and pre-emphasis
  950. * levels, per-lane.
  951. */
  952. if (dp->set_voltages) {
  953. /* Lane count verified previously. */
  954. for (i = 0; i < dp->lanes; i++) {
  955. if (dp->voltage[i] > 3 || dp->pre[i] > 3)
  956. return -EINVAL;
  957. /*
  958. * Sum of voltage swing and pre-emphasis levels cannot
  959. * exceed 3.
  960. */
  961. if (dp->voltage[i] + dp->pre[i] > 3)
  962. return -EINVAL;
  963. }
  964. }
  965. return 0;
  966. }
  967. static void rk_udphy_dp_set_voltage(struct rk_udphy *udphy, u8 bw,
  968. u32 voltage, u32 pre, u32 lane)
  969. {
  970. const struct rk_udphy_cfg *cfg = udphy->cfgs;
  971. const struct rk_udphy_dp_tx_drv_ctrl (*dp_ctrl)[4];
  972. u32 offset = 0x800 * lane;
  973. u32 val;
  974. if (udphy->mux)
  975. dp_ctrl = cfg->dp_tx_ctrl_cfg_typec[bw];
  976. else
  977. dp_ctrl = cfg->dp_tx_ctrl_cfg[bw];
  978. val = dp_ctrl[voltage][pre].trsv_reg0204;
  979. regmap_write(udphy->pma_regmap, 0x0810 + offset, val);
  980. val = dp_ctrl[voltage][pre].trsv_reg0205;
  981. regmap_write(udphy->pma_regmap, 0x0814 + offset, val);
  982. val = dp_ctrl[voltage][pre].trsv_reg0206;
  983. regmap_write(udphy->pma_regmap, 0x0818 + offset, val);
  984. val = dp_ctrl[voltage][pre].trsv_reg0207;
  985. regmap_write(udphy->pma_regmap, 0x081c + offset, val);
  986. }
  987. static int rk_udphy_dp_phy_configure(struct phy *phy,
  988. union phy_configure_opts *opts)
  989. {
  990. struct rk_udphy *udphy = phy_get_drvdata(phy);
  991. struct phy_configure_opts_dp *dp = &opts->dp;
  992. u32 i, val, lane;
  993. int ret;
  994. ret = rk_udphy_dp_phy_verify_config(udphy, dp);
  995. if (ret)
  996. return ret;
  997. if (dp->set_rate) {
  998. regmap_update_bits(udphy->pma_regmap, CMN_DP_RSTN_OFFSET,
  999. CMN_DP_CMN_RSTN, FIELD_PREP(CMN_DP_CMN_RSTN, 0x0));
  1000. switch (dp->link_rate) {
  1001. case 1620:
  1002. udphy->bw = DP_BW_RBR;
  1003. break;
  1004. case 2700:
  1005. udphy->bw = DP_BW_HBR;
  1006. break;
  1007. case 5400:
  1008. udphy->bw = DP_BW_HBR2;
  1009. break;
  1010. case 8100:
  1011. udphy->bw = DP_BW_HBR3;
  1012. break;
  1013. default:
  1014. return -EINVAL;
  1015. }
  1016. regmap_update_bits(udphy->pma_regmap, CMN_DP_LINK_OFFSET, CMN_DP_TX_LINK_BW,
  1017. FIELD_PREP(CMN_DP_TX_LINK_BW, udphy->bw));
  1018. regmap_update_bits(udphy->pma_regmap, CMN_SSC_EN_OFFSET, CMN_ROPLL_SSC_EN,
  1019. FIELD_PREP(CMN_ROPLL_SSC_EN, dp->ssc));
  1020. regmap_update_bits(udphy->pma_regmap, CMN_DP_RSTN_OFFSET, CMN_DP_CMN_RSTN,
  1021. FIELD_PREP(CMN_DP_CMN_RSTN, 0x1));
  1022. ret = regmap_read_poll_timeout(udphy->pma_regmap, CMN_ANA_ROPLL_DONE_OFFSET, val,
  1023. FIELD_GET(CMN_ANA_ROPLL_LOCK_DONE, val) &&
  1024. FIELD_GET(CMN_ANA_ROPLL_AFC_DONE, val),
  1025. 0, 1000);
  1026. if (ret) {
  1027. dev_err(udphy->dev, "ROPLL is not lock, set_rate failed\n");
  1028. return ret;
  1029. }
  1030. }
  1031. if (dp->set_voltages) {
  1032. for (i = 0; i < dp->lanes; i++) {
  1033. lane = udphy->dp_lane_sel[i];
  1034. switch (dp->link_rate) {
  1035. case 1620:
  1036. case 2700:
  1037. regmap_update_bits(udphy->pma_regmap,
  1038. TRSV_ANA_TX_CLK_OFFSET_N(lane),
  1039. LN_ANA_TX_SER_TXCLK_INV,
  1040. FIELD_PREP(LN_ANA_TX_SER_TXCLK_INV,
  1041. udphy->lane_mux_sel[lane]));
  1042. break;
  1043. case 5400:
  1044. case 8100:
  1045. regmap_update_bits(udphy->pma_regmap,
  1046. TRSV_ANA_TX_CLK_OFFSET_N(lane),
  1047. LN_ANA_TX_SER_TXCLK_INV,
  1048. FIELD_PREP(LN_ANA_TX_SER_TXCLK_INV, 0x0));
  1049. break;
  1050. }
  1051. rk_udphy_dp_set_voltage(udphy, udphy->bw, dp->voltage[i],
  1052. dp->pre[i], lane);
  1053. }
  1054. }
  1055. return 0;
  1056. }
  1057. static const struct phy_ops rk_udphy_dp_phy_ops = {
  1058. .init = rk_udphy_dp_phy_init,
  1059. .exit = rk_udphy_dp_phy_exit,
  1060. .power_on = rk_udphy_dp_phy_power_on,
  1061. .power_off = rk_udphy_dp_phy_power_off,
  1062. .configure = rk_udphy_dp_phy_configure,
  1063. .owner = THIS_MODULE,
  1064. };
  1065. static int rk_udphy_usb3_phy_init(struct phy *phy)
  1066. {
  1067. struct rk_udphy *udphy = phy_get_drvdata(phy);
  1068. int ret = 0;
  1069. mutex_lock(&udphy->mutex);
  1070. /* DP only or high-speed, disable U3 port */
  1071. if (!(udphy->mode & UDPHY_MODE_USB) || udphy->hs) {
  1072. rk_udphy_u3_port_disable(udphy, true);
  1073. goto unlock;
  1074. }
  1075. ret = rk_udphy_power_on(udphy, UDPHY_MODE_USB);
  1076. unlock:
  1077. mutex_unlock(&udphy->mutex);
  1078. return ret;
  1079. }
  1080. static int rk_udphy_usb3_phy_exit(struct phy *phy)
  1081. {
  1082. struct rk_udphy *udphy = phy_get_drvdata(phy);
  1083. mutex_lock(&udphy->mutex);
  1084. /* DP only or high-speed */
  1085. if (!(udphy->mode & UDPHY_MODE_USB) || udphy->hs)
  1086. goto unlock;
  1087. rk_udphy_power_off(udphy, UDPHY_MODE_USB);
  1088. unlock:
  1089. mutex_unlock(&udphy->mutex);
  1090. return 0;
  1091. }
  1092. static const struct phy_ops rk_udphy_usb3_phy_ops = {
  1093. .init = rk_udphy_usb3_phy_init,
  1094. .exit = rk_udphy_usb3_phy_exit,
  1095. .owner = THIS_MODULE,
  1096. };
  1097. static int rk_udphy_typec_mux_set(struct typec_mux_dev *mux,
  1098. struct typec_mux_state *state)
  1099. {
  1100. struct rk_udphy *udphy = typec_mux_get_drvdata(mux);
  1101. u8 mode;
  1102. mutex_lock(&udphy->mutex);
  1103. switch (state->mode) {
  1104. case TYPEC_DP_STATE_C:
  1105. case TYPEC_DP_STATE_E:
  1106. udphy->lane_mux_sel[0] = PHY_LANE_MUX_DP;
  1107. udphy->lane_mux_sel[1] = PHY_LANE_MUX_DP;
  1108. udphy->lane_mux_sel[2] = PHY_LANE_MUX_DP;
  1109. udphy->lane_mux_sel[3] = PHY_LANE_MUX_DP;
  1110. mode = UDPHY_MODE_DP;
  1111. break;
  1112. case TYPEC_DP_STATE_D:
  1113. default:
  1114. if (udphy->flip) {
  1115. udphy->lane_mux_sel[0] = PHY_LANE_MUX_DP;
  1116. udphy->lane_mux_sel[1] = PHY_LANE_MUX_DP;
  1117. udphy->lane_mux_sel[2] = PHY_LANE_MUX_USB;
  1118. udphy->lane_mux_sel[3] = PHY_LANE_MUX_USB;
  1119. } else {
  1120. udphy->lane_mux_sel[0] = PHY_LANE_MUX_USB;
  1121. udphy->lane_mux_sel[1] = PHY_LANE_MUX_USB;
  1122. udphy->lane_mux_sel[2] = PHY_LANE_MUX_DP;
  1123. udphy->lane_mux_sel[3] = PHY_LANE_MUX_DP;
  1124. }
  1125. mode = UDPHY_MODE_DP_USB;
  1126. break;
  1127. }
  1128. if (state->alt && state->alt->svid == USB_TYPEC_DP_SID) {
  1129. struct typec_displayport_data *data = state->data;
  1130. if (!data) {
  1131. rk_udphy_dp_hpd_event_trigger(udphy, false);
  1132. } else if (data->status & DP_STATUS_IRQ_HPD) {
  1133. rk_udphy_dp_hpd_event_trigger(udphy, false);
  1134. usleep_range(750, 800);
  1135. rk_udphy_dp_hpd_event_trigger(udphy, true);
  1136. } else if (data->status & DP_STATUS_HPD_STATE) {
  1137. if (udphy->mode != mode) {
  1138. udphy->mode = mode;
  1139. udphy->mode_change = true;
  1140. }
  1141. rk_udphy_dp_hpd_event_trigger(udphy, true);
  1142. } else {
  1143. rk_udphy_dp_hpd_event_trigger(udphy, false);
  1144. }
  1145. }
  1146. mutex_unlock(&udphy->mutex);
  1147. return 0;
  1148. }
  1149. static void rk_udphy_typec_mux_unregister(void *data)
  1150. {
  1151. struct rk_udphy *udphy = data;
  1152. typec_mux_unregister(udphy->mux);
  1153. }
  1154. static int rk_udphy_setup_typec_mux(struct rk_udphy *udphy)
  1155. {
  1156. struct typec_mux_desc mux_desc = {};
  1157. mux_desc.drvdata = udphy;
  1158. mux_desc.fwnode = dev_fwnode(udphy->dev);
  1159. mux_desc.set = rk_udphy_typec_mux_set;
  1160. udphy->mux = typec_mux_register(udphy->dev, &mux_desc);
  1161. if (IS_ERR(udphy->mux)) {
  1162. dev_err(udphy->dev, "Error register typec mux: %ld\n",
  1163. PTR_ERR(udphy->mux));
  1164. return PTR_ERR(udphy->mux);
  1165. }
  1166. return devm_add_action_or_reset(udphy->dev, rk_udphy_typec_mux_unregister,
  1167. udphy);
  1168. }
  1169. static const struct regmap_config rk_udphy_pma_regmap_cfg = {
  1170. .reg_bits = 32,
  1171. .reg_stride = 4,
  1172. .val_bits = 32,
  1173. .fast_io = true,
  1174. .max_register = 0x20dc,
  1175. };
  1176. static struct phy *rk_udphy_phy_xlate(struct device *dev, const struct of_phandle_args *args)
  1177. {
  1178. struct rk_udphy *udphy = dev_get_drvdata(dev);
  1179. if (args->args_count == 0)
  1180. return ERR_PTR(-EINVAL);
  1181. switch (args->args[0]) {
  1182. case PHY_TYPE_USB3:
  1183. return udphy->phy_u3;
  1184. case PHY_TYPE_DP:
  1185. return udphy->phy_dp;
  1186. }
  1187. return ERR_PTR(-EINVAL);
  1188. }
  1189. static int rk_udphy_probe(struct platform_device *pdev)
  1190. {
  1191. struct device *dev = &pdev->dev;
  1192. struct phy_provider *phy_provider;
  1193. struct resource *res;
  1194. struct rk_udphy *udphy;
  1195. void __iomem *base;
  1196. int id, ret;
  1197. udphy = devm_kzalloc(dev, sizeof(*udphy), GFP_KERNEL);
  1198. if (!udphy)
  1199. return -ENOMEM;
  1200. udphy->cfgs = device_get_match_data(dev);
  1201. if (!udphy->cfgs)
  1202. return dev_err_probe(dev, -EINVAL, "missing match data\n");
  1203. base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
  1204. if (IS_ERR(base))
  1205. return PTR_ERR(base);
  1206. /* find the phy-id from the io address */
  1207. udphy->id = -ENODEV;
  1208. for (id = 0; id < udphy->cfgs->num_phys; id++) {
  1209. if (res->start == udphy->cfgs->phy_ids[id]) {
  1210. udphy->id = id;
  1211. break;
  1212. }
  1213. }
  1214. if (udphy->id < 0)
  1215. return dev_err_probe(dev, -ENODEV, "no matching device found\n");
  1216. udphy->pma_regmap = devm_regmap_init_mmio(dev, base + UDPHY_PMA,
  1217. &rk_udphy_pma_regmap_cfg);
  1218. if (IS_ERR(udphy->pma_regmap))
  1219. return PTR_ERR(udphy->pma_regmap);
  1220. udphy->dev = dev;
  1221. ret = rk_udphy_parse_dt(udphy);
  1222. if (ret)
  1223. return ret;
  1224. ret = rk_udphy_get_initial_status(udphy);
  1225. if (ret)
  1226. return ret;
  1227. mutex_init(&udphy->mutex);
  1228. platform_set_drvdata(pdev, udphy);
  1229. if (device_property_present(dev, "orientation-switch")) {
  1230. ret = rk_udphy_setup_orien_switch(udphy);
  1231. if (ret)
  1232. return ret;
  1233. }
  1234. if (device_property_present(dev, "mode-switch")) {
  1235. ret = rk_udphy_setup_typec_mux(udphy);
  1236. if (ret)
  1237. return ret;
  1238. }
  1239. udphy->phy_u3 = devm_phy_create(dev, dev->of_node, &rk_udphy_usb3_phy_ops);
  1240. if (IS_ERR(udphy->phy_u3)) {
  1241. ret = PTR_ERR(udphy->phy_u3);
  1242. return dev_err_probe(dev, ret, "failed to create USB3 phy\n");
  1243. }
  1244. phy_set_drvdata(udphy->phy_u3, udphy);
  1245. udphy->phy_dp = devm_phy_create(dev, dev->of_node, &rk_udphy_dp_phy_ops);
  1246. if (IS_ERR(udphy->phy_dp)) {
  1247. ret = PTR_ERR(udphy->phy_dp);
  1248. return dev_err_probe(dev, ret, "failed to create DP phy\n");
  1249. }
  1250. phy_set_bus_width(udphy->phy_dp, rk_udphy_dplane_get(udphy));
  1251. udphy->phy_dp->attrs.max_link_rate = 8100;
  1252. phy_set_drvdata(udphy->phy_dp, udphy);
  1253. phy_provider = devm_of_phy_provider_register(dev, rk_udphy_phy_xlate);
  1254. if (IS_ERR(phy_provider)) {
  1255. ret = PTR_ERR(phy_provider);
  1256. return dev_err_probe(dev, ret, "failed to register phy provider\n");
  1257. }
  1258. return 0;
  1259. }
  1260. static int __maybe_unused rk_udphy_resume(struct device *dev)
  1261. {
  1262. struct rk_udphy *udphy = dev_get_drvdata(dev);
  1263. if (udphy->dp_sink_hpd_sel)
  1264. rk_udphy_dp_hpd_event_trigger(udphy, udphy->dp_sink_hpd_cfg);
  1265. return 0;
  1266. }
  1267. static const struct dev_pm_ops rk_udphy_pm_ops = {
  1268. SET_LATE_SYSTEM_SLEEP_PM_OPS(NULL, rk_udphy_resume)
  1269. };
  1270. static const char * const rk_udphy_rst_list[] = {
  1271. "init", "cmn", "lane", "pcs_apb", "pma_apb"
  1272. };
  1273. static const struct rk_udphy_cfg rk3588_udphy_cfgs = {
  1274. .num_phys = 2,
  1275. .phy_ids = {
  1276. 0xfed80000,
  1277. 0xfed90000,
  1278. },
  1279. .num_rsts = ARRAY_SIZE(rk_udphy_rst_list),
  1280. .rst_list = rk_udphy_rst_list,
  1281. .grfcfg = {
  1282. /* u2phy-grf */
  1283. .bvalid_phy_con = RK_UDPHY_GEN_GRF_REG(0x0008, 1, 0, 0x2, 0x3),
  1284. .bvalid_grf_con = RK_UDPHY_GEN_GRF_REG(0x0010, 3, 2, 0x2, 0x3),
  1285. /* usb-grf */
  1286. .usb3otg0_cfg = RK_UDPHY_GEN_GRF_REG(0x001c, 15, 0, 0x1100, 0x0188),
  1287. .usb3otg1_cfg = RK_UDPHY_GEN_GRF_REG(0x0034, 15, 0, 0x1100, 0x0188),
  1288. /* usbdpphy-grf */
  1289. .low_pwrn = RK_UDPHY_GEN_GRF_REG(0x0004, 13, 13, 0, 1),
  1290. .rx_lfps = RK_UDPHY_GEN_GRF_REG(0x0004, 14, 14, 0, 1),
  1291. },
  1292. .vogrfcfg = {
  1293. {
  1294. .hpd_trigger = RK_UDPHY_GEN_GRF_REG(0x0000, 11, 10, 1, 3),
  1295. .dp_lane_reg = 0x0000,
  1296. },
  1297. {
  1298. .hpd_trigger = RK_UDPHY_GEN_GRF_REG(0x0008, 11, 10, 1, 3),
  1299. .dp_lane_reg = 0x0008,
  1300. },
  1301. },
  1302. .dp_tx_ctrl_cfg = {
  1303. rk3588_dp_tx_drv_ctrl_rbr_hbr,
  1304. rk3588_dp_tx_drv_ctrl_rbr_hbr,
  1305. rk3588_dp_tx_drv_ctrl_hbr2,
  1306. rk3588_dp_tx_drv_ctrl_hbr3,
  1307. },
  1308. .dp_tx_ctrl_cfg_typec = {
  1309. rk3588_dp_tx_drv_ctrl_rbr_hbr_typec,
  1310. rk3588_dp_tx_drv_ctrl_rbr_hbr_typec,
  1311. rk3588_dp_tx_drv_ctrl_hbr2,
  1312. rk3588_dp_tx_drv_ctrl_hbr3,
  1313. },
  1314. };
  1315. static const struct of_device_id rk_udphy_dt_match[] = {
  1316. {
  1317. .compatible = "rockchip,rk3588-usbdp-phy",
  1318. .data = &rk3588_udphy_cfgs
  1319. },
  1320. { /* sentinel */ }
  1321. };
  1322. MODULE_DEVICE_TABLE(of, rk_udphy_dt_match);
  1323. static struct platform_driver rk_udphy_driver = {
  1324. .probe = rk_udphy_probe,
  1325. .driver = {
  1326. .name = "rockchip-usbdp-phy",
  1327. .of_match_table = rk_udphy_dt_match,
  1328. .pm = &rk_udphy_pm_ops,
  1329. },
  1330. };
  1331. module_platform_driver(rk_udphy_driver);
  1332. MODULE_AUTHOR("Frank Wang <frank.wang@rock-chips.com>");
  1333. MODULE_AUTHOR("Zhang Yubing <yubing.zhang@rock-chips.com>");
  1334. MODULE_DESCRIPTION("Rockchip USBDP Combo PHY driver");
  1335. MODULE_LICENSE("GPL");