• Home
  • Raw
  • Download

Lines Matching +full:tegra20 +full:- +full:ahb

1 // SPDX-License-Identifier: GPL-2.0-only
3 * IOMMU API for Graphics Address Relocation Table on Tegra20
5 * Copyright (c) 2010-2012, NVIDIA CORPORATION. All rights reserved.
23 #define GART_CONFIG (0x24 - GART_REG_BASE)
24 #define GART_ENTRY_ADDR (0x28 - GART_REG_BASE)
25 #define GART_ENTRY_DATA (0x2c - GART_REG_BASE)
54 * Any interaction between any block on PPSB and a block on APB or AHB
55 * must have these read-back to ensure the APB/AHB bus transaction is
58 #define FLUSH_GART_REGS(gart) readl_relaxed((gart)->regs + GART_CONFIG)
61 for (iova = gart->iovmm_base; \
62 iova < gart->iovmm_end; \
68 writel_relaxed(iova, gart->regs + GART_ENTRY_ADDR); in gart_set_pte()
69 writel_relaxed(pte, gart->regs + GART_ENTRY_DATA); in gart_set_pte()
77 writel_relaxed(iova, gart->regs + GART_ENTRY_ADDR); in gart_read_pte()
78 pte = readl_relaxed(gart->regs + GART_ENTRY_DATA); in gart_read_pte()
90 writel_relaxed(1, gart->regs + GART_CONFIG); in do_gart_setup()
97 return unlikely(iova < gart->iovmm_base || bytes != GART_PAGE_SIZE || in gart_iova_range_invalid()
98 iova + bytes > gart->iovmm_end); in gart_iova_range_invalid()
112 spin_lock(&gart->dom_lock); in gart_iommu_attach_dev()
114 if (gart->active_domain && gart->active_domain != domain) { in gart_iommu_attach_dev()
115 ret = -EBUSY; in gart_iommu_attach_dev()
118 gart->active_domain = domain; in gart_iommu_attach_dev()
119 gart->active_devices++; in gart_iommu_attach_dev()
122 spin_unlock(&gart->dom_lock); in gart_iommu_attach_dev()
132 spin_lock(&gart->dom_lock); in gart_iommu_detach_dev()
137 if (--gart->active_devices == 0) in gart_iommu_detach_dev()
138 gart->active_domain = NULL; in gart_iommu_detach_dev()
141 spin_unlock(&gart->dom_lock); in gart_iommu_detach_dev()
153 domain->geometry.aperture_start = gart_handle->iovmm_base; in gart_iommu_domain_alloc()
154 domain->geometry.aperture_end = gart_handle->iovmm_end - 1; in gart_iommu_domain_alloc()
155 domain->geometry.force_aperture = true; in gart_iommu_domain_alloc()
163 WARN_ON(gart_handle->active_domain == domain); in gart_iommu_domain_free()
171 dev_err(gart->dev, "Page entry is in-use\n"); in __gart_iommu_map()
172 return -EINVAL; in __gart_iommu_map()
187 return -EINVAL; in gart_iommu_map()
189 spin_lock(&gart->pte_lock); in gart_iommu_map()
191 spin_unlock(&gart->pte_lock); in gart_iommu_map()
200 dev_err(gart->dev, "Page entry is invalid\n"); in __gart_iommu_unmap()
201 return -EINVAL; in __gart_iommu_unmap()
218 spin_lock(&gart->pte_lock); in gart_iommu_unmap()
220 spin_unlock(&gart->pte_lock); in gart_iommu_unmap()
232 return -EINVAL; in gart_iommu_iova_to_phys()
234 spin_lock(&gart->pte_lock); in gart_iommu_iova_to_phys()
236 spin_unlock(&gart->pte_lock); in gart_iommu_iova_to_phys()
249 return ERR_PTR(-ENODEV); in gart_iommu_probe_device()
251 return &gart_handle->iommu; in gart_iommu_probe_device()
295 u32 *data = gart->savedata; in tegra_gart_suspend()
303 writel_relaxed(0, gart->regs + GART_CONFIG); in tegra_gart_suspend()
314 do_gart_setup(gart, gart->savedata); in tegra_gart_resume()
331 return ERR_PTR(-ENXIO); in tegra_gart_probe()
336 return ERR_PTR(-ENOMEM); in tegra_gart_probe()
340 gart->dev = dev; in tegra_gart_probe()
341 gart->regs = mc->regs + GART_REG_BASE; in tegra_gart_probe()
342 gart->iovmm_base = res->start; in tegra_gart_probe()
343 gart->iovmm_end = res->end + 1; in tegra_gart_probe()
344 spin_lock_init(&gart->pte_lock); in tegra_gart_probe()
345 spin_lock_init(&gart->dom_lock); in tegra_gart_probe()
349 err = iommu_device_sysfs_add(&gart->iommu, dev, NULL, "gart"); in tegra_gart_probe()
353 iommu_device_set_ops(&gart->iommu, &gart_iommu_ops); in tegra_gart_probe()
354 iommu_device_set_fwnode(&gart->iommu, dev->fwnode); in tegra_gart_probe()
356 err = iommu_device_register(&gart->iommu); in tegra_gart_probe()
360 gart->savedata = vmalloc(resource_size(res) / GART_PAGE_SIZE * in tegra_gart_probe()
362 if (!gart->savedata) { in tegra_gart_probe()
363 err = -ENOMEM; in tegra_gart_probe()
370 iommu_device_unregister(&gart->iommu); in tegra_gart_probe()
372 iommu_device_sysfs_remove(&gart->iommu); in tegra_gart_probe()