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/mdss: generate MDSS data for MDP5 platforms

Older (mdp5) platforms do not use per-SoC compatible strings. Instead
they use a single compat entry 'qcom,mdss'. To facilitate migrating
these platforms to the DPU driver provide a way to generate the MDSS /
UBWC data at runtime, when the DPU driver asks for it.

It is not possible to generate this data structure at the probe time,
since some platforms might not have MDP_CLK enabled, which makes reading
HW_REV register useless and prone to possible crashes.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/577502/
Link: https://lore.kernel.org/r/20240208-fd-migrate-mdp5-v4-1-945d08ef3fa8@linaro.org

+51
+51
drivers/gpu/drm/msm/msm_mdss.c
··· 3 3 * Copyright (c) 2018, The Linux Foundation 4 4 */ 5 5 6 + #include <linux/bitfield.h> 6 7 #include <linux/clk.h> 7 8 #include <linux/delay.h> 8 9 #include <linux/interconnect.h> ··· 214 213 } 215 214 } 216 215 216 + #define MDSS_HW_MAJ_MIN GENMASK(31, 16) 217 + 218 + #define MDSS_HW_MSM8996 0x1007 219 + #define MDSS_HW_MSM8937 0x100e 220 + #define MDSS_HW_MSM8953 0x1010 221 + #define MDSS_HW_MSM8998 0x3000 222 + #define MDSS_HW_SDM660 0x3002 223 + #define MDSS_HW_SDM630 0x3003 224 + 225 + /* 226 + * MDP5 platforms use generic qcom,mdp5 compat string, so we have to generate this data 227 + */ 228 + static const struct msm_mdss_data *msm_mdss_generate_mdp5_mdss_data(struct msm_mdss *mdss) 229 + { 230 + struct msm_mdss_data *data; 231 + u32 hw_rev; 232 + 233 + data = devm_kzalloc(mdss->dev, sizeof(*data), GFP_KERNEL); 234 + if (!data) 235 + return NULL; 236 + 237 + hw_rev = readl_relaxed(mdss->mmio + HW_REV); 238 + hw_rev = FIELD_GET(MDSS_HW_MAJ_MIN, hw_rev); 239 + 240 + if (hw_rev == MDSS_HW_MSM8996 || 241 + hw_rev == MDSS_HW_MSM8937 || 242 + hw_rev == MDSS_HW_MSM8953 || 243 + hw_rev == MDSS_HW_MSM8998 || 244 + hw_rev == MDSS_HW_SDM660 || 245 + hw_rev == MDSS_HW_SDM630) { 246 + data->ubwc_dec_version = UBWC_1_0; 247 + data->ubwc_enc_version = UBWC_1_0; 248 + } 249 + 250 + if (hw_rev == MDSS_HW_MSM8996 || 251 + hw_rev == MDSS_HW_MSM8998) 252 + data->highest_bank_bit = 2; 253 + else 254 + data->highest_bank_bit = 1; 255 + 256 + return data; 257 + } 258 + 217 259 const struct msm_mdss_data *msm_mdss_get_mdss_data(struct device *dev) 218 260 { 219 261 struct msm_mdss *mdss; ··· 265 221 return ERR_PTR(-EINVAL); 266 222 267 223 mdss = dev_get_drvdata(dev); 224 + 225 + /* 226 + * We could not do it at the probe time, since hw revision register was 227 + * not readable. Fill data structure now for the MDP5 platforms. 228 + */ 229 + if (!mdss->mdss_data && mdss->is_mdp5) 230 + mdss->mdss_data = msm_mdss_generate_mdp5_mdss_data(mdss); 268 231 269 232 return mdss->mdss_data; 270 233 }