From patchwork Mon Mar 28 12:07:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 602460 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 3qYXhr37zwz9s9k for ; Mon, 28 Mar 2016 23:07:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3538EA7662; Mon, 28 Mar 2016 14:07:16 +0200 (CEST) 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 3Hh1O6uuniwF; Mon, 28 Mar 2016 14:07:16 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7C36EA7663; Mon, 28 Mar 2016 14:07:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D4658A7631 for ; Mon, 28 Mar 2016 14:06:56 +0200 (CEST) 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 twOmIVWOcrCZ for ; Mon, 28 Mar 2016 14:06:56 +0200 (CEST) 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 2B37BA7626 for ; Mon, 28 Mar 2016 14:06:45 +0200 (CEST) Received: by gagarine.paulk.fr (Postfix, from userid 65534) id A498820AA6; Mon, 28 Mar 2016 14:06:43 +0200 (CEST) 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 9DB3320A8D; Mon, 28 Mar 2016 14:06:33 +0200 (CEST) Received: from localhost.localdomain (aldrin [192.168.0.128]) by armstrong.paulk.fr (Postfix) with ESMTP id B6E7C378F3; Mon, 28 Mar 2016 14:06:30 +0200 (CEST) From: Paul Kocialkowski To: u-boot@lists.denx.de Date: Mon, 28 Mar 2016 14:07:13 +0200 Message-Id: <1459166834-26015-6-git-send-email-contact@paulk.fr> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1459166834-26015-1-git-send-email-contact@paulk.fr> References: <1459166834-26015-1-git-send-email-contact@paulk.fr> Cc: Tom Rini Subject: [U-Boot] [PATCH 6/7] kc1: Proper reboot mode and boot reason validation 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" With the previous implementation, rebooting without registering a recognized reboot mode would end up with U-Boot checking for a valid power-on reason, which might result in the device turning off (e.g. with no USB cable attached and no buttons pressed). Since this approach is not viable (breaks reboot in most cases), the validity of the reboot reason is checked (in turn, by checking that a warm reset happened, as there is no magic) to detect a reboot and the 'o' char is recognized to indicate that power-off is required. Still, that might be overridden by the detection of usual power-on reasons, on purpose. Signed-off-by: Paul Kocialkowski Reviewed-by: Tom Rini --- board/amazon/kc1/kc1.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/board/amazon/kc1/kc1.c b/board/amazon/kc1/kc1.c index ca63af8..469a83e 100644 --- a/board/amazon/kc1/kc1.c +++ b/board/amazon/kc1/kc1.c @@ -88,10 +88,11 @@ int misc_init_r(void) char reboot_mode[2] = { 0 }; u32 data = 0; u32 value; + int rc; /* Reboot mode */ - omap_reboot_mode(reboot_mode, sizeof(reboot_mode)); + rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode)); /* USB ID pin pull-up indicates factory (fastboot) cable detection. */ gpio_request(KC1_GPIO_USB_ID, "USB_ID"); @@ -101,18 +102,7 @@ int misc_init_r(void) if (value) 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 { - /* Reboot mode garbage may still be valid, so clear it. */ - omap_reboot_mode_clear(); - + if (rc < 0 || reboot_mode[0] == 'o') { /* * When not rebooting, valid power on reasons are either the * power button, charger plug or USB plug. @@ -126,6 +116,13 @@ int misc_init_r(void) twl6030_power_off(); } + if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) { + if (!getenv("reboot-mode")) + setenv("reboot-mode", (char *)reboot_mode); + } + + omap_reboot_mode_clear(); + /* Serial number */ omap_die_id_serial();