Pull sbs into release branch
[pandora-kernel.git] / arch / powerpc / kernel / irq.c
index 068377a..2fc8786 100644 (file)
@@ -7,7 +7,6 @@
  *    Copyright (C) 1996-2001 Cort Dougan
  *  Adapted for Power Macintosh by Paul Mackerras
  *    Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au)
- *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -337,7 +336,8 @@ void do_IRQ(struct pt_regs *regs)
 
 void __init init_IRQ(void)
 {
-       ppc_md.init_IRQ();
+       if (ppc_md.init_IRQ)
+               ppc_md.init_IRQ();
 #ifdef CONFIG_PPC64
        irq_ctx_init();
 #endif
@@ -412,6 +412,12 @@ struct irq_map_entry irq_map[NR_IRQS];
 static unsigned int irq_virq_count = NR_IRQS;
 static struct irq_host *irq_default_host;
 
+irq_hw_number_t virq_to_hw(unsigned int virq)
+{
+       return irq_map[virq].hwirq;
+}
+EXPORT_SYMBOL_GPL(virq_to_hw);
+
 struct irq_host *irq_alloc_host(unsigned int revmap_type,
                                unsigned int revmap_arg,
                                struct irq_host_ops *ops,
@@ -489,7 +495,7 @@ struct irq_host *irq_alloc_host(unsigned int revmap_type,
        case IRQ_HOST_MAP_LINEAR:
                rmap = (unsigned int *)(host + 1);
                for (i = 0; i < revmap_arg; i++)
-                       rmap[i] = IRQ_NONE;
+                       rmap[i] = NO_IRQ;
                host->revmap_data.linear.size = revmap_arg;
                smp_wmb();
                host->revmap_data.linear.revmap = rmap;
@@ -591,6 +597,49 @@ static void irq_radix_rdunlock(unsigned long flags)
        local_irq_restore(flags);
 }
 
+static int irq_setup_virq(struct irq_host *host, unsigned int virq,
+                           irq_hw_number_t hwirq)
+{
+       /* Clear IRQ_NOREQUEST flag */
+       get_irq_desc(virq)->status &= ~IRQ_NOREQUEST;
+
+       /* map it */
+       smp_wmb();
+       irq_map[virq].hwirq = hwirq;
+       smp_mb();
+
+       if (host->ops->map(host, virq, hwirq)) {
+               pr_debug("irq: -> mapping failed, freeing\n");
+               irq_free_virt(virq, 1);
+               return -1;
+       }
+
+       return 0;
+}
+
+unsigned int irq_create_direct_mapping(struct irq_host *host)
+{
+       unsigned int virq;
+
+       if (host == NULL)
+               host = irq_default_host;
+
+       BUG_ON(host == NULL);
+       WARN_ON(host->revmap_type != IRQ_HOST_MAP_NOMAP);
+
+       virq = irq_alloc_virt(host, 1, 0);
+       if (virq == NO_IRQ) {
+               pr_debug("irq: create_direct virq allocation failed\n");
+               return NO_IRQ;
+       }
+
+       pr_debug("irq: create_direct obtained virq %d\n", virq);
+
+       if (irq_setup_virq(host, virq, virq))
+               return NO_IRQ;
+
+       return virq;
+}
 
 unsigned int irq_create_mapping(struct irq_host *host,
                                irq_hw_number_t hwirq)
@@ -614,7 +663,7 @@ unsigned int irq_create_mapping(struct irq_host *host,
         * host->ops->map() to update the flags
         */
        virq = irq_find_mapping(host, hwirq);
-       if (virq != IRQ_NONE) {
+       if (virq != NO_IRQ) {
                if (host->ops->remap)
                        host->ops->remap(host, virq, hwirq);
                pr_debug("irq: -> existing mapping on virq %d\n", virq);
@@ -639,18 +688,9 @@ unsigned int irq_create_mapping(struct irq_host *host,
        }
        pr_debug("irq: -> obtained virq %d\n", virq);
 
-       /* Clear IRQ_NOREQUEST flag */
-       get_irq_desc(virq)->status &= ~IRQ_NOREQUEST;
-
-       /* map it */
-       smp_wmb();
-       irq_map[virq].hwirq = hwirq;
-       smp_mb();
-       if (host->ops->map(host, virq, hwirq)) {
-               pr_debug("irq: -> mapping failed, freeing\n");
-               irq_free_virt(virq, 1);
+       if (irq_setup_virq(host, virq, hwirq))
                return NO_IRQ;
-       }
+
        return virq;
 }
 EXPORT_SYMBOL_GPL(irq_create_mapping);
@@ -741,7 +781,7 @@ void irq_dispose_mapping(unsigned int virq)
        switch(host->revmap_type) {
        case IRQ_HOST_MAP_LINEAR:
                if (hwirq < host->revmap_data.linear.size)
-                       host->revmap_data.linear.revmap[hwirq] = IRQ_NONE;
+                       host->revmap_data.linear.revmap[hwirq] = NO_IRQ;
                break;
        case IRQ_HOST_MAP_TREE:
                /* Check if radix tree allocated yet */