From patchwork Wed Dec 18 12:23:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913587 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3178EE77188 for ; Wed, 18 Dec 2024 12:23:25 +0000 (UTC) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web11.104378.1734524601440620291 for ; Wed, 18 Dec 2024 04:23:21 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=aAXXKaom; spf=pass (domain: tuxon.dev, ip: 209.85.221.42, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-385e06af753so3313612f8f.2 for ; Wed, 18 Dec 2024 04:23:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524600; x=1735129400; darn=lists.cip-project.org; 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=11AoqFUKSWD3zMs2LLxkh6xVkPrdT/9gMNfkIPFCQXU=; b=aAXXKaomWsIFuDN8f6jhHlXA+J9NZzQC8JKC708p8WZ1fiJMUWFOZFil/Id5V/pggB fDAvGU4KCmbWNgUyt0T1/dnaWNoXTd7abW3HtRgLItS8E3TIXlwBJQywZJJ1yKv8z/BP 8kXM1t4dvMt5SnsicODRnUxzzKRhRCt4RalcN/K1kpv+lQ1iMZloduGnMxqdNJEKhCKJ OzDf0Pyvh0ekuBJJASvei7FIoxNx9DptjhFb6hD5PRcnUwmqltEb3ldMr9OXKctF/o4U ttCOLhpCQLxBYJwgg1pKDHZ3HArQR7oNQESFIp0HXEVuIDU2Zx6TLh5HuWus6ilnxr5A 2E+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524600; x=1735129400; 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=11AoqFUKSWD3zMs2LLxkh6xVkPrdT/9gMNfkIPFCQXU=; b=dJmqlhvuTOzVeIvZ3fAUBPCaQZdu6etmM0N2uHSbjfqFldMGyS+JkQgB8rbuqcB7+u nEZJi5uSDRu9hwiU1uOE4PNGyWyQndCjASuygGR2B0U5nUs0fGMXoeQkuFRtBmbMKkNc EiSunvAg8+Y5dOUipTiuH/75JdvXbyIsYnky5C02UfjnqWPfGM/Ei4S+PLKf76MW4jSm m/9Z7ykzIfPc1WsrixhCqYc9ux1K9WW8tOtFxITM0mZhLybLaHDBZBy/6Mmcze6kJA/8 6O5vaRG6JkYr76qiboZrcIJGBOxK9eQIDV37bQlvgrySoUWmXxZ3w+blDVBHqVIOk9qg qkjQ== X-Forwarded-Encrypted: i=1; AJvYcCW0VY3Ptbn361nY9/zkNanFUX2FuiJT4iaTwj2s4uMzdV2w9ib7fL5fXPC/t7FWigejiwxS/UCJ@lists.cip-project.org X-Gm-Message-State: AOJu0YxT/M3o6Rbho/6kwpnLvyqcEpMLVrfgd2LIOCAlUHsmNjA3u+Vj xhgOPOCtByNYGuG9hYejF1fKh71DnAPtvtdrhdcRJsf5DNjiKLqGtmBIfdIkTaw= X-Gm-Gg: ASbGncv0vY4m5XMKXx40VFM1JA6WRKdAHCNnM5flFeZZEOWuX4Yn5Iw+762E00Tpe8a /haEnckFTLmko6IvKkAvT33d9o6EqOTUlzrxhY+4lm9y7ErIh4XkEvG/oamix1cw9bQVZBohebI TIVuL2xQkg6G72ALOKiY50KuOK3KdiK0nYq/GvE1LOp8ZZC8zOBdsfHIJd1oO12qQr0T6Ac/cUT RkT48XrcnUTwfHd+sMaz+vAUY5LKwPWZbWRsMW8JHsMdkbP1xMQWGn+dCn3t55tNoW8mlYfMbb9 w8fzY0jsQVE= X-Google-Smtp-Source: AGHT+IEQhevb3fmuUVggxtwVNodkEu5PISGi0ASh5nFJJpc4VUEaB0K90re2RPtaJ4loZN+5tQvGDA== X-Received: by 2002:a5d:64a1:0:b0:385:faad:bfb9 with SMTP id ffacd0b85a97d-388e4d6be0emr2432846f8f.8.1734524599917; Wed, 18 Dec 2024 04:23:19 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:19 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 01/10] clk: renesas: r9a08g045: Add clock and reset support for watchdog Date: Wed, 18 Dec 2024 14:23:08 +0200 Message-ID: <20241218122317.2365272-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:25 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17454 From: Claudiu Beznea commit 292d3079abf333540fef06c1533d7c21c6d21390 upstream. RZ/G3S has a watchdog module accessible by the Cortex-A core. Add clock and reset support for it. Signed-off-by: Claudiu Beznea Reviewed-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20240122111115.2861835-2-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- drivers/clk/renesas/r9a08g045-cpg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/renesas/r9a08g045-cpg.c b/drivers/clk/renesas/r9a08g045-cpg.c index 2582ba95256e..c3e6da2de197 100644 --- a/drivers/clk/renesas/r9a08g045-cpg.c +++ b/drivers/clk/renesas/r9a08g045-cpg.c @@ -193,6 +193,8 @@ static const struct rzg2l_mod_clk r9a08g045_mod_clks[] = { DEF_MOD("ia55_pclk", R9A08G045_IA55_PCLK, R9A08G045_CLK_P2, 0x518, 0), DEF_MOD("ia55_clk", R9A08G045_IA55_CLK, R9A08G045_CLK_P1, 0x518, 1), DEF_MOD("dmac_aclk", R9A08G045_DMAC_ACLK, R9A08G045_CLK_P3, 0x52c, 0), + DEF_MOD("wdt0_pclk", R9A08G045_WDT0_PCLK, R9A08G045_CLK_P0, 0x548, 0), + DEF_MOD("wdt0_clk", R9A08G045_WDT0_CLK, R9A08G045_OSCCLK, 0x548, 1), DEF_MOD("sdhi0_imclk", R9A08G045_SDHI0_IMCLK, CLK_SD0_DIV4, 0x554, 0), DEF_MOD("sdhi0_imclk2", R9A08G045_SDHI0_IMCLK2, CLK_SD0_DIV4, 0x554, 1), DEF_MOD("sdhi0_clk_hs", R9A08G045_SDHI0_CLK_HS, R9A08G045_CLK_SD0, 0x554, 2), @@ -219,6 +221,7 @@ static const struct rzg2l_reset r9a08g045_resets[] = { DEF_RST(R9A08G045_GIC600_GICRESET_N, 0x814, 0), DEF_RST(R9A08G045_GIC600_DBG_GICRESET_N, 0x814, 1), DEF_RST(R9A08G045_IA55_RESETN, 0x818, 0), + DEF_RST(R9A08G045_WDT0_PRESETN, 0x848, 0), DEF_RST(R9A08G045_SDHI0_IXRST, 0x854, 0), DEF_RST(R9A08G045_SDHI1_IXRST, 0x854, 1), DEF_RST(R9A08G045_SDHI2_IXRST, 0x854, 2), From patchwork Wed Dec 18 12:23:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913585 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35E07C3DA4A for ; Wed, 18 Dec 2024 12:23:25 +0000 (UTC) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mx.groups.io with SMTP id smtpd.web10.104191.1734524602517616670 for ; Wed, 18 Dec 2024 04:23:22 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=NrBwXn3g; spf=pass (domain: tuxon.dev, ip: 209.85.128.54, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-434a766b475so66613785e9.1 for ; Wed, 18 Dec 2024 04:23:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524601; x=1735129401; darn=lists.cip-project.org; 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=00l3AJHksdJYBuQvXFBdiCL8NndypugymPjDcBYEyPE=; b=NrBwXn3gq4FPnQrVzGzrncPVSm9MMFBZwX/AYqclOJpcn21vajynrTdbb3fWGn0GjK h2+9GzjNDc8Zvsu4WlYiD0q3haY+w2G3R1Ajm9k1A1/Ejougw9m9T0jjTz9CTL6Gz0YV mZAUrcot2MJRmFm7CBEvP3YezH3Wlg8QbqstXh+O38aE8TfhnHFegB1FyuN+4lMXiXHJ XCYyGa5jtiDR7KcTQ1FwLU3W7oIgm6+Zv6cg1dY1J/E7KroIypu0RwakkXE38H60hnRM yRSEeRL7sP3gAMxfd0NxAOLrDW4saIcobdOC/SHTY17C2rSRLGPxSykBjrYvt7BdxBNQ 9zBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524601; x=1735129401; 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=00l3AJHksdJYBuQvXFBdiCL8NndypugymPjDcBYEyPE=; b=cdfDXoLVZ1TBroHLPXfEQ7yUaD4i3+H6Qyu7S7UJxFnQz/YcDtP9M9dV7FOB9pIz4E K/LCtPxwyceTydPb3AH21FdBxQh9IcFyB8MVN55dL74+hO1cgJJ+RtdmAzsPkTqwB7d7 idAb5m9MwqAUBHYqvg73FoXy17UCzcSZuUxNPfqmJj76rtLFjs7p13OaL7rX9qQIcNk2 56+SqiCOw6njoLAbfqo8gENLjri2Pv4hoRSuRUB7hT8gt6CpeDGE5Ap1rV3XZiDzwoc7 Zp0OfKbcgdp9pKxooJ/RqiAL3CVe4TPcJOPytcSkg0E1bTLh3/x2K6mT66/X0ZbtmtdK LJPw== X-Forwarded-Encrypted: i=1; AJvYcCUURVFSbqTIFyNlo6JMdOrstCSdc8vFcxGZyclgE0uuEf1TwRpsxMKs2g+qBAlM7+h7WrmkywK2@lists.cip-project.org X-Gm-Message-State: AOJu0YziYEKGHOrxOgjVHHldaPZXa3dvkuGOOcCMcwijQqLkQGlFOYFD zMcOPE4r/hQc9xP+DYWCcJIrVDD5OM8TdyC+TANDtNnKrG9qyF6xldWdkFF0BDc= X-Gm-Gg: ASbGncuUWxhFrKoWqnJMpNWvYPDGWoc1vMFgWTNCUa/ReuGBVHTFq1X25lvnsoU83fJ Dlu8MZ7xwApreFp97dDe9L+leZ30bu68TfxF4uwcdf0pi9q+EhdfB/xxWW5OA7R8tKZHUigPXjL nr7HPpyfog2Yv/jn1mlFiRC49gst/Db0IFEj/wEOCzRfllIsADI53DLX1Dgit95E7y3CPHVzzcF PFwSlgsaKHcseMbyVQosnaS90oyqOwx8mCJ4yun54u0kcII2mB+YVoUdOOtq1gmYL6bZ9o4AyMW DN5fgp7d2XY= X-Google-Smtp-Source: AGHT+IGaus9AHqTq76gAUWeO5okrtKpP5a0kvlR430VjlGn+Hauc+ZDYhBxKwIynl0xyuOxtRH390g== X-Received: by 2002:a05:600c:524f:b0:434:fddf:5c0a with SMTP id 5b1f17b1804b1-436553452d7mr24084925e9.3.1734524600917; Wed, 18 Dec 2024 04:23:20 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:20 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 02/10] watchdog: rzg2l_wdt: Use pm_runtime_resume_and_get() Date: Wed, 18 Dec 2024 14:23:09 +0200 Message-ID: <20241218122317.2365272-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:25 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17455 From: Claudiu Beznea commit f0ba0fcdd19943809b1a7f760f77f6673c6aa7f7 upstream. pm_runtime_get_sync() may return with error. In case it returns with error dev->power.usage_count needs to be decremented. pm_runtime_resume_and_get() takes care of this. Thus use it. Along with it the rzg2l_wdt_set_timeout() function was updated to propagate the result of rzg2l_wdt_start() to its caller. Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L") Signed-off-by: Claudiu Beznea Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20240531065723.1085423-4-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Claudiu Beznea --- drivers/watchdog/rzg2l_wdt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index d404953d0e0f..78d904df5f1e 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -123,8 +123,11 @@ static void rzg2l_wdt_init_timeout(struct watchdog_device *wdev) static int rzg2l_wdt_start(struct watchdog_device *wdev) { struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); + int ret; - pm_runtime_get_sync(wdev->parent); + ret = pm_runtime_resume_and_get(wdev->parent); + if (ret) + return ret; /* Initialize time out */ rzg2l_wdt_init_timeout(wdev); @@ -150,6 +153,8 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev) static int rzg2l_wdt_set_timeout(struct watchdog_device *wdev, unsigned int timeout) { + int ret = 0; + wdev->timeout = timeout; /* @@ -159,10 +164,10 @@ static int rzg2l_wdt_set_timeout(struct watchdog_device *wdev, unsigned int time */ if (watchdog_active(wdev)) { rzg2l_wdt_stop(wdev); - rzg2l_wdt_start(wdev); + ret = rzg2l_wdt_start(wdev); } - return 0; + return ret; } static int rzg2l_wdt_restart(struct watchdog_device *wdev, From patchwork Wed Dec 18 12:23:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913588 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F179E7718B for ; Wed, 18 Dec 2024 12:23:25 +0000 (UTC) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mx.groups.io with SMTP id smtpd.web11.104380.1734524603836910925 for ; Wed, 18 Dec 2024 04:23:24 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=Jx74xOHk; spf=pass (domain: tuxon.dev, ip: 209.85.128.43, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43622354a3eso44573635e9.1 for ; Wed, 18 Dec 2024 04:23:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524602; x=1735129402; darn=lists.cip-project.org; 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=0sZpTitVEMgqj8B0Z4Bpm8g9dx/7f7KAIN4AxwiOZPA=; b=Jx74xOHklu/0AtFumc6VynYpfHKJCtVrxnDj1KDbKwEYvgIeVn8rr9JzzXwTGtBPms wkEZ5PKiK/MKgpHaRoQJelaVRoy+NAQLauTZ4D07m+GZ5MO1hM9Zb3EZVhThRY2cRSEr MCNUl4cnbXKRPq/zJBeJ81jysa7zBu3sM6V/Y2dDv1CS99ePfRkLLHupH70/BTJVy8Kr 2oEUyysBnt+bebZgtu1rVgZm/JHk7QMoZb3/jj/GpJflCTXiqSihlt3gwDNJOHtacA2g oL2jplDYiQCsmxdt/3z2zC83KR+3havH5p9iOF4hhOcB+emtzHPTy8dE+x1T8qfBazUp kYWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524602; x=1735129402; 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=0sZpTitVEMgqj8B0Z4Bpm8g9dx/7f7KAIN4AxwiOZPA=; b=lETz6bTsuluVefjYeqK6crwqjeZ9GxtCV1BrrXlVpYY/S4D6K/RFOFdIhirmh60kXV ggF5QWyxKEUTqZsCNFRRBhdiUbEhoXZej79xUFf8AASyBWjq7i2Ttb9KRLUTRQGPDPiS a+Mweaw7Dz72nhpm2ZSFj7WZOoGDkeIeCxRjCetFgKPjOvGg8bDyrtn0UQxtUZWxkynT CdSkqpC+GSjLaRckvmjfeYOMLK2qaiSg8ubA9iDdmB3ljl0u1d5v4QDtLcvmlVKDdaJd gcxWt+jpmT2yx5SxnnpK2CQ0bzAccYDAZ2eF9s4LlXmJrm8CaY3v7FPUFmFrW035HhiJ 3haQ== X-Forwarded-Encrypted: i=1; AJvYcCWxQFKnZfjJ46QxDtiqlCegAhXTKyNWIZzAOUyEsd94GcQr4IwQi1CMlnpAWxHBpYOApVOT27wH@lists.cip-project.org X-Gm-Message-State: AOJu0YzKnIJhz833Muy/lG48tYbXZOSJOwQXU+TwKQjZqJwRl9P5d/aq 2oZbyfkjlBCKebHPwXOnz8fQpMhqzbCrENPka+WAOplgGO/rJ7RGYJxkXqrv8YA= X-Gm-Gg: ASbGncuRc3BuY0Z5T8G5X7Si+WJPBpcf9JHjghxRYxZ6WLKqiZFVfy+6gLNSRD4BceS nT9cQZJgd8yw5bRGhKlyPLjuH3P0vLDwyBjvBCGvNst+7p65erNrYMP3J3cdHR6lzR0NzzOV2RN pCiMqU6IZIuouUN2f3CfHIHj7ri1p3Sl+ZJnXKaoQqIvX8f1x3b3M6tpyZMhUGFlkOaqDiNeiPz dHB9fxl2aE+CP+ccNyXJYE4CurAM2sI2FT+5wAHOAMBh82ki27CWBY9Xtiunl48+9+0T61d7co5 MTsObmFCB0w= X-Google-Smtp-Source: AGHT+IHLkCqrCljt5RYNk7nv3ne3abXaQ8NizN8wcUMH40QSpvkrzYx+FL8EjLFZRHx0FDDHmw/pVw== X-Received: by 2002:a05:600c:4ed3:b0:436:488f:4f3 with SMTP id 5b1f17b1804b1-4365536e7ccmr25009215e9.17.1734524602252; Wed, 18 Dec 2024 04:23:22 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:21 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 03/10] watchdog: rzg2l_wdt: Check return status of pm_runtime_put() Date: Wed, 18 Dec 2024 14:23:10 +0200 Message-ID: <20241218122317.2365272-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:25 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17456 From: Claudiu Beznea commit 471e45a33302852bf79bc140fe418782f50734f6 upstream. pm_runtime_put() may return an error code. Check its return status. Along with it the rzg2l_wdt_set_timeout() function was updated to propagate the result of rzg2l_wdt_stop() to its caller. Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L") Signed-off-by: Claudiu Beznea Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20240531065723.1085423-5-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Claudiu Beznea --- drivers/watchdog/rzg2l_wdt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index 78d904df5f1e..9b2698a4fc1a 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev) static int rzg2l_wdt_stop(struct watchdog_device *wdev) { struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); + int ret; rzg2l_wdt_reset(priv); - pm_runtime_put(wdev->parent); + + ret = pm_runtime_put(wdev->parent); + if (ret < 0) + return ret; return 0; } @@ -163,7 +167,10 @@ static int rzg2l_wdt_set_timeout(struct watchdog_device *wdev, unsigned int time * to reset the module) so that it is updated with new timeout values. */ if (watchdog_active(wdev)) { - rzg2l_wdt_stop(wdev); + ret = rzg2l_wdt_stop(wdev); + if (ret) + return ret; + ret = rzg2l_wdt_start(wdev); } From patchwork Wed Dec 18 12:23:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913589 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31994E77187 for ; Wed, 18 Dec 2024 12:23:35 +0000 (UTC) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mx.groups.io with SMTP id smtpd.web11.104381.1734524604985408478 for ; Wed, 18 Dec 2024 04:23:25 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=EtLnLJy9; spf=pass (domain: tuxon.dev, ip: 209.85.128.43, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43625c4a50dso44793235e9.0 for ; Wed, 18 Dec 2024 04:23:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524603; x=1735129403; darn=lists.cip-project.org; 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=JRihk1XGgKv8NhSJW0zRtXEipnAVHt6UpK3/YhUvPxw=; b=EtLnLJy9O+W819cG3U0YlOcgzwcuv7vX7cloAILuop1YXv+wmXCjppE1Mi6rPXLebw 5PJPgxTRGkkkSKB4qAOWz1ZYcOu9SFI+uT7K7qjSsGfVFFiRi/QElNtNMN2rOQUrpdUL SlTe0idVUDvrGO6wcow7ZkCg18eGU5/LqdAqT3VbZXjDPNWlJo3XPrb8Qoy0il5ezs8f EScFViyDD/144hZNTzwtIx+kE5rXMLy6N6CeIOu1rsRlQxJBpIS1QRvbhouNlZ7bTwWt a1LIwgQOXOVRIgrweNqfrK3X85eObV9HbZZdoTNV2fvnTVkJ/ulWB6V48QD//uRLtrel grKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524603; x=1735129403; 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=JRihk1XGgKv8NhSJW0zRtXEipnAVHt6UpK3/YhUvPxw=; b=Zp29NepjUUimrJhuN7E0T0la0jE+5nhzt+ytjGmo97zRpeyAwaipDhulR2qkXktAdV STFds6odZrSevvIXeQOReJbjFfDZ2TMsN6KJeOoaqj3BDzugGnbDatNe+bbmw3TsVKic UMmjNHDSX2gfPsEUi3a6tBuwjauH3R9A0ZK46JlJiu6XKbYsTaLAjt8bils6MBtwXQlH 7voHaVko1eIWjZPjgVMtpLYKN3hrt4AP15/jsy7e6vgUI4mkvEBmmplOlNvrHdo2jfC/ MUD6rMQmZF2C1n67i+TVUzIUFILG58AE+7YXPqswj7n2AXc+foxZz80RAtxQtOAyNF5N /xvA== X-Forwarded-Encrypted: i=1; AJvYcCUb2xIkgxk8XbIgeOGlg3xnP21YrIGXDexkDDANSOm3emdC13LM9he4m9ye2Vryiz2gnhbuHyd7@lists.cip-project.org X-Gm-Message-State: AOJu0Yy+2GAwY8ZEdmEhUVu6wcDI6/SVu5XcXvKQUWpFuHwwPDM9Ep66 jLK6VCbxnPYhsNqjeaT7O9kk7GZXuHCv0F7SYDWV3hcpQERS7g64uoFgw1Oo+wM= X-Gm-Gg: ASbGncsuZ8Pn4jHrOA/mJbSV9Kp7zSNKpatDEc1trBcZREvKNcLPODH5qPEc2a4p4wE IIuHYoExQfNijdRpHNs5SMylEJWExZUzTy1DHsRPKUbjHj46YTKVs9FoEYiiBTxYpFJNX5+3PkQ DH0/Q6FpdedSCBemLnyFJK3CzI0nxywmGT7HLiRoL0pIw78m3JO3TSEJtYbZWZNJr5OUfW+7I3H rwE3JWyaXe3cE88VZ5t80pqPr7OKsjt8bKSrQ0cK4BCFHUR+LKKmAelJ/g/TvK0Fs8GLzb198DS vMbdlWdn9Qw= X-Google-Smtp-Source: AGHT+IFPfd8C9myq5Pz8v+ZRPMrnCzwg5/wW/mEdu2o9agheYEcXsvh2pOk22LL4lcA36gIOjzReqg== X-Received: by 2002:a05:600c:4508:b0:434:e2ea:fc94 with SMTP id 5b1f17b1804b1-4365535fe12mr20814245e9.11.1734524603431; Wed, 18 Dec 2024 04:23:23 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:22 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 04/10] watchdog: rzg2l_wdt: Remove reset de-assert from probe Date: Wed, 18 Dec 2024 14:23:11 +0200 Message-ID: <20241218122317.2365272-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:35 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17457 From: Claudiu Beznea commit 064319c3fac88e04f53f3460cd24ae90de2d9fb6 upstream. There is no need to de-assert the reset signal on probe as the watchdog is not used prior executing start. Also, the clocks are not enabled in probe (pm_runtime_enable() doesn't do that), thus this is another indicator that the watchdog wasn't used previously like this. Instead, keep the watchdog hardware in its previous state at probe (by default it is in reset state), enable it when it is started and move it to reset state when it is stopped. This saves some extra power when the watchdog is unused. Signed-off-by: Claudiu Beznea Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20240531065723.1085423-6-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Claudiu Beznea --- drivers/watchdog/rzg2l_wdt.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index 9b2698a4fc1a..a473de5ff886 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -129,6 +129,12 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev) if (ret) return ret; + ret = reset_control_deassert(priv->rstc); + if (ret) { + pm_runtime_put(wdev->parent); + return ret; + } + /* Initialize time out */ rzg2l_wdt_init_timeout(wdev); @@ -146,7 +152,9 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev) struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); int ret; - rzg2l_wdt_reset(priv); + ret = reset_control_assert(priv->rstc); + if (ret) + return ret; ret = pm_runtime_put(wdev->parent); if (ret < 0) @@ -186,6 +194,12 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev, clk_prepare_enable(priv->osc_clk); if (priv->devtype == WDT_RZG2L) { + int ret; + + ret = reset_control_deassert(priv->rstc); + if (ret) + return ret; + /* Generate Reset (WDTRSTB) Signal on parity error */ rzg2l_wdt_write(priv, 0, PECR); @@ -236,13 +250,11 @@ static const struct watchdog_ops rzg2l_wdt_ops = { .restart = rzg2l_wdt_restart, }; -static void rzg2l_wdt_reset_assert_pm_disable(void *data) +static void rzg2l_wdt_pm_disable(void *data) { struct watchdog_device *wdev = data; - struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); pm_runtime_disable(wdev->parent); - reset_control_assert(priv->rstc); } static int rzg2l_wdt_probe(struct platform_device *pdev) @@ -285,10 +297,6 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(priv->rstc), "failed to get cpg reset"); - ret = reset_control_deassert(priv->rstc); - if (ret) - return dev_err_probe(dev, ret, "failed to deassert"); - priv->devtype = (uintptr_t)of_device_get_match_data(dev); if (priv->devtype == WDT_RZV2M) { @@ -309,9 +317,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) priv->wdev.timeout = WDT_DEFAULT_TIMEOUT; watchdog_set_drvdata(&priv->wdev, priv); - ret = devm_add_action_or_reset(&pdev->dev, - rzg2l_wdt_reset_assert_pm_disable, - &priv->wdev); + ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, &priv->wdev); if (ret < 0) return ret; From patchwork Wed Dec 18 12:23:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913592 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43EE7E7718A for ; Wed, 18 Dec 2024 12:23:35 +0000 (UTC) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mx.groups.io with SMTP id smtpd.web10.104194.1734524606492258166 for ; Wed, 18 Dec 2024 04:23:26 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=PuotNHcT; spf=pass (domain: tuxon.dev, ip: 209.85.128.50, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-43618283dedso62035115e9.3 for ; Wed, 18 Dec 2024 04:23:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524605; x=1735129405; darn=lists.cip-project.org; 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=yXMNAESOXHqTAoAF8i42CNtySnBQQXTbd8Cyrt6OENY=; b=PuotNHcTZ9k3R0WbWXK7RpNKR+nZHmPDiQKAIB1EzycH7EkubR+CWaFmJK+R1zLQL6 cp3MyggTaGgWsHuM1jrl11t8OcJtchz/XTX2WgpDT4m2u49OWUfcGM3BVxOXjytG//FX Unc7K8UhYqgYPhl9iwgVOi0GrULiRxOldHVtOu4YXHN0JjRoGwJs2YEbUNu1qeOg5tu0 bWW2YaZtpSqLhMz4MQhUEIaqLhkLC4MW52Q3Bh+8IOeZlfhTQOj6t6TsXp38/TiFnwp+ nLIEWgCXfrqu+DF3uQSqWD+BCB5jranZNe4aWYMrWtaZXz+pDyNkXSqxmIgM5Zd/c4ko jINQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524605; x=1735129405; 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=yXMNAESOXHqTAoAF8i42CNtySnBQQXTbd8Cyrt6OENY=; b=sjCQOlF6ORe0clPsHDpSogSB7HLGcTp0WMJVscTW4XS3aa675BqMuPNUBimA9Neqx5 9ZM5knwAO6j18Ew+LHxsozQ8SYHni9iPokfOd0P9QahvG4NxWkDBnYnNYYrDbE0Et6Y0 Vjkv8vN3oD9TvBwBtbqwNTSooxdb/Y0G/Ai+spzQo32+2mEYhqDc37xgdCaAYFU7iWuL WgMvazqotfcvgltx3YpzPV/AgETZm8B5mW/NTZ9H/YZe77U1zA4C4GNzuXc1BQPOJk+B 8KINR3JtVhSBJuZ9gawPREv3vHwyg02vRniQAQJNSzjBET+6pmzWX+RnK2cOvzdfOr/v 7cCA== X-Forwarded-Encrypted: i=1; AJvYcCX2PKEJyTr2QXW4DyyVKYrl/VsSLG0khBG6aUTCCe1jbDfj3qz3KDHn7F1wWp2qw+GW9pG9RuzC@lists.cip-project.org X-Gm-Message-State: AOJu0Yy6SRmxbgrB5iN41yB53rYcxpYpqkCHUXG13CBDTfg3snxiQQgu bgCNNysvbQWaH2/OClafVBcGdC4Owhott4Qh2LnVup0e7upuanhKZAcU5ZB0Mi4= X-Gm-Gg: ASbGnctQ97Npaw2NEb1/owNxFgSeHIilK0N3rGd1io6rHVuzCUxQLwTQJIwC8n9SnQJ 29csa55asHXgGdspM49nNR7aRgYMMpw9lWO51Uf0twhHRUFg2dBbQKg7xs7MCHmZC5PE7qnaYDB yn/rbQ7DnIc10jVG+6BeP0sEbvKz2WVl0wtqOftbQif70yRm2TDqR13zJZYNrk1XQgWuSbh0TFO 17lW+sl9LtK2QuSFfmix8QcbV1R2YsqusTcD95gek+AgmyT+v91thML+557Xg3xc0sTTQy+XiGv rZiO98+BiU4= X-Google-Smtp-Source: AGHT+IEHsUNBD4GSJuTGqz5DMvLoW8Q3c3iQ0vVcy9rBLt03oPXwSO/V7XBife35AXRr/zXwRsIb7Q== X-Received: by 2002:a05:600c:1910:b0:435:1a2:2633 with SMTP id 5b1f17b1804b1-43655368155mr26855145e9.15.1734524604905; Wed, 18 Dec 2024 04:23:24 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:24 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 05/10] watchdog: rzg2l_wdt: Remove comparison with zero Date: Wed, 18 Dec 2024 14:23:12 +0200 Message-ID: <20241218122317.2365272-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:35 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17458 From: Claudiu Beznea commit 900b938335f7fbd401dcba14c8069dbf38ed1f28 upstream. devm_add_action_or_reset() could return -ENOMEM or zero. Thus, remove comparison with zero of the returning value to make code simpler. Signed-off-by: Claudiu Beznea Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20240531065723.1085423-7-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Claudiu Beznea --- drivers/watchdog/rzg2l_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index a473de5ff886..2c50e4c76131 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -318,7 +318,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) watchdog_set_drvdata(&priv->wdev, priv); ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, &priv->wdev); - if (ret < 0) + if (ret) return ret; watchdog_set_nowayout(&priv->wdev, nowayout); From patchwork Wed Dec 18 12:23:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913595 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 564CEE7718D for ; Wed, 18 Dec 2024 12:23:35 +0000 (UTC) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.web11.104386.1734524607637656079 for ; Wed, 18 Dec 2024 04:23:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=UdYJBqCZ; spf=pass (domain: tuxon.dev, ip: 209.85.128.47, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43618283d48so46357255e9.1 for ; Wed, 18 Dec 2024 04:23:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524606; x=1735129406; darn=lists.cip-project.org; 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=jkJG4Bqf1RF27OjiKI0iUzCClliQfuwI+suFdV7UrVo=; b=UdYJBqCZHMXTSR7mOx6ob9PJEztvngmoug7jUyGyQ9JwUYdkFkcK5T+zzuuZFdB4Uf z22vMare6ETFmnpMbrp/azCY2nqj/gZnMdTnIGFb5c5EvSVrVJt2Ba2tESCqRHRhfCS1 4340flixt0DhrwK5b/krVpqbkdLe+iWECCBonm1ANb8ijtLs5QOv93OrHTlVd42mg5CT VCgDfYpMZMlfSayuP370DkmsXbdk8Y/w8jNMJsJV1QmO0sU26hLqxFTMZaeBtHttYiMt LnspN5YDgtuLNp1wxBIMLFUyfWJG7Xew3nlTH6xbXMjm7i8d5sxeX/rwTLKv+2nw7uS6 Cl1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524606; x=1735129406; 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=jkJG4Bqf1RF27OjiKI0iUzCClliQfuwI+suFdV7UrVo=; b=CML4WxDej5rO5SOiOGNc45Tx6DPiJDfv/9YML/ucYc/EpleTf+cowCNPKPymgldzvM 7vk3jNulkZqOO/FeLjqjOKl5ljCanAKBRDiO1BKzcTIPKYkcfHJqWqjf8e4rs42v51H4 fm4MsuESwSugJmMopjrYsRJ2Sr8pqim+TiFCjroFVAVwYqR2DmXX87rKwfEsHk5MFzwF ya6Dc7Bbd3BovEFLoBhfngqvhhEMxcYzdGAG0zbJjYz05q7PABttRu0bhBsIsuK+gqyx OihyO0no4+ElaV2TtwQzXmpDbniTIj0mHuxYp7rEcQLGjJ/dzuk7RkecTrZD+A2LXrQt 4x8A== X-Forwarded-Encrypted: i=1; AJvYcCXpZS83Mk3WPGz6q1/vHB/pgwd3UaZ+K8fxUd/eRR3SRdou3IwYpTbpr4mk0ttqWmhAOFcvVtT6@lists.cip-project.org X-Gm-Message-State: AOJu0YwXaGFMjBqyguGyaT7eiSXFj2Cnyq9tiFxspqvjYKtHRzYKoM4s geevRz9SNKxzPWfqdTY7yCPWfvOb/E8VW66f7P1Y5+NgeqgpTYRwhbKqsMu0VhZZUJtuPG7fo7V Q X-Gm-Gg: ASbGnctLTL1fXs2YK+sfeVF+8zuFx8PzQzdhE1H6XjPmGFKSJ5Pq5faZuNp275RU1nT ciah8JE77cr5ZpvKhUAUy363lyzM6zv43CVc5emCg/kP4oXUxBub2m7SLcGvD6ZycHQFTczbu0z Ns61/rIC6xSe4rEEosq2vphPO6uW5tQAYi5Fuz9Ct9FitzOzz5LIoetnTzIG6Epd8P+DkpPqIjg srsHaQSW5gBfE/z19spbz3VxwkHfiYKXbZwedo2R7VyqIzwwKWdL9wHn1Sgsn9vMWKEYWR+pNLn RMlFYGiz9A8= X-Google-Smtp-Source: AGHT+IE9ULXt/GJZHAx5EMsDTkM8CKSWm2Te0HdcgLs4d0I5Er5kdvMtuKnjp24iY3Gzhe3KoUAKDw== X-Received: by 2002:a05:600c:1d08:b0:434:a4b3:5ebe with SMTP id 5b1f17b1804b1-436553ec84cmr21394925e9.24.1734524606044; Wed, 18 Dec 2024 04:23:26 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:25 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 06/10] watchdog: rzg2l_wdt: Rely on the reset driver for doing proper reset Date: Wed, 18 Dec 2024 14:23:13 +0200 Message-ID: <20241218122317.2365272-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:35 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17459 From: Claudiu Beznea commit d8997ed79ed7c7c32b2ae571e0d99a58bbfd01fe upstream. The reset driver has been adapted in commit da235d2fac21 ("clk: renesas: rzg2l: Check reset monitor registers") to check the reset monitor bits before declaring reset asserts/de-asserts as successful/failure operations. With that, there is no need to keep the reset workaround for RZ/V2M in place in the watchdog driver. Signed-off-by: Claudiu Beznea Reviewed-by: Philipp Zabel Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20240531065723.1085423-8-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Claudiu Beznea --- drivers/watchdog/rzg2l_wdt.c | 39 ++++-------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index 2c50e4c76131..ea535739f8b6 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -54,35 +53,11 @@ struct rzg2l_wdt_priv { struct reset_control *rstc; unsigned long osc_clk_rate; unsigned long delay; - unsigned long minimum_assertion_period; struct clk *pclk; struct clk *osc_clk; enum rz_wdt_type devtype; }; -static int rzg2l_wdt_reset(struct rzg2l_wdt_priv *priv) -{ - int err, status; - - if (priv->devtype == WDT_RZV2M) { - /* WDT needs TYPE-B reset control */ - err = reset_control_assert(priv->rstc); - if (err) - return err; - ndelay(priv->minimum_assertion_period); - err = reset_control_deassert(priv->rstc); - if (err) - return err; - err = read_poll_timeout(reset_control_status, status, - status != 1, 0, 1000, false, - priv->rstc); - } else { - err = reset_control_reset(priv->rstc); - } - - return err; -} - static void rzg2l_wdt_wait_delay(struct rzg2l_wdt_priv *priv) { /* delay timer when change the setting register */ @@ -189,13 +164,12 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev, unsigned long action, void *data) { struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); + int ret; clk_prepare_enable(priv->pclk); clk_prepare_enable(priv->osc_clk); if (priv->devtype == WDT_RZG2L) { - int ret; - ret = reset_control_deassert(priv->rstc); if (ret) return ret; @@ -207,7 +181,9 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev, rzg2l_wdt_write(priv, PEEN_FORCE, PEEN); } else { /* RZ/V2M doesn't have parity error registers */ - rzg2l_wdt_reset(priv); + ret = reset_control_reset(priv->rstc); + if (ret) + return ret; wdev->timeout = 0; @@ -299,13 +275,6 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) priv->devtype = (uintptr_t)of_device_get_match_data(dev); - if (priv->devtype == WDT_RZV2M) { - priv->minimum_assertion_period = RZV2M_A_NSEC + - 3 * F2CYCLE_NSEC(pclk_rate) + 5 * - max(F2CYCLE_NSEC(priv->osc_clk_rate), - F2CYCLE_NSEC(pclk_rate)); - } - pm_runtime_enable(&pdev->dev); priv->wdev.info = &rzg2l_wdt_ident; From patchwork Wed Dec 18 12:23:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913594 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B2DCE7718F for ; Wed, 18 Dec 2024 12:23:35 +0000 (UTC) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.web11.104387.1734524608774382543 for ; Wed, 18 Dec 2024 04:23:29 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=GGTuJm69; spf=pass (domain: tuxon.dev, ip: 209.85.128.47, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4361d5dcf5bso69054955e9.3 for ; Wed, 18 Dec 2024 04:23:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524607; x=1735129407; darn=lists.cip-project.org; 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=0frQq1EYuR3+GgckAfdBQxSbxXb+N22JueZK+VM+kNE=; b=GGTuJm69VYFpllhhghXyGrtXgEfa9/kMFI3pEg4rL/n9TU10GknnBbCd1GECWksfno 29NyRCRXRQol7u4zc2n5u6F0M4ZmUhw1EpHifgmzQH1HLAQBjQ2FTdjrh3dfkB7Tw+FU bJPJk6t9xsrksVl20KFh0YxcgDk686STjRONM7e6Rnc2VexwjMVfZE9B3JPiGwXyGKC+ nCHq83c3pS8Sp+646PYtOP2nY3k8u6i/2pcaewM11bL/bnFMNqgtieRpph/e6Ixb+7SN ODPk4gEmuZDsaPs3lC5pZQOhad9tKtfrS/uz86HR6vxB1QZiOPWl1aIC/tJ6JJxC1TgZ nttA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524607; x=1735129407; 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=0frQq1EYuR3+GgckAfdBQxSbxXb+N22JueZK+VM+kNE=; b=oLC85LRXfiVdJ9W3o6buIG+S41t0JE0Ww1F0oTWYwUOrN7Aps8omgPjL83D+VYNEnn il+jc9EdBqPYTjnj2dpKPuv5lakZOmou72QkDx7JLsS7drp5vPZBLfTB1zPCjcCDdO0G 30WAqH1Y1P5JhPq7GRiuuoiJJYzSzCXI4RfRABx7Y+q9jmTXPi/zEndozl7Q1opJy0Tq P9FenEgCrYKX5dzIRSxNC1/4/e8UYGxZAjXyJvvABkj3Xlb73b1lGtJ+Hc7J5sO9bjjd +oRRFHJUyB927YJpJsFdGAygtxoU2DaypKCeOWseVLFXFvR6tlSeExWcHWF/oIL1SZjd 8X1A== X-Forwarded-Encrypted: i=1; AJvYcCX0FCHpPxejm4IiP02Fc8X7Jcr6lu1MUSv9KB+gO3zxMKXjrg0l9NABttniai/AEu8oU48wAnsI@lists.cip-project.org X-Gm-Message-State: AOJu0Yz4GLZtHiDm+Oq7eO06Tf2FQOlwhZNvMMV1qhz/UWm9d+M23qBS V3+MaLwYxQmw7YBVKLwwmoEwivRAwrTu9iDH99Yo8aryykF3F2KCyukJiaMdi2I= X-Gm-Gg: ASbGnctOBsimNjUhX+/8DoX3xZM50TzkVpYKEHS7886M+JaD2b44ls+Bo1akF0RomxU wWSo8SBhTGuUX7tiMBvQybA24WZO/O8OGCjspy71EnFOgD70DNr5Pob1WuDQTMYeEZgmXNH4rvv 99LKt5pGsa4sPRn5sSj0zSTLmfuS2qNA+hMarzsemNXo1wGeSiRf9HzN1czu0TLAiSRwP1plKlN SCZ4vhZHGLfe8bdpGky3SpAlmp8Gw4LcQQcYirzyWo0pUrefmdabzhzgJWyxSljPPOHTI4Sp+lA 6il28vLUqEk= X-Google-Smtp-Source: AGHT+IHDOYcQ9nOuLCW/8uDZ8mb7ZsB7HODlV9vvdoybBDcWrpRxqJmWRQiO9TROlgPiFEwgmamZkg== X-Received: by 2002:a05:600c:1987:b0:436:1b81:b65c with SMTP id 5b1f17b1804b1-4365536813fmr28035385e9.15.1734524607196; Wed, 18 Dec 2024 04:23:27 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:26 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 07/10] watchdog: rzg2l_wdt: Add suspend/resume support Date: Wed, 18 Dec 2024 14:23:14 +0200 Message-ID: <20241218122317.2365272-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:35 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17460 From: Claudiu Beznea commit 0aad7c4438b2e87359cd7b42c3e11b17f477ab8f upstream. The RZ/G3S supports deep sleep states where power to most of the IP blocks is cut off. To ensure proper working of the watchdog when resuming from such states, the suspend function is stopping the watchdog and the resume function is starting it. There is no need to configure the watchdog in case the watchdog was stopped prior to starting suspend. Signed-off-by: Claudiu Beznea Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20240531065723.1085423-9-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck [claudiu.beznea: replaced LATE_SYSTEM_SLEEP_PM_OPS() with SET_LATE_SYSTEM_SLEEP_PM_OPS() Signed-off-by: Claudiu Beznea --- drivers/watchdog/rzg2l_wdt.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index ea535739f8b6..afc1e9f1bf04 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -286,6 +286,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) priv->wdev.timeout = WDT_DEFAULT_TIMEOUT; watchdog_set_drvdata(&priv->wdev, priv); + dev_set_drvdata(dev, priv); ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, &priv->wdev); if (ret) return ret; @@ -307,10 +308,35 @@ static const struct of_device_id rzg2l_wdt_ids[] = { }; MODULE_DEVICE_TABLE(of, rzg2l_wdt_ids); +static int rzg2l_wdt_suspend_late(struct device *dev) +{ + struct rzg2l_wdt_priv *priv = dev_get_drvdata(dev); + + if (!watchdog_active(&priv->wdev)) + return 0; + + return rzg2l_wdt_stop(&priv->wdev); +} + +static int rzg2l_wdt_resume_early(struct device *dev) +{ + struct rzg2l_wdt_priv *priv = dev_get_drvdata(dev); + + if (!watchdog_active(&priv->wdev)) + return 0; + + return rzg2l_wdt_start(&priv->wdev); +} + +static const struct dev_pm_ops rzg2l_wdt_pm_ops = { + SET_LATE_SYSTEM_SLEEP_PM_OPS(rzg2l_wdt_suspend_late, rzg2l_wdt_resume_early) +}; + static struct platform_driver rzg2l_wdt_driver = { .driver = { .name = "rzg2l_wdt", .of_match_table = rzg2l_wdt_ids, + .pm = &rzg2l_wdt_pm_ops, }, .probe = rzg2l_wdt_probe, }; From patchwork Wed Dec 18 12:23:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913590 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31AACE77188 for ; Wed, 18 Dec 2024 12:23:35 +0000 (UTC) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mx.groups.io with SMTP id smtpd.web10.104196.1734524609955047661 for ; Wed, 18 Dec 2024 04:23:30 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=rCNsqpj2; spf=pass (domain: tuxon.dev, ip: 209.85.221.48, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-385d7f19f20so3254289f8f.1 for ; Wed, 18 Dec 2024 04:23:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524608; x=1735129408; darn=lists.cip-project.org; 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=nlw3XORVxneL5Y+VJ7M6kWxkt5o4r00XhCIFwaPgRow=; b=rCNsqpj2iC9MijNlRJ0u/l5me1Gs4pTMvSfDOcAw5UMw9SBGGFGJ9xKQFdMI9ZJPLA uE1ygpzcJfBHs3bDA7FIzQeZCCwcGuF5jO6Da7X8S39RVGKAUcAmJgbfKNq0b3oxMW9a IORLvXC7cMgQuxDv6vY2tcGQFl9//YhZmmMn8x0kFIXU5KxEeAIQyoPmZNiaMx9nNUMO isYGtxYr3R65G35XbMFgduvJA2zkgdkDq4WKY18JSmXimlbpk2JjH7lLfLxt/WfF3SfW 99mCA+NgoULuCMHdooMLYjqiuQ9fo3QBVl7pxGQtyE4XSXNOc5vWcdgE0dT7fypd8HYB bhWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524608; x=1735129408; 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=nlw3XORVxneL5Y+VJ7M6kWxkt5o4r00XhCIFwaPgRow=; b=eN+6yJb58xHcl4SUeHLubX10KNVJkP3ij5fURRy2ssnwjRrXM4M4+vic56TQ6Gkk+B WorCHbBy7b7Iqasm6MYz4ylJ9+zHhJAMkxouY60b72Pz0e/2kSW6eTl8Bwo+DFFblx2f cej3bB/3qg/nJY97MZt2ofwsYm/EdFT72HYSKNTaE5Z1vK7SNEX5RbCqcxMB3Z8FE5up PhwR7ThZt7cHkG2oNkN1T/lCcJfO43K42ORM7h8GmYj2/q6p6wjEMIfM2J3t3RIk9hfv A0O+XLY/4moAUoC0PZ8yjyFVaZRsXZ2fKLPJH3pYuN38Fn1Bbl/b+BtLrk3zqvkyuXlx MFoQ== X-Forwarded-Encrypted: i=1; AJvYcCWSbn7MfIMCGbphTsGzP0j0/bQFAwHZtTvgo4J78zx9xQjaLCxwfoevXKeBiEZMiCUUUi8t2+7i@lists.cip-project.org X-Gm-Message-State: AOJu0YwqD0ZycEl3gOX67G0VbrbSd88HuGNv+ZJ6JuIlhfiHnoNTlSxq vnX3NruSjZBGfilkyfnBytt9SkXiIvdVSgb0jNgXSzjO95UEsQtyzZl2TO+g7Xk= X-Gm-Gg: ASbGncvQL/tGOZp2YyuWxCfY6LWq6ZNZruMEubuIbItQyEaliCLrFCeRuz3Pzs0Gazp AgDDMDMCF7D1TlOQhj1AWTKnCkrS4WcO9QNSJJZ5AhBjhr24RSSVOOxBGqw/L8GMOGSlVreYqIj B4iZQgrpHVq+z0695oMeqeGIvQNvYcn+Ae0Wf78gXeHdIIxiwX+I8H67c6HLZx9hellrnKSfMdv Pt/JPLUCHpSmLTK936vwVcNXAJ7Wg01YqZ9moDRhzxpDXovX9yO2CohzBi2JwWrkiYuqUaKsAxM 2pcJyy21zzI= X-Google-Smtp-Source: AGHT+IEe/Omg7IqQv60ISQOz52lbNvGcmVjQoI9q7afV871dUvnSWiGxSBcdN6HG7J54uxNdNEhDfg== X-Received: by 2002:a05:6000:1f8f:b0:385:e013:39ec with SMTP id ffacd0b85a97d-388e4d2df18mr2196901f8f.8.1734524608326; Wed, 18 Dec 2024 04:23:28 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:27 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 08/10] watchdog: rzg2l_wdt: Power on the watchdog domain in the restart handler Date: Wed, 18 Dec 2024 14:23:15 +0200 Message-ID: <20241218122317.2365272-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:35 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17461 From: Claudiu Beznea commit bad201b2ac4e238c6d4b6966a220240e3861640c upstream. On RZ/G3S the watchdog can be part of a software-controlled PM domain. In this case, the watchdog device need to be powered on in struct watchdog_ops::restart API. This can be done though pm_runtime_resume_and_get() API if the watchdog PM domain and watchdog device are marked as IRQ safe. We mark the watchdog PM domain as IRQ safe with GENPD_FLAG_IRQ_SAFE when the watchdog PM domain is registered and the watchdog device though pm_runtime_irq_safe(). Before commit e4cf89596c1f ("watchdog: rzg2l_wdt: Fix 'BUG: Invalid wait context'") pm_runtime_get_sync() was used in watchdog restart handler (which is similar to pm_runtime_resume_and_get() except the later one handles the runtime resume errors). Commit e4cf89596c1f ("watchdog: rzg2l_wdt: Fix 'BUG: Invalid wait context'") dropped the pm_runtime_get_sync() and replaced it with clk_prepare_enable() to avoid invalid wait context due to genpd_lock() in genpd_runtime_resume() being called from atomic context. But clk_prepare_enable() doesn't fit for this either (as reported by Ulf Hansson) as clk_prepare() can also sleep (it just not throw invalid wait context warning as it is not written for this). Because the watchdog device is marked now as IRQ safe (though this patch) the irq_safe_dev_in_sleep_domain() call from genpd_runtime_resume() returns 1 for devices not registering an IRQ safe PM domain for watchdog (as the watchdog device is IRQ safe, PM domain is not and watchdog PM domain is always-on), this being the case for RZ/G3S with old device trees and the rest of the SoCs that use this driver, we can now drop also the clk_prepare_enable() calls in restart handler and rely on pm_runtime_resume_and_get(). Thus, drop clk_prepare_enable() and use pm_runtime_resume_and_get() in watchdog restart handler. Signed-off-by: Claudiu Beznea Reviewed-by: Ulf Hansson Reviewed-by: Geert Uytterhoeven Acked-by: Guenter Roeck Link: https://lore.kernel.org/r/20241015164732.4085249-5-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Claudiu Beznea --- drivers/watchdog/rzg2l_wdt.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index afc1e9f1bf04..73d92b6cbcf8 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -166,8 +167,22 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev, struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); int ret; - clk_prepare_enable(priv->pclk); - clk_prepare_enable(priv->osc_clk); + /* + * In case of RZ/G3S the watchdog device may be part of an IRQ safe power + * domain that is currently powered off. In this case we need to power + * it on before accessing registers. Along with this the clocks will be + * enabled. We don't undo the pm_runtime_resume_and_get() as the device + * need to be on for the reboot to happen. + * + * For the rest of SoCs not registering a watchdog IRQ safe power + * domain it is safe to call pm_runtime_resume_and_get() as the + * irq_safe_dev_in_sleep_domain() call in genpd_runtime_resume() + * returns non zero value and the genpd_lock() is avoided, thus, there + * will be no invalid wait context reported by lockdep. + */ + ret = pm_runtime_resume_and_get(wdev->parent); + if (ret) + return ret; if (priv->devtype == WDT_RZG2L) { ret = reset_control_deassert(priv->rstc); @@ -275,6 +290,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) priv->devtype = (uintptr_t)of_device_get_match_data(dev); + pm_runtime_irq_safe(&pdev->dev); pm_runtime_enable(&pdev->dev); priv->wdev.info = &rzg2l_wdt_ident; From patchwork Wed Dec 18 12:23:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913593 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BCEFE7718B for ; Wed, 18 Dec 2024 12:23:35 +0000 (UTC) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mx.groups.io with SMTP id smtpd.web11.104388.1734524611205825079 for ; Wed, 18 Dec 2024 04:23:31 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=OY4F9Frg; spf=pass (domain: tuxon.dev, ip: 209.85.128.41, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-436249df846so44538455e9.3 for ; Wed, 18 Dec 2024 04:23:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524609; x=1735129409; darn=lists.cip-project.org; 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=WgxTatePtmMYlJQsFEFDlE1obW/nLAy4k+ERKlaRMTw=; b=OY4F9Frg9sk2tQU/z6CQvj3uuMGTZwDV/vw5jty7rylRBQPZYz6ITMbEJdAmzHUmfx GV0GCB7X4ja+Rw34ikCfDW0sJN3sdIusIMOThKcroWr9Uf/t3PhfxzWllyQxlGi498XI xv8s0QnaWRvBWok37ocCi2+WMBMcrCZ80XGFAWZJ1BabFu2+s9Lso72MTCdZFAhJKvK0 5SAE7o/JzOV1Pb3GD9T7GacprLVNIJUlZcAxGR3LGDJb8ErMKvuifDMY5cxEW/j5QqfM JcOBgIDwBtjLjpT1mbJBxs0Jh+jVsDM1o3uPG6q0hSZ8oDi8GG4gzkKsoY3KGu5HDifk PvOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524609; x=1735129409; 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=WgxTatePtmMYlJQsFEFDlE1obW/nLAy4k+ERKlaRMTw=; b=onZq+R6Cu+Q8Z0r3bm9ZwsWz+tYcQNEsmXoRNvyqoplYHTIUvU+/WcXsu59jnAygli y+2GDYGKX3oDHyben52zdYg/PRINjQszkhSuC8TY54KDtD0u1yThD7B2l1hFkvnN7RGA BWVJUjzIB+D8usy4kv0AZhkzBl+i0WOhb+RohBl60tPB7gVotP2oPDTZGhEjOtve2b0Y en6wkULAqh9KLpXOrgX+DBMQ8V6LAKfBJIeFLx7TWuKbviDgech7K7U+76y/E0RpgZNI C8HiiTSTuK9qr2RMQzMsvFPYsjX99HIpx87uDgQRci5ofDcGl/oglSoj/3L0HMAbovLJ thhQ== X-Forwarded-Encrypted: i=1; AJvYcCUetCPl5RM7fyQD+KME4Vqm/ZhMvDgqwObvGwBzD6qQkyeowFEqkMzjTji30I/EKXNmReDVPDlV@lists.cip-project.org X-Gm-Message-State: AOJu0YxuZRJagbai+CJDgovtvVA39S2jXy2vUnYJX0uy8q3dr+iNVKhy LLIv6CKN014ipmra4BVNc6w2iYOSIMt3wamtTTx5WuANOdDOW4c70Fdj+M+Z50E= X-Gm-Gg: ASbGncuoE7csOKd99L9QlkLLhCQT9PA/ZJ2qFSCUMgpM40otuKi8dYjZcV0S1cBtSAX mTbeSqpZ0DnQJEPyUEBrTdhZTR6S3ljKNLe5osLmqXaEKBlTgAnDH/J/+T25EsXkJ05tcZg0/vp ej4ac633adyRCYpriGQM/rx6KMZlID2Cq+6X4nyBkrsRpHX7tcQFY0iLsl3mFRvOevJ1VeOBI6G X380NXlXP3u5frpUht7RXrVacD/6POdfF9CYR8thFtCPhKP4fxdo+klm3nyv9Vl/zeaR811pE3a HwgCdaFrFJ8= X-Google-Smtp-Source: AGHT+IEkI32YBqLWbo+O1L+Y301UBmt1cFmLplllBKR/0MzVKan82VDKX3amtbwJ+W4x/LNvILKQ2A== X-Received: by 2002:a05:600c:4ed3:b0:436:488f:4f3 with SMTP id 5b1f17b1804b1-4365536e7ccmr25013235e9.17.1734524609622; Wed, 18 Dec 2024 04:23:29 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:28 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 09/10] arm64: dts: renesas: r9a08g045: Add watchdog node Date: Wed, 18 Dec 2024 14:23:16 +0200 Message-ID: <20241218122317.2365272-10-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:35 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17462 From: Claudiu Beznea commit cee7bef61f51c04c9946cf4ddb81e85d9c1833d2 upstream. Add the DT node for the watchdog IP accessible by Cortex-A of RZ/G3S SoC (R9108G045). Signed-off-by: Claudiu Beznea Reviewed-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20240122111115.2861835-10-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi index aba6b0383778..f5f3f4f4c8d6 100644 --- a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi +++ b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi @@ -273,6 +273,20 @@ gic: interrupt-controller@12400000 { <0x0 0x12440000 0 0x60000>; interrupts = ; }; + + wdt0: watchdog@12800800 { + compatible = "renesas,r9a08g045-wdt", "renesas,rzg2l-wdt"; + reg = <0 0x12800800 0 0x400>; + clocks = <&cpg CPG_MOD R9A08G045_WDT0_PCLK>, + <&cpg CPG_MOD R9A08G045_WDT0_CLK>; + clock-names = "pclk", "oscclk"; + interrupts = , + ; + interrupt-names = "wdt", "perrout"; + resets = <&cpg R9A08G045_WDT0_PRESETN>; + power-domains = <&cpg>; + status = "disabled"; + }; }; timer { From patchwork Wed Dec 18 12:23:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13913591 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D233E7718C for ; Wed, 18 Dec 2024 12:23:35 +0000 (UTC) Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by mx.groups.io with SMTP id smtpd.web10.104198.1734524612500942209 for ; Wed, 18 Dec 2024 04:23:32 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@tuxon.dev header.s=google header.b=IGRmeUx5; spf=pass (domain: tuxon.dev, ip: 209.85.128.51, mailfrom: claudiu.beznea@tuxon.dev) Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4361b6f9faeso4555015e9.1 for ; Wed, 18 Dec 2024 04:23:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1734524611; x=1735129411; darn=lists.cip-project.org; 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=I8uQNymoji1ksmZrB7+5ifmXCiwpi+Yvt74CZN6UUYc=; b=IGRmeUx5xucaPwbflwXzdk0VxtUhzzXRiIx0LJaHJocw312S+vtPD+bUkXjKD2LpYV wlw6T0tY5z3RmwiWVoXJuTP6IcqJb8sRMqiIvEQkwf7EYtPjtkrX0zQeCFgpCZ3w0+A/ zJmQwKKx2MkotPMYMgt/nmawL93fCuk/C2qJON0GVZPU5wzTzQgbl/Xd3BLmZqQ6UPM7 mHHGrjlnJa5oo0GZt8NyvQv9y3mGrXhHSYZPGBraW25xUyEhy1qLT4JyMnoN58I0BR2h fEzgXyxpIhNamdviEIXOgKSjJX6Jv9oLSeSgN6YvvjWk8D+d5880ssIOjUHD4QqwaBSY 8u6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734524611; x=1735129411; 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=I8uQNymoji1ksmZrB7+5ifmXCiwpi+Yvt74CZN6UUYc=; b=LY3Vt53e5iaX/p93BpsBkTTFbpF2euyT9SscNHa8lv/GvmjJOSwCLMbIAmWSacqVdS kZE76B9oOn1lLSfGaQmxNwpUkDYq4A0EJRFYjL1skK3cuXqfLs4sql4R9Ov/5dtBDS3l Fuqky8EMg1pQx/GWeyY5SV6IF0fz0hVd4kmgyGbNSXZtjva8po5nDm5SlHiA1Bg8Jslp s37a1B5TvVo28CpDuOB1kj9U+ikuwLL9N5tiWDq4wgpk2BkmkxSSyXh0KkkpiIo6Fan3 qqUSTGmPZCM980K7pSzzNYDCFm2p6aEZTNNfPOlZI/vN3NTrewNV/+vLHAxULi4jzVfC WoIQ== X-Forwarded-Encrypted: i=1; AJvYcCVDH/ig+oczF0iI7oqihN9u+krAquQLrlknu5Pldqy2cMEEkWnq1neJKufUKWdsElhzTC/9Pcgz@lists.cip-project.org X-Gm-Message-State: AOJu0YxahISiEwQkbSOxFhgvT7Qktx9HVLIzX/Vh46aTm3VYqNDiCXZa 0gGmuOYLFkSFdywvyJxsTHc/zundIQQ/ul5ndQMlAPfAtguCWEvqjn4Ea0dnipg= X-Gm-Gg: ASbGncu3+tESIY3zO+hWlYQCE1QubaJomlKK7v6GN6Tl2Y5t1Dua9W3icRmUptylnYv Si4/Nd7gR2pZcm8gEMdmzi43EMIKJAFfUc5yTpXGuSONyS/tJTPYcNBveYXkXVfC7JDbPAqg9HE 9XCOJEB2yxkVd7zo3ymYNinW8pu6MXisDWgq2QdHaAE9m+lVN3KPwf0yCAnw6sWlZdVtgPOGccK lHonrqTPFf8IpnDp/y/e8IQxVHZWfCiZaCrYIPZn+BfAc5BVncJQk1YG4oflJeGUKiZc4H5MUcg J30Iu6P+J14= X-Google-Smtp-Source: AGHT+IEHwbtQydv2i94PfmNceJ0YmnY9Ar3AFscdsfUNGXyRdaSwYGapJXGVoaJqbXuDzpYcsMkiCQ== X-Received: by 2002:a05:600c:5854:b0:436:2155:be54 with SMTP id 5b1f17b1804b1-4364812a126mr64961195e9.1.1734524610892; Wed, 18 Dec 2024 04:23:30 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.102]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b01b15sm18746445e9.11.2024.12.18.04.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 04:23:30 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: claudiu.beznea@tuxon.dev, cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Subject: [cip dev][PATCH 5.10.y-cip 10/10] arm64: dts: renesas: rzg3s-smarc-som: Enable the watchdog interface Date: Wed, 18 Dec 2024 14:23:17 +0200 Message-ID: <20241218122317.2365272-11-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> References: <20241218122317.2365272-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 18 Dec 2024 12:23:35 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/17463 From: Claudiu Beznea commit 2c0f4dfad96a6809506265f53f251b83ab2c848a upstream. Enable the watchdog interface (accessible by Cortex-A of RZ/G3S SoC) on RZ/G3S SMARC SoM. Signed-off-by: Claudiu Beznea Reviewed-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20240122111115.2861835-11-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi index d33ab4c88787..acac4666ae59 100644 --- a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi +++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi @@ -340,3 +340,8 @@ mux { }; }; }; + +&wdt0 { + timeout-sec = <60>; + status = "okay"; +};