Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Broadcom specific AMBA |
| 3 | * Broadcom MIPS32 74K core driver |
| 4 | * |
| 5 | * Copyright 2009, Broadcom Corporation |
| 6 | * Copyright 2006, 2007, Michael Buesch <mb@bu3sch.de> |
| 7 | * Copyright 2010, Bernhard Loos <bernhardloos@googlemail.com> |
| 8 | * Copyright 2011, Hauke Mehrtens <hauke@hauke-m.de> |
| 9 | * |
| 10 | * Licensed under the GNU/GPL. See COPYING for details. |
| 11 | */ |
| 12 | |
| 13 | #include "bcma_private.h" |
| 14 | |
| 15 | #include <linux/bcma/bcma.h> |
| 16 | |
Rafał Miłecki | 73e4dbe4 | 2013-01-25 11:37:26 +0100 | [diff] [blame] | 17 | #include <linux/mtd/physmap.h> |
| 18 | #include <linux/platform_device.h> |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 19 | #include <linux/serial.h> |
| 20 | #include <linux/serial_core.h> |
| 21 | #include <linux/serial_reg.h> |
| 22 | #include <linux/time.h> |
Rafał Miłecki | 7177efc | 2014-10-28 13:30:23 +0100 | [diff] [blame] | 23 | #ifdef CONFIG_BCM47XX |
Rafał Miłecki | 138173d | 2014-12-01 07:58:18 +0100 | [diff] [blame] | 24 | #include <linux/bcm47xx_nvram.h> |
Rafał Miłecki | 7177efc | 2014-10-28 13:30:23 +0100 | [diff] [blame] | 25 | #endif |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 26 | |
Rafał Miłecki | 87fed55 | 2014-09-03 10:35:13 +0200 | [diff] [blame] | 27 | enum bcma_boot_dev { |
| 28 | BCMA_BOOT_DEV_UNK = 0, |
| 29 | BCMA_BOOT_DEV_ROM, |
| 30 | BCMA_BOOT_DEV_PARALLEL, |
| 31 | BCMA_BOOT_DEV_SERIAL, |
| 32 | BCMA_BOOT_DEV_NAND, |
| 33 | }; |
| 34 | |
Artem Bityutskiy | f1faa69 | 2013-03-12 10:34:50 +0200 | [diff] [blame] | 35 | static const char * const part_probes[] = { "bcm47xxpart", NULL }; |
Rafał Miłecki | 73e4dbe4 | 2013-01-25 11:37:26 +0100 | [diff] [blame] | 36 | |
| 37 | static struct physmap_flash_data bcma_pflash_data = { |
| 38 | .part_probe_types = part_probes, |
| 39 | }; |
| 40 | |
| 41 | static struct resource bcma_pflash_resource = { |
| 42 | .name = "bcma_pflash", |
| 43 | .flags = IORESOURCE_MEM, |
| 44 | }; |
| 45 | |
| 46 | struct platform_device bcma_pflash_dev = { |
| 47 | .name = "physmap-flash", |
| 48 | .dev = { |
| 49 | .platform_data = &bcma_pflash_data, |
| 50 | }, |
| 51 | .resource = &bcma_pflash_resource, |
| 52 | .num_resources = 1, |
| 53 | }; |
| 54 | |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 55 | /* The 47162a0 hangs when reading MIPS DMP registers registers */ |
| 56 | static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev) |
| 57 | { |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 58 | return dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM47162 && |
| 59 | dev->bus->chipinfo.rev == 0 && dev->id.id == BCMA_CORE_MIPS_74K; |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | /* The 5357b0 hangs when reading USB20H DMP registers */ |
| 63 | static inline bool bcma_core_mips_bcm5357b0_quirk(struct bcma_device *dev) |
| 64 | { |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 65 | return (dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 || |
| 66 | dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) && |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 67 | dev->bus->chipinfo.pkg == 11 && |
| 68 | dev->id.id == BCMA_CORE_USB20_HOST; |
| 69 | } |
| 70 | |
| 71 | static inline u32 mips_read32(struct bcma_drv_mips *mcore, |
| 72 | u16 offset) |
| 73 | { |
| 74 | return bcma_read32(mcore->core, offset); |
| 75 | } |
| 76 | |
| 77 | static inline void mips_write32(struct bcma_drv_mips *mcore, |
| 78 | u16 offset, |
| 79 | u32 value) |
| 80 | { |
| 81 | bcma_write32(mcore->core, offset, value); |
| 82 | } |
| 83 | |
| 84 | static const u32 ipsflag_irq_mask[] = { |
| 85 | 0, |
| 86 | BCMA_MIPS_IPSFLAG_IRQ1, |
| 87 | BCMA_MIPS_IPSFLAG_IRQ2, |
| 88 | BCMA_MIPS_IPSFLAG_IRQ3, |
| 89 | BCMA_MIPS_IPSFLAG_IRQ4, |
| 90 | }; |
| 91 | |
| 92 | static const u32 ipsflag_irq_shift[] = { |
| 93 | 0, |
| 94 | BCMA_MIPS_IPSFLAG_IRQ1_SHIFT, |
| 95 | BCMA_MIPS_IPSFLAG_IRQ2_SHIFT, |
| 96 | BCMA_MIPS_IPSFLAG_IRQ3_SHIFT, |
| 97 | BCMA_MIPS_IPSFLAG_IRQ4_SHIFT, |
| 98 | }; |
| 99 | |
| 100 | static u32 bcma_core_mips_irqflag(struct bcma_device *dev) |
| 101 | { |
| 102 | u32 flag; |
| 103 | |
| 104 | if (bcma_core_mips_bcm47162a0_quirk(dev)) |
| 105 | return dev->core_index; |
| 106 | if (bcma_core_mips_bcm5357b0_quirk(dev)) |
| 107 | return dev->core_index; |
| 108 | flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30); |
| 109 | |
Hauke Mehrtens | db5230d | 2013-01-04 00:51:23 +0100 | [diff] [blame] | 110 | if (flag) |
| 111 | return flag & 0x1F; |
| 112 | else |
| 113 | return 0x3f; |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /* Get the MIPS IRQ assignment for a specified device. |
| 117 | * If unassigned, 0 is returned. |
Hauke Mehrtens | db5230d | 2013-01-04 00:51:23 +0100 | [diff] [blame] | 118 | * If disabled, 5 is returned. |
| 119 | * If not supported, 6 is returned. |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 120 | */ |
Hauke Mehrtens | 85eb92e | 2014-11-01 16:54:55 +0100 | [diff] [blame] | 121 | unsigned int bcma_core_mips_irq(struct bcma_device *dev) |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 122 | { |
| 123 | struct bcma_device *mdev = dev->bus->drv_mips.core; |
| 124 | u32 irqflag; |
| 125 | unsigned int irq; |
| 126 | |
| 127 | irqflag = bcma_core_mips_irqflag(dev); |
Hauke Mehrtens | db5230d | 2013-01-04 00:51:23 +0100 | [diff] [blame] | 128 | if (irqflag == 0x3f) |
| 129 | return 6; |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 130 | |
Hauke Mehrtens | db5230d | 2013-01-04 00:51:23 +0100 | [diff] [blame] | 131 | for (irq = 0; irq <= 4; irq++) |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 132 | if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) & |
| 133 | (1 << irqflag)) |
| 134 | return irq; |
| 135 | |
Hauke Mehrtens | db5230d | 2013-01-04 00:51:23 +0100 | [diff] [blame] | 136 | return 5; |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 137 | } |
Nathan Hintz | e2aa19f | 2013-01-10 17:54:09 +0100 | [diff] [blame] | 138 | |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 139 | static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq) |
| 140 | { |
| 141 | unsigned int oldirq = bcma_core_mips_irq(dev); |
| 142 | struct bcma_bus *bus = dev->bus; |
| 143 | struct bcma_device *mdev = bus->drv_mips.core; |
| 144 | u32 irqflag; |
| 145 | |
| 146 | irqflag = bcma_core_mips_irqflag(dev); |
| 147 | BUG_ON(oldirq == 6); |
| 148 | |
| 149 | dev->irq = irq + 2; |
| 150 | |
| 151 | /* clear the old irq */ |
| 152 | if (oldirq == 0) |
| 153 | bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0), |
| 154 | bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) & |
| 155 | ~(1 << irqflag)); |
Hauke Mehrtens | db5230d | 2013-01-04 00:51:23 +0100 | [diff] [blame] | 156 | else if (oldirq != 5) |
Rafał Miłecki | cbbc013 | 2012-12-10 07:53:56 +0100 | [diff] [blame] | 157 | bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(oldirq), 0); |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 158 | |
| 159 | /* assign the new one */ |
| 160 | if (irq == 0) { |
| 161 | bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0), |
| 162 | bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) | |
| 163 | (1 << irqflag)); |
| 164 | } else { |
Hauke Mehrtens | 6ba1eaf | 2013-01-04 00:51:25 +0100 | [diff] [blame] | 165 | u32 irqinitmask = bcma_read32(mdev, |
| 166 | BCMA_MIPS_MIPS74K_INTMASK(irq)); |
| 167 | if (irqinitmask) { |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 168 | struct bcma_device *core; |
| 169 | |
| 170 | /* backplane irq line is in use, find out who uses |
| 171 | * it and set user to irq 0 |
| 172 | */ |
Hauke Mehrtens | d8f1bd2 | 2012-07-26 17:44:12 +0200 | [diff] [blame] | 173 | list_for_each_entry(core, &bus->cores, list) { |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 174 | if ((1 << bcma_core_mips_irqflag(core)) == |
Hauke Mehrtens | 6ba1eaf | 2013-01-04 00:51:25 +0100 | [diff] [blame] | 175 | irqinitmask) { |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 176 | bcma_core_mips_set_irq(core, 0); |
| 177 | break; |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq), |
| 182 | 1 << irqflag); |
| 183 | } |
| 184 | |
Hauke Mehrtens | 7401cb6 | 2013-01-04 00:51:22 +0100 | [diff] [blame] | 185 | bcma_debug(bus, "set_irq: core 0x%04x, irq %d => %d\n", |
Hauke Mehrtens | db5230d | 2013-01-04 00:51:23 +0100 | [diff] [blame] | 186 | dev->id.id, oldirq <= 4 ? oldirq + 2 : 0, irq + 2); |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 187 | } |
| 188 | |
Hauke Mehrtens | e3f05a4 | 2013-01-04 00:51:21 +0100 | [diff] [blame] | 189 | static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq, |
| 190 | u16 coreid, u8 unit) |
| 191 | { |
| 192 | struct bcma_device *core; |
| 193 | |
| 194 | core = bcma_find_core_unit(bus, coreid, unit); |
| 195 | if (!core) { |
| 196 | bcma_warn(bus, |
| 197 | "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n", |
| 198 | coreid, unit); |
| 199 | return; |
| 200 | } |
| 201 | |
| 202 | bcma_core_mips_set_irq(core, irq); |
| 203 | } |
| 204 | |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 205 | static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq) |
| 206 | { |
| 207 | int i; |
| 208 | static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"}; |
Hauke Mehrtens | 7401cb6 | 2013-01-04 00:51:22 +0100 | [diff] [blame] | 209 | printk(KERN_DEBUG KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id); |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 210 | for (i = 0; i <= 6; i++) |
| 211 | printk(" %s%s", irq_name[i], i == irq ? "*" : " "); |
| 212 | printk("\n"); |
| 213 | } |
| 214 | |
| 215 | static void bcma_core_mips_dump_irq(struct bcma_bus *bus) |
| 216 | { |
| 217 | struct bcma_device *core; |
| 218 | |
Hauke Mehrtens | d8f1bd2 | 2012-07-26 17:44:12 +0200 | [diff] [blame] | 219 | list_for_each_entry(core, &bus->cores, list) { |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 220 | bcma_core_mips_print_irq(core, bcma_core_mips_irq(core)); |
| 221 | } |
| 222 | } |
| 223 | |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 224 | u32 bcma_cpu_clock(struct bcma_drv_mips *mcore) |
| 225 | { |
| 226 | struct bcma_bus *bus = mcore->core->bus; |
| 227 | |
| 228 | if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU) |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 229 | return bcma_pmu_get_cpu_clock(&bus->drv_cc); |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 230 | |
Rafał Miłecki | 3d9d8af | 2012-07-05 22:07:32 +0200 | [diff] [blame] | 231 | bcma_err(bus, "No PMU available, need this to get the cpu clock\n"); |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 232 | return 0; |
| 233 | } |
| 234 | EXPORT_SYMBOL(bcma_cpu_clock); |
| 235 | |
Rafał Miłecki | 87fed55 | 2014-09-03 10:35:13 +0200 | [diff] [blame] | 236 | static enum bcma_boot_dev bcma_boot_dev(struct bcma_bus *bus) |
| 237 | { |
| 238 | struct bcma_drv_cc *cc = &bus->drv_cc; |
| 239 | u8 cc_rev = cc->core->id.rev; |
| 240 | |
| 241 | if (cc_rev == 42) { |
| 242 | struct bcma_device *core; |
| 243 | |
| 244 | core = bcma_find_core(bus, BCMA_CORE_NS_ROM); |
| 245 | if (core) { |
| 246 | switch (bcma_aread32(core, BCMA_IOST) & |
| 247 | BCMA_NS_ROM_IOST_BOOT_DEV_MASK) { |
| 248 | case BCMA_NS_ROM_IOST_BOOT_DEV_NOR: |
| 249 | return BCMA_BOOT_DEV_SERIAL; |
| 250 | case BCMA_NS_ROM_IOST_BOOT_DEV_NAND: |
| 251 | return BCMA_BOOT_DEV_NAND; |
| 252 | case BCMA_NS_ROM_IOST_BOOT_DEV_ROM: |
| 253 | default: |
| 254 | return BCMA_BOOT_DEV_ROM; |
| 255 | } |
| 256 | } |
| 257 | } else { |
| 258 | if (cc_rev == 38) { |
| 259 | if (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT) |
| 260 | return BCMA_BOOT_DEV_NAND; |
| 261 | else if (cc->status & BIT(5)) |
| 262 | return BCMA_BOOT_DEV_ROM; |
| 263 | } |
| 264 | |
| 265 | if ((cc->capabilities & BCMA_CC_CAP_FLASHT) == |
| 266 | BCMA_CC_FLASHT_PARA) |
| 267 | return BCMA_BOOT_DEV_PARALLEL; |
| 268 | else |
| 269 | return BCMA_BOOT_DEV_SERIAL; |
| 270 | } |
| 271 | |
| 272 | return BCMA_BOOT_DEV_SERIAL; |
| 273 | } |
| 274 | |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 275 | static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore) |
| 276 | { |
| 277 | struct bcma_bus *bus = mcore->core->bus; |
Hauke Mehrtens | 3c25ddd | 2012-09-29 20:33:52 +0200 | [diff] [blame] | 278 | struct bcma_drv_cc *cc = &bus->drv_cc; |
Rafał Miłecki | 73e4dbe4 | 2013-01-25 11:37:26 +0100 | [diff] [blame] | 279 | struct bcma_pflash *pflash = &cc->pflash; |
Rafał Miłecki | 87fed55 | 2014-09-03 10:35:13 +0200 | [diff] [blame] | 280 | enum bcma_boot_dev boot_dev; |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 281 | |
Hauke Mehrtens | 3c25ddd | 2012-09-29 20:33:52 +0200 | [diff] [blame] | 282 | switch (cc->capabilities & BCMA_CC_CAP_FLASHT) { |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 283 | case BCMA_CC_FLASHT_STSER: |
| 284 | case BCMA_CC_FLASHT_ATSER: |
Rafał Miłecki | 23cb3b2 | 2012-07-17 16:26:41 +0200 | [diff] [blame] | 285 | bcma_debug(bus, "Found serial flash\n"); |
Hauke Mehrtens | 3c25ddd | 2012-09-29 20:33:52 +0200 | [diff] [blame] | 286 | bcma_sflash_init(cc); |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 287 | break; |
| 288 | case BCMA_CC_FLASHT_PARA: |
Rafał Miłecki | 23cb3b2 | 2012-07-17 16:26:41 +0200 | [diff] [blame] | 289 | bcma_debug(bus, "Found parallel flash\n"); |
Rafał Miłecki | 73e4dbe4 | 2013-01-25 11:37:26 +0100 | [diff] [blame] | 290 | pflash->present = true; |
| 291 | pflash->window = BCMA_SOC_FLASH2; |
| 292 | pflash->window_size = BCMA_SOC_FLASH2_SZ; |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 293 | |
Hauke Mehrtens | 3c25ddd | 2012-09-29 20:33:52 +0200 | [diff] [blame] | 294 | if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) & |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 295 | BCMA_CC_FLASH_CFG_DS) == 0) |
Rafał Miłecki | 73e4dbe4 | 2013-01-25 11:37:26 +0100 | [diff] [blame] | 296 | pflash->buswidth = 1; |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 297 | else |
Rafał Miłecki | 73e4dbe4 | 2013-01-25 11:37:26 +0100 | [diff] [blame] | 298 | pflash->buswidth = 2; |
| 299 | |
| 300 | bcma_pflash_data.width = pflash->buswidth; |
| 301 | bcma_pflash_resource.start = pflash->window; |
| 302 | bcma_pflash_resource.end = pflash->window + pflash->window_size; |
| 303 | |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 304 | break; |
| 305 | default: |
Rafał Miłecki | 23cb3b2 | 2012-07-17 16:26:41 +0200 | [diff] [blame] | 306 | bcma_err(bus, "Flash type not supported\n"); |
| 307 | } |
| 308 | |
Hauke Mehrtens | 3c25ddd | 2012-09-29 20:33:52 +0200 | [diff] [blame] | 309 | if (cc->core->id.rev == 38 || |
Rafał Miłecki | 23cb3b2 | 2012-07-17 16:26:41 +0200 | [diff] [blame] | 310 | bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) { |
Hauke Mehrtens | 3c25ddd | 2012-09-29 20:33:52 +0200 | [diff] [blame] | 311 | if (cc->capabilities & BCMA_CC_CAP_NFLASH) { |
Rafał Miłecki | 23cb3b2 | 2012-07-17 16:26:41 +0200 | [diff] [blame] | 312 | bcma_debug(bus, "Found NAND flash\n"); |
Hauke Mehrtens | 3c25ddd | 2012-09-29 20:33:52 +0200 | [diff] [blame] | 313 | bcma_nflash_init(cc); |
Rafał Miłecki | 23cb3b2 | 2012-07-17 16:26:41 +0200 | [diff] [blame] | 314 | } |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 315 | } |
Rafał Miłecki | 87fed55 | 2014-09-03 10:35:13 +0200 | [diff] [blame] | 316 | |
| 317 | /* Determine flash type this SoC boots from */ |
| 318 | boot_dev = bcma_boot_dev(bus); |
| 319 | switch (boot_dev) { |
| 320 | case BCMA_BOOT_DEV_PARALLEL: |
| 321 | case BCMA_BOOT_DEV_SERIAL: |
Rafał Miłecki | 7177efc | 2014-10-28 13:30:23 +0100 | [diff] [blame] | 322 | #ifdef CONFIG_BCM47XX |
| 323 | bcm47xx_nvram_init_from_mem(BCMA_SOC_FLASH2, |
| 324 | BCMA_SOC_FLASH2_SZ); |
| 325 | #endif |
Rafał Miłecki | 87fed55 | 2014-09-03 10:35:13 +0200 | [diff] [blame] | 326 | break; |
| 327 | case BCMA_BOOT_DEV_NAND: |
Rafał Miłecki | 7177efc | 2014-10-28 13:30:23 +0100 | [diff] [blame] | 328 | #ifdef CONFIG_BCM47XX |
| 329 | bcm47xx_nvram_init_from_mem(BCMA_SOC_FLASH1, |
| 330 | BCMA_SOC_FLASH1_SZ); |
| 331 | #endif |
Rafał Miłecki | 87fed55 | 2014-09-03 10:35:13 +0200 | [diff] [blame] | 332 | break; |
| 333 | default: |
| 334 | break; |
| 335 | } |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 336 | } |
| 337 | |
Hauke Mehrtens | 49655bb | 2012-09-29 20:29:49 +0200 | [diff] [blame] | 338 | void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) |
| 339 | { |
| 340 | struct bcma_bus *bus = mcore->core->bus; |
| 341 | |
| 342 | if (mcore->early_setup_done) |
| 343 | return; |
| 344 | |
| 345 | bcma_chipco_serial_init(&bus->drv_cc); |
| 346 | bcma_core_mips_flash_detect(mcore); |
| 347 | |
| 348 | mcore->early_setup_done = true; |
| 349 | } |
| 350 | |
Nathan Hintz | 6bf2e54 | 2013-01-11 22:07:22 -0800 | [diff] [blame] | 351 | static void bcma_fix_i2s_irqflag(struct bcma_bus *bus) |
| 352 | { |
| 353 | struct bcma_device *cpu, *pcie, *i2s; |
| 354 | |
| 355 | /* Fixup the interrupts in 4716/4748 for i2s core (2010 Broadcom SDK) |
| 356 | * (IRQ flags > 7 are ignored when setting the interrupt masks) |
| 357 | */ |
| 358 | if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4716 && |
| 359 | bus->chipinfo.id != BCMA_CHIP_ID_BCM4748) |
| 360 | return; |
| 361 | |
| 362 | cpu = bcma_find_core(bus, BCMA_CORE_MIPS_74K); |
| 363 | pcie = bcma_find_core(bus, BCMA_CORE_PCIE); |
| 364 | i2s = bcma_find_core(bus, BCMA_CORE_I2S); |
| 365 | if (cpu && pcie && i2s && |
| 366 | bcma_aread32(cpu, BCMA_MIPS_OOBSELINA74) == 0x08060504 && |
| 367 | bcma_aread32(pcie, BCMA_MIPS_OOBSELINA74) == 0x08060504 && |
| 368 | bcma_aread32(i2s, BCMA_MIPS_OOBSELOUTA30) == 0x88) { |
| 369 | bcma_awrite32(cpu, BCMA_MIPS_OOBSELINA74, 0x07060504); |
| 370 | bcma_awrite32(pcie, BCMA_MIPS_OOBSELINA74, 0x07060504); |
| 371 | bcma_awrite32(i2s, BCMA_MIPS_OOBSELOUTA30, 0x87); |
| 372 | bcma_debug(bus, |
| 373 | "Moved i2s interrupt to oob line 7 instead of 8\n"); |
| 374 | } |
| 375 | } |
| 376 | |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 377 | void bcma_core_mips_init(struct bcma_drv_mips *mcore) |
| 378 | { |
| 379 | struct bcma_bus *bus; |
| 380 | struct bcma_device *core; |
| 381 | bus = mcore->core->bus; |
| 382 | |
Hauke Mehrtens | 49655bb | 2012-09-29 20:29:49 +0200 | [diff] [blame] | 383 | if (mcore->setup_done) |
| 384 | return; |
| 385 | |
Hauke Mehrtens | 7401cb6 | 2013-01-04 00:51:22 +0100 | [diff] [blame] | 386 | bcma_debug(bus, "Initializing MIPS core...\n"); |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 387 | |
Hauke Mehrtens | 49655bb | 2012-09-29 20:29:49 +0200 | [diff] [blame] | 388 | bcma_core_mips_early_init(mcore); |
| 389 | |
Nathan Hintz | 6bf2e54 | 2013-01-11 22:07:22 -0800 | [diff] [blame] | 390 | bcma_fix_i2s_irqflag(bus); |
| 391 | |
Hauke Mehrtens | e3f05a4 | 2013-01-04 00:51:21 +0100 | [diff] [blame] | 392 | switch (bus->chipinfo.id) { |
| 393 | case BCMA_CHIP_ID_BCM4716: |
| 394 | case BCMA_CHIP_ID_BCM4748: |
| 395 | bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0); |
| 396 | bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0); |
| 397 | bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0); |
| 398 | bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_PCIE, 0); |
| 399 | bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0); |
| 400 | bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0); |
| 401 | break; |
| 402 | case BCMA_CHIP_ID_BCM5356: |
| 403 | case BCMA_CHIP_ID_BCM47162: |
| 404 | case BCMA_CHIP_ID_BCM53572: |
| 405 | bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0); |
| 406 | bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0); |
| 407 | bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0); |
| 408 | break; |
| 409 | case BCMA_CHIP_ID_BCM5357: |
| 410 | case BCMA_CHIP_ID_BCM4749: |
| 411 | bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0); |
| 412 | bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0); |
| 413 | bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0); |
| 414 | bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0); |
| 415 | bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0); |
| 416 | break; |
| 417 | case BCMA_CHIP_ID_BCM4706: |
| 418 | bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_PCIE, 0); |
| 419 | bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_4706_MAC_GBIT, |
| 420 | 0); |
| 421 | bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_PCIE, 1); |
| 422 | bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_USB20_HOST, 0); |
| 423 | bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_4706_CHIPCOMMON, |
| 424 | 0); |
| 425 | break; |
| 426 | default: |
| 427 | list_for_each_entry(core, &bus->cores, list) { |
Hauke Mehrtens | 85eb92e | 2014-11-01 16:54:55 +0100 | [diff] [blame] | 428 | core->irq = bcma_core_irq(core, 0); |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 429 | } |
Hauke Mehrtens | e3f05a4 | 2013-01-04 00:51:21 +0100 | [diff] [blame] | 430 | bcma_err(bus, |
| 431 | "Unknown device (0x%x) found, can not configure IRQs\n", |
| 432 | bus->chipinfo.id); |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 433 | } |
Hauke Mehrtens | 7401cb6 | 2013-01-04 00:51:22 +0100 | [diff] [blame] | 434 | bcma_debug(bus, "IRQ reconfiguration done\n"); |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 435 | bcma_core_mips_dump_irq(bus); |
| 436 | |
Hauke Mehrtens | 21e0534 | 2011-07-23 01:20:09 +0200 | [diff] [blame] | 437 | mcore->setup_done = true; |
| 438 | } |