]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
stm32mp1: add command poweroff
authorPatrick Delaunay <patrick.delaunay@st.com>
Fri, 12 Apr 2019 09:55:46 +0000 (11:55 +0200)
committerPatrick Delaunay <patrick.delaunay@st.com>
Fri, 12 Apr 2019 14:09:13 +0000 (16:09 +0200)
Activate the command poweroff by default for STM32MP1:
- with PCSI from TF-A for trusted boot
- with PMIC sysreset request for basic boot (SYSRESET_POWER)

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
arch/arm/Kconfig
arch/arm/mach-stm32mp/Makefile
arch/arm/mach-stm32mp/cmd_poweroff.c [new file with mode: 0644]

index 33628b86d45b4798d9b1045d44de6917e9e786b9..28d4d35968f88ddaeadb8976d585c743a55f6fa3 100644 (file)
@@ -1403,6 +1403,7 @@ config ARCH_STM32MP
        select SYSRESET
        select SYS_THUMB_BUILD
        imply CMD_DM
+       imply CMD_POWEROFF
        imply ENV_VARS_UBOOT_RUNTIME_CONFIG
        help
          Support for STM32MP SoC family developed by STMicroelectronics,
index f59ced5ee1b1a5904328b4f8b4ee24903675b55c..1493914a110d3cc8be870017cc71521383a68dc8 100644 (file)
@@ -11,6 +11,9 @@ ifdef CONFIG_SPL_BUILD
 obj-y += spl.o
 else
 obj-y += bsec.o
+ifndef CONFIG_STM32MP1_TRUSTED
+obj-$(CONFIG_SYSRESET) += cmd_poweroff.o
+endif
 endif
 obj-$(CONFIG_ARMV7_PSCI) += psci.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR) += pwr_regulator.o
diff --git a/arch/arm/mach-stm32mp/cmd_poweroff.c b/arch/arm/mach-stm32mp/cmd_poweroff.c
new file mode 100644 (file)
index 0000000..f54dd1d
--- /dev/null
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
+ */
+
+#include <common.h>
+#include <command.h>
+#include <sysreset.h>
+
+int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       int ret;
+
+       puts("poweroff ...\n");
+       mdelay(100);
+
+       ret = sysreset_walk(SYSRESET_POWER);
+
+       if (ret == -EINPROGRESS)
+               mdelay(1000);
+
+       /*NOTREACHED when power off*/
+       return CMD_RET_FAILURE;
+}