From patchwork Sun Feb 17 09:25:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 1043622 X-Patchwork-Delegate: sr@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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GhrFWEyA"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 442M8K5TWtz9sDX for ; Sun, 17 Feb 2019 20:26:57 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6D97BC21E4E; Sun, 17 Feb 2019 09:26:26 +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=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID 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 4DC31C21EA1; Sun, 17 Feb 2019 09:26:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7D8E6C21E68; Sun, 17 Feb 2019 09:26:15 +0000 (UTC) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by lists.denx.de (Postfix) with ESMTPS id A1B0BC21E1D for ; Sun, 17 Feb 2019 09:26:11 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id j5so2549245pfa.2 for ; Sun, 17 Feb 2019 01:26:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3I7YhsXPdS4+KiL54wmmr4t0UDjiSSf9fNvfLpse11I=; b=GhrFWEyAVPdT8Wms4Pnay4cvGwQspafgCQg6BS0ZBFIiRYYgZs6IQ2ziSrnCmBudtV FDOfpdDZYkrHEc+AGNXXiEx6pDLkDsLuxTYSUxGVlQdF3ffHtHpNid+1iKr1j/lEsySb 0rmCxqkPZCPkQZPK6EpF+YGvpvQhLtrjwmK7dpCc2NHbj2t+08hjleEm9iflIKJ24YQ9 g24jMTzezYUkxlzHgpfaaUdhqkMKWp+mdagHndUUh79ZwXsefVSLZs8j+/UtURx26Ozt tI2GvF66bdx+4zcAxd36eu0U6V6OD/Vp7s4uSum8GXYJ+bXHujwJlYpn7TJA9PY+CI1m /I0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3I7YhsXPdS4+KiL54wmmr4t0UDjiSSf9fNvfLpse11I=; b=irYICYa+07DB72vXw57rup7fYoRFsG1vXr1xXOyvAW4kKhyEpe7B4jMmvBU2xQ3JQ/ MJmMIx6YW+sUgJ1YXg248G5+PkDIxeN/nRK8z2Ju1YR/Sg6Z68HqeC8jwLLoGFU0Iq/B QYcELtZRucY6F/x9iC0a/xbD6nwdmi2gVNtJRhWfMU9g8hmpNhBA2Lk8z5nz4a1x9Jxx F6UBHqA8/i0JIt9+IvaNK7LLabJpxxCFA35TFnbCXRPBwGvqZ7CHmrMLAd27AqrGJRDb 0yhJA3CxieF/pJlJOfpIUllTcZzOR3xzK4+eGpWVMa9qD6bbXMhpwSPpyLASPMo0tOps x5QQ== X-Gm-Message-State: AHQUAuYriPqjgSZzt6oB8Ok3YP8dpVG+2DFdB2c7DhQkCX6CFttb7Bz7 XhFtu6Sz7yLwzZbtZrp+3Fv6sQhN5h8= X-Google-Smtp-Source: AHgI3IZsKQW1+oD3Zno7jFBb8Bkumm7MaNAULDTzn7/ajK+2oI7QYZaI2cicXVPbAsDLQO+S6mcdRQ== X-Received: by 2002:a62:5c1:: with SMTP id 184mr18275766pff.165.1550395569938; Sun, 17 Feb 2019 01:26:09 -0800 (PST) Received: from chrisp-dl.ws.atlnz.lc ([2001:df5:b000:22:3a2c:4aff:fe70:2b02]) by smtp.gmail.com with ESMTPSA id s190sm17003532pfb.103.2019.02.17.01.26.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Feb 2019 01:26:09 -0800 (PST) From: Chris Packham To: u-boot@lists.denx.de, Albert Aribaud , Tom Rini , Stefan Roese Date: Sun, 17 Feb 2019 22:25:53 +1300 Message-Id: <20190217092555.20212-2-judge.packham@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190217092555.20212-1-judge.packham@gmail.com> References: <20190217092555.20212-1-judge.packham@gmail.com> MIME-Version: 1.0 Cc: Chris Packham Subject: [U-Boot] [PATCH v3 1/3] watchdog: orion_wdt: support SPL usage 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When run from the SPL the mvebu targets are using the hardware default offset for the SoC peripherals. devfdt_get_addr_size_index() understands how to deal with this via dm_get_translation_offset() so use this instead of fdtdec_get_addr_size_auto_noparent(). Signed-off-by: Chris Packham Reviewed-by: Stefan Roese --- Changes in v3: None Changes in v2: None drivers/watchdog/orion_wdt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index a0df02d10382..c1add3e7c121 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c @@ -114,9 +114,7 @@ static inline bool save_reg_from_ofdata(struct udevice *dev, int index, fdt_addr_t addr; fdt_size_t off; - addr = fdtdec_get_addr_size_auto_noparent( - gd->fdt_blob, dev_of_offset(dev), "reg", index, &off, true); - + addr = devfdt_get_addr_size_index(dev, index, &off); if (addr == FDT_ADDR_T_NONE) return false; From patchwork Sun Feb 17 09:25:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 1043623 X-Patchwork-Delegate: sr@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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="q59IPjxE"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 442M920N5Hz9sDX for ; Sun, 17 Feb 2019 20:27:33 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 8BDF0C21E2B; Sun, 17 Feb 2019 09:26:39 +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=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID 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 C0DF4C21E74; Sun, 17 Feb 2019 09:26:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6A3D3C21E68; Sun, 17 Feb 2019 09:26:21 +0000 (UTC) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by lists.denx.de (Postfix) with ESMTPS id 6D80CC21C29 for ; Sun, 17 Feb 2019 09:26:17 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id bj4so7238891plb.7 for ; Sun, 17 Feb 2019 01:26:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NwRqkIQHrjNTs4kC0OkEMC3FpLl54SgJxPXLkM2f4z8=; b=q59IPjxEXu6WlEPjLpM0DEB4yTTxxXFX5nQ1AUNUgt20PPoCU03WUsy4Gn6lUiMd5L 0p3DrIHH67QJXsRukd7HO4losf3TTXZfiGTjAxPM9tXN7c75gLaWMa0TcjhctphB4ssn FK+8uaz2Ac+J2ulSk2AacqWtF5fKcByllA4wFAaDvoAX5OC8dCxQW8vZLdE+6t+k40gG bsOG0EUiS6COdsbU0a/YDcNstqGNu3CGlGQPTphpC13t4mooez+jWm9dIfjdahObPTtt aCYUAX0h8e+eqGzofrEq/aYNuV/uSBqWYKNFc/5XG5oCIGAhXiTBOE/huTI0XKUdZTnb Lq1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NwRqkIQHrjNTs4kC0OkEMC3FpLl54SgJxPXLkM2f4z8=; b=DXIw+U+EmVlyaYCCsaSqsMzcP/sxL9d2/leeQOtafmGeYIg4s4jjgByH3c1kMNWKSF kkvtCC7m3DpR/cwb7RUV4yMnGZdf99D0bnLxKZGeJz76c17hah9mf4F0RyFhlEvY2Etz cbCchYsSeF7BX9N+Tm6fdYCarWCvIzpjpeqxGstyXedLIYYt/AjoAEQKSRc5K7jn2KFJ WRwSSmNne5q8A+mgsLtRyraxyvAa7Ys+LgM/NAL0vhcpoR5P+WVfDDHbnvkFyP1MOI9k e7+4zHtTqkDzkn37GRFc2UDuw1PEv9aHcEc1ERrv2p7bZ6Zw7GtmlUBGmy3JzdVFj1dz og2A== X-Gm-Message-State: AHQUAuZGcL+u8v97yfxQTau1t33D963U8Lzd+3c4GWlhMAc5c1SXuYV7 V0AeYvFsuT6XSjesCQZuoF2vvi/Gxxo= X-Google-Smtp-Source: AHgI3IZCAfiobm96Oc/le1gXT2Ukscwoj6P92XwHxPC/LReUasShMiCJkP/xxtqHMBwo1JKV2M3aKw== X-Received: by 2002:a17:902:1009:: with SMTP id b9mr18025204pla.42.1550395575611; Sun, 17 Feb 2019 01:26:15 -0800 (PST) Received: from chrisp-dl.ws.atlnz.lc ([2001:df5:b000:22:3a2c:4aff:fe70:2b02]) by smtp.gmail.com with ESMTPSA id s190sm17003532pfb.103.2019.02.17.01.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Feb 2019 01:26:15 -0800 (PST) From: Chris Packham To: u-boot@lists.denx.de, Albert Aribaud , Tom Rini , Stefan Roese Date: Sun, 17 Feb 2019 22:25:54 +1300 Message-Id: <20190217092555.20212-3-judge.packham@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190217092555.20212-1-judge.packham@gmail.com> References: <20190217092555.20212-1-judge.packham@gmail.com> MIME-Version: 1.0 Cc: Ryder Lee , Michal Simek , Shreenidhi Shedi , Chris Packham , Xiaoliang Yang Subject: [U-Boot] [PATCH v3 2/3] watchdog: orion_wdt: take timeout value in ms 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The generic wdt_start API expects to be called with the timeout in milliseconds. Update the orion_wdt driver to accept a timeout in milliseconds and use the clock rate specified in the dts to convert the timeout to an appropriate value for the timer reload register. Signed-off-by: Chris Packham --- It turned out to be easy enough to make orion_wdt conform to the expected wdt APIs. It looks like the turris_mox already assumed a timeout in ms, so only the turris_omnia needed updating. Changes in v3: - new Changes in v2: None board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- drivers/watchdog/Kconfig | 1 + drivers/watchdog/orion_wdt.c | 22 ++++++++++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c index 1f7650cb3610..5e0b686c597d 100644 --- a/board/CZ.NIC/turris_omnia/turris_omnia.c +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c @@ -379,7 +379,7 @@ int board_init(void) puts("Cannot find Armada 385 watchdog!\n"); } else { puts("Enabling Armada 385 watchdog.\n"); - wdt_start(watchdog_dev, (u32) 25000000 * 120, 0); + wdt_start(watchdog_dev, 120000, 0); } # endif diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 115fc4551ffd..7f7bc4bbc494 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -97,6 +97,7 @@ config WDT_BCM6345 config WDT_ORION bool "Orion watchdog timer support" depends on WDT + select CLK help Select this to enable Orion watchdog timer, which can be found on some Marvell Armada chips. diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index c1add3e7c121..03632938f239 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,8 @@ struct orion_wdt_priv { void __iomem *rstout; void __iomem *rstout_mask; u32 timeout; + unsigned long clk_rate; + struct clk clk; }; #define RSTOUT_ENABLE_BIT BIT(8) @@ -44,17 +47,18 @@ static int orion_wdt_reset(struct udevice *dev) struct orion_wdt_priv *priv = dev_get_priv(dev); /* Reload watchdog duration */ - writel(priv->timeout, priv->reg + priv->wdt_counter_offset); + writel(priv->clk_rate * priv->timeout, + priv->reg + priv->wdt_counter_offset); return 0; } -static int orion_wdt_start(struct udevice *dev, u64 timeout, ulong flags) +static int orion_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) { struct orion_wdt_priv *priv = dev_get_priv(dev); u32 reg; - priv->timeout = (u32) timeout; + priv->timeout = timeout_ms / 1000; /* Enable the fixed watchdog clock input */ reg = readl(priv->reg + TIMER_CTRL); @@ -62,7 +66,8 @@ static int orion_wdt_start(struct udevice *dev, u64 timeout, ulong flags) writel(reg, priv->reg + TIMER_CTRL); /* Set watchdog duration */ - writel(priv->timeout, priv->reg + priv->wdt_counter_offset); + writel(priv->clk_rate * priv->timeout, + priv->reg + priv->wdt_counter_offset); /* Clear the watchdog expiration bit */ reg = readl(priv->reg + TIMER_A370_STATUS); @@ -147,9 +152,18 @@ err: static int orion_wdt_probe(struct udevice *dev) { + struct orion_wdt_priv *priv = dev_get_priv(dev); + int ret; + debug("%s: Probing wdt%u\n", __func__, dev->seq); orion_wdt_stop(dev); + ret = clk_get_by_name(dev, "fixed", &priv->clk); + if (!ret) + priv->clk_rate = clk_get_rate(&priv->clk); + else + priv->clk_rate = 25000000; + return 0; } From patchwork Sun Feb 17 09:25:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 1043624 X-Patchwork-Delegate: sr@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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TwmVrSWf"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 442M935Q0Nz9sDX for ; Sun, 17 Feb 2019 20:27:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 71AD8C21EAE; Sun, 17 Feb 2019 09:26:54 +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=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID 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 474E9C21E90; Sun, 17 Feb 2019 09:26:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6C222C21E1D; Sun, 17 Feb 2019 09:26:24 +0000 (UTC) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by lists.denx.de (Postfix) with ESMTPS id B833DC21ECC for ; Sun, 17 Feb 2019 09:26:20 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id 101so7238801pld.6 for ; Sun, 17 Feb 2019 01:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZGQNTAT+bqqR95nxPqRJh3j50xe8NmW3Zi07eI+ZoLo=; b=TwmVrSWfIGEco3TyWgZycayFKxtmMGecN3rki+35An/hiSx7y3Uuoxe7u0X1n45yps iqMjZ32KUmAkKHPRjIugbqUjlWenHZ2OQ2gie1bORBxr63XwCVKu3tPUUOpZXEtUyX3B yCoA0dynJcl8TnEdSpaTyIpxHhL8IT7ZkOcNCc+k9K8/8Vua53UUNkOsQAl7tAFsQLUV v8EwrkTorbf/2s7QlIeHEEXgj+qopTRBwZOkrqaHHqUby6X3C+24aRuL3ErnQvIjPiJG eq7fzY1UhRhGA5bdBNqUjWjNjkbLkcKWbefzFGH9jB45CsvPGvk3OJPtr7cK1UBnM4sJ GmXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZGQNTAT+bqqR95nxPqRJh3j50xe8NmW3Zi07eI+ZoLo=; b=NPxiDN70TT0g/S52dBcU1+SbXnD5+hIO7lrQC9zEkN2JNMtwYKHODpjipaSCUoGwoW mvS50Z4C7IegCRmCuVwcbT8PXpUyKytwb0oFTq0GJ/YV31gc2ulx8ScaO3lwTC8oATME YVU/wxGNUEowRLNWU269/cSfhqqYPDiIPiTN/PSlSBRxuMO3J/eN7VqZ0SfQKIQDUooN LZGJqvLDneCMeRDYv3qHpX6enlMXkxxxgTxkOWPQIOxG5ULaxhhvIpi44SsJkfFQDiJE cej4VBmuePlfLe+///V/I/tfUlEn5lvBO0CUHq2tuhG0XNAxtk1o6Deh1fmQnCCeziMM VZ0Q== X-Gm-Message-State: AHQUAuYfdrqSRjL89r2HICC2DkrmqT1EkLncts8Wzs0Ox8SqVQulVDVL 41t3LbL8erIT7TUiZzulvw8MJcZAWnA= X-Google-Smtp-Source: AHgI3IayQ28rl5PvY5gZDMxU2fYmOfyfVXk1Yq0KLIVOvBgdemJ6o6pY2UvPsSbCW4uMzxvi/kYfgg== X-Received: by 2002:a17:902:2aa8:: with SMTP id j37mr18562768plb.226.1550395579039; Sun, 17 Feb 2019 01:26:19 -0800 (PST) Received: from chrisp-dl.ws.atlnz.lc ([2001:df5:b000:22:3a2c:4aff:fe70:2b02]) by smtp.gmail.com with ESMTPSA id s190sm17003532pfb.103.2019.02.17.01.26.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Feb 2019 01:26:18 -0800 (PST) From: Chris Packham To: u-boot@lists.denx.de, Albert Aribaud , Tom Rini , Stefan Roese Date: Sun, 17 Feb 2019 22:25:55 +1300 Message-Id: <20190217092555.20212-4-judge.packham@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190217092555.20212-1-judge.packham@gmail.com> References: <20190217092555.20212-1-judge.packham@gmail.com> MIME-Version: 1.0 Cc: Chris Packham , Chris Packham Subject: [U-Boot] [PATCH v3 3/3] arm: mvebu: x530: Enable watchdog in SPL and U-Boot 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Enable the hardware watchdog to guard against system lock ups when running in the SPL or U-Boot. Stop the watchdog just before booting so that the OS can re-enable it if needed. Signed-off-by: Chris Packham --- Changes in v3: - specify timeout in milliseconds Changes in v2: - update commit message arch/arm/dts/armada-385-atl-x530-u-boot.dtsi | 4 ++ board/alliedtelesis/x530/x530.c | 48 ++++++++++++++++++++ configs/x530_defconfig | 5 ++ 3 files changed, 57 insertions(+) diff --git a/arch/arm/dts/armada-385-atl-x530-u-boot.dtsi b/arch/arm/dts/armada-385-atl-x530-u-boot.dtsi index 7074a73537fa..79b694cb84bc 100644 --- a/arch/arm/dts/armada-385-atl-x530-u-boot.dtsi +++ b/arch/arm/dts/armada-385-atl-x530-u-boot.dtsi @@ -11,3 +11,7 @@ &uart0 { u-boot,dm-pre-reloc; }; + +&watchdog { + u-boot,dm-pre-reloc; +}; diff --git a/board/alliedtelesis/x530/x530.c b/board/alliedtelesis/x530/x530.c index d7d1942fe686..6934fd801730 100644 --- a/board/alliedtelesis/x530/x530.c +++ b/board/alliedtelesis/x530/x530.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,10 @@ DECLARE_GLOBAL_DATA_PTR; #define CONFIG_NVS_LOCATION 0xf4800000 #define CONFIG_NVS_SIZE (512 << 10) +#ifdef CONFIG_WATCHDOG +static struct udevice *watchdog_dev; +#endif + static struct serdes_map board_serdes_map[] = { {PEX0, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0}, {DEFAULT_SERDES, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0}, @@ -75,6 +80,10 @@ struct mv_ddr_topology_map *mv_ddr_topology_map_get(void) int board_early_init_f(void) { +#ifdef CONFIG_WATCHDOG + watchdog_dev = NULL; +#endif + /* Configure MPP */ writel(0x00001111, MVEBU_MPP_BASE + 0x00); writel(0x00000000, MVEBU_MPP_BASE + 0x04); @@ -88,6 +97,17 @@ int board_early_init_f(void) return 0; } +void spl_board_init(void) +{ +#ifdef CONFIG_WATCHDOG + int ret; + + ret = uclass_get_device(UCLASS_WDT, 0, &watchdog_dev); + if (!ret) + wdt_start(watchdog_dev, 120000, 0); +#endif +} + int board_init(void) { /* address of boot parameters */ @@ -100,9 +120,37 @@ int board_init(void) /* DEV_READYn is not needed for NVS, ignore it when accessing CS1 */ writel(0x00004001, MVEBU_DEV_BUS_BASE + 0xc8); + spl_board_init(); + return 0; } +void arch_preboot_os(void) +{ +#ifdef CONFIG_WATCHDOG + wdt_stop(watchdog_dev); +#endif +} + +#ifdef CONFIG_WATCHDOG +void watchdog_reset(void) +{ + static ulong next_reset = 0; + ulong now; + + if (!watchdog_dev) + return; + + now = timer_get_us(); + + /* Do not reset the watchdog too often */ + if (now > next_reset) { + wdt_reset(watchdog_dev); + next_reset = now + 1000; + } +} +#endif + static int led_7seg_init(unsigned int segments) { int node; diff --git a/configs/x530_defconfig b/configs/x530_defconfig index 25b9e885d8e6..3bc37b9bee11 100644 --- a/configs/x530_defconfig +++ b/configs/x530_defconfig @@ -19,6 +19,8 @@ CONFIG_SILENT_CONSOLE=y CONFIG_SILENT_U_BOOT_ONLY=y CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC=y CONFIG_MISC_INIT_R=y +CONFIG_SPL_BOARD_INIT=y +CONFIG_SPL_WATCHDOG_SUPPORT=y CONFIG_CMD_MEMINFO=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_GPIO=y @@ -70,3 +72,6 @@ CONFIG_USB_STORAGE=y CONFIG_USB_HOST_ETHER=y CONFIG_USB_ETHER_ASIX=y CONFIG_USB_ETHER_ASIX88179=y +CONFIG_WATCHDOG=y +CONFIG_WDT=y +CONFIG_WDT_ORION=y