From patchwork Sat Feb 27 18:19:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 589438 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 376AD1401C7 for ; Sun, 28 Feb 2016 05:24:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 89D7EB3817; Sat, 27 Feb 2016 19:22:10 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uahJ89hKrCs3; Sat, 27 Feb 2016 19:22:10 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 54878A78F8; Sat, 27 Feb 2016 19:21:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 94292B3807 for ; Sat, 27 Feb 2016 19:21:35 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L4FdD8LfL7nd for ; Sat, 27 Feb 2016 19:21:35 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from gagarine.paulk.fr (gagarine.paulk.fr [109.190.93.129]) by theia.denx.de (Postfix) with ESMTPS id 07ED7B37F8 for ; Sat, 27 Feb 2016 19:21:23 +0100 (CET) Received: by gagarine.paulk.fr (Postfix, from userid 65534) id 7A6B420327; Sat, 27 Feb 2016 19:21:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on gagarine.paulk.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from armstrong.paulk.fr (armstrong.paulk.fr [82.233.88.171]) by gagarine.paulk.fr (Postfix) with ESMTPS id 7546220490; Sat, 27 Feb 2016 19:19:16 +0100 (CET) Received: from localhost.localdomain (aldrin [192.168.0.128]) by armstrong.paulk.fr (Postfix) with ESMTP id 582B9378FF; Sat, 27 Feb 2016 19:19:13 +0100 (CET) From: Paul Kocialkowski To: u-boot@lists.denx.de Date: Sat, 27 Feb 2016 19:19:14 +0100 Message-Id: <1456597155-10711-27-git-send-email-contact@paulk.fr> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1456597155-10711-1-git-send-email-contact@paulk.fr> References: <1456597155-10711-1-git-send-email-contact@paulk.fr> Cc: Marek Vasut , Tom Rini , Hashcode Subject: [U-Boot] [PATCH 26/27] kc1: Power off when the power on reason is not a valid one X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Some power on reasons are not desirable (e.g. too short press on the power button), battery plug. Thus, power off the device when one of those occurs. Signed-off-by: Paul Kocialkowski --- board/amazon/kc1/kc1.c | 16 ++++++++++++++++ include/configs/kc1.h | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/board/amazon/kc1/kc1.c b/board/amazon/kc1/kc1.c index 9367b50..54e3fa3 100644 --- a/board/amazon/kc1/kc1.c +++ b/board/amazon/kc1/kc1.c @@ -86,6 +86,7 @@ int board_init(void) int misc_init_r(void) { char reboot_mode[2] = { 0 }; + u32 data = 0; u32 value; /* Reboot mode */ @@ -101,10 +102,25 @@ int misc_init_r(void) reboot_mode[0] = 'b'; if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) { + if (reboot_mode[0] == 'o') + twl6030_power_off(); + if (!getenv("reboot-mode")) setenv("reboot-mode", (char *)reboot_mode); omap_reboot_mode_clear(); + } else { + /* + * When not rebooting, valid power on reasons are either the + * power button, charger plug or USB plug. + */ + + data |= twl6030_input_power_button(); + data |= twl6030_input_charger(); + data |= twl6030_input_usb(); + + if (!data) + twl6030_power_off(); } /* Serial number */ diff --git a/include/configs/kc1.h b/include/configs/kc1.h index 04cb320..c2ac148 100644 --- a/include/configs/kc1.h +++ b/include/configs/kc1.h @@ -105,6 +105,12 @@ #define CONFIG_TWL6030_POWER /* + * Input + */ + +#define CONFIG_TWL6030_INPUT + +/* * Partitions */