[U-Boot] [PATCH] arm: Add support for poweroff via PSCI

Michal Simek michal.simek at xilinx.com
Mon May 29 07:11:32 UTC 2017


Add support for calling poweroff in case of psci is wired.
Based on the same solution as is used for reset.

Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---

 arch/arm/cpu/armv8/fwcall.c |  7 +++++++
 arch/arm/lib/Makefile       |  1 +
 arch/arm/lib/poweroff.c     | 47 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)
 create mode 100644 arch/arm/lib/poweroff.c

diff --git a/arch/arm/cpu/armv8/fwcall.c b/arch/arm/cpu/armv8/fwcall.c
index 7dfd27002916..af716cac4094 100644
--- a/arch/arm/cpu/armv8/fwcall.c
+++ b/arch/arm/cpu/armv8/fwcall.c
@@ -114,6 +114,13 @@ void __noreturn __efi_runtime psci_system_off(void)
 		;
 }
 
+#ifdef CONFIG_CMD_POWEROFF
+void poweroff_misc(void)
+{
+	psci_system_off();
+}
+#endif
+
 #ifdef CONFIG_PSCI_RESET
 void reset_misc(void)
 {
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index f162c1428c85..c3d4248ba3eb 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -55,6 +55,7 @@ endif
 ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
 endif
+obj-$(CONFIG_CMD_POWEROFF) += poweroff.o
 
 obj-y	+= cache.o
 ifndef CONFIG_ARM64
diff --git a/arch/arm/lib/poweroff.c b/arch/arm/lib/poweroff.c
new file mode 100644
index 000000000000..956d2c06af66
--- /dev/null
+++ b/arch/arm/lib/poweroff.c
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger at sysgo.de>
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Alex Zuepke <azu at sysgo.de>
+ *
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <garyj at denx.de>
+ *
+ * (C) Copyright 2004
+ * DAVE Srl
+ * http://www.dave-tech.it
+ * http://www.wawnet.biz
+ * mailto:info at wawnet.biz
+ *
+ * (C) Copyright 2004 Texas Insturments
+ *
+ * (C) Copyright 2017, Xilinx Inc.
+ *
+ * Based on reset.c
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+
+__weak void poweroff_misc(void)
+{
+}
+
+int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	puts("poweroff ...\n");
+
+	udelay(50000); /* wait 50 ms */
+
+	disable_interrupts();
+
+	poweroff_misc();
+
+	/*NOTREACHED*/
+	return 0;
+}
+
-- 
1.9.1



More information about the U-Boot mailing list