dm: treewide: Rename auto_alloc_size members to be shorter
[platform/kernel/u-boot.git] / drivers / timer / sti-timer.c
index eac22ae..1ab183c 100644 (file)
@@ -6,7 +6,9 @@
 
 #include <common.h>
 #include <dm.h>
+#include <clk.h>
 #include <timer.h>
+#include <linux/err.h>
 
 #include <asm/io.h>
 #include <asm/arch-armv7/globaltimer.h>
@@ -15,7 +17,7 @@ struct sti_timer_priv {
        struct globaltimer *global_timer;
 };
 
-static int sti_timer_get_count(struct udevice *dev, u64 *count)
+static u64 sti_timer_get_count(struct udevice *dev)
 {
        struct sti_timer_priv *priv = dev_get_priv(dev);
        struct globaltimer *global_timer = priv->global_timer;
@@ -32,23 +34,32 @@ static int sti_timer_get_count(struct udevice *dev, u64 *count)
                        old = high;
        }
        timer = high;
-       *count = (u64)((timer << 32) | low);
-
-       return 0;
+       return (u64)((timer << 32) | low);
 }
 
 static int sti_timer_probe(struct udevice *dev)
 {
        struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
        struct sti_timer_priv *priv = dev_get_priv(dev);
-
-       uc_priv->clock_rate = CONFIG_SYS_HZ_CLOCK;
+       struct clk clk;
+       int err;
+       ulong ret;
 
        /* get arm global timer base address */
        priv->global_timer = (struct globaltimer *)dev_read_addr_ptr(dev);
        if (!priv->global_timer)
                return -ENOENT;
 
+       err = clk_get_by_index(dev, 0, &clk);
+       if (!err) {
+               ret = clk_get_rate(&clk);
+               if (IS_ERR_VALUE(ret))
+                       return ret;
+               uc_priv->clock_rate = ret;
+       } else {
+               uc_priv->clock_rate = CONFIG_SYS_HZ_CLOCK;
+       }
+
        /* init timer */
        writel(0x01, &priv->global_timer->ctl);
 
@@ -68,7 +79,7 @@ U_BOOT_DRIVER(sti_timer) = {
        .name = "sti_timer",
        .id = UCLASS_TIMER,
        .of_match = sti_timer_ids,
-       .priv_auto_alloc_size = sizeof(struct sti_timer_priv),
+       .priv_auto      = sizeof(struct sti_timer_priv),
        .probe = sti_timer_probe,
        .ops = &sti_timer_ops,
 };