From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gary Bisson Date: Tue, 23 Aug 2016 23:55:20 +0200 Subject: [U-Boot] [PATCH 2/3] arm: imx-common: introduce back usec2ticks In-Reply-To: <1471989321-25280-1-git-send-email-gary.bisson@boundarydevices.com> References: <1471989321-25280-1-git-send-email-gary.bisson@boundarydevices.com> Message-ID: <1471989321-25280-3-git-send-email-gary.bisson@boundarydevices.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Peng Fan 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 Signed-off-by: Troy Kisky Signed-off-by: Gary Bisson --- 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