aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/device.c
diff options
context:
space:
mode:
authorMurali Karicheri <m-karicheri2@ti.com>2015-03-03 15:44:57 -0500
committerBjorn Helgaas <bhelgaas@google.com>2015-03-12 12:43:09 -0400
commit9a6d7298b0833614c411f774c46514efb1bd5651 (patch)
tree3d05e9319e0fe78acb70dab565e497a86b68a60b /drivers/of/device.c
parent22b3c181c6c324a46f71aae806d8ddbe61d25761 (diff)
of: Calculate device DMA masks based on DT dma-range size
Calculate the dma_mask and coherent_dma_mask based on the dma-range values set in DT for the device. Limit the mask to lower of the default mask and mask calculated. Signed-off-by: Murali Karicheri <m-karicheri2@ti.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> CC: Joerg Roedel <joro@8bytes.org> CC: Grant Likely <grant.likely@linaro.org> CC: Rob Herring <robh+dt@kernel.org> CC: Will Deacon <will.deacon@arm.com> CC: Russell King <linux@arm.linux.org.uk> CC: Arnd Bergmann <arnd@arndb.de> CC: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Diffstat (limited to 'drivers/of/device.c')
-rw-r--r--drivers/of/device.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 28e743888402..20c1332a0018 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -90,10 +90,11 @@ void of_dma_configure(struct device *dev, struct device_node *np)
90 struct iommu_ops *iommu; 90 struct iommu_ops *iommu;
91 91
92 /* 92 /*
93 * Set default dma-mask to 32 bit. Drivers are expected to setup 93 * Set default coherent_dma_mask to 32 bit. Drivers are expected to
94 * the correct supported dma_mask. 94 * setup the correct supported mask.
95 */ 95 */
96 dev->coherent_dma_mask = DMA_BIT_MASK(32); 96 if (!dev->coherent_dma_mask)
97 dev->coherent_dma_mask = DMA_BIT_MASK(32);
97 98
98 /* 99 /*
99 * Set it to coherent_dma_mask by default if the architecture 100 * Set it to coherent_dma_mask by default if the architecture
@@ -128,6 +129,15 @@ void of_dma_configure(struct device *dev, struct device_node *np)
128 129
129 dev->dma_pfn_offset = offset; 130 dev->dma_pfn_offset = offset;
130 131
132 /*
133 * Limit coherent and dma mask based on size and default mask
134 * set by the driver.
135 */
136 dev->coherent_dma_mask = min(dev->coherent_dma_mask,
137 DMA_BIT_MASK(ilog2(dma_addr + size)));
138 *dev->dma_mask = min((*dev->dma_mask),
139 DMA_BIT_MASK(ilog2(dma_addr + size)));
140
131 coherent = of_dma_is_coherent(np); 141 coherent = of_dma_is_coherent(np);
132 dev_dbg(dev, "device is%sdma coherent\n", 142 dev_dbg(dev, "device is%sdma coherent\n",
133 coherent ? " " : " not "); 143 coherent ? " " : " not ");