brcm47xx: improve IRQ handling for bcma based devices
[openwrt.git] / target / linux / brcm47xx / patches-3.6 / 181-bcma-explicit-assigne-irq-numbers.patch
diff --git a/target/linux/brcm47xx/patches-3.6/181-bcma-explicit-assigne-irq-numbers.patch b/target/linux/brcm47xx/patches-3.6/181-bcma-explicit-assigne-irq-numbers.patch
new file mode 100644 (file)
index 0000000..7fac415
--- /dev/null
@@ -0,0 +1,109 @@
+--- a/drivers/bcma/driver_mips.c
++++ b/drivers/bcma/driver_mips.c
+@@ -148,6 +148,22 @@ static void bcma_core_mips_set_irq(struc
+                 dev->id.id, oldirq + 2, irq + 2);
+ }
++static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq,
++                                      u16 coreid, u8 unit)
++{
++      struct bcma_device *core;
++
++      core = bcma_find_core_unit(bus, coreid, unit);
++      if (!core) {
++              bcma_warn(bus,
++                        "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n",
++                        coreid, unit);
++              return;
++      }
++
++      bcma_core_mips_set_irq(core, irq);
++}
++
+ static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
+ {
+       int i;
+@@ -247,7 +263,8 @@ void bcma_core_mips_early_init(struct bc
+ void bcma_core_mips_init(struct bcma_drv_mips *mcore)
+ {
+       struct bcma_bus *bus;
+-      struct bcma_device *core;
++      int irq;
++
+       bus = mcore->core->bus;
+       if (mcore->setup_done)
+@@ -259,35 +276,44 @@ void bcma_core_mips_init(struct bcma_drv
+       mcore->assigned_irqs = 1;
+-      /* Assign IRQs to all cores on the bus */
+-      list_for_each_entry(core, &bus->cores, list) {
+-              int mips_irq;
+-              if (core->irq)
+-                      continue;
+-
+-              mips_irq = bcma_core_mips_irq(core);
+-              if (mips_irq > 4)
+-                      core->irq = 0;
+-              else
+-                      core->irq = mips_irq + 2;
+-              if (core->irq > 5)
+-                      continue;
+-              switch (core->id.id) {
+-              case BCMA_CORE_PCI:
+-              case BCMA_CORE_PCIE:
+-              case BCMA_CORE_ETHERNET:
+-              case BCMA_CORE_ETHERNET_GBIT:
+-              case BCMA_CORE_MAC_GBIT:
+-              case BCMA_CORE_80211:
+-              case BCMA_CORE_USB20_HOST:
+-                      /* These devices get their own IRQ line if available,
+-                       * the rest goes on IRQ0
+-                       */
+-                      if (mcore->assigned_irqs <= 4)
+-                              bcma_core_mips_set_irq(core,
+-                                                     mcore->assigned_irqs++);
+-                      break;
+-              }
++      switch (bus->chipinfo.id) {
++      case BCMA_CHIP_ID_BCM4716:
++      case BCMA_CHIP_ID_BCM4748:
++              bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
++              bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
++              bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
++              bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_PCIE, 0);
++              bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
++              bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
++              break;
++      case BCMA_CHIP_ID_BCM5356:
++      case BCMA_CHIP_ID_BCM47162:
++      case BCMA_CHIP_ID_BCM53572:
++              bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
++              bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
++              bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
++              break;
++      case BCMA_CHIP_ID_BCM5357:
++      case BCMA_CHIP_ID_BCM4749:
++              bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
++              bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
++              bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
++              bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
++              bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
++              break;
++      case BCMA_CHIP_ID_BCM4706:
++              bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_PCIE, 0);
++              bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_4706_MAC_GBIT,
++                                          0);
++              bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_PCIE, 1);
++              bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_USB20_HOST, 0);
++              bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_4706_CHIPCOMMON,
++                                          0);
++              break;
++      default:
++              bcma_err(bus,
++                       "Unknown device (0x%x) found, can not configure IRQs\n",
++                       bus->chipinfo.id);
+       }
+       bcma_info(bus, "IRQ reconfiguration done\n");
+       bcma_core_mips_dump_irq(bus);