Lines Matching +full:sc7180 +full:- +full:mdss

1 // SPDX-License-Identifier: GPL-2.0-only
7 #include <linux/adreno-smmu-priv.h>
12 #include "arm-smmu.h"
13 #include "arm-smmu-qcom.h"
15 #define QCOM_DUMMY_VAL -1
30 for (spin_cnt = TLB_SPIN_COUNT; spin_cnt > 0; spin_cnt--) { in qcom_smmu_tlb_sync()
53 if (qsmmu->stall_enabled & BIT(idx)) in qcom_adreno_smmu_write_sctlr()
63 struct arm_smmu_cfg *cfg = &smmu_domain->cfg; in qcom_adreno_smmu_get_fault_info()
64 struct arm_smmu_device *smmu = smmu_domain->smmu; in qcom_adreno_smmu_get_fault_info()
66 info->fsr = arm_smmu_cb_read(smmu, cfg->cbndx, ARM_SMMU_CB_FSR); in qcom_adreno_smmu_get_fault_info()
67 info->fsynr0 = arm_smmu_cb_read(smmu, cfg->cbndx, ARM_SMMU_CB_FSYNR0); in qcom_adreno_smmu_get_fault_info()
68 info->fsynr1 = arm_smmu_cb_read(smmu, cfg->cbndx, ARM_SMMU_CB_FSYNR1); in qcom_adreno_smmu_get_fault_info()
69 info->far = arm_smmu_cb_readq(smmu, cfg->cbndx, ARM_SMMU_CB_FAR); in qcom_adreno_smmu_get_fault_info()
70 info->cbfrsynra = arm_smmu_gr1_read(smmu, ARM_SMMU_GR1_CBFRSYNRA(cfg->cbndx)); in qcom_adreno_smmu_get_fault_info()
71 info->ttbr0 = arm_smmu_cb_readq(smmu, cfg->cbndx, ARM_SMMU_CB_TTBR0); in qcom_adreno_smmu_get_fault_info()
72 info->contextidr = arm_smmu_cb_read(smmu, cfg->cbndx, ARM_SMMU_CB_CONTEXTIDR); in qcom_adreno_smmu_get_fault_info()
78 struct arm_smmu_cfg *cfg = &smmu_domain->cfg; in qcom_adreno_smmu_set_stall()
79 struct qcom_smmu *qsmmu = to_qcom_smmu(smmu_domain->smmu); in qcom_adreno_smmu_set_stall()
82 qsmmu->stall_enabled |= BIT(cfg->cbndx); in qcom_adreno_smmu_set_stall()
84 qsmmu->stall_enabled &= ~BIT(cfg->cbndx); in qcom_adreno_smmu_set_stall()
90 struct arm_smmu_cfg *cfg = &smmu_domain->cfg; in qcom_adreno_smmu_resume_translation()
91 struct arm_smmu_device *smmu = smmu_domain->smmu; in qcom_adreno_smmu_resume_translation()
97 arm_smmu_cb_write(smmu, cfg->cbndx, ARM_SMMU_CB_RESUME, reg); in qcom_adreno_smmu_resume_translation()
109 * identify it and configure it for per-instance pagetables in qcom_adreno_smmu_is_gpu_device()
111 for (i = 0; i < fwspec->num_ids; i++) { in qcom_adreno_smmu_is_gpu_device()
112 u16 sid = FIELD_GET(ARM_SMMU_SMR_ID, fwspec->ids[i]); in qcom_adreno_smmu_is_gpu_device()
126 io_pgtable_ops_to_pgtable(smmu_domain->pgtbl_ops); in qcom_adreno_smmu_get_ttbr1_cfg()
127 return &pgtable->cfg; in qcom_adreno_smmu_get_ttbr1_cfg()
132 * The GPU driver will call this to enable TTBR0 when per-instance pagetables
140 struct io_pgtable *pgtable = io_pgtable_ops_to_pgtable(smmu_domain->pgtbl_ops); in qcom_adreno_smmu_set_ttbr0_cfg()
141 struct arm_smmu_cfg *cfg = &smmu_domain->cfg; in qcom_adreno_smmu_set_ttbr0_cfg()
142 struct arm_smmu_cb *cb = &smmu_domain->smmu->cbs[cfg->cbndx]; in qcom_adreno_smmu_set_ttbr0_cfg()
145 if (cb->tcr[0] & ARM_SMMU_TCR_EPD1) in qcom_adreno_smmu_set_ttbr0_cfg()
146 return -EINVAL; in qcom_adreno_smmu_set_ttbr0_cfg()
151 if ((cb->tcr[0] & ARM_SMMU_TCR_EPD0)) in qcom_adreno_smmu_set_ttbr0_cfg()
152 return -EINVAL; in qcom_adreno_smmu_set_ttbr0_cfg()
155 cb->tcr[0] = arm_smmu_lpae_tcr(&pgtable->cfg); in qcom_adreno_smmu_set_ttbr0_cfg()
156 cb->ttbr[0] = FIELD_PREP(ARM_SMMU_TTBRn_ASID, cb->cfg->asid); in qcom_adreno_smmu_set_ttbr0_cfg()
158 u32 tcr = cb->tcr[0]; in qcom_adreno_smmu_set_ttbr0_cfg()
161 if (!(cb->tcr[0] & ARM_SMMU_TCR_EPD0)) in qcom_adreno_smmu_set_ttbr0_cfg()
162 return -EINVAL; in qcom_adreno_smmu_set_ttbr0_cfg()
167 cb->tcr[0] = tcr; in qcom_adreno_smmu_set_ttbr0_cfg()
168 cb->ttbr[0] = pgtbl_cfg->arm_lpae_s1_cfg.ttbr; in qcom_adreno_smmu_set_ttbr0_cfg()
169 cb->ttbr[0] |= FIELD_PREP(ARM_SMMU_TTBRn_ASID, cb->cfg->asid); in qcom_adreno_smmu_set_ttbr0_cfg()
172 arm_smmu_write_context_bank(smmu_domain->smmu, cb->cfg->cbndx); in qcom_adreno_smmu_set_ttbr0_cfg()
192 count = smmu->num_context_banks; in qcom_adreno_smmu_alloc_context_bank()
195 return __arm_smmu_alloc_bitmap(smmu->context_map, start, count); in qcom_adreno_smmu_alloc_context_bank()
200 const struct device_node *np = smmu->dev->of_node; in qcom_adreno_can_do_ttbr1()
202 if (of_device_is_compatible(np, "qcom,msm8996-smmu-v2")) in qcom_adreno_can_do_ttbr1()
213 smmu_domain->cfg.flush_walk_prefer_tlbiasid = true; in qcom_adreno_smmu_init_context()
220 * All targets that use the qcom,adreno-smmu compatible string *should* in qcom_adreno_smmu_init_context()
221 * be AARCH64 stage 1 but double check because the arm-smmu code assumes in qcom_adreno_smmu_init_context()
224 if (qcom_adreno_can_do_ttbr1(smmu_domain->smmu) && in qcom_adreno_smmu_init_context()
225 (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) && in qcom_adreno_smmu_init_context()
226 (smmu_domain->cfg.fmt == ARM_SMMU_CTX_FMT_AARCH64)) in qcom_adreno_smmu_init_context()
227 pgtbl_cfg->quirks |= IO_PGTABLE_QUIRK_ARM_TTBR1; in qcom_adreno_smmu_init_context()
234 priv->cookie = smmu_domain; in qcom_adreno_smmu_init_context()
235 priv->get_ttbr1_cfg = qcom_adreno_smmu_get_ttbr1_cfg; in qcom_adreno_smmu_init_context()
236 priv->set_ttbr0_cfg = qcom_adreno_smmu_set_ttbr0_cfg; in qcom_adreno_smmu_init_context()
237 priv->get_fault_info = qcom_adreno_smmu_get_fault_info; in qcom_adreno_smmu_init_context()
238 priv->set_stall = qcom_adreno_smmu_set_stall; in qcom_adreno_smmu_init_context()
239 priv->resume_translation = qcom_adreno_smmu_resume_translation; in qcom_adreno_smmu_init_context()
247 { .compatible = "qcom,mdss" },
248 { .compatible = "qcom,sc7180-mdss" },
249 { .compatible = "qcom,sc7180-mss-pil" },
250 { .compatible = "qcom,sc7280-mdss" },
251 { .compatible = "qcom,sc7280-mss-pil" },
252 { .compatible = "qcom,sc8180x-mdss" },
253 { .compatible = "qcom,sm8250-mdss" },
254 { .compatible = "qcom,sdm845-mdss" },
255 { .compatible = "qcom,sdm845-mss-pil" },
262 smmu_domain->cfg.flush_walk_prefer_tlbiasid = true; in qcom_smmu_init_context()
269 unsigned int last_s2cr = ARM_SMMU_GR0_S2CR(smmu->num_mapping_groups - 1); in qcom_smmu_cfg_probe()
287 qsmmu->bypass_quirk = true; in qcom_smmu_cfg_probe()
288 qsmmu->bypass_cbndx = smmu->num_context_banks - 1; in qcom_smmu_cfg_probe()
290 set_bit(qsmmu->bypass_cbndx, smmu->context_map); in qcom_smmu_cfg_probe()
292 arm_smmu_cb_write(smmu, qsmmu->bypass_cbndx, ARM_SMMU_CB_SCTLR, 0); in qcom_smmu_cfg_probe()
295 arm_smmu_gr1_write(smmu, ARM_SMMU_GR1_CBAR(qsmmu->bypass_cbndx), reg); in qcom_smmu_cfg_probe()
298 for (i = 0; i < smmu->num_mapping_groups; i++) { in qcom_smmu_cfg_probe()
304 smmu->smrs[i].id = FIELD_GET(ARM_SMMU_SMR_ID, smr); in qcom_smmu_cfg_probe()
305 smmu->smrs[i].mask = FIELD_GET(ARM_SMMU_SMR_MASK, smr); in qcom_smmu_cfg_probe()
306 smmu->smrs[i].valid = true; in qcom_smmu_cfg_probe()
308 smmu->s2crs[i].type = S2CR_TYPE_BYPASS; in qcom_smmu_cfg_probe()
309 smmu->s2crs[i].privcfg = S2CR_PRIVCFG_DEFAULT; in qcom_smmu_cfg_probe()
310 smmu->s2crs[i].cbndx = 0xff; in qcom_smmu_cfg_probe()
319 struct arm_smmu_s2cr *s2cr = smmu->s2crs + idx; in qcom_smmu_write_s2cr()
321 u32 cbndx = s2cr->cbndx; in qcom_smmu_write_s2cr()
322 u32 type = s2cr->type; in qcom_smmu_write_s2cr()
325 if (qsmmu->bypass_quirk) { in qcom_smmu_write_s2cr()
334 cbndx = qsmmu->bypass_cbndx; in qcom_smmu_write_s2cr()
348 FIELD_PREP(ARM_SMMU_S2CR_PRIVCFG, s2cr->privcfg); in qcom_smmu_write_s2cr()
365 * To address performance degradation in non-real time clients, in qcom_sdm845_smmu500_reset()
366 * such as USB and UFS, turn off wait-for-safe on sdm845 based boards, in qcom_sdm845_smmu500_reset()
368 * call handlers to turn on/off the wait-for-safe logic. in qcom_sdm845_smmu500_reset()
372 dev_warn(smmu->dev, "Failed to turn off SAFE logic\n"); in qcom_sdm845_smmu500_reset()
379 const struct device_node *np = smmu->dev->of_node; in qcom_smmu500_reset()
383 if (of_device_is_compatible(np, "qcom,sdm845-smmu-500")) in qcom_smmu500_reset()
414 return ERR_PTR(-EPROBE_DEFER); in qcom_smmu_create()
416 qsmmu = devm_krealloc(smmu->dev, smmu, sizeof(*qsmmu), GFP_KERNEL); in qcom_smmu_create()
418 return ERR_PTR(-ENOMEM); in qcom_smmu_create()
420 qsmmu->smmu.impl = impl; in qcom_smmu_create()
421 qsmmu->cfg = qcom_smmu_impl_data(smmu); in qcom_smmu_create()
423 return &qsmmu->smmu; in qcom_smmu_create()
427 { .compatible = "qcom,msm8998-smmu-v2" },
428 { .compatible = "qcom,qcm2290-smmu-500" },
429 { .compatible = "qcom,sc7180-smmu-500" },
430 { .compatible = "qcom,sc7280-smmu-500" },
431 { .compatible = "qcom,sc8180x-smmu-500" },
432 { .compatible = "qcom,sc8280xp-smmu-500" },
433 { .compatible = "qcom,sdm630-smmu-v2" },
434 { .compatible = "qcom,sdm845-smmu-500" },
435 { .compatible = "qcom,sm6125-smmu-500" },
436 { .compatible = "qcom,sm6350-smmu-500" },
437 { .compatible = "qcom,sm6375-smmu-500" },
438 { .compatible = "qcom,sm8150-smmu-500" },
439 { .compatible = "qcom,sm8250-smmu-500" },
440 { .compatible = "qcom,sm8350-smmu-500" },
441 { .compatible = "qcom,sm8450-smmu-500" },
447 { "LENOVO", "CB-01 ", 0x8180, ACPI_SIG_IORT, equal, "QCOM SMMU" },
455 const struct device_node *np = smmu->dev->of_node; in qcom_smmu_impl_init()
468 * arm,mmu-500 in which case we will miss setting adreno smmu specific in qcom_smmu_impl_init()
471 if (of_device_is_compatible(np, "qcom,adreno-smmu")) in qcom_smmu_impl_init()