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_conv_64 - convert 32-bit counter value to 64-bit
21 * @count: 32-bit counter value
22 * @return: 64-bit counter value
24 u64 timer_conv_64(u32 count);
27 * Get the current timer count
29 * @dev: The timer device
30 * @count: pointer that returns the current timer count
31 * @return: 0 if OK, -ve on error
33 int timer_get_count(struct udevice *dev, u64 *count);
36 * Get the timer input clock frequency
38 * @dev: The timer device
39 * @return: the timer input clock frequency
41 unsigned long timer_get_rate(struct udevice *dev);
44 * struct timer_ops - Driver model timer operations
46 * The uclass interface is implemented by all timer devices which use
51 * Get the current timer count
53 * @dev: The timer device
54 * @count: pointer that returns the current 64-bit timer count
55 * @return: 0 if OK, -ve on error
57 int (*get_count)(struct udevice *dev, u64 *count);
61 * struct timer_dev_priv - information about a device used by the uclass
63 * @clock_rate: the timer input clock frequency
65 struct timer_dev_priv {
66 unsigned long clock_rate;
70 * timer_early_get_count() - Implement timer_get_count() before driver model
72 * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
73 * the current timer value before the proper driver model timer is ready.
74 * It should be implemented by one of the timer values. This is mostly useful
77 u64 timer_early_get_count(void);
80 * timer_early_get_rate() - Get the timer rate before driver model
82 * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
83 * the current timer rate in Hz before the proper driver model timer is ready.
84 * It should be implemented by one of the timer values. This is mostly useful
85 * for tracing. This corresponds to the clock_rate value in struct
88 unsigned long timer_early_get_rate(void);
90 #endif /* _TIMER_H_ */