From 0cac853c2ad2d8c944459737fa539d538307c9c4 Mon Sep 17 00:00:00 2001 From: Konrad Dybcio Date: Mon, 14 Dec 2020 12:10:31 +0100 Subject: [PATCH] drm/msm/sde: sde_hw_top: Fix UBWC version detection for SDM630 SDM630 (and by extension 636/660 and probably 8998) don't seem to have a working UBWC version register, but the UBWC version is already specified in the DT and then read out by SDE, so let's make use of that instead. Signed-off-by: Konrad Dybcio --- drivers/gpu/drm/msm/sde/sde_hw_top.c | 37 ++++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/msm/sde/sde_hw_top.c b/drivers/gpu/drm/msm/sde/sde_hw_top.c index beb0613033b89..44906a7e04fa1 100644 --- a/drivers/gpu/drm/msm/sde/sde_hw_top.c +++ b/drivers/gpu/drm/msm/sde/sde_hw_top.c @@ -387,6 +387,10 @@ void sde_hw_reset_ubwc(struct sde_hw_mdp *mdp, struct sde_mdss_cfg *m) { struct sde_hw_blk_reg_map c; u32 ubwc_version; + u32 reg = m->mdp[0].ubwc_static | + (m->mdp[0].ubwc_swizzle & 0x1) | + ((m->mdp[0].highest_bank_bit & 0x3) << 4) | + ((m->macrotile_mode & 0x1) << 12); if (!mdp || !m) return; @@ -394,24 +398,25 @@ void sde_hw_reset_ubwc(struct sde_hw_mdp *mdp, struct sde_mdss_cfg *m) /* force blk offset to zero to access beginning of register region */ c = mdp->hw; c.blk_off = 0x0; - ubwc_version = SDE_REG_READ(&c, UBWC_DEC_HW_VERSION); + /* 630 doesn't seem to have the UBWC version register */ + //ubwc_version = SDE_REG_READ(&c, UBWC_DEC_HW_VERSION); + ubwc_version = m->ubwc_version; - if (IS_UBWC_20_SUPPORTED(ubwc_version)) { - SDE_REG_WRITE(&c, UBWC_STATIC, m->mdp[0].ubwc_static); - } else if (IS_UBWC_30_SUPPORTED(ubwc_version)) { - u32 reg = m->mdp[0].ubwc_static | - (m->mdp[0].ubwc_swizzle & 0x1) | - ((m->mdp[0].highest_bank_bit & 0x3) << 4) | - ((m->macrotile_mode & 0x1) << 12); - - if (IS_UBWC_30_SUPPORTED(m->ubwc_version)) - reg |= BIT(10); - if (IS_UBWC_10_SUPPORTED(m->ubwc_version)) + switch(ubwc_version) { + case 0x10000000: reg |= BIT(8); - - SDE_REG_WRITE(&c, UBWC_STATIC, reg); - } else { - SDE_ERROR("Unsupported UBWC version 0x%08x\n", ubwc_version); + SDE_REG_WRITE(&c, UBWC_STATIC, reg); + break; + case 0x20000000: + SDE_REG_WRITE(&c, UBWC_STATIC, m->mdp[0].ubwc_static); + break; + case 0x30000000: + reg |= BIT(10); + SDE_REG_WRITE(&c, UBWC_STATIC, reg); + break; + default: + SDE_ERROR("Unsupported UBWC version 0x%08x\n", ubwc_version); + break; } }