phy-rockchip-naneng-combphy.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Rockchip PIPE USB3.0 PCIE SATA Combo Phy driver
  4. *
  5. * Copyright (C) 2021 Rockchip Electronics Co., Ltd.
  6. */
  7. #include <dt-bindings/phy/phy.h>
  8. #include <linux/clk.h>
  9. #include <linux/mfd/syscon.h>
  10. #include <linux/of_device.h>
  11. #include <linux/phy/phy.h>
  12. #include <linux/regmap.h>
  13. #include <linux/reset.h>
  14. #include <linux/units.h>
  15. #define BIT_WRITEABLE_SHIFT 16
  16. #define REF_CLOCK_24MHz (24 * HZ_PER_MHZ)
  17. #define REF_CLOCK_25MHz (25 * HZ_PER_MHZ)
  18. #define REF_CLOCK_100MHz (100 * HZ_PER_MHZ)
  19. /* COMBO PHY REG */
  20. #define PHYREG6 0x14
  21. #define PHYREG6_PLL_DIV_MASK GENMASK(7, 6)
  22. #define PHYREG6_PLL_DIV_SHIFT 6
  23. #define PHYREG6_PLL_DIV_2 1
  24. #define PHYREG7 0x18
  25. #define PHYREG7_TX_RTERM_MASK GENMASK(7, 4)
  26. #define PHYREG7_TX_RTERM_SHIFT 4
  27. #define PHYREG7_TX_RTERM_50OHM 8
  28. #define PHYREG7_RX_RTERM_MASK GENMASK(3, 0)
  29. #define PHYREG7_RX_RTERM_SHIFT 0
  30. #define PHYREG7_RX_RTERM_44OHM 15
  31. #define PHYREG8 0x1C
  32. #define PHYREG8_SSC_EN BIT(4)
  33. #define PHYREG11 0x28
  34. #define PHYREG11_SU_TRIM_0_7 0xF0
  35. #define PHYREG12 0x2C
  36. #define PHYREG12_PLL_LPF_ADJ_VALUE 4
  37. #define PHYREG13 0x30
  38. #define PHYREG13_RESISTER_MASK GENMASK(5, 4)
  39. #define PHYREG13_RESISTER_SHIFT 0x4
  40. #define PHYREG13_RESISTER_HIGH_Z 3
  41. #define PHYREG13_CKRCV_AMP0 BIT(7)
  42. #define PHYREG14 0x34
  43. #define PHYREG14_CKRCV_AMP1 BIT(0)
  44. #define PHYREG15 0x38
  45. #define PHYREG15_CTLE_EN BIT(0)
  46. #define PHYREG15_SSC_CNT_MASK GENMASK(7, 6)
  47. #define PHYREG15_SSC_CNT_SHIFT 6
  48. #define PHYREG15_SSC_CNT_VALUE 1
  49. #define PHYREG16 0x3C
  50. #define PHYREG16_SSC_CNT_VALUE 0x5f
  51. #define PHYREG18 0x44
  52. #define PHYREG18_PLL_LOOP 0x32
  53. #define PHYREG32 0x7C
  54. #define PHYREG32_SSC_MASK GENMASK(7, 4)
  55. #define PHYREG32_SSC_DIR_SHIFT 4
  56. #define PHYREG32_SSC_UPWARD 0
  57. #define PHYREG32_SSC_DOWNWARD 1
  58. #define PHYREG32_SSC_OFFSET_SHIFT 6
  59. #define PHYREG32_SSC_OFFSET_500PPM 1
  60. #define PHYREG33 0x80
  61. #define PHYREG33_PLL_KVCO_MASK GENMASK(4, 2)
  62. #define PHYREG33_PLL_KVCO_SHIFT 2
  63. #define PHYREG33_PLL_KVCO_VALUE 2
  64. struct rockchip_combphy_priv;
  65. struct combphy_reg {
  66. u16 offset;
  67. u16 bitend;
  68. u16 bitstart;
  69. u16 disable;
  70. u16 enable;
  71. };
  72. struct rockchip_combphy_grfcfg {
  73. struct combphy_reg pcie_mode_set;
  74. struct combphy_reg usb_mode_set;
  75. struct combphy_reg sgmii_mode_set;
  76. struct combphy_reg qsgmii_mode_set;
  77. struct combphy_reg pipe_rxterm_set;
  78. struct combphy_reg pipe_txelec_set;
  79. struct combphy_reg pipe_txcomp_set;
  80. struct combphy_reg pipe_clk_25m;
  81. struct combphy_reg pipe_clk_100m;
  82. struct combphy_reg pipe_phymode_sel;
  83. struct combphy_reg pipe_rate_sel;
  84. struct combphy_reg pipe_rxterm_sel;
  85. struct combphy_reg pipe_txelec_sel;
  86. struct combphy_reg pipe_txcomp_sel;
  87. struct combphy_reg pipe_clk_ext;
  88. struct combphy_reg pipe_sel_usb;
  89. struct combphy_reg pipe_sel_qsgmii;
  90. struct combphy_reg pipe_phy_status;
  91. struct combphy_reg con0_for_pcie;
  92. struct combphy_reg con1_for_pcie;
  93. struct combphy_reg con2_for_pcie;
  94. struct combphy_reg con3_for_pcie;
  95. struct combphy_reg con0_for_sata;
  96. struct combphy_reg con1_for_sata;
  97. struct combphy_reg con2_for_sata;
  98. struct combphy_reg con3_for_sata;
  99. struct combphy_reg pipe_con0_for_sata;
  100. struct combphy_reg pipe_xpcs_phy_ready;
  101. };
  102. struct rockchip_combphy_cfg {
  103. const struct rockchip_combphy_grfcfg *grfcfg;
  104. int (*combphy_cfg)(struct rockchip_combphy_priv *priv);
  105. };
  106. struct rockchip_combphy_priv {
  107. u8 type;
  108. void __iomem *mmio;
  109. int num_clks;
  110. struct clk_bulk_data *clks;
  111. struct device *dev;
  112. struct regmap *pipe_grf;
  113. struct regmap *phy_grf;
  114. struct phy *phy;
  115. struct reset_control *phy_rst;
  116. const struct rockchip_combphy_cfg *cfg;
  117. bool enable_ssc;
  118. bool ext_refclk;
  119. struct clk *refclk;
  120. };
  121. static void rockchip_combphy_updatel(struct rockchip_combphy_priv *priv,
  122. int mask, int val, int reg)
  123. {
  124. unsigned int temp;
  125. temp = readl(priv->mmio + reg);
  126. temp = (temp & ~(mask)) | val;
  127. writel(temp, priv->mmio + reg);
  128. }
  129. static int rockchip_combphy_param_write(struct regmap *base,
  130. const struct combphy_reg *reg, bool en)
  131. {
  132. u32 val, mask, tmp;
  133. tmp = en ? reg->enable : reg->disable;
  134. mask = GENMASK(reg->bitend, reg->bitstart);
  135. val = (tmp << reg->bitstart) | (mask << BIT_WRITEABLE_SHIFT);
  136. return regmap_write(base, reg->offset, val);
  137. }
  138. static u32 rockchip_combphy_is_ready(struct rockchip_combphy_priv *priv)
  139. {
  140. const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
  141. u32 mask, val;
  142. mask = GENMASK(cfg->pipe_phy_status.bitend,
  143. cfg->pipe_phy_status.bitstart);
  144. regmap_read(priv->phy_grf, cfg->pipe_phy_status.offset, &val);
  145. val = (val & mask) >> cfg->pipe_phy_status.bitstart;
  146. return val;
  147. }
  148. static int rockchip_combphy_init(struct phy *phy)
  149. {
  150. struct rockchip_combphy_priv *priv = phy_get_drvdata(phy);
  151. const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
  152. u32 val;
  153. int ret;
  154. ret = clk_bulk_prepare_enable(priv->num_clks, priv->clks);
  155. if (ret) {
  156. dev_err(priv->dev, "failed to enable clks\n");
  157. return ret;
  158. }
  159. switch (priv->type) {
  160. case PHY_TYPE_PCIE:
  161. case PHY_TYPE_USB3:
  162. case PHY_TYPE_SATA:
  163. case PHY_TYPE_SGMII:
  164. case PHY_TYPE_QSGMII:
  165. if (priv->cfg->combphy_cfg)
  166. ret = priv->cfg->combphy_cfg(priv);
  167. break;
  168. default:
  169. dev_err(priv->dev, "incompatible PHY type\n");
  170. ret = -EINVAL;
  171. break;
  172. }
  173. if (ret) {
  174. dev_err(priv->dev, "failed to init phy for phy type %x\n", priv->type);
  175. goto err_clk;
  176. }
  177. ret = reset_control_deassert(priv->phy_rst);
  178. if (ret)
  179. goto err_clk;
  180. if (priv->type == PHY_TYPE_USB3) {
  181. ret = readx_poll_timeout_atomic(rockchip_combphy_is_ready,
  182. priv, val,
  183. val == cfg->pipe_phy_status.enable,
  184. 10, 1000);
  185. if (ret)
  186. dev_warn(priv->dev, "wait phy status ready timeout\n");
  187. }
  188. return 0;
  189. err_clk:
  190. clk_bulk_disable_unprepare(priv->num_clks, priv->clks);
  191. return ret;
  192. }
  193. static int rockchip_combphy_exit(struct phy *phy)
  194. {
  195. struct rockchip_combphy_priv *priv = phy_get_drvdata(phy);
  196. clk_bulk_disable_unprepare(priv->num_clks, priv->clks);
  197. reset_control_assert(priv->phy_rst);
  198. return 0;
  199. }
  200. static const struct phy_ops rochchip_combphy_ops = {
  201. .init = rockchip_combphy_init,
  202. .exit = rockchip_combphy_exit,
  203. .owner = THIS_MODULE,
  204. };
  205. static struct phy *rockchip_combphy_xlate(struct device *dev, struct of_phandle_args *args)
  206. {
  207. struct rockchip_combphy_priv *priv = dev_get_drvdata(dev);
  208. if (args->args_count != 1) {
  209. dev_err(dev, "invalid number of arguments\n");
  210. return ERR_PTR(-EINVAL);
  211. }
  212. if (priv->type != PHY_NONE && priv->type != args->args[0])
  213. dev_warn(dev, "phy type select %d overwriting type %d\n",
  214. args->args[0], priv->type);
  215. priv->type = args->args[0];
  216. return priv->phy;
  217. }
  218. static int rockchip_combphy_parse_dt(struct device *dev, struct rockchip_combphy_priv *priv)
  219. {
  220. int i;
  221. priv->num_clks = devm_clk_bulk_get_all(dev, &priv->clks);
  222. if (priv->num_clks < 1)
  223. return -EINVAL;
  224. priv->refclk = NULL;
  225. for (i = 0; i < priv->num_clks; i++) {
  226. if (!strncmp(priv->clks[i].id, "ref", 3)) {
  227. priv->refclk = priv->clks[i].clk;
  228. break;
  229. }
  230. }
  231. if (!priv->refclk) {
  232. dev_err(dev, "no refclk found\n");
  233. return -EINVAL;
  234. }
  235. priv->pipe_grf = syscon_regmap_lookup_by_phandle(dev->of_node, "rockchip,pipe-grf");
  236. if (IS_ERR(priv->pipe_grf)) {
  237. dev_err(dev, "failed to find peri_ctrl pipe-grf regmap\n");
  238. return PTR_ERR(priv->pipe_grf);
  239. }
  240. priv->phy_grf = syscon_regmap_lookup_by_phandle(dev->of_node, "rockchip,pipe-phy-grf");
  241. if (IS_ERR(priv->phy_grf)) {
  242. dev_err(dev, "failed to find peri_ctrl pipe-phy-grf regmap\n");
  243. return PTR_ERR(priv->phy_grf);
  244. }
  245. priv->enable_ssc = device_property_present(dev, "rockchip,enable-ssc");
  246. priv->ext_refclk = device_property_present(dev, "rockchip,ext-refclk");
  247. priv->phy_rst = devm_reset_control_array_get_exclusive(dev);
  248. if (IS_ERR(priv->phy_rst))
  249. return dev_err_probe(dev, PTR_ERR(priv->phy_rst), "failed to get phy reset\n");
  250. return 0;
  251. }
  252. static int rockchip_combphy_probe(struct platform_device *pdev)
  253. {
  254. struct phy_provider *phy_provider;
  255. struct device *dev = &pdev->dev;
  256. struct rockchip_combphy_priv *priv;
  257. const struct rockchip_combphy_cfg *phy_cfg;
  258. struct resource *res;
  259. int ret;
  260. phy_cfg = of_device_get_match_data(dev);
  261. if (!phy_cfg) {
  262. dev_err(dev, "no OF match data provided\n");
  263. return -EINVAL;
  264. }
  265. priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  266. if (!priv)
  267. return -ENOMEM;
  268. priv->mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
  269. if (IS_ERR(priv->mmio)) {
  270. ret = PTR_ERR(priv->mmio);
  271. return ret;
  272. }
  273. priv->dev = dev;
  274. priv->type = PHY_NONE;
  275. priv->cfg = phy_cfg;
  276. ret = rockchip_combphy_parse_dt(dev, priv);
  277. if (ret)
  278. return ret;
  279. ret = reset_control_assert(priv->phy_rst);
  280. if (ret) {
  281. dev_err(dev, "failed to reset phy\n");
  282. return ret;
  283. }
  284. priv->phy = devm_phy_create(dev, NULL, &rochchip_combphy_ops);
  285. if (IS_ERR(priv->phy)) {
  286. dev_err(dev, "failed to create combphy\n");
  287. return PTR_ERR(priv->phy);
  288. }
  289. dev_set_drvdata(dev, priv);
  290. phy_set_drvdata(priv->phy, priv);
  291. phy_provider = devm_of_phy_provider_register(dev, rockchip_combphy_xlate);
  292. return PTR_ERR_OR_ZERO(phy_provider);
  293. }
  294. static int rk3568_combphy_cfg(struct rockchip_combphy_priv *priv)
  295. {
  296. const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
  297. unsigned long rate;
  298. u32 val;
  299. switch (priv->type) {
  300. case PHY_TYPE_PCIE:
  301. /* Set SSC downward spread spectrum. */
  302. rockchip_combphy_updatel(priv, PHYREG32_SSC_MASK,
  303. PHYREG32_SSC_DOWNWARD << PHYREG32_SSC_DIR_SHIFT,
  304. PHYREG32);
  305. rockchip_combphy_param_write(priv->phy_grf, &cfg->con0_for_pcie, true);
  306. rockchip_combphy_param_write(priv->phy_grf, &cfg->con1_for_pcie, true);
  307. rockchip_combphy_param_write(priv->phy_grf, &cfg->con2_for_pcie, true);
  308. rockchip_combphy_param_write(priv->phy_grf, &cfg->con3_for_pcie, true);
  309. break;
  310. case PHY_TYPE_USB3:
  311. /* Set SSC downward spread spectrum. */
  312. rockchip_combphy_updatel(priv, PHYREG32_SSC_MASK,
  313. PHYREG32_SSC_DOWNWARD << PHYREG32_SSC_DIR_SHIFT,
  314. PHYREG32);
  315. /* Enable adaptive CTLE for USB3.0 Rx. */
  316. val = readl(priv->mmio + PHYREG15);
  317. val |= PHYREG15_CTLE_EN;
  318. writel(val, priv->mmio + PHYREG15);
  319. /* Set PLL KVCO fine tuning signals. */
  320. rockchip_combphy_updatel(priv, PHYREG33_PLL_KVCO_MASK,
  321. PHYREG33_PLL_KVCO_VALUE << PHYREG33_PLL_KVCO_SHIFT,
  322. PHYREG33);
  323. /* Enable controlling random jitter. */
  324. writel(PHYREG12_PLL_LPF_ADJ_VALUE, priv->mmio + PHYREG12);
  325. /* Set PLL input clock divider 1/2. */
  326. rockchip_combphy_updatel(priv, PHYREG6_PLL_DIV_MASK,
  327. PHYREG6_PLL_DIV_2 << PHYREG6_PLL_DIV_SHIFT,
  328. PHYREG6);
  329. writel(PHYREG18_PLL_LOOP, priv->mmio + PHYREG18);
  330. writel(PHYREG11_SU_TRIM_0_7, priv->mmio + PHYREG11);
  331. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_sel_usb, true);
  332. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_txcomp_sel, false);
  333. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_txelec_sel, false);
  334. rockchip_combphy_param_write(priv->phy_grf, &cfg->usb_mode_set, true);
  335. break;
  336. case PHY_TYPE_SATA:
  337. /* Enable adaptive CTLE for SATA Rx. */
  338. val = readl(priv->mmio + PHYREG15);
  339. val |= PHYREG15_CTLE_EN;
  340. writel(val, priv->mmio + PHYREG15);
  341. /*
  342. * Set tx_rterm=50ohm and rx_rterm=44ohm for SATA.
  343. * 0: 60ohm, 8: 50ohm 15: 44ohm (by step abort 1ohm)
  344. */
  345. val = PHYREG7_TX_RTERM_50OHM << PHYREG7_TX_RTERM_SHIFT;
  346. val |= PHYREG7_RX_RTERM_44OHM << PHYREG7_RX_RTERM_SHIFT;
  347. writel(val, priv->mmio + PHYREG7);
  348. rockchip_combphy_param_write(priv->phy_grf, &cfg->con0_for_sata, true);
  349. rockchip_combphy_param_write(priv->phy_grf, &cfg->con1_for_sata, true);
  350. rockchip_combphy_param_write(priv->phy_grf, &cfg->con2_for_sata, true);
  351. rockchip_combphy_param_write(priv->phy_grf, &cfg->con3_for_sata, true);
  352. rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_con0_for_sata, true);
  353. break;
  354. case PHY_TYPE_SGMII:
  355. rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_xpcs_phy_ready, true);
  356. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_phymode_sel, true);
  357. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_sel_qsgmii, true);
  358. rockchip_combphy_param_write(priv->phy_grf, &cfg->sgmii_mode_set, true);
  359. break;
  360. case PHY_TYPE_QSGMII:
  361. rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_xpcs_phy_ready, true);
  362. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_phymode_sel, true);
  363. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_rate_sel, true);
  364. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_sel_qsgmii, true);
  365. rockchip_combphy_param_write(priv->phy_grf, &cfg->qsgmii_mode_set, true);
  366. break;
  367. default:
  368. dev_err(priv->dev, "incompatible PHY type\n");
  369. return -EINVAL;
  370. }
  371. rate = clk_get_rate(priv->refclk);
  372. switch (rate) {
  373. case REF_CLOCK_24MHz:
  374. if (priv->type == PHY_TYPE_USB3 || priv->type == PHY_TYPE_SATA) {
  375. /* Set ssc_cnt[9:0]=0101111101 & 31.5KHz. */
  376. val = PHYREG15_SSC_CNT_VALUE << PHYREG15_SSC_CNT_SHIFT;
  377. rockchip_combphy_updatel(priv, PHYREG15_SSC_CNT_MASK,
  378. val, PHYREG15);
  379. writel(PHYREG16_SSC_CNT_VALUE, priv->mmio + PHYREG16);
  380. }
  381. break;
  382. case REF_CLOCK_25MHz:
  383. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_clk_25m, true);
  384. break;
  385. case REF_CLOCK_100MHz:
  386. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_clk_100m, true);
  387. if (priv->type == PHY_TYPE_PCIE) {
  388. /* PLL KVCO fine tuning. */
  389. val = PHYREG33_PLL_KVCO_VALUE << PHYREG33_PLL_KVCO_SHIFT;
  390. rockchip_combphy_updatel(priv, PHYREG33_PLL_KVCO_MASK,
  391. val, PHYREG33);
  392. /* Enable controlling random jitter. */
  393. writel(PHYREG12_PLL_LPF_ADJ_VALUE, priv->mmio + PHYREG12);
  394. val = PHYREG6_PLL_DIV_2 << PHYREG6_PLL_DIV_SHIFT;
  395. rockchip_combphy_updatel(priv, PHYREG6_PLL_DIV_MASK,
  396. val, PHYREG6);
  397. writel(PHYREG18_PLL_LOOP, priv->mmio + PHYREG18);
  398. writel(PHYREG11_SU_TRIM_0_7, priv->mmio + PHYREG11);
  399. } else if (priv->type == PHY_TYPE_SATA) {
  400. /* downward spread spectrum +500ppm */
  401. val = PHYREG32_SSC_DOWNWARD << PHYREG32_SSC_DIR_SHIFT;
  402. val |= PHYREG32_SSC_OFFSET_500PPM << PHYREG32_SSC_OFFSET_SHIFT;
  403. rockchip_combphy_updatel(priv, PHYREG32_SSC_MASK, val, PHYREG32);
  404. }
  405. break;
  406. default:
  407. dev_err(priv->dev, "unsupported rate: %lu\n", rate);
  408. return -EINVAL;
  409. }
  410. if (priv->ext_refclk) {
  411. rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_clk_ext, true);
  412. if (priv->type == PHY_TYPE_PCIE && rate == REF_CLOCK_100MHz) {
  413. val = PHYREG13_RESISTER_HIGH_Z << PHYREG13_RESISTER_SHIFT;
  414. val |= PHYREG13_CKRCV_AMP0;
  415. rockchip_combphy_updatel(priv, PHYREG13_RESISTER_MASK, val, PHYREG13);
  416. val = readl(priv->mmio + PHYREG14);
  417. val |= PHYREG14_CKRCV_AMP1;
  418. writel(val, priv->mmio + PHYREG14);
  419. }
  420. }
  421. if (priv->enable_ssc) {
  422. val = readl(priv->mmio + PHYREG8);
  423. val |= PHYREG8_SSC_EN;
  424. writel(val, priv->mmio + PHYREG8);
  425. }
  426. return 0;
  427. }
  428. static const struct rockchip_combphy_grfcfg rk3568_combphy_grfcfgs = {
  429. /* pipe-phy-grf */
  430. .pcie_mode_set = { 0x0000, 5, 0, 0x00, 0x11 },
  431. .usb_mode_set = { 0x0000, 5, 0, 0x00, 0x04 },
  432. .sgmii_mode_set = { 0x0000, 5, 0, 0x00, 0x01 },
  433. .qsgmii_mode_set = { 0x0000, 5, 0, 0x00, 0x21 },
  434. .pipe_rxterm_set = { 0x0000, 12, 12, 0x00, 0x01 },
  435. .pipe_txelec_set = { 0x0004, 1, 1, 0x00, 0x01 },
  436. .pipe_txcomp_set = { 0x0004, 4, 4, 0x00, 0x01 },
  437. .pipe_clk_25m = { 0x0004, 14, 13, 0x00, 0x01 },
  438. .pipe_clk_100m = { 0x0004, 14, 13, 0x00, 0x02 },
  439. .pipe_phymode_sel = { 0x0008, 1, 1, 0x00, 0x01 },
  440. .pipe_rate_sel = { 0x0008, 2, 2, 0x00, 0x01 },
  441. .pipe_rxterm_sel = { 0x0008, 8, 8, 0x00, 0x01 },
  442. .pipe_txelec_sel = { 0x0008, 12, 12, 0x00, 0x01 },
  443. .pipe_txcomp_sel = { 0x0008, 15, 15, 0x00, 0x01 },
  444. .pipe_clk_ext = { 0x000c, 9, 8, 0x02, 0x01 },
  445. .pipe_sel_usb = { 0x000c, 14, 13, 0x00, 0x01 },
  446. .pipe_sel_qsgmii = { 0x000c, 15, 13, 0x00, 0x07 },
  447. .pipe_phy_status = { 0x0034, 6, 6, 0x01, 0x00 },
  448. .con0_for_pcie = { 0x0000, 15, 0, 0x00, 0x1000 },
  449. .con1_for_pcie = { 0x0004, 15, 0, 0x00, 0x0000 },
  450. .con2_for_pcie = { 0x0008, 15, 0, 0x00, 0x0101 },
  451. .con3_for_pcie = { 0x000c, 15, 0, 0x00, 0x0200 },
  452. .con0_for_sata = { 0x0000, 15, 0, 0x00, 0x0119 },
  453. .con1_for_sata = { 0x0004, 15, 0, 0x00, 0x0040 },
  454. .con2_for_sata = { 0x0008, 15, 0, 0x00, 0x80c3 },
  455. .con3_for_sata = { 0x000c, 15, 0, 0x00, 0x4407 },
  456. /* pipe-grf */
  457. .pipe_con0_for_sata = { 0x0000, 15, 0, 0x00, 0x2220 },
  458. .pipe_xpcs_phy_ready = { 0x0040, 2, 2, 0x00, 0x01 },
  459. };
  460. static const struct rockchip_combphy_cfg rk3568_combphy_cfgs = {
  461. .grfcfg = &rk3568_combphy_grfcfgs,
  462. .combphy_cfg = rk3568_combphy_cfg,
  463. };
  464. static const struct of_device_id rockchip_combphy_of_match[] = {
  465. {
  466. .compatible = "rockchip,rk3568-naneng-combphy",
  467. .data = &rk3568_combphy_cfgs,
  468. },
  469. { },
  470. };
  471. MODULE_DEVICE_TABLE(of, rockchip_combphy_of_match);
  472. static struct platform_driver rockchip_combphy_driver = {
  473. .probe = rockchip_combphy_probe,
  474. .driver = {
  475. .name = "rockchip-naneng-combphy",
  476. .of_match_table = rockchip_combphy_of_match,
  477. },
  478. };
  479. module_platform_driver(rockchip_combphy_driver);
  480. MODULE_DESCRIPTION("Rockchip NANENG COMBPHY driver");
  481. MODULE_LICENSE("GPL v2");