public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vlad Zakharov <Vladislav.Zakharov@synopsys.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] timer: Support clocks via phandle
Date: Mon, 19 Dec 2016 13:53:57 +0000	[thread overview]
Message-ID: <1482155637.3601.2.camel@synopsys.com> (raw)
In-Reply-To: <1481293112-18577-1-git-send-email-vzakhar@synopsys.com>

Hi Tom,

On Fri, 2016-12-09 at 17:18 +0300, Vlad Zakharov wrote:
> Earlier timer driver needed a clock-frequency property in compatible
> device-tree nodes. Another way is to reference a clock via a phandle.
> 
> So now timer_pre_probe tries to get clock by reference through device
> tree. In case it is impossible to get clock device through the
> reference, clock-frequency property of the timer node is read to provide
> backward compatibility.
> 
> Signed-off-by: Vlad Zakharov <vzakhar@synopsys.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
> Changes v2..v3:
> ?- Use value type instead of pointer for timer_clk in order to fix
> build time warnings
> 
> ?drivers/timer/timer-uclass.c | 17 ++++++++++++++---
> ?1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
> index f8ddf93..5c63e6b 100644
> --- a/drivers/timer/timer-uclass.c
> +++ b/drivers/timer/timer-uclass.c
> @@ -8,6 +8,7 @@
> ?#include <dm.h>
> ?#include <dm/lists.h>
> ?#include <dm/device-internal.h>
> +#include <clk.h>
> ?#include <errno.h>
> ?#include <timer.h>
> ?
> @@ -42,9 +43,19 @@ unsigned long notrace timer_get_rate(struct udevice *dev)
> ?static int timer_pre_probe(struct udevice *dev)
> ?{
> ?	struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> -
> -	uc_priv->clock_rate = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
> -					?????"clock-frequency", 0);
> +	struct clk timer_clk;
> +	int err;
> +	ulong ret;
> +
> +	err = clk_get_by_index(dev, 0, &timer_clk);
> +	if (!err) {
> +		ret = clk_get_rate(&timer_clk);
> +		if (IS_ERR_VALUE(ret))
> +			return ret;
> +		uc_priv->clock_rate = ret;
> +	} else
> +		uc_priv->clock_rate = fdtdec_get_int(gd->fdt_blob,
> +				dev->of_offset,	"clock-frequency", 0);
> ?
> ?	return 0;
> ?}

Could you please apply this patch if there's no any objections or comments on it?
Thanks.

-- 
Best regards,
Vlad Zakharov <vzakhar@synopsys.com>

  reply	other threads:[~2016-12-19 13:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-09 14:18 [U-Boot] [PATCH v3] timer: Support clocks via phandle Vlad Zakharov
2016-12-19 13:53 ` Vlad Zakharov [this message]
2016-12-27 22:56 ` [U-Boot] [U-Boot,v3] " Tom Rini

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=1482155637.3601.2.camel@synopsys.com \
    --to=vladislav.zakharov@synopsys.com \
    --cc=u-boot@lists.denx.de \
    /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