Skip to contentSkip to conversation

ASoC: rt712-sdca: reconfigure PLL2 to fix calibration time-out

PATCH Superseded [email protected] 2 participants 3 messages Sep 7 – Sep 8

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: rt712-sdca: reconfigure PLL2 to fix calibration time-out

From: Jack Yu <[email protected]>

Add pll2 reconfiguration sequence in order to fix calibration time-out issue and to support 24.576MHz MCLK on specific platforms.

---
 sound/soc/codecs/rt712-sdca-sdw.c |  8 +++
 sound/soc/codecs/rt712-sdca.c     | 88 +++++++++++++++++++++++++++++--
 sound/soc/codecs/rt712-sdca.h     | 18 +++++++
 3 files changed, 111 insertions(+), 3 deletions(-)
sound/soc/codecs/rt712-sdca-sdw.c +8 -0
index c50e74e20a88..edba0367d9ce 100644
@@ -18,12 +18,16 @@
 static bool rt712_sdca_readable_register(struct device *dev, unsigned int reg)
 {
 	switch (reg) {
+	case 0x004d:
 	case 0x201a ... 0x201f:
 	case 0x2029 ... 0x202a:
 	case 0x202d ... 0x2034:
 	case 0x2230 ... 0x2232:
 	case 0x2f01 ... 0x2f0a:
 	case 0x2f35 ... 0x2f36:
+	case 0x2f3a:
+	case 0x2f3d:
+	case 0x2f41:
 	case 0x2f50:
 	case 0x2f54:
 	case 0x2f58 ... 0x2f5d:
@@ -48,6 +52,7 @@ static bool rt712_sdca_readable_register(struct device *dev, unsigned int reg)
 static bool rt712_sdca_volatile_register(struct device *dev, unsigned int reg)
 {
 	switch (reg) {
+	case 0x004d:
 	case 0x201b:
 	case 0x201c:
 	case 0x201d:
@@ -56,6 +61,9 @@ static bool rt712_sdca_volatile_register(struct device *dev, unsigned int reg)
 	case 0x2230:
 	case 0x2f01:
 	case 0x2f35:
+	case 0x2f3a:
+	case 0x2f3d:
+	case 0x2f41:
 	case 0x320c:
 	case SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_GE49, RT712_SDCA_CTL_DETECTED_MODE, 0):
 	case SDW_SDCA_CTL(FUNC_NUM_HID, RT712_SDCA_ENT_HID01, RT712_SDCA_CTL_HIDTX_CURRENT_OWNER, 0) ...
sound/soc/codecs/rt712-sdca.c +85 -3

122 lines not on this page · raw message

sound/soc/codecs/rt712-sdca.h +18 -0
index 46740281a5c1..6229fe341bb5 100644
@@ -162,6 +162,16 @@ struct rt712_dmic_kctrl_priv {
 #define RT712_EAPD_HIGH				0x2
 #define RT712_EAPD_LOW				0x0
 
+/* SDW clock root frequency */
+#define RT712_SDW_ROOT_CLK		0x004d
+#define RT712_SDW_SCALE_CLK0		0x0062
+#define RT712_SDW_SCALE_CLK1		0x0072
+
+/* PLL2 config */
+#define RT712_PLL2_CONF1		0x2f3a
+#define RT712_PLL2_CONF2		0x2f3d
+#define RT712_PLL2_CONF3		0x2f41
+
 /* RC Calibration register */
 #define RT712_RC_CAL			0x3201
 
@@ -254,6 +264,14 @@ enum rt712_sdca_version {
 	RT712_VB,
 };
 
+enum {
+	RT712_CLK_FREQ_19_2_MHZ = 1,
+	RT712_CLK_FREQ_24MHZ = 2,
+	RT712_CLK_FREQ_24_576MHZ = 3,
+	RT712_CLK_FREQ_22_5792MHZ = 4,
+};
+
+
 int rt712_sdca_io_init(struct device *dev, struct sdw_slave *slave);
 int rt712_sdca_init(struct device *dev, struct regmap *regmap,
 			struct regmap *mbq_regmap, struct sdw_slave *slave);
Signature · 1 line
2.54.0
maintainer
#1 lore raw

sound/soc/codecs/rt712-sdca.c static int rt712_sdca_index_update_bits(struct rt712_sdca_priv *rt712,

Quoted 11 lines · On Mon, Sep 07, 2026 at 02:41:14PM +0800, [email protected] wrote:

From: Jack Yu <[email protected]>

Add pll2 reconfiguration sequence in order to fix calibration time-out issue and to support 24.576MHz MCLK on specific platforms.

sound/soc/codecs/rt712-sdca.c +4 -0
+static void rt712_sdca_clk_patch2(struct rt712_sdca_priv *rt712)
+{
 
 
+	regmap_write(rt712->regmap, RT712_SDW_SCALE_CLK0, 0x03);
+	regmap_write(rt712->regmap, RT712_SDW_SCALE_CLK1, 0x03);

This looks like it collides with sdw_slave_set_frequency()?

sound/soc/codecs/rt712-sdca.c static int rt712_sdca_calibration(struct rt712_sdca_priv *rt712) · line 162

Quoted 5 lines
sound/soc/codecs/rt712-sdca.c +5 -0
+	if (loop_dc == chk_cnt) {
+		if (clk_base == RT712_CLK_FREQ_24_576MHZ) {
+			rt712_sdca_clk_patch(rt712);
+			rt712_sdca_clk_patch2(rt712);
+		}

Perhaps the patching should be checking that the scaling registers are the ones written above and only kicking in if that's the case, or have more cases that work with other scaling setups? Or restore whatever the core set if that's possible?

author
#2 lore raw
Quoted 18 lines

-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Tuesday, September 8, 2026 5:32 AM
To: Jack Yu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Flove(HsinFu) <[email protected]>; Oder Chiou <[email protected]>; Shuming [范書銘] <[email protected]>; Derek [方德義] <[email protected]>; [email protected]
Subject: Re: [PATCH] ASoC: rt712-sdca: reconfigure PLL2 to fix calibration time-out

Quoted 4 lines · On Mon, Sep 07, 2026 at 02:41:14PM +0800, [email protected] wrote:

From: Jack Yu <[email protected]>

Add pll2 reconfiguration sequence in order to fix calibration time-out issue and to support 24.576MHz MCLK on specific platforms.

Quoted 7 lines

sound/soc/codecs/rt712-sdca.c static int rt712_sdca_index_update_bits(struct rt712_sdca_priv *rt712, · line 109

Quoted 5 lines
sound/soc/codecs/rt712-sdca.c +3 -0
+static void rt712_sdca_clk_patch2(struct rt712_sdca_priv *rt712) {
 
 
+	regmap_write(rt712->regmap, RT712_SDW_SCALE_CLK0, 0x03);
+	regmap_write(rt712->regmap, RT712_SDW_SCALE_CLK1, 0x03);

This looks like it collides with sdw_slave_set_frequency()?

After testing, these two registers can be removed from the patch and the patch can still fix issue. I'll update this in V2 patch.

Quoted 11 lines

sound/soc/codecs/rt712-sdca.c static int rt712_sdca_calibration(struct rt712_sdca_priv *rt712) · line 162

Quoted 6 lines
sound/soc/codecs/rt712-sdca.c +5 -0
+	if (loop_dc == chk_cnt) {
+		if (clk_base == RT712_CLK_FREQ_24_576MHZ) {
+			rt712_sdca_clk_patch(rt712);
+			rt712_sdca_clk_patch2(rt712);
+		}

Perhaps the patching should be checking that the scaling registers are the ones written above and only kicking in if that's the case, or have more cases that work with other scaling setups? Or restore whatever the core set if that's possible?

I'll remove those two registers mentioned above and update a V2 patch.