Skip to contentSkip to conversation

ASoC: wm8960: Add device tree support

PATCH Superseded Zidan Wang 3 participants 4 messages Nov 20, 2014

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Zidan Wang

author
#0 lore raw

PATCH v2 1/2 ASoC: wm8960: Add device tree support

Document the device tree binding for the WM8960 codec, and modify the driver to extract the platform data from device tree, if present.

---
 Documentation/devicetree/bindings/sound/wm8960.txt | 27 ++++++++++++++
 sound/soc/codecs/wm8960.c                          | 41 ++++++++++++++++------
 2 files changed, 58 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/wm8960.txt
Documentation/devicetree/bindings/sound/wm8960.txt new file +27 -0
new file mode 100644
index 0000000..1a9ad07
@@ -0,0 +1,27 @@
+WM8960 audio CODEC
+
+This device supports I2C only.
+
+Required properties:
+
+  - compatible : "wlf,wm8960"
+
+  - reg : the I2C address of the device.
+
+Optional properties:
+  - shared_lrclk: This is a boolean property. If present, the LRCM bit of
+	R24 (Additional control 2 ) gets set, indicating that ADCLRC and DACLRC
+	will be disabled only when ADC (Left and Right) and DAC (Left and Right)
+	are disabled.
+
+  - capless: This is a boolean property. If present, OUT3 will be enabled
+	and disabled together with HP_L and HP_R in response to jack detect events.
+
+Example:
+
+codec: wm8960@1a {
+	compatible = "wlf,wm8960";
+	reg = <0x1a>;
+
+	shared_lrclk;
+};
sound/soc/codecs/wm8960.c +31 -10

84 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v2 2/2 ASoC: wm8960: LRCM operation should after software reset

When shared_lrclk is set, LRCM will be enabled. But the following software reset in wm8960_probe will reset it to the default state. So LRCM operation should after software reset.

---
 sound/soc/codecs/wm8960.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
sound/soc/codecs/wm8960.c +8 -10
index e5d89a2..a7f60b7 100644
@@ -976,6 +976,14 @@ static int wm8960_probe(struct snd_soc_codec *codec)
 		return ret;
 	}
 
+    if (pdata->shared_lrclk) {
+		ret = snd_soc_update_bits(codec, WM8960_ADDCTL2, 0x4, 0x4);
+		if (ret < 0) {
+			dev_err(codec->dev, "Failed to enable LRCM: %d\n", ret);
+			return ret;
+		}
+	}
+
 	wm8960->set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
 	/* Latch the update bits */
@@ -1059,16 +1067,6 @@ static int wm8960_i2c_probe(struct i2c_client *i2c,
 	else if (i2c->dev.of_node)
 		wm8960_set_pdata_from_of(i2c, &wm8960->pdata);
 
-	if (pdata && pdata->shared_lrclk) {
-		ret = regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2,
-					 0x4, 0x4);
-		if (ret != 0) {
-			dev_err(&i2c->dev, "Failed to enable LRCM: %d\n",
-				ret);
-			return ret;
-		}
-	}
-
 	i2c_set_clientdata(i2c, wm8960);
 
 	ret = snd_soc_register_codec(&i2c->dev,
Signature · 1 line
1.9.1
Acked-by on v2 2/2
#2 lore raw

Re: [alsa-devel][PATCH v2 2/2] ASoC: wm8960: LRCM operation should after software reset

Quoted 6 lines · Zidan Wang

When shared_lrclk is set, LRCM will be enabled. But the following software reset in wm8960_probe will reset it to the default state. So LRCM operation should after software reset.

---

For patch 2 here:

Patch 1 could still use the docs fixups Lars suggested.

Thanks,
Charles

#3 lore raw
In reply to Zidan Wang

On 11/20/2014 09:41 AM, Zidan Wang wrote:
[...][

Documentation/devicetree/bindings/sound/wm8960.txt line 18

Quoted 8 lines
Documentation/devicetree/bindings/sound/wm8960.txt new file +8 -0
+Optional properties:
+  - shared_lrclk: This is a boolean property. If present, the LRCM bit of
+	R24 (Additional control 2 ) gets set, indicating that ADCLRC and DACLRC
+	will be disabled only when ADC (Left and Right) and DAC (Left and Right)
+	are disabled.
+
+  - capless: This is a boolean property. If present, OUT3 will be enabled
+	and disabled together with HP_L and HP_R in response to jack detect events.

Custom properties need a vendor prefix and properties should use '-' instead of '_'. Also the devicetree describes the hardware and not the driver, so the description should say for which hardware setups this flag should be set, not what the behavior of the driver will be.

- Lars