Skip to contentSkip to conversation

ASoC: rt5682: Add CCF usage for providing I2S clks

PATCH Superseded [email protected] 2 participants 5 messages Feb 14, 2020 – Feb 18, 2020 1 message not in the archive

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#1 lore raw

PATCH 2/2 ASoC: rt5682: Add DAI clock binding info for WCLK/BCLK CCF usage

In reply to [email protected]

From: "derek.fang" <[email protected]>

This patch describes that rt5682 can expose WCLK and BCLK clocks and how to use.

---
 Documentation/devicetree/bindings/sound/rt5682.txt | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/sound/rt5682.txt +12 -0
index 30e927a2..ac98151 100644
@@ -32,6 +32,12 @@ Optional properties:
   The delay time is realtek,btndet-delay value multiple of 8.192 ms.
   If absent, the default is 16.
 
+- #clock-cells : Should be set to '<1>',  wclk and bclk sources provided.
+- clock-output-names : Name given for DAI clocks output.
+
+- clocks : phandle and clock specifier for codec MCLK.
+- clock-names : Clock name string for 'clocks' attribute, should be "mclk".
+
 Pins on the device (for linking into audio routes) for RT5682:
 
   * DMIC L1
@@ -53,4 +59,10 @@ rt5682 {
 	realtek,dmic1-clk-pin = <1>;
 	realtek,jd-src = <1>;
 	realtek,btndet-delay = <16>;
+
+	#clock-cells = <1>;
+	clock-output-names = "rt5682-dai-wclk", "rt5682-dai-bclk";
+
+	clocks = <&osc>;
+	clock-names = "mclk";
 };
Signature · 6 lines
2.7.4

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#0 lore raw

PATCH 1/2 ASoC: rt5682: Add CCF usage for providing I2S clks

From: "derek.fang" <[email protected]>

There is a need to use RT5682 as DAI clock master for other codecs within a system, which means that the DAI clocks are required to remain, regardless of whether the RT5682 is actually running playback/capture.

---
 include/sound/rt5682.h    |   8 +
 sound/soc/codecs/rt5682.c | 389 +++++++++++++++++++++++++++++++++++++++++++++-
 sound/soc/codecs/rt5682.h |   4 +-
 3 files changed, 397 insertions(+), 4 deletions(-)
include/sound/rt5682.h +8 -0
index bc2c317..6bf0e35 100644
@@ -24,6 +24,12 @@ enum rt5682_jd_src {
 	RT5682_JD1,
 };
 
+enum rt5682_dai_clks {
+	RT5682_DAI_WCLK_IDX,
+	RT5682_DAI_BCLK_IDX,
+	RT5682_DAI_NUM_CLKS,
+};
+
 struct rt5682_platform_data {
 
 	int ldo1_en; /* GPIO for LDO1_EN */
@@ -32,6 +38,8 @@ struct rt5682_platform_data {
 	enum rt5682_dmic1_clk_pin dmic1_clk_pin;
 	enum rt5682_jd_src jd_src;
 	unsigned int btndet_delay;
+
+	const char *dai_clk_names[RT5682_DAI_NUM_CLKS];
 };
 
 #endif
sound/soc/codecs/rt5682.c +387 -2

449 lines not on this page · raw message

sound/soc/codecs/rt5682.h +2 -2
index 465c99b..f82126a 100644
@@ -841,8 +841,8 @@
 #define RT5682_TDM_M_LP_INV			(0x1 << 1)
 #define RT5682_TDM_MS_MASK			(0x1 << 0)
 #define RT5682_TDM_MS_SFT			0
-#define RT5682_TDM_MS_M				(0x0 << 0)
-#define RT5682_TDM_MS_S				(0x1 << 0)
+#define RT5682_TDM_MS_S				(0x0 << 0)
+#define RT5682_TDM_MS_M				(0x1 << 0)
 
 /* Global Clock Control (0x0080) */
 #define RT5682_SCLK_SRC_MASK			(0x7 << 13)
Signature · 6 lines
2.7.4

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#2 lore raw
Quoted 5 lines · On Fri, Feb 14, 2020 at 03:53:33PM +0800, [email protected] wrote:
sound/soc/codecs/rt5682.c +5 -0
+	parent_clk = clk_get_parent(hw->clk);
+	if (!parent_clk)
+		dev_warn(component->dev,
+			"Parent mclk of wclk not acquired in driver. Please ensure mclk was provided as %d Hz.\n",
+			CLK_PLL2_FIN);

sound/soc/codecs/rt5682.c static int rt5682_set_bias_level(struct snd_soc_component *component, · line 2602

Quoted 10 lines
sound/soc/codecs/rt5682.c +10 -0
+
+	if (parent_rate != CLK_PLL2_FIN)
+		dev_warn(component->dev, "clk %s only support %d Hz input\n",
+			clk_name, CLK_PLL2_FIN);
+
+	if (rate != CLK_48) {
+		dev_warn(component->dev, "clk %s only support %d Hz output\n",
+			clk_name, CLK_48);
+		rate = CLK_48;
+	}

Are these genuine restrictions of the hardware or is this just being hard coded in the driver?

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#4 lore raw
In reply to a message not in the archive
Quoted 15 lines · Derek [方德義]
Quoted 6 lines

Subject: Re: [PATCH 1/2] ASoC: rt5682: Add CCF usage for providing I2S clks

Quoted 3 lines
sound/soc/codecs/rt5682.c +3 -0
+	if (parent_rate != CLK_PLL2_FIN)
+		dev_warn(component->dev, "clk %s only support %d Hz input\n",
+			clk_name, CLK_PLL2_FIN);
Quoted 8 lines

sound/soc/codecs/rt5682.c static int rt5682_set_bias_level(struct snd_soc_component *component, · line 2602

Quoted 5 lines
sound/soc/codecs/rt5682.c +5 -0
+	if (rate != CLK_48) {
+		dev_warn(component->dev, "clk %s only support %d Hz output\n",
+			clk_name, CLK_48);
+		rate = CLK_48;
+	}

Are these genuine restrictions of the hardware or is this just being hard coded in the driver?

Quoted 2 lines

It's hard coded for an application case.
Generate a 48kHz clk with a parent 48 MHz clk.

I see... obviously this is really not good quality of implementation although it doesn't actually break any external interfaces so I guess we could take it. I would at least want to see some clear comments in both the code and the changelog explaining that this limitation is just a temporary hack until a better implementation is done though.

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw
Quoted 20 lines

Subject: Re: [PATCH 1/2] ASoC: rt5682: Add CCF usage for providing I2S clks

Quoted 4 lines · Derek [方德義]
Quoted 4 lines

Subject: Re: [PATCH 1/2] ASoC: rt5682: Add CCF usage for providing I2S clks

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (parent_rate != CLK_PLL2_FIN)
+		dev_warn(component->dev, "clk %s only support %d Hz

input\n",

Quoted 4 lines
Quoted 4 lines

sound/soc/codecs/rt5682.c static int rt5682_set_bias_level(struct snd_soc_component *component,

Quoted 4 lines
sound/soc/codecs/rt5682.c +3 -0
+			clk_name, CLK_PLL2_FIN);
 
+	if (rate != CLK_48) {
+		dev_warn(component->dev, "clk %s only support %d Hz

output\n",

Quoted 6 lines
Quoted 6 lines

sound/soc/codecs/rt5682.c static int rt5682_set_bias_level(struct snd_soc_component *component, · line 2602

Quoted 3 lines
sound/soc/codecs/rt5682.c +3 -0
+			clk_name, CLK_48);
+		rate = CLK_48;
+	}

Are these genuine restrictions of the hardware or is this just being hard coded in the driver?

Quoted 8 lines
Quoted 2 lines

It's hard coded for an application case.
Generate a 48kHz clk with a parent 48 MHz clk.

I see... obviously this is really not good quality of implementation although it doesn't actually break any external interfaces so I guess we could take it. I would at least want to see some clear comments in both the code and the changelog explaining that this limitation is just a temporary hack until a better implementation is done though.

Ok. Thanks for the advice.
I will add more comments both in the source and commit to clearly describe the driver support and limitation, and then send the PATCH v2.

------Please consider the environment before printing this e-mail.