timer: Support clocks via phandle
PATCH v3 1/1 timer: Support clocks via phandle
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.
---
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(-)
drivers/timer/timer-uclass.c +14 -3
@@ -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 ; }
Signature · 1 line
2.7.4
PATCH v3 1/1 timer: Support clocks via phandle
Hi Tom,
Quoted 50 lines · Vlad Zakharov
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_probetries 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 <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes v2..v3:
?- Use value type instead of pointer fortimer_clkin order to fix build time warnings?drivers/timer/timer-uclass.c | 17 ++++++++++++++--- ?1 file changed, 14 insertions(+), 3 deletions(-)
drivers/timer/timer-uclass.c +0
-0@@ -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>
?drivers/timer/timer-uclass.c +13
-3@@ -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 );
Quoted 3 lines
?
? return 0;
?}
Could you please apply this patch if there's no any objections or comments on it? Thanks.
Signature · 2 lines
Best regards, Vlad Zakharov <[email protected]>
PATCH v3 1/1 timer: Support clocks via phandle
In reply to Vlad ZakharovQuoted 10 lines · Zakharov Vlad
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_probetries 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 <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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/20161227/913c1694/attachment.sig>