2 * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
4 * SPDX-License-Identifier: GPL-2.0+
11 * dm_timer_init - initialize a timer for time keeping. On success
12 * initializes gd->timer so that lib/timer can use it for future
15 * @return - 0 on success or error number
17 int dm_timer_init(void);
20 * timer_conv_64 - convert 32-bit counter value to 64-bit
22 * @count: 32-bit counter value
23 * @return: 64-bit counter value
25 u64 timer_conv_64(u32 count);
28 * Get the current timer count
30 * @dev: The timer device
31 * @count: pointer that returns the current timer count
32 * @return: 0 if OK, -ve on error
34 int timer_get_count(struct udevice *dev, u64 *count);
37 * Get the timer input clock frequency
39 * @dev: The timer device
40 * @return: the timer input clock frequency
42 unsigned long timer_get_rate(struct udevice *dev);
45 * struct timer_ops - Driver model timer operations
47 * The uclass interface is implemented by all timer devices which use
52 * Get the current timer count
54 * @dev: The timer device
55 * @count: pointer that returns the current 64-bit timer count
56 * @return: 0 if OK, -ve on error
58 int (*get_count)(struct udevice *dev, u64 *count);
62 * struct timer_dev_priv - information about a device used by the uclass
64 * @clock_rate: the timer input clock frequency
66 struct timer_dev_priv {
67 unsigned long clock_rate;
71 * timer_early_get_count() - Implement timer_get_count() before driver model
73 * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
74 * the current timer value before the proper driver model timer is ready.
75 * It should be implemented by one of the timer values. This is mostly useful
78 u64 timer_early_get_count(void);
81 * timer_early_get_rate() - Get the timer rate before driver model
83 * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
84 * the current timer rate in Hz before the proper driver model timer is ready.
85 * It should be implemented by one of the timer values. This is mostly useful
86 * for tracing. This corresponds to the clock_rate value in struct
89 unsigned long timer_early_get_rate(void);
91 #endif /* _TIMER_H_ */