2019-06-02 03:14:06 +08:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2016-09-21 22:57:22 +08:00
|
|
|
*
|
2019-06-02 03:14:06 +08:00
|
|
|
* Copyright(c) 2016 Intel Corporation. All rights reserved.
|
2016-09-21 22:57:22 +08:00
|
|
|
*
|
|
|
|
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
|
2019-06-02 03:14:06 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-11-10 05:24:07 +08:00
|
|
|
* Simple wait for event completion and signaling with timeouts.
|
2016-09-21 22:57:22 +08:00
|
|
|
*/
|
|
|
|
|
2022-09-01 05:19:35 +08:00
|
|
|
#ifndef __XTOS_RTOS_WAIT_H__
|
|
|
|
#define __XTOS_RTOS_WAIT_H__
|
2016-09-21 22:57:22 +08:00
|
|
|
|
2022-09-01 05:19:35 +08:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#if !CONFIG_LIBRARY
|
2019-07-17 02:31:41 +08:00
|
|
|
#include <arch/lib/wait.h>
|
2022-09-03 00:06:59 +08:00
|
|
|
#include <rtos/interrupt.h>
|
2022-09-02 20:04:14 +08:00
|
|
|
#include <rtos/timer.h>
|
2022-08-19 21:10:56 +08:00
|
|
|
#include <rtos/spinlock.h>
|
2019-07-17 02:31:41 +08:00
|
|
|
#include <sof/trace/trace.h>
|
2019-07-22 23:06:58 +08:00
|
|
|
#include <user/trace.h>
|
2020-06-12 13:47:37 +08:00
|
|
|
|
2020-04-27 00:14:15 +08:00
|
|
|
extern struct tr_ctx wait_tr;
|
|
|
|
|
2016-09-21 22:57:22 +08:00
|
|
|
static inline void wait_for_interrupt(int level)
|
|
|
|
{
|
2022-03-29 15:39:11 +08:00
|
|
|
LOG_MODULE_DECLARE(wait, CONFIG_SOF_LOG_LEVEL);
|
|
|
|
|
2020-04-27 00:14:15 +08:00
|
|
|
tr_dbg(&wait_tr, "WFE");
|
2019-07-17 19:38:39 +08:00
|
|
|
#if CONFIG_DEBUG_LOCKS
|
2019-02-14 21:34:26 +08:00
|
|
|
if (lock_dbg_atomic)
|
2020-04-27 00:14:15 +08:00
|
|
|
tr_err_atomic(&wait_tr, "atm");
|
2019-02-14 21:34:26 +08:00
|
|
|
#endif
|
2019-09-03 15:05:32 +08:00
|
|
|
platform_wait_for_interrupt(level);
|
2020-04-27 00:14:15 +08:00
|
|
|
tr_dbg(&wait_tr, "WFX");
|
2016-09-21 22:57:22 +08:00
|
|
|
}
|
|
|
|
|
2018-06-12 02:27:34 +08:00
|
|
|
/**
|
|
|
|
* \brief Waits at least passed number of clocks.
|
|
|
|
* \param[in] number_of_clks Minimum number of clocks to wait.
|
|
|
|
*/
|
2019-07-15 17:27:29 +08:00
|
|
|
void wait_delay(uint64_t number_of_clks);
|
2022-01-28 23:14:46 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Waits at least passed number of milliseconds.
|
|
|
|
* \param[in] ms Minimum number of milliseconds to wait.
|
|
|
|
*/
|
|
|
|
void wait_delay_ms(uint64_t ms);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Waits at least passed number of microseconds.
|
|
|
|
* \param[in] us Minimum number of microseconds to wait.
|
|
|
|
*/
|
|
|
|
void wait_delay_us(uint64_t us);
|
2021-08-04 22:14:18 +08:00
|
|
|
#else
|
|
|
|
static inline void wait_delay(uint64_t number_of_clks) {}
|
2022-01-28 23:14:46 +08:00
|
|
|
static inline void wait_delay_ms(uint64_t ms) {}
|
|
|
|
static inline void wait_delay_us(uint64_t us) {}
|
2021-08-04 22:14:18 +08:00
|
|
|
#endif
|
2018-06-12 02:27:34 +08:00
|
|
|
|
2019-02-14 21:34:26 +08:00
|
|
|
int poll_for_register_delay(uint32_t reg, uint32_t mask,
|
|
|
|
uint32_t val, uint64_t us);
|
2018-09-17 17:22:45 +08:00
|
|
|
|
2022-09-01 05:19:35 +08:00
|
|
|
#endif /* __XTOS_RTOS_WAIT_H__ */
|