From patchwork Mon Feb 13 20:05:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 653657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D50B5C636D4 for ; Mon, 13 Feb 2023 20:05:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229520AbjBMUFb (ORCPT ); Mon, 13 Feb 2023 15:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230136AbjBMUF2 (ORCPT ); Mon, 13 Feb 2023 15:05:28 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 637B41E2A9; Mon, 13 Feb 2023 12:05:24 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id m20-20020a05600c3b1400b003e1e754657aso3662873wms.2; Mon, 13 Feb 2023 12:05:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vxuQc2Qm9/O1c75x/Q80GT9G9dfuHOQIUSLpagOrN44=; b=YHQskvgFSms4BAqjbWCYgFCp2OTTTQrsKR9fg3OxbrL+Sj+oJzbPjbsh0gQ55mcfM/ 5aUcDmImMEbA9a+embT3FoBTYzaZAbKeNy6PYTPLOGv2zjIfnvB7Q0+KnIw65LDmlsuC Wq+dAAHA7aC4m7q4i9bsgKwpIGxmbqA6UJg3VQMEwroR8/29Qlrb2B49YCgu0l/YXuBU gy60+tqyFI95x58iKfOZMA5RWzIMNRgfg9n+KMY0aVxk62GvlXLrnniWTEfdiMr9UGEv LJwR/KIhHlRcIokFJb1YbHu1TmJTXEq1OZiU6Vh5x16JNSz7ZkFLyb99a+Y9GWOhdXNJ +i+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vxuQc2Qm9/O1c75x/Q80GT9G9dfuHOQIUSLpagOrN44=; b=HM2FkxKWOqEdEZGZ6NlUG4+3wkePqU14/w0u0VMyDvsW1TY7m8CsfmeV/Apt/1++cx MElaj2LiOHHJUigzEz6BdlBSvhdV2FlbX+HgYjhjkWrRCN1fHqNDyHXTi9yG3HY6FYWg ajRvd8UXYIsHXq4igbVNiAn+B+wjjBgeRgVyjWaXRtq+FcYGemGZjDRp4a8Q/ruVMnlb oDcJcizEEuU+nqfaeCNN9hJqUiBYL7eroubgBk7B5G/2WHGcpa5FPzmelMTunxxpLbtl PEipsApvh6Ydrn5O62M7NVpHUnQ60NOJjGqR+kEq3TqgLuud/WGIb2LKI60B7T+LIA7y 3xoQ== X-Gm-Message-State: AO0yUKXX6ugmIkUsy0qR1jkPdsPyV9evxQ0KD93Vn+n0dwFK+78yitod gDgr1BvOAD8dTDCi/JJWnwk//Xx34+4= X-Google-Smtp-Source: AK7set9y7U1h45JPvD68yUorkyDDZhH/Ef+cOVb21q6hsZcC5MCpE2ajeYzzgowxOewPagtjTqEscw== X-Received: by 2002:a05:600c:308a:b0:3dc:43a0:83bb with SMTP id g10-20020a05600c308a00b003dc43a083bbmr20186570wmn.3.1676318722560; Mon, 13 Feb 2023 12:05:22 -0800 (PST) Received: from localhost.localdomain (23.red-88-10-60.dynamicip.rima-tde.net. [88.10.60.23]) by smtp.gmail.com with ESMTPSA id c129-20020a1c3587000000b003dc1a525f22sm15591242wma.25.2023.02.13.12.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 12:05:22 -0800 (PST) From: Sergio Paracuellos To: linux-watchdog@vger.kernel.org Cc: wim@linux-watchdog.org, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, arinc.unal@arinc9.com, tsbogend@alpha.franken.de, p.zabel@pengutronix.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v6 1/3] mips: dts: ralink: mt7621: rename watchdog node from 'wdt' into 'watchdog' Date: Mon, 13 Feb 2023 21:05:17 +0100 Message-Id: <20230213200519.889503-2-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230213200519.889503-1-sergio.paracuellos@gmail.com> References: <20230213200519.889503-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Watchdog nodes must use 'watchdog' for node name. When a 'make dtbs_check' is performed the following warning appears: wdt@100: $nodename:0: 'wdt@100' does not match '^watchdog(@.*|-[0-9a-f])?$' Fix this warning up properly renaming the node into 'watchdog'. Reviewed-by: Arınç ÜNAL Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Sergio Paracuellos --- arch/mips/boot/dts/ralink/mt7621.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/boot/dts/ralink/mt7621.dtsi b/arch/mips/boot/dts/ralink/mt7621.dtsi index 5ca40fd21..ac818fd72 100644 --- a/arch/mips/boot/dts/ralink/mt7621.dtsi +++ b/arch/mips/boot/dts/ralink/mt7621.dtsi @@ -70,7 +70,7 @@ sysc: syscon@0 { "250m", "270m"; }; - wdt: wdt@100 { + wdt: watchdog@100 { compatible = "mediatek,mt7621-wdt"; reg = <0x100 0x100>; }; From patchwork Mon Feb 13 20:05:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 653447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 494D3C678DB for ; Mon, 13 Feb 2023 20:05:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbjBMUFc (ORCPT ); Mon, 13 Feb 2023 15:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbjBMUF3 (ORCPT ); Mon, 13 Feb 2023 15:05:29 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3DFF1E2B0; Mon, 13 Feb 2023 12:05:25 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id r2so13455701wrv.7; Mon, 13 Feb 2023 12:05:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eTGPGFaQb/DlfYZrXhPbzKJDWxh4+D5n3UiQCEuPX0I=; b=ez7EynmaFLZ9mWHcUnVekEqRj1HYCfFo+U0FC+0pSmPUf4/sbRsEUG694SXGRe4jSw Ccfm8VWUlfxIBQG2R1tYV/N5PMNlpWoXCw9dNJgQrkxKx0m5VOBCefLY/bzfTFUpzNHG GdL9O4zT7N8nrXNPh9Rj07QiQc1Fh4W0+qu111TS8a+NICy4X/TE4XVqA85hseRUF/4s Zf72v6ImMCuq9+9T1arT5HtMvCRAwABQdV3rnFg67G5W/275qldiyrwFv2cegB2BHMD0 kq6NyOJEiS3ELpSqrfaxB1LQ+SrETTRZj4NjBt3/+1AwrQrIsYqGQhmNIyFO6rac3a7S mB+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eTGPGFaQb/DlfYZrXhPbzKJDWxh4+D5n3UiQCEuPX0I=; b=b5EKkva8NvWy5rw2oy70RqvmCZfAsPqeKvNcYa+b4f0srKRaraqRElMXOEruhj32uS 4t/0cdJHwALu9yWQcq4mSWOnHwdBIkVhS0qwnAyahcgrcsH75qvajO1FjfGBWefWxwlg spAVPackPJv0ioKYehA8atwZyJOysEmBu8jwsrdweswE+D/WkBw+xguwBEWfxrSE4+Sz 0zpnflXa8WbxjIKHXmxVg13rMKnjT8dQttMeWVu+6jnuuToGRI0WJ+r/wz7XRbM7TL42 E4sYy3cpm4q9MvnEs6bk+sggNZzGzvr2koLki9TIHDgxiiiTp5eUEHNQRLPvsTbFkPSZ HcoQ== X-Gm-Message-State: AO0yUKXh+I752PCVDMQjNk5Mebytslq7pTXlw7H6r7fnTLt+Vp9wIX40 xNZafgyn2Atuc/iwdJ+dduvfFKxNbn0= X-Google-Smtp-Source: AK7set8e9Vu5lWf3u0ZRRGbRhp9okecHZ/8ihwvSVJupThvgR1U1my48mnnyIhIdXejN+1lLKO45xg== X-Received: by 2002:adf:ed03:0:b0:2bf:c0d3:430c with SMTP id a3-20020adfed03000000b002bfc0d3430cmr22843241wro.11.1676318723700; Mon, 13 Feb 2023 12:05:23 -0800 (PST) Received: from localhost.localdomain (23.red-88-10-60.dynamicip.rima-tde.net. [88.10.60.23]) by smtp.gmail.com with ESMTPSA id c129-20020a1c3587000000b003dc1a525f22sm15591242wma.25.2023.02.13.12.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 12:05:23 -0800 (PST) From: Sergio Paracuellos To: linux-watchdog@vger.kernel.org Cc: wim@linux-watchdog.org, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, arinc.unal@arinc9.com, tsbogend@alpha.franken.de, p.zabel@pengutronix.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH v6 2/3] watchdog: mt7621-wdt: avoid static global declarations Date: Mon, 13 Feb 2023 21:05:18 +0100 Message-Id: <20230213200519.889503-3-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230213200519.889503-1-sergio.paracuellos@gmail.com> References: <20230213200519.889503-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Instead of using static global definitions in driver code, refactor code introducing a new watchdog driver data structure and use it along the code. Reviewed-by: Guenter Roeck Signed-off-by: Sergio Paracuellos --- drivers/watchdog/mt7621_wdt.c | 102 ++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 37 deletions(-) diff --git a/drivers/watchdog/mt7621_wdt.c b/drivers/watchdog/mt7621_wdt.c index a8aa3522c..40fb2c9ba 100644 --- a/drivers/watchdog/mt7621_wdt.c +++ b/drivers/watchdog/mt7621_wdt.c @@ -31,8 +31,11 @@ #define TMR1CTL_RESTART BIT(9) #define TMR1CTL_PRESCALE_SHIFT 16 -static void __iomem *mt7621_wdt_base; -static struct reset_control *mt7621_wdt_reset; +struct mt7621_wdt_data { + void __iomem *base; + struct reset_control *rst; + struct watchdog_device wdt; +}; static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, 0); @@ -40,27 +43,31 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); -static inline void rt_wdt_w32(unsigned reg, u32 val) +static inline void rt_wdt_w32(void __iomem *base, unsigned reg, u32 val) { - iowrite32(val, mt7621_wdt_base + reg); + iowrite32(val, base + reg); } -static inline u32 rt_wdt_r32(unsigned reg) +static inline u32 rt_wdt_r32(void __iomem *base, unsigned reg) { - return ioread32(mt7621_wdt_base + reg); + return ioread32(base + reg); } static int mt7621_wdt_ping(struct watchdog_device *w) { - rt_wdt_w32(TIMER_REG_TMRSTAT, TMR1CTL_RESTART); + struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); + + rt_wdt_w32(drvdata->base, TIMER_REG_TMRSTAT, TMR1CTL_RESTART); return 0; } static int mt7621_wdt_set_timeout(struct watchdog_device *w, unsigned int t) { + struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); + w->timeout = t; - rt_wdt_w32(TIMER_REG_TMR1LOAD, t * 1000); + rt_wdt_w32(drvdata->base, TIMER_REG_TMR1LOAD, t * 1000); mt7621_wdt_ping(w); return 0; @@ -68,29 +75,31 @@ static int mt7621_wdt_set_timeout(struct watchdog_device *w, unsigned int t) static int mt7621_wdt_start(struct watchdog_device *w) { + struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); u32 t; /* set the prescaler to 1ms == 1000us */ - rt_wdt_w32(TIMER_REG_TMR1CTL, 1000 << TMR1CTL_PRESCALE_SHIFT); + rt_wdt_w32(drvdata->base, TIMER_REG_TMR1CTL, 1000 << TMR1CTL_PRESCALE_SHIFT); mt7621_wdt_set_timeout(w, w->timeout); - t = rt_wdt_r32(TIMER_REG_TMR1CTL); + t = rt_wdt_r32(drvdata->base, TIMER_REG_TMR1CTL); t |= TMR1CTL_ENABLE; - rt_wdt_w32(TIMER_REG_TMR1CTL, t); + rt_wdt_w32(drvdata->base, TIMER_REG_TMR1CTL, t); return 0; } static int mt7621_wdt_stop(struct watchdog_device *w) { + struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); u32 t; mt7621_wdt_ping(w); - t = rt_wdt_r32(TIMER_REG_TMR1CTL); + t = rt_wdt_r32(drvdata->base, TIMER_REG_TMR1CTL); t &= ~TMR1CTL_ENABLE; - rt_wdt_w32(TIMER_REG_TMR1CTL, t); + rt_wdt_w32(drvdata->base, TIMER_REG_TMR1CTL, t); return 0; } @@ -105,7 +114,9 @@ static int mt7621_wdt_bootcause(void) static int mt7621_wdt_is_running(struct watchdog_device *w) { - return !!(rt_wdt_r32(TIMER_REG_TMR1CTL) & TMR1CTL_ENABLE); + struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w); + + return !!(rt_wdt_r32(drvdata->base, TIMER_REG_TMR1CTL) & TMR1CTL_ENABLE); } static const struct watchdog_info mt7621_wdt_info = { @@ -121,30 +132,39 @@ static const struct watchdog_ops mt7621_wdt_ops = { .set_timeout = mt7621_wdt_set_timeout, }; -static struct watchdog_device mt7621_wdt_dev = { - .info = &mt7621_wdt_info, - .ops = &mt7621_wdt_ops, - .min_timeout = 1, - .max_timeout = 0xfffful / 1000, -}; - static int mt7621_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - mt7621_wdt_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(mt7621_wdt_base)) - return PTR_ERR(mt7621_wdt_base); + struct watchdog_device *mt7621_wdt; + struct mt7621_wdt_data *drvdata; + int err; + + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; - mt7621_wdt_reset = devm_reset_control_get_exclusive(dev, NULL); - if (!IS_ERR(mt7621_wdt_reset)) - reset_control_deassert(mt7621_wdt_reset); + drvdata->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(drvdata->base)) + return PTR_ERR(drvdata->base); - mt7621_wdt_dev.bootstatus = mt7621_wdt_bootcause(); + drvdata->rst = devm_reset_control_get_exclusive(dev, NULL); + if (!IS_ERR(drvdata->rst)) + reset_control_deassert(drvdata->rst); - watchdog_init_timeout(&mt7621_wdt_dev, mt7621_wdt_dev.max_timeout, - dev); - watchdog_set_nowayout(&mt7621_wdt_dev, nowayout); - if (mt7621_wdt_is_running(&mt7621_wdt_dev)) { + mt7621_wdt = &drvdata->wdt; + mt7621_wdt->info = &mt7621_wdt_info; + mt7621_wdt->ops = &mt7621_wdt_ops; + mt7621_wdt->min_timeout = 1; + mt7621_wdt->max_timeout = 0xfffful / 1000; + mt7621_wdt->parent = dev; + + mt7621_wdt->bootstatus = mt7621_wdt_bootcause(); + + watchdog_init_timeout(mt7621_wdt, mt7621_wdt->max_timeout, dev); + watchdog_set_nowayout(mt7621_wdt, nowayout); + watchdog_set_drvdata(mt7621_wdt, drvdata); + + if (mt7621_wdt_is_running(mt7621_wdt)) { /* * Make sure to apply timeout from watchdog core, taking * the prescaler of this driver here into account (the @@ -154,17 +174,25 @@ static int mt7621_wdt_probe(struct platform_device *pdev) * we first disable the watchdog, set the new prescaler * and timeout, and then re-enable the watchdog. */ - mt7621_wdt_stop(&mt7621_wdt_dev); - mt7621_wdt_start(&mt7621_wdt_dev); - set_bit(WDOG_HW_RUNNING, &mt7621_wdt_dev.status); + mt7621_wdt_stop(mt7621_wdt); + mt7621_wdt_start(mt7621_wdt); + set_bit(WDOG_HW_RUNNING, &mt7621_wdt->status); } - return devm_watchdog_register_device(dev, &mt7621_wdt_dev); + err = devm_watchdog_register_device(dev, &drvdata->wdt); + if (err) + return err; + + platform_set_drvdata(pdev, drvdata); + + return 0; } static void mt7621_wdt_shutdown(struct platform_device *pdev) { - mt7621_wdt_stop(&mt7621_wdt_dev); + struct mt7621_wdt_data *drvdata = platform_get_drvdata(pdev); + + mt7621_wdt_stop(&drvdata->wdt); } static const struct of_device_id mt7621_wdt_match[] = { From patchwork Mon Feb 13 20:05:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 653656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D692C6FA8E for ; Mon, 13 Feb 2023 20:05:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230095AbjBMUFd (ORCPT ); Mon, 13 Feb 2023 15:05:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbjBMUF3 (ORCPT ); Mon, 13 Feb 2023 15:05:29 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B470C1D934; Mon, 13 Feb 2023 12:05:26 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id m16-20020a05600c3b1000b003dc4050c94aso9912809wms.4; Mon, 13 Feb 2023 12:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lhlCnihZNb20BPjIHQMYuoRdi3oZ62JfzhHTqCzRQ24=; b=dNDDKMpMHgloJyHwNh90yoMIp0iBvWg/A6xWij6O3F0yy3+V7nnKlJPbE7E4LXsUsd Wykacpe0ojR+DR2/W0SejFA5M4rG9mM8zrz3D3/o+PeM85pIsLV/lg1vr5YawwnYwTzJ MElxtQa2IkbKKVlxnPx3N5YMBa+DOK2c8SDe90tVivpwq2nd0s6xFjDFDhxM6Y4mJ1ZZ fw0krbuevPiUTPbwVcHoBH3WIEmelQnlY3Mvj+8voCMgBhAz2nGeOJ4GX9cj+tqZWykP DsCFE873vogsY0ojvhLKgWkQXY+cUkVl/nYcjgKgN41Alc9CkZ4TXB44qlq9FRAau9Uy UZCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lhlCnihZNb20BPjIHQMYuoRdi3oZ62JfzhHTqCzRQ24=; b=lRWnk4X8LT7wLEmn2yhWE4gL02HylIRUzjkqVCmdCqxkZ5xx8LSGv5ZJmKTIaqPc0U pnRuxVfyYPXJeVnTwPtVmlWQSRCJ7mqzK+i8Bsiw1kU77TA0fs0JnV9qts5uszYM2wNQ HAJUgwQrtoNp7c6pfNtA5TcC/f9H8NHd3JFO70KZ1kB52O4u9NgvBXU10D4oaOJZQrvK 0ELhKvtyRhyy8VvJKdMEY3KPQOUlsGKNbzLkYOKrwdbtFLfFA0p50fxEjcOh0q2VzU0t PkOYLJ6io22C3z0jFZE8WpC05Qizo5I65GQR4wxeuit8OGUV++9Dsi6eGQNFDUZ1BceE ETug== X-Gm-Message-State: AO0yUKXWpBCMdQt3L3ftDg5UaDw6Imvjx+douWGSS8XO1p1nP9bQoDpa nUbDzqFE6NabbmXdBqceW0JHVEDCZbQ= X-Google-Smtp-Source: AK7set8N4Fktu7d+K0Pr53TyVYQ66TrRRkSI6n5yAFkQioauKyspkp2DXN1WwVGJOvshbtLeQlnrHQ== X-Received: by 2002:a05:600c:81b:b0:3c6:e63e:23e9 with SMTP id k27-20020a05600c081b00b003c6e63e23e9mr23363211wmp.24.1676318724833; Mon, 13 Feb 2023 12:05:24 -0800 (PST) Received: from localhost.localdomain (23.red-88-10-60.dynamicip.rima-tde.net. [88.10.60.23]) by smtp.gmail.com with ESMTPSA id c129-20020a1c3587000000b003dc1a525f22sm15591242wma.25.2023.02.13.12.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 12:05:24 -0800 (PST) From: Sergio Paracuellos To: linux-watchdog@vger.kernel.org Cc: wim@linux-watchdog.org, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, arinc.unal@arinc9.com, tsbogend@alpha.franken.de, p.zabel@pengutronix.de, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH v6 3/3] watchdog: mt7621-wdt: avoid ralink architecture dependent code Date: Mon, 13 Feb 2023 21:05:19 +0100 Message-Id: <20230213200519.889503-4-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230213200519.889503-1-sergio.paracuellos@gmail.com> References: <20230213200519.889503-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org MT7621 SoC has a system controller node. Watchdog need to access to reset status register. Ralink architecture and related driver are old and from the beggining they are using some architecture dependent operations for accessing this shared registers through 'asm/mach-ralink/ralink_regs.h' header file. However this is not ideal from a driver perspective which can just access to the system controller registers in an arch independent way using regmap syscon APIs. Update Kconfig accordingly to select new added dependencies and allow driver to be compile tested. Signed-off-by: Sergio Paracuellos --- drivers/watchdog/Kconfig | 4 +++- drivers/watchdog/mt7621_wdt.c | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index b64bc49c7..cf752ad64 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1865,7 +1865,9 @@ config GXP_WATCHDOG config MT7621_WDT tristate "Mediatek SoC watchdog" select WATCHDOG_CORE - depends on SOC_MT7620 || SOC_MT7621 + select REGMAP_MMIO + select MFD_SYSCON + depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST help Hardware driver for the Mediatek/Ralink MT7621/8 SoC Watchdog Timer. diff --git a/drivers/watchdog/mt7621_wdt.c b/drivers/watchdog/mt7621_wdt.c index 40fb2c9ba..22e979bdd 100644 --- a/drivers/watchdog/mt7621_wdt.c +++ b/drivers/watchdog/mt7621_wdt.c @@ -15,8 +15,8 @@ #include #include #include - -#include +#include +#include #define SYSC_RSTSTAT 0x38 #define WDT_RST_CAUSE BIT(1) @@ -34,6 +34,7 @@ struct mt7621_wdt_data { void __iomem *base; struct reset_control *rst; + struct regmap *sysc; struct watchdog_device wdt; }; @@ -104,9 +105,12 @@ static int mt7621_wdt_stop(struct watchdog_device *w) return 0; } -static int mt7621_wdt_bootcause(void) +static int mt7621_wdt_bootcause(struct mt7621_wdt_data *d) { - if (rt_sysc_r32(SYSC_RSTSTAT) & WDT_RST_CAUSE) + u32 val; + + regmap_read(d->sysc, SYSC_RSTSTAT, &val); + if (val & WDT_RST_CAUSE) return WDIOF_CARDRESET; return 0; @@ -143,6 +147,10 @@ static int mt7621_wdt_probe(struct platform_device *pdev) if (!drvdata) return -ENOMEM; + drvdata->sysc = syscon_regmap_lookup_by_compatible("mediatek,mt7621-sysc"); + if (IS_ERR(drvdata->sysc)) + return PTR_ERR(drvdata->sysc); + drvdata->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(drvdata->base)) return PTR_ERR(drvdata->base); @@ -158,7 +166,7 @@ static int mt7621_wdt_probe(struct platform_device *pdev) mt7621_wdt->max_timeout = 0xfffful / 1000; mt7621_wdt->parent = dev; - mt7621_wdt->bootstatus = mt7621_wdt_bootcause(); + mt7621_wdt->bootstatus = mt7621_wdt_bootcause(drvdata); watchdog_init_timeout(mt7621_wdt, mt7621_wdt->max_timeout, dev); watchdog_set_nowayout(mt7621_wdt, nowayout);