powerpc: Fix compile error with CONFIG_TAU=y
[safe/jmp/linux-2.6] / arch / powerpc / kernel / prom.c
index c8d2884..2eccd0e 100644 (file)
@@ -78,15 +78,13 @@ extern struct rtas_t rtas;
 extern struct lmb lmb;
 extern unsigned long klimit;
 
-static unsigned long memory_limit;
-
 static int __initdata dt_root_addr_cells;
 static int __initdata dt_root_size_cells;
 
 #ifdef CONFIG_PPC64
 static int __initdata iommu_is_off;
 int __initdata iommu_force_on;
-extern unsigned long tce_alloc_start, tce_alloc_end;
+unsigned long tce_alloc_start, tce_alloc_end;
 #endif
 
 typedef u32 cell_t;
@@ -110,9 +108,6 @@ struct device_node *of_chosen;
 struct device_node *dflt_interrupt_controller;
 int num_interrupt_controllers;
 
-u32 rtas_data;
-u32 rtas_entry;
-
 /*
  * Wrapper for allocating memory for various data that needs to be
  * attached to device nodes as they are processed at boot or when
@@ -299,16 +294,63 @@ static int __devinit map_interrupt(unsigned int **irq, struct device_node **ictr
        return nintrc;
 }
 
+static unsigned char map_isa_senses[4] = {
+       IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE,
+       IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE,
+       IRQ_SENSE_EDGE  | IRQ_POLARITY_NEGATIVE,
+       IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE
+};
+
+static unsigned char map_mpic_senses[4] = {
+       IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE,
+       IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE,
+       /* 2 seems to be used for the 8259 cascade... */
+       IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE,
+       IRQ_SENSE_EDGE  | IRQ_POLARITY_NEGATIVE,
+};
+
 static int __devinit finish_node_interrupts(struct device_node *np,
                                            unsigned long *mem_start,
                                            int measure_only)
 {
        unsigned int *ints;
        int intlen, intrcells, intrcount;
-       int i, j, n;
+       int i, j, n, sense;
        unsigned int *irq, virq;
        struct device_node *ic;
 
+       if (num_interrupt_controllers == 0) {
+               /*
+                * Old machines just have a list of interrupt numbers
+                * and no interrupt-controller nodes.
+                */
+               ints = (unsigned int *) get_property(np, "AAPL,interrupts",
+                                                    &intlen);
+               /* XXX old interpret_pci_props looked in parent too */
+               /* XXX old interpret_macio_props looked for interrupts
+                  before AAPL,interrupts */
+               if (ints == NULL)
+                       ints = (unsigned int *) get_property(np, "interrupts",
+                                                            &intlen);
+               if (ints == NULL)
+                       return 0;
+
+               np->n_intrs = intlen / sizeof(unsigned int);
+               np->intrs = prom_alloc(np->n_intrs * sizeof(np->intrs[0]),
+                                      mem_start);
+               if (!np->intrs)
+                       return -ENOMEM;
+               if (measure_only)
+                       return 0;
+
+               for (i = 0; i < np->n_intrs; ++i) {
+                       np->intrs[i].line = *ints++;
+                       np->intrs[i].sense = IRQ_SENSE_LEVEL
+                               | IRQ_POLARITY_NEGATIVE;
+               }
+               return 0;
+       }
+
        ints = (unsigned int *) get_property(np, "interrupts", &intlen);
        if (ints == NULL)
                return 0;
@@ -331,19 +373,20 @@ static int __devinit finish_node_interrupts(struct device_node *np,
                /* don't map IRQ numbers under a cascaded 8259 controller */
                if (ic && device_is_compatible(ic, "chrp,iic")) {
                        np->intrs[intrcount].line = irq[0];
+                       sense = (n > 1)? (irq[1] & 3): 3;
+                       np->intrs[intrcount].sense = map_isa_senses[sense];
                } else {
-#ifdef CONFIG_PPC64
                        virq = virt_irq_create_mapping(irq[0]);
+#ifdef CONFIG_PPC64
                        if (virq == NO_IRQ) {
                                printk(KERN_CRIT "Could not allocate interrupt"
                                       " number for %s\n", np->full_name);
                                continue;
                        }
-                       virq = irq_offset_up(virq);
-#else
-                       virq = irq[0];
 #endif
-                       np->intrs[intrcount].line = virq;
+                       np->intrs[intrcount].line = irq_offset_up(virq);
+                       sense = (n > 1)? (irq[1] & 3): 1;
+                       np->intrs[intrcount].sense = map_mpic_senses[sense];
                }
 
 #ifdef CONFIG_PPC64
@@ -358,9 +401,6 @@ static int __devinit finish_node_interrupts(struct device_node *np,
                                break;
                }
 #endif
-               np->intrs[intrcount].sense = 1;
-               if (n > 1)
-                       np->intrs[intrcount].sense = irq[1];
                if (n > 2) {
                        printk("hmmm, got %d intr cells for %s:", n,
                               np->full_name);
@@ -1024,6 +1064,8 @@ void __init unflatten_device_tree(void)
 
        /* Get pointer to OF "/chosen" node for use everywhere */
        of_chosen = of_find_node_by_path("/chosen");
+       if (of_chosen == NULL)
+               of_chosen = of_find_node_by_path("/chosen@0");
 
        /* Retreive command line */
        if (of_chosen != NULL) {
@@ -1066,22 +1108,22 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
        }
 #endif
 
-#ifdef CONFIG_PPC64
+       boot_cpuid = 0;
+       boot_cpuid_phys = 0;
        if (initial_boot_params && initial_boot_params->version >= 2) {
                /* version 2 of the kexec param format adds the phys cpuid
                 * of booted proc.
                 */
                boot_cpuid_phys = initial_boot_params->boot_cpuid_phys;
-               boot_cpuid = 0;
        } else {
-               /* Check if it's the boot-cpu, set it's hw index in paca now */
+               /* Check if it's the boot-cpu, set it's hw index now */
                if (get_flat_dt_prop(node, "linux,boot-cpu", NULL) != NULL) {
                        prop = get_flat_dt_prop(node, "reg", NULL);
-                       set_hard_smp_processor_id(0, prop == NULL ? 0 : *prop);
-                       boot_cpuid_phys = get_hard_smp_processor_id(0);
+                       if (prop != NULL)
+                               boot_cpuid_phys = *prop;
                }
        }
-#endif
+       set_hard_smp_processor_id(0, boot_cpuid_phys);
 
 #ifdef CONFIG_ALTIVEC
        /* Check if we have a VMX and eventually update CPU features */
@@ -1123,7 +1165,8 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
 
        DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
 
-       if (depth != 1 || strcmp(uname, "chosen") != 0)
+       if (depth != 1 ||
+           (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
                return 0;
 
        /* get platform type */
@@ -1133,8 +1176,10 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
 #ifdef CONFIG_PPC64
        systemcfg->platform = *prop;
 #else
+#ifdef CONFIG_PPC_MULTIPLATFORM
        _machine = *prop;
 #endif
+#endif
 
 #ifdef CONFIG_PPC64
        /* check if iommu is forced on or off */
@@ -1368,15 +1413,13 @@ void __init prom_get_irq_senses(unsigned char *senses, int off, int max)
        int i, j;
 
        /* default to level-triggered */
-       memset(senses, 1, max - off);
+       memset(senses, IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE, max - off);
 
        for (np = allnodes; np != 0; np = np->allnext) {
                for (j = 0; j < np->n_intrs; j++) {
                        i = np->intrs[j].line;
                        if (i >= off && i < max)
-                               senses[i-off] = np->intrs[j].sense ?
-                                       IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE :
-                                       IRQ_SENSE_EDGE | IRQ_POLARITY_POSITIVE;
+                               senses[i-off] = np->intrs[j].sense;
                }
        }
 }
@@ -1971,6 +2014,7 @@ bus_space_to_resource_flags(unsigned int bus_space)
        }
 }
 
+#ifdef CONFIG_PCI
 static struct resource *find_parent_pci_resource(struct pci_dev* pdev,
                                                 struct address_range *range)
 {
@@ -2123,3 +2167,4 @@ int release_OF_resource(struct device_node *node, int index)
        return 0;
 }
 EXPORT_SYMBOL(release_OF_resource);
+#endif /* CONFIG_PCI */