phy-rockchip-usbdp.c 41 KB

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