[PATCH 1/7] common: spl: move armv7m-specific code to spl_perform_fixups()

Factor out armv7m fragment to spl_perform_fixups(), which is an arch/board specific function designed for this purpose.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com ---
arch/arm/cpu/armv7m/cpu.c | 6 ++++++ common/spl/spl.c | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/arm/cpu/armv7m/cpu.c b/arch/arm/cpu/armv7m/cpu.c index 63721018c1..65427b5312 100644 --- a/arch/arm/cpu/armv7m/cpu.c +++ b/arch/arm/cpu/armv7m/cpu.c @@ -12,6 +12,7 @@ #include <irq_func.h> #include <asm/io.h> #include <asm/armv7m.h> +#include <spl.h>
/* * This is called right before passing control to @@ -56,3 +57,8 @@ void reset_cpu(void) | (V7M_SCB->aircr & V7M_AIRCR_PRIGROUP_MSK) | V7M_AIRCR_SYSRESET, &V7M_SCB->aircr); } + +void spl_perform_fixups(struct spl_image_info *spl_image) +{ + spl_image->entry_point |= 0x1; +} diff --git a/common/spl/spl.c b/common/spl/spl.c index 0c08da06e8..63556f35bd 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -770,9 +770,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2) ret); }
-#ifdef CONFIG_CPU_V7M - spl_image.entry_point |= 0x1; -#endif switch (spl_image.os) { case IH_OS_U_BOOT: debug("Jumping to %s...\n", spl_phase_name(spl_next_phase()));

bedbug/types.h is included to provide bedbug_init() declaration, which is an empty stub that is only called from the common init sequence. In order to get rid of this dependency and the associated #ifdef: * move the bedbug_init() declaration from include/bedbug/type.h to include/init.h * provide a weak stub for bedbug_init() in board_r.c, so each CPU can provide its own implementation, as explained in the function comment
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com ---
cmd/bedbug.c | 14 -------------- common/board_r.c | 10 ++++++---- include/bedbug/type.h | 1 - include/init.h | 11 +++++++++++ 4 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/cmd/bedbug.c b/cmd/bedbug.c index 0bd67fcf47..7fc206bd26 100644 --- a/cmd/bedbug.c +++ b/cmd/bedbug.c @@ -38,20 +38,6 @@ int bedbug_puts (const char *str) return 0; } /* bedbug_puts */
- -/* ====================================================================== - * Initialize the bug_ctx structure used by the bedbug debugger. This is - * specific to the CPU since each has different debug registers and - * settings. - * ====================================================================== */ - -int bedbug_init(void) -{ - /* -------------------------------------------------- */ - return 0; -} /* bedbug_init */ - - /* ====================================================================== * Entry point from the interpreter to the disassembler. Repeated calls * will resume from the last disassembled address. diff --git a/common/board_r.c b/common/board_r.c index 31a59c585a..a5c1af9c1f 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -23,10 +23,6 @@ #include <asm/cache.h> #include <asm/global_data.h> #include <u-boot/crc.h> -/* TODO: can we just include all these headers whether needed or not? */ -#if defined(CONFIG_CMD_BEDBUG) -#include <bedbug/type.h> -#endif #include <binman.h> #include <command.h> #include <console.h> @@ -37,6 +33,7 @@ #include <ide.h> #include <init.h> #include <initcall.h> +/* TODO: can we just include all these headers whether needed or not? */ #if defined(CONFIG_CMD_KGDB) #include <kgdb.h> #endif @@ -568,6 +565,11 @@ static int initr_ide(void) } #endif
+__weak int bedbug_init(void) +{ + return 0; +} + #if defined(CONFIG_PRAM) /* * Export available size of memory for Linux, taking into account the diff --git a/include/bedbug/type.h b/include/bedbug/type.h index f7a719caf0..99c3d4d83e 100644 --- a/include/bedbug/type.h +++ b/include/bedbug/type.h @@ -5,7 +5,6 @@ struct cmd_tbl;
/* Supporting routines */ int bedbug_puts (const char *); -int bedbug_init(void); void bedbug860_init (void); void do_bedbug_breakpoint (struct pt_regs *); void bedbug_main_loop (unsigned long, struct pt_regs *); diff --git a/include/init.h b/include/init.h index c781789e36..e11472ac09 100644 --- a/include/init.h +++ b/include/init.h @@ -307,6 +307,17 @@ int board_early_init_r(void); */ int arch_initr_trap(void);
+/** + * bedbug_init() - init bedbug debugger + * + * Initialize the bug_ctx structure used by the bedbug debugger. This is + * specific to the CPU since each has different debug registers and + * settings. + * + * Return: 0 if OK + */ +int bedbug_init(void); + /** * main_loop() - Enter the main loop of U-Boot *

Add a return value to kgdb_init and use it directly in the post-relocation init sequence, rather than using a wrapper stub. Also, move the "KGDB" print message inside kgdb_init().
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com ---
common/board_r.c | 11 +---------- common/kgdb.c | 7 +++++-- include/kgdb.h | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index a5c1af9c1f..1c7397b29e 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -498,15 +498,6 @@ static int initr_ethaddr(void) } #endif /* CONFIG_CMD_NET */
-#ifdef CONFIG_CMD_KGDB -static int initr_kgdb(void) -{ - puts("KGDB: "); - kgdb_init(); - return 0; -} -#endif - #if defined(CONFIG_LED_STATUS) static int initr_status_led(void) { @@ -750,7 +741,7 @@ static init_fnc_t init_sequence_r[] = { #endif INIT_FUNC_WATCHDOG_RESET #ifdef CONFIG_CMD_KGDB - initr_kgdb, + kgdb_init, #endif interrupt_init, #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K) diff --git a/common/kgdb.c b/common/kgdb.c index 4493a15919..29b09fcfe5 100644 --- a/common/kgdb.c +++ b/common/kgdb.c @@ -527,15 +527,18 @@ handle_exception (struct pt_regs *regs) * kgdb_init must be called *after* the * monitor is relocated into ram */ -void -kgdb_init(void) +int kgdb_init(void) { + puts("KGDB: "); + kgdb_serial_init(); debugger_exception_handler = handle_exception; initialized = 1;
putDebugStr("kgdb ready\n"); puts("ready\n"); + + return 0; }
void diff --git a/include/kgdb.h b/include/kgdb.h index 616ce4451f..0609eadade 100644 --- a/include/kgdb.h +++ b/include/kgdb.h @@ -39,7 +39,7 @@ typedef kgdb_data;
/* these functions are provided by the generic kgdb support */ -extern void kgdb_init(void); +extern int kgdb_init(void); extern void kgdb_error(int); extern int kgdb_output_string(const char *, unsigned int); extern void breakpoint(void);

Add a return value to init_addr_map and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com ---
arch/arm/include/asm/mmu.h | 2 +- arch/arm/mach-bcm283x/init.c | 4 +++- arch/powerpc/cpu/mpc85xx/tlb.c | 4 ++-- arch/powerpc/include/asm/mmu.h | 2 +- common/board_r.c | 11 +---------- 5 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h index 9ac16f599e..8449720fad 100644 --- a/arch/arm/include/asm/mmu.h +++ b/arch/arm/include/asm/mmu.h @@ -3,6 +3,6 @@ #ifndef __ASM_ARM_MMU_H #define __ASM_ARM_MMU_H
-void init_addr_map(void); +int init_addr_map(void);
#endif diff --git a/arch/arm/mach-bcm283x/init.c b/arch/arm/mach-bcm283x/init.c index 9803499985..183650a90a 100644 --- a/arch/arm/mach-bcm283x/init.c +++ b/arch/arm/mach-bcm283x/init.c @@ -152,7 +152,7 @@ int mach_cpu_init(void) #include <addr_map.h> #include <asm/system.h>
-void init_addr_map(void) +int init_addr_map(void) { mmu_set_region_dcache_behaviour_phys(BCM2711_RPI4_PCIE_XHCI_MMIO_VIRT, BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS, @@ -165,6 +165,8 @@ void init_addr_map(void) addrmap_set_entry(BCM2711_RPI4_PCIE_XHCI_MMIO_VIRT, BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS, BCM2711_RPI4_PCIE_XHCI_MMIO_SIZE, 1); + + return 0; } #endif
diff --git a/arch/powerpc/cpu/mpc85xx/tlb.c b/arch/powerpc/cpu/mpc85xx/tlb.c index 973b6fbe4b..aa9b59d487 100644 --- a/arch/powerpc/cpu/mpc85xx/tlb.c +++ b/arch/powerpc/cpu/mpc85xx/tlb.c @@ -219,7 +219,7 @@ int find_tlb_idx(void *addr, u8 tlbsel) }
#ifdef CONFIG_ADDR_MAP -void init_addr_map(void) +int init_addr_map(void) { int i; unsigned int num_cam = mfspr(SPRN_TLB1CFG) & 0xfff; @@ -235,7 +235,7 @@ void init_addr_map(void) addrmap_set_entry(epn, rpn, TSIZE_TO_BYTES(tsize), i); }
- return ; + return 0; } #endif
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index 353dc4e874..cb5b26cd77 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -138,7 +138,7 @@ extern void _tlbie(unsigned long va); /* invalidate a TLB entry */ extern void _tlbia(void); /* invalidate all TLB entries */
#ifdef CONFIG_ADDR_MAP -extern void init_addr_map(void); +extern int init_addr_map(void); #endif
typedef enum { diff --git a/common/board_r.c b/common/board_r.c index 1c7397b29e..0b8f2a0b91 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -186,15 +186,6 @@ __weak int arch_initr_trap(void) return 0; }
-#ifdef CONFIG_ADDR_MAP -static int initr_addr_map(void) -{ - init_addr_map(); - - return 0; -} -#endif - #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) static int initr_unlock_ram_in_cache(void) { @@ -628,7 +619,7 @@ static init_fnc_t init_sequence_r[] = { initr_dm, #endif #ifdef CONFIG_ADDR_MAP - initr_addr_map, + init_addr_map, #endif #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \ defined(CONFIG_SANDBOX)

On 30/10/2021 08:51, Ovidiu Panait wrote:
Add a return value to init_addr_map and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
arch/arm/include/asm/mmu.h | 2 +- arch/arm/mach-bcm283x/init.c | 4 +++- arch/powerpc/cpu/mpc85xx/tlb.c | 4 ++-- arch/powerpc/include/asm/mmu.h | 2 +- common/board_r.c | 11 +---------- 5 files changed, 8 insertions(+), 15 deletions(-)
[...]
diff --git a/arch/arm/mach-bcm283x/init.c b/arch/arm/mach-bcm283x/init.c index 9803499985..183650a90a 100644 --- a/arch/arm/mach-bcm283x/init.c +++ b/arch/arm/mach-bcm283x/init.c @@ -152,7 +152,7 @@ int mach_cpu_init(void) #include <addr_map.h> #include <asm/system.h>
-void init_addr_map(void) +int init_addr_map(void) { mmu_set_region_dcache_behaviour_phys(BCM2711_RPI4_PCIE_XHCI_MMIO_VIRT, BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS,
For the bcm283x part: Reviewed-by: Matthias Brugger mbrugger@suse.com

On Sat, 30 Oct 2021 at 00:52, Ovidiu Panait ovidiu.panait@windriver.com wrote:
Add a return value to init_addr_map and use it directly in the post-relocation init sequence, rather than using a wrapper stub.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com
arch/arm/include/asm/mmu.h | 2 +- arch/arm/mach-bcm283x/init.c | 4 +++- arch/powerpc/cpu/mpc85xx/tlb.c | 4 ++-- arch/powerpc/include/asm/mmu.h | 2 +- common/board_r.c | 11 +---------- 5 files changed, 8 insertions(+), 15 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

asm/mmu.h include is currently guarded by CONFIG_ADDR_MAP ifdef because the header is only present on arm and powerpc. In order to remove the dependency on this header and the associated ifdef, move init_addr_map() declaration to init.h, since it is only called during the common init sequence.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com ---
arch/arm/include/asm/mmu.h | 8 -------- arch/powerpc/cpu/mpc85xx/tlb.c | 1 + arch/powerpc/include/asm/mmu.h | 4 ---- board/freescale/common/fsl_chain_of_trust.c | 5 +---- common/board_r.c | 3 --- include/init.h | 10 ++++++++++ 6 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 arch/arm/include/asm/mmu.h
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h deleted file mode 100644 index 8449720fad..0000000000 --- a/arch/arm/include/asm/mmu.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ - -#ifndef __ASM_ARM_MMU_H -#define __ASM_ARM_MMU_H - -int init_addr_map(void); - -#endif diff --git a/arch/powerpc/cpu/mpc85xx/tlb.c b/arch/powerpc/cpu/mpc85xx/tlb.c index aa9b59d487..550d45da0e 100644 --- a/arch/powerpc/cpu/mpc85xx/tlb.c +++ b/arch/powerpc/cpu/mpc85xx/tlb.c @@ -7,6 +7,7 @@ */
#include <common.h> +#include <init.h> #include <asm/bitops.h> #include <asm/global_data.h> #include <asm/processor.h> diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index cb5b26cd77..2e6255f0d6 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -137,10 +137,6 @@ typedef struct _MMU_context { extern void _tlbie(unsigned long va); /* invalidate a TLB entry */ extern void _tlbia(void); /* invalidate all TLB entries */
-#ifdef CONFIG_ADDR_MAP -extern int init_addr_map(void); -#endif - typedef enum { IBAT0 = 0, IBAT1, IBAT2, IBAT3, DBAT0, DBAT1, DBAT2, DBAT3, diff --git a/board/freescale/common/fsl_chain_of_trust.c b/board/freescale/common/fsl_chain_of_trust.c index cafb24971b..7ffb315bc9 100644 --- a/board/freescale/common/fsl_chain_of_trust.c +++ b/board/freescale/common/fsl_chain_of_trust.c @@ -6,6 +6,7 @@ #include <common.h> #include <dm.h> #include <env.h> +#include <init.h> #include <fsl_validate.h> #include <fsl_secboot_err.h> #include <fsl_sfp.h> @@ -16,10 +17,6 @@ #include <spl.h> #endif
-#ifdef CONFIG_ADDR_MAP -#include <asm/mmu.h> -#endif - #ifdef CONFIG_FSL_CORENET #include <asm/fsl_pamu.h> #endif diff --git a/common/board_r.c b/common/board_r.c index 0b8f2a0b91..af900e2c6e 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -59,9 +59,6 @@ #ifdef CONFIG_XEN #include <xen.h> #endif -#ifdef CONFIG_ADDR_MAP -#include <asm/mmu.h> -#endif #include <asm/sections.h> #include <dm/root.h> #include <dm/ofnode.h> diff --git a/include/init.h b/include/init.h index e11472ac09..09a1ccefc9 100644 --- a/include/init.h +++ b/include/init.h @@ -318,6 +318,16 @@ int arch_initr_trap(void); */ int bedbug_init(void);
+/** + * init_addr_map() + * + * Initialize non-identity virtual-physical memory mappings for 32bit CPUs. + * It is called during the generic board init sequence, after relocation. + * + * Return: 0 if OK + */ +int init_addr_map(void); + /** * main_loop() - Enter the main loop of U-Boot *

Not all architectures define <asm/gpio.h> and even on those that do, the header cannot be included for all boards without causing various build failures.
Since common/board_r.c only needs gpio_hog_probe_all() declaration, include <asm-generic/gpio.h> and drop the associated ifdef.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com ---
common/board_r.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index af900e2c6e..506aa446fc 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -66,9 +66,7 @@ #include <linux/err.h> #include <efi_loader.h> #include <wdt.h> -#if defined(CONFIG_GPIO_HOG) -#include <asm/gpio.h> -#endif +#include <asm-generic/gpio.h> #ifdef CONFIG_EFI_SETUP_EARLY #include <efi_loader.h> #endif

Drop the remaining ifdefs around header includes, to fix an old TODO.
Signed-off-by: Ovidiu Panait ovidiu.panait@windriver.com ---
common/board_r.c | 9 --------- 1 file changed, 9 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c index 506aa446fc..18a4849420 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -33,16 +33,11 @@ #include <ide.h> #include <init.h> #include <initcall.h> -/* TODO: can we just include all these headers whether needed or not? */ -#if defined(CONFIG_CMD_KGDB) #include <kgdb.h> -#endif #include <irq_func.h> #include <malloc.h> #include <mapmem.h> -#ifdef CONFIG_BITBANGMII #include <miiphy.h> -#endif #include <mmc.h> #include <mux.h> #include <nand.h> @@ -56,9 +51,7 @@ #include <timer.h> #include <trace.h> #include <watchdog.h> -#ifdef CONFIG_XEN #include <xen.h> -#endif #include <asm/sections.h> #include <dm/root.h> #include <dm/ofnode.h> @@ -67,9 +60,7 @@ #include <efi_loader.h> #include <wdt.h> #include <asm-generic/gpio.h> -#ifdef CONFIG_EFI_SETUP_EARLY #include <efi_loader.h> -#endif
DECLARE_GLOBAL_DATA_PTR;
participants (3)
-
Matthias Brugger
-
Ovidiu Panait
-
Simon Glass