Clocks¶
API for manipulating clock sources.
The clock interface allows for controlling the rate of various clocks in the system.
Typedefs
-
typedef void (*
metal_clock_pre_rate_change_callback
)(void *priv)¶ Function signature of clock pre-rate change callbacks.
-
typedef void (*
metal_clock_post_rate_change_callback
)(void *priv)¶ Function signature of clock post-rate change callbacks.
Functions
-
long
metal_clock_get_rate_hz
(const struct metal_clock *clk)¶ Returns the current rate of the given clock.
- Return
- The current rate of the clock in Hz
- Parameters
clk
: The handle for the clock
-
long
metal_clock_set_rate_hz
(struct metal_clock *clk, long hz)¶ Set the current rate of a clock.
Attempts to set the current rate of the given clock to as close as possible to the given rate in Hz. Returns the actual value that’s been selected, which could be anything!
- Return
- The new rate of the clock in Hz.
- Parameters
clk
: The handle for the clockhz
: The desired rate in Hz
Prior to and after the rate change of the clock, this will call the registered pre- and post-rate change callbacks.
-
void
metal_clock_register_pre_rate_change_callback
(struct metal_clock *clk, metal_clock_pre_rate_change_callback cb, void *priv)¶ Register a callback that must be called before a rate change.
- Parameters
clk
: The handle for the clockcb
: The callback to be registeredpriv
: Private data for the callback handler
-
void
metal_clock_register_post_rate_change_callback
(struct metal_clock *clk, metal_clock_post_rate_change_callback cb, void *priv)¶ Registers a callback that must be called after a rate change.
- Parameters
clk
: The handle for the clockcb
: The callback to be registeredpriv
: Private data for the callback handler
-
struct
metal_clock
¶ - #include <clock.h>
The handle for a clock.
Clocks are defined as a pointer to a
struct metal_clock
, the contents of which are implementation defined. Users of the clock interface must call functions which accept astruct metal_clock *
as an argument to interract with the clock.Note that no mechanism for obtaining a pointer to a
struct metal_clock
has been defined, making it impossible to call any of these functions without invoking implementation-defined behavior.