From: Guenter Roeck <linux@roeck-us.net>
To: Laxman Dewangan <ldewangan@nvidia.com>, wim@iguana.be
Cc: linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH V2] watchdog: max77620: Add support for watchdog timer
Date: Wed, 8 Jun 2016 06:41:27 -0700 [thread overview]
Message-ID: <57582087.1050900@roeck-us.net> (raw)
In-Reply-To: <1465381068-13071-1-git-send-email-ldewangan@nvidia.com>
Hi,
On 06/08/2016 03:17 AM, Laxman Dewangan wrote:
> Maxim PMIC MAX77620 is Power management IC which have multiple
> sub blocks like regulators (DCDC/LDOs), GPIO, RTC, Clock, Watchdog
> timer etc.
>
> Add the driver for watchdog timer under watchdog framework.
> The driver implements the watchdog callbacks to start, stop,
> ping and set timeout for watchodg framework.
>
Almost good. One more comment below.
> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
>
> ---
> Changes from V1:
> - Remove the error prints from start/stop/ping to simplify the function.
> - Instead of stopping running WDT, inform HW RUNNING and update the required
> param accordingly.
> - Resequence the param sets for wdt device to avoid race condition, move all
> wdt device setting before registration.
>
[ ... ]
> +static int max77620_wdt_probe(struct platform_device *pdev)
> +{
> + struct max77620_wdt *wdt;
> + struct watchdog_device *wdt_dev;
> + unsigned int regval;
> + int ret;
> +
> + wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL);
> + if (!wdt)
> + return -ENOMEM;
> +
> + wdt->dev = &pdev->dev;
> + wdt->rmap = dev_get_regmap(pdev->dev.parent, NULL);
> + if (!wdt->rmap) {
> + dev_err(wdt->dev, "Failed to get parent regmap\n");
> + return -ENODEV;
> + }
> +
> + wdt_dev = &wdt->wdt_dev;
> + wdt_dev->info = &max77620_wdt_info;
> + wdt_dev->ops = &max77620_wdt_ops;
> + wdt_dev->min_timeout = 2;
> + wdt_dev->max_timeout = 128;
> + wdt_dev->max_hw_heartbeat_ms = 128 * 1000;
> +
> + platform_set_drvdata(pdev, wdt);
> +
> + /* Enable WD_RST_WK - WDT expire results in a restart */
> + ret = regmap_update_bits(wdt->rmap, MAX77620_REG_ONOFFCNFG2,
> + MAX77620_ONOFFCNFG2_WD_RST_WK,
> + MAX77620_ONOFFCNFG2_WD_RST_WK);
> + if (ret < 0) {
> + dev_err(wdt->dev, "Failed to set WD_RST_WK: %d\n", ret);
> + return ret;
> + }
> +
> + /* Set WDT clear in OFF and sleep mode */
> + ret = regmap_update_bits(wdt->rmap, MAX77620_REG_CNFGGLBL2,
> + MAX77620_WDTOFFC | MAX77620_WDTSLPC,
> + MAX77620_WDTOFFC | MAX77620_WDTSLPC);
> + if (ret < 0) {
> + dev_err(wdt->dev, "Failed to set WDT OFF mode: %d\n", ret);
> + return ret;
> + }
> +
> + /* Check if WDT running and ig yes then set flags properly */
> + ret = regmap_read(wdt->rmap, MAX77620_REG_CNFGGLBL2, ®val);
> + if (ret < 0) {
> + dev_err(wdt->dev, "Failed to read WDT CFG register: %d\n", ret);
> + return ret;
> + }
> +
> + if (regval & MAX77620_WDTEN) {
> + regval = regval & MAX77620_TWD_MASK;
> + if (regval == MAX77620_TWD_2s)
> + wdt_dev->timeout = 2;
> + else if (regval == MAX77620_TWD_16s)
> + wdt_dev->timeout = 16;
> + else if (regval == MAX77620_TWD_64s)
> + wdt_dev->timeout = 64;
> + else
> + wdt_dev->timeout = 128;
> + set_bit(WDOG_HW_RUNNING, &wdt_dev->status);
> + }
Please also set a default timeout if the watchdog is not running
(and remember to write it to the chip). Otherwise the core won't know
the timeout and can not report it to user space when the watchdog
device is opened.
Thanks,
Guenter
prev parent reply other threads:[~2016-06-08 13:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 10:17 [PATCH V2] watchdog: max77620: Add support for watchdog timer Laxman Dewangan
2016-06-08 13:41 ` Guenter Roeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57582087.1050900@roeck-us.net \
--to=linux@roeck-us.net \
--cc=ldewangan@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=wim@iguana.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox