diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2009-03-19 03:40:51 +0000 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-03-24 13:47:30 +1100 |
commit | d746286c1fcb186ce16295c30d48db852ede6772 (patch) | |
tree | a851d7aa2b785004a4a1623bf6399f47ee80afdc /arch/powerpc | |
parent | 32ac57668dccf6c4ad5522b61a86fe211886c180 (diff) | |
download | talos-obmc-linux-d746286c1fcb186ce16295c30d48db852ede6772.tar.gz talos-obmc-linux-d746286c1fcb186ce16295c30d48db852ede6772.zip |
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')
-rw-r--r-- | arch/powerpc/kernel/setup-common.c | 36 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/qpace_setup.c | 13 |
2 files changed, 36 insertions, 13 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 @@ #include <linux/debugfs.h> #include <linux/percpu.h> #include <linux/lmb.h> +#include <linux/of_platform.h> +#include <linux/platform_device.h> #include <asm/io.h> #include <asm/prom.h> #include <asm/processor.h> @@ -669,3 +671,37 @@ static int powerpc_debugfs_init(void) } arch_initcall(powerpc_debugfs_init); #endif + +static int ppc_dflt_bus_notify(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct device *dev = data; + + /* We are only intereted in device addition */ + if (action != BUS_NOTIFY_ADD_DEVICE) + return 0; + + set_dma_ops(dev, &dma_direct_ops); + + return NOTIFY_DONE; +} + +static struct notifier_block ppc_dflt_plat_bus_notifier = { + .notifier_call = ppc_dflt_bus_notify, + .priority = INT_MAX, +}; + +static struct notifier_block ppc_dflt_of_bus_notifier = { + .notifier_call = ppc_dflt_bus_notify, + .priority = INT_MAX, +}; + +static int __init setup_bus_notifier(void) +{ + bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier); + bus_register_notifier(&of_platform_bus_type, &ppc_dflt_of_bus_notifier); + + return 0; +} + +arch_initcall(setup_bus_notifier); diff --git a/arch/powerpc/platforms/cell/qpace_setup.c b/arch/powerpc/platforms/cell/qpace_setup.c index c75b66278fa2..c5ce02e84c8e 100644 --- a/arch/powerpc/platforms/cell/qpace_setup.c +++ b/arch/powerpc/platforms/cell/qpace_setup.c @@ -81,16 +81,6 @@ static int __init qpace_publish_devices(void) } machine_subsys_initcall(qpace, qpace_publish_devices); -extern int qpace_notify(struct device *dev) -{ - /* set dma_ops for of_platform bus */ - if (dev->bus && dev->bus->name - && !strcmp(dev->bus->name, "of_platform")) - set_dma_ops(dev, &dma_direct_ops); - - return 0; -} - static void __init qpace_setup_arch(void) { #ifdef CONFIG_SPU_BASE @@ -115,9 +105,6 @@ static void __init qpace_setup_arch(void) #ifdef CONFIG_DUMMY_CONSOLE conswitchp = &dummy_con; #endif - - /* set notifier function */ - platform_notify = &qpace_notify; } static int __init qpace_probe(void) |