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

drm/msm/dp: move link-specific parsing from dp_panel to dp_link

Since max_dp_lanes and max_dp_link_rate are link-specific parameters, move
their parsing from dp_panel to dp_link for better separation of concerns.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/675643/
Link: https://lore.kernel.org/r/20250919-add-displayport-support-for-qcs615-platform-v5-13-eae6681f4002@oss.qualcomm.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

authored by

Xiangxu Yin and committed by
Dmitry Baryshkov
c8fc7280 d7ec9366

+70 -72
+57
drivers/gpu/drm/msm/dp/dp_link.c
··· 6 6 #define pr_fmt(fmt) "[drm-dp] %s: " fmt, __func__ 7 7 8 8 #include <drm/drm_device.h> 9 + #include <drm/drm_of.h> 9 10 #include <drm/drm_print.h> 10 11 11 12 #include "dp_reg.h" 12 13 #include "dp_link.h" 13 14 #include "dp_panel.h" 14 15 16 + #define DP_LINK_RATE_HBR2 540000 /* kbytes */ 15 17 #define DP_TEST_REQUEST_MASK 0x7F 16 18 17 19 enum audio_sample_rate { ··· 1212 1210 return tbd; 1213 1211 } 1214 1212 1213 + static u32 msm_dp_link_link_frequencies(struct device_node *of_node) 1214 + { 1215 + struct device_node *endpoint; 1216 + u64 frequency = 0; 1217 + int cnt; 1218 + 1219 + endpoint = of_graph_get_endpoint_by_regs(of_node, 1, 0); /* port@1 */ 1220 + if (!endpoint) 1221 + return 0; 1222 + 1223 + cnt = of_property_count_u64_elems(endpoint, "link-frequencies"); 1224 + 1225 + if (cnt > 0) 1226 + of_property_read_u64_index(endpoint, "link-frequencies", 1227 + cnt - 1, &frequency); 1228 + of_node_put(endpoint); 1229 + 1230 + do_div(frequency, 1231 + 10 * /* from symbol rate to link rate */ 1232 + 1000); /* kbytes */ 1233 + 1234 + return frequency; 1235 + } 1236 + 1237 + static int msm_dp_link_parse_dt(struct device *dev, struct msm_dp_link *msm_dp_link) 1238 + { 1239 + struct device_node *of_node = dev->of_node; 1240 + int cnt; 1241 + 1242 + /* 1243 + * data-lanes is the property of msm_dp_out endpoint 1244 + */ 1245 + cnt = drm_of_get_data_lanes_count_ep(of_node, 1, 0, 1, DP_MAX_NUM_DP_LANES); 1246 + if (cnt < 0) { 1247 + /* legacy code, data-lanes is the property of mdss_dp node */ 1248 + cnt = drm_of_get_data_lanes_count(of_node, 1, DP_MAX_NUM_DP_LANES); 1249 + } 1250 + 1251 + if (cnt > 0) 1252 + msm_dp_link->max_dp_lanes = cnt; 1253 + else 1254 + msm_dp_link->max_dp_lanes = DP_MAX_NUM_DP_LANES; /* 4 lanes */ 1255 + 1256 + msm_dp_link->max_dp_link_rate = msm_dp_link_link_frequencies(of_node); 1257 + if (!msm_dp_link->max_dp_link_rate) 1258 + msm_dp_link->max_dp_link_rate = DP_LINK_RATE_HBR2; 1259 + 1260 + return 0; 1261 + } 1262 + 1215 1263 struct msm_dp_link *msm_dp_link_get(struct device *dev, struct drm_dp_aux *aux) 1216 1264 { 1217 1265 struct msm_dp_link_private *link; 1218 1266 struct msm_dp_link *msm_dp_link; 1267 + int ret; 1219 1268 1220 1269 if (!dev || !aux) { 1221 1270 DRM_ERROR("invalid input\n"); ··· 1281 1228 1282 1229 mutex_init(&link->psm_mutex); 1283 1230 msm_dp_link = &link->msm_dp_link; 1231 + 1232 + ret = msm_dp_link_parse_dt(dev, msm_dp_link); 1233 + if (ret) 1234 + return ERR_PTR(ret); 1284 1235 1285 1236 return msm_dp_link; 1286 1237 }
+4
drivers/gpu/drm/msm/dp/dp_link.h
··· 12 12 #define DS_PORT_STATUS_CHANGED 0x200 13 13 #define DP_TEST_BIT_DEPTH_UNKNOWN 0xFFFFFFFF 14 14 #define DP_LINK_CAP_ENHANCED_FRAMING (1 << 0) 15 + #define DP_MAX_NUM_DP_LANES 4 15 16 16 17 struct msm_dp_link_info { 17 18 unsigned char revision; ··· 73 72 struct msm_dp_link_test_audio test_audio; 74 73 struct msm_dp_link_phy_params phy_params; 75 74 struct msm_dp_link_info link_params; 75 + 76 + u32 max_dp_lanes; 77 + u32 max_dp_link_rate; 76 78 }; 77 79 78 80 /**
+9 -69
drivers/gpu/drm/msm/dp/dp_panel.c
··· 16 16 17 17 #define DP_INTF_CONFIG_DATABUS_WIDEN BIT(4) 18 18 19 - #define DP_MAX_NUM_DP_LANES 4 20 - #define DP_LINK_RATE_HBR2 540000 /* kbytes */ 21 - 22 19 struct msm_dp_panel_private { 23 20 struct device *dev; 24 21 struct drm_device *drm_dev; ··· 88 91 int rc, max_lttpr_lanes, max_lttpr_rate; 89 92 struct msm_dp_panel_private *panel; 90 93 struct msm_dp_link_info *link_info; 94 + struct msm_dp_link *link; 91 95 u8 *dpcd, major, minor; 92 96 93 97 panel = container_of(msm_dp_panel, struct msm_dp_panel_private, msm_dp_panel); ··· 103 105 major = (link_info->revision >> 4) & 0x0f; 104 106 minor = link_info->revision & 0x0f; 105 107 108 + link = panel->link; 109 + drm_dbg_dp(panel->drm_dev, "max_lanes=%d max_link_rate=%d\n", 110 + link->max_dp_lanes, link->max_dp_link_rate); 111 + 106 112 link_info->rate = drm_dp_max_link_rate(dpcd); 107 113 link_info->num_lanes = drm_dp_max_lane_count(dpcd); 108 114 109 115 /* Limit data lanes from data-lanes of endpoint property of dtsi */ 110 - if (link_info->num_lanes > msm_dp_panel->max_dp_lanes) 111 - link_info->num_lanes = msm_dp_panel->max_dp_lanes; 116 + if (link_info->num_lanes > link->max_dp_lanes) 117 + link_info->num_lanes = link->max_dp_lanes; 112 118 113 119 /* Limit link rate from link-frequencies of endpoint property of dtsi */ 114 - if (link_info->rate > msm_dp_panel->max_dp_link_rate) 115 - link_info->rate = msm_dp_panel->max_dp_link_rate; 120 + if (link_info->rate > link->max_dp_link_rate) 121 + link_info->rate = link->max_dp_link_rate; 116 122 117 123 /* Limit data lanes from LTTPR capabilities, if any */ 118 124 max_lttpr_lanes = drm_dp_lttpr_max_lane_count(panel->link->lttpr_common_caps); ··· 174 172 } 175 173 176 174 panel = container_of(msm_dp_panel, struct msm_dp_panel_private, msm_dp_panel); 177 - 178 - drm_dbg_dp(panel->drm_dev, "max_lanes=%d max_link_rate=%d\n", 179 - msm_dp_panel->max_dp_lanes, msm_dp_panel->max_dp_link_rate); 180 175 181 176 rc = msm_dp_panel_read_dpcd(msm_dp_panel); 182 177 if (rc) { ··· 647 648 return 0; 648 649 } 649 650 650 - static u32 msm_dp_panel_link_frequencies(struct device_node *of_node) 651 - { 652 - struct device_node *endpoint; 653 - u64 frequency = 0; 654 - int cnt; 655 - 656 - endpoint = of_graph_get_endpoint_by_regs(of_node, 1, 0); /* port@1 */ 657 - if (!endpoint) 658 - return 0; 659 - 660 - cnt = of_property_count_u64_elems(endpoint, "link-frequencies"); 661 - 662 - if (cnt > 0) 663 - of_property_read_u64_index(endpoint, "link-frequencies", 664 - cnt - 1, &frequency); 665 - of_node_put(endpoint); 666 - 667 - do_div(frequency, 668 - 10 * /* from symbol rate to link rate */ 669 - 1000); /* kbytes */ 670 - 671 - return frequency; 672 - } 673 - 674 - static int msm_dp_panel_parse_dt(struct msm_dp_panel *msm_dp_panel) 675 - { 676 - struct msm_dp_panel_private *panel; 677 - struct device_node *of_node; 678 - int cnt; 679 - 680 - panel = container_of(msm_dp_panel, struct msm_dp_panel_private, msm_dp_panel); 681 - of_node = panel->dev->of_node; 682 - 683 - /* 684 - * data-lanes is the property of msm_dp_out endpoint 685 - */ 686 - cnt = drm_of_get_data_lanes_count_ep(of_node, 1, 0, 1, DP_MAX_NUM_DP_LANES); 687 - if (cnt < 0) { 688 - /* legacy code, data-lanes is the property of mdss_dp node */ 689 - cnt = drm_of_get_data_lanes_count(of_node, 1, DP_MAX_NUM_DP_LANES); 690 - } 691 - 692 - if (cnt > 0) 693 - msm_dp_panel->max_dp_lanes = cnt; 694 - else 695 - msm_dp_panel->max_dp_lanes = DP_MAX_NUM_DP_LANES; /* 4 lanes */ 696 - 697 - msm_dp_panel->max_dp_link_rate = msm_dp_panel_link_frequencies(of_node); 698 - if (!msm_dp_panel->max_dp_link_rate) 699 - msm_dp_panel->max_dp_link_rate = DP_LINK_RATE_HBR2; 700 - 701 - return 0; 702 - } 703 - 704 651 struct msm_dp_panel *msm_dp_panel_get(struct device *dev, struct drm_dp_aux *aux, 705 652 struct msm_dp_link *link, 706 653 void __iomem *link_base, ··· 654 709 { 655 710 struct msm_dp_panel_private *panel; 656 711 struct msm_dp_panel *msm_dp_panel; 657 - int ret; 658 712 659 713 if (!dev || !aux || !link) { 660 714 DRM_ERROR("invalid input\n"); ··· 672 728 673 729 msm_dp_panel = &panel->msm_dp_panel; 674 730 msm_dp_panel->max_bw_code = DP_LINK_BW_8_1; 675 - 676 - ret = msm_dp_panel_parse_dt(msm_dp_panel); 677 - if (ret) 678 - return ERR_PTR(ret); 679 731 680 732 return msm_dp_panel; 681 733 }
-3
drivers/gpu/drm/msm/dp/dp_panel.h
··· 41 41 bool vsc_sdp_supported; 42 42 u32 hw_revision; 43 43 44 - u32 max_dp_lanes; 45 - u32 max_dp_link_rate; 46 - 47 44 u32 max_bw_code; 48 45 }; 49 46