MA-17353-1 Add system board reset command for imx8q devices
authorJi Luo <ji.luo@nxp.com>
Wed, 10 Jun 2020 10:29:54 +0000 (18:29 +0800)
committerJi Luo <ji.luo@nxp.com>
Thu, 13 May 2021 01:49:18 +0000 (09:49 +0800)
Default 'reset' command in bootloader will only trigger partition reboot
for A core, which will not reload everything (like SPL, SCFW, M4, etc.).
Sometimes, we want to trigger a board reboot without pressing the reset
button, it can be very helpful in some cases like remote debugging...

This commit adds command 'reboot' to trigger system board reboot via the
psci interface provided by ATF, it's enabled on i.MX 8 Quad platforms only.

Test: system board reboot on imx8qm/imx8qxp.

Change-Id: I27f2291806b6959d46fa6f55fe186041d141d2f4
Signed-off-by: Ji Luo <ji.luo@nxp.com>
(cherry picked from commit f8a127354ba4f77ba5b1af87f692133bb704cfe0)
(cherry picked from commit 646b99c6bcba96c97d3517a2c21d54908a8c4ed5)

arch/arm/mach-imx/imx8/Kconfig
arch/arm/mach-imx/imx8/misc.c

index bb3b2da..2f31a4f 100644 (file)
@@ -71,6 +71,12 @@ config BOOTAUX_RESERVED_MEM_SIZE
        hex "i.MX auxiliary core dram memory size"
        default 0
 
+config PSCI_BOARD_REBOOT
+       bool "Enable psci board reboot command"
+       depends on ARM_PSCI_FW
+       help
+         This is a optional command used to trigger system board reboot on imx8.
+
 choice
        prompt "i.MX8 board select"
        optional
index 508a7c8..0b86214 100644 (file)
@@ -10,6 +10,9 @@
 #include <generated/version_autogenerated.h>
 #include <linux/libfdt.h>
 #include <asm/arch/lpcg.h>
+#include <linux/psci.h>
+#include <dm.h>
+#include <command.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -134,3 +137,25 @@ void build_info(void)
        }
        printf("\n");
 }
+
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_PSCI_BOARD_REBOOT)
+
+#define PSCI_SYSTEM_RESET2_AARCH64             0xc4000012
+#define PSCI_RESET2_SYSTEM_BOARD_RESET         0x80000002
+
+int do_board_reboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       struct udevice *dev;
+
+       uclass_get_device_by_name(UCLASS_FIRMWARE, "psci", &dev);
+       invoke_psci_fn(PSCI_SYSTEM_RESET2_AARCH64, PSCI_RESET2_SYSTEM_BOARD_RESET, 0, 0);
+
+       return 1;
+}
+
+U_BOOT_CMD(
+       reboot, 1,      1,      do_board_reboot,
+       "reboot\n",
+       "system board reboot for i.MX 8 Quad devices \n"
+);
+#endif