PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
System timer drivers

Interface for clock source and clock event drivers. More...

Data Structures

struct  pbl_clocksource_ops
 Clock source operations. More...
 
struct  pbl_clocksource
 Clock source: a free-running counter. More...
 
struct  pbl_clockevent_ops
 Clock event device operations. More...
 
struct  pbl_clockevent
 Clock event device: a one-shot timer interrupt. More...
 

Macros

#define PBL_CLOCKSOURCE_INIT(sym, _name, _init, _parent, _ops, _bits)
 Clock source initializer.
 
#define PBL_CLOCKEVENT_INIT(sym, _name, _init, _parent, _ops, _min, _max)
 Clock event device initializer.
 

Functions

void pbl_clocksource_set_hz (const struct pbl_clocksource *cs, uint32_t hz)
 Set the rate of a clock source.
 
void pbl_clocksource_set_mhz (const struct pbl_clocksource *cs, uint64_t mhz)
 Set the rate of a clock source, with millihertz resolution.
 
void pbl_clockevent_set_hz (const struct pbl_clockevent *ce, uint32_t hz)
 Set the rate of a clock event device.
 
void pbl_clockevent_handler (const struct pbl_clockevent *ce)
 Report a clock event.
 

Detailed Description

Interface for clock source and clock event drivers.

A driver embeds a struct pbl_clocksource or struct pbl_clockevent in its instance, sets it up with PBL_CLOCKSOURCE_INIT() or PBL_CLOCKEVENT_INIT(), implements the operations the kernel calls, sets the rate and reports its events.


Data Structure Documentation

◆ pbl_clocksource

struct pbl_clocksource

Clock source: a free-running counter.

Data Fields
struct pbl_device dev Device.
uint32_t mask Counter mask, 2^bits - 1.
const struct pbl_clocksource_ops * ops Driver operations.

◆ pbl_clockevent

struct pbl_clockevent

Clock event device: a one-shot timer interrupt.

Data Fields
struct pbl_device dev Device.
uint32_t max_delta Longest delay the device can generate, in its cycles.
uint32_t min_delta Shortest delay the device can generate, in its cycles.
const struct pbl_clockevent_ops * ops Driver operations.

Macro Definition Documentation

◆ PBL_CLOCKEVENT_INIT

#define PBL_CLOCKEVENT_INIT (   sym,
  _name,
  _init,
  _parent,
  _ops,
  _min,
  _max 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, &pbl_clockevent_class), \
.ops = (_ops), \
.min_delta = (_min), \
.max_delta = (_max), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153

Clock event device initializer.

Parameters
symSymbol of the device instance, with its state defined by PBL_DEVICE_STATE_DEFINE().
_nameName.
_initInit function, which must set the rate with pbl_clockevent_set_hz().
_parentParent device, or NULL.
_opsDriver operations.
_minShortest delay, in cycles.
_maxLongest delay, in cycles.

◆ PBL_CLOCKSOURCE_INIT

#define PBL_CLOCKSOURCE_INIT (   sym,
  _name,
  _init,
  _parent,
  _ops,
  _bits 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, &pbl_clocksource_class), \
.ops = (_ops), \
.mask = (uint32_t)((1ULL << (_bits)) - 1U), \
}

Clock source initializer.

Parameters
symSymbol of the device instance, with its state defined by PBL_DEVICE_STATE_DEFINE().
_nameName.
_initInit function, which must set the rate with pbl_clocksource_set_hz() or pbl_clocksource_set_mhz().
_parentParent device, or NULL.
_opsDriver operations.
_bitsCounter width.

Function Documentation

◆ pbl_clockevent_handler()

void pbl_clockevent_handler ( const struct pbl_clockevent *  ce)

Report a clock event.

Called by the driver from its interrupt handler.

Parameters
ceClock event device.

◆ pbl_clockevent_set_hz()

void pbl_clockevent_set_hz ( const struct pbl_clockevent *  ce,
uint32_t  hz 
)

Set the rate of a clock event device.

Called by the driver from its init, and again whenever the rate changes.

Parameters
ceClock event device.
hzRate of the cycles the device counts delays in.

◆ pbl_clocksource_set_hz()

void pbl_clocksource_set_hz ( const struct pbl_clocksource *  cs,
uint32_t  hz 
)

Set the rate of a clock source.

Called by the driver from its init, and again whenever the rate changes, for instance after a low-power oscillator calibration. Time stays continuous across changes.

Parameters
csClock source.
hzCounter rate.

◆ pbl_clocksource_set_mhz()

void pbl_clocksource_set_mhz ( const struct pbl_clocksource *  cs,
uint64_t  mhz 
)

Set the rate of a clock source, with millihertz resolution.

As pbl_clocksource_set_hz(), for counters whose rate is not a whole number of hertz, such as a calibrated RC oscillator.

Parameters
csClock source.
mhzCounter rate, in millihertz.