diff options
| author | Tom Rini <[email protected]> | 2020-10-05 13:05:46 -0400 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2020-10-05 14:10:59 -0400 |
| commit | b7e7831e5d5be047f421ddc1f308afc22764a893 (patch) | |
| tree | 7d5f27c82b260278ed0b3ea96bce592b0505b898 /drivers/timer/timer-uclass.c | |
| parent | 050acee119b3757fee3bd128f55d720fdd9bb890 (diff) | |
| parent | caebff09efe8c061b4d99b82262c67fb2db9bbcf (diff) | |
Merge branch 'next'
Bring in the assorted changes that have been staged in the 'next' branch
prior to release.
Signed-off-by: Tom Rini <[email protected]>
Diffstat (limited to 'drivers/timer/timer-uclass.c')
| -rw-r--r-- | drivers/timer/timer-uclass.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 14dde950a18..e9802c8b43e 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -4,6 +4,7 @@ */ #include <common.h> +#include <cpu.h> #include <dm.h> #include <init.h> #include <dm/lists.h> @@ -79,6 +80,36 @@ static int timer_post_probe(struct udevice *dev) return 0; } +/* + * TODO: should be CONFIG_IS_ENABLED(CPU), but the SPL config has _SUPPORT on + * the end... + */ +#if defined(CONFIG_CPU) || defined(CONFIG_SPL_CPU_SUPPORT) +int timer_timebase_fallback(struct udevice *dev) +{ + struct udevice *cpu; + struct cpu_platdata *cpu_plat; + struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); + + /* Did we get our clock rate from the device tree? */ + if (uc_priv->clock_rate) + return 0; + + /* Fall back to timebase-frequency */ + dev_dbg(dev, "missing clocks or clock-frequency property; falling back on timebase-frequency\n"); + cpu = cpu_get_current_dev(); + if (!cpu) + return -ENODEV; + + cpu_plat = dev_get_parent_platdata(cpu); + if (!cpu_plat) + return -ENODEV; + + uc_priv->clock_rate = cpu_plat->timebase_freq; + return 0; +} +#endif + u64 timer_conv_64(u32 count) { /* increment tbh if tbl has rolled over */ |
