summaryrefslogtreecommitdiff
path: root/arch/arm/include/asm/arch-sunxi/dram.h
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-12-08 13:38:21 +0100
committerHans de Goede <hdegoede@redhat.com>2015-01-14 14:56:37 +0100
commit07f4fe7d7d94b03204dabd40b548bed4f796894c (patch)
treed6f5cf88a708b2bf6e9e617fe44636d0b2fa3e13 /arch/arm/include/asm/arch-sunxi/dram.h
parent1aac47bd1bf8f1f4a5f12bf7c8e06a18e5b649b4 (diff)
downloadu-boot-imx-07f4fe7d7d94b03204dabd40b548bed4f796894c.zip
u-boot-imx-07f4fe7d7d94b03204dabd40b548bed4f796894c.tar.gz
u-boot-imx-07f4fe7d7d94b03204dabd40b548bed4f796894c.tar.bz2
sunxi: Move await_completion dram helper to dram.h
The await_completion helper is already copy pasted between the sun4i and sun6i dram code, and we need it for sun8i too, so lets make it an inline helper in dram.h, rather then adding yet another copy. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Ian Campbell <ijc@hellion.org.uk>
Diffstat (limited to 'arch/arm/include/asm/arch-sunxi/dram.h')
-rw-r--r--arch/arm/include/asm/arch-sunxi/dram.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/arm/include/asm/arch-sunxi/dram.h b/arch/arm/include/asm/arch-sunxi/dram.h
index 9072e68..18924f5 100644
--- a/arch/arm/include/asm/arch-sunxi/dram.h
+++ b/arch/arm/include/asm/arch-sunxi/dram.h
@@ -12,6 +12,7 @@
#ifndef _SUNXI_DRAM_H
#define _SUNXI_DRAM_H
+#include <asm/io.h>
#include <linux/types.h>
/* dram regs definition */
@@ -23,4 +24,17 @@
unsigned long sunxi_dram_init(void);
+/*
+ * Wait up to 1s for value to be set in given part of reg.
+ */
+static inline void mctl_await_completion(u32 *reg, u32 mask, u32 val)
+{
+ unsigned long tmo = timer_get_us() + 1000000;
+
+ while ((readl(reg) & mask) != val) {
+ if (timer_get_us() > tmo)
+ panic("Timeout initialising DRAM\n");
+ }
+}
+
#endif /* _SUNXI_DRAM_H */