linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Srinath Mannam <srinath.mannam@broadcom.com>, wim@linux-watchdog.org
Cc: ray.jui@broadcom.com, vladimir.olovyannikov@broadcom.com,
	vikram.prakash@broadcom.com, scott.branden@broadcom.com,
	sudeep.holla@arm.com, linux-watchdog@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] watchdog: sp805: Add clock-frequency property
Date: Thu, 5 Jul 2018 08:28:08 -0700	[thread overview]
Message-ID: <f29c486a-2ac8-55e7-86ed-90e3cf71bcea@roeck-us.net> (raw)
In-Reply-To: <1530760968-13104-1-git-send-email-srinath.mannam@broadcom.com>

On 07/04/2018 08:22 PM, Srinath Mannam wrote:
> When using ACPI node, binding clock devices are
> not available as device tree, So clock-frequency
> property given in _DSD object of ACPI device is
> used to calculate Watchdog rate.
> 
> Signed-off-by: Srinath Mannam <srinath.mannam@broadcom.com>
> ---
>   drivers/watchdog/sp805_wdt.c | 29 ++++++++++++++++++++++++-----
>   1 file changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c
> index 9849db0..d830dbc 100644
> --- a/drivers/watchdog/sp805_wdt.c
> +++ b/drivers/watchdog/sp805_wdt.c
> @@ -22,6 +22,7 @@
>   #include <linux/math64.h>
>   #include <linux/module.h>
>   #include <linux/moduleparam.h>
> +#include <linux/of.h>
>   #include <linux/pm.h>
>   #include <linux/slab.h>
>   #include <linux/spinlock.h>
> @@ -65,6 +66,7 @@ struct sp805_wdt {
>   	spinlock_t			lock;
>   	void __iomem			*base;
>   	struct clk			*clk;
> +	u64				rate;
>   	struct amba_device		*adev;
>   	unsigned int			load_val;
>   };
> @@ -80,7 +82,10 @@ static int wdt_setload(struct watchdog_device *wdd, unsigned int timeout)
>   	struct sp805_wdt *wdt = watchdog_get_drvdata(wdd);
>   	u64 load, rate;
>   
> -	rate = clk_get_rate(wdt->clk);
> +	if (wdt->rate)
> +		rate = wdt->rate;
> +	else
> +		rate = clk_get_rate(wdt->clk);

No. Get the rate once during probe and store it in wdt->rate.

>   
>   	/*
>   	 * sp805 runs counter with given value twice, after the end of first
> @@ -108,7 +113,10 @@ static unsigned int wdt_timeleft(struct watchdog_device *wdd)
>   	struct sp805_wdt *wdt = watchdog_get_drvdata(wdd);
>   	u64 load, rate;
>   
> -	rate = clk_get_rate(wdt->clk);
> +	if (wdt->rate)
> +		rate = wdt->rate;
> +	else
> +		rate = clk_get_rate(wdt->clk);

Same here.

>   
>   	spin_lock(&wdt->lock);
>   	load = readl_relaxed(wdt->base + WDTVALUE);
> @@ -230,11 +238,22 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id)
>   
>   	wdt->clk = devm_clk_get(&adev->dev, NULL);
>   	if (IS_ERR(wdt->clk)) {
> -		dev_warn(&adev->dev, "Clock not found\n");
> -		ret = PTR_ERR(wdt->clk);
> -		goto err;
> +		dev_warn(&adev->dev, "Clock device not found\n");

"Clock _device_" ? Why this change ? And why retain that warning unconditionally ?

> +		wdt->clk = NULL;
> +		/*
> +		 * When Driver probe with ACPI device, clock devices
> +		 * are not available, so watchdog rate get from
> +		 * clock-frequency property given in _DSD object.
> +		 */
> +		device_property_read_u64(&adev->dev, "clock-frequency",
> +					 &wdt->rate);
> +		if (!wdt->rate) {
> +			ret = -ENODEV;

This unconditionally overrides the original error.

> +			goto err;
> +		}
>   	}
>   
> +

No whitespace changes, please.

Does that mean that ACPI doesn't support the clock subsystem and that each driver
supporting ACPI must do this ? That would be messy. Also, the above does not check
if the device was probed through ACPI. It just tries to find an undocumented
"clock-frequency" property which is quite different and would apply to
(probably mis-configured) devicetree files as well.

Either case, I would rather have this addressed through the clock subsystem.
Otherwise, someone with subject knowledge will have to confirm that this is the
appropriate solution. If so, the new property will have to be documented as an
alternative to clock specifiers and accepted by devicetree maintainers.

Guenter

>   	wdt->adev = adev;
>   	wdt->wdd.info = &wdt_info;
>   	wdt->wdd.ops = &wdt_ops;
> 


  reply	other threads:[~2018-07-05 15:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05  3:22 [RFC PATCH] watchdog: sp805: Add clock-frequency property Srinath Mannam
2018-07-05 15:28 ` Guenter Roeck [this message]
2018-07-06  8:18   ` Srinath Mannam
2018-07-08 18:06     ` Guenter Roeck
2018-07-09  5:39       ` Srinath Mannam

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=f29c486a-2ac8-55e7-86ed-90e3cf71bcea@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=ray.jui@broadcom.com \
    --cc=scott.branden@broadcom.com \
    --cc=srinath.mannam@broadcom.com \
    --cc=sudeep.holla@arm.com \
    --cc=vikram.prakash@broadcom.com \
    --cc=vladimir.olovyannikov@broadcom.com \
    --cc=wim@linux-watchdog.org \
    /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;
as well as URLs for NNTP newsgroup(s).