xref: /rk3399_rockchip-uboot/drivers/phy/phy-rockchip-naneng-combphy.c (revision 3452d642419d9f5c9cf33e8103c3ff544edd016b)
1925c5749SYifeng Zhao // SPDX-License-Identifier: GPL-2.0
2925c5749SYifeng Zhao /*
3925c5749SYifeng Zhao  * Rockchip USB3.0/PCIe Gen2/SATA/SGMII combphy driver
4925c5749SYifeng Zhao  *
5925c5749SYifeng Zhao  * Copyright (C) 2021 Rockchip Electronics Co., Ltd.
6925c5749SYifeng Zhao  */
7925c5749SYifeng Zhao 
8925c5749SYifeng Zhao #include <common.h>
9925c5749SYifeng Zhao #include <clk.h>
10925c5749SYifeng Zhao #include <dm.h>
11925c5749SYifeng Zhao #include <dm/lists.h>
12925c5749SYifeng Zhao #include <dt-bindings/phy/phy.h>
13925c5749SYifeng Zhao #include <generic-phy.h>
14925c5749SYifeng Zhao #include <syscon.h>
15925c5749SYifeng Zhao #include <asm/io.h>
16925c5749SYifeng Zhao #include <asm/arch/clock.h>
17925c5749SYifeng Zhao #include <regmap.h>
18925c5749SYifeng Zhao #include <reset-uclass.h>
19925c5749SYifeng Zhao 
20925c5749SYifeng Zhao #define BIT_WRITEABLE_SHIFT		16
21925c5749SYifeng Zhao 
22925c5749SYifeng Zhao struct rockchip_combphy_priv;
23925c5749SYifeng Zhao 
24925c5749SYifeng Zhao struct combphy_reg {
25*3452d642SJianwei Zheng 	u32 offset;
26925c5749SYifeng Zhao 	u16 bitend;
27925c5749SYifeng Zhao 	u16 bitstart;
28925c5749SYifeng Zhao 	u16 disable;
29925c5749SYifeng Zhao 	u16 enable;
30925c5749SYifeng Zhao };
31925c5749SYifeng Zhao 
32925c5749SYifeng Zhao struct rockchip_combphy_grfcfg {
33925c5749SYifeng Zhao 	struct combphy_reg pcie_mode_set;
34925c5749SYifeng Zhao 	struct combphy_reg usb_mode_set;
35925c5749SYifeng Zhao 	struct combphy_reg sgmii_mode_set;
36925c5749SYifeng Zhao 	struct combphy_reg qsgmii_mode_set;
37925c5749SYifeng Zhao 	struct combphy_reg pipe_rxterm_set;
38925c5749SYifeng Zhao 	struct combphy_reg pipe_txelec_set;
39925c5749SYifeng Zhao 	struct combphy_reg pipe_txcomp_set;
40*3452d642SJianwei Zheng 	struct combphy_reg pipe_clk_24m;
41925c5749SYifeng Zhao 	struct combphy_reg pipe_clk_25m;
42925c5749SYifeng Zhao 	struct combphy_reg pipe_clk_100m;
43925c5749SYifeng Zhao 	struct combphy_reg pipe_phymode_sel;
44925c5749SYifeng Zhao 	struct combphy_reg pipe_rate_sel;
45925c5749SYifeng Zhao 	struct combphy_reg pipe_rxterm_sel;
46925c5749SYifeng Zhao 	struct combphy_reg pipe_txelec_sel;
47925c5749SYifeng Zhao 	struct combphy_reg pipe_txcomp_sel;
48925c5749SYifeng Zhao 	struct combphy_reg pipe_clk_ext;
49925c5749SYifeng Zhao 	struct combphy_reg pipe_sel_usb;
50925c5749SYifeng Zhao 	struct combphy_reg pipe_sel_qsgmii;
51925c5749SYifeng Zhao 	struct combphy_reg pipe_phy_status;
52925c5749SYifeng Zhao 	struct combphy_reg con0_for_pcie;
53925c5749SYifeng Zhao 	struct combphy_reg con1_for_pcie;
54925c5749SYifeng Zhao 	struct combphy_reg con2_for_pcie;
55925c5749SYifeng Zhao 	struct combphy_reg con3_for_pcie;
56925c5749SYifeng Zhao 	struct combphy_reg con0_for_sata;
57925c5749SYifeng Zhao 	struct combphy_reg con1_for_sata;
58925c5749SYifeng Zhao 	struct combphy_reg con2_for_sata;
59925c5749SYifeng Zhao 	struct combphy_reg con3_for_sata;
60925c5749SYifeng Zhao 	struct combphy_reg pipe_con0_for_sata;
61cf3c44cbSJon Lin 	struct combphy_reg pipe_con1_for_sata;
62925c5749SYifeng Zhao 	struct combphy_reg pipe_sgmii_mac_sel;
63925c5749SYifeng Zhao 	struct combphy_reg pipe_xpcs_phy_ready;
64925c5749SYifeng Zhao 	struct combphy_reg u3otg0_port_en;
65925c5749SYifeng Zhao 	struct combphy_reg u3otg1_port_en;
66925c5749SYifeng Zhao };
67925c5749SYifeng Zhao 
68925c5749SYifeng Zhao struct rockchip_combphy_cfg {
69925c5749SYifeng Zhao 	const struct rockchip_combphy_grfcfg *grfcfg;
70925c5749SYifeng Zhao 	int (*combphy_cfg)(struct rockchip_combphy_priv *priv);
71925c5749SYifeng Zhao };
72925c5749SYifeng Zhao 
73925c5749SYifeng Zhao struct rockchip_combphy_priv {
74925c5749SYifeng Zhao 	u32 mode;
75925c5749SYifeng Zhao 	void __iomem *mmio;
76925c5749SYifeng Zhao 	struct udevice *dev;
77925c5749SYifeng Zhao 	struct regmap *pipe_grf;
78925c5749SYifeng Zhao 	struct regmap *phy_grf;
79925c5749SYifeng Zhao 	struct phy *phy;
80925c5749SYifeng Zhao 	struct reset_ctl phy_rst;
81925c5749SYifeng Zhao 	struct clk ref_clk;
82925c5749SYifeng Zhao 	const struct rockchip_combphy_cfg *cfg;
83925c5749SYifeng Zhao };
84925c5749SYifeng Zhao 
85925c5749SYifeng Zhao static int param_write(struct regmap *base,
86925c5749SYifeng Zhao 		       const struct combphy_reg *reg, bool en)
87925c5749SYifeng Zhao {
88925c5749SYifeng Zhao 	u32 val, mask, tmp;
89925c5749SYifeng Zhao 
90925c5749SYifeng Zhao 	tmp = en ? reg->enable : reg->disable;
91925c5749SYifeng Zhao 	mask = GENMASK(reg->bitend, reg->bitstart);
92925c5749SYifeng Zhao 	val = (tmp << reg->bitstart) | (mask << BIT_WRITEABLE_SHIFT);
93925c5749SYifeng Zhao 
94925c5749SYifeng Zhao 	return regmap_write(base, reg->offset, val);
95925c5749SYifeng Zhao }
96925c5749SYifeng Zhao 
97925c5749SYifeng Zhao static int rockchip_combphy_pcie_init(struct rockchip_combphy_priv *priv)
98925c5749SYifeng Zhao {
99925c5749SYifeng Zhao 	int ret = 0;
100925c5749SYifeng Zhao 
101925c5749SYifeng Zhao 	if (priv->cfg->combphy_cfg) {
102925c5749SYifeng Zhao 		ret = priv->cfg->combphy_cfg(priv);
103925c5749SYifeng Zhao 		if (ret) {
104925c5749SYifeng Zhao 			dev_err(priv->dev, "failed to init phy for pcie\n");
105925c5749SYifeng Zhao 			return ret;
106925c5749SYifeng Zhao 		}
107925c5749SYifeng Zhao 	}
108925c5749SYifeng Zhao 
109925c5749SYifeng Zhao 	return ret;
110925c5749SYifeng Zhao }
111925c5749SYifeng Zhao 
112925c5749SYifeng Zhao static int rockchip_combphy_usb3_init(struct rockchip_combphy_priv *priv)
113925c5749SYifeng Zhao {
114925c5749SYifeng Zhao 	int ret = 0;
115925c5749SYifeng Zhao 
116925c5749SYifeng Zhao 	if (priv->cfg->combphy_cfg) {
117925c5749SYifeng Zhao 		ret = priv->cfg->combphy_cfg(priv);
118925c5749SYifeng Zhao 		if (ret) {
119925c5749SYifeng Zhao 			dev_err(priv->dev, "failed to init phy for usb3\n");
120925c5749SYifeng Zhao 			return ret;
121925c5749SYifeng Zhao 		}
122925c5749SYifeng Zhao 	}
123925c5749SYifeng Zhao 
124925c5749SYifeng Zhao 	return ret;
125925c5749SYifeng Zhao }
126925c5749SYifeng Zhao 
127925c5749SYifeng Zhao static int rockchip_combphy_sata_init(struct rockchip_combphy_priv *priv)
128925c5749SYifeng Zhao {
129925c5749SYifeng Zhao 	int ret = 0;
130925c5749SYifeng Zhao 
131925c5749SYifeng Zhao 	if (priv->cfg->combphy_cfg) {
132925c5749SYifeng Zhao 		ret = priv->cfg->combphy_cfg(priv);
133925c5749SYifeng Zhao 		if (ret) {
134925c5749SYifeng Zhao 			dev_err(priv->dev, "failed to init phy for sata\n");
135925c5749SYifeng Zhao 			return ret;
136925c5749SYifeng Zhao 		}
137925c5749SYifeng Zhao 	}
138925c5749SYifeng Zhao 
139925c5749SYifeng Zhao 	return ret;
140925c5749SYifeng Zhao }
141925c5749SYifeng Zhao 
142925c5749SYifeng Zhao static int rockchip_combphy_sgmii_init(struct rockchip_combphy_priv *priv)
143925c5749SYifeng Zhao {
144925c5749SYifeng Zhao 	int ret = 0;
145925c5749SYifeng Zhao 
146925c5749SYifeng Zhao 	if (priv->cfg->combphy_cfg) {
147925c5749SYifeng Zhao 		ret = priv->cfg->combphy_cfg(priv);
148925c5749SYifeng Zhao 		if (ret) {
149925c5749SYifeng Zhao 			dev_err(priv->dev, "failed to init phy for sgmii\n");
150925c5749SYifeng Zhao 			return ret;
151925c5749SYifeng Zhao 		}
152925c5749SYifeng Zhao 	}
153925c5749SYifeng Zhao 
154925c5749SYifeng Zhao 	return ret;
155925c5749SYifeng Zhao }
156925c5749SYifeng Zhao 
157925c5749SYifeng Zhao static int rockchip_combphy_set_mode(struct rockchip_combphy_priv *priv)
158925c5749SYifeng Zhao {
159925c5749SYifeng Zhao 	switch (priv->mode) {
160925c5749SYifeng Zhao 	case PHY_TYPE_PCIE:
161925c5749SYifeng Zhao 		rockchip_combphy_pcie_init(priv);
162925c5749SYifeng Zhao 		break;
163925c5749SYifeng Zhao 	case PHY_TYPE_USB3:
164925c5749SYifeng Zhao 		rockchip_combphy_usb3_init(priv);
165925c5749SYifeng Zhao 		break;
166925c5749SYifeng Zhao 	case PHY_TYPE_SATA:
167925c5749SYifeng Zhao 		rockchip_combphy_sata_init(priv);
168925c5749SYifeng Zhao 		break;
169925c5749SYifeng Zhao 	case PHY_TYPE_SGMII:
170925c5749SYifeng Zhao 	case PHY_TYPE_QSGMII:
171925c5749SYifeng Zhao 		return rockchip_combphy_sgmii_init(priv);
172925c5749SYifeng Zhao 	default:
173925c5749SYifeng Zhao 		dev_err(priv->dev, "incompatible PHY type\n");
174925c5749SYifeng Zhao 		return -EINVAL;
175925c5749SYifeng Zhao 	}
176925c5749SYifeng Zhao 
177925c5749SYifeng Zhao 	return 0;
178925c5749SYifeng Zhao }
179925c5749SYifeng Zhao 
180925c5749SYifeng Zhao static int rockchip_combphy_init(struct phy *phy)
181925c5749SYifeng Zhao {
182925c5749SYifeng Zhao 	struct rockchip_combphy_priv *priv = dev_get_priv(phy->dev);
183925c5749SYifeng Zhao 	int ret;
184925c5749SYifeng Zhao 
185925c5749SYifeng Zhao 	ret = clk_enable(&priv->ref_clk);
186925c5749SYifeng Zhao 	if (ret < 0 && ret != -ENOSYS)
187925c5749SYifeng Zhao 		return ret;
188925c5749SYifeng Zhao 
189925c5749SYifeng Zhao 	ret = rockchip_combphy_set_mode(priv);
190925c5749SYifeng Zhao 	if (ret)
191925c5749SYifeng Zhao 		goto err_clk;
192925c5749SYifeng Zhao 
193925c5749SYifeng Zhao 	reset_deassert(&priv->phy_rst);
194925c5749SYifeng Zhao 
195925c5749SYifeng Zhao 	return 0;
196925c5749SYifeng Zhao 
197925c5749SYifeng Zhao err_clk:
198925c5749SYifeng Zhao 	clk_disable(&priv->ref_clk);
199925c5749SYifeng Zhao 
200925c5749SYifeng Zhao 	return ret;
201925c5749SYifeng Zhao }
202925c5749SYifeng Zhao 
203925c5749SYifeng Zhao static int rockchip_combphy_exit(struct phy *phy)
204925c5749SYifeng Zhao {
205925c5749SYifeng Zhao 	struct rockchip_combphy_priv *priv = dev_get_priv(phy->dev);
206925c5749SYifeng Zhao 
207925c5749SYifeng Zhao 	clk_disable(&priv->ref_clk);
208925c5749SYifeng Zhao 	reset_assert(&priv->phy_rst);
209925c5749SYifeng Zhao 
210925c5749SYifeng Zhao 	return 0;
211925c5749SYifeng Zhao }
212925c5749SYifeng Zhao 
213925c5749SYifeng Zhao static int rockchip_combphy_xlate(struct phy *phy, struct ofnode_phandle_args *args)
214925c5749SYifeng Zhao {
215925c5749SYifeng Zhao 	struct rockchip_combphy_priv *priv = dev_get_priv(phy->dev);
216925c5749SYifeng Zhao 
217925c5749SYifeng Zhao 	if (args->args_count != 1) {
218925c5749SYifeng Zhao 		pr_err("invalid number of arguments\n");
219925c5749SYifeng Zhao 		return -EINVAL;
220925c5749SYifeng Zhao 	}
221925c5749SYifeng Zhao 
222925c5749SYifeng Zhao 	priv->mode = args->args[0];
223925c5749SYifeng Zhao 
224925c5749SYifeng Zhao 	return 0;
225925c5749SYifeng Zhao }
226925c5749SYifeng Zhao 
227925c5749SYifeng Zhao static const struct phy_ops rochchip_combphy_ops = {
228925c5749SYifeng Zhao 	.init = rockchip_combphy_init,
229925c5749SYifeng Zhao 	.exit = rockchip_combphy_exit,
230925c5749SYifeng Zhao 	.of_xlate = rockchip_combphy_xlate,
231925c5749SYifeng Zhao };
232925c5749SYifeng Zhao 
233925c5749SYifeng Zhao static int rockchip_combphy_parse_dt(struct udevice *dev,
234925c5749SYifeng Zhao 				     struct rockchip_combphy_priv *priv)
235925c5749SYifeng Zhao {
236925c5749SYifeng Zhao 	struct udevice *syscon;
237925c5749SYifeng Zhao 	int ret;
2387cc44222SJon Lin 	u32 vals[4];
239925c5749SYifeng Zhao 
240925c5749SYifeng Zhao 	ret = uclass_get_device_by_phandle(UCLASS_SYSCON, dev, "rockchip,pipe-grf", &syscon);
241925c5749SYifeng Zhao 	if (ret) {
242cf3c44cbSJon Lin 		dev_err(dev, "failed to find peri_ctrl pipe-grf regmap ret= %d\n", ret);
243925c5749SYifeng Zhao 		return ret;
244925c5749SYifeng Zhao 	}
245925c5749SYifeng Zhao 	priv->pipe_grf = syscon_get_regmap(syscon);
246925c5749SYifeng Zhao 
247925c5749SYifeng Zhao 	ret = uclass_get_device_by_phandle(UCLASS_SYSCON, dev, "rockchip,pipe-phy-grf", &syscon);
248925c5749SYifeng Zhao 	if (ret) {
249925c5749SYifeng Zhao 		dev_err(dev, "failed to find peri_ctrl pipe-phy-grf regmap\n");
250925c5749SYifeng Zhao 		return ret;
251925c5749SYifeng Zhao 	}
252925c5749SYifeng Zhao 	priv->phy_grf = syscon_get_regmap(syscon);
253925c5749SYifeng Zhao 
254925c5749SYifeng Zhao 	ret = clk_get_by_index(dev, 0, &priv->ref_clk);
255925c5749SYifeng Zhao 	if (ret) {
256925c5749SYifeng Zhao 		dev_err(dev, "failed to find ref clock\n");
257925c5749SYifeng Zhao 		return PTR_ERR(&priv->ref_clk);
258925c5749SYifeng Zhao 	}
259925c5749SYifeng Zhao 
260dbf89912SRen Jianing 	ret = reset_get_by_name(dev, "combphy", &priv->phy_rst);
261925c5749SYifeng Zhao 	if (ret) {
262925c5749SYifeng Zhao 		dev_err(dev, "no phy reset control specified\n");
263925c5749SYifeng Zhao 		return ret;
264925c5749SYifeng Zhao 	}
265925c5749SYifeng Zhao 
2667cc44222SJon Lin 	if (!dev_read_u32_array(dev, "rockchip,pcie1ln-sel-bits",
2677cc44222SJon Lin 				vals, ARRAY_SIZE(vals)))
2687cc44222SJon Lin 		regmap_write(priv->pipe_grf, vals[0],
2697cc44222SJon Lin 			     (GENMASK(vals[2], vals[1]) << 16) | vals[3]);
2707cc44222SJon Lin 
271925c5749SYifeng Zhao 	return 0;
272925c5749SYifeng Zhao }
273925c5749SYifeng Zhao 
274925c5749SYifeng Zhao static int rockchip_combphy_probe(struct udevice *udev)
275925c5749SYifeng Zhao {
276925c5749SYifeng Zhao 	struct rockchip_combphy_priv *priv = dev_get_priv(udev);
277925c5749SYifeng Zhao 	const struct rockchip_combphy_cfg *phy_cfg;
278925c5749SYifeng Zhao 
279925c5749SYifeng Zhao 	priv->mmio = (void __iomem *)dev_read_addr(udev);
280925c5749SYifeng Zhao 	if (IS_ERR(priv->mmio))
281925c5749SYifeng Zhao 		return PTR_ERR(priv->mmio);
282925c5749SYifeng Zhao 
283925c5749SYifeng Zhao 	phy_cfg = (const struct rockchip_combphy_cfg *)dev_get_driver_data(udev);
284925c5749SYifeng Zhao 	if (!phy_cfg) {
285925c5749SYifeng Zhao 		dev_err(udev, "No OF match data provided\n");
286925c5749SYifeng Zhao 		return -EINVAL;
287925c5749SYifeng Zhao 	}
288925c5749SYifeng Zhao 
289925c5749SYifeng Zhao 	priv->dev = udev;
290925c5749SYifeng Zhao 	priv->mode = PHY_TYPE_SATA;
291925c5749SYifeng Zhao 	priv->cfg = phy_cfg;
292925c5749SYifeng Zhao 
2935eec6d12SJon Lin 	return rockchip_combphy_parse_dt(udev, priv);
294925c5749SYifeng Zhao }
295925c5749SYifeng Zhao 
296*3452d642SJianwei Zheng static int rk3528_combphy_cfg(struct rockchip_combphy_priv *priv)
297*3452d642SJianwei Zheng {
298*3452d642SJianwei Zheng 	const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
299*3452d642SJianwei Zheng 	u32 val;
300*3452d642SJianwei Zheng 
301*3452d642SJianwei Zheng 	switch (priv->mode) {
302*3452d642SJianwei Zheng 	case PHY_TYPE_PCIE:
303*3452d642SJianwei Zheng 		/* Set SSC downward spread spectrum */
304*3452d642SJianwei Zheng 		val = readl(priv->mmio + 0x18);
305*3452d642SJianwei Zheng 		val &= ~GENMASK(5, 4);
306*3452d642SJianwei Zheng 		val |= 0x01 << 4;
307*3452d642SJianwei Zheng 		writel(val, priv->mmio + 0x18);
308*3452d642SJianwei Zheng 
309*3452d642SJianwei Zheng 		param_write(priv->phy_grf, &cfg->con0_for_pcie, true);
310*3452d642SJianwei Zheng 		param_write(priv->phy_grf, &cfg->con1_for_pcie, true);
311*3452d642SJianwei Zheng 		param_write(priv->phy_grf, &cfg->con2_for_pcie, true);
312*3452d642SJianwei Zheng 		param_write(priv->phy_grf, &cfg->con3_for_pcie, true);
313*3452d642SJianwei Zheng 		break;
314*3452d642SJianwei Zheng 	case PHY_TYPE_USB3:
315*3452d642SJianwei Zheng 		/* Set SSC downward spread spectrum */
316*3452d642SJianwei Zheng 		val = readl(priv->mmio + 0x18);
317*3452d642SJianwei Zheng 		val &= ~GENMASK(5, 4);
318*3452d642SJianwei Zheng 		val |= 0x01 << 4;
319*3452d642SJianwei Zheng 		writel(val, priv->mmio + 0x18);
320*3452d642SJianwei Zheng 
321*3452d642SJianwei Zheng 		/* Enable adaptive CTLE for USB3.0 Rx */
322*3452d642SJianwei Zheng 		val = readl(priv->mmio + 0x200);
323*3452d642SJianwei Zheng 		val &= ~GENMASK(17, 17);
324*3452d642SJianwei Zheng 		val |= 0x01;
325*3452d642SJianwei Zheng 		writel(val, priv->mmio + 0x200);
326*3452d642SJianwei Zheng 
327*3452d642SJianwei Zheng 		param_write(priv->phy_grf, &cfg->pipe_txcomp_sel, false);
328*3452d642SJianwei Zheng 		param_write(priv->phy_grf, &cfg->pipe_txelec_sel, false);
329*3452d642SJianwei Zheng 		param_write(priv->phy_grf, &cfg->usb_mode_set, true);
330*3452d642SJianwei Zheng 		break;
331*3452d642SJianwei Zheng 	default:
332*3452d642SJianwei Zheng 		dev_err(priv->dev, "incompatible PHY type\n");
333*3452d642SJianwei Zheng 		return -EINVAL;
334*3452d642SJianwei Zheng 	}
335*3452d642SJianwei Zheng 
336*3452d642SJianwei Zheng 	param_write(priv->phy_grf, &cfg->pipe_clk_100m, true);
337*3452d642SJianwei Zheng 	if (priv->mode == PHY_TYPE_PCIE) {
338*3452d642SJianwei Zheng 		/* PLL KVCO tuning fine */
339*3452d642SJianwei Zheng 		val = readl(priv->mmio + 0x18);
340*3452d642SJianwei Zheng 		val &= ~(0x7 << 10);
341*3452d642SJianwei Zheng 		val |= 0x2 << 10;
342*3452d642SJianwei Zheng 		writel(val, priv->mmio + 0x18);
343*3452d642SJianwei Zheng 
344*3452d642SJianwei Zheng 		/* su_trim[6:4]=111, [10:7]=1001, [2:0]=000 */
345*3452d642SJianwei Zheng 		val = readl(priv->mmio + 0x108);
346*3452d642SJianwei Zheng 		val &= ~(0x7f7);
347*3452d642SJianwei Zheng 		val |= 0x4f0;
348*3452d642SJianwei Zheng 		writel(val, priv->mmio + 0x108);
349*3452d642SJianwei Zheng 	}
350*3452d642SJianwei Zheng 
351*3452d642SJianwei Zheng 	return 0;
352*3452d642SJianwei Zheng }
353*3452d642SJianwei Zheng 
354*3452d642SJianwei Zheng static const struct rockchip_combphy_grfcfg rk3528_combphy_grfcfgs = {
355*3452d642SJianwei Zheng 	/* pipe-phy-grf */
356*3452d642SJianwei Zheng 	.pcie_mode_set		= { 0x48000, 5, 0, 0x00, 0x11 },
357*3452d642SJianwei Zheng 	.usb_mode_set		= { 0x48000, 5, 0, 0x00, 0x04 },
358*3452d642SJianwei Zheng 	.pipe_rxterm_set	= { 0x48000, 12, 12, 0x00, 0x01 },
359*3452d642SJianwei Zheng 	.pipe_txelec_set	= { 0x48004, 1, 1, 0x00, 0x01 },
360*3452d642SJianwei Zheng 	.pipe_txcomp_set	= { 0x48004, 4, 4, 0x00, 0x01 },
361*3452d642SJianwei Zheng 	.pipe_clk_24m		= { 0x48004, 14, 13, 0x00, 0x00 },
362*3452d642SJianwei Zheng 	.pipe_clk_100m		= { 0x48004, 14, 13, 0x00, 0x02 },
363*3452d642SJianwei Zheng 	.pipe_rxterm_sel	= { 0x48008, 8, 8, 0x00, 0x01 },
364*3452d642SJianwei Zheng 	.pipe_txelec_sel	= { 0x48008, 12, 12, 0x00, 0x01 },
365*3452d642SJianwei Zheng 	.pipe_txcomp_sel	= { 0x48008, 15, 15, 0x00, 0x01 },
366*3452d642SJianwei Zheng 	.pipe_clk_ext		= { 0x4800c, 9, 8, 0x02, 0x01 },
367*3452d642SJianwei Zheng 	.pipe_phy_status	= { 0x48034, 6, 6, 0x01, 0x00 },
368*3452d642SJianwei Zheng 	.con0_for_pcie		= { 0x48000, 15, 0, 0x00, 0x110 },
369*3452d642SJianwei Zheng 	.con1_for_pcie		= { 0x48004, 15, 0, 0x00, 0x00 },
370*3452d642SJianwei Zheng 	.con2_for_pcie		= { 0x48008, 15, 0, 0x00, 0x101 },
371*3452d642SJianwei Zheng 	.con3_for_pcie		= { 0x4800c, 15, 0, 0x00, 0x0200 },
372*3452d642SJianwei Zheng 	/* pipe-grf */
373*3452d642SJianwei Zheng 	.u3otg0_port_en		= { 0x40044, 15, 0, 0x0181, 0x1100 },
374*3452d642SJianwei Zheng };
375*3452d642SJianwei Zheng 
376*3452d642SJianwei Zheng static const struct rockchip_combphy_cfg rk3528_combphy_cfgs = {
377*3452d642SJianwei Zheng 	.grfcfg		= &rk3528_combphy_grfcfgs,
378*3452d642SJianwei Zheng 	.combphy_cfg	= rk3528_combphy_cfg,
379*3452d642SJianwei Zheng };
380*3452d642SJianwei Zheng 
381925c5749SYifeng Zhao static int rk3568_combphy_cfg(struct rockchip_combphy_priv *priv)
382925c5749SYifeng Zhao {
383925c5749SYifeng Zhao 	const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
384925c5749SYifeng Zhao 	u32 val;
385925c5749SYifeng Zhao 
386925c5749SYifeng Zhao 	switch (priv->mode) {
387925c5749SYifeng Zhao 	case PHY_TYPE_PCIE:
388925c5749SYifeng Zhao 		/* Set SSC downward spread spectrum */
389925c5749SYifeng Zhao 		val = readl(priv->mmio + (0x1f << 2));
390925c5749SYifeng Zhao 		val &= ~GENMASK(5, 4);
391925c5749SYifeng Zhao 		val |= 0x01 << 4;
392925c5749SYifeng Zhao 		writel(val, priv->mmio + 0x7c);
393925c5749SYifeng Zhao 
394925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->con0_for_pcie, true);
395925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->con1_for_pcie, true);
396925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->con2_for_pcie, true);
397925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->con3_for_pcie, true);
398925c5749SYifeng Zhao 		break;
399925c5749SYifeng Zhao 	case PHY_TYPE_USB3:
400925c5749SYifeng Zhao 		/* Set SSC downward spread spectrum */
401925c5749SYifeng Zhao 		val = readl(priv->mmio + (0x1f << 2));
402925c5749SYifeng Zhao 		val &= ~GENMASK(5, 4);
403925c5749SYifeng Zhao 		val |= 0x01 << 4;
404925c5749SYifeng Zhao 		writel(val, priv->mmio + 0x7c);
405925c5749SYifeng Zhao 
406925c5749SYifeng Zhao 		/* Enable adaptive CTLE for USB3.0 Rx */
407925c5749SYifeng Zhao 		val = readl(priv->mmio + (0x0e << 2));
408925c5749SYifeng Zhao 		val &= ~GENMASK(0, 0);
409925c5749SYifeng Zhao 		val |= 0x01;
410925c5749SYifeng Zhao 		writel(val, priv->mmio + (0x0e << 2));
411925c5749SYifeng Zhao 
412a0d03578SWilliam Wu 		/* Set PLL KVCO fine tuning signals */
413a0d03578SWilliam Wu 		val = readl(priv->mmio + (0x20 << 2));
414a0d03578SWilliam Wu 		val &= ~(0x7 << 2);
415a0d03578SWilliam Wu 		val |= 0x2 << 2;
416a0d03578SWilliam Wu 		writel(val, priv->mmio + (0x20 << 2));
417a0d03578SWilliam Wu 
418a0d03578SWilliam Wu 		/* Set PLL LPF R1 to su_trim[10:7]=1001 */
419a0d03578SWilliam Wu 		writel(0x4, priv->mmio + (0xb << 2));
420a0d03578SWilliam Wu 
421a0d03578SWilliam Wu 		/* Set PLL input clock divider 1/2 */
422a0d03578SWilliam Wu 		val = readl(priv->mmio + (0x5 << 2));
423a0d03578SWilliam Wu 		val &= ~(0x3 << 6);
424a0d03578SWilliam Wu 		val |= 0x1 << 6;
425a0d03578SWilliam Wu 		writel(val, priv->mmio + (0x5 << 2));
426a0d03578SWilliam Wu 
427a0d03578SWilliam Wu 		/* Set PLL loop divider */
428a0d03578SWilliam Wu 		writel(0x32, priv->mmio + (0x11 << 2));
429a0d03578SWilliam Wu 
430a0d03578SWilliam Wu 		/* Set PLL KVCO to min and set PLL charge pump current to max */
431a0d03578SWilliam Wu 		writel(0xf0, priv->mmio + (0xa << 2));
432a0d03578SWilliam Wu 
433925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->pipe_sel_usb, true);
434925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->pipe_txcomp_sel, false);
435925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->pipe_txelec_sel, false);
436925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->usb_mode_set, true);
437925c5749SYifeng Zhao 		break;
438925c5749SYifeng Zhao 	case PHY_TYPE_SATA:
439925c5749SYifeng Zhao 		writel(0x41, priv->mmio + 0x38);
440925c5749SYifeng Zhao 		writel(0x8F, priv->mmio + 0x18);
441925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->con0_for_sata, true);
442925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->con1_for_sata, true);
443925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->con2_for_sata, true);
444925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->con3_for_sata, true);
445925c5749SYifeng Zhao 		param_write(priv->pipe_grf, &cfg->pipe_con0_for_sata, true);
446925c5749SYifeng Zhao 		break;
447925c5749SYifeng Zhao 	case PHY_TYPE_SGMII:
448925c5749SYifeng Zhao 		param_write(priv->pipe_grf, &cfg->pipe_xpcs_phy_ready, true);
449925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->pipe_phymode_sel, true);
450925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->pipe_sel_qsgmii, true);
451925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->sgmii_mode_set, true);
452925c5749SYifeng Zhao 		break;
453925c5749SYifeng Zhao 	case PHY_TYPE_QSGMII:
454925c5749SYifeng Zhao 		param_write(priv->pipe_grf, &cfg->pipe_xpcs_phy_ready, true);
455925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->pipe_phymode_sel, true);
456925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->pipe_rate_sel, true);
457925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->pipe_sel_qsgmii, true);
458925c5749SYifeng Zhao 		param_write(priv->phy_grf, &cfg->qsgmii_mode_set, true);
459925c5749SYifeng Zhao 		break;
460925c5749SYifeng Zhao 	default:
461925c5749SYifeng Zhao 		pr_err("%s, phy-type %d\n", __func__, priv->mode);
462925c5749SYifeng Zhao 		return -EINVAL;
463925c5749SYifeng Zhao 	}
464925c5749SYifeng Zhao 
465dbf89912SRen Jianing 	/* The default ref clock is 25Mhz */
466dbf89912SRen Jianing 	param_write(priv->phy_grf, &cfg->pipe_clk_25m, true);
467925c5749SYifeng Zhao 
468925c5749SYifeng Zhao 	if (dev_read_bool(priv->dev, "rockchip,enable-ssc")) {
469925c5749SYifeng Zhao 		val = readl(priv->mmio + (0x7 << 2));
470925c5749SYifeng Zhao 		val |= BIT(4);
471925c5749SYifeng Zhao 		writel(val, priv->mmio + (0x7 << 2));
472925c5749SYifeng Zhao 	}
473925c5749SYifeng Zhao 
474925c5749SYifeng Zhao 	return 0;
475925c5749SYifeng Zhao }
476925c5749SYifeng Zhao 
477925c5749SYifeng Zhao static const struct rockchip_combphy_grfcfg rk3568_combphy_grfcfgs = {
478925c5749SYifeng Zhao 	/* pipe-phy-grf */
479925c5749SYifeng Zhao 	.pcie_mode_set		= { 0x0000, 5, 0, 0x00, 0x11 },
480925c5749SYifeng Zhao 	.usb_mode_set		= { 0x0000, 5, 0, 0x00, 0x04 },
481925c5749SYifeng Zhao 	.sgmii_mode_set		= { 0x0000, 5, 0, 0x00, 0x01 },
482925c5749SYifeng Zhao 	.qsgmii_mode_set	= { 0x0000, 5, 0, 0x00, 0x21 },
483925c5749SYifeng Zhao 	.pipe_rxterm_set	= { 0x0000, 12, 12, 0x00, 0x01 },
484925c5749SYifeng Zhao 	.pipe_txelec_set	= { 0x0004, 1, 1, 0x00, 0x01 },
485925c5749SYifeng Zhao 	.pipe_txcomp_set	= { 0x0004, 4, 4, 0x00, 0x01 },
486925c5749SYifeng Zhao 	.pipe_clk_25m		= { 0x0004, 14, 13, 0x00, 0x01 },
487925c5749SYifeng Zhao 	.pipe_clk_100m		= { 0x0004, 14, 13, 0x00, 0x02 },
488925c5749SYifeng Zhao 	.pipe_phymode_sel	= { 0x0008, 1, 1, 0x00, 0x01 },
489925c5749SYifeng Zhao 	.pipe_rate_sel		= { 0x0008, 2, 2, 0x00, 0x01 },
490925c5749SYifeng Zhao 	.pipe_rxterm_sel	= { 0x0008, 8, 8, 0x00, 0x01 },
491925c5749SYifeng Zhao 	.pipe_txelec_sel	= { 0x0008, 12, 12, 0x00, 0x01 },
492925c5749SYifeng Zhao 	.pipe_txcomp_sel	= { 0x0008, 15, 15, 0x00, 0x01 },
493925c5749SYifeng Zhao 	.pipe_clk_ext		= { 0x000c, 9, 8, 0x02, 0x01 },
494925c5749SYifeng Zhao 	.pipe_sel_usb		= { 0x000c, 14, 13, 0x00, 0x01 },
495925c5749SYifeng Zhao 	.pipe_sel_qsgmii	= { 0x000c, 15, 13, 0x00, 0x07 },
496925c5749SYifeng Zhao 	.pipe_phy_status	= { 0x0034, 6, 6, 0x01, 0x00 },
497925c5749SYifeng Zhao 	.con0_for_pcie		= { 0x0000, 15, 0, 0x00, 0x1000 },
498925c5749SYifeng Zhao 	.con1_for_pcie		= { 0x0004, 15, 0, 0x00, 0x0000 },
499925c5749SYifeng Zhao 	.con2_for_pcie		= { 0x0008, 15, 0, 0x00, 0x0101 },
500925c5749SYifeng Zhao 	.con3_for_pcie		= { 0x000c, 15, 0, 0x00, 0x0200 },
501925c5749SYifeng Zhao 	.con0_for_sata		= { 0x0000, 15, 0, 0x00, 0x0119 },
502925c5749SYifeng Zhao 	.con1_for_sata		= { 0x0004, 15, 0, 0x00, 0x0040 },
503925c5749SYifeng Zhao 	.con2_for_sata		= { 0x0008, 15, 0, 0x00, 0x80c3 },
504925c5749SYifeng Zhao 	.con3_for_sata		= { 0x000c, 15, 0, 0x00, 0x4407 },
505925c5749SYifeng Zhao 	/* pipe-grf */
506925c5749SYifeng Zhao 	.pipe_con0_for_sata	= { 0x0000, 15, 0, 0x00, 0x2220 },
507925c5749SYifeng Zhao 	.pipe_sgmii_mac_sel	= { 0x0040, 1, 1, 0x00, 0x01 },
508925c5749SYifeng Zhao 	.pipe_xpcs_phy_ready	= { 0x0040, 2, 2, 0x00, 0x01 },
509925c5749SYifeng Zhao 	.u3otg0_port_en		= { 0x0104, 15, 0, 0x0181, 0x1100 },
510925c5749SYifeng Zhao 	.u3otg1_port_en		= { 0x0144, 15, 0, 0x0181, 0x1100 },
511925c5749SYifeng Zhao };
512925c5749SYifeng Zhao 
513925c5749SYifeng Zhao static const struct rockchip_combphy_cfg rk3568_combphy_cfgs = {
514925c5749SYifeng Zhao 	.grfcfg		= &rk3568_combphy_grfcfgs,
515925c5749SYifeng Zhao 	.combphy_cfg	= rk3568_combphy_cfg,
516925c5749SYifeng Zhao };
517925c5749SYifeng Zhao 
518cf3c44cbSJon Lin static int rk3588_combphy_cfg(struct rockchip_combphy_priv *priv)
519cf3c44cbSJon Lin {
520cf3c44cbSJon Lin 	const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg;
521d8968f57SWilliam Wu 	u32 val;
522cf3c44cbSJon Lin 
523cf3c44cbSJon Lin 	switch (priv->mode) {
524cf3c44cbSJon Lin 	case PHY_TYPE_PCIE:
525cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->con0_for_pcie, true);
526cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->con1_for_pcie, true);
527cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->con2_for_pcie, true);
528cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->con3_for_pcie, true);
529cf3c44cbSJon Lin 		break;
530cf3c44cbSJon Lin 	case PHY_TYPE_USB3:
531d8968f57SWilliam Wu 		/* Set SSC downward spread spectrum */
532d8968f57SWilliam Wu 		val = readl(priv->mmio + (0x1f << 2));
533d8968f57SWilliam Wu 		val &= ~GENMASK(5, 4);
534d8968f57SWilliam Wu 		val |= 0x01 << 4;
535d8968f57SWilliam Wu 		writel(val, priv->mmio + 0x7c);
536d8968f57SWilliam Wu 
537d8968f57SWilliam Wu 		/* Enable adaptive CTLE for USB3.0 Rx */
538d8968f57SWilliam Wu 		val = readl(priv->mmio + (0x0e << 2));
539d8968f57SWilliam Wu 		val &= ~GENMASK(0, 0);
540d8968f57SWilliam Wu 		val |= 0x01;
541d8968f57SWilliam Wu 		writel(val, priv->mmio + (0x0e << 2));
542d8968f57SWilliam Wu 
543d8968f57SWilliam Wu 		/* Set PLL KVCO fine tuning signals */
544d8968f57SWilliam Wu 		val = readl(priv->mmio + (0x20 << 2));
545d8968f57SWilliam Wu 		val &= ~(0x7 << 2);
546d8968f57SWilliam Wu 		val |= 0x2 << 2;
547d8968f57SWilliam Wu 		writel(val, priv->mmio + (0x20 << 2));
548d8968f57SWilliam Wu 
549d8968f57SWilliam Wu 		/* Set PLL LPF R1 to su_trim[10:7]=1001 */
550d8968f57SWilliam Wu 		writel(0x4, priv->mmio + (0xb << 2));
551d8968f57SWilliam Wu 
552d8968f57SWilliam Wu 		/* Set PLL input clock divider 1/2 */
553d8968f57SWilliam Wu 		val = readl(priv->mmio + (0x5 << 2));
554d8968f57SWilliam Wu 		val &= ~(0x3 << 6);
555d8968f57SWilliam Wu 		val |= 0x1 << 6;
556d8968f57SWilliam Wu 		writel(val, priv->mmio + (0x5 << 2));
557d8968f57SWilliam Wu 
558d8968f57SWilliam Wu 		/* Set PLL loop divider */
559d8968f57SWilliam Wu 		writel(0x32, priv->mmio + (0x11 << 2));
560d8968f57SWilliam Wu 
561d8968f57SWilliam Wu 		/* Set PLL KVCO to min and set PLL charge pump current to max */
562d8968f57SWilliam Wu 		writel(0xf0, priv->mmio + (0xa << 2));
563d8968f57SWilliam Wu 
56487bfcd06SWilliam Wu 		/* Set Rx squelch input filler bandwidth */
56587bfcd06SWilliam Wu 		writel(0x0d, priv->mmio + (0x14 << 2));
56687bfcd06SWilliam Wu 
567cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->pipe_txcomp_sel, false);
568cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->pipe_txelec_sel, false);
569cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->usb_mode_set, true);
570cf3c44cbSJon Lin 		break;
571cf3c44cbSJon Lin 	case PHY_TYPE_SATA:
572418dd88dSYifeng Zhao 		/* Enable adaptive CTLE for SATA Rx */
573418dd88dSYifeng Zhao 		val = readl(priv->mmio + (0x0e << 2));
574418dd88dSYifeng Zhao 		val &= ~GENMASK(0, 0);
575418dd88dSYifeng Zhao 		val |= 0x01;
576418dd88dSYifeng Zhao 		writel(val, priv->mmio + (0x0e << 2));
577418dd88dSYifeng Zhao 		/* Set tx_rterm = 50 ohm and rx_rterm = 43.5 ohm */
578418dd88dSYifeng Zhao 		writel(0x8F, priv->mmio + (0x06 << 2));
579418dd88dSYifeng Zhao 
580cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->con0_for_sata, true);
581cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->con1_for_sata, true);
582cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->con2_for_sata, true);
583cf3c44cbSJon Lin 		param_write(priv->phy_grf, &cfg->con3_for_sata, true);
584cf3c44cbSJon Lin 		param_write(priv->pipe_grf, &cfg->pipe_con0_for_sata, true);
585cf3c44cbSJon Lin 		param_write(priv->pipe_grf, &cfg->pipe_con1_for_sata, true);
586cf3c44cbSJon Lin 		break;
587cf3c44cbSJon Lin 	case PHY_TYPE_SGMII:
588cf3c44cbSJon Lin 	case PHY_TYPE_QSGMII:
589cf3c44cbSJon Lin 	default:
590cf3c44cbSJon Lin 		dev_err(priv->dev, "incompatible PHY type\n");
591cf3c44cbSJon Lin 		return -EINVAL;
592cf3c44cbSJon Lin 	}
593cf3c44cbSJon Lin 
594c72d402cSJon Lin 	/* 100MHz refclock signal is good */
595c72d402cSJon Lin 	clk_set_rate(&priv->ref_clk, 100000000);
596cf3c44cbSJon Lin 	param_write(priv->phy_grf, &cfg->pipe_clk_100m, true);
597e278c201SKever Yang 	if (priv->mode == PHY_TYPE_PCIE) {
598e278c201SKever Yang 		/* PLL KVCO tuning fine */
599e278c201SKever Yang 		val = readl(priv->mmio + (0x20 << 2));
600e278c201SKever Yang 		val &= ~GENMASK(4, 2);
601e278c201SKever Yang 		val |= 0x4 << 2;
602e278c201SKever Yang 		writel(val, priv->mmio + (0x20 << 2));
603e278c201SKever Yang 
604e278c201SKever Yang 		/* Set up rx_trim: PLL LPF C1 85pf R1 1.25kohm */
605e278c201SKever Yang 		val = 0x4c;
606e278c201SKever Yang 		writel(val, priv->mmio + (0x1b << 2));
607e278c201SKever Yang 
608e278c201SKever Yang 		/* Set up su_trim: T3 */
609e278c201SKever Yang 		val = 0xb0;
610e278c201SKever Yang 		writel(val, priv->mmio + (0xa << 2));
611e278c201SKever Yang 		val = 0x47;
612e278c201SKever Yang 		writel(val, priv->mmio + (0xb << 2));
613e278c201SKever Yang 		val = 0x57;
614e278c201SKever Yang 		writel(val, priv->mmio + (0xd << 2));
615e278c201SKever Yang 	}
616cf3c44cbSJon Lin 
617cf3c44cbSJon Lin 	return 0;
618cf3c44cbSJon Lin }
619cf3c44cbSJon Lin 
620cf3c44cbSJon Lin static const struct rockchip_combphy_grfcfg rk3588_combphy_grfcfgs = {
621cf3c44cbSJon Lin 	/* pipe-phy-grf */
622cf3c44cbSJon Lin 	.pcie_mode_set		= { 0x0000, 5, 0, 0x00, 0x11 },
623cf3c44cbSJon Lin 	.usb_mode_set		= { 0x0000, 5, 0, 0x00, 0x04 },
624cf3c44cbSJon Lin 	.pipe_rxterm_set	= { 0x0000, 12, 12, 0x00, 0x01 },
625cf3c44cbSJon Lin 	.pipe_txelec_set	= { 0x0004, 1, 1, 0x00, 0x01 },
626cf3c44cbSJon Lin 	.pipe_txcomp_set	= { 0x0004, 4, 4, 0x00, 0x01 },
627cf3c44cbSJon Lin 	.pipe_clk_25m		= { 0x0004, 14, 13, 0x00, 0x01 },
628cf3c44cbSJon Lin 	.pipe_clk_100m		= { 0x0004, 14, 13, 0x00, 0x02 },
629cf3c44cbSJon Lin 	.pipe_rxterm_sel	= { 0x0008, 8, 8, 0x00, 0x01 },
630cf3c44cbSJon Lin 	.pipe_txelec_sel	= { 0x0008, 12, 12, 0x00, 0x01 },
631cf3c44cbSJon Lin 	.pipe_txcomp_sel	= { 0x0008, 15, 15, 0x00, 0x01 },
632cf3c44cbSJon Lin 	.pipe_clk_ext		= { 0x000c, 9, 8, 0x02, 0x01 },
633cf3c44cbSJon Lin 	.pipe_phy_status	= { 0x0034, 6, 6, 0x01, 0x00 },
634cf3c44cbSJon Lin 	.con0_for_pcie		= { 0x0000, 15, 0, 0x00, 0x1000 },
635cf3c44cbSJon Lin 	.con1_for_pcie		= { 0x0004, 15, 0, 0x00, 0x0000 },
636cf3c44cbSJon Lin 	.con2_for_pcie		= { 0x0008, 15, 0, 0x00, 0x0101 },
637cf3c44cbSJon Lin 	.con3_for_pcie		= { 0x000c, 15, 0, 0x00, 0x0200 },
638cf3c44cbSJon Lin 	.con0_for_sata		= { 0x0000, 15, 0, 0x00, 0x0129 },
639418dd88dSYifeng Zhao 	.con1_for_sata		= { 0x0004, 15, 0, 0x00, 0x0000 },
640cf3c44cbSJon Lin 	.con2_for_sata		= { 0x0008, 15, 0, 0x00, 0x80c1 },
641cf3c44cbSJon Lin 	.con3_for_sata		= { 0x000c, 15, 0, 0x00, 0x0407 },
642cf3c44cbSJon Lin 	/* pipe-grf */
643cf3c44cbSJon Lin 	.pipe_con0_for_sata	= { 0x0000, 11, 5, 0x00, 0x22 },
644cf3c44cbSJon Lin 	.pipe_con1_for_sata	= { 0x0000, 2, 0, 0x00, 0x2 },
645cf3c44cbSJon Lin };
646cf3c44cbSJon Lin 
647cf3c44cbSJon Lin static const struct rockchip_combphy_cfg rk3588_combphy_cfgs = {
648cf3c44cbSJon Lin 	.grfcfg		= &rk3588_combphy_grfcfgs,
649cf3c44cbSJon Lin 	.combphy_cfg	= rk3588_combphy_cfg,
650cf3c44cbSJon Lin };
651cf3c44cbSJon Lin 
652925c5749SYifeng Zhao static const struct udevice_id rockchip_combphy_ids[] = {
653925c5749SYifeng Zhao 	{
654*3452d642SJianwei Zheng 		.compatible = "rockchip,rk3528-naneng-combphy",
655*3452d642SJianwei Zheng 		.data = (ulong)&rk3528_combphy_cfgs
656*3452d642SJianwei Zheng 	},
657*3452d642SJianwei Zheng 	{
658925c5749SYifeng Zhao 		.compatible = "rockchip,rk3568-naneng-combphy",
659925c5749SYifeng Zhao 		.data = (ulong)&rk3568_combphy_cfgs
660925c5749SYifeng Zhao 	},
661cf3c44cbSJon Lin 	{
662cf3c44cbSJon Lin 		.compatible = "rockchip,rk3588-naneng-combphy",
663cf3c44cbSJon Lin 		.data = (ulong)&rk3588_combphy_cfgs
664cf3c44cbSJon Lin 	},
665925c5749SYifeng Zhao 	{ }
666925c5749SYifeng Zhao };
667925c5749SYifeng Zhao 
668925c5749SYifeng Zhao U_BOOT_DRIVER(rockchip_naneng_combphy) = {
669925c5749SYifeng Zhao 	.name		= "naneng-combphy",
670925c5749SYifeng Zhao 	.id		= UCLASS_PHY,
671925c5749SYifeng Zhao 	.of_match	= rockchip_combphy_ids,
672925c5749SYifeng Zhao 	.ops		= &rochchip_combphy_ops,
673925c5749SYifeng Zhao 	.probe		= rockchip_combphy_probe,
674925c5749SYifeng Zhao 	.priv_auto_alloc_size = sizeof(struct rockchip_combphy_priv),
675925c5749SYifeng Zhao };
676