PebbleOS v4.48.0-75-g7416f78a1
Loading...
Searching...
No Matches
clk.h File Reference
#include <stdint.h>
#include <pbl/device.h>

Data Structures

struct  pbl_clk
 A clock, as used by a consumer. More...
 
struct  pbl_clk_assigned
 Parent and rate a clock is set to when its controller comes up. More...
 
struct  pbl_clk_notifier
 A rate change subscription. More...
 

Macros

#define PBL_CLK(_ctrl, _id)   {.ctrl = (_ctrl), .id = (_id)}
 Initializer for a struct pbl_clk.
 
#define PBL_CLK_NONE   PBL_CLK(nullptr, 0)
 Initializer for a struct pbl_clk without a clock.
 
#define PBL_CLK_ASSIGNED(_clk, _parent, _rate_hz)    {.clk = _clk, .parent = _parent, .rate_hz = (_rate_hz)}
 Initializer for a struct pbl_clk_assigned.
 
#define PBL_CLK_ASSIGNED_DEFINE(sym, ...)    static const struct pbl_clk_assigned sym[] = {__VA_ARGS__ __VA_OPT__(, ){}}
 Define the list of parents and rates a clock controller assigns, for the driver's define macro.
 

Typedefs

typedef void(* pbl_clk_notifier_fn_t) (struct pbl_clk_notifier *nb, uint64_t rate_mhz)
 Rate change callback.
 

Functions

static bool pbl_clk_is_connected (const struct pbl_clk *clk)
 Check whether a clock reference has a clock.
 
int pbl_clk_init (const struct pbl_clk *clk)
 Bring up the controller of a clock, for a user that runs before the devices are initialized.
 
static bool pbl_clk_eq (const struct pbl_clk *a, const struct pbl_clk *b)
 Check whether two clock references name the same clock.
 
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.
 
bool pbl_clk_is_enabled (const struct pbl_clk *clk)
 Check whether a clock has users.
 
int pbl_clk_get_rate (const struct pbl_clk *clk, uint64_t *rate_mhz)
 Get the rate of a clock.
 
int pbl_clk_get_parent (const struct pbl_clk *clk, struct pbl_clk *parent)
 Get the parent of a clock.
 
int pbl_clk_set_parent (const struct pbl_clk *clk, const struct pbl_clk *parent)
 Switch a clock to another parent.
 
int pbl_clk_set_rate (const struct pbl_clk *clk, uint64_t rate_mhz)
 Set the rate of a clock.
 
int pbl_clk_assign (const struct pbl_clk_assigned *assigned)
 Switch clocks to their assigned parents, then set their assigned rates, as Linux does, for clock controller drivers.
 
void pbl_clk_notifier_register (struct pbl_clk_notifier *nb)
 Call a function whenever the rate of a clock changes.