From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: To: From: Benjamin Herrenschmidt Date: Mon, 06 Nov 2006 18:05:50 +1100 Subject: [PATCH 16/27] powerpc: Add DMA ops support for of_plaform_device to Cell In-Reply-To: <1162796738.274582.277491064706.qpush@grosgo> Message-Id: <20061106070706.65BC167D3C@ozlabs.org> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 arch/powerpc/platforms/cell/setup.c | 45 +++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) Index: linux-cell/arch/powerpc/platforms/cell/setup.c =================================================================== --- linux-cell.orig/arch/powerpc/platforms/cell/setup.c 2006-10-26 16:42:30.000000000 +1000 +++ linux-cell/arch/powerpc/platforms/cell/setup.c 2006-10-26 16:45:00.000000000 +1000 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -82,10 +83,49 @@ static void cell_progress(char *s, unsig 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; + struct device_ext *dext; + + if (action != BUS_NOTIFY_ADD_DEVICE) + return 0; + + dext = device_get_ext(dev); + if (dext == NULL) { + dev_printk(KERN_ERR, dev, + "OF platform device with extension !\n"); + 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. + */ + dext->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 + */ + register_bus_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 +194,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;