]>
Commit | Line | Data |
---|---|---|
f2efa4ee | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
fad9119b | 2 | /* Copyright (C) 2013 - 2021 Intel Corporation */ |
f2efa4ee WY |
3 | |
4 | #ifndef IPU_MMU_H | |
5 | #define IPU_MMU_H | |
6 | ||
7 | #include <linux/dma-mapping.h> | |
8 | ||
9 | #include "ipu.h" | |
10 | #include "ipu-pdata.h" | |
11 | ||
12 | #define ISYS_MMID 1 | |
13 | #define PSYS_MMID 0 | |
14 | ||
15 | /* | |
16 | * @pgtbl: virtual address of the l1 page table (one page) | |
17 | */ | |
18 | struct ipu_mmu_info { | |
fad9119b WY |
19 | struct device *dev; |
20 | ||
21 | u32 __iomem *l1_pt; | |
22 | u32 l1_pt_dma; | |
23 | u32 **l2_pts; | |
24 | ||
25 | u32 *dummy_l2_pt; | |
26 | u32 dummy_l2_pteval; | |
27 | void *dummy_page; | |
28 | u32 dummy_page_pteval; | |
29 | ||
f2efa4ee WY |
30 | dma_addr_t aperture_start; |
31 | dma_addr_t aperture_end; | |
32 | unsigned long pgsize_bitmap; | |
33 | ||
34 | spinlock_t lock; /* Serialize access to users */ | |
35 | struct ipu_dma_mapping *dmap; | |
f2efa4ee WY |
36 | }; |
37 | ||
38 | /* | |
39 | * @pgtbl: physical address of the l1 page table | |
40 | */ | |
41 | struct ipu_mmu { | |
42 | struct list_head node; | |
43 | ||
44 | struct ipu_mmu_hw *mmu_hw; | |
45 | unsigned int nr_mmus; | |
46 | int mmid; | |
47 | ||
48 | phys_addr_t pgtbl; | |
49 | struct device *dev; | |
50 | ||
51 | struct ipu_dma_mapping *dmap; | |
52 | struct list_head vma_list; | |
53 | ||
54 | struct page *trash_page; | |
fad9119b WY |
55 | dma_addr_t pci_trash_page; /* IOVA from PCI DMA services (parent) */ |
56 | dma_addr_t iova_trash_page; /* IOVA for IPU child nodes to use */ | |
f2efa4ee WY |
57 | |
58 | bool ready; | |
59 | spinlock_t ready_lock; /* Serialize access to bool ready */ | |
60 | ||
61 | void (*tlb_invalidate)(struct ipu_mmu *mmu); | |
62 | }; | |
63 | ||
64 | struct ipu_mmu *ipu_mmu_init(struct device *dev, | |
65 | void __iomem *base, int mmid, | |
66 | const struct ipu_hw_variants *hw); | |
67 | void ipu_mmu_cleanup(struct ipu_mmu *mmu); | |
68 | int ipu_mmu_hw_init(struct ipu_mmu *mmu); | |
69 | int ipu_mmu_hw_cleanup(struct ipu_mmu *mmu); | |
70 | int ipu_mmu_map(struct ipu_mmu_info *mmu_info, unsigned long iova, | |
71 | phys_addr_t paddr, size_t size); | |
72 | size_t ipu_mmu_unmap(struct ipu_mmu_info *mmu_info, unsigned long iova, | |
73 | size_t size); | |
74 | phys_addr_t ipu_mmu_iova_to_phys(struct ipu_mmu_info *mmu_info, | |
75 | dma_addr_t iova); | |
76 | #endif |