Skip to content

Commit eb4d0a9

Browse files
kv2019ilgirdwood
authored andcommitted
zephyr: rtos: implement wait_delay variants with k_busy_wait
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 <kai.vehmanen@linux.intel.com>
1 parent 85e876c commit eb4d0a9

1 file changed

Lines changed: 5 additions & 17 deletions

File tree

zephyr/include/rtos/wait.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,22 @@
1111
#include <stdint.h>
1212
#include <stdbool.h>
1313
#include <zephyr/kernel.h>
14+
#include <zephyr/sys/time_units.h>
1415
#include <rtos/timer.h>
1516

16-
/* TODO: use equivalent Zephyr */
17-
static inline void idelay(int n)
17+
static inline void wait_delay_us(uint64_t us)
1818
{
19-
while (n--)
20-
__asm__ volatile("nop");
19+
k_busy_wait(us);
2120
}
2221

23-
/* DSP default delay in cycles - all platforms use this today */
24-
#define PLATFORM_DEFAULT_DELAY 12
25-
2622
static inline void wait_delay(uint64_t number_of_clks)
2723
{
28-
uint64_t timeout = sof_cycle_get_64() + number_of_clks;
29-
30-
while (sof_cycle_get_64() < timeout)
31-
idelay(PLATFORM_DEFAULT_DELAY);
24+
k_busy_wait(k_cyc_to_us_floor64(number_of_clks));
3225
}
3326

3427
static inline void wait_delay_ms(uint64_t ms)
3528
{
36-
wait_delay(k_ms_to_cyc_ceil64(ms));
37-
}
38-
39-
static inline void wait_delay_us(uint64_t us)
40-
{
41-
wait_delay(k_us_to_cyc_ceil64(us));
29+
k_busy_wait(ms * 1000);
4230
}
4331

4432
int poll_for_register_delay(uint32_t reg, uint32_t mask,

0 commit comments

Comments
 (0)