diff options
Diffstat (limited to 'drivers/of/platform.c')
-rw-r--r-- | drivers/of/platform.c | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 667c6f13f12b..a01f57c9e34e 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
@@ -19,7 +19,6 @@ | |||
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> | ||
23 | #include <linux/of_irq.h> | 22 | #include <linux/of_irq.h> |
24 | #include <linux/of_platform.h> | 23 | #include <linux/of_platform.h> |
25 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
@@ -150,59 +149,6 @@ struct platform_device *of_device_alloc(struct device_node *np, | |||
150 | } | 149 | } |
151 | EXPORT_SYMBOL(of_device_alloc); | 150 | EXPORT_SYMBOL(of_device_alloc); |
152 | 151 | ||
153 | /** | ||
154 | * of_dma_configure - Setup DMA configuration | ||
155 | * @dev: Device to apply DMA configuration | ||
156 | * | ||
157 | * Try to get devices's DMA configuration from DT and update it | ||
158 | * accordingly. | ||
159 | * | ||
160 | * In case if platform code need to use own special DMA configuration,it | ||
161 | * can use Platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE event | ||
162 | * to fix up DMA configuration. | ||
163 | */ | ||
164 | static void of_dma_configure(struct device *dev) | ||
165 | { | ||
166 | u64 dma_addr, paddr, size; | ||
167 | int ret; | ||
168 | bool coherent; | ||
169 | unsigned long offset; | ||
170 | struct iommu_ops *iommu; | ||
171 | |||
172 | /* | ||
173 | * Set default dma-mask to 32 bit. Drivers are expected to setup | ||
174 | * the correct supported dma_mask. | ||
175 | */ | ||
176 | dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
177 | |||
178 | /* | ||
179 | * Set it to coherent_dma_mask by default if the architecture | ||
180 | * code has not set it. | ||
181 | */ | ||
182 | if (!dev->dma_mask) | ||
183 | dev->dma_mask = &dev->coherent_dma_mask; | ||
184 | |||
185 | ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size); | ||
186 | if (ret < 0) { | ||
187 | dma_addr = offset = 0; | ||
188 | size = dev->coherent_dma_mask; | ||
189 | } else { | ||
190 | offset = PFN_DOWN(paddr - dma_addr); | ||
191 | dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset); | ||
192 | } | ||
193 | dev->dma_pfn_offset = offset; | ||
194 | |||
195 | coherent = of_dma_is_coherent(dev->of_node); | ||
196 | dev_dbg(dev, "device is%sdma coherent\n", | ||
197 | coherent ? " " : " not "); | ||
198 | |||
199 | iommu = of_iommu_configure(dev, dev->of_node); | ||
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) | 152 | static void of_dma_deconfigure(struct device *dev) |
207 | { | 153 | { |
208 | arch_teardown_dma_ops(dev); | 154 | arch_teardown_dma_ops(dev); |
@@ -236,7 +182,7 @@ static struct platform_device *of_platform_device_create_pdata( | |||
236 | 182 | ||
237 | dev->dev.bus = &platform_bus_type; | 183 | dev->dev.bus = &platform_bus_type; |
238 | dev->dev.platform_data = platform_data; | 184 | dev->dev.platform_data = platform_data; |
239 | of_dma_configure(&dev->dev); | 185 | of_dma_configure(&dev->dev, dev->dev.of_node); |
240 | 186 | ||
241 | if (of_device_add(dev) != 0) { | 187 | if (of_device_add(dev) != 0) { |
242 | of_dma_deconfigure(&dev->dev); | 188 | of_dma_deconfigure(&dev->dev); |
@@ -299,7 +245,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node, | |||
299 | dev_set_name(&dev->dev, "%s", bus_id); | 245 | dev_set_name(&dev->dev, "%s", bus_id); |
300 | else | 246 | else |
301 | of_device_make_bus_id(&dev->dev); | 247 | of_device_make_bus_id(&dev->dev); |
302 | of_dma_configure(&dev->dev); | 248 | of_dma_configure(&dev->dev, dev->dev.of_node); |
303 | 249 | ||
304 | /* Allow the HW Peripheral ID to be overridden */ | 250 | /* Allow the HW Peripheral ID to be overridden */ |
305 | prop = of_get_property(node, "arm,primecell-periphid", NULL); | 251 | prop = of_get_property(node, "arm,primecell-periphid", NULL); |