time.c (19ea4678ca5ce4c3a626039ed7642d4e0fbfdee1) | time.c (c8a7ba9e6a5fe2fc7b4a7894829aa0b0148b4d40) |
---|---|
1/* 2 * (C) Copyright 2000-2009 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8#include <common.h> | 1/* 2 * (C) Copyright 2000-2009 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8#include <common.h> |
9#include <dm.h> 10#include <errno.h> 11#include <timer.h> |
|
9#include <watchdog.h> 10#include <div64.h> 11#include <asm/io.h> 12 13#ifndef CONFIG_WD_PERIOD 14# define CONFIG_WD_PERIOD (10 * 1000 * 1000) /* 10 seconds default */ 15#endif 16 --- 15 unchanged lines hidden (view full) --- 32#else 33 return readl(CONFIG_SYS_TIMER_COUNTER); 34#endif 35} 36#else 37extern unsigned long __weak timer_read_counter(void); 38#endif 39 | 12#include <watchdog.h> 13#include <div64.h> 14#include <asm/io.h> 15 16#ifndef CONFIG_WD_PERIOD 17# define CONFIG_WD_PERIOD (10 * 1000 * 1000) /* 10 seconds default */ 18#endif 19 --- 15 unchanged lines hidden (view full) --- 35#else 36 return readl(CONFIG_SYS_TIMER_COUNTER); 37#endif 38} 39#else 40extern unsigned long __weak timer_read_counter(void); 41#endif 42 |
43#ifdef CONFIG_TIMER 44static int notrace dm_timer_init(void) 45{ 46 struct udevice *dev; 47 int ret; 48 49 if (!gd->timer) { 50 ret = uclass_first_device(UCLASS_TIMER, &dev); 51 if (ret) 52 return ret; 53 if (!dev) 54 return -ENODEV; 55 gd->timer = dev; 56 } 57 58 return 0; 59} 60 61ulong notrace get_tbclk(void) 62{ 63 int ret; 64 65 ret = dm_timer_init(); 66 if (ret) 67 return ret; 68 69 return timer_get_rate(gd->timer); 70} 71 72unsigned long notrace timer_read_counter(void) 73{ 74 unsigned long count; 75 int ret; 76 77 ret = dm_timer_init(); 78 if (ret) 79 return ret; 80 81 ret = timer_get_count(gd->timer, &count); 82 if (ret) 83 return ret; 84 85 return count; 86} 87#endif /* CONFIG_TIMER */ 88 |
|
40uint64_t __weak notrace get_ticks(void) 41{ 42 unsigned long now = timer_read_counter(); 43 44 /* increment tbu if tbl has rolled over */ 45 if (now < gd->timebase_l) 46 gd->timebase_h++; 47 gd->timebase_l = now; --- 66 unchanged lines hidden --- | 89uint64_t __weak notrace get_ticks(void) 90{ 91 unsigned long now = timer_read_counter(); 92 93 /* increment tbu if tbl has rolled over */ 94 if (now < gd->timebase_l) 95 gd->timebase_h++; 96 gd->timebase_l = now; --- 66 unchanged lines hidden --- |