]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/bcma/driver_mips.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless
[karo-tx-linux.git] / drivers / bcma / driver_mips.c
index c6d7be33b972a4a701e3c170b187b288ee5d9adb..9a7f0e3ab5a33fbb012a5c2f74145cc47c346dcd 100644 (file)
 
 #include <linux/bcma/bcma.h>
 
+#include <linux/mtd/physmap.h>
+#include <linux/platform_device.h>
 #include <linux/serial.h>
 #include <linux/serial_core.h>
 #include <linux/serial_reg.h>
 #include <linux/time.h>
 
+static const char *part_probes[] = { "bcm47xxpart", NULL };
+
+static struct physmap_flash_data bcma_pflash_data = {
+       .part_probe_types       = part_probes,
+};
+
+static struct resource bcma_pflash_resource = {
+       .name   = "bcma_pflash",
+       .flags  = IORESOURCE_MEM,
+};
+
+struct platform_device bcma_pflash_dev = {
+       .name           = "physmap-flash",
+       .dev            = {
+               .platform_data  = &bcma_pflash_data,
+       },
+       .resource       = &bcma_pflash_resource,
+       .num_resources  = 1,
+};
+
 /* The 47162a0 hangs when reading MIPS DMP registers registers */
 static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
 {
@@ -85,7 +107,7 @@ static u32 bcma_core_mips_irqflag(struct bcma_device *dev)
  * If disabled, 5 is returned.
  * If not supported, 6 is returned.
  */
-unsigned int bcma_core_mips_irq(struct bcma_device *dev)
+static unsigned int bcma_core_mips_irq(struct bcma_device *dev)
 {
        struct bcma_device *mdev = dev->bus->drv_mips.core;
        u32 irqflag;
@@ -102,7 +124,13 @@ unsigned int bcma_core_mips_irq(struct bcma_device *dev)
 
        return 5;
 }
-EXPORT_SYMBOL(bcma_core_mips_irq);
+
+unsigned int bcma_core_irq(struct bcma_device *dev)
+{
+       unsigned int mips_irq = bcma_core_mips_irq(dev);
+       return mips_irq <= 4 ? mips_irq + 2 : 0;
+}
+EXPORT_SYMBOL(bcma_core_irq);
 
 static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
 {
@@ -130,9 +158,9 @@ static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
                            bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
                            (1 << irqflag));
        } else {
-               u32 oldirqflag = bcma_read32(mdev,
-                                            BCMA_MIPS_MIPS74K_INTMASK(irq));
-               if (oldirqflag) {
+               u32 irqinitmask = bcma_read32(mdev,
+                                             BCMA_MIPS_MIPS74K_INTMASK(irq));
+               if (irqinitmask) {
                        struct bcma_device *core;
 
                        /* backplane irq line is in use, find out who uses
@@ -140,7 +168,7 @@ static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
                         */
                        list_for_each_entry(core, &bus->cores, list) {
                                if ((1 << bcma_core_mips_irqflag(core)) ==
-                                   oldirqflag) {
+                                   irqinitmask) {
                                        bcma_core_mips_set_irq(core, 0);
                                        break;
                                }
@@ -205,6 +233,7 @@ static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
 {
        struct bcma_bus *bus = mcore->core->bus;
        struct bcma_drv_cc *cc = &bus->drv_cc;
+       struct bcma_pflash *pflash = &cc->pflash;
 
        switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
        case BCMA_CC_FLASHT_STSER:
@@ -214,15 +243,20 @@ static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
                break;
        case BCMA_CC_FLASHT_PARA:
                bcma_debug(bus, "Found parallel flash\n");
-               cc->pflash.present = true;
-               cc->pflash.window = BCMA_SOC_FLASH2;
-               cc->pflash.window_size = BCMA_SOC_FLASH2_SZ;
+               pflash->present = true;
+               pflash->window = BCMA_SOC_FLASH2;
+               pflash->window_size = BCMA_SOC_FLASH2_SZ;
 
                if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) &
                     BCMA_CC_FLASH_CFG_DS) == 0)
-                       cc->pflash.buswidth = 1;
+                       pflash->buswidth = 1;
                else
-                       cc->pflash.buswidth = 2;
+                       pflash->buswidth = 2;
+
+               bcma_pflash_data.width = pflash->buswidth;
+               bcma_pflash_resource.start = pflash->window;
+               bcma_pflash_resource.end = pflash->window + pflash->window_size;
+
                break;
        default:
                bcma_err(bus, "Flash type not supported\n");
@@ -250,6 +284,32 @@ void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
        mcore->early_setup_done = true;
 }
 
+static void bcma_fix_i2s_irqflag(struct bcma_bus *bus)
+{
+       struct bcma_device *cpu, *pcie, *i2s;
+
+       /* Fixup the interrupts in 4716/4748 for i2s core (2010 Broadcom SDK)
+        * (IRQ flags > 7 are ignored when setting the interrupt masks)
+        */
+       if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4716 &&
+           bus->chipinfo.id != BCMA_CHIP_ID_BCM4748)
+               return;
+
+       cpu = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
+       pcie = bcma_find_core(bus, BCMA_CORE_PCIE);
+       i2s = bcma_find_core(bus, BCMA_CORE_I2S);
+       if (cpu && pcie && i2s &&
+           bcma_aread32(cpu, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
+           bcma_aread32(pcie, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
+           bcma_aread32(i2s, BCMA_MIPS_OOBSELOUTA30) == 0x88) {
+               bcma_awrite32(cpu, BCMA_MIPS_OOBSELINA74, 0x07060504);
+               bcma_awrite32(pcie, BCMA_MIPS_OOBSELINA74, 0x07060504);
+               bcma_awrite32(i2s, BCMA_MIPS_OOBSELOUTA30, 0x87);
+               bcma_debug(bus,
+                          "Moved i2s interrupt to oob line 7 instead of 8\n");
+       }
+}
+
 void bcma_core_mips_init(struct bcma_drv_mips *mcore)
 {
        struct bcma_bus *bus;
@@ -263,6 +323,8 @@ void bcma_core_mips_init(struct bcma_drv_mips *mcore)
 
        bcma_core_mips_early_init(mcore);
 
+       bcma_fix_i2s_irqflag(bus);
+
        switch (bus->chipinfo.id) {
        case BCMA_CHIP_ID_BCM4716:
        case BCMA_CHIP_ID_BCM4748: