summaryrefslogtreecommitdiff
path: root/drivers/timer/sti-timer.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-04-13 11:27:00 -0400
committerTom Rini <trini@konsulko.com>2020-04-13 11:27:00 -0400
commit891483186052b259852f3f48926ff307763f4eb0 (patch)
tree019e4a490e40ad5459f7dd3d4129021be696c495 /drivers/timer/sti-timer.c
parent36fec02b1f90b92cf51ec531564f9284eae27ab4 (diff)
parent67bbc1ecd311c78b06e845a3fd4e333806782367 (diff)
Merge branch 'next'
Pull in changes that have been pending in our 'next' branch. This includes: - A large number of CI improvements including moving to gcc-9.2 for all platforms. - amlogic, xilinx, stm32, TI SoC updates - USB and i2c subsystem updtaes - Re-sync Kbuild/etc logic with v4.19 of the Linux kernel. - RSA key handling improvements
Diffstat (limited to 'drivers/timer/sti-timer.c')
-rw-r--r--drivers/timer/sti-timer.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/timer/sti-timer.c b/drivers/timer/sti-timer.c
index 9def7e02f4..ff42056abd 100644
--- a/drivers/timer/sti-timer.c
+++ b/drivers/timer/sti-timer.c
@@ -6,14 +6,13 @@
#include <common.h>
#include <dm.h>
-#include <fdtdec.h>
+#include <clk.h>
#include <timer.h>
+#include <linux/err.h>
#include <asm/io.h>
#include <asm/arch-armv7/globaltimer.h>
-DECLARE_GLOBAL_DATA_PTR;
-
struct sti_timer_priv {
struct globaltimer *global_timer;
};
@@ -44,13 +43,24 @@ 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);
- fdt_addr_t addr;
-
- uc_priv->clock_rate = CONFIG_SYS_HZ_CLOCK;
+ struct clk clk;
+ int err;
+ ulong ret;
/* get arm global timer base address */
- addr = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), "reg");
- priv->global_timer = (struct globaltimer *)addr;
+ 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);