Lines Matching refs:dom

85 static struct sprd_iommu_domain *to_sprd_domain(struct iommu_domain *dom)  in to_sprd_domain()  argument
87 return container_of(dom, struct sprd_iommu_domain, domain); in to_sprd_domain()
137 struct sprd_iommu_domain *dom; in sprd_iommu_domain_alloc() local
142 dom = kzalloc(sizeof(*dom), GFP_KERNEL); in sprd_iommu_domain_alloc()
143 if (!dom) in sprd_iommu_domain_alloc()
146 spin_lock_init(&dom->pgtlock); in sprd_iommu_domain_alloc()
148 dom->domain.geometry.aperture_start = 0; in sprd_iommu_domain_alloc()
149 dom->domain.geometry.aperture_end = SZ_256M - 1; in sprd_iommu_domain_alloc()
151 return &dom->domain; in sprd_iommu_domain_alloc()
156 struct sprd_iommu_domain *dom = to_sprd_domain(domain); in sprd_iommu_domain_free() local
158 kfree(dom); in sprd_iommu_domain_free()
161 static void sprd_iommu_first_vpn(struct sprd_iommu_domain *dom) in sprd_iommu_first_vpn() argument
163 struct sprd_iommu_device *sdev = dom->sdev; in sprd_iommu_first_vpn()
172 val = dom->domain.geometry.aperture_start >> SPRD_IOMMU_PAGE_SHIFT; in sprd_iommu_first_vpn()
176 static void sprd_iommu_vpn_range(struct sprd_iommu_domain *dom) in sprd_iommu_vpn_range() argument
178 struct sprd_iommu_device *sdev = dom->sdev; in sprd_iommu_vpn_range()
187 val = (dom->domain.geometry.aperture_end - in sprd_iommu_vpn_range()
188 dom->domain.geometry.aperture_start) >> SPRD_IOMMU_PAGE_SHIFT; in sprd_iommu_vpn_range()
192 static void sprd_iommu_first_ppn(struct sprd_iommu_domain *dom) in sprd_iommu_first_ppn() argument
194 u32 val = dom->pgt_pa >> SPRD_IOMMU_PAGE_SHIFT; in sprd_iommu_first_ppn()
195 struct sprd_iommu_device *sdev = dom->sdev; in sprd_iommu_first_ppn()
237 struct sprd_iommu_domain *dom = to_sprd_domain(domain); in sprd_iommu_attach_device() local
240 if (dom->sdev) { in sprd_iommu_attach_device()
245 dom->pgt_va = dma_alloc_coherent(sdev->dev, pgt_size, &dom->pgt_pa, GFP_KERNEL); in sprd_iommu_attach_device()
246 if (!dom->pgt_va) in sprd_iommu_attach_device()
249 dom->sdev = sdev; in sprd_iommu_attach_device()
251 sprd_iommu_first_ppn(dom); in sprd_iommu_attach_device()
252 sprd_iommu_first_vpn(dom); in sprd_iommu_attach_device()
253 sprd_iommu_vpn_range(dom); in sprd_iommu_attach_device()
263 struct sprd_iommu_domain *dom = to_sprd_domain(domain); in sprd_iommu_detach_device() local
264 struct sprd_iommu_device *sdev = dom->sdev; in sprd_iommu_detach_device()
270 dma_free_coherent(sdev->dev, pgt_size, dom->pgt_va, dom->pgt_pa); in sprd_iommu_detach_device()
272 dom->sdev = NULL; in sprd_iommu_detach_device()
278 struct sprd_iommu_domain *dom = to_sprd_domain(domain); in sprd_iommu_map() local
287 if (!dom->sdev) { in sprd_iommu_map()
293 dev_err(dom->sdev->dev, "(iova(0x%lx) + size(%zx)) are not in the range!\n", in sprd_iommu_map()
298 pgt_base_iova = dom->pgt_va + ((iova - start) >> SPRD_IOMMU_PAGE_SHIFT); in sprd_iommu_map()
300 spin_lock_irqsave(&dom->pgtlock, flags); in sprd_iommu_map()
305 spin_unlock_irqrestore(&dom->pgtlock, flags); in sprd_iommu_map()
313 struct sprd_iommu_domain *dom = to_sprd_domain(domain); in sprd_iommu_unmap() local
323 pgt_base_iova = dom->pgt_va + ((iova - start) >> SPRD_IOMMU_PAGE_SHIFT); in sprd_iommu_unmap()
325 spin_lock_irqsave(&dom->pgtlock, flags); in sprd_iommu_unmap()
327 spin_unlock_irqrestore(&dom->pgtlock, flags); in sprd_iommu_unmap()
335 struct sprd_iommu_domain *dom = to_sprd_domain(domain); in sprd_iommu_sync_map() local
338 if (dom->sdev->ver == SPRD_IOMMU_EX) in sprd_iommu_sync_map()
344 sprd_iommu_write(dom->sdev, reg, 0xffffffff); in sprd_iommu_sync_map()
356 struct sprd_iommu_domain *dom = to_sprd_domain(domain); in sprd_iommu_iova_to_phys() local
365 spin_lock_irqsave(&dom->pgtlock, flags); in sprd_iommu_iova_to_phys()
366 pa = *(dom->pgt_va + ((iova - start) >> SPRD_IOMMU_PAGE_SHIFT)); in sprd_iommu_iova_to_phys()
368 spin_unlock_irqrestore(&dom->pgtlock, flags); in sprd_iommu_iova_to_phys()