From: Przemyslaw Marczak
Date: Mon, 9 Jun 2014 06:25:09 +0000 (+0200)
Subject: common: add command power off - to switch off the device by command
X-Git-Tag: submit/tizen_common/20150115.132736~67
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9121b3d891bf5a89f315b70d9a42ec844f30c74b;p=platform%2Fkernel%2Fu-boot.git
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
---
diff --git a/common/Makefile b/common/Makefile
index c668a2fd5b..2c771cd8e4 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -187,6 +187,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
+ *
+ * Power off command
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include
+#include
+
+/*
+ * 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",
+ "\n"
+ "It turn off the power supply of the board"
+);