diff options
-rw-r--r-- | arch/arm/include/asm/dma-mapping.h | 4 | ||||
-rw-r--r-- | drivers/of/platform.c | 21 | ||||
-rw-r--r-- | include/linux/dma-mapping.h | 8 |
3 files changed, 24 insertions, 9 deletions
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index dc3420e77758..f3c0d953f6a2 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h | |||
@@ -121,7 +121,9 @@ static inline unsigned long dma_max_pfn(struct device *dev) | |||
121 | } | 121 | } |
122 | #define dma_max_pfn(dev) dma_max_pfn(dev) | 122 | #define dma_max_pfn(dev) dma_max_pfn(dev) |
123 | 123 | ||
124 | static inline void arch_setup_dma_ops(struct device *dev, bool coherent) | 124 | static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, |
125 | u64 size, struct iommu_ops *iommu, | ||
126 | bool coherent) | ||
125 | { | 127 | { |
126 | if (coherent) | 128 | if (coherent) |
127 | set_dma_ops(dev, &arm_coherent_dma_ops); | 129 | set_dma_ops(dev, &arm_coherent_dma_ops); |
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index ff1f4e9afccb..b89caf8c7586 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/of_address.h> | 20 | #include <linux/of_address.h> |
21 | #include <linux/of_device.h> | 21 | #include <linux/of_device.h> |
22 | #include <linux/of_iommu.h> | ||
22 | #include <linux/of_irq.h> | 23 | #include <linux/of_irq.h> |
23 | #include <linux/of_platform.h> | 24 | #include <linux/of_platform.h> |
24 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
@@ -166,6 +167,7 @@ static void of_dma_configure(struct device *dev) | |||
166 | int ret; | 167 | int ret; |
167 | bool coherent; | 168 | bool coherent; |
168 | unsigned long offset; | 169 | unsigned long offset; |
170 | struct iommu_ops *iommu; | ||
169 | 171 | ||
170 | /* | 172 | /* |
171 | * Set default dma-mask to 32 bit. Drivers are expected to setup | 173 | * Set default dma-mask to 32 bit. Drivers are expected to setup |
@@ -194,7 +196,16 @@ static void of_dma_configure(struct device *dev) | |||
194 | dev_dbg(dev, "device is%sdma coherent\n", | 196 | dev_dbg(dev, "device is%sdma coherent\n", |
195 | coherent ? " " : " not "); | 197 | coherent ? " " : " not "); |
196 | 198 | ||
197 | arch_setup_dma_ops(dev, coherent); | 199 | iommu = of_iommu_configure(dev); |
200 | dev_dbg(dev, "device is%sbehind an iommu\n", | ||
201 | iommu ? " " : " not "); | ||
202 | |||
203 | arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent); | ||
204 | } | ||
205 | |||
206 | static void of_dma_deconfigure(struct device *dev) | ||
207 | { | ||
208 | arch_teardown_dma_ops(dev); | ||
198 | } | 209 | } |
199 | 210 | ||
200 | /** | 211 | /** |
@@ -223,16 +234,12 @@ static struct platform_device *of_platform_device_create_pdata( | |||
223 | if (!dev) | 234 | if (!dev) |
224 | goto err_clear_flag; | 235 | goto err_clear_flag; |
225 | 236 | ||
226 | of_dma_configure(&dev->dev); | ||
227 | dev->dev.bus = &platform_bus_type; | 237 | dev->dev.bus = &platform_bus_type; |
228 | dev->dev.platform_data = platform_data; | 238 | dev->dev.platform_data = platform_data; |
229 | 239 | of_dma_configure(&dev->dev); | |
230 | /* We do not fill the DMA ops for platform devices by default. | ||
231 | * This is currently the responsibility of the platform code | ||
232 | * to do such, possibly using a device notifier | ||
233 | */ | ||
234 | 240 | ||
235 | if (of_device_add(dev) != 0) { | 241 | if (of_device_add(dev) != 0) { |
242 | of_dma_deconfigure(&dev->dev); | ||
236 | platform_device_put(dev); | 243 | platform_device_put(dev); |
237 | goto err_clear_flag; | 244 | goto err_clear_flag; |
238 | } | 245 | } |
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 8a1560f95d4a..c3007cb4bfa6 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
@@ -130,7 +130,13 @@ static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask) | |||
130 | extern u64 dma_get_required_mask(struct device *dev); | 130 | extern u64 dma_get_required_mask(struct device *dev); |
131 | 131 | ||
132 | #ifndef arch_setup_dma_ops | 132 | #ifndef arch_setup_dma_ops |
133 | static inline void arch_setup_dma_ops(struct device *dev, bool coherent) { } | 133 | static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, |
134 | u64 size, struct iommu_ops *iommu, | ||
135 | bool coherent) { } | ||
136 | #endif | ||
137 | |||
138 | #ifndef arch_teardown_dma_ops | ||
139 | static inline void arch_teardown_dma_ops(struct device *dev) { } | ||
134 | #endif | 140 | #endif |
135 | 141 | ||
136 | static inline unsigned int dma_get_max_seg_size(struct device *dev) | 142 | static inline unsigned int dma_get_max_seg_size(struct device *dev) |