@@ -77,9 +77,20 @@ struct qcom_edp_swing_pre_emph_cfg {
77
77
const u8 (* pre_emphasis_hbr3_hbr2 )[4 ][4 ];
78
78
};
79
79
80
+ struct qcom_edp ;
81
+
82
+ struct phy_ver_ops {
83
+ int (* com_power_on )(const struct qcom_edp * edp );
84
+ int (* com_resetsm_cntrl )(const struct qcom_edp * edp );
85
+ int (* com_bias_en_clkbuflr )(const struct qcom_edp * edp );
86
+ int (* com_configure_pll )(const struct qcom_edp * edp );
87
+ int (* com_configure_ssc )(const struct qcom_edp * edp );
88
+ };
89
+
80
90
struct qcom_edp_phy_cfg {
81
91
bool is_edp ;
82
92
const struct qcom_edp_swing_pre_emph_cfg * swing_pre_emph_cfg ;
93
+ const struct phy_ver_ops * ver_ops ;
83
94
};
84
95
85
96
struct qcom_edp {
@@ -174,18 +185,6 @@ static const struct qcom_edp_swing_pre_emph_cfg edp_phy_swing_pre_emph_cfg = {
174
185
.pre_emphasis_hbr3_hbr2 = & edp_pre_emp_hbr2_hbr3 ,
175
186
};
176
187
177
- static const struct qcom_edp_phy_cfg sc7280_dp_phy_cfg = {
178
- };
179
-
180
- static const struct qcom_edp_phy_cfg sc8280xp_dp_phy_cfg = {
181
- .swing_pre_emph_cfg = & dp_phy_swing_pre_emph_cfg ,
182
- };
183
-
184
- static const struct qcom_edp_phy_cfg sc8280xp_edp_phy_cfg = {
185
- .is_edp = true,
186
- .swing_pre_emph_cfg = & edp_phy_swing_pre_emph_cfg ,
187
- };
188
-
189
188
static int qcom_edp_phy_init (struct phy * phy )
190
189
{
191
190
struct qcom_edp * edp = phy_get_drvdata (phy );
@@ -204,8 +203,9 @@ static int qcom_edp_phy_init(struct phy *phy)
204
203
DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN ,
205
204
edp -> edp + DP_PHY_PD_CTL );
206
205
207
- /* Turn on BIAS current for PHY/PLL */
208
- writel (0x17 , edp -> pll + QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN );
206
+ ret = edp -> cfg -> ver_ops -> com_bias_en_clkbuflr (edp );
207
+ if (ret )
208
+ return ret ;
209
209
210
210
writel (DP_PHY_PD_CTL_PSR_PWRDN , edp -> edp + DP_PHY_PD_CTL );
211
211
msleep (20 );
@@ -312,6 +312,84 @@ static int qcom_edp_phy_configure(struct phy *phy, union phy_configure_opts *opt
312
312
}
313
313
314
314
static int qcom_edp_configure_ssc (const struct qcom_edp * edp )
315
+ {
316
+ return edp -> cfg -> ver_ops -> com_configure_ssc (edp );
317
+ }
318
+
319
+ static int qcom_edp_configure_pll (const struct qcom_edp * edp )
320
+ {
321
+ return edp -> cfg -> ver_ops -> com_configure_pll (edp );
322
+ }
323
+
324
+ static int qcom_edp_set_vco_div (const struct qcom_edp * edp , unsigned long * pixel_freq )
325
+ {
326
+ const struct phy_configure_opts_dp * dp_opts = & edp -> dp_opts ;
327
+ u32 vco_div ;
328
+
329
+ switch (dp_opts -> link_rate ) {
330
+ case 1620 :
331
+ vco_div = 0x1 ;
332
+ * pixel_freq = 1620000000UL / 2 ;
333
+ break ;
334
+
335
+ case 2700 :
336
+ vco_div = 0x1 ;
337
+ * pixel_freq = 2700000000UL / 2 ;
338
+ break ;
339
+
340
+ case 5400 :
341
+ vco_div = 0x2 ;
342
+ * pixel_freq = 5400000000UL / 4 ;
343
+ break ;
344
+
345
+ case 8100 :
346
+ vco_div = 0x0 ;
347
+ * pixel_freq = 8100000000UL / 6 ;
348
+ break ;
349
+
350
+ default :
351
+ /* Other link rates aren't supported */
352
+ return - EINVAL ;
353
+ }
354
+
355
+ writel (vco_div , edp -> edp + DP_PHY_VCO_DIV );
356
+
357
+ return 0 ;
358
+ }
359
+
360
+ static int qcom_edp_phy_power_on_v4 (const struct qcom_edp * edp )
361
+ {
362
+ u32 val ;
363
+
364
+ writel (DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
365
+ DP_PHY_PD_CTL_LANE_0_1_PWRDN | DP_PHY_PD_CTL_LANE_2_3_PWRDN |
366
+ DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN ,
367
+ edp -> edp + DP_PHY_PD_CTL );
368
+ writel (0xfc , edp -> edp + DP_PHY_MODE );
369
+
370
+ return readl_poll_timeout (edp -> pll + QSERDES_V4_COM_CMN_STATUS ,
371
+ val , val & BIT (7 ), 5 , 200 );
372
+ }
373
+
374
+ static int qcom_edp_phy_com_resetsm_cntrl_v4 (const struct qcom_edp * edp )
375
+ {
376
+ u32 val ;
377
+
378
+ writel (0x20 , edp -> pll + QSERDES_V4_COM_RESETSM_CNTRL );
379
+
380
+ return readl_poll_timeout (edp -> pll + QSERDES_V4_COM_C_READY_STATUS ,
381
+ val , val & BIT (0 ), 500 , 10000 );
382
+ }
383
+
384
+ static int qcom_edp_com_bias_en_clkbuflr_v4 (const struct qcom_edp * edp )
385
+ {
386
+ /* Turn on BIAS current for PHY/PLL */
387
+ writel (0x17 , edp -> pll + QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN );
388
+
389
+ return 0 ;
390
+ }
391
+
392
+ static int qcom_edp_com_configure_ssc_v4 (const struct qcom_edp * edp )
315
393
{
316
394
const struct phy_configure_opts_dp * dp_opts = & edp -> dp_opts ;
317
395
u32 step1 ;
@@ -345,7 +423,7 @@ static int qcom_edp_configure_ssc(const struct qcom_edp *edp)
345
423
return 0 ;
346
424
}
347
425
348
- static int qcom_edp_configure_pll (const struct qcom_edp * edp )
426
+ static int qcom_edp_com_configure_pll_v4 (const struct qcom_edp * edp )
349
427
{
350
428
const struct phy_configure_opts_dp * dp_opts = & edp -> dp_opts ;
351
429
u32 div_frac_start2_mode0 ;
@@ -431,64 +509,42 @@ static int qcom_edp_configure_pll(const struct qcom_edp *edp)
431
509
return 0 ;
432
510
}
433
511
434
- static int qcom_edp_set_vco_div (const struct qcom_edp * edp , unsigned long * pixel_freq )
435
- {
436
- const struct phy_configure_opts_dp * dp_opts = & edp -> dp_opts ;
437
- u32 vco_div ;
438
-
439
- switch (dp_opts -> link_rate ) {
440
- case 1620 :
441
- vco_div = 0x1 ;
442
- * pixel_freq = 1620000000UL / 2 ;
443
- break ;
444
-
445
- case 2700 :
446
- vco_div = 0x1 ;
447
- * pixel_freq = 2700000000UL / 2 ;
448
- break ;
449
-
450
- case 5400 :
451
- vco_div = 0x2 ;
452
- * pixel_freq = 5400000000UL / 4 ;
453
- break ;
454
-
455
- case 8100 :
456
- vco_div = 0x0 ;
457
- * pixel_freq = 8100000000UL / 6 ;
458
- break ;
512
+ static const struct phy_ver_ops qcom_edp_phy_ops_v4 = {
513
+ .com_power_on = qcom_edp_phy_power_on_v4 ,
514
+ .com_resetsm_cntrl = qcom_edp_phy_com_resetsm_cntrl_v4 ,
515
+ .com_bias_en_clkbuflr = qcom_edp_com_bias_en_clkbuflr_v4 ,
516
+ .com_configure_pll = qcom_edp_com_configure_pll_v4 ,
517
+ .com_configure_ssc = qcom_edp_com_configure_ssc_v4 ,
518
+ };
459
519
460
- default :
461
- /* Other link rates aren't supported */
462
- return - EINVAL ;
463
- }
520
+ static const struct qcom_edp_phy_cfg sc7280_dp_phy_cfg = {
521
+ .ver_ops = & qcom_edp_phy_ops_v4 ,
522
+ };
464
523
465
- writel (vco_div , edp -> edp + DP_PHY_VCO_DIV );
524
+ static const struct qcom_edp_phy_cfg sc8280xp_dp_phy_cfg = {
525
+ .swing_pre_emph_cfg = & dp_phy_swing_pre_emph_cfg ,
526
+ .ver_ops = & qcom_edp_phy_ops_v4 ,
527
+ };
466
528
467
- return 0 ;
468
- }
529
+ static const struct qcom_edp_phy_cfg sc8280xp_edp_phy_cfg = {
530
+ .is_edp = true,
531
+ .swing_pre_emph_cfg = & edp_phy_swing_pre_emph_cfg ,
532
+ .ver_ops = & qcom_edp_phy_ops_v4 ,
533
+ };
469
534
470
535
static int qcom_edp_phy_power_on (struct phy * phy )
471
536
{
472
537
const struct qcom_edp * edp = phy_get_drvdata (phy );
473
538
u32 bias0_en , drvr0_en , bias1_en , drvr1_en ;
474
539
unsigned long pixel_freq ;
475
540
u8 ldo_config = 0x0 ;
476
- int timeout ;
477
541
int ret ;
478
542
u32 val ;
479
543
u8 cfg1 ;
480
544
481
- writel (DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
482
- DP_PHY_PD_CTL_LANE_0_1_PWRDN | DP_PHY_PD_CTL_LANE_2_3_PWRDN |
483
- DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN ,
484
- edp -> edp + DP_PHY_PD_CTL );
485
- writel (0xfc , edp -> edp + DP_PHY_MODE );
486
-
487
- timeout = readl_poll_timeout (edp -> pll + QSERDES_V4_COM_CMN_STATUS ,
488
- val , val & BIT (7 ), 5 , 200 );
489
- if (timeout )
490
- return timeout ;
491
-
545
+ ret = edp -> cfg -> ver_ops -> com_power_on (edp );
546
+ if (ret )
547
+ return ret ;
492
548
493
549
if (edp -> cfg -> swing_pre_emph_cfg && !edp -> is_edp )
494
550
ldo_config = 0x1 ;
@@ -535,12 +591,9 @@ static int qcom_edp_phy_power_on(struct phy *phy)
535
591
writel (0x01 , edp -> edp + DP_PHY_CFG );
536
592
writel (0x09 , edp -> edp + DP_PHY_CFG );
537
593
538
- writel (0x20 , edp -> pll + QSERDES_V4_COM_RESETSM_CNTRL );
539
-
540
- timeout = readl_poll_timeout (edp -> pll + QSERDES_V4_COM_C_READY_STATUS ,
541
- val , val & BIT (0 ), 500 , 10000 );
542
- if (timeout )
543
- return timeout ;
594
+ ret = edp -> cfg -> ver_ops -> com_resetsm_cntrl (edp );
595
+ if (ret )
596
+ return ret ;
544
597
545
598
writel (0x19 , edp -> edp + DP_PHY_CFG );
546
599
writel (0x1f , edp -> tx0 + TXn_HIGHZ_DRVR_EN );
0 commit comments