forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/gpu/drm/rockchip/rk628/rk628_combtxphy.c
....@@ -90,7 +90,6 @@
9090 struct clk *pclk;
9191 struct clk *ref_clk;
9292 struct reset_control *rstc;
93
- enum phy_mode mode;
9493 unsigned int flags;
9594
9695 u16 frac_div;
....@@ -229,10 +228,12 @@
229228
230229 return 0;
231230 }
231
+EXPORT_SYMBOL(rk628_combtxphy_set_gvi_division_mode);
232232
233233 static int rk628_combtxphy_power_on(struct phy *phy)
234234 {
235235 struct rk628_combtxphy *combtxphy = phy_get_drvdata(phy);
236
+ enum phy_mode mode = phy_get_mode(phy);
236237
237238 clk_prepare_enable(combtxphy->pclk);
238239 reset_control_assert(combtxphy->rstc);
....@@ -247,24 +248,22 @@
247248 SW_TX_IDLE_MASK | SW_TX_PD_MASK | SW_PD_PLL_MASK,
248249 SW_TX_IDLE(0x3ff) | SW_TX_PD(0x3ff) | SW_PD_PLL);
249250
250
- switch (combtxphy->mode) {
251
- case PHY_MODE_VIDEO_MIPI:
251
+ switch (mode) {
252
+ case PHY_MODE_MIPI_DPHY:
252253 regmap_update_bits(combtxphy->grf, GRF_POST_PROC_CON,
253254 SW_TXPHY_REFCLK_SEL_MASK,
254255 SW_TXPHY_REFCLK_SEL(0));
255256 return rk628_combtxphy_dsi_power_on(combtxphy);
256
- case PHY_MODE_VIDEO_LVDS:
257
+ case PHY_MODE_LVDS:
257258 regmap_update_bits(combtxphy->grf, GRF_POST_PROC_CON,
258259 SW_TXPHY_REFCLK_SEL_MASK,
259260 SW_TXPHY_REFCLK_SEL(1));
260261 return rk628_combtxphy_lvds_power_on(combtxphy);
261
- case PHY_MODE_GVI:
262
+ default:
262263 regmap_update_bits(combtxphy->grf, GRF_POST_PROC_CON,
263264 SW_TXPHY_REFCLK_SEL_MASK,
264265 SW_TXPHY_REFCLK_SEL(2));
265266 return rk628_combtxphy_gvi_power_on(combtxphy);
266
- default:
267
- return -EINVAL;
268267 }
269268
270269 return 0;
....@@ -284,7 +283,8 @@
284283 return 0;
285284 }
286285
287
-static int rk628_combtxphy_set_mode(struct phy *phy, enum phy_mode mode)
286
+static int rk628_combtxphy_set_mode(struct phy *phy, enum phy_mode mode,
287
+ int submode)
288288 {
289289 struct rk628_combtxphy *combtxphy = phy_get_drvdata(phy);
290290 unsigned int bus_width = phy_get_bus_width(phy);
....@@ -292,7 +292,7 @@
292292 unsigned long fvco, fpfd;
293293
294294 switch (mode) {
295
- case PHY_MODE_VIDEO_MIPI:
295
+ case PHY_MODE_MIPI_DPHY:
296296 {
297297 unsigned int fhsc = bus_width >> 8;
298298 unsigned int flags = bus_width & 0xff;
....@@ -330,7 +330,7 @@
330330 phy_set_bus_width(phy, fhsc);
331331 break;
332332 }
333
- case PHY_MODE_VIDEO_LVDS:
333
+ case PHY_MODE_LVDS:
334334 {
335335 unsigned int flags = bus_width & 0xff;
336336 unsigned int rate = (bus_width >> 8) * 7;
....@@ -348,7 +348,7 @@
348348 combtxphy->rate_div = 1;
349349 break;
350350 }
351
- case PHY_MODE_GVI:
351
+ default:
352352 {
353353 unsigned int i, delta_freq, best_delta_freq, fb_div;
354354 unsigned long ref_clk;
....@@ -366,6 +366,10 @@
366366 ref_clk = clk_get_rate(combtxphy->ref_clk) / 1000; /* khz */
367367 if (combtxphy->division_mode)
368368 ref_clk /= 2;
369
+
370
+ if (!ref_clk)
371
+ return -EINVAL;
372
+
369373 /*
370374 * the reference clock at PFD(FPFD = ref_clk / ref_div) about
371375 * 25MHz is recommende, FPFD must range from 16MHz to 35MHz,
....@@ -399,14 +403,9 @@
399403 combtxphy->fb_div = fb_div;
400404
401405 phy_set_bus_width(phy, bus_width);
402
-
403406 break;
404407 }
405
- default:
406
- return -EINVAL;
407408 }
408
-
409
- combtxphy->mode = mode;
410409
411410 return 0;
412411 }