imx: bootaux: cleanup code
Subsystems (3)
PATCH 1/4 imx: bootaux: cleanup code
From: Peng Fan <[email protected]>
Use if (CONFIG_IS_ENABLED()) to make code cleaner
Enable elf support for i.MX8M
--- arch/arm/mach-imx/imx_bootaux.c | 43 +++++++++++++++------------------ 1 file changed, 20 insertions(+), 23 deletions(-)
arch/arm/mach-imx/imx_bootaux.c +20 -23
@@ -14,7 +14,13 @@#include <linux/compiler.h> #include <cpu_func.h> -#ifndef CONFIG_IMX8M +/* Just to avoid build error */ +#if CONFIG_IS_ENABLED (IMX8M ) +#define SRC_M4C_NON_SCLR_RST_MASK BIT(0) +#define SRC_M4_ENABLE_MASK BIT(0) +#define SRC_M4_REG_OFFSET 0 +#endif +const __weak struct rproc_att hostmap[] = { };static const struct rproc_att *get_host_mapping (unsigned long auxcore)
@@ -59,7 +65,7 @@ static unsigned long load_elf_image_m_core_phdr(unsigned long addr)return 0 ; } - dst = (void *)(phdr->p_paddr - mmap->da) + mmap->sa; + dst = (void *)(ulong)(phdr->p_paddr - mmap->da) + mmap->sa; src = (void *)addr + phdr->p_offset; debug("Loading phdr %i to 0x%p (%i bytes)\n",
@@ -77,7 +83,6 @@ static unsigned long load_elf_image_m_core_phdr(unsigned long addr)return ehdr->e_entry; } -#endif int arch_auxiliary_core_up (u32 core_id,ulong addr) {
@@ -86,10 +91,6 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr)if (!addr)return -EINVAL ; -#ifdef CONFIG_IMX8M - stack = *(u32 *)addr; - pc = *(u32 *)(addr +4 ); -#else /* * handling ELF64 binaries * isn't supported yet.
@@ -109,7 +110,7 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr) stack = *(u32 *)addr; pc = *(u32 *)(addr +4 ); } -#endif +printf ("## Starting auxiliary core stack = 0x%08lX, pc = 0x%08lX...\n" , stack, pc);
@@ -120,36 +121,32 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr)flush_dcache_all ();/* Enable M4 */ -#ifdef CONFIG_IMX8M -arm_smccc_smc (IMX_SIP_SRC ,IMX_SIP_SRC_M4_START ,0 ,0 , -0 ,0 ,0 ,0 ,NULL ); -#else -clrsetbits_le32 (SRC_BASE_ADDR +SRC_M4_REG_OFFSET , -SRC_M4C_NON_SCLR_RST_MASK ,SRC_M4_ENABLE_MASK ); -#endif +if (CONFIG_IS_ENABLED (IMX8M )) { +arm_smccc_smc (IMX_SIP_SRC ,IMX_SIP_SRC_M4_START ,0 ,0 ,0 ,0 ,0 ,0 ,NULL ); + }else { +clrsetbits_le32 (SRC_BASE_ADDR +SRC_M4_REG_OFFSET , +SRC_M4C_NON_SCLR_RST_MASK ,SRC_M4_ENABLE_MASK ); + }return 0 ; }int arch_auxiliary_core_check_up (u32 core_id) { -#ifdef CONFIG_IMX8M struct arm_smccc_res res; - -arm_smccc_smc (IMX_SIP_SRC ,IMX_SIP_SRC_M4_STARTED ,0 ,0 , -0 ,0 ,0 ,0 , &res); - -return res.a0; -#else unsigned int val; +if (CONFIG_IS_ENABLED (IMX8M )) { +arm_smccc_smc (IMX_SIP_SRC ,IMX_SIP_SRC_M4_STARTED ,0 ,0 ,0 ,0 ,0 ,0 , &res); +return res.a0; + } + val =readl (SRC_BASE_ADDR +SRC_M4_REG_OFFSET );if (val &SRC_M4C_NON_SCLR_RST_MASK )return 0 ;/* assert in reset */ return 1 ; -#endif }/*
Signature · 1 line
2.36.0
PATCH 2/4 imx: bootaux: add missing newline
From: Peng Fan <[email protected]>
Add missing newline
--- arch/arm/mach-imx/imx_bootaux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/imx_bootaux.c +1 -1
@@ -60,7 +60,7 @@ static unsigned long load_elf_image_m_core_phdr(unsigned long addr)continue ;if (!mmap) { -printf ("Invalid aux core address: %08x" , +printf ("Invalid aux core address: %08x\n" , phdr->p_paddr);return 0 ; }
Signature · 1 line
2.36.0
PATCH 2/4 imx: bootaux: add missing newline
Quoted 3 lines
From: Peng Fan <[email protected]>
Add missing newlineSigned-off-by Peng Fan <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected] =====================================================================
PATCH 3/4 imx: bootaux: get stack from elf file
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
To i.MX8, M core stack is pre-coded in source code, so need to get it before kicking M core. The stack pointer is stored in the first word of the first PT_LOAD section __isr_vector. So use a num to index the section loading.
--- arch/arm/mach-imx/imx_bootaux.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
arch/arm/mach-imx/imx_bootaux.c +11 -4
@@ -42,10 +42,11 @@ static const struct rproc_att *get_host_mapping(unsigned long auxcore)* is valid, returns the entry point address. * Translates load addresses in the elf file to the U-Boot address space. */ -static unsigned long load_elf_image_m_core_phdr (unsigned long addr) +static unsigned long load_elf_image_m_core_phdr (unsigned long addr,ulong *stack) {Elf32_Ehdr *ehdr;/* ELF header structure pointer */ Elf32_Phdr *phdr;/* Program header structure pointer */ +int num =0 ;int i; ehdr = (Elf32_Ehdr *)addr;
@@ -71,8 +72,13 @@ static unsigned long load_elf_image_m_core_phdr(unsigned long addr)debug ("Loading phdr %i to 0x%p (%i bytes)\n" , i, dst, phdr->p_filesz); -if (phdr->p_filesz) +if (phdr->p_filesz) {memcpy (dst, src, phdr->p_filesz); +/* Stack in __isr_vector is the first section/word */ +if (!num) + *stack = *(uint32_t *)src; + num++; + }if (phdr->p_filesz != phdr->p_memsz)memset (dst + phdr->p_filesz,0x00 , phdr->p_memsz - phdr->p_filesz);
@@ -96,11 +102,12 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr)* isn't supported yet. */ if (valid_elf_image (addr)) { - stack =0x0 ; - pc =load_elf_image_m_core_phdr (addr); + pc =load_elf_image_m_core_phdr (addr, &stack);if (!pc)return CMD_RET_FAILURE ; +if (!CONFIG_IS_ENABLED (ARM64 )) + stack =0x0 ; }else {/* * Assume binary file with vector table at the beginning.
Signature · 1 line
2.36.0
PATCH 3/4 imx: bootaux: get stack from elf file
Quoted 6 lines
From: Peng Fan <[email protected]>
To i.MX8, M core stack is pre-coded in source code, so need to get it before kicking M core. The stack pointer is stored in the first word of the firstPT_LOADsection__isr_vector. So use a num to index the section loading.Signed-off-by Peng Fan <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected] =====================================================================
PATCH 4/4 imx: imx8m: add rproc_att
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
With rpoc_att, bootaux able to kick elf file for M core
--- arch/arm/mach-imx/imx8m/soc.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +26 -0
@@ -1561,3 +1561,29 @@ enum env_location arch_env_get_location(enum env_operation op, int prio) }#endif + +#ifdef CONFIG_IMX_BOOTAUX +const struct rproc_att hostmap[] = { +/* aux core , host core, size */ + {0x00000000 ,0x007e0000 ,0x00020000 }, +/* OCRAM_S */ + {0x00180000 ,0x00180000 ,0x00008000 }, +/* OCRAM */ + {0x00900000 ,0x00900000 ,0x00020000 }, +/* OCRAM */ + {0x00920000 ,0x00920000 ,0x00020000 }, +/* QSPI Code - alias */ + {0x08000000 ,0x08000000 ,0x08000000 }, +/* DDR (Code) - alias */ + {0x10000000 ,0x80000000 ,0x0FFE0000 }, +/* TCML */ + {0x1FFE0000 ,0x007E0000 ,0x00040000 }, +/* OCRAM_S */ + {0x20180000 ,0x00180000 ,0x00008000 }, +/* OCRAM */ + {0x20200000 ,0x00900000 ,0x00040000 }, +/* DDR (Data) */ + {0x40000000 ,0x40000000 ,0x80000000 }, + {/* sentinel */ } +}; +#endif
Signature · 1 line
2.36.0
PATCH 4/4 imx: imx8m: add rproc_att
Quoted 3 lines
From: Peng Fan <[email protected]>
Withrpoc_att, bootaux able to kick elf file for M coreSigned-off-by Peng Fan <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected] =====================================================================
PATCH 1/4 imx: bootaux: cleanup code
In reply to Peng Fan (OSS)Quoted 4 lines
From: Peng Fan <[email protected]>
Use if (CONFIG_IS_ENABLED()) to make code cleaner
Enable elf support for i.MX8MSigned-off-by Peng Fan <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected] =====================================================================