Accessors for standard RISC-V platform timer (mtime/mtimecmp), available on Raspberry Pi microcontrollers with RISC-V processors. More...
Functions | |
| static void | riscv_timer_set_enabled (bool enabled) |
| Enable or disable the RISC-V platform timer. | |
| static void | riscv_timer_set_fullspeed (bool fullspeed) |
| Configure the RISC-V platform timer to run at full system clock speed. | |
| static uint64_t | riscv_timer_get_mtime (void) |
| Read the RISC-V platform timer. | |
| static void | riscv_timer_set_mtime (uint64_t mtime) |
| Update the RISC-V platform timer. | |
| static uint64_t | riscv_timer_get_mtimecmp (void) |
| Get the current RISC-V platform timer mtimecmp value for this core. | |
| static void | riscv_timer_set_mtimecmp (uint64_t mtimecmp) |
| Set a new RISC-V platform timer interrupt comparison value (mtimecmp) for this core. | |
Accessors for standard RISC-V platform timer (mtime/mtimecmp), available on Raspberry Pi microcontrollers with RISC-V processors.
Note this header can be used by Arm as well as RISC-V processors, as the timer is a memory-mapped peripheral external to the processors. The name refers to this timer being a standard RISC-V peripheral.
|
inlinestatic |
Read the RISC-V platform timer.
|
inlinestatic |
Get the current RISC-V platform timer mtimecmp value for this core.
Get the current mtimecmp value for the calling core. This function is interrupt-safe as long as timer interrupts only increase the value of mtimecmp. Otherwise, it must be called with timer interrupts disabled.
|
inlinestatic |
Enable or disable the RISC-V platform timer.
This enables and disables the counting of the RISC-V platform timer. It does not enable or disable the interrupts, which are asserted unconditionally when a given core's mtimecmp/mtimecmph registers are greater than the current 64-bit value of the mtime/mtimeh registers.
| enabled | Pass true to enable, false to disable |
|
inlinestatic |
Configure the RISC-V platform timer to run at full system clock speed.
| fullspeed | Pass true to increment at system clock speed, false to increment at the frequency defined by the system tick generator (the ticks block) |
|
inlinestatic |
Update the RISC-V platform timer.
This function should only be called when the timer is disabled via riscv_timer_set_enabled(). Note also that unlike the mtimecmp comparison values, mtime is not core-local, so updates on one core will be visible to the other core.
| mtime | New value to set the RISC-V platform timer to |
|
inlinestatic |
Set a new RISC-V platform timer interrupt comparison value (mtimecmp) for this core.
This function updates the mtimecmp value for the current core. The calling core's RISC-V platform timer interrupt is asserted whenever the 64-bit mtime value (stored in 32-bit mtime/mtimeh registers) is greater than or equal to this core's current mtime/mtimecmph value.
| mtimecmp | New value to set the RISC-V platform timer to |