mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: Theo Debrouwere <theo.debrouwere@gmail.com>
To: linux-amlogic@lists.infradead.org
Cc: Theo Debrouwere <theo.debrouwere@faytech.de>
Subject: [PATCH 2/2] clk: meson: axg-audio: fix sm1 mclk_pad support
Date: Fri,  6 Sep 2024 15:18:02 +0200	[thread overview]
Message-ID: <20240906131802.630513-2-theo.debrouwere@faytech.de> (raw)
In-Reply-To: <20240906131802.630513-1-theo.debrouwere@faytech.de>

Fix the mclk_pad_0/1 of the sm1 family.
The pads have an additional divider & gate.

Signed-off-by: Theo Debrouwere <theo.debrouwere@faytech.de>
---
 drivers/clk/meson/axg-audio.c | 36 +++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/meson/axg-audio.c b/drivers/clk/meson/axg-audio.c
index e03a5bf899c0..838281218e71 100644
--- a/drivers/clk/meson/axg-audio.c
+++ b/drivers/clk/meson/axg-audio.c
@@ -323,6 +323,16 @@ static const struct clk_parent_data lrclk_pad_ctrl_parent_data[] = {
 	AUD_MUX(_name, _reg, 0x7, _shift, 0, _parents,		\
 		CLK_SET_RATE_NO_REPARENT)
 
+#define AUD_TDM_PAD_MUX(_name, _reg, _shift, _parents)			\
+	AUD_MUX(_name##_sel, _reg, 0x7, _shift, 0, _parents,		\
+		CLK_SET_RATE_NO_REPARENT)
+#define AUD_TDM_PAD_DIV(_name, _reg, _shift)				\
+	AUD_DIV(_name##_div, _reg, _shift, 8, CLK_DIVIDER_ROUND_CLOSEST,\
+		aud_##_name##_sel, CLK_SET_RATE_PARENT)
+#define AUD_TDM_PAD_GATE(_name, _reg, _bit)				\
+	AUD_GATE(_name, _reg, _bit, aud_##_name##_div,			\
+		 CLK_SET_RATE_PARENT)
+
 /* Common Clocks */
 static struct clk_regmap ddr_arb =
 	AUD_PCLK_GATE(ddr_arb, AUDIO_CLK_GATE_EN, 0);
@@ -793,10 +803,20 @@ static struct clk_regmap sm1_mst_e_mclk =
 static struct clk_regmap sm1_mst_f_mclk =
 	AUD_MST_MCLK_GATE(mst_f_mclk, AUDIO_SM1_MCLK_F_CTRL);
 
-static struct clk_regmap sm1_tdm_mclk_pad_0 = AUD_TDM_PAD_CTRL(
-	tdm_mclk_pad_0, AUDIO_SM1_MST_PAD_CTRL0, 0, mclk_pad_ctrl_parent_data);
-static struct clk_regmap sm1_tdm_mclk_pad_1 = AUD_TDM_PAD_CTRL(
-	tdm_mclk_pad_1, AUDIO_SM1_MST_PAD_CTRL0, 4, mclk_pad_ctrl_parent_data);
+static struct clk_regmap sm1_tdm_mclk_pad_0_sel = AUD_TDM_PAD_MUX(
+	tdm_mclk_pad_0, AUDIO_SM1_MST_PAD_CTRL0, 8, mclk_pad_ctrl_parent_data);
+static struct clk_regmap sm1_tdm_mclk_pad_0_div = AUD_TDM_PAD_DIV(
+	tdm_mclk_pad_0, AUDIO_SM1_MST_PAD_CTRL0, 0);
+static struct clk_regmap sm1_tdm_mclk_pad_0 = AUD_TDM_PAD_GATE(
+	tdm_mclk_pad_0, AUDIO_SM1_MST_PAD_CTRL0, 15);
+
+static struct clk_regmap sm1_tdm_mclk_pad_1_sel = AUD_TDM_PAD_MUX(
+	tdm_mclk_pad_1, AUDIO_SM1_MST_PAD_CTRL0, 24, mclk_pad_ctrl_parent_data);
+static struct clk_regmap sm1_tdm_mclk_pad_1_div = AUD_TDM_PAD_DIV(
+	tdm_mclk_pad_1, AUDIO_SM1_MST_PAD_CTRL0, 16);
+static struct clk_regmap sm1_tdm_mclk_pad_1 = AUD_TDM_PAD_GATE(
+	tdm_mclk_pad_1, AUDIO_SM1_MST_PAD_CTRL0, 31);
+
 static struct clk_regmap sm1_tdm_lrclk_pad_0 = AUD_TDM_PAD_CTRL(
 	tdm_lrclk_pad_0, AUDIO_SM1_MST_PAD_CTRL1, 16, lrclk_pad_ctrl_parent_data);
 static struct clk_regmap sm1_tdm_lrclk_pad_1 = AUD_TDM_PAD_CTRL(
@@ -1232,6 +1252,10 @@ static struct clk_hw *sm1_audio_hw_clks[] = {
 	[AUD_CLKID_SYSCLK_A_EN]		= &sm1_sysclk_a_en.hw,
 	[AUD_CLKID_SYSCLK_B_DIV]	= &sm1_sysclk_b_div.hw,
 	[AUD_CLKID_SYSCLK_B_EN]		= &sm1_sysclk_b_en.hw,
+	[AUD_CLKID_TDM_MCLK_PAD0_SEL]	= &sm1_tdm_mclk_pad_0_sel.hw,
+	[AUD_CLKID_TDM_MCLK_PAD0_DIV]	= &sm1_tdm_mclk_pad_0_div.hw,
+	[AUD_CLKID_TDM_MCLK_PAD1_SEL]	= &sm1_tdm_mclk_pad_1_sel.hw,
+	[AUD_CLKID_TDM_MCLK_PAD1_DIV]	= &sm1_tdm_mclk_pad_1_div.hw,
 };
 
 
@@ -1646,6 +1670,10 @@ static struct clk_regmap *const sm1_clk_regmaps[] = {
 	&sm1_sysclk_a_en,
 	&sm1_sysclk_b_div,
 	&sm1_sysclk_b_en,
+	&sm1_tdm_mclk_pad_0_sel,
+	&sm1_tdm_mclk_pad_0_div,
+	&sm1_tdm_mclk_pad_1_sel,
+	&sm1_tdm_mclk_pad_1_div,
 };
 
 struct axg_audio_reset_data {
-- 
2.45.2


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

      reply	other threads:[~2024-09-06 13:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06 13:18 [PATCH 1/2] dt-bindings: clk: axg-audio: add missing sm1 pad bindings Theo Debrouwere
2024-09-06 13:18 ` Theo Debrouwere [this message]

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=20240906131802.630513-2-theo.debrouwere@faytech.de \
    --to=theo.debrouwere@gmail.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=theo.debrouwere@faytech.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

all inboxes | Powered by JetHome®