Skip to content

Commit b95b30e

Browse files
Ansueltsbogend
authored andcommitted
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 <[email protected]> Acked-by: Florian Fainelli <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 3de96d8 commit b95b30e

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

arch/mips/bcm47xx/setup.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
#include <bcm47xx.h>
4747
#include <bcm47xx_board.h>
4848

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+
*/
5054
void __iomem *bmips_cbr_addr __read_mostly;
5155

5256
union bcm47xx_bus bcm47xx_bus;

arch/mips/bcm63xx/setup.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
#include <bcm63xx_io.h>
2424
#include <bcm63xx_gpio.h>
2525

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+
*/
2731
void __iomem *bmips_cbr_addr __read_mostly;
2832

2933
void bcm63xx_machine_halt(void)

arch/mips/bmips/setup.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
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 */
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+
*/
3842
void __iomem *bmips_cbr_addr __read_mostly;
3943

4044
extern bool bmips_rac_flush_disable;
@@ -208,13 +212,35 @@ void __init plat_mem_setup(void)
208212
void __init device_tree_init(void)
209213
{
210214
struct device_node *np;
215+
u32 addr;
211216

212217
unflatten_and_copy_device_tree();
213218

214219
/* Disable SMP boot unless both CPUs are listed in DT and !disabled */
215220
np = of_find_node_by_name(NULL, "cpus");
216-
if (np && of_get_available_child_count(np) <= 1)
221+
if (!np)
222+
return;
223+
224+
if (of_get_available_child_count(np) <= 1)
217225
bmips_smp_enabled = 0;
226+
227+
/* Check if DT provide a CBR address */
228+
if (of_property_read_u32(np, "brcm,bmips-cbr-reg", &addr))
229+
goto exit;
230+
231+
/* Make sure CBR address is outside DRAM window */
232+
if (addr >= (u32)memblock_start_of_DRAM() &&
233+
addr < (u32)memblock_end_of_DRAM()) {
234+
WARN(1, "DT CBR %x inside DRAM window. Ignoring DT CBR.\n",
235+
addr);
236+
goto exit;
237+
}
238+
239+
bmips_cbr_addr = (void __iomem *)addr;
240+
/* Since CBR is provided by DT, enable RAC flush */
241+
bmips_rac_flush_disable = false;
242+
243+
exit:
218244
of_node_put(np);
219245
}
220246

0 commit comments

Comments
 (0)