Subject: powerpc: axon: DCR support Base Axon south bridge support. Adds probing for of_device's based on the /axon device subtree. Signed-off-by: Shaun Wetzstein Signed-off-by: Arnd Bergmann Index: linux-2.6/arch/powerpc/platforms/cell/Makefile =================================================================== --- linux-2.6.orig/arch/powerpc/platforms/cell/Makefile +++ linux-2.6/arch/powerpc/platforms/cell/Makefile @@ -1,6 +1,6 @@ obj-$(CONFIG_PPC_CELL_NATIVE) += interrupt.o iommu.o setup.o \ cbe_regs.o spider-pic.o pervasive.o \ - pmu.o + pmu.o axon.o obj-$(CONFIG_CBE_RAS) += ras.o obj-$(CONFIG_CBE_THERM) += cbe_thermal.o Index: linux-2.6/arch/powerpc/platforms/cell/axon.c =================================================================== --- /dev/null +++ linux-2.6/arch/powerpc/platforms/cell/axon.c @@ -0,0 +1,112 @@ +/* + * AXON base support + * + * Copyright (C) 2006 Shaun Wetzstein (shaun@vnet.ibm.com) + * IBM, Corp. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include + +static int axon_create_device_name(int axon_nr, + struct device_node *node, + char *name) +{ + const u32 * reg; + u64 addr; + + reg = get_property(node, "dcr-reg", NULL); + if (reg) { + addr = of_translate_dcr_address(node, reg); + if (addr != OF_BAD_ADDR) + goto found_dcr; + } + + reg = get_property(node, "reg", NULL); + if (reg) { + addr = of_translate_address(node, reg); + if (addr != OF_BAD_ADDR) + goto found; + } + + return 1; + +found_dcr: + sprintf(name, "D%lx.%s", addr, node->name); + return 0; + +found: + sprintf(name, "%lx.%s", addr, node->name); + return 0; +} + +static int __init axon_probe_of_nodes(int axon_nr, + struct device_node *parent, + struct device *dev) +{ + struct of_device * parent_dev, * child_dev; + struct device_node * child; + char name[BUS_ID_SIZE]; + + int rc = 0; + + if (axon_create_device_name(axon_nr, parent, name)) + sprintf(name, "%d.%s", axon_nr, parent->name); + parent_dev = of_platform_device_create(parent, name, dev); + + for (child = NULL; (child = of_get_next_child(parent, child));) { + if ((strcmp(child->type, "plb5") == 0) || + (strcmp(child->type, "plb4") == 0) || + (strcmp(child->type, "opb") == 0) || + (strcmp(child->type, "ebc") == 0)) + { + rc = axon_probe_of_nodes(axon_nr, child, + &parent_dev->dev); + } else { + if (axon_create_device_name(axon_nr, child, name)) { + printk(KERN_WARNING + "%s: Invalid node properties!\n", + child->full_name); + continue; + } + + child_dev = of_platform_device_create(child, + name, + &parent_dev->dev); + child->data = (void *)child_dev; + } + } + + return rc; +} + +static int __init axon_declare_of_platform_devices(void) +{ + struct device_node * node; + int axon_nr; + + for (axon_nr = 0, node = NULL; + (node = of_find_node_by_name(node, "axon")); + axon_nr++) + { + axon_probe_of_nodes(axon_nr, node, NULL); + } + + return 0; +} +postcore_initcall(axon_declare_of_platform_devices); Index: linux-2.6/arch/powerpc/kernel/dma_64.c =================================================================== --- linux-2.6.orig/arch/powerpc/kernel/dma_64.c +++ linux-2.6/arch/powerpc/kernel/dma_64.c @@ -28,6 +28,8 @@ static struct dma_mapping_ops *get_dma_o if (dev->bus == &ibmebus_bus_type) return &ibmebus_dma_ops; #endif + if (dev->bus == &of_platform_bus_type) + return &pci_dma_ops; return NULL; }