@@ -636,27 +636,28 @@ static void zynqmp_dp_adjust_train(struct zynqmp_dp *dp,
636
636
/**
637
637
* zynqmp_dp_update_vs_emph - Update the training values
638
638
* @dp: DisplayPort IP core structure
639
+ * @train_set: A set of training values
639
640
*
640
641
* Update the training values based on the request from sink. The mapped values
641
642
* are predefined, and values(vs, pe, pc) are from the device manual.
642
643
*
643
644
* Return: 0 if vs and emph are updated successfully, or the error code returned
644
645
* by drm_dp_dpcd_write().
645
646
*/
646
- static int zynqmp_dp_update_vs_emph (struct zynqmp_dp * dp )
647
+ static int zynqmp_dp_update_vs_emph (struct zynqmp_dp * dp , u8 * train_set )
647
648
{
648
649
unsigned int i ;
649
650
int ret ;
650
651
651
- ret = drm_dp_dpcd_write (& dp -> aux , DP_TRAINING_LANE0_SET , dp -> train_set ,
652
+ ret = drm_dp_dpcd_write (& dp -> aux , DP_TRAINING_LANE0_SET , train_set ,
652
653
dp -> mode .lane_cnt );
653
654
if (ret < 0 )
654
655
return ret ;
655
656
656
657
for (i = 0 ; i < dp -> mode .lane_cnt ; i ++ ) {
657
658
u32 reg = ZYNQMP_DP_SUB_TX_PHY_PRECURSOR_LANE_0 + i * 4 ;
658
659
union phy_configure_opts opts = { 0 };
659
- u8 train = dp -> train_set [i ];
660
+ u8 train = train_set [i ];
660
661
661
662
opts .dp .voltage [0 ] = (train & DP_TRAIN_VOLTAGE_SWING_MASK )
662
663
>> DP_TRAIN_VOLTAGE_SWING_SHIFT ;
@@ -700,7 +701,7 @@ static int zynqmp_dp_link_train_cr(struct zynqmp_dp *dp)
700
701
* So, This loop should exit before 512 iterations
701
702
*/
702
703
for (max_tries = 0 ; max_tries < 512 ; max_tries ++ ) {
703
- ret = zynqmp_dp_update_vs_emph (dp );
704
+ ret = zynqmp_dp_update_vs_emph (dp , dp -> train_set );
704
705
if (ret )
705
706
return ret ;
706
707
@@ -765,7 +766,7 @@ static int zynqmp_dp_link_train_ce(struct zynqmp_dp *dp)
765
766
return ret ;
766
767
767
768
for (tries = 0 ; tries < DP_MAX_TRAINING_TRIES ; tries ++ ) {
768
- ret = zynqmp_dp_update_vs_emph (dp );
769
+ ret = zynqmp_dp_update_vs_emph (dp , dp -> train_set );
769
770
if (ret )
770
771
return ret ;
771
772
@@ -788,28 +789,29 @@ static int zynqmp_dp_link_train_ce(struct zynqmp_dp *dp)
788
789
}
789
790
790
791
/**
791
- * zynqmp_dp_train - Train the link
792
+ * zynqmp_dp_setup() - Set up major link parameters
792
793
* @dp: DisplayPort IP core structure
794
+ * @bw_code: The link bandwidth as a multiple of 270 MHz
795
+ * @lane_cnt: The number of lanes to use
796
+ * @enhanced: Use enhanced framing
797
+ * @downspread: Enable spread-spectrum clocking
793
798
*
794
- * Return: 0 if all trains are done successfully , or corresponding error code.
799
+ * Return: 0 on success , or -errno on failure
795
800
*/
796
- static int zynqmp_dp_train (struct zynqmp_dp * dp )
801
+ static int zynqmp_dp_setup (struct zynqmp_dp * dp , u8 bw_code , u8 lane_cnt ,
802
+ bool enhanced , bool downspread )
797
803
{
798
804
u32 reg ;
799
- u8 bw_code = dp -> mode .bw_code ;
800
- u8 lane_cnt = dp -> mode .lane_cnt ;
801
805
u8 aux_lane_cnt = lane_cnt ;
802
- bool enhanced ;
803
806
int ret ;
804
807
805
808
zynqmp_dp_write (dp , ZYNQMP_DP_LANE_COUNT_SET , lane_cnt );
806
- enhanced = drm_dp_enhanced_frame_cap (dp -> dpcd );
807
809
if (enhanced ) {
808
810
zynqmp_dp_write (dp , ZYNQMP_DP_ENHANCED_FRAME_EN , 1 );
809
811
aux_lane_cnt |= DP_LANE_COUNT_ENHANCED_FRAME_EN ;
810
812
}
811
813
812
- if (dp -> dpcd [ 3 ] & 0x1 ) {
814
+ if (downspread ) {
813
815
zynqmp_dp_write (dp , ZYNQMP_DP_DOWNSPREAD_CTL , 1 );
814
816
drm_dp_dpcd_writeb (& dp -> aux , DP_DOWNSPREAD_CTRL ,
815
817
DP_SPREAD_AMP_0_5 );
@@ -852,8 +854,24 @@ static int zynqmp_dp_train(struct zynqmp_dp *dp)
852
854
}
853
855
854
856
zynqmp_dp_write (dp , ZYNQMP_DP_PHY_CLOCK_SELECT , reg );
855
- ret = zynqmp_dp_phy_ready (dp );
856
- if (ret < 0 )
857
+ return zynqmp_dp_phy_ready (dp );
858
+ }
859
+
860
+ /**
861
+ * zynqmp_dp_train - Train the link
862
+ * @dp: DisplayPort IP core structure
863
+ *
864
+ * Return: 0 if all trains are done successfully, or corresponding error code.
865
+ */
866
+ static int zynqmp_dp_train (struct zynqmp_dp * dp )
867
+ {
868
+ int ret ;
869
+
870
+ ret = zynqmp_dp_setup (dp , dp -> mode .bw_code , dp -> mode .lane_cnt ,
871
+ drm_dp_enhanced_frame_cap (dp -> dpcd ),
872
+ dp -> dpcd [DP_MAX_DOWNSPREAD ] &
873
+ DP_MAX_DOWNSPREAD_0_5 );
874
+ if (ret )
857
875
return ret ;
858
876
859
877
zynqmp_dp_write (dp , ZYNQMP_DP_SCRAMBLING_DISABLE , 1 );
0 commit comments