summaryrefslogtreecommitdiff
path: root/include/sbi/sbi_timer.h
AgeCommit message (Collapse)Author
2026-05-09lib: sbi_timer: Introduce sbi_timer_compute_delta() and friendsAnup Patel
The users of timer event have to compute next_event (aka timer value in the future) based on desired units and unit frequency. Introduce sbi_timer_compute_delta() and friends to simplify computing next_event for timer event users. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-09lib: sbi_timer: Add support for timer eventsAnup Patel
Currently, the sbi_timer only supports timer events configured via SBI calls. Introduce struct sbi_timer_event and related functions to allow configuring timer events from any part of OpenSBI. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2024-11-05lib: sbi_timer: Call driver warm_init from SBI coreSamuel Holland
Currently, the platform's timer device is tracked in two places: the core SBI implementation has `timer_dev`, and the FDT timer layer has `current_driver`. The latter is used for warm initialization of the timer device. However, this warm init is not specific to FDT-based platforms; other platforms call exactly the same functions from the same point in the boot sequence. The code is simplified and made common across platforms by treating warm init and exit as properties of the driver, not the platform. Then the platform's only role is to select and prepare a driver during cold boot. For now, only add a .warm_init hook, since none of the existing drivers need an .exit hook. It could be added in the future if needed. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-09-20lib: sbi: Fix writes to emulated 32-bit htimedelta CSRSamuel Holland
Writes to the low half CSR should not affect the high half of the value. Make this separation explicit by writing to the delta in memory as two adjacent XLEN-sized values. Fixes: 1e9f88889f8b ("lib: Emulate HTIMEDELTA CSR for platforms not having TIME CSR") Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-07-08lib: sbi_timer: Added a conditional wait function which can timeoutAdnan Rahman Chowdhury
Motivation: Suppose a peripheral needs to be configured to transmit data. There is an SFR bit which indicates that the peripheral is ready to transmit. The firmware should check the bit and will only transmit data when the peripheral is ready. When the firmware starts polling the SFR, the peripheral could be busy transmitting/receiving other data so the firmware must wait till that completes. Assuming that there is no other way, the firmware shouldn't wait indefinitely. The function sbi_timer_waitms_until() will constantly check whether a certain condition is satisfied, or timeout occurs. It can be used for the cases when a timeout is required. Signed-off-by: Adnan Rahman Chowdhury <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2021-09-26lib: sbi: Add generic timer delay loop functionAnup Patel
We now have frequency of the timer device provided by the platform support so we can emulate desired delay using a loop where the number loop iterations are based on timer frequency. This patch provides sbi_timer_delay_loop() for above purpose. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Xiang W <[email protected]>
2021-09-26lib: sbi: Add timer frequency to struct sbi_timer_deviceAnup Patel
Generic mdelay() and udelay() functions can be provided by the sbi_timer framework if timer frequency is available in the timer instance provided by the platform support or timer driver. This patch adds timer frequency (timer_freq) member in the struct sbi_timer_device for above purpose. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Xiang W <[email protected]>
2021-04-28lib: sbi: Simplify timer platform operationsAnup Patel
Instead of having timer_value(), timer_event_start(), and timer_event_stop() callbacks in platform operations, it will be much simpler for timer driver to directly register these operations as device to the sbi_timer implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]>
2020-03-28include: sbi_timer: Remove scratch parameter from most funcitonsAnup Patel
This patch removes scratch parameter from most sbi_timer functions. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-01-07lib: Add timer exit APIAnup Patel
We add sbi_timer_exit() API for OpenSBI exit path handling in sbi_exit() implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2019-09-30lib: Emulate HTIMEDELTA CSR for platforms not having TIME CSRAnup Patel
For platforms not having TIME CSR, we trap-n-emulate TIME CSR read/write in OpenSBI. Same rationale applies to HTIMEDELTA CSR as well so we trap-n-emulate HTIMEDELTA CSR for platforms not having TIME CSR. Signed-off-by: Anup Patel <[email protected]>
2019-01-24all: Update copyright header in all filesAnup patel
This patch updates copyright header in all files as follows: 1. Makes "SPDX-License-Identifier: BSD-2-Clause" as first line 2. Change copyright year to 2019 for Western Digital Signed-off-by: Anup Patel <[email protected]>
2019-01-23lib: Remove target_hart and hartid parameter from TIMER callbacksAnup Patel
The target_hart and hartid paramter of TIMER callbacks is not required because it always current hartid which can be obtained using sbi_current_hartid() API. Signed-off-by: Anup Patel <[email protected]>
2018-12-27lib: Simplify sbi_platform timer_init() hooksAnup Patel
Instead of having separate timer_init() hooks for cold and warm boot, this patch updates struct sbi_platform to have just one timer_init() hook. The type of boot (cold or warm) is now a boolean flag parameter for the updated timer_init() hook. Signed-off-by: Anup Patel <[email protected]>
2018-12-11Initial commit.Anup Patel
Signed-off-by: Anup Patel <[email protected]>