From mboxrd@z Thu Jan 1 00:00:00 1970 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 CCFD5C4332F for ; Thu, 2 Dec 2021 14:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358674AbhLBOol (ORCPT ); Thu, 2 Dec 2021 09:44:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231202AbhLBOoi (ORCPT ); Thu, 2 Dec 2021 09:44:38 -0500 Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E04B0C06174A; Thu, 2 Dec 2021 06:41:15 -0800 (PST) Received: by mail-ot1-x330.google.com with SMTP id w6-20020a9d77c6000000b0055e804fa524so40182133otl.3; Thu, 02 Dec 2021 06:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Y4at8L60EXfC3cEZPxJ2dBLND1wT12N83NGhaALKKS0=; b=nLKe1VXlRjDQoG4ohd4OQO8q80qM2cmlZyZa2LSp2un5q4FcuxASvQZxUfp+cp16/9 ea938qTVJPehLvuG7alpoZvd8P1KGq1cgWs0xzqFEpGnBsqOsduCKPdXpBnI8ovKqZZb sWO4fELGA9d5E11bCpUpQEDGE84RStt6gCpELEVhlkwYq66914QqyWLGqkpu57CZak96 YmpTYIwvuCu7IX/njU1NEdmeXlug/lhFnHpUizVCjQ9nYYKYh7qIeo5JY2BL7rYYM5he 3UIN0+gZ37g0ts4G/FdT0XYJ9UoSY3qs5nLCERtzmnJTHxTe8AQbUAsPPViWFsOMU4fK 7xVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=Y4at8L60EXfC3cEZPxJ2dBLND1wT12N83NGhaALKKS0=; b=jEN7xwRF4oY+rLfBcNtpevWQvoGOP4DtLXI1fgR4f7VegfcyhjAp8Npd4lDn8DXuku DsPX53y90F2325x0WlQDlqAcpGaA0ypuGgnbqOIzTEGzdclbNY1zW49aDBhpcedk9XU6 hl5spW6QSKopKgUJMT0N0bST7JuV8NNwYyJhwWLOSFoQl+6AlWA035lZQDrXLNnx6+aW hOxNTqGjLqLCsVC0VJC9DDA7MKgi+IxGiYr4B3cCZjSVRfdVWLiX2IJUmSgEKx32CbV3 3HYfWA7OkD9W6gWjq4lYH4C3Nl+ufA3aEsY+53Mwclljt/RzJLXXaAjciJ5A27XinqCm OKfA== X-Gm-Message-State: AOAM532aDAu/MrvqnB+fGbWccC3b5VJJaTMopPVdxOTtMJByHq06KiVV mPBdG7uboOEt8Ffw3h+NEZQ= X-Google-Smtp-Source: ABdhPJz5xD8isNpVTkMna0LFOmiVRyMKZUrUK9Ae68fME5gRpQzvlI1Yv57sLiKQHGIwBIssBT1i5w== X-Received: by 2002:a05:6830:3094:: with SMTP id f20mr11773489ots.201.1638456075329; Thu, 02 Dec 2021 06:41:15 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x12sm1192120oom.44.2021.12.02.06.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 06:41:14 -0800 (PST) Sender: Guenter Roeck Date: Thu, 2 Dec 2021 06:41:13 -0800 From: Guenter Roeck To: Andrej Picej Cc: support.opensource@diasemi.com, linux-watchdog@vger.kernel.org, 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: Re: [PATCH v4 2/4] watchdog: da9062: reset board on watchdog timeout Message-ID: <20211202144113.GB828760@roeck-us.net> References: <20211202093230.3951996-1-andrej.picej@norik.com> <20211202093230.3951996-2-andrej.picej@norik.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211202093230.3951996-2-andrej.picej@norik.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 02, 2021 at 10:32:28AM +0100, Andrej Picej wrote: > 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 Reviewed-by: Guenter Roeck > --- > Chnages in v4: > - move the code to probe function > > 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 | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c > index f02cbd530538..bd85f84b0fd4 100644 > --- a/drivers/watchdog/da9062_wdt.c > +++ b/drivers/watchdog/da9062_wdt.c > @@ -195,8 +195,11 @@ static int da9062_wdt_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > unsigned int timeout; > + unsigned int mask; > struct da9062 *chip; > struct da9062_watchdog *wdt; > + int ret; > + u32 val; > > chip = dev_get_drvdata(dev->parent); > if (!chip) > @@ -236,6 +239,30 @@ static int da9062_wdt_probe(struct platform_device *pdev) > set_bit(WDOG_HW_RUNNING, &wdt->wdtdev.status); > } > > + /* > + * 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(dev, "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(dev, "failed to set wdt reset mode: %d\n", > + ret); > + } > + > return devm_watchdog_register_device(dev, &wdt->wdtdev); > } > > -- > 2.25.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A47F7C433F5 for ; Thu, 2 Dec 2021 14:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eckpfU9wUadXS8olxJYsSItgY0A/p9P1hD/shC2OR0Q=; b=vEQVFwdajLLju2 q213jTsYgbx2yTMq0tnIBiLa6CcJpwru5IxFkN/AGQIOdngtjWRuUV0TeIPpbV18nPudEwW0X+aLp Hxv/QLzTc17GKp9CKD1whOCHtjxQxZjKm0uD78prgNvi2u1JJAQQ37dKai6ZsSAs1QHqyV6qgERK+ hLaZMxLMb9tsiCsNWEIRynkd5q+g6XPvDp3BTIU1P2swoxCx4EDIYrk4px6mZVWgmM9NE4zH1sTfh 93tfOKjisvdZJYCcFjfIlAXKKA4Cqwf4mPxY2qyWPx+whVPqY/Cw0/f+rsS3hZS8d8kX1puwCaJZs 7k7+0tZ5jJVSbFPAAtHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1msnH0-00CbUs-3R; Thu, 02 Dec 2021 14:41:22 +0000 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1msnGu-00CbTR-Kp for linux-arm-kernel@lists.infradead.org; Thu, 02 Dec 2021 14:41:18 +0000 Received: by mail-ot1-x329.google.com with SMTP id h19-20020a9d3e53000000b0056547b797b2so40209719otg.4 for ; Thu, 02 Dec 2021 06:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Y4at8L60EXfC3cEZPxJ2dBLND1wT12N83NGhaALKKS0=; b=nLKe1VXlRjDQoG4ohd4OQO8q80qM2cmlZyZa2LSp2un5q4FcuxASvQZxUfp+cp16/9 ea938qTVJPehLvuG7alpoZvd8P1KGq1cgWs0xzqFEpGnBsqOsduCKPdXpBnI8ovKqZZb sWO4fELGA9d5E11bCpUpQEDGE84RStt6gCpELEVhlkwYq66914QqyWLGqkpu57CZak96 YmpTYIwvuCu7IX/njU1NEdmeXlug/lhFnHpUizVCjQ9nYYKYh7qIeo5JY2BL7rYYM5he 3UIN0+gZ37g0ts4G/FdT0XYJ9UoSY3qs5nLCERtzmnJTHxTe8AQbUAsPPViWFsOMU4fK 7xVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=Y4at8L60EXfC3cEZPxJ2dBLND1wT12N83NGhaALKKS0=; b=dVYq3kSrjNOjMUcPSuxltOz65CS6O5gYn4oW2DxBNokKtsK6tfa1HrljEtY7V3lPbr uCS2X+WcxalVQhKLAkn8PQwXxRxoGCLycRt7IkOMrF6SpKwOWBBaAhghjNheFXKTdOIH lpqQBD+Hpi4/y4GsYoisHU4EzmdLlH6eIWu1hXOflNuyLSX3sZegoNptSawH1gHqEoBx 8We/Cq+XkD6cSpB/X+KzVpFYDxkSDV1qI2X/6+j4YQete9t8/VGH4puEwSBIUkn4+z6i 0Dt5glnhXLhLgpU4oSt+RogUTaa4vu3jFsSHD+SLKeqA6h/op/0tlvD/R8hpjqn9Q9Z2 v6zA== X-Gm-Message-State: AOAM530JHeGfjCY+o7kV3eEoEh7bYXvJPKucHz+3pfjT7RwgyT9ZZAMP mKQj3ejHk32yW8BiRrj1uLk= X-Google-Smtp-Source: ABdhPJz5xD8isNpVTkMna0LFOmiVRyMKZUrUK9Ae68fME5gRpQzvlI1Yv57sLiKQHGIwBIssBT1i5w== X-Received: by 2002:a05:6830:3094:: with SMTP id f20mr11773489ots.201.1638456075329; Thu, 02 Dec 2021 06:41:15 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x12sm1192120oom.44.2021.12.02.06.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 06:41:14 -0800 (PST) Date: Thu, 2 Dec 2021 06:41:13 -0800 From: Guenter Roeck To: Andrej Picej Cc: support.opensource@diasemi.com, linux-watchdog@vger.kernel.org, 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: Re: [PATCH v4 2/4] watchdog: da9062: reset board on watchdog timeout Message-ID: <20211202144113.GB828760@roeck-us.net> References: <20211202093230.3951996-1-andrej.picej@norik.com> <20211202093230.3951996-2-andrej.picej@norik.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211202093230.3951996-2-andrej.picej@norik.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211202_064116_736267_4B2C06C0 X-CRM114-Status: GOOD ( 28.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Dec 02, 2021 at 10:32:28AM +0100, Andrej Picej wrote: > 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 Reviewed-by: Guenter Roeck > --- > Chnages in v4: > - move the code to probe function > > 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 | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c > index f02cbd530538..bd85f84b0fd4 100644 > --- a/drivers/watchdog/da9062_wdt.c > +++ b/drivers/watchdog/da9062_wdt.c > @@ -195,8 +195,11 @@ static int da9062_wdt_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > unsigned int timeout; > + unsigned int mask; > struct da9062 *chip; > struct da9062_watchdog *wdt; > + int ret; > + u32 val; > > chip = dev_get_drvdata(dev->parent); > if (!chip) > @@ -236,6 +239,30 @@ static int da9062_wdt_probe(struct platform_device *pdev) > set_bit(WDOG_HW_RUNNING, &wdt->wdtdev.status); > } > > + /* > + * 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(dev, "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(dev, "failed to set wdt reset mode: %d\n", > + ret); > + } > + > return devm_watchdog_register_device(dev, &wdt->wdtdev); > } > > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel