summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrzemyslaw Marczak <p.marczak@samsung.com>2014-06-09 08:25:09 +0200
committerPrzemyslaw Marczak <p.marczak@samsung.com>2015-05-18 11:29:13 +0200
commit1d99b2964c34765a681b4a5a671baecc7e415788 (patch)
tree2c1d78af821af403e236984ddb3cbac33aad4da4
parent150bf2b87f9bb8fe4aa4adcc865d1b5242f1afdf (diff)
downloadu-boot-1d99b2964c34765a681b4a5a671baecc7e415788.tar.gz
u-boot-1d99b2964c34765a681b4a5a671baecc7e415788.tar.bz2
u-boot-1d99b2964c34765a681b4a5a671baecc7e415788.zip
common: add command power off - to switch off the device by command
This change introduces new config: - CONFIG_CMD_POWEROFF - which enables common/cmd_poweroff.c This requires implementation of function board_poweroff() which is yet declared in include/common.h Implementation of board_poweroff() should: 1.a. turn off the device or 1.b. print info to user about turn off ability 2. never back to caller Usage is simple: "power off" Change-Id: Ia5fe73250e2ac29d0868b80bcd867bae2aa8d5be Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
-rw-r--r--common/Makefile1
-rw-r--r--common/cmd_poweroff.c42
2 files changed, 43 insertions, 0 deletions
diff --git a/common/Makefile b/common/Makefile
index 9084c73ad9..9223487325 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -191,6 +191,7 @@ obj-$(CONFIG_YAFFS2) += cmd_yaffs2.o
obj-$(CONFIG_CMD_SPL) += cmd_spl.o
obj-$(CONFIG_CMD_ZIP) += cmd_zip.o
obj-$(CONFIG_CMD_ZFS) += cmd_zfs.o
+obj-$(CONFIG_CMD_POWEROFF) += cmd_poweroff.o
# others
obj-$(CONFIG_BOOTSTAGE) += bootstage.o
diff --git a/common/cmd_poweroff.c b/common/cmd_poweroff.c
new file mode 100644
index 0000000000..2f310f1d06
--- /dev/null
+++ b/common/cmd_poweroff.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ * Przemyslaw Marczak <p.marczak@samsung.com>
+ *
+ * Power off command
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+
+/*
+ * Power off the board by simple command
+ * This requires implementation of function board_poweroff() which is declared
+ * in include/common.h
+ *
+ * Implementation of board_poweroff() should:
+ * 1.a. turn off the device
+ * or
+ * 1.b. print info to user about turn off ability as it is in few boards
+ * 2. never back to caller
+ */
+int do_power_off(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ if (argc != 2)
+ return CMD_RET_USAGE;
+
+ if (!strcmp("off", argv[1])) {
+ board_poweroff();
+ /* This function should not back here */
+ return CMD_RET_SUCCESS;
+ }
+
+ return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(power, CONFIG_SYS_MAXARGS, 1, do_power_off,
+ "Device power off",
+ "<off>\n"
+ "It turn off the power supply of the board"
+);