![]() |
RT-Thread RTOS
An open source embedded real-time operating system
|
Collaboration diagram for Clock:Data Structures | |
| struct | rt_clk_node |
| struct | rt_clk_cell |
| struct | rt_clk_fixed_rate |
| struct | rt_clk |
| struct | rt_clk_array |
| struct | rt_clk_notifier |
Macros | |
| #define | RT_CLK_F_SET_RATE_GATE RT_BIT(0) |
| #define | RT_CLK_F_SET_PARENT_GATE RT_BIT(1) |
| #define | RT_CLK_F_SET_RATE_PARENT RT_BIT(2) |
| #define | RT_CLK_F_IGNORE_UNUSED RT_BIT(3) |
| #define | RT_CLK_F_SET_RATE_UNGATE RT_BIT(4) |
| #define | RT_CLK_F_IS_CRITICAL RT_BIT(5) |
| #define | RT_CLK_F_GET_RATE_NOCACHE RT_BIT(6) |
Functions | |
| rt_err_t | rt_clk_register (struct rt_clk_node *clk_np) |
| rt_err_t | rt_clk_unregister (struct rt_clk_node *clk_np) |
| rt_err_t | rt_clk_notifier_register (struct rt_clk *clk, struct rt_clk_notifier *notifier) |
| rt_err_t | rt_clk_notifier_unregister (struct rt_clk *clk, struct rt_clk_notifier *notifier) |
| rt_err_t | rt_clk_prepare (struct rt_clk *clk) |
| void | rt_clk_unprepare (struct rt_clk *clk) |
| rt_err_t | rt_clk_enable (struct rt_clk *clk) |
| void | rt_clk_disable (struct rt_clk *clk) |
| rt_err_t | rt_clk_prepare_enable (struct rt_clk *clk) |
| void | rt_clk_disable_unprepare (struct rt_clk *clk) |
| rt_err_t | rt_clk_array_prepare (struct rt_clk_array *clk_arr) |
| void | rt_clk_array_unprepare (struct rt_clk_array *clk_arr) |
| rt_err_t | rt_clk_array_enable (struct rt_clk_array *clk_arr) |
| void | rt_clk_array_disable (struct rt_clk_array *clk_arr) |
| rt_err_t | rt_clk_array_prepare_enable (struct rt_clk_array *clk_arr) |
| void | rt_clk_array_disable_unprepare (struct rt_clk_array *clk_arr) |
| rt_err_t | rt_clk_set_rate_range (struct rt_clk *clk, rt_ubase_t min, rt_ubase_t max) |
| rt_err_t | rt_clk_set_min_rate (struct rt_clk *clk, rt_ubase_t rate) |
| rt_err_t | rt_clk_set_max_rate (struct rt_clk *clk, rt_ubase_t rate) |
| rt_err_t | rt_clk_set_rate (struct rt_clk *clk, rt_ubase_t rate) |
| rt_ubase_t | rt_clk_get_rate (struct rt_clk *clk) |
| rt_base_t | rt_clk_round_rate (struct rt_clk *clk, rt_ubase_t rate) |
| rt_err_t | rt_clk_set_parent (struct rt_clk *clk, struct rt_clk *clk_parent) |
| struct rt_clk * | rt_clk_get_parent (struct rt_clk *clk) |
| rt_err_t | rt_clk_set_phase (struct rt_clk *clk, int degrees) |
| rt_base_t | rt_clk_get_phase (struct rt_clk *clk) |
| struct rt_clk * | rt_clk_cell_get_clk (const struct rt_clk_cell *cell, const char *con_id) |
| rt_bool_t | rt_clk_cell_is_prepared (const struct rt_clk_cell *cell) |
| rt_bool_t | rt_clk_cell_is_enabled (const struct rt_clk_cell *cell) |
| rt_ubase_t | rt_clk_cell_get_rate (const struct rt_clk_cell *cell) |
| rt_ubase_t | rt_clk_cell_round_rate (struct rt_clk_cell *cell, rt_ubase_t rate) |
| struct rt_clk_cell * | rt_clk_cell_get_parent (const struct rt_clk_cell *cell) |
| struct rt_clk_cell * | rt_clk_cell_get_parent_by_index (const struct rt_clk_cell *cell, rt_uint8_t idx) |
| rt_uint8_t | rt_clk_cell_get_parent_index (struct rt_clk_cell *cell) |
| rt_err_t | rt_clk_cell_set_parent (struct rt_clk_cell *cell, struct rt_clk_cell *parent) |
| struct rt_clk_array * | rt_clk_get_array (struct rt_device *dev) |
| struct rt_clk * | rt_clk_get_by_index (struct rt_device *dev, int index) |
| struct rt_clk * | rt_clk_get_by_name (struct rt_device *dev, const char *name) |
| void | rt_clk_array_put (struct rt_clk_array *clk_arr) |
| void | rt_clk_put (struct rt_clk *clk) |
Clock driver API.
| #define RT_CLK_F_SET_RATE_GATE RT_BIT(0) |
Must be gated across rate change
| #define RT_CLK_F_SET_PARENT_GATE RT_BIT(1) |
Must be gated across re-parent
| #define RT_CLK_F_SET_RATE_PARENT RT_BIT(2) |
Propagate rate change up one level
| #define RT_CLK_F_IGNORE_UNUSED RT_BIT(3) |
Do not gate even if unused
| #define RT_CLK_F_SET_RATE_UNGATE RT_BIT(4) |
Clock needs to run to set rate
| #define RT_CLK_F_IS_CRITICAL RT_BIT(5) |
Do not gate, ever
| #define RT_CLK_F_GET_RATE_NOCACHE RT_BIT(6) |
Do not get rate by cache
| rt_err_t rt_clk_register | ( | struct rt_clk_node * | clk_np | ) |
Register a clock node into the global clock framework.
This function initializes an rt_clk_node structure and inserts it into the global clock node list. Each node may contain multiple rt_clk_cell instances, which represent the individual output clocks provided by the node.
If the node is associated with a device (clk_np->dev is not NULL), the framework will automatically try to obtain its parent clocks by calling rt_clk_get_array(clk_np->dev). Otherwise, the node will be treated as a root-level provider (e.g., fixed clock).
The caller must ensure that all rt_clk_cell entries are allocated and linked to the node before calling this function.
| clk_np | Pointer to the clock node to be registered. |
| RT_EOK | Successfully registered. |
| -RT_EINVAL | Invalid argument or missing cell list. |
| -RT_ENOMEM | Failed to allocate parent clock array. |
| rt_err_t rt_clk_unregister | ( | struct rt_clk_node * | clk_np | ) |
Unregister a clock node from global clock list.
This API is intended for rollback use only, typically called when a clock provider fails after registration but before any consumer starts using its clocks.
It removes the specified clock node from the global list and releases its parent clock array if present. The function does not free memory of rt_clk_cell instances or the node itself.
| clk_np | Pointer to the clock node to be unregistered. |
| RT_EOK | Successfully unregistered. |
| -RT_EINVAL | Invalid parameter. |
| -RT_EBUSY | One or more cells are active and cannot be removed. |
| rt_err_t rt_clk_notifier_register | ( | struct rt_clk * | clk, |
| struct rt_clk_notifier * | notifier | ||
| ) |
Register clock notifier into notifier list.
| clk | point to clock |
| notifier | point to notifier for register |
| RT_EOK | |
| -RT_EINVAL |
| rt_err_t rt_clk_notifier_unregister | ( | struct rt_clk * | clk, |
| struct rt_clk_notifier * | notifier | ||
| ) |
Unregister clock notifier into notifier list.
| clk | point to clock |
| notifier | point to notifier for unregister |
| RT_EOK | |
| -RT_EINVAL |
| rt_err_t rt_clk_prepare | ( | struct rt_clk * | clk | ) |
Prepare clock.
| clk |
| void rt_clk_unprepare | ( | struct rt_clk * | clk | ) |
Unprepare clock.
| clk | Ponit to clock that will be unprepared |
| rt_err_t rt_clk_enable | ( | struct rt_clk * | clk | ) |
Enable clock.
| clk | point to clock |
| void rt_clk_disable | ( | struct rt_clk * | clk | ) |
Disable clock.
| clk | point to clock |
| rt_err_t rt_clk_prepare_enable | ( | struct rt_clk * | clk | ) |
Prepare and enable clock.
| clk | point to clock |
| void rt_clk_disable_unprepare | ( | struct rt_clk * | clk | ) |
Disable and unprepare clock.
| clk | point to clock |
| rt_err_t rt_clk_array_prepare | ( | struct rt_clk_array * | clk_arr | ) |
Prepare clock array for mutipule out clock.
| clk_arr | point to clock array |
| void rt_clk_array_unprepare | ( | struct rt_clk_array * | clk_arr | ) |
Unprepare clock array for mutipule out clock.
| clk_arr | point to clock array |
| rt_err_t rt_clk_array_enable | ( | struct rt_clk_array * | clk_arr | ) |
Enable clock array for mutipule out clock.
| clk_arr | point to clock array |
| void rt_clk_array_disable | ( | struct rt_clk_array * | clk_arr | ) |
Enable clock array for mutipule out clock.
| clk_arr | point to clock array |
| rt_err_t rt_clk_array_prepare_enable | ( | struct rt_clk_array * | clk_arr | ) |
Prepare and enable clock array.
| clk_arr | point to clock array |
| void rt_clk_array_disable_unprepare | ( | struct rt_clk_array * | clk_arr | ) |
Disable and unprepare clock array.
| clk_arr | point to clock array |
| rt_err_t rt_clk_set_rate_range | ( | struct rt_clk * | clk, |
| rt_ubase_t | min, | ||
| rt_ubase_t | max | ||
| ) |
Set clock rate range.
| clk | point to clock |
| min | minimum clock rate |
| max | minimum clock rate |
| rt_err_t rt_clk_set_min_rate | ( | struct rt_clk * | clk, |
| rt_ubase_t | rate | ||
| ) |
Set minimum clock rate.
| clk | point to clock |
| rate | miminum clock rate |
| rt_err_t rt_clk_set_max_rate | ( | struct rt_clk * | clk, |
| rt_ubase_t | rate | ||
| ) |
Set maximum clock rate.
| clk | point to clock |
| rate | maximum clock rate |
| rt_err_t rt_clk_set_rate | ( | struct rt_clk * | clk, |
| rt_ubase_t | rate | ||
| ) |
Set clock rate.
| clk | point to clock |
| rate | target rate |
| rt_ubase_t rt_clk_get_rate | ( | struct rt_clk * | clk | ) |
Get clock rate.
| clk | point to clock |
| rt_base_t rt_clk_round_rate | ( | struct rt_clk * | clk, |
| rt_ubase_t | rate | ||
| ) |
Check if clock rate is in the minimum to maximun and get it.
| clk | point to clock |
| rate | rate will be checked |
Set clock parent object.
| clk | point to clock |
| clk_parent | point to parent clock |
Get parent clock pointer.
| clk | child clock |
| rt_err_t rt_clk_set_phase | ( | struct rt_clk * | clk, |
| int | degrees | ||
| ) |
Set clock phase.
| clk | point to clock |
| degrees | target phase and the unit of phase is degree |
| rt_base_t rt_clk_get_phase | ( | struct rt_clk * | clk | ) |
Get clock phase.
| clk | point to clock |
| struct rt_clk * rt_clk_cell_get_clk | ( | const struct rt_clk_cell * | cell, |
| const char * | con_id | ||
| ) |
Get or create clock handle for a clock cell.
| cell | Pointer to clock cell |
| con_id | Connection identifier for the clock cell |
| rt_bool_t rt_clk_cell_is_prepared | ( | const struct rt_clk_cell * | cell | ) |
Check if the clock cell is prepared.
| cell | Pointer to clock cell |
| rt_bool_t rt_clk_cell_is_enabled | ( | const struct rt_clk_cell * | cell | ) |
Check if the clock cell is enabled.
| cell | Pointer to clock cell |
| rt_ubase_t rt_clk_cell_get_rate | ( | const struct rt_clk_cell * | cell | ) |
Get current rate of the clock cell.
| cell | Pointer to clock cell |
| rt_ubase_t rt_clk_cell_round_rate | ( | struct rt_clk_cell * | cell, |
| rt_ubase_t | rate | ||
| ) |
Round a desired rate to the nearest supported rate.
| cell | Pointer to clock cell |
| rate | Desired frequency in Hz |
| struct rt_clk_cell * rt_clk_cell_get_parent | ( | const struct rt_clk_cell * | cell | ) |
Get parent clock cell.
| cell | Pointer to clock cell |
| struct rt_clk_cell * rt_clk_cell_get_parent_by_index | ( | const struct rt_clk_cell * | cell, |
| rt_uint8_t | idx | ||
| ) |
Get parent clock cell by index.
| cell | Pointer to clock cell |
| idx | Parent index |
| rt_uint8_t rt_clk_cell_get_parent_index | ( | struct rt_clk_cell * | cell | ) |
Get current parent index.
| cell | Pointer to clock cell |
| rt_err_t rt_clk_cell_set_parent | ( | struct rt_clk_cell * | cell, |
| struct rt_clk_cell * | parent | ||
| ) |
Set new parent clock cell.
| cell | Pointer to clock cell |
| parent | Pointer to new parent clock cell |
| struct rt_clk_array * rt_clk_get_array | ( | struct rt_device * | dev | ) |
Get clock array pointer from ofw device node.
| dev | point to dev |
Get clock pointer from ofw device node by index.
| dev | point to dev |
| index | index of clock object |
Get clock pointer from ofw device node by name.
| dev | point to dev |
| name | name of clock object |
| void rt_clk_array_put | ( | struct rt_clk_array * | clk_arr | ) |
Put reference count of all colock in the clock array.
| clk_arr | point to clock array |
| void rt_clk_put | ( | struct rt_clk * | clk | ) |
Put reference count of clock.
| clk | point to clock |