diff options
author | Will Deacon <will.deacon@arm.com> | 2014-08-27 10:49:10 -0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2014-12-01 11:50:32 -0500 |
commit | a3a60f81ee6f8fa65a57fa186b395bcd1f1bb097 (patch) | |
tree | fb9f47c0b0f9065916242bfa76864d5b72825b8f /drivers/of | |
parent | 1cd076bf67793942ed921b766f7d461de2ebc0a2 (diff) |
dma-mapping: replace set_arch_dma_coherent_ops with arch_setup_dma_ops
set_arch_dma_coherent_ops is called from of_dma_configure in order to
swizzle the architectural dma-mapping functions over to a cache-coherent
implementation. This is currently implemented only for ARM.
In anticipation of re-using this mechanism for IOMMU-backed dma-mapping
ops too, this patch replaces the function with a broader
arch_setup_dma_ops callback which will be extended in future.
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/platform.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 3b64d0bf5bba..ff1f4e9afccb 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
@@ -164,6 +164,8 @@ static void of_dma_configure(struct device *dev) | |||
164 | { | 164 | { |
165 | u64 dma_addr, paddr, size; | 165 | u64 dma_addr, paddr, size; |
166 | int ret; | 166 | int ret; |
167 | bool coherent; | ||
168 | unsigned long offset; | ||
167 | 169 | ||
168 | /* | 170 | /* |
169 | * Set default dma-mask to 32 bit. Drivers are expected to setup | 171 | * Set default dma-mask to 32 bit. Drivers are expected to setup |
@@ -178,28 +180,21 @@ static void of_dma_configure(struct device *dev) | |||
178 | if (!dev->dma_mask) | 180 | if (!dev->dma_mask) |
179 | dev->dma_mask = &dev->coherent_dma_mask; | 181 | dev->dma_mask = &dev->coherent_dma_mask; |
180 | 182 | ||
181 | /* | ||
182 | * if dma-coherent property exist, call arch hook to setup | ||
183 | * dma coherent operations. | ||
184 | */ | ||
185 | if (of_dma_is_coherent(dev->of_node)) { | ||
186 | set_arch_dma_coherent_ops(dev); | ||
187 | dev_dbg(dev, "device is dma coherent\n"); | ||
188 | } | ||
189 | |||
190 | /* | ||
191 | * if dma-ranges property doesn't exist - just return else | ||
192 | * setup the dma offset | ||
193 | */ | ||
194 | ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size); | 183 | ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size); |
195 | if (ret < 0) { | 184 | if (ret < 0) { |
196 | dev_dbg(dev, "no dma range information to setup\n"); | 185 | dma_addr = offset = 0; |
197 | return; | 186 | size = dev->coherent_dma_mask; |
187 | } else { | ||
188 | offset = PFN_DOWN(paddr - dma_addr); | ||
189 | dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", dev->dma_pfn_offset); | ||
198 | } | 190 | } |
191 | dev->dma_pfn_offset = offset; | ||
192 | |||
193 | coherent = of_dma_is_coherent(dev->of_node); | ||
194 | dev_dbg(dev, "device is%sdma coherent\n", | ||
195 | coherent ? " " : " not "); | ||
199 | 196 | ||
200 | /* DMA ranges found. Calculate and set dma_pfn_offset */ | 197 | arch_setup_dma_ops(dev, coherent); |
201 | dev->dma_pfn_offset = PFN_DOWN(paddr - dma_addr); | ||
202 | dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", dev->dma_pfn_offset); | ||
203 | } | 198 | } |
204 | 199 | ||
205 | /** | 200 | /** |