From patchwork Wed Feb 19 16:50:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 1240893 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=c-s.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=c-s.fr header.i=@c-s.fr header.a=rsa-sha256 header.s=mail header.b=au0VQ8Eo; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48N4KT2wYBz9sRl for ; Thu, 20 Feb 2020 04:22:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 82BE881262; Wed, 19 Feb 2020 18:22:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=c-s.fr Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=c-s.fr header.i=@c-s.fr header.b="au0VQ8Eo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7636A8104A; Wed, 19 Feb 2020 17:50:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 93EA08104A for ; Wed, 19 Feb 2020 17:50:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=c-s.fr Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=christophe.leroy@c-s.fr Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48N3cQ3jhTz9v9Dm; Wed, 19 Feb 2020 17:50:14 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=au0VQ8Eo; dkim-adsp=pass; dkim-atps=neutral Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id dljxRG4zxFgM; Wed, 19 Feb 2020 17:50:14 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48N3cQ2fzYz9v9Dl; Wed, 19 Feb 2020 17:50:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1582131014; bh=F6iIIlGjc4F4dK5bu0Mm1QtkCq6/MpOT/R3GfrbJQZI=; h=From:Subject:To:Cc:Date:From; b=au0VQ8EoD46zqdJLP6HDjqzOAKQyTACWrzrg1mMzMGpdnl5C3oA4E6AEXdTGkAWL2 +fGN5YxZPyAicc1EEdjYzwS87h9S4XuD9eLQhqrRVGouJBHfD/fhuejMEUS9YOPPrj cDLVZNG6yYzpqE3ploXs5InsdUb3E3v38jVU2kEQ= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 02FA88B85B; Wed, 19 Feb 2020 17:50:16 +0100 (CET) Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 9lkl0PoxNzwy; Wed, 19 Feb 2020 17:50:15 +0100 (CET) Received: from pc16570vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.102]) by messagerie.si.c-s.fr (Postfix) with ESMTP id CAC2A8B856; Wed, 19 Feb 2020 17:50:15 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id B87FF65335; Wed, 19 Feb 2020 16:50:15 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH] watchdog: mpc8xx_wdt: Allow selection of watchdog mode through environment To: Tom Rini Cc: u-boot@lists.denx.de, charles.frey@c-s.fr Date: Wed, 19 Feb 2020 16:50:15 +0000 (UTC) X-Mailman-Approved-At: Wed, 19 Feb 2020 18:22:13 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean From: Charles Frey The mpc8xx watchdog can work either in 'reset mode' or 'NMI mode'. The selection can be done at startup only. It is desirable to select the mode without rebuilding U-boot. It is also desirable to disable the watchdog without rebuilding. At watchdog startup, check environment variable 'watchdog_mode'. If it is 'off', the watchdog is not started. If it is 'nmi', the watchdog is started in NMI mode. Otherwise, it is started in reset mode which is the default mode. Signed-off-by: Charles Frey Signed-off-by: Christophe Leroy --- drivers/watchdog/mpc8xx_wdt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c index 675b62d8b3..8a7a4c5bc6 100644 --- a/drivers/watchdog/mpc8xx_wdt.c +++ b/drivers/watchdog/mpc8xx_wdt.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -21,8 +22,15 @@ static void hw_watchdog_reset(void) static int mpc8xx_wdt_start(struct udevice *dev, u64 timeout, ulong flags) { immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; + u32 val = CONFIG_SYS_SYPCR; + const char *mode = env_get("watchdog_mode"); - out_be32(&immap->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR); + if (strcmp(mode, "off") == 0) + val = val & ~(SYPCR_SWE | SYPCR_SWRI); + else if (strcmp(mode, "nmi") == 0) + val = (val & ~SYPCR_SWRI) | SYPCR_SWE; + + out_be32(&immap->im_siu_conf.sc_sypcr, val); if (!(in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE)) return -EBUSY;