Timer Subsystem¶
-
int
dm_timer_init
(void)¶ initialize a timer for time keeping. On success initializes gd->timer so that lib/timer can use it for future referrence.
Parameters
void
no arguments
Return
0 on success or error number
Parameters
struct udevice *dev
A timer partially-probed timer device
Description
This is a helper function designed for timers which need to fall back on the
cpu’s timebase. This function is designed to be called during the driver’s
probe(). If there is a clocks or clock-frequency property in the timer’s
binding, then it will be used. Otherwise, the timebase of the current cpu
will be used. This is initialized by the cpu driver, and usually gotten from
/cpus/timebase-frequency
or /cpus/cpu**X**/timebase-frequency
.
Return
0 if OK, or negative error code on failure
-
u64
timer_conv_64
(u32 count)¶ convert 32-bit counter value to 64-bit
Parameters
u32 count
32-bit counter value
Return
64-bit counter value
Parameters
struct udevice *dev
The timer device
u64 *count
pointer that returns the current timer count
Return
0 if OK, -ve on error
Parameters
struct udevice *dev
The timer device
Return
the timer input clock frequency
-
struct
timer_ops
¶ Driver model timer operations
Definition
struct timer_ops {
u64 (*get_count)(struct udevice *dev);
};
Members
get_count
Get the current timer count
dev: The timer device
This function may be called at any time after the driver is probed. All necessary initialization must be completed by the time probe() returns. The count returned by this functions should be monotonic. This function must succeed.
Return: The current 64-bit timer count
Description
The uclass interface is implemented by all timer devices which use driver model.
-
struct
timer_dev_priv
¶ information about a device used by the uclass
Definition
struct timer_dev_priv {
unsigned long clock_rate;
};
Members
clock_rate
the timer input clock frequency
-
u64
timer_early_get_count
(void)¶ Implement timer_get_count() before driver model
Parameters
void
no arguments
Description
If CONFIG_TIMER_EARLY
is enabled, this function wil be called to return
the current timer value before the proper driver model timer is ready.
It should be implemented by one of the timer values. This is mostly useful
for tracing.
-
unsigned long
timer_early_get_rate
(void)¶ Get the timer rate before driver model
Parameters
void
no arguments
Description
If CONFIG_TIMER_EARLY
is enabled, this function wil be called to return
the current timer rate in Hz before the proper driver model timer is ready.
It should be implemented by one of the timer values. This is mostly useful
for tracing. This corresponds to the clock_rate value in struct
timer_dev_priv.