public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] timer: Support clocks via phandle
@ 2016-11-19 16:57 Vlad Zakharov
  2016-11-21 14:38 ` Vlad Zakharov
  2016-11-29  0:49 ` [U-Boot] [U-Boot,v2] " Tom Rini
  0 siblings, 2 replies; 5+ messages in thread
From: Vlad Zakharov @ 2016-11-19 16:57 UTC (permalink / raw)
  To: u-boot

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 v1..v2:
 - Use temporary variable when getting clock rate

 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..a891a58 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;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] timer: Support clocks via phandle
  2016-11-19 16:57 [U-Boot] [PATCH v2] timer: Support clocks via phandle Vlad Zakharov
@ 2016-11-21 14:38 ` Vlad Zakharov
  2016-11-21 14:51   ` Tom Rini
  2016-11-29  0:49 ` [U-Boot] [U-Boot,v2] " Tom Rini
  1 sibling, 1 reply; 5+ messages in thread
From: Vlad Zakharov @ 2016-11-21 14:38 UTC (permalink / raw)
  To: u-boot

Hi Tom,

On Sat, 2016-11-19 at 19:57 +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 v1..v2:
> ?- Use temporary variable when getting clock rate
> 
> ?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..a891a58 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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] timer: Support clocks via phandle
  2016-11-21 14:38 ` Vlad Zakharov
@ 2016-11-21 14:51   ` Tom Rini
  2016-11-21 15:50     ` Vlad Zakharov
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Rini @ 2016-11-21 14:51 UTC (permalink / raw)
  To: u-boot

On Mon, Nov 21, 2016 at 02:38:30PM +0000, Vlad Zakharov wrote:
> Hi Tom,
> 
> On Sat, 2016-11-19 at 19:57 +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 v1..v2:
> > ?- Use temporary variable when getting clock rate
> > 
> > ?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..a891a58 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.

Is this required for the other series?  If not, I'd like to let it
"bake" a bit longer, but if it's needed, I'm OK with it coming in via
the arc tree now as well.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161121/471410be/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] timer: Support clocks via phandle
  2016-11-21 14:51   ` Tom Rini
@ 2016-11-21 15:50     ` Vlad Zakharov
  0 siblings, 0 replies; 5+ messages in thread
From: Vlad Zakharov @ 2016-11-21 15:50 UTC (permalink / raw)
  To: u-boot

Hi again,

On Mon, 2016-11-21 at 09:51 -0500, Tom Rini wrote:
> On Mon, Nov 21, 2016 at 02:38:30PM +0000, Vlad Zakharov wrote:
> > 
> > Hi Tom,
> > 
> > On Sat, 2016-11-19 at 19:57 +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 v1..v2:
> > > ?- Use temporary variable when getting clock rate
> > > 
> > > ?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..a891a58 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.
> 
> Is this required for the other series???If not, I'd like to let it
> "bake" a bit longer, but if it's needed, I'm OK with it coming in via
> the arc tree now as well.??Thanks!
> 

This update is not required for any patch series that have already been sent to mailing list.

Nevertheless this week I am going to send another series that introduces ARC clk driver and uses this driver to get
timer clock via the reference in device tree. Therefore current patch will be required for the updates I have just
described.

Thanks.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [U-Boot,v2] timer: Support clocks via phandle
  2016-11-19 16:57 [U-Boot] [PATCH v2] timer: Support clocks via phandle Vlad Zakharov
  2016-11-21 14:38 ` Vlad Zakharov
@ 2016-11-29  0:49 ` Tom Rini
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2016-11-29  0:49 UTC (permalink / raw)
  To: u-boot

On Sat, Nov 19, 2016 at 07:57:27PM +0300, Zakharov Vlad 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>

NAK:
   sandbox:  +   sandbox_spl             x
+(sandbox_spl)   err = clk_get_by_index(dev, 0, timer_clk);
+(sandbox_spl)       ^
w+(sandbox_spl) drivers/timer/timer-uclass.c: In function ?timer_pre_probe?:
w+(sandbox_spl) drivers/timer/timer-uclass.c:50:6: warning: ?timer_clk? is used uninitialized in this function [-Wuninitialized]

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161128/e6519008/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-29  0:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-19 16:57 [U-Boot] [PATCH v2] timer: Support clocks via phandle Vlad Zakharov
2016-11-21 14:38 ` Vlad Zakharov
2016-11-21 14:51   ` Tom Rini
2016-11-21 15:50     ` Vlad Zakharov
2016-11-29  0:49 ` [U-Boot] [U-Boot,v2] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox