diff options
-rw-r--r-- | drivers/iommu/of_iommu.c | 17 | ||||
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 2 | ||||
-rw-r--r-- | include/linux/iommu.h | 2 | ||||
-rw-r--r-- | include/linux/of_iommu.h | 25 |
4 files changed, 46 insertions, 0 deletions
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index e550ccb7634e..89b903406968 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c | |||
@@ -22,6 +22,9 @@ | |||
22 | #include <linux/of.h> | 22 | #include <linux/of.h> |
23 | #include <linux/of_iommu.h> | 23 | #include <linux/of_iommu.h> |
24 | 24 | ||
25 | static const struct of_device_id __iommu_of_table_sentinel | ||
26 | __used __section(__iommu_of_table_end); | ||
27 | |||
25 | /** | 28 | /** |
26 | * of_get_dma_window - Parse *dma-window property and returns 0 if found. | 29 | * of_get_dma_window - Parse *dma-window property and returns 0 if found. |
27 | * | 30 | * |
@@ -89,3 +92,17 @@ int of_get_dma_window(struct device_node *dn, const char *prefix, int index, | |||
89 | return 0; | 92 | return 0; |
90 | } | 93 | } |
91 | EXPORT_SYMBOL_GPL(of_get_dma_window); | 94 | EXPORT_SYMBOL_GPL(of_get_dma_window); |
95 | |||
96 | void __init of_iommu_init(void) | ||
97 | { | ||
98 | struct device_node *np; | ||
99 | const struct of_device_id *match, *matches = &__iommu_of_table; | ||
100 | |||
101 | for_each_matching_node_and_match(np, matches, &match) { | ||
102 | const of_iommu_init_fn init_fn = match->data; | ||
103 | |||
104 | if (init_fn(np)) | ||
105 | pr_err("Failed to initialise IOMMU %s\n", | ||
106 | of_node_full_name(np)); | ||
107 | } | ||
108 | } | ||
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index aa70cbda327c..bee5d683074d 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -164,6 +164,7 @@ | |||
164 | #define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc) | 164 | #define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc) |
165 | #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) | 165 | #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) |
166 | #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) | 166 | #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) |
167 | #define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu) | ||
167 | #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) | 168 | #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) |
168 | #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) | 169 | #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) |
169 | #define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) | 170 | #define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) |
@@ -497,6 +498,7 @@ | |||
497 | CLK_OF_TABLES() \ | 498 | CLK_OF_TABLES() \ |
498 | RESERVEDMEM_OF_TABLES() \ | 499 | RESERVEDMEM_OF_TABLES() \ |
499 | CLKSRC_OF_TABLES() \ | 500 | CLKSRC_OF_TABLES() \ |
501 | IOMMU_OF_TABLES() \ | ||
500 | CPU_METHOD_OF_TABLES() \ | 502 | CPU_METHOD_OF_TABLES() \ |
501 | KERNEL_DTB() \ | 503 | KERNEL_DTB() \ |
502 | IRQCHIP_OF_MATCH_TABLE() \ | 504 | IRQCHIP_OF_MATCH_TABLE() \ |
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index e6a7c9ff72f2..7b83f9f8e11d 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h | |||
@@ -103,6 +103,7 @@ enum iommu_attr { | |||
103 | * @domain_get_attr: Query domain attributes | 103 | * @domain_get_attr: Query domain attributes |
104 | * @domain_set_attr: Change domain attributes | 104 | * @domain_set_attr: Change domain attributes |
105 | * @pgsize_bitmap: bitmap of supported page sizes | 105 | * @pgsize_bitmap: bitmap of supported page sizes |
106 | * @priv: per-instance data private to the iommu driver | ||
106 | */ | 107 | */ |
107 | struct iommu_ops { | 108 | struct iommu_ops { |
108 | bool (*capable)(enum iommu_cap); | 109 | bool (*capable)(enum iommu_cap); |
@@ -133,6 +134,7 @@ struct iommu_ops { | |||
133 | u32 (*domain_get_windows)(struct iommu_domain *domain); | 134 | u32 (*domain_get_windows)(struct iommu_domain *domain); |
134 | 135 | ||
135 | unsigned long pgsize_bitmap; | 136 | unsigned long pgsize_bitmap; |
137 | void *priv; | ||
136 | }; | 138 | }; |
137 | 139 | ||
138 | #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */ | 140 | #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */ |
diff --git a/include/linux/of_iommu.h b/include/linux/of_iommu.h index 51a560f34bca..5762cdc8effe 100644 --- a/include/linux/of_iommu.h +++ b/include/linux/of_iommu.h | |||
@@ -1,12 +1,17 @@ | |||
1 | #ifndef __OF_IOMMU_H | 1 | #ifndef __OF_IOMMU_H |
2 | #define __OF_IOMMU_H | 2 | #define __OF_IOMMU_H |
3 | 3 | ||
4 | #include <linux/iommu.h> | ||
5 | #include <linux/of.h> | ||
6 | |||
4 | #ifdef CONFIG_OF_IOMMU | 7 | #ifdef CONFIG_OF_IOMMU |
5 | 8 | ||
6 | extern int of_get_dma_window(struct device_node *dn, const char *prefix, | 9 | extern int of_get_dma_window(struct device_node *dn, const char *prefix, |
7 | int index, unsigned long *busno, dma_addr_t *addr, | 10 | int index, unsigned long *busno, dma_addr_t *addr, |
8 | size_t *size); | 11 | size_t *size); |
9 | 12 | ||
13 | extern void of_iommu_init(void); | ||
14 | |||
10 | #else | 15 | #else |
11 | 16 | ||
12 | static inline int of_get_dma_window(struct device_node *dn, const char *prefix, | 17 | static inline int of_get_dma_window(struct device_node *dn, const char *prefix, |
@@ -16,6 +21,26 @@ static inline int of_get_dma_window(struct device_node *dn, const char *prefix, | |||
16 | return -EINVAL; | 21 | return -EINVAL; |
17 | } | 22 | } |
18 | 23 | ||
24 | static inline void of_iommu_init(void) { } | ||
25 | |||
19 | #endif /* CONFIG_OF_IOMMU */ | 26 | #endif /* CONFIG_OF_IOMMU */ |
20 | 27 | ||
28 | static inline void of_iommu_set_ops(struct device_node *np, | ||
29 | const struct iommu_ops *ops) | ||
30 | { | ||
31 | np->data = (struct iommu_ops *)ops; | ||
32 | } | ||
33 | |||
34 | static inline struct iommu_ops *of_iommu_get_ops(struct device_node *np) | ||
35 | { | ||
36 | return np->data; | ||
37 | } | ||
38 | |||
39 | extern struct of_device_id __iommu_of_table; | ||
40 | |||
41 | typedef int (*of_iommu_init_fn)(struct device_node *); | ||
42 | |||
43 | #define IOMMU_OF_DECLARE(name, compat, fn) \ | ||
44 | _OF_DECLARE(iommu, name, compat, fn, of_iommu_init_fn) | ||
45 | |||
21 | #endif /* __OF_IOMMU_H */ | 46 | #endif /* __OF_IOMMU_H */ |