public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Gary Bisson <gary.bisson@boundarydevices.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] arm: imx-common: introduce back usec2ticks
Date: Tue, 23 Aug 2016 23:55:20 +0200	[thread overview]
Message-ID: <1471989321-25280-3-git-send-email-gary.bisson@boundarydevices.com> (raw)
In-Reply-To: <1471989321-25280-1-git-send-email-gary.bisson@boundarydevices.com>

From: Peng Fan <van.freenix@gmail.com>

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>
---
 arch/arm/imx-common/timer.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/imx-common/timer.c b/arch/arm/imx-common/timer.c
index a01590c..a04c7ae 100644
--- a/arch/arm/imx-common/timer.c
+++ b/arch/arm/imx-common/timer.c
@@ -119,3 +119,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;
+}
-- 
2.8.1

  parent reply	other threads:[~2016-08-23 21:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23 21:55 [U-Boot] [PATCH 0/3] Add i.MX HAB encryption support Gary Bisson
2016-08-23 21:55 ` [U-Boot] [PATCH 1/3] arm: imx-common: add SECURE_BOOT option to Kconfig Gary Bisson
2016-08-24  0:24   ` Eric Nelson
2016-08-24 10:12     ` Gary Bisson
2016-08-24 13:13       ` Eric Nelson
2016-08-23 21:55 ` Gary Bisson [this message]
2016-08-24  0:30   ` [U-Boot] [PATCH 2/3] arm: imx-common: introduce back usec2ticks Eric Nelson
2016-08-24 10:15     ` Gary Bisson
2016-08-23 21:55 ` [U-Boot] [PATCH 3/3] nitrogen6x: add secure boot support Gary Bisson
2016-08-24  0:35   ` Eric Nelson
2016-08-24 10:17     ` Gary Bisson
2016-08-25 16:22       ` Fabio Estevam
2016-08-25 17:03 ` [U-Boot] [PATCH v2 0/5] Add i.MX HAB encryption support Gary Bisson
2016-08-25 17:03   ` [U-Boot] [PATCH v2 1/5] arm: imx-common: add SECURE_BOOT option to Kconfig Gary Bisson
2016-08-25 17:03   ` [U-Boot] [PATCH v2 2/5] arm: imx-common: introduce back usec2ticks Gary Bisson
2016-08-25 17:03   ` [U-Boot] [PATCH v2 3/5] mx6_common: add secure boot support Gary Bisson
2016-08-25 17:03   ` [U-Boot] [PATCH v2 4/5] mx7_common: " Gary Bisson
2016-08-25 17:03   ` [U-Boot] [PATCH v2 5/5] nitrogen6x: " Gary Bisson
2016-10-17  7:09   ` [U-Boot] [PATCH v2 0/5] Add i.MX HAB encryption support Stefano Babic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1471989321-25280-3-git-send-email-gary.bisson@boundarydevices.com \
    --to=gary.bisson@boundarydevices.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox