Interface for clock source and clock event drivers.
More...
|
| #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.
|
| |
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.
◆ pbl_clocksource
Clock source: a free-running counter.
◆ 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. |
◆ PBL_CLOCKEVENT_INIT
| #define PBL_CLOCKEVENT_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_init, |
|
|
|
_parent, |
|
|
|
_ops, |
|
|
|
_min, |
|
|
|
_max |
|
) |
| |
Value: { \
.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
-
| sym | Symbol of the device instance, with its state defined by PBL_DEVICE_STATE_DEFINE(). |
| _name | Name. |
| _init | Init function, which must set the rate with pbl_clockevent_set_hz(). |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
| _min | Shortest delay, in cycles. |
| _max | Longest delay, in cycles. |
◆ PBL_CLOCKSOURCE_INIT
| #define PBL_CLOCKSOURCE_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_init, |
|
|
|
_parent, |
|
|
|
_ops, |
|
|
|
_bits |
|
) |
| |
Value: { \
.ops = (_ops), \
.mask = (uint32_t)((1ULL << (_bits)) - 1U), \
}
Clock source initializer.
- Parameters
-
◆ pbl_clockevent_handler()
Report a clock event.
Called by the driver from its interrupt handler.
- Parameters
-
◆ 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
-
| ce | Clock event device. |
| hz | Rate 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
-
| cs | Clock source. |
| hz | Counter 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
-
| cs | Clock source. |
| mhz | Counter rate, in millihertz. |