[POWERPC] Add DMA ops support for of_platform_device to Cell
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Sat, 11 Nov 2006 06:25:04 +0000 (17:25 +1100)
committerPaul Mackerras <paulus@samba.org>
Mon, 4 Dec 2006 09:38:42 +0000 (20:38 +1100)
This patch adds a bus device notifier to the of_platform bus type on
cell to setup the DMA operations for of_platform_devices. We currently
use the PCI operations as Cell use a special version of them that
happens to be suitable for our needs.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/platforms/cell/setup.c

index d704bc19a646905ddf39a921e19903a3d7d60569..b39753f16d482db58899e8ace9eb8ff41c2a78f1 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/console.h>
 #include <linux/mutex.h>
 #include <linux/memory_hotplug.h>
+#include <linux/notifier.h>
 
 #include <asm/mmu.h>
 #include <asm/processor.h>
@@ -82,10 +83,41 @@ static void cell_progress(char *s, unsigned short hex)
        printk("*** %04x : %s\n", hex, s ? s : "");
 }
 
+static int cell_of_bus_notify(struct notifier_block *nb, unsigned long action,
+                             void *data)
+{
+       struct device *dev = data;
+
+       if (action != BUS_NOTIFY_ADD_DEVICE)
+               return 0;
+
+       /* For now, we just use the PCI DMA ops for everything, though
+        * we'll need something better when we have a real iommu
+        * implementation.
+        */
+       dev->archdata.dma_ops = pci_dma_ops;
+
+       return 0;
+}
+
+static struct notifier_block cell_of_bus_notifier = {
+       .notifier_call = cell_of_bus_notify
+};
+
+
 static int __init cell_publish_devices(void)
 {
-       if (machine_is(cell))
-               of_platform_bus_probe(NULL, NULL, NULL);
+       if (!machine_is(cell))
+               return 0;
+
+       /* Register callbacks on OF platform device addition/removal
+        * to handle linking them to the right DMA operations
+        */
+       bus_register_notifier(&of_platform_bus_type, &cell_of_bus_notifier);
+
+       /* Publish OF platform devices for southbridge IOs */
+       of_platform_bus_probe(NULL, NULL, NULL);
+
        return 0;
 }
 device_initcall(cell_publish_devices);
@@ -154,7 +186,6 @@ static void __init cell_setup_arch(void)
 #ifdef CONFIG_SMP
        smp_init_cell();
 #endif
-
        /* init to some ~sane value until calibrate_delay() runs */
        loops_per_jiffy = 50000000;