From: Kever Yang <kever.yang@rock-chips.com>
To: Stefan Roese <sr@denx.de>, u-boot@lists.denx.de
Cc: sjg@chromium.org, trini@konsulko.com,
Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Subject: Re: [PATCH 06/10] timer: rockchip_timer: Add timer_early functions
Date: Sat, 24 Sep 2022 15:57:03 +0800 [thread overview]
Message-ID: <d3409016-78a4-e159-7b19-bad062559184@rock-chips.com> (raw)
In-Reply-To: <20220921140625.999002-7-sr@denx.de>
On 2022/9/21 22:06, Stefan Roese wrote:
> Currently this timer driver provides timer_get_boot_us() to support the
> BOOTSTAGE functionality. This patch adds the timer_early functions so
> that the "normal" timer functions can be used, when CONFIG_TIMER_EARLY
> is enabled.
>
> timer_get_boot_us() will get removed in a follow-up patch, once the
> BOOTSTAGE interface is migrated to timer_get_us().
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Thanks,
- Kever
> ---
> drivers/timer/rockchip_timer.c | 50 ++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/drivers/timer/rockchip_timer.c b/drivers/timer/rockchip_timer.c
> index 62eacb986890..6e3483edce72 100644
> --- a/drivers/timer/rockchip_timer.c
> +++ b/drivers/timer/rockchip_timer.c
> @@ -87,6 +87,56 @@ ulong timer_get_boot_us(void)
> }
> #endif
>
> +static u64 timer_early_get_count_rate(uint32_t *rate)
> +{
> + uint64_t ticks = 0;
> +
> + *rate = 1;
> + if (CONFIG_IS_ENABLED(OF_REAL)) {
> + /* We have been called so early that the DM is not ready,... */
> + ofnode node = offset_to_ofnode(-1);
> + struct rk_timer *timer = NULL;
> +
> + /*
> + * ... so we try to access the raw timer, if it is specified
> + * via the tick-timer property in /chosen.
> + */
> + node = ofnode_get_chosen_node("tick-timer");
> + if (!ofnode_valid(node)) {
> + debug("%s: no /chosen/tick-timer\n", __func__);
> + return 0;
> + }
> +
> + timer = (struct rk_timer *)ofnode_get_addr(node);
> +
> + /* This timer is down-counting */
> + ticks = ~0ULL - rockchip_timer_get_curr_value(timer);
> + if (ofnode_read_u32(node, "clock-frequency", rate)) {
> + debug("%s: could not read clock-frequency\n", __func__);
> + return 0;
> + }
> + } else {
> + return 0;
> + }
> +
> + return ticks;
> +}
> +
> +unsigned long notrace timer_early_get_rate(void)
> +{
> + uint32_t rate;
> +
> + timer_early_get_count_rate(&rate);
> + return rate;
> +}
> +
> +u64 notrace timer_early_get_count(void)
> +{
> + uint32_t rate;
> +
> + return timer_early_get_count_rate(&rate);
> +}
> +
> static u64 rockchip_timer_get_count(struct udevice *dev)
> {
> struct rockchip_timer_priv *priv = dev_get_priv(dev);
next prev parent reply other threads:[~2022-09-24 7:57 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-21 14:06 [PATCH 00/10] bootstage: Migrate from timer_get_boot_us() to timer_get_us() Stefan Roese
2022-09-21 14:06 ` [PATCH 01/10] arm: arch_timer: Add timer_early functions Stefan Roese
2022-09-25 14:15 ` Simon Glass
2022-09-21 14:06 ` [PATCH 02/10] arm: imx: syscounter: " Stefan Roese
2022-09-25 14:15 ` Simon Glass
2022-09-21 14:06 ` [PATCH 03/10] arm: armv8: generic_timer: " Stefan Roese
2022-09-25 14:15 ` Simon Glass
2022-09-21 14:06 ` [PATCH 04/10] timer: cadence-ttc: " Stefan Roese
2022-09-25 14:15 ` Simon Glass
2022-09-26 14:11 ` Stefan Roese
2022-09-28 1:54 ` Simon Glass
2022-09-30 12:02 ` Michal Simek
2022-09-30 13:45 ` Stefan Roese
2022-10-04 11:49 ` Michal Simek
2022-10-04 14:54 ` Stefan Roese
2022-10-04 16:29 ` Simon Glass
2022-10-05 6:59 ` Michal Simek
2022-09-21 14:06 ` [PATCH 05/10] timer: omap-timer: " Stefan Roese
2022-09-21 14:06 ` [PATCH 06/10] timer: rockchip_timer: " Stefan Roese
2022-09-24 7:57 ` Kever Yang [this message]
2022-09-21 14:06 ` [PATCH 07/10] board_f/r: Allow selection of CONFIG_TIMER_EARLY w/o CONFIG_TIMER Stefan Roese
2022-09-25 14:15 ` Simon Glass
2022-09-26 13:52 ` Stefan Roese
2022-09-28 1:54 ` Simon Glass
2022-09-30 5:36 ` Stefan Roese
2022-09-30 13:28 ` Simon Glass
2022-09-30 13:52 ` Stefan Roese
2022-09-21 14:06 ` [PATCH 08/10] board_f/r: Don't call timer_init() when TIMER is enabled Stefan Roese
2022-09-21 14:06 ` [PATCH 09/10] bootstage: Migrate from timer_get_boot_us() to timer_get_us() Stefan Roese
2022-09-28 10:20 ` Simon Glass
2022-09-30 11:30 ` Michal Simek
2022-09-21 14:06 ` [PATCH 10/10] bootstage/timer: Treewide remove timer_get_boot_us() Stefan Roese
2022-09-25 14:15 ` Simon Glass
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=d3409016-78a4-e159-7b19-bad062559184@rock-chips.com \
--to=kever.yang@rock-chips.com \
--cc=philipp.tomsich@theobroma-systems.com \
--cc=sjg@chromium.org \
--cc=sr@denx.de \
--cc=trini@konsulko.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