Lines Matching +full:0 +full:x10 +full:- +full:0 +full:x14

1 // SPDX-License-Identifier: GPL-2.0+
19 #include <linux/phy/phy-mipi-dphy.h>
26 #define STF_DPHY_AON_POWER_READY_N_ACTIVE 0
27 #define STF_DPHY_AON_POWER_READY_N BIT(0)
43 #define STF_DPHY_RG_CDTX_L4N_HSTX_RES GENMASK(4, 0)
45 #define STF_DPHY_RG_CDTX_PLL_FBK_FRA GENMASK(23, 0)
47 #define STF_DPHY_RG_CDTX_PLL_FBK_INT GENMASK(8, 0)
54 #define STF_DPHY_RG_CLANE_HS_CLK_POST_TIME GENMASK(7, 0)
59 #define STF_DPHY_RG_CLANE_HS_ZERO_TIME GENMASK(7, 0)
64 #define STF_DPHY_RG_EXTD_CYCLE_SEL GENMASK(2, 0)
65 #define STF_DPHY_SCFG_C_HS_PRE_ZERO_TIME GENMASK(31, 0)
100 {160000000, 0x6a, 0xaa, 0x3, 0xa, 0x17, 0x11, 0x5, 0x2b, 0xd, 0x7, 0x3d},
101 {170000000, 0x71, 0x55, 0x3, 0xb, 0x18, 0x11, 0x5, 0x2e, 0xd, 0x7, 0x3d},
102 {180000000, 0x78, 0x0, 0x3, 0xb, 0x19, 0x12, 0x6, 0x30, 0xe, 0x7, 0x3e},
103 {190000000, 0x7e, 0xaa, 0x3, 0xc, 0x1a, 0x12, 0x6, 0x33, 0xe, 0x7, 0x3e},
104 {200000000, 0x85, 0x55, 0x3, 0xc, 0x1b, 0x13, 0x7, 0x35, 0xf, 0x7, 0x3f},
105 {320000000, 0x6a, 0xaa, 0x2, 0x8, 0x14, 0xf, 0x5, 0x2b, 0xd, 0x3, 0x23},
106 {330000000, 0x6e, 0x0, 0x2, 0x8, 0x15, 0xf, 0x5, 0x2d, 0xd, 0x3, 0x23},
107 {340000000, 0x71, 0x55, 0x2, 0x9, 0x15, 0xf, 0x5, 0x2e, 0xd, 0x3, 0x23},
108 {350000000, 0x74, 0xaa, 0x2, 0x9, 0x15, 0x10, 0x6, 0x2f, 0xe, 0x3, 0x24},
109 {360000000, 0x78, 0x0, 0x2, 0x9, 0x16, 0x10, 0x6, 0x30, 0xe, 0x3, 0x24},
110 {370000000, 0x7b, 0x55, 0x2, 0x9, 0x17, 0x10, 0x6, 0x32, 0xe, 0x3, 0x24},
111 {380000000, 0x7e, 0xaa, 0x2, 0xa, 0x17, 0x10, 0x6, 0x33, 0xe, 0x3, 0x24},
112 {390000000, 0x82, 0x0, 0x2, 0xa, 0x17, 0x11, 0x6, 0x35, 0xf, 0x3, 0x25},
113 {400000000, 0x85, 0x55, 0x2, 0xa, 0x18, 0x11, 0x7, 0x35, 0xf, 0x3, 0x25},
114 {410000000, 0x88, 0xaa, 0x2, 0xa, 0x19, 0x11, 0x7, 0x37, 0xf, 0x3, 0x25},
115 {420000000, 0x8c, 0x0, 0x2, 0xa, 0x19, 0x12, 0x7, 0x38, 0x10, 0x3, 0x26},
116 {430000000, 0x8f, 0x55, 0x2, 0xb, 0x19, 0x12, 0x7, 0x39, 0x10, 0x3, 0x26},
117 {440000000, 0x92, 0xaa, 0x2, 0xb, 0x1a, 0x12, 0x7, 0x3b, 0x10, 0x3, 0x26},
118 {450000000, 0x96, 0x0, 0x2, 0xb, 0x1b, 0x12, 0x8, 0x3c, 0x10, 0x3, 0x26},
119 {460000000, 0x99, 0x55, 0x2, 0xb, 0x1b, 0x13, 0x8, 0x3d, 0x11, 0x3, 0x27},
120 {470000000, 0x9c, 0xaa, 0x2, 0xc, 0x1b, 0x13, 0x8, 0x3e, 0x11, 0x3, 0x27},
121 {480000000, 0xa0, 0x27, 0x2, 0xc, 0x1c, 0x13, 0x8, 0x40, 0x11, 0x3, 0x27},
122 {490000000, 0xa3, 0x55, 0x2, 0xc, 0x1d, 0x14, 0x8, 0x42, 0x12, 0x3, 0x28},
123 {500000000, 0xa6, 0xaa, 0x2, 0xc, 0x1d, 0x14, 0x9, 0x42, 0x12, 0x3, 0x28},
124 {510000000, 0xaa, 0x0, 0x2, 0xc, 0x1e, 0x14, 0x9, 0x44, 0x12, 0x3, 0x28},
125 {520000000, 0xad, 0x55, 0x2, 0xd, 0x1e, 0x15, 0x9, 0x45, 0x13, 0x3, 0x29},
126 {530000000, 0xb0, 0xaa, 0x2, 0xd, 0x1e, 0x15, 0x9, 0x47, 0x13, 0x3, 0x29},
127 {540000000, 0xb4, 0x0, 0x2, 0xd, 0x1f, 0x15, 0x9, 0x48, 0x13, 0x3, 0x29},
128 {550000000, 0xb7, 0x55, 0x2, 0xd, 0x20, 0x16, 0x9, 0x4a, 0x14, 0x3, 0x2a},
129 {560000000, 0xba, 0xaa, 0x2, 0xe, 0x20, 0x16, 0xa, 0x4a, 0x14, 0x3, 0x2a},
130 {570000000, 0xbe, 0x0, 0x2, 0xe, 0x20, 0x16, 0xa, 0x4c, 0x14, 0x3, 0x2a},
131 {580000000, 0xc1, 0x55, 0x2, 0xe, 0x21, 0x16, 0xa, 0x4d, 0x14, 0x3, 0x2a},
132 {590000000, 0xc4, 0xaa, 0x2, 0xe, 0x22, 0x17, 0xa, 0x4f, 0x15, 0x3, 0x2b},
133 {600000000, 0xc8, 0x0, 0x2, 0xe, 0x23, 0x17, 0xa, 0x50, 0x15, 0x3, 0x2b},
134 {610000000, 0xcb, 0x55, 0x2, 0xf, 0x22, 0x17, 0xb, 0x50, 0x15, 0x3, 0x2b},
135 {620000000, 0xce, 0xaa, 0x2, 0xf, 0x23, 0x18, 0xb, 0x52, 0x16, 0x3, 0x2c},
136 {630000000, 0x69, 0x0, 0x1, 0x7, 0x12, 0xd, 0x5, 0x2a, 0xc, 0x1, 0x15},
137 {640000000, 0x6a, 0xaa, 0x1, 0x7, 0x13, 0xe, 0x5, 0x2b, 0xd, 0x1, 0x16},
138 {650000000, 0x6c, 0x55, 0x1, 0x7, 0x13, 0xe, 0x5, 0x2c, 0xd, 0x1, 0x16},
139 {660000000, 0x6e, 0x0, 0x1, 0x7, 0x13, 0xe, 0x5, 0x2d, 0xd, 0x1, 0x16},
140 {670000000, 0x6f, 0xaa, 0x1, 0x8, 0x13, 0xe, 0x5, 0x2d, 0xd, 0x1, 0x16},
141 {680000000, 0x71, 0x55, 0x1, 0x8, 0x13, 0xe, 0x5, 0x2e, 0xd, 0x1, 0x16},
142 {690000000, 0x73, 0x0, 0x1, 0x8, 0x14, 0xe, 0x6, 0x2e, 0xd, 0x1, 0x16},
143 {700000000, 0x74, 0xaa, 0x1, 0x8, 0x14, 0xf, 0x6, 0x2f, 0xe, 0x1, 0x16},
144 {710000000, 0x76, 0x55, 0x1, 0x8, 0x14, 0xf, 0x6, 0x2f, 0xe, 0x1, 0x17},
145 {720000000, 0x78, 0x0, 0x1, 0x8, 0x15, 0xf, 0x6, 0x30, 0xe, 0x1, 0x17},
146 {730000000, 0x79, 0xaa, 0x1, 0x8, 0x15, 0xf, 0x6, 0x31, 0xe, 0x1, 0x17},
147 {740000000, 0x7b, 0x55, 0x1, 0x8, 0x15, 0xf, 0x6, 0x32, 0xe, 0x1, 0x17},
148 {750000000, 0x7d, 0x0, 0x1, 0x8, 0x16, 0xf, 0x6, 0x32, 0xe, 0x1, 0x17},
149 {760000000, 0x7e, 0xaa, 0x1, 0x9, 0x15, 0xf, 0x6, 0x33, 0xe, 0x1, 0x17},
150 {770000000, 0x80, 0x55, 0x1, 0x9, 0x15, 0x10, 0x6, 0x34, 0xf, 0x1, 0x18},
151 {780000000, 0x82, 0x0, 0x1, 0x9, 0x16, 0x10, 0x6, 0x35, 0xf, 0x1, 0x18,},
152 {790000000, 0x83, 0xaa, 0x1, 0x9, 0x16, 0x10, 0x7, 0x34, 0xf, 0x1, 0x18},
153 {800000000, 0x85, 0x55, 0x1, 0x9, 0x17, 0x10, 0x7, 0x35, 0xf, 0x1, 0x18},
154 {810000000, 0x87, 0x0, 0x1, 0x9, 0x17, 0x10, 0x7, 0x36, 0xf, 0x1, 0x18},
155 {820000000, 0x88, 0xaa, 0x1, 0x9, 0x17, 0x10, 0x7, 0x37, 0xf, 0x1, 0x18},
156 {830000000, 0x8a, 0x55, 0x1, 0x9, 0x18, 0x10, 0x7, 0x37, 0xf, 0x1, 0x18},
157 {840000000, 0x8c, 0x0, 0x1, 0x9, 0x18, 0x11, 0x7, 0x38, 0x10, 0x1, 0x19},
158 {850000000, 0x8d, 0xaa, 0x1, 0xa, 0x17, 0x11, 0x7, 0x39, 0x10, 0x1, 0x19},
159 {860000000, 0x8f, 0x55, 0x1, 0xa, 0x18, 0x11, 0x7, 0x39, 0x10, 0x1, 0x19},
160 {870000000, 0x91, 0x0, 0x1, 0xa, 0x18, 0x11, 0x7, 0x3a, 0x10, 0x1, 0x19},
161 {880000000, 0x92, 0xaa, 0x1, 0xa, 0x18, 0x11, 0x7, 0x3b, 0x10, 0x1, 0x19},
162 {890000000, 0x94, 0x55, 0x1, 0xa, 0x19, 0x11, 0x7, 0x3c, 0x10, 0x1, 0x19},
163 {900000000, 0x96, 0x0, 0x1, 0xa, 0x19, 0x12, 0x8, 0x3c, 0x10, 0x1, 0x19},
164 {910000000, 0x97, 0xaa, 0x1, 0xa, 0x19, 0x12, 0x8, 0x3c, 0x11, 0x1, 0x1a},
165 {920000000, 0x99, 0x55, 0x1, 0xa, 0x1a, 0x12, 0x8, 0x3d, 0x11, 0x1, 0x1a},
166 {930000000, 0x9b, 0x0, 0x1, 0xa, 0x1a, 0x12, 0x8, 0x3e, 0x11, 0x1, 0x1a},
167 {940000000, 0x9c, 0xaa, 0x1, 0xb, 0x1a, 0x12, 0x8, 0x3e, 0x11, 0x1, 0x1a},
168 {950000000, 0x9e, 0x55, 0x1, 0xb, 0x1a, 0x12, 0x8, 0x3f, 0x11, 0x1, 0x1a},
169 {960000000, 0xa0, 0x0, 0x1, 0xb, 0x1a, 0x12, 0x8, 0x40, 0x11, 0x1, 0x1a},
170 {970000000, 0xa1, 0xaa, 0x1, 0xb, 0x1b, 0x13, 0x8, 0x41, 0x12, 0x1, 0x1b},
171 {980000000, 0xa3, 0x55, 0x1, 0xb, 0x1b, 0x13, 0x8, 0x42, 0x12, 0x1, 0x1b},
172 {990000000, 0xa5, 0x0, 0x1, 0xb, 0x1b, 0x13, 0x8, 0x42, 0x12, 0x1, 0x1b},
173 {1000000000, 0xa6, 0xaa, 0x1, 0xb, 0x1c, 0x13, 0x9, 0x42, 0x12, 0x1, 0x1b},
183 * [data lane 0, data lane 1, data lane 2, date lane 3, clk lane]
204 for (i = 0; i < ARRAY_SIZE(reg_configs); i++) { in stf_dphy_get_config_index()
209 return 0; in stf_dphy_get_config_index()
215 u32 status = 0; in stf_dphy_hw_reset()
218 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(100)); in stf_dphy_hw_reset()
221 rc = readl_poll_timeout_atomic(dphy->topsys + in stf_dphy_hw_reset()
227 dev_err(dphy->dev, "MIPI dphy-tx # PLL Locked\n"); in stf_dphy_hw_reset()
234 const struct stf_dphy_info *info = dphy->info; in stf_dphy_configure()
237 u32 bitrate = opts->mipi_dphy.hs_clk_rate; in stf_dphy_configure()
242 bitrate += alignment - (bitrate % alignment); in stf_dphy_configure()
246 tmp = readl(dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(100)); in stf_dphy_configure()
249 writel(tmp, dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(100)); in stf_dphy_configure()
251 writel(FIELD_PREP(STF_DPHY_RG_CDTX_L0N_HSTX_RES, 0x10) | in stf_dphy_configure()
252 FIELD_PREP(STF_DPHY_RG_CDTX_L0P_HSTX_RES, 0x10), in stf_dphy_configure()
253 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(8)); in stf_dphy_configure()
255 writel(FIELD_PREP(STF_DPHY_RG_CDTX_L0N_HSTX_RES, 0x10) | in stf_dphy_configure()
256 FIELD_PREP(STF_DPHY_RG_CDTX_L2N_HSTX_RES, 0x10) | in stf_dphy_configure()
257 FIELD_PREP(STF_DPHY_RG_CDTX_L3N_HSTX_RES, 0x10) | in stf_dphy_configure()
258 FIELD_PREP(STF_DPHY_RG_CDTX_L1P_HSTX_RES, 0x10) | in stf_dphy_configure()
259 FIELD_PREP(STF_DPHY_RG_CDTX_L2P_HSTX_RES, 0x10) | in stf_dphy_configure()
260 FIELD_PREP(STF_DPHY_RG_CDTX_L3P_HSTX_RES, 0x10), in stf_dphy_configure()
261 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(12)); in stf_dphy_configure()
263 writel(FIELD_PREP(STF_DPHY_RG_CDTX_L4N_HSTX_RES, 0x10) | in stf_dphy_configure()
264 FIELD_PREP(STF_DPHY_RG_CDTX_L4P_HSTX_RES, 0x10), in stf_dphy_configure()
265 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(16)); in stf_dphy_configure()
270 FIELD_PREP(STF_DPHY_CFG_L0_SWAP_SEL, info->maps[0]) | in stf_dphy_configure()
271 FIELD_PREP(STF_DPHY_CFG_L1_SWAP_SEL, info->maps[1]) | in stf_dphy_configure()
272 FIELD_PREP(STF_DPHY_CFG_L2_SWAP_SEL, info->maps[2]) | in stf_dphy_configure()
273 FIELD_PREP(STF_DPHY_CFG_L3_SWAP_SEL, info->maps[3]) | in stf_dphy_configure()
274 FIELD_PREP(STF_DPHY_CFG_L4_SWAP_SEL, info->maps[4]), in stf_dphy_configure()
275 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(0)); in stf_dphy_configure()
278 writel(FIELD_PREP(STF_DPHY_RG_CDTX_PLL_SSC_EN, 0x0), in stf_dphy_configure()
279 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(28)); in stf_dphy_configure()
281 writel(FIELD_PREP(STF_DPHY_RG_CDTX_PLL_LDO_STB_X2_EN, 0x1) | in stf_dphy_configure()
282 FIELD_PREP(STF_DPHY_RG_CDTX_PLL_FM_EN, 0x1) | in stf_dphy_configure()
283 FIELD_PREP(STF_DPHY_RG_CDTX_PLL_PRE_DIV, 0x0) | in stf_dphy_configure()
285 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(24)); in stf_dphy_configure()
291 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(20)); in stf_dphy_configure()
294 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(40)); in stf_dphy_configure()
300 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(36)); in stf_dphy_configure()
306 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(32)); in stf_dphy_configure()
308 return 0; in stf_dphy_configure()
318 writel(FIELD_PREP(STF_DPHY_SCFG_PPI_C_READY_SEL, 0) | in stf_dphy_init()
319 FIELD_PREP(STF_DPHY_SCFG_DSI_TXREADY_ESC_SEL, 0), in stf_dphy_init()
320 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(48)); in stf_dphy_init()
322 writel(FIELD_PREP(STF_DPHY_SCFG_C_HS_PRE_ZERO_TIME, 0x30), in stf_dphy_init()
323 dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(44)); in stf_dphy_init()
325 ret = clk_prepare_enable(dphy->txesc_clk); in stf_dphy_init()
327 dev_err(dphy->dev, "Failed to prepare/enable txesc_clk\n"); in stf_dphy_init()
331 ret = reset_control_deassert(dphy->sys_rst); in stf_dphy_init()
333 dev_err(dphy->dev, "Failed to deassert sys_rst\n"); in stf_dphy_init()
337 return 0; in stf_dphy_init()
345 ret = reset_control_assert(dphy->sys_rst); in stf_dphy_exit()
347 dev_err(dphy->dev, "Failed to assert sys_rst\n"); in stf_dphy_exit()
351 clk_disable_unprepare(dphy->txesc_clk); in stf_dphy_exit()
353 stf_dphy_hw_reset(dphy, 0); in stf_dphy_exit()
355 return 0; in stf_dphy_exit()
362 return pm_runtime_resume_and_get(dphy->dev); in stf_dphy_power_on()
369 return -EINVAL; in stf_dphy_validate()
371 return 0; in stf_dphy_validate()
378 return pm_runtime_put_sync(dphy->dev); in stf_dphy_power_off()
396 dphy = devm_kzalloc(&pdev->dev, sizeof(*dphy), GFP_KERNEL); in stf_dphy_probe()
398 return -ENOMEM; in stf_dphy_probe()
400 dphy->info = of_device_get_match_data(&pdev->dev); in stf_dphy_probe()
402 dphy->dev = &pdev->dev; in stf_dphy_probe()
403 dev_set_drvdata(&pdev->dev, dphy); in stf_dphy_probe()
405 dphy->topsys = devm_platform_ioremap_resource(pdev, 0); in stf_dphy_probe()
406 if (IS_ERR(dphy->topsys)) in stf_dphy_probe()
407 return PTR_ERR(dphy->topsys); in stf_dphy_probe()
409 pm_runtime_enable(&pdev->dev); in stf_dphy_probe()
411 dphy->txesc_clk = devm_clk_get(&pdev->dev, "txesc"); in stf_dphy_probe()
412 if (IS_ERR(dphy->txesc_clk)) in stf_dphy_probe()
413 return dev_err_probe(&pdev->dev, PTR_ERR(dphy->txesc_clk), in stf_dphy_probe()
416 dphy->sys_rst = devm_reset_control_get_exclusive(&pdev->dev, "sys"); in stf_dphy_probe()
417 if (IS_ERR(dphy->sys_rst)) in stf_dphy_probe()
418 return dev_err_probe(&pdev->dev, PTR_ERR(dphy->sys_rst), in stf_dphy_probe()
421 dphy->phy = devm_phy_create(&pdev->dev, NULL, &stf_dphy_ops); in stf_dphy_probe()
422 if (IS_ERR(dphy->phy)) in stf_dphy_probe()
423 return dev_err_probe(&pdev->dev, PTR_ERR(dphy->phy), in stf_dphy_probe()
426 phy_set_drvdata(dphy->phy, dphy); in stf_dphy_probe()
428 phy_provider = devm_of_phy_provider_register(&pdev->dev, of_phy_simple_xlate); in stf_dphy_probe()
430 return dev_err_probe(&pdev->dev, PTR_ERR(phy_provider), in stf_dphy_probe()
433 return 0; in stf_dphy_probe()
437 .maps = {0, 1, 2, 3, 4},
442 .compatible = "starfive,jh7110-dphy-tx",
451 .name = "starfive-dphy-tx",