Merge branch 'next/dt' of git://git.linaro.org/people/arnd/arm-soc
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 2 Nov 2011 04:02:35 +0000 (21:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 2 Nov 2011 04:02:35 +0000 (21:02 -0700)
* 'next/dt' of git://git.linaro.org/people/arnd/arm-soc:
  ARM: gic: use module.h instead of export.h
  ARM: gic: fix irq_alloc_descs handling for sparse irq
  ARM: gic: add OF based initialization
  ARM: gic: add irq_domain support
  irq: support domains with non-zero hwirq base
  of/irq: introduce of_irq_init
  ARM: at91: add at91sam9g20 and Calao USB A9G20 DT support
  ARM: at91: dt: at91sam9g45 family and board device tree files
  arm/mx5: add device tree support for imx51 babbage
  arm/mx5: add device tree support for imx53 boards
  ARM: msm: Add devicetree support for msm8660-surf
  msm_serial: Add devicetree support
  msm_serial: Use relative resources for iomem

Fix up conflicts in arch/arm/mach-at91/{at91sam9260.c,at91sam9g45.c}

1  2 
arch/arm/common/gic.c
arch/arm/mach-at91/Kconfig
arch/arm/mach-at91/Makefile
arch/arm/mach-at91/Makefile.boot
arch/arm/mach-at91/at91sam9260.c
arch/arm/mach-at91/at91sam9g45.c
drivers/of/irq.c
drivers/tty/serial/msm_serial.c

diff --combined arch/arm/common/gic.c
   */
  #include <linux/init.h>
  #include <linux/kernel.h>
+ #include <linux/err.h>
+ #include <linux/module.h>
  #include <linux/list.h>
  #include <linux/smp.h>
  #include <linux/cpu_pm.h>
  #include <linux/cpumask.h>
  #include <linux/io.h>
+ #include <linux/of.h>
+ #include <linux/of_address.h>
+ #include <linux/of_irq.h>
+ #include <linux/irqdomain.h>
  #include <linux/interrupt.h>
  #include <linux/percpu.h>
  #include <linux/slab.h>
@@@ -37,7 -43,7 +43,7 @@@
  #include <asm/mach/irq.h>
  #include <asm/hardware/gic.h>
  
 -static DEFINE_SPINLOCK(irq_controller_lock);
 +static DEFINE_RAW_SPINLOCK(irq_controller_lock);
  
  /* Address of GIC 0 CPU interface */
  void __iomem *gic_cpu_base_addr __read_mostly;
@@@ -75,8 -81,7 +81,7 @@@ static inline void __iomem *gic_cpu_bas
  
  static inline unsigned int gic_irq(struct irq_data *d)
  {
-       struct gic_chip_data *gic_data = irq_data_get_irq_chip_data(d);
-       return d->irq - gic_data->irq_offset;
+       return d->hwirq;
  }
  
  /*
   */
  static void gic_mask_irq(struct irq_data *d)
  {
-       u32 mask = 1 << (d->irq % 32);
+       u32 mask = 1 << (gic_irq(d) % 32);
  
 -      spin_lock(&irq_controller_lock);
 +      raw_spin_lock(&irq_controller_lock);
        writel_relaxed(mask, gic_dist_base(d) + GIC_DIST_ENABLE_CLEAR + (gic_irq(d) / 32) * 4);
        if (gic_arch_extn.irq_mask)
                gic_arch_extn.irq_mask(d);
 -      spin_unlock(&irq_controller_lock);
 +      raw_spin_unlock(&irq_controller_lock);
  }
  
  static void gic_unmask_irq(struct irq_data *d)
  {
-       u32 mask = 1 << (d->irq % 32);
+       u32 mask = 1 << (gic_irq(d) % 32);
  
 -      spin_lock(&irq_controller_lock);
 +      raw_spin_lock(&irq_controller_lock);
        if (gic_arch_extn.irq_unmask)
                gic_arch_extn.irq_unmask(d);
        writel_relaxed(mask, gic_dist_base(d) + GIC_DIST_ENABLE_SET + (gic_irq(d) / 32) * 4);
 -      spin_unlock(&irq_controller_lock);
 +      raw_spin_unlock(&irq_controller_lock);
  }
  
  static void gic_eoi_irq(struct irq_data *d)
  {
        if (gic_arch_extn.irq_eoi) {
 -              spin_lock(&irq_controller_lock);
 +              raw_spin_lock(&irq_controller_lock);
                gic_arch_extn.irq_eoi(d);
 -              spin_unlock(&irq_controller_lock);
 +              raw_spin_unlock(&irq_controller_lock);
        }
  
        writel_relaxed(gic_irq(d), gic_cpu_base(d) + GIC_CPU_EOI);
@@@ -133,7 -138,7 +138,7 @@@ static int gic_set_type(struct irq_dat
        if (type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
                return -EINVAL;
  
 -      spin_lock(&irq_controller_lock);
 +      raw_spin_lock(&irq_controller_lock);
  
        if (gic_arch_extn.irq_set_type)
                gic_arch_extn.irq_set_type(d, type);
        if (enabled)
                writel_relaxed(enablemask, base + GIC_DIST_ENABLE_SET + enableoff);
  
 -      spin_unlock(&irq_controller_lock);
 +      raw_spin_unlock(&irq_controller_lock);
  
        return 0;
  }
@@@ -176,7 -181,7 +181,7 @@@ static int gic_set_affinity(struct irq_
                            bool force)
  {
        void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + (gic_irq(d) & ~3);
-       unsigned int shift = (d->irq % 4) * 8;
+       unsigned int shift = (gic_irq(d) % 4) * 8;
        unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask);
        u32 val, mask, bit;
  
        mask = 0xff << shift;
        bit = 1 << (cpu_logical_map(cpu) + shift);
  
 -      spin_lock(&irq_controller_lock);
 +      raw_spin_lock(&irq_controller_lock);
        val = readl_relaxed(reg) & ~mask;
        writel_relaxed(val | bit, reg);
 -      spin_unlock(&irq_controller_lock);
 +      raw_spin_unlock(&irq_controller_lock);
  
        return IRQ_SET_MASK_OK;
  }
@@@ -219,15 -224,15 +224,15 @@@ static void gic_handle_cascade_irq(unsi
  
        chained_irq_enter(chip, desc);
  
 -      spin_lock(&irq_controller_lock);
 +      raw_spin_lock(&irq_controller_lock);
        status = readl_relaxed(chip_data->cpu_base + GIC_CPU_INTACK);
 -      spin_unlock(&irq_controller_lock);
 +      raw_spin_unlock(&irq_controller_lock);
  
        gic_irq = (status & 0x3ff);
        if (gic_irq == 1023)
                goto out;
  
-       cascade_irq = gic_irq + chip_data->irq_offset;
+       cascade_irq = irq_domain_to_irq(&chip_data->domain, gic_irq);
        if (unlikely(gic_irq < 32 || gic_irq > 1020 || cascade_irq >= NR_IRQS))
                do_bad_IRQ(cascade_irq, desc);
        else
@@@ -259,14 -264,14 +264,14 @@@ void __init gic_cascade_irq(unsigned in
        irq_set_chained_handler(irq, gic_handle_cascade_irq);
  }
  
- static void __init gic_dist_init(struct gic_chip_data *gic,
-       unsigned int irq_start)
+ static void __init gic_dist_init(struct gic_chip_data *gic)
  {
-       unsigned int gic_irqs, irq_limit, i;
+       unsigned int i, irq;
        u32 cpumask;
+       unsigned int gic_irqs = gic->gic_irqs;
+       struct irq_domain *domain = &gic->domain;
        void __iomem *base = gic->dist_base;
        u32 cpu = 0;
-       u32 nrppis = 0, ppi_base = 0;
  
  #ifdef CONFIG_SMP
        cpu = cpu_logical_map(smp_processor_id());
  
        writel_relaxed(0, base + GIC_DIST_CTRL);
  
-       /*
-        * Find out how many interrupts are supported.
-        * The GIC only supports up to 1020 interrupt sources.
-        */
-       gic_irqs = readl_relaxed(base + GIC_DIST_CTR) & 0x1f;
-       gic_irqs = (gic_irqs + 1) * 32;
-       if (gic_irqs > 1020)
-               gic_irqs = 1020;
-       gic->gic_irqs = gic_irqs;
-       /*
-        * Nobody would be insane enough to use PPIs on a secondary
-        * GIC, right?
-        */
-       if (gic == &gic_data[0]) {
-               nrppis = (32 - irq_start) & 31;
-               /* The GIC only supports up to 16 PPIs. */
-               if (nrppis > 16)
-                       BUG();
-               ppi_base = gic->irq_offset + 32 - nrppis;
-       }
-       pr_info("Configuring GIC with %d sources (%d PPIs)\n",
-               gic_irqs, (gic == &gic_data[0]) ? nrppis : 0);
        /*
         * Set all global interrupts to be level triggered, active low.
         */
        for (i = 32; i < gic_irqs; i += 32)
                writel_relaxed(0xffffffff, base + GIC_DIST_ENABLE_CLEAR + i * 4 / 32);
  
-       /*
-        * Limit number of interrupts registered to the platform maximum
-        */
-       irq_limit = gic->irq_offset + gic_irqs;
-       if (WARN_ON(irq_limit > NR_IRQS))
-               irq_limit = NR_IRQS;
        /*
         * Setup the Linux IRQ subsystem.
         */
-       for (i = 0; i < nrppis; i++) {
-               int ppi = i + ppi_base;
-               irq_set_percpu_devid(ppi);
-               irq_set_chip_and_handler(ppi, &gic_chip,
-                                        handle_percpu_devid_irq);
-               irq_set_chip_data(ppi, gic);
-               set_irq_flags(ppi, IRQF_VALID | IRQF_NOAUTOEN);
-       }
-       for (i = irq_start + nrppis; i < irq_limit; i++) {
-               irq_set_chip_and_handler(i, &gic_chip, handle_fasteoi_irq);
-               irq_set_chip_data(i, gic);
-               set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
+       irq_domain_for_each_irq(domain, i, irq) {
+               if (i < 32) {
+                       irq_set_percpu_devid(irq);
+                       irq_set_chip_and_handler(irq, &gic_chip,
+                                                handle_percpu_devid_irq);
+                       set_irq_flags(irq, IRQF_VALID | IRQF_NOAUTOEN);
+               } else {
+                       irq_set_chip_and_handler(irq, &gic_chip,
+                                                handle_fasteoi_irq);
+                       set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
+               }
+               irq_set_chip_data(irq, gic);
        }
  
        writel_relaxed(1, base + GIC_DIST_CTRL);
@@@ -566,23 -534,85 +534,85 @@@ static void __init gic_pm_init(struct g
  }
  #endif
  
- void __init gic_init(unsigned int gic_nr, unsigned int irq_start,
+ #ifdef CONFIG_OF
+ static int gic_irq_domain_dt_translate(struct irq_domain *d,
+                                      struct device_node *controller,
+                                      const u32 *intspec, unsigned int intsize,
+                                      unsigned long *out_hwirq, unsigned int *out_type)
+ {
+       if (d->of_node != controller)
+               return -EINVAL;
+       if (intsize < 3)
+               return -EINVAL;
+       /* Get the interrupt number and add 16 to skip over SGIs */
+       *out_hwirq = intspec[1] + 16;
+       /* For SPIs, we need to add 16 more to get the GIC irq ID number */
+       if (!intspec[0])
+               *out_hwirq += 16;
+       *out_type = intspec[2] & IRQ_TYPE_SENSE_MASK;
+       return 0;
+ }
+ #endif
+ const struct irq_domain_ops gic_irq_domain_ops = {
+ #ifdef CONFIG_OF
+       .dt_translate = gic_irq_domain_dt_translate,
+ #endif
+ };
+ void __init gic_init(unsigned int gic_nr, int irq_start,
        void __iomem *dist_base, void __iomem *cpu_base)
  {
        struct gic_chip_data *gic;
+       struct irq_domain *domain;
+       int gic_irqs;
  
        BUG_ON(gic_nr >= MAX_GIC_NR);
  
        gic = &gic_data[gic_nr];
+       domain = &gic->domain;
        gic->dist_base = dist_base;
        gic->cpu_base = cpu_base;
-       gic->irq_offset = (irq_start - 1) & ~31;
  
-       if (gic_nr == 0)
+       /*
+        * For primary GICs, skip over SGIs.
+        * For secondary GICs, skip over PPIs, too.
+        */
+       if (gic_nr == 0) {
                gic_cpu_base_addr = cpu_base;
+               domain->hwirq_base = 16;
+               if (irq_start > 0)
+                       irq_start = (irq_start & ~31) + 16;
+       } else
+               domain->hwirq_base = 32;
+       /*
+        * Find out how many interrupts are supported.
+        * The GIC only supports up to 1020 interrupt sources.
+        */
+       gic_irqs = readl_relaxed(dist_base + GIC_DIST_CTR) & 0x1f;
+       gic_irqs = (gic_irqs + 1) * 32;
+       if (gic_irqs > 1020)
+               gic_irqs = 1020;
+       gic->gic_irqs = gic_irqs;
+       domain->nr_irq = gic_irqs - domain->hwirq_base;
+       domain->irq_base = irq_alloc_descs(irq_start, 16, domain->nr_irq,
+                                          numa_node_id());
+       if (IS_ERR_VALUE(domain->irq_base)) {
+               WARN(1, "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
+                    irq_start);
+               domain->irq_base = irq_start;
+       }
+       domain->priv = gic;
+       domain->ops = &gic_irq_domain_ops;
+       irq_domain_add(domain);
  
        gic_chip.flags |= gic_arch_extn.flags;
-       gic_dist_init(gic, irq_start);
+       gic_dist_init(gic);
        gic_cpu_init(gic);
        gic_pm_init(gic);
  }
@@@ -614,3 -644,35 +644,35 @@@ void gic_raise_softirq(const struct cpu
        writel_relaxed(map << 16 | irq, gic_data[0].dist_base + GIC_DIST_SOFTINT);
  }
  #endif
+ #ifdef CONFIG_OF
+ static int gic_cnt __initdata = 0;
+ int __init gic_of_init(struct device_node *node, struct device_node *parent)
+ {
+       void __iomem *cpu_base;
+       void __iomem *dist_base;
+       int irq;
+       struct irq_domain *domain = &gic_data[gic_cnt].domain;
+       if (WARN_ON(!node))
+               return -ENODEV;
+       dist_base = of_iomap(node, 0);
+       WARN(!dist_base, "unable to map gic dist registers\n");
+       cpu_base = of_iomap(node, 1);
+       WARN(!cpu_base, "unable to map gic cpu registers\n");
+       domain->of_node = of_node_get(node);
+       gic_init(gic_cnt, -1, dist_base, cpu_base);
+       if (parent) {
+               irq = irq_of_parse_and_map(node, 0);
+               gic_cascade_irq(gic_cnt, irq);
+       }
+       gic_cnt++;
+       return 0;
+ }
+ #endif
@@@ -182,11 -182,6 +182,11 @@@ config MACH_ECO92
        help
          Select this if you are using the eco920 board
  
 +config MACH_RSI_EWS
 +      bool "RSI Embedded Webserver"
 +      depends on ARCH_AT91RM9200
 +      help
 +        Select this if you are using RSIs EWS board.
  endif
  
  # ----------------------------------------------------------
@@@ -386,14 -381,6 +386,14 @@@ config MACH_GSIA18
          This enables support for the GS_IA18_S board
          produced by GeoSIG Ltd company. This is an internet accelerograph.
          <http://www.geosig.com>
 +
 +config MACH_USB_A9G20
 +      bool "CALAO USB-A9G20"
 +      depends on ARCH_AT91SAM9G20
 +      help
 +        Select this if you are using a Calao Systems USB-A9G20.
 +        <http://www.calao-systems.com>
 +
  endif
  
  if (ARCH_AT91SAM9260 || ARCH_AT91SAM9G20)
@@@ -455,6 -442,17 +455,17 @@@ endi
  
  # ----------------------------------------------------------
  
+ comment "Generic Board Type"
+ config MACH_AT91SAM_DT
+       bool "Atmel AT91SAM Evaluation Kits with device-tree support"
+       select USE_OF
+       help
+         Select this if you want to experiment device-tree with
+         an Atmel Evaluation Kit.
+ # ----------------------------------------------------------
  comment "AT91 Board Options"
  
  config MTD_AT91_DATAFLASH_CARD
@@@ -36,13 -36,12 +36,13 @@@ obj-$(CONFIG_MACH_ECBAT91) += board-ecb
  obj-$(CONFIG_MACH_YL9200)     += board-yl-9200.o
  obj-$(CONFIG_MACH_CPUAT91)    += board-cpuat91.o
  obj-$(CONFIG_MACH_ECO920)     += board-eco920.o
 +obj-$(CONFIG_MACH_RSI_EWS)    += board-rsi-ews.o
  
  # AT91SAM9260 board-specific support
  obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
  obj-$(CONFIG_MACH_CAM60)      += board-cam60.o
  obj-$(CONFIG_MACH_SAM9_L9260) += board-sam9-l9260.o
 -obj-$(CONFIG_MACH_USB_A9260)  += board-usb-a9260.o
 +obj-$(CONFIG_MACH_USB_A9260)  += board-usb-a926x.o
  obj-$(CONFIG_MACH_QIL_A9260)  += board-qil-a9260.o
  obj-$(CONFIG_MACH_AFEB9260)   += board-afeb-9260v1.o
  obj-$(CONFIG_MACH_CPU9260)    += board-cpu9krea.o
@@@ -54,7 -53,7 +54,7 @@@ obj-$(CONFIG_MACH_AT91SAM9G10EK) += boa
  
  # AT91SAM9263 board-specific support
  obj-$(CONFIG_MACH_AT91SAM9263EK) += board-sam9263ek.o
 -obj-$(CONFIG_MACH_USB_A9263)  += board-usb-a9263.o
 +obj-$(CONFIG_MACH_USB_A9263)  += board-usb-a926x.o
  obj-$(CONFIG_MACH_NEOCORE926) += board-neocore926.o
  
  # AT91SAM9RL board-specific support
@@@ -68,7 -67,6 +68,7 @@@ obj-$(CONFIG_MACH_STAMP9G20)  += board-s
  obj-$(CONFIG_MACH_PORTUXG20)  += board-stamp9g20.o
  obj-$(CONFIG_MACH_PCONTROL_G20)       += board-pcontrol-g20.o board-stamp9g20.o
  obj-$(CONFIG_MACH_GSIA18S)    += board-gsia18s.o board-stamp9g20.o
 +obj-$(CONFIG_MACH_USB_A9G20)  += board-usb-a926x.o
  
  # AT91SAM9260/AT91SAM9G20 board-specific support
  obj-$(CONFIG_MACH_SNAPPER_9260)       += board-snapper9260.o
@@@ -76,6 -74,9 +76,9 @@@
  # AT91SAM9G45 board-specific support
  obj-$(CONFIG_MACH_AT91SAM9M10G45EK) += board-sam9m10g45ek.o
  
+ # AT91SAM board with device-tree
+ obj-$(CONFIG_MACH_AT91SAM_DT) += board-dt.o
  # AT91CAP9 board-specific support
  obj-$(CONFIG_MACH_AT91CAP9ADK)        += board-cap9adk.o
  
@@@ -4,15 -4,17 +4,17 @@@
  #   INITRD_PHYS must be in RAM
  
  ifeq ($(CONFIG_ARCH_AT91CAP9),y)
 -   zreladdr-y := 0x70008000
 +   zreladdr-y += 0x70008000
  params_phys-y := 0x70000100
  initrd_phys-y := 0x70410000
  else ifeq ($(CONFIG_ARCH_AT91SAM9G45),y)
 -   zreladdr-y := 0x70008000
 +   zreladdr-y += 0x70008000
  params_phys-y := 0x70000100
  initrd_phys-y := 0x70410000
  else
 -   zreladdr-y := 0x20008000
 +   zreladdr-y += 0x20008000
  params_phys-y := 0x20000100
  initrd_phys-y := 0x20410000
  endif
+ dtb-$(CONFIG_MACH_AT91SAM_DT) += at91sam9m10g45ek.dtb usb_a9g20.dtb
@@@ -199,8 -199,14 +199,16 @@@ static struct clk_lookup periph_clocks_
        CLKDEV_CON_DEV_ID("t4_clk", "atmel_tcb.1", &tc4_clk),
        CLKDEV_CON_DEV_ID("t5_clk", "atmel_tcb.1", &tc5_clk),
        CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk),
+       /* more usart lookup table for DT entries */
+       CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
+       CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk),
+       CLKDEV_CON_DEV_ID("usart", "fffb4000.serial", &usart1_clk),
+       CLKDEV_CON_DEV_ID("usart", "fffb8000.serial", &usart2_clk),
+       CLKDEV_CON_DEV_ID("usart", "fffd0000.serial", &usart3_clk),
+       CLKDEV_CON_DEV_ID("usart", "fffd4000.serial", &usart4_clk),
+       CLKDEV_CON_DEV_ID("usart", "fffd8000.serial", &usart5_clk),
 +      /* fake hclk clock */
 +      CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
  };
  
  static struct clk_lookup usart_clocks_lookups[] = {
@@@ -54,11 -54,6 +54,11 @@@ static struct clk pioDE_clk = 
        .pmc_mask       = 1 << AT91SAM9G45_ID_PIODE,
        .type           = CLK_TYPE_PERIPHERAL,
  };
 +static struct clk trng_clk = {
 +      .name           = "trng_clk",
 +      .pmc_mask       = 1 << AT91SAM9G45_ID_TRNG,
 +      .type           = CLK_TYPE_PERIPHERAL,
 +};
  static struct clk usart0_clk = {
        .name           = "usart0_clk",
        .pmc_mask       = 1 << AT91SAM9G45_ID_US0,
@@@ -182,7 -177,6 +182,7 @@@ static struct clk *periph_clocks[] __in
        &pioB_clk,
        &pioC_clk,
        &pioDE_clk,
 +      &trng_clk,
        &usart0_clk,
        &usart1_clk,
        &usart2_clk,
@@@ -222,9 -216,12 +222,15 @@@ static struct clk_lookup periph_clocks_
        CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk),
        CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
        CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
 +      CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk),
+       /* more usart lookup table for DT entries */
+       CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck),
+       CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk),
+       CLKDEV_CON_DEV_ID("usart", "fff90000.serial", &usart1_clk),
+       CLKDEV_CON_DEV_ID("usart", "fff94000.serial", &usart2_clk),
+       CLKDEV_CON_DEV_ID("usart", "fff98000.serial", &usart3_clk),
 +      /* fake hclk clock */
 +      CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
  };
  
  static struct clk_lookup usart_clocks_lookups[] = {
diff --combined drivers/of/irq.c
   */
  
  #include <linux/errno.h>
+ #include <linux/list.h>
  #include <linux/module.h>
  #include <linux/of.h>
  #include <linux/of_irq.h>
  #include <linux/string.h>
+ #include <linux/slab.h>
  
  /* For archs that don't support NO_IRQ (such as x86), provide a dummy value */
  #ifndef NO_IRQ
@@@ -58,27 -60,27 +60,27 @@@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map)
   */
  struct device_node *of_irq_find_parent(struct device_node *child)
  {
 -      struct device_node *p;
 +      struct device_node *p, *c = child;
        const __be32 *parp;
  
 -      if (!of_node_get(child))
 +      if (!of_node_get(c))
                return NULL;
  
        do {
 -              parp = of_get_property(child, "interrupt-parent", NULL);
 +              parp = of_get_property(c, "interrupt-parent", NULL);
                if (parp == NULL)
 -                      p = of_get_parent(child);
 +                      p = of_get_parent(c);
                else {
                        if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
                                p = of_node_get(of_irq_dflt_pic);
                        else
                                p = of_find_node_by_phandle(be32_to_cpup(parp));
                }
 -              of_node_put(child);
 -              child = p;
 +              of_node_put(c);
 +              c = p;
        } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
  
 -      return p;
 +      return (p == child) ? NULL : p;
  }
  
  /**
@@@ -386,3 -388,108 +388,108 @@@ int of_irq_to_resource_table(struct dev
  
        return i;
  }
+ struct intc_desc {
+       struct list_head        list;
+       struct device_node      *dev;
+       struct device_node      *interrupt_parent;
+ };
+ /**
+  * of_irq_init - Scan and init matching interrupt controllers in DT
+  * @matches: 0 terminated array of nodes to match and init function to call
+  *
+  * This function scans the device tree for matching interrupt controller nodes,
+  * and calls their initialization functions in order with parents first.
+  */
+ void __init of_irq_init(const struct of_device_id *matches)
+ {
+       struct device_node *np, *parent = NULL;
+       struct intc_desc *desc, *temp_desc;
+       struct list_head intc_desc_list, intc_parent_list;
+       INIT_LIST_HEAD(&intc_desc_list);
+       INIT_LIST_HEAD(&intc_parent_list);
+       for_each_matching_node(np, matches) {
+               if (!of_find_property(np, "interrupt-controller", NULL))
+                       continue;
+               /*
+                * Here, we allocate and populate an intc_desc with the node
+                * pointer, interrupt-parent device_node etc.
+                */
+               desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+               if (WARN_ON(!desc))
+                       goto err;
+               desc->dev = np;
+               desc->interrupt_parent = of_irq_find_parent(np);
+               list_add_tail(&desc->list, &intc_desc_list);
+       }
+       /*
+        * The root irq controller is the one without an interrupt-parent.
+        * That one goes first, followed by the controllers that reference it,
+        * followed by the ones that reference the 2nd level controllers, etc.
+        */
+       while (!list_empty(&intc_desc_list)) {
+               /*
+                * Process all controllers with the current 'parent'.
+                * First pass will be looking for NULL as the parent.
+                * The assumption is that NULL parent means a root controller.
+                */
+               list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
+                       const struct of_device_id *match;
+                       int ret;
+                       of_irq_init_cb_t irq_init_cb;
+                       if (desc->interrupt_parent != parent)
+                               continue;
+                       list_del(&desc->list);
+                       match = of_match_node(matches, desc->dev);
+                       if (WARN(!match->data,
+                           "of_irq_init: no init function for %s\n",
+                           match->compatible)) {
+                               kfree(desc);
+                               continue;
+                       }
+                       pr_debug("of_irq_init: init %s @ %p, parent %p\n",
+                                match->compatible,
+                                desc->dev, desc->interrupt_parent);
+                       irq_init_cb = match->data;
+                       ret = irq_init_cb(desc->dev, desc->interrupt_parent);
+                       if (ret) {
+                               kfree(desc);
+                               continue;
+                       }
+                       /*
+                        * This one is now set up; add it to the parent list so
+                        * its children can get processed in a subsequent pass.
+                        */
+                       list_add_tail(&desc->list, &intc_parent_list);
+               }
+               /* Get the next pending parent that might have children */
+               desc = list_first_entry(&intc_parent_list, typeof(*desc), list);
+               if (list_empty(&intc_parent_list) || !desc) {
+                       pr_err("of_irq_init: children remain, but no parents\n");
+                       break;
+               }
+               list_del(&desc->list);
+               parent = desc->dev;
+               kfree(desc);
+       }
+       list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
+               list_del(&desc->list);
+               kfree(desc);
+       }
+ err:
+       list_for_each_entry_safe(desc, temp_desc, &intc_desc_list, list) {
+               list_del(&desc->list);
+               kfree(desc);
+       }
+ }
@@@ -19,6 -19,7 +19,7 @@@
  # define SUPPORT_SYSRQ
  #endif
  
+ #include <linux/atomic.h>
  #include <linux/hrtimer.h>
  #include <linux/module.h>
  #include <linux/io.h>
@@@ -33,6 -34,8 +34,8 @@@
  #include <linux/clk.h>
  #include <linux/platform_device.h>
  #include <linux/delay.h>
+ #include <linux/of.h>
+ #include <linux/of_device.h>
  
  #include "msm_serial.h"
  
@@@ -589,9 -592,8 +592,8 @@@ static void msm_release_port(struct uar
                iowrite32(GSBI_PROTOCOL_IDLE, msm_port->gsbi_base +
                          GSBI_CONTROL);
  
-               gsbi_resource = platform_get_resource_byname(pdev,
-                                                            IORESOURCE_MEM,
-                                                            "gsbi_resource");
+               gsbi_resource = platform_get_resource(pdev,
+                                                       IORESOURCE_MEM, 1);
  
                if (unlikely(!gsbi_resource))
                        return;
@@@ -612,8 -614,7 +614,7 @@@ static int msm_request_port(struct uart
        resource_size_t size;
        int ret;
  
-       uart_resource = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-                                                    "uart_resource");
+       uart_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (unlikely(!uart_resource))
                return -ENXIO;
  
                goto fail_release_port;
        }
  
-       gsbi_resource = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-                                                    "gsbi_resource");
+       gsbi_resource = platform_get_resource(pdev, IORESOURCE_MEM, 1);
        /* Is this a GSBI-based port? */
        if (gsbi_resource) {
                size = resource_size(gsbi_resource);
@@@ -804,6 -804,8 +804,6 @@@ static int __init msm_console_setup(str
        if (unlikely(!port->membase))
                return -ENXIO;
  
 -      port->cons = co;
 -
        msm_init_clock(port);
  
        if (options)
@@@ -857,6 -859,8 +857,8 @@@ static struct uart_driver msm_uart_driv
        .cons = MSM_CONSOLE,
  };
  
+ static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
  static int __init msm_serial_probe(struct platform_device *pdev)
  {
        struct msm_port *msm_port;
        struct uart_port *port;
        int irq;
  
+       if (pdev->id == -1)
+               pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
        if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
                return -ENXIO;
  
        port->dev = &pdev->dev;
        msm_port = UART_TO_MSM(port);
  
-       if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "gsbi_resource"))
+       if (platform_get_resource(pdev, IORESOURCE_MEM, 1))
                msm_port->is_uartdm = 1;
        else
                msm_port->is_uartdm = 0;
        printk(KERN_INFO "uartclk = %d\n", port->uartclk);
  
  
-       resource = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-                                                    "uart_resource");
+       resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (unlikely(!resource))
                return -ENXIO;
        port->mapbase = resource->start;
@@@ -922,11 -928,17 +926,17 @@@ static int __devexit msm_serial_remove(
        return 0;
  }
  
+ static struct of_device_id msm_match_table[] = {
+       { .compatible = "qcom,msm-uart" },
+       {}
+ };
  static struct platform_driver msm_platform_driver = {
        .remove = msm_serial_remove,
        .driver = {
                .name = "msm_serial",
                .owner = THIS_MODULE,
+               .of_match_table = msm_match_table,
        },
  };