1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
10 * dm_timer_init() - initialize a timer for time keeping. On success
11 * initializes gd->timer so that lib/timer can use it for future
14 * Return: 0 on success or error number
16 int dm_timer_init(void);
19 * timer_timebase_fallback() - Helper for timers using timebase fallback
20 * @dev: A timer partially-probed timer device
22 * This is a helper function designed for timers which need to fall back on the
23 * cpu's timebase. This function is designed to be called during the driver's
24 * probe(). If there is a clocks or clock-frequency property in the timer's
25 * binding, then it will be used. Otherwise, the timebase of the current cpu
26 * will be used. This is initialized by the cpu driver, and usually gotten from
27 * ``/cpus/timebase-frequency`` or ``/cpus/cpu@X/timebase-frequency``.
29 * Return: 0 if OK, or negative error code on failure
31 int timer_timebase_fallback(struct udevice *dev);
34 * timer_conv_64() - convert 32-bit counter value to 64-bit
35 * @count: 32-bit counter value
37 * Return: 64-bit counter value
39 u64 timer_conv_64(u32 count);
42 * timer_get_count() - Get the current timer count
43 * @dev: The timer device
44 * @count: pointer that returns the current timer count
46 * Return: 0 if OK, -ve on error
48 int timer_get_count(struct udevice *dev, u64 *count);
51 * timer_get_rate() - Get the timer input clock frequency
52 * @dev: The timer device
54 * Return: the timer input clock frequency
56 unsigned long timer_get_rate(struct udevice *dev);
59 * struct timer_ops - Driver model timer operations
61 * The uclass interface is implemented by all timer devices which use
66 * @get_count: Get the current timer count
68 * @dev: The timer device
70 * @count: pointer that returns the current 64-bit timer count
72 * Return: 0 if OK, -ve on error
74 int (*get_count)(struct udevice *dev, u64 *count);
78 * struct timer_dev_priv - information about a device used by the uclass
80 * @clock_rate: the timer input clock frequency
82 struct timer_dev_priv {
83 unsigned long clock_rate;
87 * timer_early_get_count() - Implement timer_get_count() before driver model
89 * If ``CONFIG_TIMER_EARLY`` is enabled, this function wil be called to return
90 * the current timer value before the proper driver model timer is ready.
91 * It should be implemented by one of the timer values. This is mostly useful
94 u64 timer_early_get_count(void);
97 * timer_early_get_rate() - Get the timer rate before driver model
99 * If ``CONFIG_TIMER_EARLY`` is enabled, this function wil be called to return
100 * the current timer rate in Hz before the proper driver model timer is ready.
101 * It should be implemented by one of the timer values. This is mostly useful
102 * for tracing. This corresponds to the clock_rate value in struct
105 unsigned long timer_early_get_rate(void);
107 #endif /* _TIMER_H_ */