Lines Matching refs:cmdqv
133 struct tegra241_cmdqv *cmdqv; member
156 struct tegra241_cmdqv *cmdqv; member
193 static inline int tegra241_cmdqv_write_config(struct tegra241_cmdqv *cmdqv, in tegra241_cmdqv_write_config() argument
207 dev_err(cmdqv->dev, "%sfailed to %sable, STATUS=0x%08X\n", in tegra241_cmdqv_write_config()
214 static inline int cmdqv_write_config(struct tegra241_cmdqv *cmdqv, u32 regval) in cmdqv_write_config() argument
216 return tegra241_cmdqv_write_config(cmdqv, in cmdqv_write_config()
217 REG_CMDQV(cmdqv, CONFIG), in cmdqv_write_config()
218 REG_CMDQV(cmdqv, STATUS), in cmdqv_write_config()
227 return tegra241_cmdqv_write_config(vintf->cmdqv, in vintf_write_config()
248 return tegra241_cmdqv_write_config(vcmdq->cmdqv, in vcmdq_write_config()
268 __arm_smmu_cmdq_skip_err(&vintf->cmdqv->smmu, &vcmdq->cmdq); in tegra241_vintf0_handle_error()
277 struct tegra241_cmdqv *cmdqv = (struct tegra241_cmdqv *)devid; in tegra241_cmdqv_isr() local
278 void __iomem *reg_vintf_map = REG_CMDQV(cmdqv, VINTF_ERR_MAP); in tegra241_cmdqv_isr()
288 readl_relaxed(REG_CMDQV(cmdqv, CMDQ_ERR_MAP(3))), in tegra241_cmdqv_isr()
289 readl_relaxed(REG_CMDQV(cmdqv, CMDQ_ERR_MAP(2))), in tegra241_cmdqv_isr()
290 readl_relaxed(REG_CMDQV(cmdqv, CMDQ_ERR_MAP(1))), in tegra241_cmdqv_isr()
291 readl_relaxed(REG_CMDQV(cmdqv, CMDQ_ERR_MAP(0)))); in tegra241_cmdqv_isr()
293 dev_warn(cmdqv->dev, "unexpected error reported. %s\n", err_str); in tegra241_cmdqv_isr()
297 tegra241_vintf0_handle_error(cmdqv->vintfs[0]); in tegra241_cmdqv_isr()
322 struct tegra241_cmdqv *cmdqv = in tegra241_cmdqv_get_cmdq() local
324 struct tegra241_vintf *vintf = cmdqv->vintfs[0]; in tegra241_cmdqv_get_cmdq()
342 lidx = raw_smp_processor_id() % cmdqv->num_lvcmdqs_per_vintf; in tegra241_cmdqv_get_cmdq()
361 dev_err(vcmdq->cmdqv->dev, in tegra241_vcmdq_hw_deinit()
375 dev_warn(vcmdq->cmdqv->dev, in tegra241_vcmdq_hw_deinit()
380 dev_dbg(vcmdq->cmdqv->dev, "%sdeinited\n", h); in tegra241_vcmdq_hw_deinit()
396 dev_err(vcmdq->cmdqv->dev, in tegra241_vcmdq_hw_init()
404 dev_dbg(vcmdq->cmdqv->dev, "%sinited\n", h); in tegra241_vcmdq_hw_init()
412 for (lidx = 0; lidx < vintf->cmdqv->num_lvcmdqs_per_vintf; lidx++) in tegra241_vintf_hw_deinit()
445 for (lidx = 0; lidx < vintf->cmdqv->num_lvcmdqs_per_vintf; lidx++) { in tegra241_vintf_hw_init()
460 struct tegra241_cmdqv *cmdqv = in tegra241_cmdqv_hw_reset() local
467 regval = readl_relaxed(REG_CMDQV(cmdqv, CONFIG)); in tegra241_cmdqv_hw_reset()
468 ret = cmdqv_write_config(cmdqv, regval & ~CMDQV_EN); in tegra241_cmdqv_hw_reset()
471 ret = cmdqv_write_config(cmdqv, regval | CMDQV_EN); in tegra241_cmdqv_hw_reset()
476 for (idx = 0, qidx = 0; idx < cmdqv->num_vintfs; idx++) { in tegra241_cmdqv_hw_reset()
477 for (lidx = 0; lidx < cmdqv->num_lvcmdqs_per_vintf; lidx++) { in tegra241_cmdqv_hw_reset()
482 REG_CMDQV(cmdqv, CMDQ_ALLOC(qidx++))); in tegra241_cmdqv_hw_reset()
486 return tegra241_vintf_hw_init(cmdqv->vintfs[0], true); in tegra241_cmdqv_hw_reset()
499 dmam_free_coherent(vcmdq->cmdqv->smmu.dev, qsz, q->base, q->base_dma); in tegra241_vcmdq_free_smmu_cmdq()
504 struct arm_smmu_device *smmu = &vcmdq->cmdqv->smmu; in tegra241_vcmdq_alloc_smmu_cmdq()
542 struct tegra241_cmdqv *cmdqv = vintf->cmdqv; in tegra241_vintf_init_lvcmdq() local
545 vcmdq->idx = idx * cmdqv->num_lvcmdqs_per_vintf + lidx; in tegra241_vintf_init_lvcmdq()
547 vcmdq->cmdqv = cmdqv; in tegra241_vintf_init_lvcmdq()
549 vcmdq->page0 = cmdqv->base + TEGRA241_VINTFi_LVCMDQ_PAGE0(idx, lidx); in tegra241_vintf_init_lvcmdq()
550 vcmdq->page1 = cmdqv->base + TEGRA241_VINTFi_LVCMDQ_PAGE1(idx, lidx); in tegra241_vintf_init_lvcmdq()
564 dev_dbg(vintf->cmdqv->dev, in tegra241_vintf_free_lvcmdq()
572 struct tegra241_cmdqv *cmdqv = vintf->cmdqv; in tegra241_vintf_alloc_lvcmdq() local
590 dev_dbg(cmdqv->dev, in tegra241_vintf_alloc_lvcmdq()
603 static void tegra241_cmdqv_deinit_vintf(struct tegra241_cmdqv *cmdqv, u16 idx) in tegra241_cmdqv_deinit_vintf() argument
605 kfree(cmdqv->vintfs[idx]->lvcmdqs); in tegra241_cmdqv_deinit_vintf()
606 ida_free(&cmdqv->vintf_ids, idx); in tegra241_cmdqv_deinit_vintf()
607 cmdqv->vintfs[idx] = NULL; in tegra241_cmdqv_deinit_vintf()
610 static int tegra241_cmdqv_init_vintf(struct tegra241_cmdqv *cmdqv, u16 max_idx, in tegra241_cmdqv_init_vintf() argument
617 ret = ida_alloc_max(&cmdqv->vintf_ids, max_idx, GFP_KERNEL); in tegra241_cmdqv_init_vintf()
623 vintf->cmdqv = cmdqv; in tegra241_cmdqv_init_vintf()
624 vintf->base = cmdqv->base + TEGRA241_VINTF(idx); in tegra241_cmdqv_init_vintf()
626 vintf->lvcmdqs = kcalloc(cmdqv->num_lvcmdqs_per_vintf, in tegra241_cmdqv_init_vintf()
629 ida_free(&cmdqv->vintf_ids, idx); in tegra241_cmdqv_init_vintf()
633 cmdqv->vintfs[idx] = vintf; in tegra241_cmdqv_init_vintf()
645 static void tegra241_cmdqv_remove_vintf(struct tegra241_cmdqv *cmdqv, u16 idx) in tegra241_cmdqv_remove_vintf() argument
647 struct tegra241_vintf *vintf = cmdqv->vintfs[idx]; in tegra241_cmdqv_remove_vintf()
651 for (lidx = 0; lidx < vintf->cmdqv->num_lvcmdqs_per_vintf; lidx++) in tegra241_cmdqv_remove_vintf()
658 dev_dbg(cmdqv->dev, "VINTF%u: deallocated\n", vintf->idx); in tegra241_cmdqv_remove_vintf()
659 tegra241_cmdqv_deinit_vintf(cmdqv, idx); in tegra241_cmdqv_remove_vintf()
665 struct tegra241_cmdqv *cmdqv = in tegra241_cmdqv_remove() local
670 for (idx = 0; idx < cmdqv->num_vintfs; idx++) { in tegra241_cmdqv_remove()
671 if (cmdqv->vintfs[idx]) { in tegra241_cmdqv_remove()
674 tegra241_cmdqv_remove_vintf(cmdqv, idx); in tegra241_cmdqv_remove()
679 ida_destroy(&cmdqv->vintf_ids); in tegra241_cmdqv_remove()
681 if (cmdqv->irq > 0) in tegra241_cmdqv_remove()
682 free_irq(cmdqv->irq, cmdqv); in tegra241_cmdqv_remove()
683 iounmap(cmdqv->base); in tegra241_cmdqv_remove()
684 kfree(cmdqv->vintfs); in tegra241_cmdqv_remove()
685 put_device(cmdqv->dev); /* smmu->impl_dev */ in tegra241_cmdqv_remove()
761 struct tegra241_cmdqv *cmdqv = in tegra241_cmdqv_init_structures() local
772 ret = tegra241_cmdqv_init_vintf(cmdqv, 0, vintf); in tegra241_cmdqv_init_structures()
774 dev_err(cmdqv->dev, "failed to init vintf0: %d\n", ret); in tegra241_cmdqv_init_structures()
779 for (lidx = 0; lidx < cmdqv->num_lvcmdqs_per_vintf; lidx++) { in tegra241_cmdqv_init_structures()
794 tegra241_cmdqv_deinit_vintf(cmdqv, vintf->idx); in tegra241_cmdqv_init_structures()
816 struct tegra241_cmdqv *cmdqv = NULL; in __tegra241_cmdqv_probe() local
837 cmdqv = devm_krealloc(smmu->dev, smmu, sizeof(*cmdqv), GFP_KERNEL); in __tegra241_cmdqv_probe()
838 if (!cmdqv) in __tegra241_cmdqv_probe()
840 new_smmu = &cmdqv->smmu; in __tegra241_cmdqv_probe()
842 cmdqv->irq = irq; in __tegra241_cmdqv_probe()
843 cmdqv->base = base; in __tegra241_cmdqv_probe()
844 cmdqv->dev = smmu->impl_dev; in __tegra241_cmdqv_probe()
846 if (cmdqv->irq > 0) { in __tegra241_cmdqv_probe()
848 cmdqv); in __tegra241_cmdqv_probe()
850 dev_err(cmdqv->dev, "failed to request irq (%d): %d\n", in __tegra241_cmdqv_probe()
851 cmdqv->irq, ret); in __tegra241_cmdqv_probe()
856 regval = readl_relaxed(REG_CMDQV(cmdqv, PARAM)); in __tegra241_cmdqv_probe()
857 cmdqv->num_vintfs = 1 << FIELD_GET(CMDQV_NUM_VINTF_LOG2, regval); in __tegra241_cmdqv_probe()
858 cmdqv->num_vcmdqs = 1 << FIELD_GET(CMDQV_NUM_VCMDQ_LOG2, regval); in __tegra241_cmdqv_probe()
859 cmdqv->num_lvcmdqs_per_vintf = cmdqv->num_vcmdqs / cmdqv->num_vintfs; in __tegra241_cmdqv_probe()
861 cmdqv->vintfs = in __tegra241_cmdqv_probe()
862 kcalloc(cmdqv->num_vintfs, sizeof(*cmdqv->vintfs), GFP_KERNEL); in __tegra241_cmdqv_probe()
863 if (!cmdqv->vintfs) in __tegra241_cmdqv_probe()
866 ida_init(&cmdqv->vintf_ids); in __tegra241_cmdqv_probe()
883 if (cmdqv->irq > 0) in __tegra241_cmdqv_probe()
884 free_irq(cmdqv->irq, cmdqv); in __tegra241_cmdqv_probe()