Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mips: bmips: setup: make CBR address configurable

Add support to provide CBR address from DT to handle broken
SoC/Bootloader that doesn't correctly init it. This permits to use the
RAC flush even in these condition.

To provide a CBR address from DT, the property "brcm,bmips-cbr-reg"
needs to be set in the "cpus" node. On DT init, this property presence
will be checked and will set the bmips_cbr_addr value accordingly. Also
bmips_rac_flush_disable will be set to false as RAC flush can be
correctly supported.

The CBR address from DT will overwrite the cached one and the
one set in the CBR register will be ignored.

Also the DT CBR address is validated on being outside DRAM window.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Christian Marangi and committed by
Thomas Bogendoerfer
b95b30e5 3de96d81

+38 -4
+5 -1
arch/mips/bcm47xx/setup.c
··· 46 46 #include <bcm47xx.h> 47 47 #include <bcm47xx_board.h> 48 48 49 - /* CBR addr doesn't change and we can cache it */ 49 + /* 50 + * CBR addr doesn't change and we can cache it. 51 + * For broken SoC/Bootloader CBR addr might also be provided via DT 52 + * with "brcm,bmips-cbr-reg" in the "cpus" node. 53 + */ 50 54 void __iomem *bmips_cbr_addr __read_mostly; 51 55 52 56 union bcm47xx_bus bcm47xx_bus;
+5 -1
arch/mips/bcm63xx/setup.c
··· 23 23 #include <bcm63xx_io.h> 24 24 #include <bcm63xx_gpio.h> 25 25 26 - /* CBR addr doesn't change and we can cache it */ 26 + /* 27 + * CBR addr doesn't change and we can cache it. 28 + * For broken SoC/Bootloader CBR addr might also be provided via DT 29 + * with "brcm,bmips-cbr-reg" in the "cpus" node. 30 + */ 27 31 void __iomem *bmips_cbr_addr __read_mostly; 28 32 29 33 void bcm63xx_machine_halt(void)
+28 -2
arch/mips/bmips/setup.c
··· 34 34 #define REG_BCM6328_OTP ((void __iomem *)CKSEG1ADDR(0x1000062c)) 35 35 #define BCM6328_TP1_DISABLED BIT(9) 36 36 37 - /* CBR addr doesn't change and we can cache it */ 37 + /* 38 + * CBR addr doesn't change and we can cache it. 39 + * For broken SoC/Bootloader CBR addr might also be provided via DT 40 + * with "brcm,bmips-cbr-reg" in the "cpus" node. 41 + */ 38 42 void __iomem *bmips_cbr_addr __read_mostly; 39 43 40 44 extern bool bmips_rac_flush_disable; ··· 212 208 void __init device_tree_init(void) 213 209 { 214 210 struct device_node *np; 211 + u32 addr; 215 212 216 213 unflatten_and_copy_device_tree(); 217 214 218 215 /* Disable SMP boot unless both CPUs are listed in DT and !disabled */ 219 216 np = of_find_node_by_name(NULL, "cpus"); 220 - if (np && of_get_available_child_count(np) <= 1) 217 + if (!np) 218 + return; 219 + 220 + if (of_get_available_child_count(np) <= 1) 221 221 bmips_smp_enabled = 0; 222 + 223 + /* Check if DT provide a CBR address */ 224 + if (of_property_read_u32(np, "brcm,bmips-cbr-reg", &addr)) 225 + goto exit; 226 + 227 + /* Make sure CBR address is outside DRAM window */ 228 + if (addr >= (u32)memblock_start_of_DRAM() && 229 + addr < (u32)memblock_end_of_DRAM()) { 230 + WARN(1, "DT CBR %x inside DRAM window. Ignoring DT CBR.\n", 231 + addr); 232 + goto exit; 233 + } 234 + 235 + bmips_cbr_addr = (void __iomem *)addr; 236 + /* Since CBR is provided by DT, enable RAC flush */ 237 + bmips_rac_flush_disable = false; 238 + 239 + exit: 222 240 of_node_put(np); 223 241 } 224 242