arm: socfpga: fix SPL booting from fpga OnChip RAM
Subsystems (3)
PATCH v4 1/1 arm: socfpga: fix SPL booting from fpga OnChip RAM
This patch prevents disabling the FPGA bridges when SPL or U-Boot is executed from FPGA onchip RAM.
---
Changes in v4:
- use an inline function in misc.h to check for the address range instead of a macro in base_addr_ac5.h
Changes in v3:
- use __image_copy_start to check if we are executing from FPGA
Changes in v2:
- use less ifdefs and more C code for address checks (but this gives a checkpatch warning because of comparing two upper case constants)
- changed comments
arch/arm/mach-socfpga/include/mach/base_addr_ac5.h | 1 + arch/arm/mach-socfpga/include/mach/misc.h | 7 +++++++ arch/arm/mach-socfpga/misc_gen5.c | 10 +++++++++- arch/arm/mach-socfpga/spl_gen5.c | 10 +++++++--- 4 files changed, 24 insertions(+), 4 deletions(-)
arch/arm/mach-socfpga/include/mach/base_addr_ac5.h +1 -0
@@ -6,6 +6,7 @@#ifndef _SOCFPGA_BASE_ADDRS_H_#define _SOCFPGA_BASE_ADDRS_H_ +#define SOCFPGA_FPGA_SLAVES_ADDRESS 0xc0000000#define SOCFPGA_STM_ADDRESS 0xfc000000#define SOCFPGA_DAP_ADDRESS 0xff000000#define SOCFPGA_EMAC0_ADDRESS 0xff700000
arch/arm/mach-socfpga/include/mach/misc.h +7 -0
@@ -23,6 +23,13 @@ static inline void socfpga_fpga_add(void) {}#ifdef CONFIG_TARGET_SOCFPGA_GEN5 void socfpga_sdram_remap_zero (void ); +static inline bool socfpga_is_fpga_slaves_addr (void *addr) +{ +if ((addr >= (void *)SOCFPGA_FPGA_SLAVES_ADDRESS ) && + (addr < (void *)SOCFPGA_STM_ADDRESS )) +return true; +return false; +}#endif #ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
arch/arm/mach-socfpga/misc_gen5.c +9 -1
@@ -20,6 +20,7 @@#include <asm/arch/nic301.h> #include <asm/arch/scu.h> #include <asm/pl310.h> +#include <asm/sections.h> #include <dt-bindings/reset/altr,rst-mgr.h>
@@ -177,6 +178,8 @@ static void socfpga_nic301_slave_ns(void)void socfpga_sdram_remap_zero (void ) { +u32 remap; +socfpga_nic301_slave_ns ();/*
@@ -187,7 +190,12 @@ void socfpga_sdram_remap_zero(void)setbits_le32 (&scu_regs->sacr,0xfff );/* Configure the L2 controller to make SDRAM start at 0 */ -writel (0x1 , &nic301_regs->remap);/* remap.mpuzero */ + remap =0x1 ;/* remap.mpuzero */ +/* Keep fpga bridge enabled when running from FPGA onchip RAM */ +if (socfpga_is_fpga_slaves_addr (__image_copy_start)) + remap |=0x8 ;/* remap.hps2fpga */ +writel (remap, &nic301_regs->remap); +writel (0x1 , &pl310->pl310_addr_filter_start); }
arch/arm/mach-socfpga/spl_gen5.c +7 -3
@@ -92,8 +92,11 @@ void board_init_f(ulong dummy)/* Put everything into reset but L4WD0. */ socfpga_per_reset_all (); -/* Put FPGA bridges into reset too. */ -socfpga_bridges_reset (1 ); + +if (!socfpga_is_fpga_slaves_addr (__image_copy_start)) { +/* Put FPGA bridges into reset (unless booting from FPGA). */ +socfpga_bridges_reset (1 ); + }socfpga_per_reset (SOCFPGA_RESET (SDR ),0 );socfpga_per_reset (SOCFPGA_RESET (UART0 ),0 );
@@ -163,5 +166,6 @@ void board_init_f(ulong dummy)hang (); } -socfpga_bridges_reset (1 ); +if (!socfpga_is_fpga_slaves_addr (__image_copy_start)) +socfpga_bridges_reset (1 ); }
Signature · 1 line
2.17.1
PATCH v4 1/1 arm: socfpga: fix SPL booting from fpga OnChip RAM
Quoted 42 lines · Simon Goldschmidt
This patch prevents disabling the FPGA bridges when SPL or U-Boot is executed from FPGA onchip RAM.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v4:
- use an inline function inmisc.hto check for the address range instead of a macro inbase_addr_ac5.hChanges in v3:
- use__image_copy_startto check if we are executing from FPGAChanges in v2:
- use less ifdefs and more C code for address checks (but this gives a checkpatch warning because of comparing two upper case constants)
- changed commentsarch/arm/mach-socfpga/include/mach/base_addr_ac5.h | 1 + arch/arm/mach-socfpga/include/mach/misc.h | 7 +++++++ arch/arm/mach-socfpga/misc_gen5.c | 10 +++++++++- arch/arm/mach-socfpga/spl_gen5.c | 10 +++++++--- 4 files changed, 24 insertions(+), 4 deletions(-)arch/arm/mach-socfpga/include/mach/base_addr_ac5.h +1
-0@@ -6,6 +6,7 @@#ifndef _SOCFPGA_BASE_ADDRS_H_#define _SOCFPGA_BASE_ADDRS_H_ +#define SOCFPGA_FPGA_SLAVES_ADDRESS 0xc0000000#define SOCFPGA_STM_ADDRESS 0xfc000000#define SOCFPGA_DAP_ADDRESS 0xff000000#define SOCFPGA_EMAC0_ADDRESS 0xff700000arch/arm/mach-socfpga/include/mach/misc.h +0
-0
arch/arm/mach-socfpga/include/mach/misc.h static inline void socfpga_fpga_add(void) {} · line 27
Quoted 5 lines
arch/arm/mach-socfpga/include/mach/misc.h +2
-0@@ -23,6 +23,13 @@ static inline void socfpga_fpga_add(void) {}#ifdef CONFIG_TARGET_SOCFPGA_GEN5 void socfpga_sdram_remap_zero (void ); +static inline bool socfpga_is_fpga_slaves_addr (void *addr) +{
Is the inline needed ?
btw would it make sense to encode __image_copy_start here and just make it a function like ie.
static bool socfpga_is_booting_from_fpga(void) {} ?
[...]
Signature · 2 lines
Best regards, Marek Vasut
PATCH v4 1/1 arm: socfpga: fix SPL booting from fpga OnChip RAM
Quoted 45 lines · Marek Vasut
Quoted 43 lines · Simon Goldschmidt
This patch prevents disabling the FPGA bridges when SPL or U-Boot is executed from FPGA onchip RAM.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v4:
- use an inline function inmisc.hto check for the address range instead of a macro inbase_addr_ac5.hChanges in v3:
- use__image_copy_startto check if we are executing from FPGAChanges in v2:
- use less ifdefs and more C code for address checks (but this gives a checkpatch warning because of comparing two upper case constants)
- changed commentsarch/arm/mach-socfpga/include/mach/base_addr_ac5.h | 1 + arch/arm/mach-socfpga/include/mach/misc.h | 7 +++++++ arch/arm/mach-socfpga/misc_gen5.c | 10 +++++++++- arch/arm/mach-socfpga/spl_gen5.c | 10 +++++++--- 4 files changed, 24 insertions(+), 4 deletions(-)arch/arm/mach-socfpga/include/mach/base_addr_ac5.h +1
-0@@ -6,6 +6,7 @@#ifndef _SOCFPGA_BASE_ADDRS_H_#define _SOCFPGA_BASE_ADDRS_H_ +#define SOCFPGA_FPGA_SLAVES_ADDRESS 0xc0000000#define SOCFPGA_STM_ADDRESS 0xfc000000#define SOCFPGA_DAP_ADDRESS 0xff000000#define SOCFPGA_EMAC0_ADDRESS 0xff700000arch/arm/mach-socfpga/include/mach/misc.h +0
-0@@ -23,6 +23,13 @@ static inline void socfpga_fpga_add(void) {}
Quoted 6 lines
arch/arm/mach-socfpga/include/mach/misc.h static inline void socfpga_fpga_add(void) {} · line 27
Quoted 4 lines
arch/arm/mach-socfpga/include/mach/misc.h +2
-0#ifdef CONFIG_TARGET_SOCFPGA_GEN5 void socfpga_sdram_remap_zero (void ); +static inline bool socfpga_is_fpga_slaves_addr (void *addr) +{Is the inline needed ?
If it's in this header, yes. As without the inline, you get this compiler warnings in files that include misc.h but don't call the function:
warning: ‘socfpga_is_fpga_slaves_addr’ defined but not used [-Wunused-function]
Quoted 4 lines
btw would it make sense to encode
__image_copy_starthere and just make it a function like ie.static bool
socfpga_is_booting_from_fpga(void){} ?
Sure. Do you want me to move it into misc_gen5.c r keep the inline?
Simon
PATCH v4 1/1 arm: socfpga: fix SPL booting from fpga OnChip RAM
Quoted 53 lines · Simon Goldschmidt
Quoted 45 lines · Marek Vasut
Quoted 43 lines · Simon Goldschmidt
This patch prevents disabling the FPGA bridges when SPL or U-Boot is executed from FPGA onchip RAM.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v4:
- use an inline function inmisc.hto check for the address range instead of a macro inbase_addr_ac5.hChanges in v3:
- use__image_copy_startto check if we are executing from FPGAChanges in v2:
- use less ifdefs and more C code for address checks (but this gives a checkpatch warning because of comparing two upper case constants)
- changed commentsarch/arm/mach-socfpga/include/mach/base_addr_ac5.h | 1 + arch/arm/mach-socfpga/include/mach/misc.h | 7 +++++++ arch/arm/mach-socfpga/misc_gen5.c | 10 +++++++++- arch/arm/mach-socfpga/spl_gen5.c | 10 +++++++--- 4 files changed, 24 insertions(+), 4 deletions(-)arch/arm/mach-socfpga/include/mach/base_addr_ac5.h +1
-0@@ -6,6 +6,7 @@#ifndef _SOCFPGA_BASE_ADDRS_H_#define _SOCFPGA_BASE_ADDRS_H_ +#define SOCFPGA_FPGA_SLAVES_ADDRESS 0xc0000000#define SOCFPGA_STM_ADDRESS 0xfc000000#define SOCFPGA_DAP_ADDRESS 0xff000000#define SOCFPGA_EMAC0_ADDRESS 0xff700000arch/arm/mach-socfpga/include/mach/misc.h +0
-0@@ -23,6 +23,13 @@ static inline void socfpga_fpga_add(void) {}Quoted 6 lines
arch/arm/mach-socfpga/include/mach/misc.h static inline void socfpga_fpga_add(void) {} · line 27
Quoted 4 lines
arch/arm/mach-socfpga/include/mach/misc.h +2
-0#ifdef CONFIG_TARGET_SOCFPGA_GEN5 void socfpga_sdram_remap_zero (void ); +static inline bool socfpga_is_fpga_slaves_addr (void *addr) +{Is the inline needed ?
Quoted 3 lines
If it's in this header, yes. As without the inline, you get this compiler warnings in files that include
misc.hbut don't call the function:
warning: ‘socfpga_is_fpga_slaves_addr’ defined but not used [-Wunused-function]
Ah, got it.
Quoted 6 lines
Quoted 4 lines
btw would it make sense to encode
__image_copy_starthere and just make it a function like ie.static bool
socfpga_is_booting_from_fpga(void){} ?Sure. Do you want me to move it into
misc_gen5.cr keep the inline?
Nope, just this. Sorry for pestering you so much.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v4 1/1 arm: socfpga: fix SPL booting from fpga OnChip RAM
Quoted 60 lines · Marek Vasut
Quoted 53 lines · Simon Goldschmidt
Quoted 45 lines · Marek Vasut
Quoted 43 lines · Simon Goldschmidt
This patch prevents disabling the FPGA bridges when SPL or U-Boot is executed from FPGA onchip RAM.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v4:
- use an inline function inmisc.hto check for the address range instead of a macro inbase_addr_ac5.hChanges in v3:
- use__image_copy_startto check if we are executing from FPGAChanges in v2:
- use less ifdefs and more C code for address checks (but this gives a checkpatch warning because of comparing two upper case constants)
- changed commentsarch/arm/mach-socfpga/include/mach/base_addr_ac5.h | 1 + arch/arm/mach-socfpga/include/mach/misc.h | 7 +++++++ arch/arm/mach-socfpga/misc_gen5.c | 10 +++++++++- arch/arm/mach-socfpga/spl_gen5.c | 10 +++++++--- 4 files changed, 24 insertions(+), 4 deletions(-)arch/arm/mach-socfpga/include/mach/base_addr_ac5.h +1
-0@@ -6,6 +6,7 @@#ifndef _SOCFPGA_BASE_ADDRS_H_#define _SOCFPGA_BASE_ADDRS_H_ +#define SOCFPGA_FPGA_SLAVES_ADDRESS 0xc0000000#define SOCFPGA_STM_ADDRESS 0xfc000000#define SOCFPGA_DAP_ADDRESS 0xff000000#define SOCFPGA_EMAC0_ADDRESS 0xff700000arch/arm/mach-socfpga/include/mach/misc.h +0
-0@@ -23,6 +23,13 @@ static inline void socfpga_fpga_add(void) {}Quoted 6 lines
arch/arm/mach-socfpga/include/mach/misc.h static inline void socfpga_fpga_add(void) {} · line 27
Quoted 4 lines
arch/arm/mach-socfpga/include/mach/misc.h +2
-0#ifdef CONFIG_TARGET_SOCFPGA_GEN5 void socfpga_sdram_remap_zero (void ); +static inline bool socfpga_is_fpga_slaves_addr (void *addr) +{Is the inline needed ?
Quoted 3 lines
If it's in this header, yes. As without the inline, you get this compiler warnings in files that include
misc.hbut don't call the function:
warning: ‘socfpga_is_fpga_slaves_addr’ defined but not used [-Wunused-function]Ah, got it.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
btw would it make sense to encode
__image_copy_starthere and just make it a function like ie.static bool
socfpga_is_booting_from_fpga(void){} ?Sure. Do you want me to move it into
misc_gen5.cr keep the inline?Nope, just this. Sorry for pestering you so much.
And by just this I mean, just encode the __image_start_addr into the function and drop the argument, keep it where it is.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v4 1/1 arm: socfpga: fix SPL booting from fpga OnChip RAM
Quoted 62 lines · Marek Vasut
Quoted 60 lines · Marek Vasut
Quoted 53 lines · Simon Goldschmidt
Quoted 45 lines · Marek Vasut
Quoted 43 lines · Simon Goldschmidt
This patch prevents disabling the FPGA bridges when SPL or U-Boot is executed from FPGA onchip RAM.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v4:
- use an inline function inmisc.hto check for the address range instead of a macro inbase_addr_ac5.hChanges in v3:
- use__image_copy_startto check if we are executing from FPGAChanges in v2:
- use less ifdefs and more C code for address checks (but this gives a checkpatch warning because of comparing two upper case constants)
- changed commentsarch/arm/mach-socfpga/include/mach/base_addr_ac5.h | 1 + arch/arm/mach-socfpga/include/mach/misc.h | 7 +++++++ arch/arm/mach-socfpga/misc_gen5.c | 10 +++++++++- arch/arm/mach-socfpga/spl_gen5.c | 10 +++++++--- 4 files changed, 24 insertions(+), 4 deletions(-)arch/arm/mach-socfpga/include/mach/base_addr_ac5.h +1
-0@@ -6,6 +6,7 @@#ifndef _SOCFPGA_BASE_ADDRS_H_#define _SOCFPGA_BASE_ADDRS_H_ +#define SOCFPGA_FPGA_SLAVES_ADDRESS 0xc0000000#define SOCFPGA_STM_ADDRESS 0xfc000000#define SOCFPGA_DAP_ADDRESS 0xff000000#define SOCFPGA_EMAC0_ADDRESS 0xff700000arch/arm/mach-socfpga/include/mach/misc.h +0
-0@@ -23,6 +23,13 @@ static inline void socfpga_fpga_add(void) {}Quoted 6 lines
arch/arm/mach-socfpga/include/mach/misc.h static inline void socfpga_fpga_add(void) {} · line 27
Quoted 4 lines
arch/arm/mach-socfpga/include/mach/misc.h +2
-0#ifdef CONFIG_TARGET_SOCFPGA_GEN5 void socfpga_sdram_remap_zero (void ); +static inline bool socfpga_is_fpga_slaves_addr (void *addr) +{Is the inline needed ?
Quoted 3 lines
If it's in this header, yes. As without the inline, you get this compiler warnings in files that include
misc.hbut don't call the function:
warning: ‘socfpga_is_fpga_slaves_addr’ defined but not used [-Wunused-function]Ah, got it.
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
btw would it make sense to encode
__image_copy_starthere and just make it a function like ie.static bool
socfpga_is_booting_from_fpga(void){} ?Sure. Do you want me to move it into
misc_gen5.cr keep the inline?Nope, just this. Sorry for pestering you so much.
No problem. Thanks to patman, sending new versions is not really much work :-)
Quoted 3 lines
And by just this I mean, just encode the
__image_start_addrinto the function and drop the argument, keep it where it is.
Yeah, got it.
Simon