Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Clock Control Interface

Clock Control Interface. More...

Modules

 LiteX Clock Control driver interface
 LiteX Clock Control driver interface.
 

Data Structures

struct  clock_control_driver_api
 

Macros

#define CLOCK_CONTROL_SUBSYS_ALL   NULL
 

Typedefs

typedef void * clock_control_subsys_t
 clock_control_subsys_t is a type to identify a clock controller sub-system.
 
typedef void * clock_control_subsys_rate_t
 clock_control_subsys_rate_t is a type to identify a clock controller sub-system rate.
 
typedef void(* clock_control_cb_t) (const struct device *dev, clock_control_subsys_t subsys, void *user_data)
 Callback called on clock started.
 
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)
 

Enumerations

enum  clock_control_status { CLOCK_CONTROL_STATUS_STARTING , CLOCK_CONTROL_STATUS_OFF , CLOCK_CONTROL_STATUS_ON , CLOCK_CONTROL_STATUS_UNKNOWN }
 Current clock status. More...
 

Functions

static int clock_control_on (const struct device *dev, clock_control_subsys_t sys)
 Enable a clock controlled by the device.
 
static int clock_control_off (const struct device *dev, clock_control_subsys_t sys)
 Disable a clock controlled by the device.
 
static 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.
 
static enum clock_control_status clock_control_get_status (const struct device *dev, clock_control_subsys_t sys)
 Get clock status.
 
static 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.
 
static 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.
 
static int clock_control_configure (const struct device *dev, clock_control_subsys_t sys, void *data)
 Configure a source clock.
 

Detailed Description

Clock Control Interface.

Since
1.0
Version
1.0.0

Macro Definition Documentation

◆ CLOCK_CONTROL_SUBSYS_ALL

#define CLOCK_CONTROL_SUBSYS_ALL   NULL

Typedef Documentation

◆ clock_control

typedef int(* clock_control) (const struct device *dev, clock_control_subsys_t sys)

◆ clock_control_async_on_fn

typedef int(* clock_control_async_on_fn) (const struct device *dev, clock_control_subsys_t sys, clock_control_cb_t cb, void *user_data)

◆ clock_control_cb_t

typedef void(* clock_control_cb_t) (const struct device *dev, clock_control_subsys_t subsys, void *user_data)

#include <zephyr/drivers/clock_control.h>

Callback called on clock started.

Parameters
devDevice structure whose driver controls the clock.
subsysOpaque data representing the clock.
user_dataUser data.

◆ clock_control_configure_fn

typedef int(* clock_control_configure_fn) (const struct device *dev, clock_control_subsys_t sys, void *data)

◆ clock_control_get

typedef int(* clock_control_get) (const struct device *dev, clock_control_subsys_t sys, uint32_t *rate)

◆ clock_control_get_status_fn

typedef enum clock_control_status(* clock_control_get_status_fn) (const struct device *dev, clock_control_subsys_t sys)

◆ clock_control_set

typedef int(* clock_control_set) (const struct device *dev, clock_control_subsys_t sys, clock_control_subsys_rate_t rate)

◆ clock_control_subsys_rate_t

#include <zephyr/drivers/clock_control.h>

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.

◆ clock_control_subsys_t

typedef void* clock_control_subsys_t

#include <zephyr/drivers/clock_control.h>

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.

Enumeration Type Documentation

◆ clock_control_status

#include <zephyr/drivers/clock_control.h>

Current clock status.

Enumerator
CLOCK_CONTROL_STATUS_STARTING 
CLOCK_CONTROL_STATUS_OFF 
CLOCK_CONTROL_STATUS_ON 
CLOCK_CONTROL_STATUS_UNKNOWN 

Function Documentation

◆ clock_control_async_on()

static int clock_control_async_on ( const struct device dev,
clock_control_subsys_t  sys,
clock_control_cb_t  cb,
void *  user_data 
)
inlinestatic

#include <zephyr/drivers/clock_control.h>

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
devDevice.
sysA pointer to an opaque data representing the sub-system.
cbCallback.
user_dataUser context passed to the callback.
Return values
0if start is successfully initiated.
-EALREADYif clock was already started and is starting or running.
-ENOTSUPIf the requested mode of operation is not supported.
-ENOSYSif the interface is not implemented.
othernegative errno on vendor specific error.

◆ clock_control_configure()

static int clock_control_configure ( const struct device dev,
clock_control_subsys_t  sys,
void *  data 
)
inlinestatic

#include <zephyr/drivers/clock_control.h>

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
devDevice structure whose driver controls the clock
sysOpaque data representing the clock
dataOpaque data providing additional input for clock configuration
Return values
0On success
-ENOSYSIf the device driver does not implement this call
-errnoOther negative errno on failure.

◆ clock_control_get_rate()

static int clock_control_get_rate ( const struct device dev,
clock_control_subsys_t  sys,
uint32_t rate 
)
inlinestatic

#include <zephyr/drivers/clock_control.h>

Obtain the clock rate of given sub-system.

Parameters
devPointer to the device structure for the clock controller driver instance
sysA pointer to an opaque data representing the sub-system
[out]rateSubsystem clock rate
Return values
0on successful rate reading.
-EAGAINif rate cannot be read. Some drivers do not support returning the rate when the clock is off.
-ENOTSUPif reading the clock rate is not supported for the given sub-system.
-ENOSYSif the interface is not implemented.

◆ clock_control_get_status()

static enum clock_control_status clock_control_get_status ( const struct device dev,
clock_control_subsys_t  sys 
)
inlinestatic

#include <zephyr/drivers/clock_control.h>

Get clock status.

Parameters
devDevice.
sysA pointer to an opaque data representing the sub-system.
Returns
Status.

◆ clock_control_off()

static int clock_control_off ( const struct device dev,
clock_control_subsys_t  sys 
)
inlinestatic

#include <zephyr/drivers/clock_control.h>

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
devDevice structure whose driver controls the clock
sysOpaque data representing the clock
Returns
0 on success, negative errno on failure.

◆ clock_control_on()

static int clock_control_on ( const struct device dev,
clock_control_subsys_t  sys 
)
inlinestatic

#include <zephyr/drivers/clock_control.h>

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
devDevice structure whose driver controls the clock.
sysOpaque data representing the clock.
Returns
0 on success, negative errno on failure.

◆ clock_control_set_rate()

static int clock_control_set_rate ( const struct device dev,
clock_control_subsys_t  sys,
clock_control_subsys_rate_t  rate 
)
inlinestatic

#include <zephyr/drivers/clock_control.h>

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
devDevice structure whose driver controls the clock.
sysOpaque data representing the clock.
rateOpaque data representing the clock rate to be used.
Return values
-EALREADYif clock was already in the given rate.
-ENOTSUPIf the requested mode of operation is not supported.
-ENOSYSif the interface is not implemented.
othernegative errno on vendor specific error.