From: Patrick Delaunay <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/7] clk: stm32mp1: recalculate counter when switching freq
Date: Wed, 30 Jan 2019 13:07:03 +0100 [thread overview]
Message-ID: <1548850026-31746-5-git-send-email-patrick.delaunay@st.com> (raw)
In-Reply-To: <1548850026-31746-1-git-send-email-patrick.delaunay@st.com>
Because stgen is initialized with HSI clock, we need to
recalculate the counter when changing frequency.
Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
drivers/clk/clk_stm32mp1.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c
index 5f2b2f1..ca98e0b 100644
--- a/drivers/clk/clk_stm32mp1.c
+++ b/drivers/clk/clk_stm32mp1.c
@@ -1471,10 +1471,15 @@ static void stgen_config(struct stm32mp1_clk_priv *priv)
rate = stm32mp1_clk_get(priv, p);
if (cntfid0 != rate) {
+ u64 counter;
+
pr_debug("System Generic Counter (STGEN) update\n");
clrbits_le32(stgenc + STGENC_CNTCR, STGENC_CNTCR_EN);
- writel(0x0, stgenc + STGENC_CNTCVL);
- writel(0x0, stgenc + STGENC_CNTCVU);
+ counter = (u64)readl(stgenc + STGENC_CNTCVL);
+ counter |= ((u64)(readl(stgenc + STGENC_CNTCVU))) << 32;
+ counter = lldiv(counter * (u64)rate, cntfid0);
+ writel((u32)counter, stgenc + STGENC_CNTCVL);
+ writel((u32)(counter >> 32), stgenc + STGENC_CNTCVU);
writel(rate, stgenc + STGENC_CNTFID0);
setbits_le32(stgenc + STGENC_CNTCR, STGENC_CNTCR_EN);
--
2.7.4
next prev parent reply other threads:[~2019-01-30 12:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-30 12:06 [U-Boot] [PATCH 0/7] stm32mp1: update clock driver Patrick Delaunay
2019-01-30 12:07 ` [U-Boot] [PATCH 1/7] clk: stm32mp1: no more get ck_usbo_48m in device tree Patrick Delaunay
2019-02-10 13:08 ` [U-Boot] [U-Boot, " Tom Rini
2019-01-30 12:07 ` [U-Boot] [PATCH 2/7] clk: stm32mp1: add IPCC clock Patrick Delaunay
2019-02-10 13:08 ` [U-Boot] [U-Boot,2/7] " Tom Rini
2019-01-30 12:07 ` [U-Boot] [PATCH 3/7] clk: stm32mp1: correct access to RCC_OCENSETR/RCC_OCENCLRR Patrick Delaunay
2019-02-10 13:09 ` [U-Boot] [U-Boot, " Tom Rini
2019-02-10 13:09 ` Tom Rini
2019-01-30 12:07 ` Patrick Delaunay [this message]
2019-02-10 13:09 ` [U-Boot] [U-Boot, 4/7] clk: stm32mp1: recalculate counter when switching freq Tom Rini
2019-01-30 12:07 ` [U-Boot] [PATCH 5/7] clk: stm32mp1: add debug information Patrick Delaunay
2019-02-10 13:09 ` [U-Boot] [U-Boot,5/7] " Tom Rini
2019-01-30 12:07 ` [U-Boot] [PATCH 6/7] dts: stm32mp1: clock tree update Patrick Delaunay
2019-02-10 13:09 ` [U-Boot] [U-Boot,6/7] " Tom Rini
2019-01-30 12:07 ` [U-Boot] [PATCH 7/7] clk: stm32mp1: correctly handle Clock Spreading Generator Patrick Delaunay
2019-02-10 13:09 ` [U-Boot] [U-Boot, " 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=1548850026-31746-5-git-send-email-patrick.delaunay@st.com \
--to=patrick.delaunay@st.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