aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of/platform.c')
-rw-r--r--drivers/of/platform.c31
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/**