From: Alex Elder <elder@riscstar.com>
To: Haylen Chu <heylenay@4d2.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Haylen Chu <heylenay@outlook.com>, Yixun Lan <dlan@gentoo.org>
Cc: linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
spacemit@lists.linux.dev, Inochi Amaoto <inochiama@outlook.com>,
Chen Wang <unicornxdotw@foxmail.com>,
Jisheng Zhang <jszhang@kernel.org>,
Meng Zhang <zhangmeng.kevin@linux.spacemit.com>,
Guodong Xu <guodong@riscstar.com>
Subject: Re: [PATCH v5 3/5] clk: spacemit: Add clock support for Spacemit K1 SoC
Date: Thu, 20 Mar 2025 17:39:13 -0500 [thread overview]
Message-ID: <84232793-9cba-4148-9875-d996e85b81be@riscstar.com> (raw)
In-Reply-To: <d625c473-789c-42f9-918c-8a649d058513@riscstar.com>
On 3/11/25 6:19 PM, Alex Elder wrote:
> On 3/6/25 11:57 AM, Haylen Chu wrote:
>> The clock tree of K1 SoC contains three main types of clock hardware
>> (PLL/DDN/MIX) and has control registers split into several multifunction
>> devices: APBS (PLLs), MPMU, APBC and APMU.
>>
>> All register operations are done through regmap to ensure atomiciy
>> between concurrent operations of clock driver and reset,
>> power-domain driver that will be introduced in the future.
>>
>> Signed-off-by: Haylen Chu <heylenay@4d2.org>
>
> I'm very glad you have the DT issues resolved now.
>
> I again have lots of comments on the code, and I think I've
> identified a few bugs. Most of my comments, however, are
> suggesting minor changes for consistency and readability.
>
> I'm going to skip over a lot of "ccu-k1.c" because most of what I
> say applies to the definitions in the header files.
FYI I encountered a problem I mentioned below.
. . .
>> +/* frequency unit Mhz, return pll vco freq */
>> +static unsigned long ccu_pll_get_vco_freq(struct clk_hw *hw)
>> +{
>> + const struct ccu_pll_rate_tbl *pll_rate_table;
>> + struct ccu_pll *p = hw_to_ccu_pll(hw);
>> + struct ccu_common *common = &p->common;
>> + u32 swcr1, swcr3, size;
>> + int i;
>> +
>> + ccu_read(swcr1, common, &swcr1);
>> + ccu_read(swcr3, common, &swcr3);
>
> You are masking off the EN bit, but you should really be
> using a mask defining which bits are valid instead. As
> I said earlier:
>
> #define SPACEMIT_PLL_SWCR3_MASK ~(SPACEMIT_PLL_SWCR3_EN)
>
>> + swcr3 &= ~PLL_SWCR3_EN;
>
> swcr3 &= SPACEMIT_PLL_SWCR3_MASK;
>> +
>> + pll_rate_table = p->pll.rate_tbl;
>> + size = p->pll.tbl_size;
>> +
>> + for (i = 0; i < size; i++) {
>> + if (pll_rate_table[i].swcr1 == swcr1 &&
>> + pll_rate_table[i].swcr3 == swcr3)
>> + return pll_rate_table[i].rate;
>> + }
>> +
>
> I have a general question here. Once you set one of these
> clock rates, it will always use one of the rates defined
> in the table.
>
> But what about initially? Could the hardware start in a
> state that is not defined by this code? Do you *set* the
> rate initially? Should you (at least the first time the
> clock is prepared/enabled)?
When doing some testing today I found that the WARN_ON_ONCE()
got called. I added some information and learned that the
values in hardware of the swcr1 and swcr3 registers were:
swcr1: 0x0050cd61
swcr3: 0x3fe00000
I'm not sure which PLL was being used.
So clearly this can happen. Somehow you need to find a way
to ensure that these registers are initialized to a sane
state (meaning one defined within pll_rate_table[]).
-Alex
>> + WARN_ON_ONCE(1);
>
> Maybe WARN_ONCE(true, "msg");. . .
next prev parent reply other threads:[~2025-03-20 22:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 17:57 [PATCH v5 0/5] Add clock controller support for SpacemiT K1 Haylen Chu
2025-03-06 17:57 ` [PATCH v5 1/5] dt-bindings: soc: spacemit: Add spacemit,k1-syscon Haylen Chu
2025-03-07 8:16 ` Krzysztof Kozlowski
2025-03-06 17:57 ` [PATCH v5 2/5] dt-bindings: clock: spacemit: Add spacemit,k1-pll Haylen Chu
2025-03-07 0:29 ` Yixun Lan
2025-03-07 6:34 ` Haylen Chu
2025-03-07 8:20 ` Krzysztof Kozlowski
2025-03-07 8:19 ` Krzysztof Kozlowski
2025-03-06 17:57 ` [PATCH v5 3/5] clk: spacemit: Add clock support for Spacemit K1 SoC Haylen Chu
2025-03-07 0:51 ` Yixun Lan
2025-03-07 6:42 ` Haylen Chu
2025-03-07 8:26 ` Krzysztof Kozlowski
2025-03-11 23:19 ` Alex Elder
2025-03-20 22:39 ` Alex Elder [this message]
2025-03-24 11:14 ` Haylen Chu
2025-03-28 14:00 ` Alex Elder
2025-03-29 10:21 ` Haylen Chu
2025-03-12 20:17 ` kernel test robot
2025-03-18 5:37 ` Yixun Lan
2025-03-18 5:43 ` Inochi Amaoto
2025-03-23 8:55 ` Haylen Chu
2025-03-06 17:57 ` [PATCH v5 4/5] clk: spacemit: k1: Add TWSI8 bus and function clocks Haylen Chu
2025-03-07 6:30 ` Haylen Chu
2025-03-06 17:57 ` [PATCH v5 5/5] riscv: dts: spacemit: Add clock tree for Spacemit K1 Haylen Chu
2025-03-07 1:55 ` Inochi Amaoto
2025-03-07 6:28 ` Haylen Chu
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=84232793-9cba-4148-9875-d996e85b81be@riscstar.com \
--to=elder@riscstar.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlan@gentoo.org \
--cc=guodong@riscstar.com \
--cc=heylenay@4d2.org \
--cc=heylenay@outlook.com \
--cc=inochiama@outlook.com \
--cc=jszhang@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mturquette@baylibre.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=spacemit@lists.linux.dev \
--cc=unicornxdotw@foxmail.com \
--cc=zhangmeng.kevin@linux.spacemit.com \
/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
all inboxes | Powered by JetHome®