summaryrefslogtreecommitdiff
path: root/chip/ish/ish_dma.h
diff options
context:
space:
mode:
Diffstat (limited to 'chip/ish/ish_dma.h')
-rw-r--r--chip/ish/ish_dma.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/chip/ish/ish_dma.h b/chip/ish/ish_dma.h
index fb9c4f4f06..89d6cb7342 100644
--- a/chip/ish/ish_dma.h
+++ b/chip/ish/ish_dma.h
@@ -27,6 +27,47 @@
#define PAGE_SIZE 4096
+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));
+}
+
+static inline 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;
+}
+
/**
* SRAM: ISH local static ram
* UMA: Protected system DRAM region dedicated for ISH