summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-02-25 14:02:02 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-13 10:27:42 +0100
commit06a3cd1d1c8b0c59ca4313dfe02915f951c8b4c6 (patch)
tree5c2e3586bba81e2575695abbd2509319c2d0ed5b
parentec09152b909d88a1bd26ba125d87d74a5ca424d8 (diff)
downloadbarebox-06a3cd1d1c8b0c59ca4313dfe02915f951c8b4c6.tar.gz
barebox-06a3cd1d1c8b0c59ca4313dfe02915f951c8b4c6.tar.xz
ARM: Add arm64 pbl udelay
PBL often needs a way to udelay execution. Since we have a generic timer in ARMv8 we can implement a generic udelay. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/lib64/Makefile2
-rw-r--r--arch/arm/lib64/pbl.c17
2 files changed, 18 insertions, 1 deletions
diff --git a/arch/arm/lib64/Makefile b/arch/arm/lib64/Makefile
index 4c0019fabe..5068431342 100644
--- a/arch/arm/lib64/Makefile
+++ b/arch/arm/lib64/Makefile
@@ -6,4 +6,4 @@ obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS) += memset.o string.o
extra-y += barebox.lds
obj-pbl-y += runtime-offset.o
-pbl-y += div0.o
+pbl-y += div0.o pbl.o
diff --git a/arch/arm/lib64/pbl.c b/arch/arm/lib64/pbl.c
new file mode 100644
index 0000000000..0cef08e4d2
--- /dev/null
+++ b/arch/arm/lib64/pbl.c
@@ -0,0 +1,17 @@
+#include <asm/system.h>
+#include <clock.h>
+#include <common.h>
+
+void udelay(unsigned long us)
+{
+ unsigned long cntfrq = get_cntfrq();
+ unsigned long ticks = (us * cntfrq) / 1000000;
+ unsigned long start = get_cntpct();
+
+ while ((long)(start + ticks - get_cntpct()) > 0);
+}
+
+void mdelay(unsigned long ms)
+{
+ udelay(ms * 1000);
+}