From: Haylen Chu <heylenay@4d2.org>
To: Troy Mitchell <troy.mitchell@linux.spacemit.com>,
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>, Yixun Lan <dlan@gentoo.org>,
Alex Elder <elder@riscstar.com>,
Inochi Amaoto <inochiama@outlook.com>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-riscv@lists.infradead.org, spacemit@lists.linux.dev,
linux-kernel@vger.kernel.org,
Jinmei Wei <weijinmei@linux.spacemit.com>
Subject: Re: [PATCH v3 3/3] clk: spacemit: fix i2s clock
Date: Mon, 18 Aug 2025 10:04:18 +0000 [thread overview]
Message-ID: <aKL6ormE1N72fwVG@ketchup> (raw)
In-Reply-To: <20250818-k1-clk-i2s-generation-v3-3-8139b22ae709@linux.spacemit.com>
On Mon, Aug 18, 2025 at 05:28:22PM +0800, Troy Mitchell wrote:
> Defining i2s_bclk and i2s_sysclk as fixed-rate clocks is insufficient
> for real I2S use cases.
>
> Moreover, the current I2S clock configuration does not work as expected
> due to missing parent clocks.
>
> This patch adds the missing parent clocks, defines i2s_sysclk as
> a DDN clock, and i2s_bclk as a DIV clock.
>
> A special note for i2s_bclk:
>
> From the definition of register, The i2s_bclk is a non-linear,
> discrete divider clock.
No, it IS linear. It just comes with a 1/2 factor according to your code
(I'm assuming there's a typo in the table below).
> In calculus and related areas, a linear function is a function whose
> graph is a straight line, that is, a polynomial function of degree
> zero or one. (From Wikipedia)
> The following table shows the correspondence between index
> and frequency division coefficients:
>
> | index | div |
> |-------|-------|
> | 0 | 2 |
> | 1 | 4 |
> | 2 | 6 |
> | 2 | 8 |
Index = 2 appears twice in the table. Is this a typo?
> From a software perspective, introducing i2s_bclk_factor as the
> parent of i2s_bclk is sufficient to address the issue.
>
> The I2S-related clock registers can be found here [1].
>
> Link:
> https://developer.spacemit.com/documentation?token=LCrKwWDasiJuROkVNusc2pWTnEb
> [1]
>
> Fixes: 1b72c59db0add ("clk: spacemit: Add clock support for SpacemiT K1 SoC")
> Co-developer: Jinmei Wei <weijinmei@linux.spacemit.com>
> Suggested-by: Haylen Chu <heylenay@4d2.org>
> Signed-off-by: Jinmei Wei <weijinmei@linux.spacemit.com>
> Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
> ---
> drivers/clk/spacemit/ccu-k1.c | 29 +++++++++++++++++++++++++++--
> drivers/clk/spacemit/ccu_mix.h | 2 +-
> include/soc/spacemit/k1-syscon.h | 1 +
> 3 files changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
> index 7155824673fb450971439873b6b6163faf48c7e5..b2c426b629a37a9901bbced26fc55c5f1b34eba5 100644
> --- a/drivers/clk/spacemit/ccu-k1.c
> +++ b/drivers/clk/spacemit/ccu-k1.c
...
> + * i2s_bclk is a non-linear discrete divider clock.
> + * Using i2s_bclk_factor as its parent simplifies software handling
> + * and avoids dealing with the non-linear division directly.
> + */
And thus this comment is wrong and misleading. Suggest something like,
Divider of i2s_bclk always implies a 1/2 factor, which is
described by i2s_bclk_factor.
> +CCU_DIV_GATE_DEFINE(i2s_bclk, CCU_PARENT_HW(i2s_bclk_factor), MPMU_ISCCR, 27, 2, BIT(29), 0);
> static const struct clk_parent_data apb_parents[] = {
> CCU_PARENT_HW(pll1_d96_25p6),
> @@ -756,6 +777,10 @@ static struct clk_hw *k1_ccu_mpmu_hws[] = {
> [CLK_I2S_BCLK] = &i2s_bclk.common.hw,
> [CLK_APB] = &apb_clk.common.hw,
> [CLK_WDT_BUS] = &wdt_bus_clk.common.hw,
> + [CLK_I2S_153P6] = &i2s_153p6.common.hw,
> + [CLK_I2S_153P6_BASE] = &i2s_153p6_base.common.hw,
> + [CLK_I2S_SYSCLK_SRC] = &i2s_sysclk_src.common.hw,
> + [CLK_I2S_BCLK_FACTOR] = &i2s_bclk_factor.common.hw,
> };
>
> static const struct spacemit_ccu_data k1_ccu_mpmu_data = {
Best regards,
Haylen Chu
WARNING: multiple messages have this Message-ID (diff)
From: Haylen Chu <heylenay@4d2.org>
To: Troy Mitchell <troy.mitchell@linux.spacemit.com>,
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>, Yixun Lan <dlan@gentoo.org>,
Alex Elder <elder@riscstar.com>,
Inochi Amaoto <inochiama@outlook.com>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-riscv@lists.infradead.org, spacemit@lists.linux.dev,
linux-kernel@vger.kernel.org,
Jinmei Wei <weijinmei@linux.spacemit.com>
Subject: Re: [PATCH v3 3/3] clk: spacemit: fix i2s clock
Date: Mon, 18 Aug 2025 10:04:18 +0000 [thread overview]
Message-ID: <aKL6ormE1N72fwVG@ketchup> (raw)
In-Reply-To: <20250818-k1-clk-i2s-generation-v3-3-8139b22ae709@linux.spacemit.com>
On Mon, Aug 18, 2025 at 05:28:22PM +0800, Troy Mitchell wrote:
> Defining i2s_bclk and i2s_sysclk as fixed-rate clocks is insufficient
> for real I2S use cases.
>
> Moreover, the current I2S clock configuration does not work as expected
> due to missing parent clocks.
>
> This patch adds the missing parent clocks, defines i2s_sysclk as
> a DDN clock, and i2s_bclk as a DIV clock.
>
> A special note for i2s_bclk:
>
> From the definition of register, The i2s_bclk is a non-linear,
> discrete divider clock.
No, it IS linear. It just comes with a 1/2 factor according to your code
(I'm assuming there's a typo in the table below).
> In calculus and related areas, a linear function is a function whose
> graph is a straight line, that is, a polynomial function of degree
> zero or one. (From Wikipedia)
> The following table shows the correspondence between index
> and frequency division coefficients:
>
> | index | div |
> |-------|-------|
> | 0 | 2 |
> | 1 | 4 |
> | 2 | 6 |
> | 2 | 8 |
Index = 2 appears twice in the table. Is this a typo?
> From a software perspective, introducing i2s_bclk_factor as the
> parent of i2s_bclk is sufficient to address the issue.
>
> The I2S-related clock registers can be found here [1].
>
> Link:
> https://developer.spacemit.com/documentation?token=LCrKwWDasiJuROkVNusc2pWTnEb
> [1]
>
> Fixes: 1b72c59db0add ("clk: spacemit: Add clock support for SpacemiT K1 SoC")
> Co-developer: Jinmei Wei <weijinmei@linux.spacemit.com>
> Suggested-by: Haylen Chu <heylenay@4d2.org>
> Signed-off-by: Jinmei Wei <weijinmei@linux.spacemit.com>
> Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
> ---
> drivers/clk/spacemit/ccu-k1.c | 29 +++++++++++++++++++++++++++--
> drivers/clk/spacemit/ccu_mix.h | 2 +-
> include/soc/spacemit/k1-syscon.h | 1 +
> 3 files changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
> index 7155824673fb450971439873b6b6163faf48c7e5..b2c426b629a37a9901bbced26fc55c5f1b34eba5 100644
> --- a/drivers/clk/spacemit/ccu-k1.c
> +++ b/drivers/clk/spacemit/ccu-k1.c
...
> + * i2s_bclk is a non-linear discrete divider clock.
> + * Using i2s_bclk_factor as its parent simplifies software handling
> + * and avoids dealing with the non-linear division directly.
> + */
And thus this comment is wrong and misleading. Suggest something like,
Divider of i2s_bclk always implies a 1/2 factor, which is
described by i2s_bclk_factor.
> +CCU_DIV_GATE_DEFINE(i2s_bclk, CCU_PARENT_HW(i2s_bclk_factor), MPMU_ISCCR, 27, 2, BIT(29), 0);
> static const struct clk_parent_data apb_parents[] = {
> CCU_PARENT_HW(pll1_d96_25p6),
> @@ -756,6 +777,10 @@ static struct clk_hw *k1_ccu_mpmu_hws[] = {
> [CLK_I2S_BCLK] = &i2s_bclk.common.hw,
> [CLK_APB] = &apb_clk.common.hw,
> [CLK_WDT_BUS] = &wdt_bus_clk.common.hw,
> + [CLK_I2S_153P6] = &i2s_153p6.common.hw,
> + [CLK_I2S_153P6_BASE] = &i2s_153p6_base.common.hw,
> + [CLK_I2S_SYSCLK_SRC] = &i2s_sysclk_src.common.hw,
> + [CLK_I2S_BCLK_FACTOR] = &i2s_bclk_factor.common.hw,
> };
>
> static const struct spacemit_ccu_data k1_ccu_mpmu_data = {
Best regards,
Haylen Chu
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-08-18 10:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 9:28 [PATCH v3 0/3] clk: spacemit: fix i2s clock Troy Mitchell
2025-08-18 9:28 ` Troy Mitchell
2025-08-18 9:28 ` [PATCH v3 1/3] dt-bindings: clock: spacemit: introduce i2s pre-clock to " Troy Mitchell
2025-08-18 9:28 ` Troy Mitchell
2025-08-18 9:28 ` [PATCH v3 2/3] clk: spacemit: introduce pre-div for ddn clock Troy Mitchell
2025-08-18 9:28 ` Troy Mitchell
2025-08-18 9:49 ` Haylen Chu
2025-08-18 9:49 ` Haylen Chu
2025-08-18 9:28 ` [PATCH v3 3/3] clk: spacemit: fix i2s clock Troy Mitchell
2025-08-18 9:28 ` Troy Mitchell
2025-08-18 10:04 ` Haylen Chu [this message]
2025-08-18 10:04 ` Haylen Chu
2025-08-18 13:08 ` Troy Mitchell
2025-08-18 13:08 ` Troy Mitchell
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=aKL6ormE1N72fwVG@ketchup \
--to=heylenay@4d2.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlan@gentoo.org \
--cc=elder@riscstar.com \
--cc=inochiama@outlook.com \
--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=troy.mitchell@linux.spacemit.com \
--cc=weijinmei@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.