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

mips: bmips: rework and cache CBR addr handling

Rework the handling of the CBR address and cache it. This address
doesn't change and can be cached instead of reading the register every
time.

This is in preparation of permitting to tweak the CBR address in DT with
broken SoC or bootloader.

bmips_cbr_addr is defined in setup.c for each arch to keep compatibility
with legacy brcm47xx/brcm63xx and generic BMIPS target.

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

authored by

Christian Marangi and committed by
Thomas Bogendoerfer
a5c05453 7c48090a

+24 -4
+3
arch/mips/bcm47xx/prom.c
··· 32 32 #include <linux/ssb/ssb_driver_chipcommon.h> 33 33 #include <linux/ssb/ssb_regs.h> 34 34 #include <linux/smp.h> 35 + #include <asm/bmips.h> 35 36 #include <asm/bootinfo.h> 36 37 #include <bcm47xx.h> 37 38 #include <bcm47xx_board.h> ··· 111 110 112 111 void __init prom_init(void) 113 112 { 113 + /* Cache CBR addr before CPU/DMA setup */ 114 + bmips_cbr_addr = BMIPS_GET_CBR(); 114 115 prom_init_mem(); 115 116 setup_8250_early_printk_port(CKSEG1ADDR(BCM47XX_SERIAL_ADDR), 0, 0); 116 117 }
+4
arch/mips/bcm47xx/setup.c
··· 37 37 #include <linux/ssb/ssb.h> 38 38 #include <linux/ssb/ssb_embedded.h> 39 39 #include <linux/bcma/bcma_soc.h> 40 + #include <asm/bmips.h> 40 41 #include <asm/bootinfo.h> 41 42 #include <asm/idle.h> 42 43 #include <asm/prom.h> ··· 45 44 #include <asm/time.h> 46 45 #include <bcm47xx.h> 47 46 #include <bcm47xx_board.h> 47 + 48 + /* CBR addr doesn't change and we can cache it */ 49 + void __iomem *bmips_cbr_addr __read_mostly; 48 50 49 51 union bcm47xx_bus bcm47xx_bus; 50 52 EXPORT_SYMBOL(bcm47xx_bus);
+3
arch/mips/bcm63xx/prom.c
··· 22 22 { 23 23 u32 reg, mask; 24 24 25 + /* Cache CBR addr before CPU/DMA setup */ 26 + bmips_cbr_addr = BMIPS_GET_CBR(); 27 + 25 28 bcm63xx_cpu_init(); 26 29 27 30 /* stop any running watchdog */
+4
arch/mips/bcm63xx/setup.c
··· 12 12 #include <linux/memblock.h> 13 13 #include <linux/ioport.h> 14 14 #include <linux/pm.h> 15 + #include <asm/bmips.h> 15 16 #include <asm/bootinfo.h> 16 17 #include <asm/time.h> 17 18 #include <asm/reboot.h> ··· 22 21 #include <bcm63xx_regs.h> 23 22 #include <bcm63xx_io.h> 24 23 #include <bcm63xx_gpio.h> 24 + 25 + /* CBR addr doesn't change and we can cache it */ 26 + void __iomem *bmips_cbr_addr __read_mostly; 25 27 26 28 void bcm63xx_machine_halt(void) 27 29 {
+1 -1
arch/mips/bmips/dma.c
··· 9 9 10 10 void arch_sync_dma_for_cpu_all(void) 11 11 { 12 - void __iomem *cbr = BMIPS_GET_CBR(); 12 + void __iomem *cbr = bmips_cbr_addr; 13 13 u32 cfg; 14 14 15 15 if (boot_cpu_type() != CPU_BMIPS3300 &&
+6 -1
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 */ 38 + void __iomem *bmips_cbr_addr __read_mostly; 39 + 37 40 extern bool bmips_rac_flush_disable; 38 41 39 42 static const unsigned long kbase = VMLINUX_LOAD_ADDRESS & 0xfff00000; ··· 114 111 * because the bootloader is not initializing it properly. 115 112 */ 116 113 bmips_rac_flush_disable = !!(read_c0_brcm_cmt_local() & (1 << 31)) || 117 - !!BMIPS_GET_CBR(); 114 + !!bmips_cbr_addr; 118 115 } 119 116 120 117 static void bcm6368_quirks(void) ··· 147 144 148 145 void __init prom_init(void) 149 146 { 147 + /* Cache CBR addr before CPU/DMA setup */ 148 + bmips_cbr_addr = BMIPS_GET_CBR(); 150 149 bmips_init_cfe(); 151 150 bmips_cpu_setup(); 152 151 register_bmips_smp_ops();
+1
arch/mips/include/asm/bmips.h
··· 81 81 extern char bmips_smp_int_vec[]; 82 82 extern char bmips_smp_int_vec_end[]; 83 83 84 + extern void __iomem *bmips_cbr_addr; 84 85 extern int bmips_smp_enabled; 85 86 extern int bmips_cpu_offset; 86 87 extern cpumask_t bmips_booted_mask;
+2 -2
arch/mips/kernel/smp-bmips.c
··· 518 518 info.val = val; 519 519 bmips_set_reset_vec_remote(&info); 520 520 } else { 521 - void __iomem *cbr = BMIPS_GET_CBR(); 521 + void __iomem *cbr = bmips_cbr_addr; 522 522 523 523 if (cpu == 0) 524 524 __raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_0); ··· 591 591 592 592 void bmips_cpu_setup(void) 593 593 { 594 - void __iomem __maybe_unused *cbr = BMIPS_GET_CBR(); 594 + void __iomem __maybe_unused *cbr = bmips_cbr_addr; 595 595 u32 __maybe_unused cfg; 596 596 597 597 switch (current_cpu_type()) {