Skip to content

Commit a5c0545

Browse files
Ansueltsbogend
authored andcommitted
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 <[email protected]> Signed-off-by: Christian Marangi <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 7c48090 commit a5c0545

File tree

8 files changed

+24
-4
lines changed

8 files changed

+24
-4
lines changed

arch/mips/bcm47xx/prom.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/ssb/ssb_driver_chipcommon.h>
3333
#include <linux/ssb/ssb_regs.h>
3434
#include <linux/smp.h>
35+
#include <asm/bmips.h>
3536
#include <asm/bootinfo.h>
3637
#include <bcm47xx.h>
3738
#include <bcm47xx_board.h>
@@ -110,6 +111,8 @@ static __init void prom_init_mem(void)
110111

111112
void __init prom_init(void)
112113
{
114+
/* Cache CBR addr before CPU/DMA setup */
115+
bmips_cbr_addr = BMIPS_GET_CBR();
113116
prom_init_mem();
114117
setup_8250_early_printk_port(CKSEG1ADDR(BCM47XX_SERIAL_ADDR), 0, 0);
115118
}

arch/mips/bcm47xx/setup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/ssb/ssb.h>
3838
#include <linux/ssb/ssb_embedded.h>
3939
#include <linux/bcma/bcma_soc.h>
40+
#include <asm/bmips.h>
4041
#include <asm/bootinfo.h>
4142
#include <asm/idle.h>
4243
#include <asm/prom.h>
@@ -45,6 +46,9 @@
4546
#include <bcm47xx.h>
4647
#include <bcm47xx_board.h>
4748

49+
/* CBR addr doesn't change and we can cache it */
50+
void __iomem *bmips_cbr_addr __read_mostly;
51+
4852
union bcm47xx_bus bcm47xx_bus;
4953
EXPORT_SYMBOL(bcm47xx_bus);
5054

arch/mips/bcm63xx/prom.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ void __init prom_init(void)
2222
{
2323
u32 reg, mask;
2424

25+
/* Cache CBR addr before CPU/DMA setup */
26+
bmips_cbr_addr = BMIPS_GET_CBR();
27+
2528
bcm63xx_cpu_init();
2629

2730
/* stop any running watchdog */

arch/mips/bcm63xx/setup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/memblock.h>
1313
#include <linux/ioport.h>
1414
#include <linux/pm.h>
15+
#include <asm/bmips.h>
1516
#include <asm/bootinfo.h>
1617
#include <asm/time.h>
1718
#include <asm/reboot.h>
@@ -22,6 +23,9 @@
2223
#include <bcm63xx_io.h>
2324
#include <bcm63xx_gpio.h>
2425

26+
/* CBR addr doesn't change and we can cache it */
27+
void __iomem *bmips_cbr_addr __read_mostly;
28+
2529
void bcm63xx_machine_halt(void)
2630
{
2731
pr_info("System halted\n");

arch/mips/bmips/dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bool bmips_rac_flush_disable;
99

1010
void arch_sync_dma_for_cpu_all(void)
1111
{
12-
void __iomem *cbr = BMIPS_GET_CBR();
12+
void __iomem *cbr = bmips_cbr_addr;
1313
u32 cfg;
1414

1515
if (boot_cpu_type() != CPU_BMIPS3300 &&

arch/mips/bmips/setup.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
#define REG_BCM6328_OTP ((void __iomem *)CKSEG1ADDR(0x1000062c))
3535
#define BCM6328_TP1_DISABLED BIT(9)
3636

37+
/* CBR addr doesn't change and we can cache it */
38+
void __iomem *bmips_cbr_addr __read_mostly;
39+
3740
extern bool bmips_rac_flush_disable;
3841

3942
static const unsigned long kbase = VMLINUX_LOAD_ADDRESS & 0xfff00000;
@@ -111,7 +114,7 @@ static void bcm6358_quirks(void)
111114
* because the bootloader is not initializing it properly.
112115
*/
113116
bmips_rac_flush_disable = !!(read_c0_brcm_cmt_local() & (1 << 31)) ||
114-
!!BMIPS_GET_CBR();
117+
!!bmips_cbr_addr;
115118
}
116119

117120
static void bcm6368_quirks(void)
@@ -144,6 +147,8 @@ static void __init bmips_init_cfe(void)
144147

145148
void __init prom_init(void)
146149
{
150+
/* Cache CBR addr before CPU/DMA setup */
151+
bmips_cbr_addr = BMIPS_GET_CBR();
147152
bmips_init_cfe();
148153
bmips_cpu_setup();
149154
register_bmips_smp_ops();

arch/mips/include/asm/bmips.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ extern char bmips_smp_movevec[];
8181
extern char bmips_smp_int_vec[];
8282
extern char bmips_smp_int_vec_end[];
8383

84+
extern void __iomem *bmips_cbr_addr;
8485
extern int bmips_smp_enabled;
8586
extern int bmips_cpu_offset;
8687
extern cpumask_t bmips_booted_mask;

arch/mips/kernel/smp-bmips.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static void bmips_set_reset_vec(int cpu, u32 val)
518518
info.val = val;
519519
bmips_set_reset_vec_remote(&info);
520520
} else {
521-
void __iomem *cbr = BMIPS_GET_CBR();
521+
void __iomem *cbr = bmips_cbr_addr;
522522

523523
if (cpu == 0)
524524
__raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_0);
@@ -591,7 +591,7 @@ asmlinkage void __weak plat_wired_tlb_setup(void)
591591

592592
void bmips_cpu_setup(void)
593593
{
594-
void __iomem __maybe_unused *cbr = BMIPS_GET_CBR();
594+
void __iomem __maybe_unused *cbr = bmips_cbr_addr;
595595
u32 __maybe_unused cfg;
596596

597597
switch (current_cpu_type()) {

0 commit comments

Comments
 (0)