From 811578e51bc1ead0ed20ca8b9afa4719f6733187 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Mon, 9 Jun 2014 08:25:09 +0200 Subject: [PATCH] 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 --- cmd/Makefile | 1 + cmd/poweroff.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 cmd/poweroff.c diff --git a/cmd/Makefile b/cmd/Makefile index 3a9c974..5c0079d 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -116,6 +116,7 @@ endif obj-$(CONFIG_CMD_PINMUX) += pinmux.o obj-$(CONFIG_CMD_PMC) += pmc.o obj-$(CONFIG_CMD_PXE) += pxe.o pxe_utils.o +obj-$(CONFIG_CMD_POWEROFF) += poweroff.o obj-$(CONFIG_CMD_WOL) += wol.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 index 0000000..96bcd6d --- /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; +} -- 2.7.4