summaryrefslogtreecommitdiff
path: root/chip/ish/dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'chip/ish/dma.c')
-rw-r--r--chip/ish/dma.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/chip/ish/dma.c b/chip/ish/dma.c
index eae6a850f1..48a27a0463 100644
--- a/chip/ish/dma.c
+++ b/chip/ish/dma.c
@@ -7,12 +7,34 @@
#include "common.h"
#include "console.h"
-#include "ish_dma.h"
#include "registers.h"
+#include "ish_dma.h"
#include "util.h"
static int dma_init_called; /* If ish_dma_init is called */
+static int dma_poll(uint32_t addr, uint32_t expected, uint32_t mask)
+{
+ int retval = -1;
+ uint32_t counter = 0;
+
+ /*
+ * The timeout is approximately 2.2 seconds according to
+ * value of UINT32_MAX, 120MHZ ISH clock frequency and
+ * instruction count which is around 4.
+ */
+ while (counter < (UINT32_MAX / 64)) {
+ /* test condition */
+ if ((REG32(addr) & mask) == expected) {
+ retval = DMA_RC_OK;
+ break;
+ }
+ counter++;
+ }
+
+ return retval;
+}
+
void ish_dma_ocp_timeout_disable(void)
{
if (!IS_ENABLED(CONFIG_ISH_NEW_PM)) {
@@ -22,6 +44,24 @@ void ish_dma_ocp_timeout_disable(void)
}
}
+static inline uint32_t interrupt_lock(void)
+{
+ uint32_t eflags = 0;
+ __asm__ volatile("pushfl;" /* save eflag value */
+ "popl %0;"
+ "cli;"
+ : "=r"(eflags)); /* shut off interrupts */
+ return eflags;
+}
+
+static inline void interrupt_unlock(uint32_t eflags)
+{
+ __asm__ volatile("pushl %0;" /* restore elfag values */
+ "popfl;"
+ :
+ : "r"(eflags));
+}
+
void dma_configure_psize(void)
{
/* Give chan0 512 bytes for high performance, and chan1 128 bytes. */