From: Andrew Davis <afd@ti.com>
To: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
<u-boot@lists.denx.de>
Cc: Andrew Davis <afd@ti.com>
Subject: [PATCH 06/12] arm: mach-k3: Make release_resources_for_core_shutdown() common
Date: Thu, 30 Mar 2023 15:28:51 -0500 [thread overview]
Message-ID: <20230330202857.8216-6-afd@ti.com> (raw)
In-Reply-To: <20230330202857.8216-1-afd@ti.com>
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 <afd@ti.com>
---
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 96f292ea75c..74297be0f20 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 768fdd69602..8ee1e9be643 100644
--- a/arch/arm/mach-k3/am654_init.c
+++ b/arch/arm/mach-k3/am654_init.c
@@ -354,54 +354,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 233b867e90c..afd46647405 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -399,58 +399,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
next prev parent reply other threads:[~2023-03-30 20:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 20:28 [PATCH 01/12] arm: mach-k3: Move MSMC fixup to SoC level Andrew Davis
2023-03-30 20:28 ` [PATCH 02/12] arm: mach-k3: Move J721e SoC detection out of common section Andrew Davis
2023-03-30 20:28 ` [PATCH 03/12] soc: soc_ti_k3: Use hardware.h to remove definition duplication Andrew Davis
2023-03-30 20:28 ` [PATCH 04/12] configs: j721x_evm.h: Remove unneeded check for SYS_K3_SPL_ATF Andrew Davis
2023-03-30 20:28 ` [PATCH 05/12] configs: j721s2_evm.h: Remove refrences to J7200 EVM Andrew Davis
2023-03-30 20:28 ` Andrew Davis [this message]
2023-03-30 20:28 ` [PATCH 07/12] arm: mach-k3: Move sysfw-loader.h out of mach includes Andrew Davis
2023-03-30 20:28 ` [PATCH 08/12] arm: mach-k3: Add weak do_board_detect() to common file Andrew Davis
2023-04-02 10:44 ` Christian Gmeiner
2023-04-05 14:42 ` Andrew Davis
2023-03-30 20:28 ` [PATCH 09/12] arm: mach-k3: Remove unused fdt_disable_node() Andrew Davis
2023-03-30 20:28 ` [PATCH 10/12] arm: mach-k3: Move sdelay() and wait_on_value() declaration Andrew Davis
2023-03-30 20:28 ` [PATCH 11/12] arm: mach-k3: Move J721s2 SPL init functions to mach-k3 Andrew Davis
2023-03-30 20:28 ` [PATCH 12/12] arm: mach-k3: Remove empty sys_proto.h include Andrew Davis
2023-04-02 10:47 ` [PATCH 01/12] arm: mach-k3: Move MSMC fixup to SoC level Christian Gmeiner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230330202857.8216-6-afd@ti.com \
--to=afd@ti.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox