Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp479935rdb; Thu, 15 Feb 2024 06:14:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVO+UKLNOh0RP4PuxjBoTvQSWdRKvHUjdx2ZAN9I8rE301GRBOrmlkjhxNIAQMUoHf98zN9hP+3vUVRilFyI3j1TqWUBmcsxkDXv/lbEA== X-Google-Smtp-Source: AGHT+IG/JPt/j9zAj/suaaFJfwhTVk1cp4a7ToM/rqBVCwxN3malDa7ZFZMdhq7hvBdSZOaCRPAL X-Received: by 2002:a92:c051:0:b0:363:d8f7:bb1c with SMTP id o17-20020a92c051000000b00363d8f7bb1cmr1691757ilf.26.1708006445464; Thu, 15 Feb 2024 06:14:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708006445; cv=pass; d=google.com; s=arc-20160816; b=gh7z07uPI4nl3v2x6mIUsO0DV8L0xu819JrB3Ow5nh2EU17JvNO2abrjcmT3n0LV4P E/RK1chDHcyOF2aM+pJK+a4N2MBhpVRKBZdZF5z2w4uzmz9lCmYk4uEbg5u+86b+fEJ5 b2G07t/xhJKPTtFSQ7h8Ud2IOdh1pDRDAQn4NztRONYwf1N0woGiCkbV1kc04NNa/umH UqHdOZO1WqNniFcOPD4QcrAVIphRrh4V9yFM3lbI6xVWnMiOTfhG9W72854eitwTyL3A lvABIqOpgpxjUUYmCdCp8y/rHCt5t3oDUFGcC4gctM/QnVbrnuwBvFBRJw0JJB8LDgxu DAFg== 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=7GMx3oEvdufHoBvmFi6dbwMx9fUDNCWnepPcsld4qxw=; fh=PM0uR07VynnhNRwr2fbIkX22vrP6ZsmIkqSLCrnDPdA=; b=UYKx5zMkE7DkWtJVV+b+zm6SoFecknWd1myJPadWVV390NtRXQYBcYWrz/ZPHx28Ki xM1FqW96+AQqLFYTpot4cCATOsQ7cx4owyw/83R4oSJKhAAnNH88xjzJYgKOByZ6F751 59pExqicy+jQ6m8xYL1LASVK/ea9l+qv3yuX7MGMyXl4AEzAVpTWt88xlZy0X3sNbqCD y+2Q7sOqgtU+ZNRdU59e6eQ/TvIQiuaQ6QvLyj8Ar3SE7vyQENTHZNplCJqOrI4EJq96 ZixG7ANXl/AYMrdfJH0+ySUKclxZr4/G/ung1qYdgTw3Kice8yM/h8yvlrT1AWiMD05J W96g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=DjiT0rk+; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-67057-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67057-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a30-20020a630b5e000000b005d47866f376si1156914pgl.854.2024.02.15.06.14.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:14:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67057-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=DjiT0rk+; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-67057-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67057-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6E981293EE6 for ; Thu, 15 Feb 2024 14:11:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2C2813341D; Thu, 15 Feb 2024 14:09:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="DjiT0rk+" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 6613F133400 for ; Thu, 15 Feb 2024 14:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708006153; cv=none; b=GVZgpCicxRdG4vc3xi3j443i4m7PxHm/Vc6RRwUwg6pWPy26uNL4gTDXHLfgxk4VWWX5MRdaXwqTxfj1VeIsmu7s7uxftH5WFeaxaMB9g2I5GAULDStCAR8vfy6s4s+qRVkFRCPTd4Ysw74Gf5QOckYYy8ttnIXhVc+/lzOlNXY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708006153; c=relaxed/simple; bh=b/dlKiES8flQO1V7kDRxQagNiDwOIUuMR02By8uyldM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fJZtbmxlYVXkeS0mqrArje2IeCE87nr/k8aCWZ1FaNX6aBvhHr1kKZ8IU1yk3NWYTlffbkCUU+xjSbutoUa7LTLzKBL4vMtd6Q/CAymWuc3c+4/N66owg2he6mZX2ofLpy5Wqzd+aI4rUg5j/jomdvhnMbNEX+gURi73CxRhWug= 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=DjiT0rk+; arc=none smtp.client-ip=209.85.128.46 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-wm1-f46.google.com with SMTP id 5b1f17b1804b1-411e71d8a2bso6524415e9.1 for ; Thu, 15 Feb 2024 06:09:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1708006150; x=1708610950; 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=7GMx3oEvdufHoBvmFi6dbwMx9fUDNCWnepPcsld4qxw=; b=DjiT0rk+zQmfaS142q7BKYsfwol45IPjbXcAwO/9/h5ASkZThSojCLTBTCFbV7QJcF 572uMJo2HqGShQwoEmllDH15qnwjTt7ODxReJaQK5D1g5p5yebo4wtEVnBEqRuvE0cyi OTqXlgg8lG0Ym0f883AsTBpfHMBq2pamVV941eD2kRc+rnt25BKRoJb9y9SDmgRHFedc 8VyLZUcZyELJbufeI5V3obUDdKZVTWg9pXmxJ78b1wcr/NaZ/UjUwlKBVRSk+rmcmvcM ty20vMKA2F6xQQzlJigW2Lly+mqdHWvthkBNDQEiS6MTD7ES3sXzICRLZbmYc8wSGzHP Rlow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708006150; x=1708610950; 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=7GMx3oEvdufHoBvmFi6dbwMx9fUDNCWnepPcsld4qxw=; b=Qu3dqisk8TUkplq6rY14kbzrPfpcys8F4FSpuZH8SCkhKOOIo1uVi6BDRxdgcj/qzw absCxUDMw0QuaxweZ8NDggAbfqd+x0apVhYOgluGfmrhdVSkIXnUpBlFT3Ilh61rJ+ER CxoGpC9/6/ICJ3hqYLHS30+Ofp6gK79Ka16TqQdUQIpM7uW6BrlqRKFlTbc0tT0HhCHK qrYXGOxHQTKe0pbzJ1CYVN5BuzliU8TbVsPsUsAxBQWmThEfYcj7AU2+P9ULual0mxG3 JtzgV3VKUuyG74scmJeRq43ouAGDy+yDduyFWgNSbVOsTFCWh62TjoKc+j88vq2nL8CU Id+w== X-Forwarded-Encrypted: i=1; AJvYcCUiDErndvDw5JST4QoSPgrztPPIo5rOeEZ/OPfOW9johlrsNrVLxoGBLkt7rjBmF4EmFSe0r2jvAwgD375pOzCghPDv5sKPNuJgZJn6 X-Gm-Message-State: AOJu0YziXEA4bluJl7Rz0TmkVZccJa0b8fntWIu4K4KsuT3rXv0bf4bI ubXdXOtsOLBwU1/aXLS5abz8o15yVem2+vmMKWYAfZvdAdhNmq2H7xrADyrrM8s= X-Received: by 2002:a05:600c:5342:b0:410:8db2:d5ec with SMTP id hi2-20020a05600c534200b004108db2d5ecmr1478045wmb.38.1708006149702; Thu, 15 Feb 2024 06:09:09 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id h17-20020a05600c261100b0040fe4b733f4sm5120950wma.26.2024.02.15.06.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:09:09 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: wim@linux-watchdog.org, linux@roeck-us.net, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, p.zabel@pengutronix.de, geert+renesas@glider.be, magnus.damm@gmail.com, 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, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v7 8/9] watchdog: rzg2l_wdt: Add suspend/resume support Date: Thu, 15 Feb 2024 16:08:40 +0200 Message-Id: <20240215140841.2278657-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215140841.2278657-1-claudiu.beznea.uj@bp.renesas.com> References: <20240215140841.2278657-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 --- Changes in v7: - none Changes in v6: - none Changes in v5: - none Changes in v4: - none Changes in v3: - none Changes in v2: - remove the usage of pm_ptr() 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 42f1d5d6f07e..c8c20cfb97a3 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -284,6 +284,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; @@ -305,10 +306,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 = &rzg2l_wdt_pm_ops, }, .probe = rzg2l_wdt_probe, }; -- 2.39.2