Clock source and clock event devices the kernel keeps time with.
More...
Clock source and clock event devices the kernel keeps time with.
A clock source is a free-running counter: the kernel reads it to know how much time passed, extending it to 64 bits. A clock event device raises an interrupt after a given number of its cycles, once: the kernel programs it for the next tick while threads run, and for the next timeout when the CPU idles. Drivers know nothing about ticks.
The system clock source and clock event device are pbl_system_clocksource and pbl_system_clockevent, defined by the timer drivers of the SoC; one device may provide both. The kernel initializes them when the scheduler starts, or earlier through pbl_device_init(). Both must keep running in every idle state the SoC enters.
}
static void prv_set_next(
const struct pbl_clockevent *ce, uint32_t delta) {
}
static void prv_isr(void) {
}
Clock event device: a one-shot timer interrupt.
Definition timer.h:73
Clock source: a free-running counter.
Definition timer.h:52
void pbl_clockevent_handler(const struct pbl_clockevent *ce)
Report a clock event.
static uint32_t pbl_readl(uintptr_t addr)
Read a 32-bit register.
Definition mmio.h:67
static void pbl_writel(uint32_t val, uintptr_t addr)
Write a 32-bit register.
Definition mmio.h:97
◆ 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, |
|
|
|
_ops, |
|
|
|
_min, |
|
|
|
_max |
|
) |
| |
Value: { \
.ops = (_ops), \
.min_delta = (_min), \
.max_delta = (_max), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _deps, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:123
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(). |
| _ops | Driver operations. |
| _min | Shortest delay, in cycles. |
| _max | Longest delay, in cycles. |
◆ PBL_CLOCKSOURCE_INIT
| #define PBL_CLOCKSOURCE_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_init, |
|
|
|
_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. |
◆ pbl_system_clockevent
The system clock event device, defined by the SoC's timer driver.
◆ pbl_system_clocksource
The system clock source, defined by the SoC's timer driver.