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-21 10:44:22 -0400
commit2f2db618fe4dd8f37539e527480c88f6dd093e78 (patch)
treeb19130e7f5dc8ac5fe3c3ceba36ef0497fb34c62
parentb652c443c4b2100d3ff6e87baed5869744af3a92 (diff)
downloadlinux-keystone-2f2db618fe4dd8f37539e527480c88f6dd093e78.tar.gz
ARM: keystone: add support for coherent dmaHEADmaster
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);
}