From: Sascha Hauer <sha@pengutronix.de>
To: Renaud Barbier <Renaud.Barbier@ametek.com>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: Subject: [PATCH 1/1] ARM:lib32: add architected timer
Date: Thu, 9 Mar 2023 11:48:08 +0100 [thread overview]
Message-ID: <20230309104808.GA5784@pengutronix.de> (raw)
In-Reply-To: <BL0PR07MB566565603B9BFC2D40141142ECB79@BL0PR07MB5665.namprd07.prod.outlook.com>
On Tue, Mar 07, 2023 at 04:17:08PM +0000, Renaud Barbier wrote:
> In preparation for the introduction of the LS1021A support,
> add a specific timer support based on the LS1046A support so
> that delays can be used in the PBL.
>
> Signed-off-by: Renaud Barbier <renaud.barbier@ametek.com>
> ---
> arch/arm/lib32/Makefile | 2 ++
> arch/arm/lib32/arm_architected_timer.c | 17 +++++++++++++++++
> include/clock.h | 2 ++
> 3 files changed, 21 insertions(+)
> create mode 100644 arch/arm/lib32/arm_architected_timer.c
Applied, thanks
Sascha
>
> diff --git a/arch/arm/lib32/Makefile b/arch/arm/lib32/Makefile
> index 82507fffc0..d54fb7644c 100644
> --- a/arch/arm/lib32/Makefile
> +++ b/arch/arm/lib32/Makefile
> @@ -31,6 +31,8 @@ extra-y += barebox.lds
> pbl-y += lib1funcs.o
> pbl-y += ashldi3.o
> pbl-y += div0.o
> +pbl-$(CONFIG_CPU_32v7) += arm_architected_timer.o
> +CFLAGS_arm_architected_timer.o := -march=armv7-a
>
> obj-pbl-y += setjmp.o
>
> diff --git a/arch/arm/lib32/arm_architected_timer.c b/arch/arm/lib32/arm_architected_timer.c
> new file mode 100644
> index 0000000000..54eca13f8b
> --- /dev/null
> +++ b/arch/arm/lib32/arm_architected_timer.c
> @@ -0,0 +1,17 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <asm/system.h>
> +#include <clock.h>
> +#include <common.h>
> +
> +/* Unlike the ARMv8, the timer is not generic to ARM32 */
> +void arm_architected_timer_udelay(unsigned long us)
> +{
> + unsigned long long ticks, cntfrq = get_cntfrq();
> + unsigned long long start = get_cntpct();
> +
> + ticks = DIV_ROUND_DOWN_ULL((us * cntfrq), 1000000);
> +
> + while ((long)(start + ticks - get_cntpct()) > 0)
> + ;
> +}
> diff --git a/include/clock.h b/include/clock.h
> index e6197e7eb0..8e07c35d37 100644
> --- a/include/clock.h
> +++ b/include/clock.h
> @@ -35,6 +35,8 @@ uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant);
> int is_timeout(uint64_t start_ns, uint64_t time_offset_ns);
> int is_timeout_non_interruptible(uint64_t start_ns, uint64_t time_offset_ns);
>
> +void arm_architected_timer_udelay(unsigned long us);
> +
> void ndelay(unsigned long nsecs);
> void udelay(unsigned long usecs);
> void mdelay(unsigned long msecs);
> --
> 2.27.0
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2023-03-09 10:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 16:17 Renaud Barbier
2023-03-09 10:48 ` Sascha Hauer [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-03-03 17:05 Renaud Barbier
2023-03-03 17:31 ` Ahmad Fatoum
2023-03-04 14:14 ` Sascha Hauer
2023-03-06 13:13 ` Renaud Barbier
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=20230309104808.GA5784@pengutronix.de \
--to=sha@pengutronix.de \
--cc=Renaud.Barbier@ametek.com \
--cc=barebox@lists.infradead.org \
/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