From patchwork Wed Dec 1 08:15:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrej Picej X-Patchwork-Id: 519611 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 ED23AC433F5 for ; Wed, 1 Dec 2021 08:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347902AbhLAISy (ORCPT ); Wed, 1 Dec 2021 03:18:54 -0500 Received: from cpanel.siel.si ([46.19.9.99]:54120 "EHLO cpanel.siel.si" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347890AbhLAISw (ORCPT ); Wed, 1 Dec 2021 03:18:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=norik.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ajvHKaf0+LgO7cQ6eDi53nI2uxKkWsWNL99lhHLwFXQ=; b=UEq6+zMDDxyoHd5XFekh30hfX5 tYp9ePkTomqGlxaWpQXqUj0a5wyo+09gb0SW0D3nVA8+4SeSEqG5e9LxHIJBdmJ8gmIALuN+Ia8pt 3T8B0K47atN8eBKUw61cqEb6QcldJTv5umdEBMskQmOT2qSc9os8xdxICBWXFyd8AijsYeHbECXtB 6Rt2Pn7WwZ6bljMyvnFJKs8HCGQctCUY29nuMmrmaTeGgg2eIwTgQg5AxcxGar/72JMl+p5KANLDY 2oikykbLP2eYX4OpbN/DfN+RqWD1NbgnGCfMsCgGCY9mgZYeEh8at28vIN826iv9rdsE48ZWW1tRJ Duulrjjw==; Received: from 89-212-21-243.static.t-2.net ([89.212.21.243]:60688 helo=localhost.localdomain) by cpanel.siel.si with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1msKls-007fXk-AT; Wed, 01 Dec 2021 09:15:27 +0100 From: Andrej Picej To: support.opensource@diasemi.com, linux@roeck-us.net, linux-watchdog@vger.kernel.org Cc: andrej.picej@norik.com, wim@linux-watchdog.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 1/4] mfd: da9062: make register CONFIG_I writable Date: Wed, 1 Dec 2021 09:15:09 +0100 Message-Id: <20211201081512.3580837-1-andrej.picej@norik.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel.siel.si X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - norik.com X-Get-Message-Sender-Via: cpanel.siel.si: authenticated_id: andrej.picej@norik.com X-Authenticated-Sender: cpanel.siel.si: andrej.picej@norik.com X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org From: Stefan Christ Make the config register CONFIG_I writable to change the watchdog mode. Signed-off-by: Stefan Christ Signed-off-by: Andrej Picej --- Changes in v3: - no chagnes Changes in v2: - no changes --- drivers/mfd/da9062-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index 01f8e10dfa55..7041ba53efb4 100644 --- a/drivers/mfd/da9062-core.c +++ b/drivers/mfd/da9062-core.c @@ -556,6 +556,7 @@ static const struct regmap_range da9062_aa_writeable_ranges[] = { regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), regmap_reg_range(DA9062AA_BBAT_CONT, DA9062AA_BBAT_CONT), + regmap_reg_range(DA9062AA_CONFIG_I, DA9062AA_CONFIG_I), regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19), }; From patchwork Wed Dec 1 08:15:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrej Picej X-Patchwork-Id: 520157 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 D2191C433EF for ; Wed, 1 Dec 2021 08:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347899AbhLAISy (ORCPT ); Wed, 1 Dec 2021 03:18:54 -0500 Received: from cpanel.siel.si ([46.19.9.99]:54138 "EHLO cpanel.siel.si" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347885AbhLAISw (ORCPT ); Wed, 1 Dec 2021 03:18:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=norik.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/hEXr+aosdPD8kgmCCVvUG/UOlYBJ3INN479Y9j0AYY=; b=aGeJg2YsUZZbl+PgBUElEhiEvb Np4tarywVdVBuMaEqhk5QZaLgfk+/EbQEkvAiXAkgzDpRh55OqIfwGjTopMNnFVUOejBEnkptsEmH bld95ldni3wLu/g1ohnRMIlpVUWx3tMEN+K5ENHo0m7rK01F/rW0pguc6S4ZOPA/xDu/mVNFQvYy3 oHfj7dq+9wPeZNfH0nE3kE0ubdKGESzmI5HzF3dZ/z9uwNLXP7BiSLEPhGbO3bhmDCzHK1/QtV8iY Hx/LO17aDy/00yfiCPAgh7Dru6+Ie26Szcw+MoVtJSrx4Y6VF/dd4wboKRLb6FltTtFErYFU766eG NVbJZgbw==; Received: from 89-212-21-243.static.t-2.net ([89.212.21.243]:60688 helo=localhost.localdomain) by cpanel.siel.si with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1msKls-007fXk-Gb; Wed, 01 Dec 2021 09:15:27 +0100 From: Andrej Picej To: support.opensource@diasemi.com, linux@roeck-us.net, linux-watchdog@vger.kernel.org Cc: andrej.picej@norik.com, wim@linux-watchdog.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/4] watchdog: da9062: reset board on watchdog timeout Date: Wed, 1 Dec 2021 09:15:10 +0100 Message-Id: <20211201081512.3580837-2-andrej.picej@norik.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211201081512.3580837-1-andrej.picej@norik.com> References: <20211201081512.3580837-1-andrej.picej@norik.com> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel.siel.si X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - norik.com X-Get-Message-Sender-Via: cpanel.siel.si: authenticated_id: andrej.picej@norik.com X-Authenticated-Sender: cpanel.siel.si: andrej.picej@norik.com X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Implement a method to change watchdog timeout configuration based on DT binding ("dlg,wdt-sd"). There is a possibility to change the bahaviour of watchdog reset. Setting WATCHDOG_SD bit enables SHUTDOWN mode, and clearing it enables POWERDOWN mode on watchdog timeout. If no DT binding is specified the WATCHDOG_SD bit stays in default configuration, not breaking behaviour of devices which might depend on default fuse configuration. Note: This patch requires that the config register CONFIG_I is configured as writable in the da9062 multi function device. Signed-off-by: Andrej Picej --- Changes in v3: - no changes Changes in v2: - don't force the "reset" for all da9062-watchdog users, instead add DT binding where the behavior can be selected --- drivers/watchdog/da9062_wdt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c index f02cbd530538..e342e9e50cb1 100644 --- a/drivers/watchdog/da9062_wdt.c +++ b/drivers/watchdog/da9062_wdt.c @@ -85,8 +85,33 @@ static int da9062_wdt_start(struct watchdog_device *wdd) { struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd); unsigned int selector; + unsigned int mask; + u32 val; int ret; + /* Configure what happens on watchdog timeout. Can be specified with + * "dlg,wdt-sd" dt-binding (0 -> POWERDOWN, 1 -> SHUTDOWN). + * If "dlg,wdt-sd" dt-binding is NOT set use the default. + */ + ret = device_property_read_u32(wdd->parent, "dlg,wdt-sd", &val); + if (!ret) { + if (val) + /* Use da9062's SHUTDOWN mode */ + mask = DA9062AA_WATCHDOG_SD_MASK; + else + /* Use da9062's POWERDOWN mode. */ + mask = 0x0; + + ret = regmap_update_bits(wdt->hw->regmap, + DA9062AA_CONFIG_I, + DA9062AA_WATCHDOG_SD_MASK, + mask); + + if (ret) + dev_err(wdt->hw->dev, "failed to set wdt reset mode: %d\n", + ret); + } + selector = da9062_wdt_timeout_to_sel(wdt->wdtdev.timeout); ret = da9062_wdt_update_timeout_register(wdt, selector); if (ret) From patchwork Wed Dec 1 08:15:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrej Picej X-Patchwork-Id: 519610 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 70941C43219 for ; Wed, 1 Dec 2021 08:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347924AbhLAIS6 (ORCPT ); Wed, 1 Dec 2021 03:18:58 -0500 Received: from cpanel.siel.si ([46.19.9.99]:54154 "EHLO cpanel.siel.si" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347888AbhLAISw (ORCPT ); Wed, 1 Dec 2021 03:18:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=norik.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=X4I7/VDo+Nmcno5XwpZJavmoFcXppCkFreimPxBmm34=; b=NpWuw5wCd1PPxWMq/nXSMCyb3u mhSupZRRTlDmrxYlKu1T4qtB+qnANPPfd9tAJQLAp7sUxT5T1OF/MzHqi75BuC381K0VqsHmaZpZR QVMXqGtx3hI8323WoApRCd88zSHAZdNpgmkdjdlbVUl3zM6ukNmmq7WINnexgVteNs6xRwZNZfciQ v8EGMsJWUntvnGtUVU87NOCdugAuqHYq3Qom0M50kUhhYZfDyu9xAUo8TkmSimI4Jw8BDOSU0HhPk 17DGFxW3cXSPVmRH+qjku2ur1bZvBXKTRa7/c5IVeE0rn2L1+kiKbluTk906jKFOngKbkfbDQklWJ LJu4WRTg==; Received: from 89-212-21-243.static.t-2.net ([89.212.21.243]:60688 helo=localhost.localdomain) by cpanel.siel.si with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1msKls-007fXk-Mf; Wed, 01 Dec 2021 09:15:28 +0100 From: Andrej Picej To: support.opensource@diasemi.com, linux@roeck-us.net, linux-watchdog@vger.kernel.org Cc: andrej.picej@norik.com, wim@linux-watchdog.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 3/4] dt-bindings: watchdog: da9062: add watchdog timeout mode Date: Wed, 1 Dec 2021 09:15:11 +0100 Message-Id: <20211201081512.3580837-3-andrej.picej@norik.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211201081512.3580837-1-andrej.picej@norik.com> References: <20211201081512.3580837-1-andrej.picej@norik.com> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel.siel.si X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - norik.com X-Get-Message-Sender-Via: cpanel.siel.si: authenticated_id: andrej.picej@norik.com X-Authenticated-Sender: cpanel.siel.si: andrej.picej@norik.com X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Document the watchdog timeout mode property. If this property is used the user can select what happens on watchdog timeout. Set this property to 1 to enable SHUTDOWN (the device resets), set it to 0 and the device will go to POWERDOWN on watchdog timeout. If this property is not set, don't touch the WATCHDOG_SD bit and leave the configuration to OTP. This way backward compatibility is not broken. Signed-off-by: Andrej Picej --- Changes in v3: - add note about using the default OTP setting if this DT binding is not specified Changes in v2: - new patch, document new DT binding --- Documentation/devicetree/bindings/watchdog/da9062-wdt.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/watchdog/da9062-wdt.txt b/Documentation/devicetree/bindings/watchdog/da9062-wdt.txt index 950e4fba8dbc..354314d854ef 100644 --- a/Documentation/devicetree/bindings/watchdog/da9062-wdt.txt +++ b/Documentation/devicetree/bindings/watchdog/da9062-wdt.txt @@ -10,6 +10,12 @@ Optional properties: - dlg,use-sw-pm: Add this property to disable the watchdog during suspend. Only use this option if you can't use the watchdog automatic suspend function during a suspend (see register CONTROL_B). +- dlg,wdt-sd: Set what happens on watchdog timeout. If this bit is set the + watchdog timeout triggers SHUTDOWN, if cleared the watchdog triggers + POWERDOWN. Can be 0 or 1. Only use this option if you want to change the + default chip's OTP setting for WATCHDOG_SD bit. If this property is NOT + set the WATCHDOG_SD bit and on timeout watchdog behavior will match the + chip's OTP settings. Example: DA9062 From patchwork Wed Dec 1 08:15:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrej Picej X-Patchwork-Id: 520156 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 C349EC4332F for ; Wed, 1 Dec 2021 08:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347917AbhLAIS4 (ORCPT ); Wed, 1 Dec 2021 03:18:56 -0500 Received: from cpanel.siel.si ([46.19.9.99]:54172 "EHLO cpanel.siel.si" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347892AbhLAISw (ORCPT ); Wed, 1 Dec 2021 03:18:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=norik.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=xdrTiqESD9Grk59I9BTw6TCEauQQQ1XgoZZ8AlUk9+4=; b=AEj7bM395MwdEr3quD5g0zsT5Z NPqde2E8s1Iadoi3ymZpic4N4em6q2fVbsMkY2fyXgbrp96glFUA/57YTUZjPn3k8QpNeowRgsk9y HCXCFgR9b5uMnGvgUie8rNArmIrkJqIprvqJn7GUOMLfxn4wBym9HNJJ8CuYQaDpJirJByUaewbdS YuTDst6sBU9qy+j+grPpPVb4vIfsenf10dJxBpHshVgFtGJ5/+oraGlDvYefqCUTC3zZ++KO3Io+D f1jQEj08f2w8XPkTRG0yfjLRMRgGYgTKs49BPq/Oi6Ly1szaOSmsAszX/S4b06osNnzQpBOQye64q FUnHa1+A==; Received: from 89-212-21-243.static.t-2.net ([89.212.21.243]:60688 helo=localhost.localdomain) by cpanel.siel.si with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1msKls-007fXk-Rz; Wed, 01 Dec 2021 09:15:28 +0100 From: Andrej Picej To: support.opensource@diasemi.com, linux@roeck-us.net, linux-watchdog@vger.kernel.org Cc: andrej.picej@norik.com, wim@linux-watchdog.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 4/4] ARM: dts: imx6: phycore-som: set watchdog timeout mode to shutdown Date: Wed, 1 Dec 2021 09:15:12 +0100 Message-Id: <20211201081512.3580837-4-andrej.picej@norik.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211201081512.3580837-1-andrej.picej@norik.com> References: <20211201081512.3580837-1-andrej.picej@norik.com> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel.siel.si X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - norik.com X-Get-Message-Sender-Via: cpanel.siel.si: authenticated_id: andrej.picej@norik.com X-Authenticated-Sender: cpanel.siel.si: andrej.picej@norik.com X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Enable system restart when the watchdog timeout occurs. Signed-off-by: Andrej Picej --- Changes in v3: - no changes Changes in v2: - new patch, enable shutdown mode for phytec-phycore (da9062 user) --- arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi index a80aa08a37cb..743343e525cf 100644 --- a/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi +++ b/arch/arm/boot/dts/imx6qdl-phytec-phycore-som.dtsi @@ -111,6 +111,7 @@ da9062_onkey: onkey { watchdog { compatible = "dlg,da9062-watchdog"; dlg,use-sw-pm; + dlg,wdt-sd = <1>; }; regulators {