From: Matthias Brugger <matthias.bgg@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH 1/2] timer: mtk_timer: initialize the timer before use
Date: Fri, 15 Jan 2021 17:36:15 +0100 [thread overview]
Message-ID: <YAHEf/FI9vx9zw0+@ziggy.stardust> (raw)
In-Reply-To: <0dc6f5e159ec0bc471483c77192237f42dbcc646.1610424657.git.weijie.gao@mediatek.com>
On Tue, Jan 12, 2021 at 01:44:02PM +0800, Weijie Gao wrote:
> The timer being used by this driver may have already been used by first
> stage bootloader (e.g. ATF/preloader), and it's settings may differ from
> what this driver is going to use.
>
> This may cause issues, such as inaccurate timer frequency due to
> incorrect clock divider.
>
> This patch adds the initialization code to avoid them.
>
> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> ---
> drivers/timer/mtk_timer.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/timer/mtk_timer.c b/drivers/timer/mtk_timer.c
> index 448a76a7e1..f6b97f868c 100644
> --- a/drivers/timer/mtk_timer.c
> +++ b/drivers/timer/mtk_timer.c
> @@ -61,6 +61,16 @@ static int mtk_timer_probe(struct udevice *dev)
> if (!uc_priv->clock_rate)
> return -EINVAL;
>
> + /*
> + * Initialize the timer:
> + * 1. set clock source to system clock with clock divider setting to 1
> + * 2. set timer mode to free running
> + * 3. reset timer counter to 0 then enable the timer
> + */
> + writel(GPT4_CLK_SYS | GPT4_CLK_DIV1, priv->base + MTK_GPT4_CLK);
> + writel(GPT4_FREERUN | GPT4_CLEAR | GPT4_ENABLE,
GPT4_FREERUN is defined as GENMASK(5,4) while in the Linux kernel it has
the value of 3. Can you explain where this difference comes from?
Regards,
Matthias
> + priv->base + MTK_GPT4_CTRL);
> +
> return 0;
> }
>
> --
> 2.17.1
next prev parent reply other threads:[~2021-01-15 16:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 5:44 [PATCH 1/2] timer: mtk_timer: initialize the timer before use Weijie Gao
2021-01-12 5:44 ` [PATCH 2/2] dts: mt7622: use accurate clock source fot mtk_timer Weijie Gao
2021-01-19 13:06 ` Tom Rini
2021-01-15 16:36 ` Matthias Brugger [this message]
2021-01-18 0:44 ` [PATCH 1/2] timer: mtk_timer: initialize the timer before use Weijie Gao
2021-01-19 10:42 ` Matthias Brugger
2021-01-19 13:06 ` Tom Rini
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=YAHEf/FI9vx9zw0+@ziggy.stardust \
--to=matthias.bgg@kernel.org \
--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