Merge tag 'u-boot-stm32-mcu-20190514' of https://github.com/pchotard/u-boot
[platform/kernel/u-boot.git] / drivers / timer / altera_timer.c
index 971ed38..6f504f7 100644 (file)
@@ -1,11 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2000-2002
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
  * Scott McNutt <smcnutt@psyent.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -14,8 +13,6 @@
 #include <timer.h>
 #include <asm/io.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
 /* control register */
 #define ALTERA_TIMER_CONT      BIT(1)  /* Continuous mode */
 #define ALTERA_TIMER_START     BIT(2)  /* Start timer */
@@ -32,10 +29,9 @@ struct altera_timer_regs {
 
 struct altera_timer_platdata {
        struct altera_timer_regs *regs;
-       unsigned long clock_rate;
 };
 
-static int altera_timer_get_count(struct udevice *dev, unsigned long *count)
+static int altera_timer_get_count(struct udevice *dev, u64 *count)
 {
        struct altera_timer_platdata *plat = dev->platdata;
        struct altera_timer_regs *const regs = plat->regs;
@@ -47,19 +43,16 @@ static int altera_timer_get_count(struct udevice *dev, unsigned long *count)
        /* Read timer value */
        val = readl(&regs->snapl) & 0xffff;
        val |= (readl(&regs->snaph) & 0xffff) << 16;
-       *count = ~val;
+       *count = timer_conv_64(~val);
 
        return 0;
 }
 
 static int altera_timer_probe(struct udevice *dev)
 {
-       struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
        struct altera_timer_platdata *plat = dev->platdata;
        struct altera_timer_regs *const regs = plat->regs;
 
-       uc_priv->clock_rate = plat->clock_rate;
-
        writel(0, &regs->status);
        writel(0, &regs->control);
        writel(ALTERA_TIMER_STOP, &regs->control);
@@ -75,11 +68,9 @@ static int altera_timer_ofdata_to_platdata(struct udevice *dev)
 {
        struct altera_timer_platdata *plat = dev_get_platdata(dev);
 
-       plat->regs = map_physmem(dev_get_addr(dev),
+       plat->regs = map_physmem(devfdt_get_addr(dev),
                                 sizeof(struct altera_timer_regs),
                                 MAP_NOCACHE);
-       plat->clock_rate = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-               "clock-frequency", 0);
 
        return 0;
 }
@@ -101,5 +92,4 @@ U_BOOT_DRIVER(altera_timer) = {
        .platdata_auto_alloc_size = sizeof(struct altera_timer_platdata),
        .probe = altera_timer_probe,
        .ops    = &altera_timer_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };