Skip to contentSkip to conversation

Add "mclk" support for maxim,max9867

PATCH In review [email protected] 3 participants 11 messages Mar 3, 2023 – Mar 28, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Add "mclk" support for maxim,max9867

This series adds support for the clocks properties in the maxim,max9867 bindings. Furthermore the binding definitions are converted from txt to yaml.

The clock property is needed to define the mclk for one of our boards which uses the the i.MX8MP SAI MCLK as clock for the maxim,max9867.

ChangeLog:
v2:
- dt-bindings:
- add "additionalProperties: false" property
- remove "clock-names" property
- fix $id
- fix example
- max9867:
- Enable and prepare mclk on SND_SOC_BIAS_ON
- disable and unprepare mclk on SND_SOC_BIAS_OFF
- drop "mclk" clock-name

---
Benjamin Bara (1):
ASoC: maxim,max9867: add "mclk" support

Richard Leitner (2):
ASoC: dt-bindings: maxim,max9867: convert txt bindings to yaml
ASoC: dt-bindings: maxim,max9867: add clocks property

 .../devicetree/bindings/sound/max9867.txt          | 17 ------
 .../devicetree/bindings/sound/maxim,max9867.yaml   | 66 ++++++++++++++++++++++
 sound/soc/codecs/max9867.c                         | 19 ++++++-
 3 files changed, 83 insertions(+), 19 deletions(-)

---
base-commit: c9c3395d5e3dcc6daee66c6908354d47bf98cb0c
change-id: 20230302-max9867-49081908a2ab

Best regards,

Signature · 1 line
Richard Leitner <[email protected]>
#1 lore raw

PATCH v2 1/3 ASoC: dt-bindings: maxim,max9867: convert txt bindings to yaml

From: Richard Leitner <[email protected]>

Convert from max9867.txt to maxim,max9867.yaml and add missing '#sound-dai-cells' property.

---
 .../devicetree/bindings/sound/max9867.txt          | 17 -------
 .../devicetree/bindings/sound/maxim,max9867.yaml   | 55 ++++++++++++++++++++++
 2 files changed, 55 insertions(+), 17 deletions(-)
Documentation/devicetree/bindings/sound/max9867.txt deleted +0 -17
deleted file mode 100644
index b8bd914ee697..000000000000
@@ -1,17 +0,0 @@
-max9867 codec
-
-This device supports I2C mode only.
-
-Required properties:
-
-- compatible : "maxim,max9867"
-- reg : The chip select number on the I2C bus
-
-Example:
-
-&i2c {
-	max9867: max9867@18 {
-		compatible = "maxim,max9867";
-		reg = <0x18>;
-	};
-};
Documentation/devicetree/bindings/sound/maxim,max9867.yaml new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.39.2
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] ASoC: dt-bindings: maxim,max9867: convert txt bindings to yaml

Quoted 11 lines · On 03/03/2023 11:04, [email protected] wrote:

From: Richard Leitner <[email protected]>

Convert from max9867.txt to maxim,max9867.yaml and add missing '#sound-dai-cells' property.

---
 .../devicetree/bindings/sound/max9867.txt          | 17 -------
 .../devicetree/bindings/sound/maxim,max9867.yaml   | 55 ++++++++++++++++++++++
 2 files changed, 55 insertions(+), 17 deletions(-)

Looks ok. Need to wait for Rob's bot to check for issues.

Best regards,
Krzysztof

#3 lore raw

PATCH v2 2/3 ASoC: dt-bindings: maxim,max9867: add clocks property

In reply to [email protected]

From: Richard Leitner <[email protected]>

Add clocks property to require a "mclk" definition for the maxim,max9867 codec.

---
 Documentation/devicetree/bindings/sound/maxim,max9867.yaml | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/sound/maxim,max9867.yaml +11 -0
index 74cd163546ec..6f27029b137d 100644
@@ -35,9 +35,13 @@ properties:
   reg:
     maxItems: 1
 
+  clocks:
+    maxItems: 1
+
 required:
   - compatible
   - reg
+  - clocks
 
 additionalProperties: false
 
@@ -50,6 +54,13 @@ examples:
             compatible = "maxim,max9867";
             #sound-dai-cells = <0>;
             reg = <0x18>;
+            clocks = <&codec_clk>;
         };
     };
+
+    codec_clk: clock {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <12288000>;
+    };
 ...
Signature · 1 line
2.39.2
#4 lore raw

Re: [PATCH v2 2/3] ASoC: dt-bindings: maxim,max9867: add clocks property

Quoted 4 lines · On 03/03/2023 11:04, [email protected] wrote:

From: Richard Leitner <[email protected]>

Add clocks property to require a "mclk" definition for the maxim,max9867 codec.

But why? You just wrote what the patch does, which is easy to see. Commit msgs should explain why you are doing something.

Quoted 26 lines
---
 Documentation/devicetree/bindings/sound/maxim,max9867.yaml | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/sound/maxim,max9867.yaml +4 -0
index 74cd163546ec..6f27029b137d 100644
@@ -35,9 +35,13 @@ properties:
   reg:
     maxItems: 1
 
+  clocks:
+    maxItems: 1
+
 required:
   - compatible
   - reg
+  - clocks
 
 additionalProperties: false
 
@@ -50,6 +54,13 @@ examples:
             compatible = "maxim,max9867";

Documentation/devicetree/bindings/sound/maxim,max9867.yaml examples: · line 64

Quoted 10 lines
Documentation/devicetree/bindings/sound/maxim,max9867.yaml +6 -0
             #sound-dai-cells = <0>;
             reg = <0x18>;
+            clocks = <&codec_clk>;
         };
     };
+
+    codec_clk: clock {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <12288000>;

Drop the node, it's entirely common/regular stuff.

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH v2 2/3] ASoC: dt-bindings: maxim,max9867: add clocks property

Hi Krzysztof,
thanks for the review and quick response!

Quoted 8 lines · Krzysztof Kozlowski
Quoted 4 lines · On 03/03/2023 11:04, [email protected] wrote:

From: Richard Leitner <[email protected]>

Add clocks property to require a "mclk" definition for the maxim,max9867 codec.

But why? You just wrote what the patch does, which is easy to see. Commit msgs should explain why you are doing something.

Ok. Will adapt the message in v3.

Quoted 25 lines
Quoted 25 lines
---
 Documentation/devicetree/bindings/sound/maxim,max9867.yaml | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/sound/maxim,max9867.yaml +4 -0
index 74cd163546ec..6f27029b137d 100644
@@ -35,9 +35,13 @@ properties:
   reg:
     maxItems: 1
 
+  clocks:
+    maxItems: 1
+
 required:
   - compatible
   - reg
+  - clocks
 
 additionalProperties: false
 
Quoted 14 lines

Documentation/devicetree/bindings/sound/maxim,max9867.yaml examples: · line 64

Quoted 12 lines
Documentation/devicetree/bindings/sound/maxim,max9867.yaml +6 -0
@@ -50,6 +54,13 @@ examples:
             compatible = "maxim,max9867";
             #sound-dai-cells = <0>;
             reg = <0x18>;
+            clocks = <&codec_clk>;
         };
     };
+
+    codec_clk: clock {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <12288000>;

Drop the node, it's entirely common/regular stuff.

True. I thought it is nessecary for
"make DT_CHECKER_FLAGS=-m dt_binding_check"
to succeed. But I just learned it in fact isn't. Thanks for the pointer and that eureka moment 😉.

Will fix that in v3.

Quoted 4 lines

Best regards,
Krzysztof

regards;rl

#6 lore raw

PATCH v2 3/3 ASoC: maxim,max9867: add "mclk" support

In reply to [email protected]

From: Benjamin Bara <[email protected]>

Add basic support for the codecs' mclk.
Enable it on SND_SOC_BIAS_ON, disable it on SND_SOC_BIAS_OFF.

---
 sound/soc/codecs/max9867.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
sound/soc/codecs/max9867.c +17 -2
index e161ab037bf7..ae552d72beec 100644
@@ -6,6 +6,7 @@
 // Copyright 2018 Ladislav Michl <[email protected]>
 //
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
@@ -16,6 +17,7 @@
 #include "max9867.h"
 
 struct max9867_priv {
+	struct clk *mclk;
 	struct regmap *regmap;
 	const struct snd_pcm_hw_constraint_list *constraints;
 	unsigned int sysclk, pclk;
@@ -577,6 +579,11 @@ static int max9867_set_bias_level(struct snd_soc_component *component,
 	struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
 
 	switch (level) {
+	case SND_SOC_BIAS_ON:
+		err = clk_prepare_enable(max9867->mclk);
+		if (err)
+			return err;
+		break;
 	case SND_SOC_BIAS_STANDBY:
 		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
 			err = regcache_sync(max9867->regmap);
@@ -595,6 +602,7 @@ static int max9867_set_bias_level(struct snd_soc_component *component,
 			return err;
 
 		regcache_mark_dirty(max9867->regmap);
+		clk_disable_unprepare(max9867->mclk);
 		break;
 	default:
 		break;
@@ -663,9 +671,16 @@ static int max9867_i2c_probe(struct i2c_client *i2c)
 	dev_info(&i2c->dev, "device revision: %x\n", reg);
 	ret = devm_snd_soc_register_component(&i2c->dev, &max9867_component,
 			max9867_dai, ARRAY_SIZE(max9867_dai));
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(&i2c->dev, "Failed to register component: %d\n", ret);
-	return ret;
+		return ret;
+	}
+
+	max9867->mclk = devm_clk_get(&i2c->dev, NULL);
+	if (IS_ERR(max9867->mclk))
+		return PTR_ERR(max9867->mclk);
+
+	return 0;
 }
 
 static const struct i2c_device_id max9867_i2c_id[] = {
Signature · 1 line
2.39.2
maintainer
#7 lore raw
In reply to [email protected]
Quoted 9 lines · On Fri, 03 Mar 2023 11:04:00 +0100, [email protected] wrote:

This series adds support for the clocks properties in the maxim,max9867 bindings. Furthermore the binding definitions are converted from txt to yaml.

The clock property is needed to define the mclk for one of our boards which uses the the i.MX8MP SAI MCLK as clock for the maxim,max9867.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: dt-bindings: maxim,max9867: convert txt bindings to yaml

      commit: 6668f70abeea30f4674b2fdbc4232d5c3611b272
[2/3] ASoC: dt-bindings: maxim,max9867: add clocks property
      commit: d63e55b3e8ec90da69107f32038f3059d7317cc5
[3/3] ASoC: maxim,max9867: add "mclk" support
      commit: 448b06ba107d925d59d02781acdd2e4ad12dda0b

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

#8 lore raw

Hi Mark, Hi Krzysztof,

sorry for coming back to you on this series, but I have a question on the "workflow"...

Quoted 29 lines · Mark Brown
Quoted 9 lines · On Fri, 03 Mar 2023 11:04:00 +0100, [email protected] wrote:

This series adds support for the clocks properties in the maxim,max9867 bindings. Furthermore the binding definitions are converted from txt to yaml.

The clock property is needed to define the mclk for one of our boards which uses the the i.MX8MP SAI MCLK as clock for the maxim,max9867.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: dt-bindings: maxim,max9867: convert txt bindings to yaml

      commit: 6668f70abeea30f4674b2fdbc4232d5c3611b272
[2/3] ASoC: dt-bindings: maxim,max9867: add clocks property
      commit: d63e55b3e8ec90da69107f32038f3059d7317cc5
[3/3] ASoC: maxim,max9867: add "mclk" support
      commit: 448b06ba107d925d59d02781acdd2e4ad12dda0b

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

Quoted 7 lines

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

As Krzysztof requested some changes on the clocks property dt-bindings patch (#2) commit message... How should I handle this?

The changes requested on the patch content (dts example) should be sent as incremental patch to the original series, I guess?

see https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Thanks & regards;rl

#9 lore raw
Quoted 8 lines · Richard Leitner
Quoted 2 lines

should be sent as incremental updates against current git, existing patches will not be replaced.

As Krzysztof requested some changes on the clocks property dt-bindings patch (#2) commit message... How should I handle this?

The changes requested on the patch content (dts example) should be sent as incremental patch to the original series, I guess?

Incremental updates, so new patch. Rebase on maintainer's tree next branch or linux-next (usually linux-next is the easiest but for cross-tree patches might create inapplicable series).

Best regards,
Krzysztof

maintainer
#10 lore raw
In reply to Richard Leitner
Quoted 5 lines · Richard Leitner

As Krzysztof requested some changes on the clocks property dt-bindings patch (#2) commit message... How should I handle this?

The changes requested on the patch content (dts example) should be sent as incremental patch to the original series, I guess?

If it's just the commit message it's too late. Otherwise incremental patches against current git.