> > This function is the same for each device when it needs to shutdown > the R5 core. Move this to the common section and move the remaining > device specific ID list to the device hardware include. > > Signed-off-by: Andrew Davis <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]> > --- > arch/arm/mach-k3/am642_init.c | 51 ----------------- > arch/arm/mach-k3/am654_init.c | 51 ----------------- > arch/arm/mach-k3/common.c | 32 ++++++++++- > arch/arm/mach-k3/include/mach/am62_hardware.h | 8 +++ > .../arm/mach-k3/include/mach/am62a_hardware.h | 8 +++ > arch/arm/mach-k3/include/mach/am64_hardware.h | 24 ++++++++ > arch/arm/mach-k3/include/mach/am6_hardware.h | 19 +++++++ > .../arm/mach-k3/include/mach/j721e_hardware.h | 19 +++++++ > .../mach-k3/include/mach/j721s2_hardware.h | 19 +++++++ > arch/arm/mach-k3/include/mach/sys_proto.h | 1 - > arch/arm/mach-k3/j721e_init.c | 55 ------------------- > arch/arm/mach-k3/j721s2_init.c | 54 ------------------ > 12 files changed, 127 insertions(+), 214 deletions(-) > > diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c > index 1bf7e163cc4..86aced54646 100644 > --- a/arch/arm/mach-k3/am642_init.c > +++ b/arch/arm/mach-k3/am642_init.c > @@ -346,54 +346,3 @@ u32 spl_boot_device(void) > else > return __get_backup_bootmedia(devstat); > } > - > -#if defined(CONFIG_SYS_K3_SPL_ATF) > - > -#define AM64X_DEV_RTI8 127 > -#define AM64X_DEV_RTI9 128 > -#define AM64X_DEV_R5FSS0_CORE0 121 > -#define AM64X_DEV_R5FSS0_CORE1 122 > - > -void release_resources_for_core_shutdown(void) > -{ > - struct ti_sci_handle *ti_sci = get_ti_sci_handle(); > - struct ti_sci_dev_ops *dev_ops = &ti_sci->ops.dev_ops; > - struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops; > - int ret; > - u32 i; > - > - const u32 put_device_ids[] = { > - AM64X_DEV_RTI9, > - AM64X_DEV_RTI8, > - }; > - > - /* Iterate through list of devices to put (shutdown) */ > - for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) { > - u32 id = put_device_ids[i]; > - > - ret = dev_ops->put_device(ti_sci, id); > - if (ret) > - panic("Failed to put device %u (%d)\n", id, ret); > - } > - > - const u32 put_core_ids[] = { > - AM64X_DEV_R5FSS0_CORE1, > - AM64X_DEV_R5FSS0_CORE0, /* Handle CPU0 after CPU1 */ > - }; > - > - /* Iterate through list of cores to put (shutdown) */ > - for (i = 0; i < ARRAY_SIZE(put_core_ids); i++) { > - u32 id = put_core_ids[i]; > - > - /* > - * Queue up the core shutdown request. Note that this call > - * needs to be followed up by an actual invocation of an WFE > - * or WFI CPU instruction. > - */ > - ret = proc_ops->proc_shutdown_no_wait(ti_sci, id); > - if (ret) > - panic("Failed sending core %u shutdown message > (%d)\n", > - id, ret); > - } > -} > -#endif > diff --git a/arch/arm/mach-k3/am654_init.c b/arch/arm/mach-k3/am654_init.c > index 70059edb039..abd0c0bccbc 100644 > --- a/arch/arm/mach-k3/am654_init.c > +++ b/arch/arm/mach-k3/am654_init.c > @@ -353,54 +353,3 @@ u32 spl_boot_device(void) > else > return __get_backup_bootmedia(devstat); > } > - > -#ifdef CONFIG_SYS_K3_SPL_ATF > - > -#define AM6_DEV_MCU_RTI0 134 > -#define AM6_DEV_MCU_RTI1 135 > -#define AM6_DEV_MCU_ARMSS0_CPU0 159 > -#define AM6_DEV_MCU_ARMSS0_CPU1 245 > - > -void release_resources_for_core_shutdown(void) > -{ > - struct ti_sci_handle *ti_sci = get_ti_sci_handle(); > - struct ti_sci_dev_ops *dev_ops = &ti_sci->ops.dev_ops; > - struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops; > - int ret; > - u32 i; > - > - const u32 put_device_ids[] = { > - AM6_DEV_MCU_RTI0, > - AM6_DEV_MCU_RTI1, > - }; > - > - /* Iterate through list of devices to put (shutdown) */ > - for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) { > - u32 id = put_device_ids[i]; > - > - ret = dev_ops->put_device(ti_sci, id); > - if (ret) > - panic("Failed to put device %u (%d)\n", id, ret); > - } > - > - const u32 put_core_ids[] = { > - AM6_DEV_MCU_ARMSS0_CPU1, > - AM6_DEV_MCU_ARMSS0_CPU0, /* Handle CPU0 after CPU1 */ > - }; > - > - /* Iterate through list of cores to put (shutdown) */ > - for (i = 0; i < ARRAY_SIZE(put_core_ids); i++) { > - u32 id = put_core_ids[i]; > - > - /* > - * Queue up the core shutdown request. Note that this call > - * needs to be followed up by an actual invocation of an WFE > - * or WFI CPU instruction. > - */ > - ret = proc_ops->proc_shutdown_no_wait(ti_sci, id); > - if (ret) > - panic("Failed sending core %u shutdown message > (%d)\n", > - id, ret); > - } > -} > -#endif > diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c > index 6e084de692c..4f2e14c3105 100644 > --- a/arch/arm/mach-k3/common.c > +++ b/arch/arm/mach-k3/common.c > @@ -189,9 +189,37 @@ int load_firmware(char *name_fw, char *name_loadaddr, > u32 *loadaddr) > return size; > } > > -__weak void release_resources_for_core_shutdown(void) > +void release_resources_for_core_shutdown(void) > { > - debug("%s not implemented...\n", __func__); > + struct ti_sci_handle *ti_sci = get_ti_sci_handle(); > + struct ti_sci_dev_ops *dev_ops = &ti_sci->ops.dev_ops; > + struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops; > + int ret; > + u32 i; > + > + /* Iterate through list of devices to put (shutdown) */ > + for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) { > + u32 id = put_device_ids[i]; > + > + ret = dev_ops->put_device(ti_sci, id); > + if (ret) > + panic("Failed to put device %u (%d)\n", id, ret); > + } > + > + /* Iterate through list of cores to put (shutdown) */ > + for (i = 0; i < ARRAY_SIZE(put_core_ids); i++) { > + u32 id = put_core_ids[i]; > + > + /* > + * Queue up the core shutdown request. Note that this call > + * needs to be followed up by an actual invocation of an WFE > + * or WFI CPU instruction. > + */ > + ret = proc_ops->proc_shutdown_no_wait(ti_sci, id); > + if (ret) > + panic("Failed sending core %u shutdown message > (%d)\n", > + id, ret); > + } > } > > void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) > diff --git a/arch/arm/mach-k3/include/mach/am62_hardware.h > b/arch/arm/mach-k3/include/mach/am62_hardware.h > index db4a32cd461..88d58947269 100644 > --- a/arch/arm/mach-k3/include/mach/am62_hardware.h > +++ b/arch/arm/mach-k3/include/mach/am62_hardware.h > @@ -57,4 +57,12 @@ > > #define TI_SRAM_SCRATCH_BOARD_EEPROM_START 0x43c30000 > > +#if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__) > + > +static const u32 put_device_ids[] = {}; > + > +static const u32 put_core_ids[] = {}; > + > +#endif > + > #endif /* __ASM_ARCH_AM62_HARDWARE_H */ > diff --git a/arch/arm/mach-k3/include/mach/am62a_hardware.h > b/arch/arm/mach-k3/include/mach/am62a_hardware.h > index 13bf50f147b..11080801c4c 100644 > --- a/arch/arm/mach-k3/include/mach/am62a_hardware.h > +++ b/arch/arm/mach-k3/include/mach/am62a_hardware.h > @@ -86,4 +86,12 @@ > #define TI_SRAM_SCRATCH_BOARD_EEPROM_START 0x70000001 > #endif /* CONFIG_CPU_V7R */ > > +#if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__) > + > +static const u32 put_device_ids[] = {}; > + > +static const u32 put_core_ids[] = {}; > + > +#endif > + > #endif /* __ASM_ARCH_AM62A_HARDWARE_H */ > diff --git a/arch/arm/mach-k3/include/mach/am64_hardware.h > b/arch/arm/mach-k3/include/mach/am64_hardware.h > index 207ef95f218..44df887d5df 100644 > --- a/arch/arm/mach-k3/include/mach/am64_hardware.h > +++ b/arch/arm/mach-k3/include/mach/am64_hardware.h > @@ -7,6 +7,11 @@ > #ifndef __ASM_ARCH_AM64_HARDWARE_H > #define __ASM_ARCH_AM64_HARDWARE_H > > +#include <config.h> > +#ifndef __ASSEMBLY__ > +#include <linux/bitops.h> > +#endif > + > #define PADCFG_MMR1_BASE 0x000f0000 > #define MCU_PADCFG_MMR1_BASE 0x04080000 > #define WKUP_CTRL_MMR0_BASE 0x43000000 > @@ -41,4 +46,23 @@ > /* Use Last 2K as Scratch pad */ > #define TI_SRAM_SCRATCH_BOARD_EEPROM_START 0x7019f800 > > +#if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__) > + > +#define AM64X_DEV_RTI8 127 > +#define AM64X_DEV_RTI9 128 > +#define AM64X_DEV_R5FSS0_CORE0 121 > +#define AM64X_DEV_R5FSS0_CORE1 122 > + > +static const u32 put_device_ids[] = { > + AM64X_DEV_RTI9, > + AM64X_DEV_RTI8, > +}; > + > +static const u32 put_core_ids[] = { > + AM64X_DEV_R5FSS0_CORE1, > + AM64X_DEV_R5FSS0_CORE0, /* Handle CPU0 after CPU1 */ > +}; > + > +#endif > + > #endif /* __ASM_ARCH_DRA8_HARDWARE_H */ > diff --git a/arch/arm/mach-k3/include/mach/am6_hardware.h > b/arch/arm/mach-k3/include/mach/am6_hardware.h > index f9f32918f7c..029041f415c 100644 > --- a/arch/arm/mach-k3/include/mach/am6_hardware.h > +++ b/arch/arm/mach-k3/include/mach/am6_hardware.h > @@ -39,4 +39,23 @@ > > #define NAVSS_NBSS_THREADMAP 0x10 > > +#if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__) > + > +#define AM6_DEV_MCU_RTI0 134 > +#define AM6_DEV_MCU_RTI1 135 > +#define AM6_DEV_MCU_ARMSS0_CPU0 159 > +#define AM6_DEV_MCU_ARMSS0_CPU1 245 > + > +static const u32 put_device_ids[] = { > + AM6_DEV_MCU_RTI0, > + AM6_DEV_MCU_RTI1, > +}; > + > +static const u32 put_core_ids[] = { > + AM6_DEV_MCU_ARMSS0_CPU1, > + AM6_DEV_MCU_ARMSS0_CPU0, /* Handle CPU0 after CPU1 */ > +}; > + > +#endif > + > #endif /* __ASM_ARCH_AM6_HARDWARE_H */ > diff --git a/arch/arm/mach-k3/include/mach/j721e_hardware.h > b/arch/arm/mach-k3/include/mach/j721e_hardware.h > index 247dee99ce5..376db389ba1 100644 > --- a/arch/arm/mach-k3/include/mach/j721e_hardware.h > +++ b/arch/arm/mach-k3/include/mach/j721e_hardware.h > @@ -38,4 +38,23 @@ > /* MCU SCRATCHPAD usage */ > #define TI_SRAM_SCRATCH_BOARD_EEPROM_START > CONFIG_SYS_K3_MCU_SCRATCHPAD_BASE > > +#if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__) > + > +#define J721E_DEV_MCU_RTI0 262 > +#define J721E_DEV_MCU_RTI1 263 > +#define J721E_DEV_MCU_ARMSS0_CPU0 250 > +#define J721E_DEV_MCU_ARMSS0_CPU1 251 > + > +static const u32 put_device_ids[] = { > + J721E_DEV_MCU_RTI0, > + J721E_DEV_MCU_RTI1, > +}; > + > +static const u32 put_core_ids[] = { > + J721E_DEV_MCU_ARMSS0_CPU1, > + J721E_DEV_MCU_ARMSS0_CPU0, /* Handle CPU0 after CPU1 */ > +}; > + > +#endif > + > #endif /* __ASM_ARCH_J721E_HARDWARE_H */ > diff --git a/arch/arm/mach-k3/include/mach/j721s2_hardware.h > b/arch/arm/mach-k3/include/mach/j721s2_hardware.h > index 2e155ed9ec4..7948bcf4789 100644 > --- a/arch/arm/mach-k3/include/mach/j721s2_hardware.h > +++ b/arch/arm/mach-k3/include/mach/j721s2_hardware.h > @@ -38,4 +38,23 @@ > /* MCU SCRATCHPAD usage */ > #define TI_SRAM_SCRATCH_BOARD_EEPROM_START > CONFIG_SYS_K3_MCU_SCRATCHPAD_BASE > > +#if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__) > + > +#define J721S2_DEV_MCU_RTI0 295 > +#define J721S2_DEV_MCU_RTI1 296 > +#define J721S2_DEV_MCU_ARMSS0_CPU0 284 > +#define J721S2_DEV_MCU_ARMSS0_CPU1 285 > + > +static const u32 put_device_ids[] = { > + J721S2_DEV_MCU_RTI0, > + J721S2_DEV_MCU_RTI1, > +}; > + > +static const u32 put_core_ids[] = { > + J721S2_DEV_MCU_ARMSS0_CPU1, > + J721S2_DEV_MCU_ARMSS0_CPU0, /* Handle CPU0 after CPU1 */ > +}; > + > +#endif > + > #endif /* __ASM_ARCH_J721S2_HARDWARE_H */ > diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h > b/arch/arm/mach-k3/include/mach/sys_proto.h > index d5d4b787b7d..8cc75b636b5 100644 > --- a/arch/arm/mach-k3/include/mach/sys_proto.h > +++ b/arch/arm/mach-k3/include/mach/sys_proto.h > @@ -12,7 +12,6 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, void > *read_addr, > u32 bound); > struct ti_sci_handle *get_ti_sci_handle(void); > int do_board_detect(void); > -void release_resources_for_core_shutdown(void); > int fdt_disable_node(void *blob, char *node_path); > > void k3_spl_init(void); > diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c > index 432cbc6a992..6d848239399 100644 > --- a/arch/arm/mach-k3/j721e_init.c > +++ b/arch/arm/mach-k3/j721e_init.c > @@ -398,58 +398,3 @@ u32 spl_boot_device(void) > else > return __get_backup_bootmedia(main_devstat); > } > - > -#ifdef CONFIG_SYS_K3_SPL_ATF > - > -#define J721E_DEV_MCU_RTI0 262 > -#define J721E_DEV_MCU_RTI1 263 > -#define J721E_DEV_MCU_ARMSS0_CPU0 250 > -#define J721E_DEV_MCU_ARMSS0_CPU1 251 > - > -void release_resources_for_core_shutdown(void) > -{ > - struct ti_sci_handle *ti_sci; > - struct ti_sci_dev_ops *dev_ops; > - struct ti_sci_proc_ops *proc_ops; > - int ret; > - u32 i; > - > - const u32 put_device_ids[] = { > - J721E_DEV_MCU_RTI0, > - J721E_DEV_MCU_RTI1, > - }; > - > - ti_sci = get_ti_sci_handle(); > - dev_ops = &ti_sci->ops.dev_ops; > - proc_ops = &ti_sci->ops.proc_ops; > - > - /* Iterate through list of devices to put (shutdown) */ > - for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) { > - u32 id = put_device_ids[i]; > - > - ret = dev_ops->put_device(ti_sci, id); > - if (ret) > - panic("Failed to put device %u (%d)\n", id, ret); > - } > - > - const u32 put_core_ids[] = { > - J721E_DEV_MCU_ARMSS0_CPU1, > - J721E_DEV_MCU_ARMSS0_CPU0, /* Handle CPU0 after CPU1 */ > - }; > - > - /* Iterate through list of cores to put (shutdown) */ > - for (i = 0; i < ARRAY_SIZE(put_core_ids); i++) { > - u32 id = put_core_ids[i]; > - > - /* > - * Queue up the core shutdown request. Note that this call > - * needs to be followed up by an actual invocation of an WFE > - * or WFI CPU instruction. > - */ > - ret = proc_ops->proc_shutdown_no_wait(ti_sci, id); > - if (ret) > - panic("Failed sending core %u shutdown message > (%d)\n", > - id, ret); > - } > -} > -#endif > diff --git a/arch/arm/mach-k3/j721s2_init.c b/arch/arm/mach-k3/j721s2_init.c > index 09e55ed4566..fb95984c1ab 100644 > --- a/arch/arm/mach-k3/j721s2_init.c > +++ b/arch/arm/mach-k3/j721s2_init.c > @@ -264,57 +264,3 @@ u32 spl_boot_device(void) > else > return __get_backup_bootmedia(main_devstat); > } > - > -#define J721S2_DEV_MCU_RTI0 295 > -#define J721S2_DEV_MCU_RTI1 296 > -#define J721S2_DEV_MCU_ARMSS0_CPU0 284 > -#define J721S2_DEV_MCU_ARMSS0_CPU1 285 > - > -void release_resources_for_core_shutdown(void) > -{ > - if (IS_ENABLED(CONFIG_SYS_K3_SPL_ATF)) { > - struct ti_sci_handle *ti_sci; > - struct ti_sci_dev_ops *dev_ops; > - struct ti_sci_proc_ops *proc_ops; > - int ret; > - u32 i; > - > - const u32 put_device_ids[] = { > - J721S2_DEV_MCU_RTI0, > - J721S2_DEV_MCU_RTI1, > - }; > - > - ti_sci = get_ti_sci_handle(); > - dev_ops = &ti_sci->ops.dev_ops; > - proc_ops = &ti_sci->ops.proc_ops; > - > - /* Iterate through list of devices to put (shutdown) */ > - for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) { > - u32 id = put_device_ids[i]; > - > - ret = dev_ops->put_device(ti_sci, id); > - if (ret) > - panic("Failed to put device %u (%d)\n", id, > ret); > - } > - > - const u32 put_core_ids[] = { > - J721S2_DEV_MCU_ARMSS0_CPU1, > - J721S2_DEV_MCU_ARMSS0_CPU0, /* Handle CPU0 after > CPU1 */ > - }; > - > - /* Iterate through list of cores to put (shutdown) */ > - for (i = 0; i < ARRAY_SIZE(put_core_ids); i++) { > - u32 id = put_core_ids[i]; > - > - /* > - * Queue up the core shutdown request. Note that this > call > - * needs to be followed up by an actual invocation of > an WFE > - * or WFI CPU instruction. > - */ > - ret = proc_ops->proc_shutdown_no_wait(ti_sci, id); > - if (ret) > - panic("Failed sending core %u shutdown > message (%d)\n", > - id, ret); > - } > - } > -} > -- > 2.39.2 > -- greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy

