aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/setup-common.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2009-03-18 23:40:51 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-03-23 22:47:30 -0400
commitd746286c1fcb186ce16295c30d48db852ede6772 (patch)
treea851d7aa2b785004a4a1623bf6399f47ee80afdc /arch/powerpc/kernel/setup-common.c
parent32ac57668dccf6c4ad5522b61a86fe211886c180 (diff)
powerpc: setup default archdata for {of_}platform via bus_register_notifier
Since a number of powerpc chips are SoCs we end up having dma-able devices that are registered as platform or of_platform devices. We need to hook the archdata to setup proper dma_ops for these devices. Rather than having to add a bus_notify to each platform we add a default one at the highest priority (called first) to set the default dma_ops for of_platform and platform devices to dma_direct_ops. This allows platform code to override the ops by providing their own notifier call back. In the future to enable >4G DMA support on ppc32 we can hook swiotlb ops. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/setup-common.c')
-rw-r--r--arch/powerpc/kernel/setup-common.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 705fc4bf3800..9774f9fed96e 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -35,6 +35,8 @@
35#include <linux/debugfs.h> 35#include <linux/debugfs.h>
36#include <linux/percpu.h> 36#include <linux/percpu.h>
37#include <linux/lmb.h> 37#include <linux/lmb.h>
38#include <linux/of_platform.h>
39#include <linux/platform_device.h>
38#include <asm/io.h> 40#include <asm/io.h>
39#include <asm/prom.h> 41#include <asm/prom.h>
40#include <asm/processor.h> 42#include <asm/processor.h>
@@ -669,3 +671,37 @@ static int powerpc_debugfs_init(void)
669} 671}
670arch_initcall(powerpc_debugfs_init); 672arch_initcall(powerpc_debugfs_init);
671#endif 673#endif
674
675static int ppc_dflt_bus_notify(struct notifier_block *nb,
676 unsigned long action, void *data)
677{
678 struct device *dev = data;
679
680 /* We are only intereted in device addition */
681 if (action != BUS_NOTIFY_ADD_DEVICE)
682 return 0;
683
684 set_dma_ops(dev, &dma_direct_ops);
685
686 return NOTIFY_DONE;
687}
688
689static struct notifier_block ppc_dflt_plat_bus_notifier = {
690 .notifier_call = ppc_dflt_bus_notify,
691 .priority = INT_MAX,
692};
693
694static struct notifier_block ppc_dflt_of_bus_notifier = {
695 .notifier_call = ppc_dflt_bus_notify,
696 .priority = INT_MAX,
697};
698
699static int __init setup_bus_notifier(void)
700{
701 bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier);
702 bus_register_notifier(&of_platform_bus_type, &ppc_dflt_of_bus_notifier);
703
704 return 0;
705}
706
707arch_initcall(setup_bus_notifier);