[PATCH 04/15] ARM: Add arm64 pbl udelay

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 arch/arm/lib64/Makefile |  2 +-
 arch/arm/lib64/pbl.c    | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/lib64/pbl.c

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);
+}
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux