]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/sparc64/kernel/prom.c
[SPARC64]: Fix boot failures due to bootmem.
[linux-2.6-omap-h63xx.git] / arch / sparc64 / kernel / prom.c
index 2462731ac1a3efec4b006ff0484eee9451e9ed3e..a246e962e5a73591d546d8d6c7ac2f950ad075d4 100644 (file)
 #include <asm/upa.h>
 #include <asm/smp.h>
 
-static struct device_node *allnodes;
+extern struct device_node *allnodes;   /* temporary while merging */
 
 extern rwlock_t devtree_lock;  /* temporary while merging */
 
-struct device_node *of_get_next_child(const struct device_node *node,
-       struct device_node *prev)
-{
-       struct device_node *next;
-
-       next = prev ? prev->sibling : node->child;
-       for (; next != 0; next = next->sibling) {
-               break;
-       }
-
-       return next;
-}
-EXPORT_SYMBOL(of_get_next_child);
-
-struct device_node *of_find_node_by_path(const char *path)
-{
-       struct device_node *np = allnodes;
-
-       for (; np != 0; np = np->allnext) {
-               if (np->full_name != 0 && strcmp(np->full_name, path) == 0)
-                       break;
-       }
-
-       return np;
-}
-EXPORT_SYMBOL(of_find_node_by_path);
-
 struct device_node *of_find_node_by_phandle(phandle handle)
 {
        struct device_node *np;
@@ -73,52 +46,6 @@ struct device_node *of_find_node_by_phandle(phandle handle)
 }
 EXPORT_SYMBOL(of_find_node_by_phandle);
 
-struct device_node *of_find_node_by_name(struct device_node *from,
-       const char *name)
-{
-       struct device_node *np;
-
-       np = from ? from->allnext : allnodes;
-       for (; np != NULL; np = np->allnext)
-               if (np->name != NULL && strcmp(np->name, name) == 0)
-                       break;
-
-       return np;
-}
-EXPORT_SYMBOL(of_find_node_by_name);
-
-struct device_node *of_find_node_by_type(struct device_node *from,
-       const char *type)
-{
-       struct device_node *np;
-
-       np = from ? from->allnext : allnodes;
-       for (; np != 0; np = np->allnext)
-               if (np->type != 0 && strcmp(np->type, type) == 0)
-                       break;
-
-       return np;
-}
-EXPORT_SYMBOL(of_find_node_by_type);
-
-struct device_node *of_find_compatible_node(struct device_node *from,
-       const char *type, const char *compatible)
-{
-       struct device_node *np;
-
-       np = from ? from->allnext : allnodes;
-       for (; np != 0; np = np->allnext) {
-               if (type != NULL
-                   && !(np->type != 0 && strcmp(np->type, type) == 0))
-                       continue;
-               if (of_device_is_compatible(np, compatible))
-                       break;
-       }
-
-       return np;
-}
-EXPORT_SYMBOL(of_find_compatible_node);
-
 int of_getintprop_default(struct device_node *np, const char *name, int def)
 {
        struct property *prop;
@@ -180,6 +107,21 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
 }
 EXPORT_SYMBOL(of_set_property);
 
+int of_find_in_proplist(const char *list, const char *match, int len)
+{
+       while (len > 0) {
+               int l;
+
+               if (!strcmp(list, match))
+                       return 1;
+               l = strlen(list) + 1;
+               list += l;
+               len -= l;
+       }
+       return 0;
+}
+EXPORT_SYMBOL(of_find_in_proplist);
+
 static unsigned int prom_early_allocated;
 
 static void * __init prom_early_alloc(unsigned long size)
@@ -1104,7 +1046,8 @@ static void __init irq_trans_init(struct device_node *dp)
        if (!strcmp(dp->name, "fhc") &&
            !strcmp(dp->parent->name, "central"))
                return central_irq_trans_init(dp);
-       if (!strcmp(dp->name, "virtual-devices"))
+       if (!strcmp(dp->name, "virtual-devices") ||
+           !strcmp(dp->name, "niu"))
                return sun4v_vdev_irq_trans_init(dp);
 }
 
@@ -1641,8 +1584,12 @@ static void __init of_fill_in_cpu_data(void)
                ncpus_probed++;
 
 #ifdef CONFIG_SMP
-               if (cpuid >= NR_CPUS)
+               if (cpuid >= NR_CPUS) {
+                       printk(KERN_WARNING "Ignoring CPU %d which is "
+                              ">= NR_CPUS (%d)\n",
+                              cpuid, NR_CPUS);
                        continue;
+               }
 #else
                /* On uniprocessor we only want the values for the
                 * real physical cpu the kernel booted onto, however
@@ -1719,6 +1666,60 @@ static void __init of_fill_in_cpu_data(void)
        smp_fill_in_sib_core_maps();
 }
 
+struct device_node *of_console_device;
+EXPORT_SYMBOL(of_console_device);
+
+char *of_console_path;
+EXPORT_SYMBOL(of_console_path);
+
+char *of_console_options;
+EXPORT_SYMBOL(of_console_options);
+
+static void __init of_console_init(void)
+{
+       char *msg = "OF stdout device is: %s\n";
+       struct device_node *dp;
+       const char *type;
+       phandle node;
+
+       of_console_path = prom_early_alloc(256);
+       if (prom_ihandle2path(prom_stdout, of_console_path, 256) < 0) {
+               prom_printf("Cannot obtain path of stdout.\n");
+               prom_halt();
+       }
+       of_console_options = strrchr(of_console_path, ':');
+       if (of_console_options) {
+               of_console_options++;
+               if (*of_console_options == '\0')
+                       of_console_options = NULL;
+       }
+
+       node = prom_inst2pkg(prom_stdout);
+       if (!node) {
+               prom_printf("Cannot resolve stdout node from "
+                           "instance %08x.\n", prom_stdout);
+               prom_halt();
+       }
+
+       dp = of_find_node_by_phandle(node);
+       type = of_get_property(dp, "device_type", NULL);
+       if (!type) {
+               prom_printf("Console stdout lacks device_type property.\n");
+               prom_halt();
+       }
+
+       if (strcmp(type, "display") && strcmp(type, "serial")) {
+               prom_printf("Console device_type is neither display "
+                           "nor serial.\n");
+               prom_halt();
+       }
+
+       of_console_device = dp;
+
+       prom_printf(msg, of_console_path);
+       printk(msg, of_console_path);
+}
+
 void __init prom_build_devicetree(void)
 {
        struct device_node **nextp;
@@ -1731,6 +1732,8 @@ void __init prom_build_devicetree(void)
        allnodes->child = build_tree(allnodes,
                                     prom_getchild(allnodes->node),
                                     &nextp);
+       of_console_init();
+
        printk("PROM: Built device tree with %u bytes of memory.\n",
               prom_early_allocated);