mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-16 14:08:45 +00:00
timer: mtk_timer: initialize the timer before use
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>
This commit is contained in:
parent
97bf73762f
commit
63779b2407
1 changed files with 10 additions and 0 deletions
|
@ -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,
|
||||
priv->base + MTK_GPT4_CTRL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue