From patchwork Tue Aug 6 17:05:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 1142980 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sedsystems.ca Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4631Kl3TjQz9sBF for ; Wed, 7 Aug 2019 03:07:55 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 33734C21E70; Tue, 6 Aug 2019 17:06:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de 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 lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CAEBFC21E49; Tue, 6 Aug 2019 17:06:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 727D2C21DA6; Tue, 6 Aug 2019 17:06:45 +0000 (UTC) Received: from sed198n136.sedsystems.ca (sed198n136.SEDSystems.ca [198.169.180.136]) by lists.denx.de (Postfix) with ESMTPS id D510EC21DC1 for ; Tue, 6 Aug 2019 17:06:44 +0000 (UTC) Received: from barney.sedsystems.ca (barney [198.169.180.121]) by sed198n136.sedsystems.ca with ESMTP id x76H6fc6017393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 6 Aug 2019 11:06:41 -0600 (CST) Received: from SED.RFC1918.192.168.sedsystems.ca (eng1n65.eng.sedsystems.ca [172.21.1.65]) by barney.sedsystems.ca (8.14.7/8.14.4) with ESMTP id x76H6cZ2029066 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 6 Aug 2019 11:06:41 -0600 From: Robert Hancock To: u-boot@lists.denx.de Date: Tue, 6 Aug 2019 11:05:29 -0600 Message-Id: <1565111130-18777-2-git-send-email-hancock@sedsystems.ca> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1565111130-18777-1-git-send-email-hancock@sedsystems.ca> References: <1565111130-18777-1-git-send-email-hancock@sedsystems.ca> X-Scanned-By: MIMEDefang 2.64 on 198.169.180.136 Cc: marex@denx.de Subject: [U-Boot] [PATCH 1/2] watchdog: imx: Add DT ext-reset handling X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" The Linux imx2_wdt driver uses a fsl,ext-reset-output boolean in the device tree to specify whether the board design should use the external reset instead of the internal reset. Use this boolean to determine which mode to use rather than using external reset unconditionally. For the legacy non-DM mode, the external reset is always used in order to maintain the previous behavior. Signed-off-by: Robert Hancock --- drivers/watchdog/imx_watchdog.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index 53a3e9f..05bbfe0 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -47,9 +47,10 @@ static void imx_watchdog_reset(struct watchdog_regs *wdog) #endif /* CONFIG_WATCHDOG_RESET_DISABLE*/ } -static void imx_watchdog_init(struct watchdog_regs *wdog) +static void imx_watchdog_init(struct watchdog_regs *wdog, bool ext_reset) { u16 timeout; + u16 wcr; /* * The timer watchdog can be set between @@ -61,11 +62,14 @@ static void imx_watchdog_init(struct watchdog_regs *wdog) #endif timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1; #ifdef CONFIG_FSL_LSCH2 - writew((WCR_WDA | WCR_SRS | WCR_WDE) << 8 | timeout, &wdog->wcr); + wcr = (WCR_WDA | WCR_SRS | WCR_WDE) << 8 | timeout; #else - writew(WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_WDT | WCR_SRS | - WCR_WDA | SET_WCR_WT(timeout), &wdog->wcr); + wcr = WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_SRS | + WCR_WDA | SET_WCR_WT(timeout); + if (ext_reset) + wcr |= WCR_WDT; #endif /* CONFIG_FSL_LSCH2*/ + writew(wcr, &wdog->wcr); imx_watchdog_reset(wdog); } @@ -81,11 +85,12 @@ void hw_watchdog_init(void) { struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; - imx_watchdog_init(wdog); + imx_watchdog_init(wdog, true); } #else struct imx_wdt_priv { void __iomem *base; + bool ext_reset; }; static int imx_wdt_reset(struct udevice *dev) @@ -111,7 +116,7 @@ static int imx_wdt_start(struct udevice *dev, u64 timeout, ulong flags) { struct imx_wdt_priv *priv = dev_get_priv(dev); - imx_watchdog_init(priv->base); + imx_watchdog_init(priv->base, priv->ext_reset); return 0; } @@ -124,6 +129,8 @@ static int imx_wdt_probe(struct udevice *dev) if (!priv->base) return -ENOENT; + priv->ext_reset = dev_read_bool(dev, "fsl,ext-reset-output"); + return 0; } From patchwork Tue Aug 6 17:05:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 1142979 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sedsystems.ca Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4631KJ6Q0Vz9sN1 for ; Wed, 7 Aug 2019 03:07:32 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 96297C21DC1; Tue, 6 Aug 2019 17:07:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de 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 lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 901DDC21E7E; Tue, 6 Aug 2019 17:06:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E3234C21EA6; Tue, 6 Aug 2019 17:06:48 +0000 (UTC) Received: from sed198n136.sedsystems.ca (sed198n136.SEDSystems.ca [198.169.180.136]) by lists.denx.de (Postfix) with ESMTPS id 8215CC21E38 for ; Tue, 6 Aug 2019 17:06:46 +0000 (UTC) Received: from barney.sedsystems.ca (barney [198.169.180.121]) by sed198n136.sedsystems.ca with ESMTP id x76H6hf7027177 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 6 Aug 2019 11:06:43 -0600 (CST) Received: from SED.RFC1918.192.168.sedsystems.ca (eng1n65.eng.sedsystems.ca [172.21.1.65]) by barney.sedsystems.ca (8.14.7/8.14.4) with ESMTP id x76H6cZ3029066 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 6 Aug 2019 11:06:42 -0600 From: Robert Hancock To: u-boot@lists.denx.de Date: Tue, 6 Aug 2019 11:05:30 -0600 Message-Id: <1565111130-18777-3-git-send-email-hancock@sedsystems.ca> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1565111130-18777-1-git-send-email-hancock@sedsystems.ca> References: <1565111130-18777-1-git-send-email-hancock@sedsystems.ca> X-Scanned-By: MIMEDefang 2.64 on 198.169.180.136 Cc: marex@denx.de Subject: [U-Boot] [PATCH 2/2] watchdog: imx: Use immediate reset bits for expire_now X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" The expire_now function was previously setting the watchdog timeout to minimum and waiting for the watchdog to expire. However, this watchdog also has bits to trigger immediate reset. Use those instead, like the Linux imx2_wdt driver does. Signed-off-by: Robert Hancock --- drivers/watchdog/imx_watchdog.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index 05bbfe0..c030360 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -15,15 +15,23 @@ #endif #include -static void imx_watchdog_expire_now(struct watchdog_regs *wdog) +static void imx_watchdog_expire_now(struct watchdog_regs *wdog, bool ext_reset) { - clrsetbits_le16(&wdog->wcr, WCR_WT_MSK, WCR_WDE); + u16 wcr = WCR_WDE; + + if (ext_reset) + wcr |= WCR_SRS; /* do not assert internal reset */ + else + wcr |= WCR_WDA; /* do not assert external reset */ + + /* Write 3 times to ensure it works, due to IMX6Q errata ERR004346 */ + writew(wcr, &wdog->wcr); + writew(wcr, &wdog->wcr); + writew(wcr, &wdog->wcr); - writew(0x5555, &wdog->wsr); - writew(0xaaaa, &wdog->wsr); /* load minimum 1/2 second timeout */ while (1) { /* - * spin for .5 seconds before reset + * spin before reset */ } } @@ -34,7 +42,7 @@ void __attribute__((weak)) reset_cpu(ulong addr) { struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; - imx_watchdog_expire_now(wdog); + imx_watchdog_expire_now(wdog, true); } #endif @@ -106,7 +114,7 @@ static int imx_wdt_expire_now(struct udevice *dev, ulong flags) { struct imx_wdt_priv *priv = dev_get_priv(dev); - imx_watchdog_expire_now(priv->base); + imx_watchdog_expire_now(priv->base, priv->ext_reset); hang(); return 0;