summaryrefslogtreecommitdiff
path: root/arch/arm/imx-common/timer.c
diff options
context:
space:
mode:
authorPeng Fan <van.freenix@gmail.com>2016-08-25 19:03:17 +0200
committerStefano Babic <sbabic@denx.de>2016-10-17 09:04:43 +0200
commit436baaa2f58b06dded81388853d0ae1277af5bbe (patch)
tree41fb88f7d8ec8284a58acc713f49372aff29280e /arch/arm/imx-common/timer.c
parent6e1f4d2652e79c5afc3a2b1411ff261bc355bdcb (diff)
arm: imx-common: introduce back usec2ticks
This commit "2bb014820c49a63902103bac710bc86b5772e843" do some clean up to use the code in lib/time.c. But usec2ticks is still being used by security related job ring code. Bring back the function to avoid build break when CONFIG_FSL_CAAM is defined. The computation logic has been changed, using 64-bit variable to ease the process, making it work on older (MX5) platforms. Signed-off-by: Peng Fan <van.freenix@gmail.com> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
Diffstat (limited to 'arch/arm/imx-common/timer.c')
-rw-r--r--arch/arm/imx-common/timer.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/arm/imx-common/timer.c b/arch/arm/imx-common/timer.c
index fb1b693161..1f7c671ebe 100644
--- a/arch/arm/imx-common/timer.c
+++ b/arch/arm/imx-common/timer.c
@@ -120,3 +120,19 @@ ulong get_tbclk(void)
{
return gpt_get_clk();
}
+
+/*
+ * This function is intended for SHORT delays only.
+ * It will overflow at around 10 seconds @ 400MHz,
+ * or 20 seconds @ 200MHz.
+ */
+unsigned long usec2ticks(unsigned long _usec)
+{
+ unsigned long long usec = _usec;
+
+ usec *= get_tbclk();
+ usec += 999999;
+ do_div(usec, 1000000);
+
+ return usec;
+}