Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp259780rdb; Mon, 22 Jan 2024 03:25:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRN5+GwPA1ImswWecpVJ6PPMhlJGj0LmLMg4xaIvcPe/YSv33CZ4I4e6rR/vhJyDVjPPL1 X-Received: by 2002:a50:ed0c:0:b0:558:2872:e3de with SMTP id j12-20020a50ed0c000000b005582872e3demr2097979eds.83.1705922722216; Mon, 22 Jan 2024 03:25:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705922722; cv=pass; d=google.com; s=arc-20160816; b=NWWps3CZk++HOK6DQiu4xs/fQeazfwbeu2OwTLFFEEXSUvw4p4EH9mjfV6smneRWFw 5owCa/k7fQg+VtMpFP4bEZptSm//2sYQTv5kCV9VAIu6UF6OyaHS4miZucKZ4882XrQ3 SQBw+y+SDoqHq+S3JwxNifTE2Kg/Gu0CXeCQkX3lkY1j48uDpGgJRXM3jHK43p1w8d+k B89Arw+nNJpd+Jy1NSI2D/ICPLZH+HtajtZ609b2I5bfqtUkuvK2i/zmMByQAxSOjJoN IBQQZxO1zHUcrjb8Y0Lh5K+3fR4J7C6zbmZ5EDNmSH24MO9ju+jhV92hRCtum5ajKrwh 79/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wEA5wOjREvccnNUzxu9B12Stn4mw/QPURiJXd8LQ/aM=; fh=udVwO0NRYY7+WHGry+7JLVq01vR2BwLxtvAczjMVMl8=; b=kP6H9IbjeQ+mFj63eYzWb79DfVVne/Bf0ZK0PKgTb2CzEddDsPeVDf61y2WK6DrgCG ufBzc8QpDItYWkHqNa8q0crt+lsNmCyRy00X7PDNJeahC4EYYXpyMM2urn3DQ7qZRvY4 xllSEtgwtVE9NY8yE24mMIin3kPNzU3qsIfSxcD2n/KtScHQWnuM+ZP5wB0PrCfY1xct T9bV8PHC/e42kdbEQ0mQZStE5cZikiSSvAkVbd3kYqjCsz9mAIEf6UZ95GFqAU1X4k1h 9BBs3zEmy2eBDj68w4W0or1Xd4j0keFdRVFO0uXDIwgz9kU76uxcAFNW5qFXv8ycWvFQ o+iQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=HFjfxles; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-32880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32880-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ef6-20020a05640228c600b00559da7d67a6si5616180edb.304.2024.01.22.03.25.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 03:25:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=HFjfxles; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-32880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32880-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F35DD1F2358E for ; Mon, 22 Jan 2024 11:25:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8874A4B5C1; Mon, 22 Jan 2024 11:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="HFjfxles" Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E4DE4A9AC for ; Mon, 22 Jan 2024 11:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705921913; cv=none; b=Y2vDtJfSdwUv3A0EeFj32FpAbc90BgdQnENL/ioUnezqkkKYsAVc28H4+26Zm+yfKhyj8SPmMPbgVtCzZsTwXjJmNGUi5t2SIDxyKis+0ECYe8C5hZjoaSb5KtRT9l9cpZ1OT1IGKobFsl/iQ7bYyLHzSJePDc06P2I2Pqrqw7Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705921913; c=relaxed/simple; bh=QSHrqKvBFITUcBnX8YOoV4xwGvo/LUKyPfUJqWIie9Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DFd6fF2mLvQ+befZdJt894RUHHyzN5JGuE2uz47NzSNl9zgll/jgKY7cBJ3VkHVf8a1iNsDb13+6gNp9f7ThqjCbkkmveCIltZ3t3WF4nj3oC6ZQh7/VUPPAeTGg3Z2srIVhpflUDx1eC8NgbyFjqrph0b9mXiSNX8CxaqKuP18= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=HFjfxles; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-55a45a453eeso3644519a12.0 for ; Mon, 22 Jan 2024 03:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1705921910; x=1706526710; darn=vger.kernel.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=wEA5wOjREvccnNUzxu9B12Stn4mw/QPURiJXd8LQ/aM=; b=HFjfxlesQLWw2eazjzzCx0ZUeYlZkaX9e6bPqKbFPVp09D8LiB6fiInRs94zGNY4gN 265+waRwh8HjkazjHLBGdhrcLWu18bk3oVdf+mgov4heHbFbvsTYhUfRfeghGLkkn9Ia r2iFcILXmuZ0QD9odPGBsXFdH3tRIp+9tNikCI6QH1Ascm+DvgfmJhZ3gpVnMwhrK7FV iHlOdftnB+UWuaED82lAco3jnqujLk09a5Xgh2CC8GcmBeEnClEzk9ehSqVtSZaLL7/U VrPMHSib/NbLA6q73tbghDAhk8XAej8GwA47/ab4/vTUnKgtFtjODKu0FTkxAaizMHnU WriQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705921910; x=1706526710; 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=wEA5wOjREvccnNUzxu9B12Stn4mw/QPURiJXd8LQ/aM=; b=nfOrqsetLdg4gYRBFdQKUgZKUbTXZ8ALUIr12AzjQc10KOlJAqOv7IeRRnoxOO66QK ozTHsgIuchG1+mJFuKlMx3CPqn2sDwAa2IsFXowRAeoHw1Tfy0SI5sLH9uyBYY6ffsfI LZzigyAZ1AR5AjVV4afZFPuXuJIwiCRXMyxuYRzUv6gEjCSCXO7Aqk3w9zjp9dB45/ci exXsUDCYv0heYK1w3R8F0r7dNm+CK+iGTHcbsgUYq6qaKe8k2S791Pk0dVE5C6ZC7X/+ 8X59GD35RYj7IPpt9OBRaBkqRTTR10tkmWC2m4klHkJcZKr28UEVrZUKMVwGTUQGLg6B NcuA== X-Gm-Message-State: AOJu0YzbTr89xjQXvTXk+SpWNlJ/HFX0E9/E99nLxsqx2x9OXVTbOhyL m7i9k4gxrnfgJB52d/5h9EDUrCiUHQQWeycgfy4FYu4Ao5eqoR1Uem0P6TpjPDI= X-Received: by 2002:a50:d5c9:0:b0:55a:5fad:6c7c with SMTP id g9-20020a50d5c9000000b0055a5fad6c7cmr2300051edj.50.1705921910408; Mon, 22 Jan 2024 03:11:50 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.135]) by smtp.gmail.com with ESMTPSA id t34-20020a056402242200b0055823c2ae17sm14194241eda.64.2024.01.22.03.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 03:11:49 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: wim@linux-watchdog.org, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de, biju.das.jz@bp.renesas.com Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support Date: Mon, 22 Jan 2024 13:11:12 +0200 Message-Id: <20240122111115.2861835-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240122111115.2861835-1-claudiu.beznea.uj@bp.renesas.com> References: <20240122111115.2861835-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Claudiu Beznea 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 --- 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 9333dc1a75ab..186796b739f7 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -279,6 +279,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; @@ -300,10 +301,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 = { + 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 = pm_ptr(&rzg2l_wdt_pm_ops), }, .probe = rzg2l_wdt_probe, }; -- 2.39.2