Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/msm/dp: Enable support for eDP v1.4+ link rates table

The MSM DRM driver currently does not support panels which report their
supported link rates via the SUPPORTED_LINK_RATES table.

For panels which do not offer the optional eDP v1.3 fallback via
MAX_LINK_RATE, this will cause a panel probe failure (e.g. Samsung
ATNA30DW01-1 as found in Microsoft Surface Pro 11).

Detect eDP v1.4 panels and parse the SUPPORTED_LINK_RATES table when
present.

Additionally, set the rate using LINK_RATE_SET instead of LINK_BW_SET,
but only if LINK_BW_SET hasn't already been written to.

Signed-off-by: Dale Whinham <daleyo@gmail.com>
Tested-by: Jérôme de Bretagne <jerome.debretagne@gmail.com>
Tested-by: Steev Klimaszewski <threeway@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/695064/
Link: https://lore.kernel.org/r/20251218-drm-msm-edp14-v2-1-2e56c2338ab1@gmail.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

authored by

Dale Whinham and committed by
Dmitry Baryshkov
ed100aa2 794b0e68

+120 -32
+35 -21
drivers/gpu/drm/msm/dp/dp_ctrl.c
··· 175 175 static int msm_dp_aux_link_configure(struct drm_dp_aux *aux, 176 176 struct msm_dp_link_info *link) 177 177 { 178 - u8 values[2]; 178 + u8 lane_count, bw_code; 179 179 int err; 180 180 181 - values[0] = drm_dp_link_rate_to_bw_code(link->rate); 182 - values[1] = link->num_lanes; 181 + lane_count = link->num_lanes; 183 182 184 183 if (link->capabilities & DP_LINK_CAP_ENHANCED_FRAMING) 185 - values[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN; 184 + lane_count |= DP_LANE_COUNT_ENHANCED_FRAME_EN; 186 185 187 - err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, values, sizeof(values)); 186 + err = drm_dp_dpcd_writeb(aux, DP_LANE_COUNT_SET, lane_count); 188 187 if (err < 0) 189 188 return err; 190 189 191 - return 0; 190 + if (link->use_rate_set) { 191 + DRM_DEBUG_DP("using LINK_RATE_SET: 0x%02x", link->rate_set); 192 + err = drm_dp_dpcd_writeb(aux, DP_LINK_RATE_SET, link->rate_set); 193 + } else { 194 + bw_code = drm_dp_link_rate_to_bw_code(link->rate); 195 + DRM_DEBUG_DP("using LINK_BW_SET: 0x%02x", bw_code); 196 + err = drm_dp_dpcd_writeb(aux, DP_LINK_BW_SET, bw_code); 197 + } 198 + 199 + return err; 192 200 } 193 201 194 202 /* ··· 1482 1474 static int msm_dp_ctrl_link_rate_down_shift(struct msm_dp_ctrl_private *ctrl) 1483 1475 { 1484 1476 int ret = 0; 1477 + struct msm_dp_link_info *link_params = &ctrl->link->link_params; 1485 1478 1486 - switch (ctrl->link->link_params.rate) { 1487 - case 810000: 1488 - ctrl->link->link_params.rate = 540000; 1489 - break; 1490 - case 540000: 1491 - ctrl->link->link_params.rate = 270000; 1492 - break; 1493 - case 270000: 1494 - ctrl->link->link_params.rate = 162000; 1495 - break; 1496 - case 162000: 1497 - default: 1498 - ret = -EINVAL; 1499 - break; 1479 + if (link_params->rate_set) { 1480 + --link_params->rate_set; 1481 + link_params->rate = link_params->supported_rates[link_params->rate_set]; 1482 + } else { 1483 + switch (link_params->rate) { 1484 + case 810000: 1485 + link_params->rate = 540000; 1486 + break; 1487 + case 540000: 1488 + link_params->rate = 270000; 1489 + break; 1490 + case 270000: 1491 + link_params->rate = 162000; 1492 + break; 1493 + case 162000: 1494 + default: 1495 + ret = -EINVAL; 1496 + break; 1497 + } 1500 1498 } 1501 1499 1502 1500 if (!ret) { 1503 1501 drm_dbg_dp(ctrl->drm_dev, "new rate=0x%x\n", 1504 - ctrl->link->link_params.rate); 1502 + link_params->rate); 1505 1503 } 1506 1504 1507 1505 return ret;
+3
drivers/gpu/drm/msm/dp/dp_link.h
··· 17 17 struct msm_dp_link_info { 18 18 unsigned char revision; 19 19 unsigned int rate; 20 + unsigned int supported_rates[DP_MAX_SUPPORTED_RATES]; 21 + unsigned int rate_set; 22 + bool use_rate_set; 20 23 unsigned int num_lanes; 21 24 unsigned long capabilities; 22 25 };
+82 -11
drivers/gpu/drm/msm/dp/dp_panel.c
··· 13 13 #include <drm/drm_print.h> 14 14 15 15 #include <linux/io.h> 16 + #include <linux/types.h> 17 + #include <asm/byteorder.h> 16 18 17 19 #define DP_INTF_CONFIG_DATABUS_WIDEN BIT(4) 18 20 ··· 109 107 drm_dbg_dp(panel->drm_dev, "max_lanes=%d max_link_rate=%d\n", 110 108 link->max_dp_lanes, link->max_dp_link_rate); 111 109 112 - link_info->rate = drm_dp_max_link_rate(dpcd); 110 + max_lttpr_lanes = drm_dp_lttpr_max_lane_count(link->lttpr_common_caps); 111 + max_lttpr_rate = drm_dp_lttpr_max_link_rate(link->lttpr_common_caps); 112 + 113 + /* eDP sink */ 114 + if (msm_dp_panel->dpcd[DP_EDP_CONFIGURATION_CAP]) { 115 + u8 edp_rev; 116 + 117 + rc = drm_dp_dpcd_read_byte(panel->aux, DP_EDP_DPCD_REV, &edp_rev); 118 + if (rc) 119 + return rc; 120 + 121 + drm_dbg_dp(panel->drm_dev, "edp_rev=0x%x\n", edp_rev); 122 + 123 + /* For eDP v1.4+, parse the SUPPORTED_LINK_RATES table */ 124 + if (edp_rev >= DP_EDP_14) { 125 + __le16 rates[DP_MAX_SUPPORTED_RATES]; 126 + u8 bw_set; 127 + int i; 128 + 129 + rc = drm_dp_dpcd_read_data(panel->aux, DP_SUPPORTED_LINK_RATES, 130 + rates, sizeof(rates)); 131 + if (rc) 132 + return rc; 133 + 134 + rc = drm_dp_dpcd_read_byte(panel->aux, DP_LINK_BW_SET, &bw_set); 135 + if (rc) 136 + return rc; 137 + 138 + /* Find index of max supported link rate that does not exceed dtsi limits */ 139 + for (i = 0; i < ARRAY_SIZE(rates); i++) { 140 + /* 141 + * The value from the DPCD multiplied by 200 gives 142 + * the link rate in kHz. Divide by 10 to convert to 143 + * symbol rate, accounting for 8b/10b encoding. 144 + */ 145 + u32 rate = (le16_to_cpu(rates[i]) * 200) / 10; 146 + 147 + if (!rate) 148 + break; 149 + 150 + drm_dbg_dp(panel->drm_dev, 151 + "SUPPORTED_LINK_RATES[%d]: %d\n", i, rate); 152 + 153 + /* 154 + * Limit link rate from link-frequencies of endpoint 155 + * property of dtsi 156 + */ 157 + if (rate > link->max_dp_link_rate) 158 + break; 159 + 160 + /* Limit link rate from LTTPR capabilities, if any */ 161 + if (max_lttpr_rate && rate > max_lttpr_rate) 162 + break; 163 + 164 + link_info->rate = rate; 165 + link_info->supported_rates[i] = rate; 166 + link_info->rate_set = i; 167 + } 168 + 169 + /* Only use LINK_RATE_SET if LINK_BW_SET hasn't already been written to */ 170 + if (!bw_set && link_info->rate) 171 + link_info->use_rate_set = true; 172 + } 173 + } 174 + 175 + /* Fall back on MAX_LINK_RATE/LINK_BW_SET (DP, eDP <= v1.3) */ 176 + if (!link_info->rate) { 177 + link_info->rate = drm_dp_max_link_rate(dpcd); 178 + 179 + /* Limit link rate from link-frequencies of endpoint property of dtsi */ 180 + if (link_info->rate > link->max_dp_link_rate) 181 + link_info->rate = link->max_dp_link_rate; 182 + 183 + /* Limit link rate from LTTPR capabilities, if any */ 184 + if (max_lttpr_rate && max_lttpr_rate < link_info->rate) 185 + link_info->rate = max_lttpr_rate; 186 + } 187 + 113 188 link_info->num_lanes = drm_dp_max_lane_count(dpcd); 114 189 115 190 /* Limit data lanes from data-lanes of endpoint property of dtsi */ 116 191 if (link_info->num_lanes > link->max_dp_lanes) 117 192 link_info->num_lanes = link->max_dp_lanes; 118 193 119 - /* Limit link rate from link-frequencies of endpoint property of dtsi */ 120 - if (link_info->rate > link->max_dp_link_rate) 121 - link_info->rate = link->max_dp_link_rate; 122 - 123 194 /* Limit data lanes from LTTPR capabilities, if any */ 124 - max_lttpr_lanes = drm_dp_lttpr_max_lane_count(panel->link->lttpr_common_caps); 125 195 if (max_lttpr_lanes && max_lttpr_lanes < link_info->num_lanes) 126 196 link_info->num_lanes = max_lttpr_lanes; 127 197 128 - /* Limit link rate from LTTPR capabilities, if any */ 129 - max_lttpr_rate = drm_dp_lttpr_max_link_rate(panel->link->lttpr_common_caps); 130 - if (max_lttpr_rate && max_lttpr_rate < link_info->rate) 131 - link_info->rate = max_lttpr_rate; 132 - 133 198 drm_dbg_dp(panel->drm_dev, "version: %d.%d\n", major, minor); 134 199 drm_dbg_dp(panel->drm_dev, "link_rate=%d\n", link_info->rate); 200 + drm_dbg_dp(panel->drm_dev, "link_rate_set=%d\n", link_info->rate_set); 201 + drm_dbg_dp(panel->drm_dev, "use_rate_set=%d\n", link_info->use_rate_set); 135 202 drm_dbg_dp(panel->drm_dev, "lane_count=%d\n", link_info->num_lanes); 136 203 137 204 if (drm_dp_enhanced_frame_cap(dpcd))