]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/platforms/cell/spu_manage.c
Cell: Draw SPE helper penguin logos
[linux-2.6-omap-h63xx.git] / arch / powerpc / platforms / cell / spu_manage.c
index d8b39fe39cddc9be1872e5f75fd59ccd2cd3ab23..75ed50fcc3dbaf70903fc74b00ab75b3e7d99ad3 100644 (file)
@@ -48,74 +48,17 @@ static u64 __init find_spu_unit_number(struct device_node *spe)
 {
        const unsigned int *prop;
        int proplen;
-       prop = get_property(spe, "unit-id", &proplen);
+       prop = of_get_property(spe, "unit-id", &proplen);
        if (proplen == 4)
                return (u64)*prop;
 
-       prop = get_property(spe, "reg", &proplen);
+       prop = of_get_property(spe, "reg", &proplen);
        if (proplen == 4)
                return (u64)*prop;
 
        return 0;
 }
 
-static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
-               const char *prop)
-{
-       const struct address_prop {
-               unsigned long address;
-               unsigned int len;
-       } __attribute__((packed)) *p;
-       int proplen;
-
-       unsigned long start_pfn, nr_pages;
-       struct pglist_data *pgdata;
-       struct zone *zone;
-       int ret;
-
-       p = get_property(spe, prop, &proplen);
-       WARN_ON(proplen != sizeof (*p));
-
-       start_pfn = p->address >> PAGE_SHIFT;
-       nr_pages = ((unsigned long)p->len + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
-       pgdata = NODE_DATA(spu->node);
-       zone = pgdata->node_zones;
-
-       ret = __add_pages(zone, start_pfn, nr_pages);
-
-       return ret;
-}
-
-static void __iomem * __init map_spe_prop(struct spu *spu,
-               struct device_node *n, const char *name)
-{
-       const struct address_prop {
-               unsigned long address;
-               unsigned int len;
-       } __attribute__((packed)) *prop;
-
-       const void *p;
-       int proplen;
-       void __iomem *ret = NULL;
-       int err = 0;
-
-       p = get_property(n, name, &proplen);
-       if (proplen != sizeof (struct address_prop))
-               return NULL;
-
-       prop = p;
-
-       err = cell_spuprop_present(spu, n, name);
-       if (err && (err != -EEXIST))
-               goto out;
-
-       ret = ioremap(prop->address, prop->len);
-
- out:
-       return ret;
-}
-
 static void spu_unmap(struct spu *spu)
 {
        if (!firmware_has_feature(FW_FEATURE_LPAR))
@@ -133,12 +76,12 @@ static int __init spu_map_interrupts_old(struct spu *spu,
        int nid;
 
        /* Get the interrupt source unit from the device-tree */
-       tmp = get_property(np, "isrc", NULL);
+       tmp = of_get_property(np, "isrc", NULL);
        if (!tmp)
                return -ENODEV;
        isrc = tmp[0];
 
-       tmp = get_property(np->parent->parent, "node-id", NULL);
+       tmp = of_get_property(np->parent->parent, "node-id", NULL);
        if (!tmp) {
                printk(KERN_WARNING "%s: can't find node-id\n", __FUNCTION__);
                nid = spu->node;
@@ -157,6 +100,23 @@ static int __init spu_map_interrupts_old(struct spu *spu,
        return spu->irqs[2] == NO_IRQ ? -EINVAL : 0;
 }
 
+static void __iomem * __init spu_map_prop_old(struct spu *spu,
+                                             struct device_node *n,
+                                             const char *name)
+{
+       const struct address_prop {
+               unsigned long address;
+               unsigned int len;
+       } __attribute__((packed)) *prop;
+       int proplen;
+
+       prop = of_get_property(n, name, &proplen);
+       if (prop == NULL || proplen != sizeof (struct address_prop))
+               return NULL;
+
+       return ioremap(prop->address, prop->len);
+}
+
 static int __init spu_map_device_old(struct spu *spu)
 {
        struct device_node *node = spu->devnode;
@@ -164,36 +124,36 @@ static int __init spu_map_device_old(struct spu *spu)
        int ret;
 
        ret = -ENODEV;
-       spu->name = get_property(node, "name", NULL);
+       spu->name = of_get_property(node, "name", NULL);
        if (!spu->name)
                goto out;
 
-       prop = get_property(node, "local-store", NULL);
+       prop = of_get_property(node, "local-store", NULL);
        if (!prop)
                goto out;
        spu->local_store_phys = *(unsigned long *)prop;
 
        /* we use local store as ram, not io memory */
        spu->local_store = (void __force *)
-               map_spe_prop(spu, node, "local-store");
+               spu_map_prop_old(spu, node, "local-store");
        if (!spu->local_store)
                goto out;
 
-       prop = get_property(node, "problem", NULL);
+       prop = of_get_property(node, "problem", NULL);
        if (!prop)
                goto out_unmap;
        spu->problem_phys = *(unsigned long *)prop;
 
-       spu->problem = map_spe_prop(spu, node, "problem");
+       spu->problem = spu_map_prop_old(spu, node, "problem");
        if (!spu->problem)
                goto out_unmap;
 
-       spu->priv2 = map_spe_prop(spu, node, "priv2");
+       spu->priv2 = spu_map_prop_old(spu, node, "priv2");
        if (!spu->priv2)
                goto out_unmap;
 
        if (!firmware_has_feature(FW_FEATURE_LPAR)) {
-               spu->priv1 = map_spe_prop(spu, node, "priv1");
+               spu->priv1 = spu_map_prop_old(spu, node, "priv1");
                if (!spu->priv1)
                        goto out_unmap;
        }
@@ -245,34 +205,20 @@ static int spu_map_resource(struct spu *spu, int nr,
                            void __iomem** virt, unsigned long *phys)
 {
        struct device_node *np = spu->devnode;
-       unsigned long start_pfn, nr_pages;
-       struct pglist_data *pgdata;
-       struct zone *zone;
        struct resource resource = { };
        unsigned long len;
        int ret;
 
        ret = of_address_to_resource(np, nr, &resource);
        if (ret)
-               goto out;
-
+               return ret;
        if (phys)
                *phys = resource.start;
        len = resource.end - resource.start + 1;
        *virt = ioremap(resource.start, len);
        if (!*virt)
-               ret = -EINVAL;
-
-       start_pfn = resource.start >> PAGE_SHIFT;
-       nr_pages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
-       pgdata = NODE_DATA(spu->node);
-       zone = pgdata->node_zones;
-
-       ret = __add_pages(zone, start_pfn, nr_pages);
-
-out:
-       return ret;
+               return -EINVAL;
+       return 0;
 }
 
 static int __init spu_map_device(struct spu *spu)
@@ -280,7 +226,7 @@ static int __init spu_map_device(struct spu *spu)
        struct device_node *np = spu->devnode;
        int ret = -ENODEV;
 
-       spu->name = get_property(np, "name", NULL);
+       spu->name = of_get_property(np, "name", NULL);
        if (!spu->name)
                goto out;
 
@@ -333,6 +279,7 @@ static int __init of_enumerate_spus(int (*fn)(void *data))
 {
        int ret;
        struct device_node *node;
+       unsigned int n = 0;
 
        ret = -ENODEV;
        for (node = of_find_node_by_type(NULL, "spe");
@@ -343,8 +290,9 @@ static int __init of_enumerate_spus(int (*fn)(void *data))
                                __FUNCTION__, node->name);
                        break;
                }
+               n++;
        }
-       return ret;
+       return ret ? ret : n;
 }
 
 static int __init of_create_spu(struct spu *spu, void *data)