Lines Matching refs:tbu

106 	struct qcom_tbu *tbu;  in qcom_find_tbu()  local
114 list_for_each_entry(tbu, &tbu_list, list) { in qcom_find_tbu()
115 start = tbu->sid_range[0]; in qcom_find_tbu()
116 end = start + tbu->sid_range[1]; in qcom_find_tbu()
118 if (qsmmu->smmu.dev->of_node == tbu->smmu_np && in qcom_find_tbu()
120 return tbu; in qcom_find_tbu()
127 static int qcom_tbu_halt(struct qcom_tbu *tbu, struct arm_smmu_domain *smmu_domain) in qcom_tbu_halt() argument
133 guard(spinlock_irqsave)(&tbu->halt_lock); in qcom_tbu_halt()
134 if (tbu->halt_count) { in qcom_tbu_halt()
135 tbu->halt_count++; in qcom_tbu_halt()
139 val = readl_relaxed(tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_halt()
141 writel_relaxed(val, tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_halt()
161 if (readl_poll_timeout_atomic(tbu->base + DEBUG_SR_HALT_ACK_REG, status, in qcom_tbu_halt()
164 dev_err(tbu->dev, "Timeout while trying to halt TBU!\n"); in qcom_tbu_halt()
167 val = readl_relaxed(tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_halt()
169 writel_relaxed(val, tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_halt()
174 tbu->halt_count = 1; in qcom_tbu_halt()
179 static void qcom_tbu_resume(struct qcom_tbu *tbu) in qcom_tbu_resume() argument
183 guard(spinlock_irqsave)(&tbu->halt_lock); in qcom_tbu_resume()
184 if (!tbu->halt_count) { in qcom_tbu_resume()
185 WARN(1, "%s: halt_count is 0", dev_name(tbu->dev)); in qcom_tbu_resume()
189 if (tbu->halt_count > 1) { in qcom_tbu_resume()
190 tbu->halt_count--; in qcom_tbu_resume()
194 val = readl_relaxed(tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_resume()
196 writel_relaxed(val, tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_resume()
198 tbu->halt_count = 0; in qcom_tbu_resume()
202 struct qcom_tbu *tbu, dma_addr_t iova, u32 sid) in qcom_tbu_trigger_atos() argument
210 val = readq_relaxed(tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_trigger_atos()
213 writeq_relaxed(val, tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_trigger_atos()
214 writeq_relaxed(iova, tbu->base + DEBUG_VA_ADDR_REG); in qcom_tbu_trigger_atos()
216 writeq_relaxed(val, tbu->base + DEBUG_AXUSER_REG); in qcom_tbu_trigger_atos()
228 writeq_relaxed(val, tbu->base + DEBUG_TXN_TRIGG_REG); in qcom_tbu_trigger_atos()
232 val = readl_relaxed(tbu->base + DEBUG_SR_HALT_ACK_REG); in qcom_tbu_trigger_atos()
235 val = readl_relaxed(tbu->base + DEBUG_PAR_REG); in qcom_tbu_trigger_atos()
244 val = readq_relaxed(tbu->base + DEBUG_PAR_REG); in qcom_tbu_trigger_atos()
246 dev_err(tbu->dev, "ATOS generated a fault interrupt! PAR = %llx, SID=0x%x\n", in qcom_tbu_trigger_atos()
249 dev_err_ratelimited(tbu->dev, "ATOS translation timed out!\n"); in qcom_tbu_trigger_atos()
254 writeq_relaxed(0, tbu->base + DEBUG_TXN_TRIGG_REG); in qcom_tbu_trigger_atos()
255 writeq_relaxed(0, tbu->base + DEBUG_VA_ADDR_REG); in qcom_tbu_trigger_atos()
256 val = readl_relaxed(tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_trigger_atos()
258 writel_relaxed(val, tbu->base + DEBUG_SID_HALT_REG); in qcom_tbu_trigger_atos()
269 struct qcom_tbu *tbu; in qcom_iova_to_phys() local
276 tbu = qcom_find_tbu(qsmmu, sid); in qcom_iova_to_phys()
277 if (!tbu) in qcom_iova_to_phys()
280 ret = icc_set_bw(tbu->path, 0, UINT_MAX); in qcom_iova_to_phys()
284 ret = clk_prepare_enable(tbu->clk); in qcom_iova_to_phys()
288 ret = qcom_tbu_halt(tbu, smmu_domain); in qcom_iova_to_phys()
320 phys = qcom_tbu_trigger_atos(smmu_domain, tbu, iova, sid); in qcom_iova_to_phys()
335 qcom_tbu_resume(tbu); in qcom_iova_to_phys()
338 readl_relaxed(tbu->base + DEBUG_SR_HALT_ACK_REG); in qcom_iova_to_phys()
341 clk_disable_unprepare(tbu->clk); in qcom_iova_to_phys()
343 icc_set_bw(tbu->path, 0, 0); in qcom_iova_to_phys()
472 struct qcom_tbu *tbu; in qcom_tbu_probe() local
474 tbu = devm_kzalloc(dev, sizeof(*tbu), GFP_KERNEL); in qcom_tbu_probe()
475 if (!tbu) in qcom_tbu_probe()
478 tbu->dev = dev; in qcom_tbu_probe()
479 INIT_LIST_HEAD(&tbu->list); in qcom_tbu_probe()
480 spin_lock_init(&tbu->halt_lock); in qcom_tbu_probe()
487 tbu->smmu_np = args.np; in qcom_tbu_probe()
488 tbu->sid_range[0] = args.args[0]; in qcom_tbu_probe()
489 tbu->sid_range[1] = args.args[1]; in qcom_tbu_probe()
492 tbu->base = devm_of_iomap(dev, np, 0, NULL); in qcom_tbu_probe()
493 if (IS_ERR(tbu->base)) in qcom_tbu_probe()
494 return PTR_ERR(tbu->base); in qcom_tbu_probe()
496 tbu->clk = devm_clk_get_optional(dev, NULL); in qcom_tbu_probe()
497 if (IS_ERR(tbu->clk)) in qcom_tbu_probe()
498 return PTR_ERR(tbu->clk); in qcom_tbu_probe()
500 tbu->path = devm_of_icc_get(dev, NULL); in qcom_tbu_probe()
501 if (IS_ERR(tbu->path)) in qcom_tbu_probe()
502 return PTR_ERR(tbu->path); in qcom_tbu_probe()
505 list_add_tail(&tbu->list, &tbu_list); in qcom_tbu_probe()