aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyril Chemparathy <cyril@ti.com>2012-09-20 14:13:51 -0400
committerCyril Chemparathy <cyril@ti.com>2012-09-20 14:13:51 -0400
commitf60e4d4c9ca669126b8413443f5302df3dddf840 (patch)
treee4d4fcd36344aa9a937871350b7fe499a97e6231
parentd6cc748e15b28ebe7c5f9266c653fd4109f923b9 (diff)
downloadlinux-keystone-rebuild/17-keystone-machine.tar.gz
ARM: keystone: add support for coherent dmarebuild/17-keystone-machine
This patch adds a bus notifier that walks up the device tree, looking for a "dma-coherent" property in the device's node, and its ancestors. If this property is found, the notifier callback applies coherent dma ops for the device.
-rw-r--r--arch/arm/mach-keystone/keystone.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c
index fac8faeb765f9c..22043467f9fc52 100644
--- a/arch/arm/mach-keystone/keystone.c
+++ b/arch/arm/mach-keystone/keystone.c
@@ -18,6 +18,7 @@
#include <linux/init.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
+#include <linux/dma-mapping.h>
#include <asm/setup.h>
#include <asm/mach/map.h>
@@ -63,9 +64,39 @@ static struct sys_timer keystone_timer = {
.init = keystone_timer_init,
};
+static bool is_coherent(struct device *dev)
+{
+ struct device_node *node = of_node_get(dev->of_node);
+
+ while (node) {
+ if (of_property_read_bool(node, "dma-coherent")) {
+ of_node_put(node);
+ return true;
+ }
+ node = of_get_next_parent(node);
+ }
+ return false;
+}
+
+static int keystone_platform_notifier(struct notifier_block *nb,
+ unsigned long event, void *dev)
+{
+ if (event != BUS_NOTIFY_ADD_DEVICE)
+ return NOTIFY_DONE;
+
+ if (is_coherent(dev))
+ set_dma_ops(dev, &arm_coherent_dma_ops);
+
+ return NOTIFY_OK;
+}
+
+static struct notifier_block keystone_platform_nb = {
+ .notifier_call = keystone_platform_notifier,
+};
static void __init keystone_init(void)
{
+ bus_register_notifier(&platform_bus_type, &keystone_platform_nb);
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
}