From patchwork Wed Dec 1 21:08:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sander Vanheule X-Patchwork-Id: 1562462 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=WnwuhJov; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=svanheule.net header.i=@svanheule.net header.a=rsa-sha256 header.s=mail1707 header.b=2wOx8M42; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J4Bd84F55z9sCD for ; Thu, 2 Dec 2021 08:12:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4UP03/mffNnt0POhpn3zFYpTF5TuiP/4xz01tgjqhw8=; b=WnwuhJovkdD1aO nTy+2JKa/GQnLCCLqG3wL7lt70LfrFlw94mfvgDpTFi847urWZdB4BMRDZfzEJCp6v4vGWSQAkW2C U6Wy87PCbjl6v36tf8DRxu/3oN/rGJuwKfozzFN1upAB2vTpAyWO+KG+7mtmrJRApkJjbIgViFQRM A75t+BJimeZ7vTg90IzRc5sQbUWUDLeHXd5oyKbMx04xYvqghDUc/pk3Iu1l0DynaGx1ZoT0v6/lp HqiIi3H57/HP0wnDz+IKThXH79QtsIAAP85czCmUUUVrJXso5fUe6f4yNaHY7IHXlXI5+fGsKUNG4 bw/5y+mnlv3Pn/rfjcCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1msWqd-00ABBr-Uj; Wed, 01 Dec 2021 21:09:04 +0000 Received: from polaris.svanheule.net ([84.16.241.116]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1msWqY-00AB9x-Kz for openwrt-devel@lists.openwrt.org; Wed, 01 Dec 2021 21:09:00 +0000 Received: from terra.local.svanheule.net (unknown [IPv6:2a02:a03f:eafe:c901:286b:6734:a19a:eaab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sander@svanheule.net) by polaris.svanheule.net (Postfix) with ESMTPSA id E7F2827A812; Wed, 1 Dec 2021 22:08:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svanheule.net; s=mail1707; t=1638392933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=RnFHKLKq3auQlBmYzir5JkQCAdWEszOIC6PDNjw7gNY=; b=2wOx8M429uc/ka4X5J3QNsYuIXzK7tKJbb/J8R4xO+q1bhgbCxNa0wtdD1yFcgQvlGjz0M uWyHf7KYb0363S7wBW3enrMUGW3sRLFez5ZJpH6tWIIyvE66+doBvNQbpEQDKlVIBThMxa R1mz86KTwtX1fDU+/YCM9y+xzA7BmkUp1yXDgu8qkGmPUOV38AZKNBKKz6QuWw2zuqu53g dqaTk4I/FL5FHb/zg9NeCejgJWWOasAZWGmrno42mAOZA9BoMWsdWsG0RlR3nQuCrJ0K6x grB6PLkJzADKUD0+x/Q09X4zCLgz+5/MhDBDICAoDvBenBT1VkZV6ggqwuLKaw== From: Sander Vanheule To: openwrt-devel@lists.openwrt.org Cc: Sander Vanheule Subject: [PATCH] realtek: update watchdog timer patch Date: Wed, 1 Dec 2021 22:08:23 +0100 Message-Id: <20211201210822.326892-1-sander@svanheule.net> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211201_130859_081153_2C38DF6A X-CRM114-Status: GOOD ( 17.57 ) X-Spam-Score: -2.5 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The Realtek Otto watchdog timer driver was accepted upstream, and is queued for 5.17. Update the patch's file name, and replace by the final version. Signed-off-by: Sander Vanheule --- ...dog-add-realtek-otto-watchdog-timer.patch} | 82 +++++++++++++------ 1 file changed, 57 insertions(+), 25 deletions(-) rename target/linux/r [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [84.16.241.116 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The Realtek Otto watchdog timer driver was accepted upstream, and is queued for 5.17. Update the patch's file name, and replace by the final version. Signed-off-by: Sander Vanheule --- ...dog-add-realtek-otto-watchdog-timer.patch} | 82 +++++++++++++------ 1 file changed, 57 insertions(+), 25 deletions(-) rename target/linux/realtek/patches-5.10/{100-watchdog-add-realtek-otto-watchdog-timer.patch => 008-5.17-watchdog-add-realtek-otto-watchdog-timer.patch} (86%) diff --git a/target/linux/realtek/patches-5.10/100-watchdog-add-realtek-otto-watchdog-timer.patch b/target/linux/realtek/patches-5.10/008-5.17-watchdog-add-realtek-otto-watchdog-timer.patch similarity index 86% rename from target/linux/realtek/patches-5.10/100-watchdog-add-realtek-otto-watchdog-timer.patch rename to target/linux/realtek/patches-5.10/008-5.17-watchdog-add-realtek-otto-watchdog-timer.patch index fae478a6246a..735ea445313f 100644 --- a/target/linux/realtek/patches-5.10/100-watchdog-add-realtek-otto-watchdog-timer.patch +++ b/target/linux/realtek/patches-5.10/008-5.17-watchdog-add-realtek-otto-watchdog-timer.patch @@ -1,10 +1,7 @@ -From 2dbf0c6e0eebf523008c15794434d2d1a9b1260e Mon Sep 17 00:00:00 2001 -Message-Id: <2dbf0c6e0eebf523008c15794434d2d1a9b1260e.1636018117.git.sander@svanheule.net> -In-Reply-To: -References: +From 293903b9dfe43520f01374dc1661be11d6838c49 Mon Sep 17 00:00:00 2001 From: Sander Vanheule -Date: Sun, 3 Oct 2021 09:25:27 +0200 -Subject: [PATCH v3 2/2] watchdog: Add Realtek Otto watchdog timer +Date: Thu, 18 Nov 2021 17:29:52 +0100 +Subject: watchdog: Add Realtek Otto watchdog timer Realtek MIPS SoCs (platform name Otto) have a watchdog timer with pretimeout notifitication support. The WDT can (partially) hard reset, @@ -22,17 +19,22 @@ supported platforms. This means that the phase2 interrupt will only fire at the same time as reset, so implementing phase2 is of little use. Signed-off-by: Sander Vanheule +Reviewed-by: Guenter Roeck +Link: https://lore.kernel.org/r/6d060bccbdcc709cfa79203485db85aad3c3beb5.1637252610.git.sander@svanheule.net +Signed-off-by: Guenter Roeck --- MAINTAINERS | 7 + - drivers/watchdog/Kconfig | 13 + + drivers/watchdog/Kconfig | 13 ++ drivers/watchdog/Makefile | 1 + - drivers/watchdog/realtek_otto_wdt.c | 361 ++++++++++++++++++++++++++++ - 4 files changed, 382 insertions(+) + drivers/watchdog/realtek_otto_wdt.c | 384 ++++++++++++++++++++++++++++++++++++ + 4 files changed, 405 insertions(+) create mode 100644 drivers/watchdog/realtek_otto_wdt.c +diff --git a/MAINTAINERS b/MAINTAINERS +index 7a2345ce85213..2e255902dd906 100644 --- a/MAINTAINERS +++ b/MAINTAINERS -@@ -14815,6 +14815,13 @@ S: Maintained +@@ -16122,6 +16122,13 @@ S: Maintained F: include/sound/rt*.h F: sound/soc/codecs/rt* @@ -46,9 +48,11 @@ Signed-off-by: Sander Vanheule REALTEK RTL83xx SMI DSA ROUTER CHIPS M: Linus Walleij S: Maintained +diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig +index 73084e008c2be..bac8901072e23 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig -@@ -995,6 +995,19 @@ config RTD119X_WATCHDOG +@@ -941,6 +941,19 @@ config RTD119X_WATCHDOG Say Y here to include support for the watchdog timer in Realtek RTD1295 SoCs. @@ -68,9 +72,11 @@ Signed-off-by: Sander Vanheule config SPRD_WATCHDOG tristate "Spreadtrum watchdog support" depends on ARCH_SPRD || COMPILE_TEST +diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile +index b01007c0396ce..92d8d8530ac6b 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile -@@ -174,6 +174,7 @@ obj-$(CONFIG_IMGPDC_WDT) += imgpdc_wdt.o +@@ -169,6 +169,7 @@ obj-$(CONFIG_IMGPDC_WDT) += imgpdc_wdt.o obj-$(CONFIG_MT7621_WDT) += mt7621_wdt.o obj-$(CONFIG_PIC32_WDT) += pic32-wdt.o obj-$(CONFIG_PIC32_DMT) += pic32-dmt.o @@ -78,9 +84,12 @@ Signed-off-by: Sander Vanheule # PARISC Architecture +diff --git a/drivers/watchdog/realtek_otto_wdt.c b/drivers/watchdog/realtek_otto_wdt.c +new file mode 100644 +index 0000000000000..60058a0c3ec4d --- /dev/null +++ b/drivers/watchdog/realtek_otto_wdt.c -@@ -0,0 +1,361 @@ +@@ -0,0 +1,384 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/* @@ -150,7 +159,7 @@ Signed-off-by: Sander Vanheule + struct watchdog_device wdev; + struct device *dev; + void __iomem *base; -+ struct clk *clk; ++ unsigned int clk_rate_khz; + int irq_phase1; +}; + @@ -189,12 +198,7 @@ Signed-off-by: Sander Vanheule + +static int otto_wdt_tick_ms(struct otto_wdt_ctrl *ctrl, int prescale) +{ -+ unsigned int rate_khz = clk_get_rate(ctrl->clk) / 1000; -+ -+ if (!rate_khz) -+ return 0; -+ -+ return DIV_ROUND_CLOSEST(1 << (25 + prescale), rate_khz); ++ return DIV_ROUND_CLOSEST(1 << (25 + prescale), ctrl->clk_rate_khz); +} + +/* @@ -323,6 +327,34 @@ Signed-off-by: Sander Vanheule + WDIOF_PRETIMEOUT, +}; + ++static void otto_wdt_clock_action(void *data) ++{ ++ clk_disable_unprepare(data); ++} ++ ++static int otto_wdt_probe_clk(struct otto_wdt_ctrl *ctrl) ++{ ++ struct clk *clk = devm_clk_get(ctrl->dev, NULL); ++ int ret; ++ ++ if (IS_ERR(clk)) ++ return dev_err_probe(ctrl->dev, PTR_ERR(clk), "Failed to get clock\n"); ++ ++ ret = clk_prepare_enable(clk); ++ if (ret) ++ return dev_err_probe(ctrl->dev, ret, "Failed to enable clock\n"); ++ ++ ret = devm_add_action_or_reset(ctrl->dev, otto_wdt_clock_action, clk); ++ if (ret) ++ return ret; ++ ++ ctrl->clk_rate_khz = clk_get_rate(clk) / 1000; ++ if (ctrl->clk_rate_khz == 0) ++ return dev_err_probe(ctrl->dev, -ENXIO, "Failed to get clock rate\n"); ++ ++ return 0; ++} ++ +static int otto_wdt_probe_reset_mode(struct otto_wdt_ctrl *ctrl) +{ + static const char *mode_property = "realtek,reset-mode"; @@ -380,13 +412,13 @@ Signed-off-by: Sander Vanheule + ctrl->base + OTTO_WDT_REG_INTR); + iowrite32(OTTO_WDT_CTRL_DEFAULT, ctrl->base + OTTO_WDT_REG_CTRL); + -+ ctrl->clk = devm_clk_get(dev, NULL); -+ if (IS_ERR(ctrl->clk)) -+ return dev_err_probe(dev, PTR_ERR(ctrl->clk), "Failed to get clock\n"); ++ ret = otto_wdt_probe_clk(ctrl); ++ if (ret) ++ return ret; + + ctrl->irq_phase1 = platform_get_irq_byname(pdev, "phase1"); + if (ctrl->irq_phase1 < 0) -+ return dev_err_probe(dev, ctrl->irq_phase1, "phase1 IRQ not found\n"); ++ return ctrl->irq_phase1; + + ret = devm_request_irq(dev, ctrl->irq_phase1, otto_wdt_phase1_isr, 0, + "realtek-otto-wdt", ctrl); @@ -403,7 +435,7 @@ Signed-off-by: Sander Vanheule + + /* + * Since pretimeout cannot be disabled, min. timeout is twice the -+ * subsystem resolution. max. timeout is ca. 43s at a bus clock of 200MHz. ++ * subsystem resolution. Max. timeout is ca. 43s at a bus clock of 200MHz. + */ + ctrl->wdev.min_timeout = 2; + max_tick_ms = otto_wdt_tick_ms(ctrl, OTTO_WDT_PRESCALE_MAX);