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/20160425.072005~58
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a36ae8b814497125c65cddd0d57e142d449693d;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 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"
Changed for v2016.03:
- Relocated from common directory to cmd directory
- Renamed from cmd_poweroff to poweroff
Change-Id: Ia5fe73250e2ac29d0868b80bcd867bae2aa8d5be
Signed-off-by: Przemyslaw Marczak
---
diff --git a/cmd/Makefile b/cmd/Makefile
index 03f7e0a21d..40e9c1e3a5 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -102,6 +102,7 @@ obj-$(CONFIG_CMD_PCI) += pci.o
endif
obj-y += pcmcia.o
obj-$(CONFIG_CMD_PORTIO) += portio.o
+obj-$(CONFIG_CMD_POWEROFF) += poweroff.o
obj-$(CONFIG_CMD_PXE) += pxe.o
obj-$(CONFIG_CMD_READ) += read.o
obj-$(CONFIG_CMD_REGINFO) += reginfo.o
diff --git a/cmd/poweroff.c b/cmd/poweroff.c
new file mode 100644
index 0000000000..96bcd6d68b
--- /dev/null
+++ b/cmd/poweroff.c
@@ -0,0 +1,36 @@
+/*
+ * 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_poweroff(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;
+}