common: add command power off - to switch off the device by command
authorPrzemyslaw Marczak <p.marczak@samsung.com>
Mon, 9 Jun 2014 06:25:09 +0000 (08:25 +0200)
committerJaehoon Chung <jh80.chung@samsung.com>
Wed, 5 Apr 2017 09:57:02 +0000 (18:57 +0900)
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 <p.marczak@samsung.com>
cmd/Makefile
cmd/poweroff.c [new file with mode: 0644]

index f13bb8c..685952e 100644 (file)
@@ -107,6 +107,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_QFW) += qfw.o
 obj-$(CONFIG_CMD_READ) += read.o
diff --git a/cmd/poweroff.c b/cmd/poweroff.c
new file mode 100644 (file)
index 0000000..96bcd6d
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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_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;
+}