Skip to content

Commit

Permalink
zephyr: rtos: implement wait_delay variants with k_busy_wait
Browse files Browse the repository at this point in the history
Implement wait_delay*() variants with k_busy_wait(). If some
target requires to customize the busy wait implementation,
this can be done with Zephyr CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT.

Remove idelay() as this is no longer used in generic SOF code.

Signed-off-by: Kai Vehmanen <[email protected]>
  • Loading branch information
kv2019i authored and lgirdwood committed Nov 18, 2024
1 parent 85e876c commit eb4d0a9
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions zephyr/include/rtos/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,22 @@
#include <stdint.h>
#include <stdbool.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/time_units.h>
#include <rtos/timer.h>

/* TODO: use equivalent Zephyr */
static inline void idelay(int n)
static inline void wait_delay_us(uint64_t us)
{
while (n--)
__asm__ volatile("nop");
k_busy_wait(us);
}

/* DSP default delay in cycles - all platforms use this today */
#define PLATFORM_DEFAULT_DELAY 12

static inline void wait_delay(uint64_t number_of_clks)
{
uint64_t timeout = sof_cycle_get_64() + number_of_clks;

while (sof_cycle_get_64() < timeout)
idelay(PLATFORM_DEFAULT_DELAY);
k_busy_wait(k_cyc_to_us_floor64(number_of_clks));
}

static inline void wait_delay_ms(uint64_t ms)
{
wait_delay(k_ms_to_cyc_ceil64(ms));
}

static inline void wait_delay_us(uint64_t us)
{
wait_delay(k_us_to_cyc_ceil64(us));
k_busy_wait(ms * 1000);
}

int poll_for_register_delay(uint32_t reg, uint32_t mask,
Expand Down

0 comments on commit eb4d0a9

Please sign in to comment.