[Sound-open-firmware] [PATCH 2/3] wait: add wait_delay routine

Liam Girdwood liam.r.girdwood at linux.intel.com
Mon Jun 11 20:58:29 CEST 2018


From: Tomasz Lauda <tomasz.lauda at linux.intel.com>

This patch adds wait_delay routine, which will wait
for specified minimum number of clocks.

Signed-off-by: Tomasz Lauda <tomasz.lauda at linux.intel.com>
---
 src/include/sof/wait.h                              | 12 ++++++++++++
 src/platform/apollolake/include/platform/platform.h |  3 +++
 src/platform/baytrail/include/platform/platform.h   |  3 +++
 src/platform/cannonlake/include/platform/platform.h |  3 +++
 src/platform/haswell/include/platform/platform.h    |  3 +++
 5 files changed, 24 insertions(+)

diff --git a/src/include/sof/wait.h b/src/include/sof/wait.h
index b7725b8..feb8b29 100644
--- a/src/include/sof/wait.h
+++ b/src/include/sof/wait.h
@@ -145,4 +145,16 @@ static inline int wait_for_completion_timeout(completion_t *comp)
 	}
 }
 
+/**
+ * \brief Waits at least passed number of clocks.
+ * \param[in] number_of_clks Minimum number of clocks to wait.
+ */
+static inline void wait_delay(uint64_t number_of_clks)
+{
+	uint64_t current = platform_timer_get(platform_timer);
+
+	while ((platform_timer_get(platform_timer) - current) < number_of_clks)
+		idelay(PLATFORM_DEFAULT_DELAY);
+}
+
 #endif
diff --git a/src/platform/apollolake/include/platform/platform.h b/src/platform/apollolake/include/platform/platform.h
index 1321f1f..ff40b1c 100644
--- a/src/platform/apollolake/include/platform/platform.h
+++ b/src/platform/apollolake/include/platform/platform.h
@@ -120,6 +120,9 @@ struct sof;
 /* number of SSP ports in platform */
 #define PLATFORM_NUM_SSP	6
 
+/* DSP default delay in cycles */
+#define PLATFORM_DEFAULT_DELAY	12
+
 /* Platform defined panic code */
 static inline void platform_panic(uint32_t p)
 {
diff --git a/src/platform/baytrail/include/platform/platform.h b/src/platform/baytrail/include/platform/platform.h
index 1defe27..0d1664c 100644
--- a/src/platform/baytrail/include/platform/platform.h
+++ b/src/platform/baytrail/include/platform/platform.h
@@ -102,6 +102,9 @@ struct sof;
 /* DSP should be idle in this time frame */
 #define PLATFORM_IDLE_TIME	750000
 
+/* DSP default delay in cycles */
+#define PLATFORM_DEFAULT_DELAY	12
+
 /* Platform defined panic code */
 static inline void platform_panic(uint32_t p)
 {
diff --git a/src/platform/cannonlake/include/platform/platform.h b/src/platform/cannonlake/include/platform/platform.h
index c7d4a82..cf045c0 100644
--- a/src/platform/cannonlake/include/platform/platform.h
+++ b/src/platform/cannonlake/include/platform/platform.h
@@ -117,6 +117,9 @@ struct sof;
 /* DSP should be idle in this time frame */
 #define PLATFORM_IDLE_TIME	750000
 
+/* DSP default delay in cycles */
+#define PLATFORM_DEFAULT_DELAY	12
+
 /* Platform defined trace code */
 static inline void platform_panic(uint32_t p)
 {
diff --git a/src/platform/haswell/include/platform/platform.h b/src/platform/haswell/include/platform/platform.h
index c5d8187..af628ee 100644
--- a/src/platform/haswell/include/platform/platform.h
+++ b/src/platform/haswell/include/platform/platform.h
@@ -101,6 +101,9 @@ struct sof;
 /* DSP should be idle in this time frame */
 #define PLATFORM_IDLE_TIME	750000
 
+/* DSP default delay in cycles */
+#define PLATFORM_DEFAULT_DELAY	12
+
 /* Platform defined panic code */
 static inline void platform_panic(uint32_t p)
 {
-- 
2.17.0



More information about the Sound-open-firmware mailing list