]> err.no Git - linux-2.6/blobdiff - arch/powerpc/platforms/cell/cbe_regs.c
[POWERPC] spu sched: static timeslicing for SCHED_RR contexts
[linux-2.6] / arch / powerpc / platforms / cell / cbe_regs.c
index 2dfde61c8412ff6fafe023e7f5d4f89d1148ea44..9a0ee62691d529f69a90779e5bbe62cd7e5fbdcd 100644 (file)
@@ -6,10 +6,9 @@
  * (c) 2006 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
  */
 
-
-#include <linux/config.h>
 #include <linux/percpu.h>
 #include <linux/types.h>
+#include <linux/module.h>
 
 #include <asm/io.h>
 #include <asm/pgtable.h>
@@ -18,8 +17,6 @@
 
 #include "cbe_regs.h"
 
-#define MAX_CBE                2
-
 /*
  * Current implementation uses "cpu" nodes. We build our own mapping
  * array of cpu numbers to cpu nodes locally for now to allow interrupt
@@ -32,6 +29,8 @@ static struct cbe_regs_map
        struct device_node *cpu_node;
        struct cbe_pmd_regs __iomem *pmd_regs;
        struct cbe_iic_regs __iomem *iic_regs;
+       struct cbe_mic_tm_regs __iomem *mic_tm_regs;
+       struct cbe_pmd_shadow_regs pmd_shadow_regs;
 } cbe_regs_maps[MAX_CBE];
 static int cbe_regs_map_count;
 
@@ -44,6 +43,19 @@ static struct cbe_thread_map
 static struct cbe_regs_map *cbe_find_map(struct device_node *np)
 {
        int i;
+       struct device_node *tmp_np;
+
+       if (strcasecmp(np->type, "spe") == 0) {
+               if (np->data == NULL) {
+                       /* walk up path until cpu node was found */
+                       tmp_np = np->parent;
+                       while (tmp_np != NULL && strcasecmp(tmp_np->type, "cpu") != 0)
+                               tmp_np = tmp_np->parent;
+
+                       np->data = cbe_find_map(tmp_np);
+               }
+               return np->data;
+       }
 
        for (i = 0; i < cbe_regs_map_count; i++)
                if (cbe_regs_maps[i].cpu_node == np)
@@ -58,6 +70,7 @@ struct cbe_pmd_regs __iomem *cbe_get_pmd_regs(struct device_node *np)
                return NULL;
        return map->pmd_regs;
 }
+EXPORT_SYMBOL_GPL(cbe_get_pmd_regs);
 
 struct cbe_pmd_regs __iomem *cbe_get_cpu_pmd_regs(int cpu)
 {
@@ -66,7 +79,23 @@ struct cbe_pmd_regs __iomem *cbe_get_cpu_pmd_regs(int cpu)
                return NULL;
        return map->pmd_regs;
 }
+EXPORT_SYMBOL_GPL(cbe_get_cpu_pmd_regs);
 
+struct cbe_pmd_shadow_regs *cbe_get_pmd_shadow_regs(struct device_node *np)
+{
+       struct cbe_regs_map *map = cbe_find_map(np);
+       if (map == NULL)
+               return NULL;
+       return &map->pmd_shadow_regs;
+}
+
+struct cbe_pmd_shadow_regs *cbe_get_cpu_pmd_shadow_regs(int cpu)
+{
+       struct cbe_regs_map *map = cbe_thread_map[cpu].regs;
+       if (map == NULL)
+               return NULL;
+       return &map->pmd_shadow_regs;
+}
 
 struct cbe_iic_regs __iomem *cbe_get_iic_regs(struct device_node *np)
 {
@@ -75,6 +104,7 @@ struct cbe_iic_regs __iomem *cbe_get_iic_regs(struct device_node *np)
                return NULL;
        return map->iic_regs;
 }
+
 struct cbe_iic_regs __iomem *cbe_get_cpu_iic_regs(int cpu)
 {
        struct cbe_regs_map *map = cbe_thread_map[cpu].regs;
@@ -83,13 +113,43 @@ struct cbe_iic_regs __iomem *cbe_get_cpu_iic_regs(int cpu)
        return map->iic_regs;
 }
 
+struct cbe_mic_tm_regs __iomem *cbe_get_mic_tm_regs(struct device_node *np)
+{
+       struct cbe_regs_map *map = cbe_find_map(np);
+       if (map == NULL)
+               return NULL;
+       return map->mic_tm_regs;
+}
+
+struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu)
+{
+       struct cbe_regs_map *map = cbe_thread_map[cpu].regs;
+       if (map == NULL)
+               return NULL;
+       return map->mic_tm_regs;
+}
+EXPORT_SYMBOL_GPL(cbe_get_cpu_mic_tm_regs);
+
+/* FIXME
+ * This is little more than a stub at the moment.  It should be
+ * fleshed out so that it works for both SMT and non-SMT, no
+ * matter if the passed cpu is odd or even.
+ * For SMT enabled, returns 0 for even-numbered cpu; otherwise 1.
+ * For SMT disabled, returns 0 for all cpus.
+ */
+u32 cbe_get_hw_thread_id(int cpu)
+{
+       return (cpu & 1);
+}
+EXPORT_SYMBOL_GPL(cbe_get_hw_thread_id);
+
 void __init cbe_regs_init(void)
 {
        int i;
        struct device_node *cpu;
 
        /* Build local fast map of CPUs */
-       for_each_cpu(i)
+       for_each_possible_cpu(i)
                cbe_thread_map[i].cpu_node = of_get_cpu_node(i, NULL);
 
        /* Find maps for each device tree CPU */
@@ -97,7 +157,7 @@ void __init cbe_regs_init(void)
                struct cbe_regs_map *map = &cbe_regs_maps[cbe_regs_map_count++];
 
                /* That hack must die die die ! */
-               struct address_prop {
+               const struct address_prop {
                        unsigned long address;
                        unsigned int len;
                } __attribute__((packed)) *prop;
@@ -110,19 +170,22 @@ void __init cbe_regs_init(void)
                        return;
                }
                map->cpu_node = cpu;
-               for_each_cpu(i)
+               for_each_possible_cpu(i)
                        if (cbe_thread_map[i].cpu_node == cpu)
                                cbe_thread_map[i].regs = map;
 
-               prop = (struct address_prop *)get_property(cpu, "pervasive",
-                                                          NULL);
+               prop = get_property(cpu, "pervasive", NULL);
                if (prop != NULL)
                        map->pmd_regs = ioremap(prop->address, prop->len);
 
-               prop = (struct address_prop *)get_property(cpu, "iic",
-                                                          NULL);
+               prop = get_property(cpu, "iic", NULL);
                if (prop != NULL)
                        map->iic_regs = ioremap(prop->address, prop->len);
+
+               prop = (struct address_prop *)get_property(cpu, "mic-tm",
+                                                          NULL);
+               if (prop != NULL)
+                       map->mic_tm_regs = ioremap(prop->address, prop->len);
        }
 }