Clock controller class.
More...
Clock controller class.
A clock controller is a struct pbl_clk_controller device providing a set of clocks, each identified by a provider-specific number defined in the controller header. A consumer holds a struct pbl_clk naming the controller and clock, lists the controller among its device dependencies, and enables the clock while it uses the peripheral. Enables are counted per clock, so drivers sharing a clock never gate it under each other, and are safe to call from any context:
#define SF32LB_HPSYS_RCC
HPSYS RCC clock controller.
Definition sf32lb.h:22
#define SF32LB52_HPSYS_CLK_TRNG
Definition sf32lb.h:39
A clock, as used by a consumer.
Definition clk.h:83
int pbl_clk_enable(const struct pbl_clk *clk)
Take a reference on a clock, ungating it for the first user.
int pbl_clk_disable(const struct pbl_clk *clk)
Drop a reference on a clock, gating it after the last user.
#define PBL_CLK(_ctrl, _id)
Initializer for a struct pbl_clk.
Definition clk.h:96
◆ pbl_clk_controller
| struct pbl_clk_controller |
| Data Fields |
|
struct pbl_device |
dev |
Device. |
|
uint16_t |
num_clks |
Number of clocks. |
|
const struct pbl_clk_controller_ops * |
ops |
Driver operations. |
|
uint8_t * |
use_counts |
Enable count of each clock. |
◆ pbl_clk
A clock, as used by a consumer.
| Data Fields |
|
const struct pbl_clk_controller * |
ctrl |
Controller. |
|
uint32_t |
id |
Clock number on the controller. |
◆ PBL_CLK
| #define PBL_CLK |
( |
|
_ctrl, |
|
|
|
_id |
|
) |
| {.ctrl = (_ctrl), .id = (_id)} |
Initializer for a struct pbl_clk.
- Parameters
-
| _ctrl | Clock controller. |
| _id | Clock number, from the controller's binding header. |
◆ PBL_CLK_CONTROLLER_INIT
| #define PBL_CLK_CONTROLLER_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_init, |
|
|
|
_parent, |
|
|
|
_ops |
|
) |
| |
Value: { \
.ops = (_ops), \
.use_counts = sym##_clk_use_counts, \
.num_clks = sizeof(sym##_clk_use_counts), \
}
#define PBL_DEVICE_INIT(sym, _name, _init, _parent, _deps)
Initializer for the struct pbl_device of device instance sym.
Definition device.h:142
Initializer for the struct pbl_clk_controller of controller sym.
- Parameters
-
| sym | Symbol of the controller instance, with its state defined by PBL_CLK_CONTROLLER_STATE_DEFINE(). |
| _name | Name. |
| _init | Device init function, or NULL. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
◆ PBL_CLK_CONTROLLER_STATE_DEFINE
| #define PBL_CLK_CONTROLLER_STATE_DEFINE |
( |
|
sym, |
|
|
|
_num_clks |
|
) |
| |
Value:
static uint8_t sym##_clk_use_counts[_num_clks]
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:109
Define the class state of clock controller sym, for the driver's define macro.
- Parameters
-
| sym | Symbol of the controller instance. |
| _num_clks | Number of clocks. |
◆ pbl_clk_disable()
| int pbl_clk_disable |
( |
const struct pbl_clk * |
clk | ) |
|
Drop a reference on a clock, gating it after the last user.
Must balance a successful pbl_clk_enable().
- Parameters
-
- Returns
- 0 or a negative errno.
◆ pbl_clk_enable()
| int pbl_clk_enable |
( |
const struct pbl_clk * |
clk | ) |
|
Take a reference on a clock, ungating it for the first user.
- Parameters
-
- Returns
- 0 or a negative errno.
◆ pbl_clk_is_enabled()
| bool pbl_clk_is_enabled |
( |
const struct pbl_clk * |
clk | ) |
|
Check whether a clock has users.
- Parameters
-
- Returns
- True if the clock is enabled.