If you need urgent consulting help click here
Clock Control
Overview
The clock control API provides access to clocks in the system, including the ability to turn them on and off.
API Reference
- group clock_control_interface
Clock Control Interface.
Defines
-
CLOCK_CONTROL_SUBSYS_ALL
Typedefs
-
typedef void *clock_control_subsys_t
clock_control_subsys_t is a type to identify a clock controller sub-system. Such data pointed is opaque and relevant only to the clock controller driver instance being used.
-
typedef void *clock_control_subsys_rate_t
clock_control_subsys_rate_t is a type to identify a clock controller sub-system rate. Such data pointed is opaque and relevant only to set the clock controller rate of the driver instance being used.
-
typedef void (*clock_control_cb_t)(const struct device *dev, clock_control_subsys_t subsys, void *user_data)
Callback called on clock started.
- Param dev
Device structure whose driver controls the clock.
- Param subsys
Opaque data representing the clock.
- Param user_data
User data.
-
typedef int (*clock_control)(const struct device *dev, clock_control_subsys_t sys)
-
typedef int (*clock_control_get)(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate)
-
typedef int (*clock_control_async_on_fn)(const struct device *dev, clock_control_subsys_t sys, clock_control_cb_t cb, void *user_data)
-
typedef enum clock_control_status (*clock_control_get_status_fn)(const struct device *dev, clock_control_subsys_t sys)
-
typedef int (*clock_control_set)(const struct device *dev, clock_control_subsys_t sys, clock_control_subsys_rate_t rate)
-
typedef int (*clock_control_configure_fn)(const struct device *dev, clock_control_subsys_t sys, void *data)
Enums
Functions
-
static inline int clock_control_on(const struct device *dev, clock_control_subsys_t sys)
Enable a clock controlled by the device.
On success, the clock is enabled and ready when this function returns. This function may sleep, and thus can only be called from thread context.
Use clock_control_async_on() for non-blocking operation.
- Parameters
dev – Device structure whose driver controls the clock.
sys – Opaque data representing the clock.
- Returns
0 on success, negative errno on failure.
-
static inline int clock_control_off(const struct device *dev, clock_control_subsys_t sys)
Disable a clock controlled by the device.
This function is non-blocking and can be called from any context. On success, the clock is disabled when this function returns.
- Parameters
dev – Device structure whose driver controls the clock
sys – Opaque data representing the clock
- Returns
0 on success, negative errno on failure.
-
static inline int clock_control_async_on(const struct device *dev, clock_control_subsys_t sys, clock_control_cb_t cb, void *user_data)
Request clock to start with notification when clock has been started.
Function is non-blocking and can be called from any context. User callback is called when clock is started.
- Parameters
dev – Device.
sys – A pointer to an opaque data representing the sub-system.
cb – Callback.
user_data – User context passed to the callback.
- Return values
0 – if start is successfully initiated.
-EALREADY – if clock was already started and is starting or running.
-ENOTSUP – If the requested mode of operation is not supported.
-ENOSYS – if the interface is not implemented.
other – negative errno on vendor specific error.
-
static inline enum clock_control_status clock_control_get_status(const struct device *dev, clock_control_subsys_t sys)
Get clock status.
- Parameters
dev – Device.
sys – A pointer to an opaque data representing the sub-system.
- Returns
Status.
-
static inline int clock_control_get_rate(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate)
Obtain the clock rate of given sub-system.
- Parameters
dev – Pointer to the device structure for the clock controller driver instance
sys – A pointer to an opaque data representing the sub-system
rate – [out] Subsystem clock rate
-
static inline int clock_control_set_rate(const struct device *dev, clock_control_subsys_t sys, clock_control_subsys_rate_t rate)
Set the rate of the clock controlled by the device.
On success, the new clock rate is set and ready when this function returns. This function may sleep, and thus can only be called from thread context.
- Parameters
dev – Device structure whose driver controls the clock.
sys – Opaque data representing the clock.
rate – Opaque data representing the clock rate to be used.
- Return values
-EALREADY – if clock was already in the given rate.
-ENOTSUP – If the requested mode of operation is not supported.
-ENOSYS – if the interface is not implemented.
other – negative errno on vendor specific error.
-
static inline int clock_control_configure(const struct device *dev, clock_control_subsys_t sys, void *data)
Configure a source clock.
This function is non-blocking and can be called from any context. On success, the selected clock is configured as per caller’s request.
It is caller’s responsibility to ensure that subsequent calls to the API provide the right information to allows clock_control driver to perform the right action (such as using the right clock source on clock_control_get_rate call).
data
is implementation specific and could be used to convey supplementary information required for expected clock configuration.- Parameters
dev – Device structure whose driver controls the clock
sys – Opaque data representing the clock
data – Opaque data providing additional input for clock configuration
- Return values
0 – On success
-ENOSYS – If the device driver does not implement this call
-errno – Other negative errno on failure.
-
struct clock_control_driver_api
- #include <clock_control.h>
-
CLOCK_CONTROL_SUBSYS_ALL