Skip to contentSkip to conversation

Add configuration options for tlv320aic32x4

PATCH New Kimmo Saarela 1 participant 6 messages Jun 30, 2015 1 message not in the archive

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

cover Add configuration options for tlv320aic32x4

* Patch 1: Make tlv320aic32x4 module selectable on it's own on config system
* Make codec visible in config tool, instead of magic selection via certain board option
* Patch 2: Don't stop driver initialization if mlck is not defined
* Only warn if mclk isn't in dtb file, such cases exist when other end of I2S bus provides the clock for the system and coded is not in control
* Patch 3: Fix bus signal polarity configuration
* Fix driver to use correct format polarity bits in config word, instead of magically setting polarity in format configuration
* Patch 4: Add more devicetree options to driver
* Add input-use and cmode array options to configure codec input pins properly. Current driver lets unused input pins to float.
* Add swapdacs option, works similarly to old platform data option. When enabled, swaps output channels
* Add powercfg config mask to pass codec power options, like: micbias off, configurable ldoin voltage, disable weak pull between AVDD and DVDD, configurable LDO voltages
* Patch 5: Update codec documentation to meet changes above

Kimmo Saarela (5):
sound/soc/codecs: Make tlv320aic32x4 codec selectable on it's own
ASoC: tlv320aic32x4: Make mclk optional
ASoC: tlv320aic32x4: Move bit polarity config to specific switch
statement
ASoC: tlv320aic32x4: Change codec input config options
ASoC: tlv320aic32x4: Update devicetree documentation

 .../devicetree/bindings/sound/tlv320aic32x4.txt    |  27 ++-
 include/sound/tlv320aic32x4.h                      |   8 +
 sound/soc/codecs/Kconfig                           |   3 +-
 sound/soc/codecs/tlv320aic32x4.c                   | 244 ++++++++++++++++++---
 sound/soc/codecs/tlv320aic32x4.h                   |  10 +
 5 files changed, 258 insertions(+), 34 deletions(-)
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): cover.1435569929.git.kimmo.saarela-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/5 sound/soc/codecs: Make tlv320aic32x4 codec selectable on it's own

---
 sound/soc/codecs/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/codecs/Kconfig +2 -1
index efaafce..ff297bc 100644
@@ -649,7 +649,8 @@ config SND_SOC_TLV320AIC31XX
 	select REGMAP_I2C
 
 config SND_SOC_TLV320AIC32X4
-	tristate
+	tristate "Texas Instruments TLV320AIC32x4 CODECs"
+	depends on I2C
 
 config SND_SOC_TLV320AIC3X
 	tristate "Texas Instruments TLV320AIC3x CODECs"
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH 2/5 ASoC: tlv320aic32x4: Make mclk optional

In reply to a message not in the archive

In case mclk is not given, assume that HW works without it, only print warning instead of error for missing mclk.

---
 sound/soc/codecs/tlv320aic32x4.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
sound/soc/codecs/tlv320aic32x4.c +13 -10
index ad6cb90..ce0972f 100644
@@ -500,13 +500,14 @@ static int aic32x4_set_bias_level(struct snd_soc_codec *codec,
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
-		/* Switch on master clock */
-		ret = clk_prepare_enable(aic32x4->mclk);
-		if (ret) {
-			dev_err(codec->dev, "Failed to enable master clock\n");
-			return ret;
+		if (aic32x4->mclk) {
+			/* Switch on master clock */
+			ret = clk_prepare_enable(aic32x4->mclk);
+			if (ret) {
+				dev_err(codec->dev, "Failed to enable master clock\n");
+				return ret;
+			}
 		}
-
 		/* Switch on PLL */
 		snd_soc_update_bits(codec, AIC32X4_PLLPR,
 				    AIC32X4_PLLEN, AIC32X4_PLLEN);
@@ -558,8 +559,10 @@ static int aic32x4_set_bias_level(struct snd_soc_codec *codec,
 		snd_soc_update_bits(codec, AIC32X4_PLLPR,
 				    AIC32X4_PLLEN, 0);
 
-		/* Switch off master clock */
-		clk_disable_unprepare(aic32x4->mclk);
+		if (aic32x4->mclk) {
+			/* Switch off master clock */
+			clk_disable_unprepare(aic32x4->mclk);
+		}
 		break;
 	case SND_SOC_BIAS_OFF:
 		break;
@@ -816,8 +819,8 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c,
 
 	aic32x4->mclk = devm_clk_get(&i2c->dev, "mclk");
 	if (IS_ERR(aic32x4->mclk)) {
-		dev_err(&i2c->dev, "Failed getting the mclk. The current implementation does not support the usage of this codec without mclk\n");
-		return PTR_ERR(aic32x4->mclk);
+		dev_warn(&i2c->dev, "Failed getting the mclk.\n");
+		aic32x4->mclk = NULL;
 	}
 
 	if (gpio_is_valid(aic32x4->rstn_gpio)) {
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

PATCH 3/5 ASoC: tlv320aic32x4: Move bit polarity config to specific switch statement

In reply to a message not in the archive

Move data format bit polarity control to its own switch statement, instead of magically selecting invert for specific formats. Fix supply format in binding documentation

---
 .../devicetree/bindings/sound/tlv320aic32x4.txt    |  2 +-
 sound/soc/codecs/tlv320aic32x4.c                   | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/sound/tlv320aic32x4.txt +1 -1
index 5e2741a..143a192 100644
@@ -5,7 +5,7 @@ The tlv320aic32x4 serial control bus communicates through I2C protocols
 Required properties:
  - compatible: Should be "ti,tlv320aic32x4"
  - reg: I2C slave address
- - supply-*: Required supply regulators are:
+ - *-supply: Required supply regulators are:
     "iov" - digital IO power supply
     "ldoin" - LDO power supply
     "dv" - Digital core power supply
sound/soc/codecs/tlv320aic32x4.c +20 -2
index ce0972f..d3636c1 100644
@@ -353,17 +353,35 @@ static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 		return -EINVAL;
 	}
 
+	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+	case SND_SOC_DAIFMT_IB_NF:
+		iface_reg_3 |= (1 << 3); /* invert bit clock */
+		break;
+
+	case SND_SOC_DAIFMT_NB_IF:
+		break;
+
+	case SND_SOC_DAIFMT_IB_IF:
+		iface_reg_3 |= (1 << 3); /* invert bit clock */
+		break;
+
+	case SND_SOC_DAIFMT_NB_NF:
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
 		break;
 	case SND_SOC_DAIFMT_DSP_A:
 		iface_reg_1 |= (AIC32X4_DSP_MODE << AIC32X4_PLLJ_SHIFT);
-		iface_reg_3 |= (1 << 3); /* invert bit clock */
 		iface_reg_2 = 0x01; /* add offset 1 */
 		break;
 	case SND_SOC_DAIFMT_DSP_B:
 		iface_reg_1 |= (AIC32X4_DSP_MODE << AIC32X4_PLLJ_SHIFT);
-		iface_reg_3 |= (1 << 3); /* invert bit clock */
 		break;
 	case SND_SOC_DAIFMT_RIGHT_J:
 		iface_reg_1 |=
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH 4/5 ASoC: tlv320aic32x4: Change codec input config options

In reply to a message not in the archive

Add more of paramenters for codec initial configuration, similar options are also added to pdata. Add input level selections to mixer. Now probe function ties unused input pins to common mode as should, according to tlv320aic3204 datasheet.

---
 include/sound/tlv320aic32x4.h    |   8 ++
 sound/soc/codecs/tlv320aic32x4.c | 199 +++++++++++++++++++++++++++++++++++----
 sound/soc/codecs/tlv320aic32x4.h |  10 ++
 3 files changed, 198 insertions(+), 19 deletions(-)
include/sound/tlv320aic32x4.h +8 -0
index 24e5d99..43ea355 100644
@@ -18,13 +18,21 @@
 #define AIC32X4_PWR_AIC32X4_LDO_ENABLE		0x00000004
 #define AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36	0x00000008
 #define AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED	0x00000010
+#define AIC32X4_PWR_AIC32X4_LDO_DVDD_1_77	0x00000020
+#define AIC32X4_PWR_AIC32X4_LDO_AVDD_1_77	0x00000040
+#define AIC32X4_PWR_MICBIAS_OFF			0x00000080
+
+#define AIC32X4_PWR_AIC32X4_MASK		0x000000ff
 
 #define AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K	0x00000001
 #define AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K	0x00000002
+#define AIC32X4_MICPGA_ROUTE_MASK		0x00000003
 
 struct aic32x4_pdata {
 	u32 power_cfg;
 	u32 micpga_routing;
+	u32 inputs[6];
+	u32 cmode[2];
 	bool swapdacs;
 	int rstn_gpio;
 };
sound/soc/codecs/tlv320aic32x4.c +180 -19

280 lines not on this page · raw message

sound/soc/codecs/tlv320aic32x4.h +10 -0
index 995f033..75bb727 100644
@@ -104,6 +104,9 @@
 
 #define AIC32X4_AVDDWEAKDISABLE		0x08
 #define AIC32X4_LDOCTLEN		0x01
+#define AIC32X4_ANALOG_DISABLE		0x08
+#define AIC32X4_LDO_DVDD_1_77		0x80
+#define AIC32X4_LDO_AVDD_1_77		0x20
 
 #define AIC32X4_LDOIN_18_36		0x01
 #define AIC32X4_LDOIN2HP		0x02
@@ -124,6 +127,13 @@
 #define AIC32X4_RMICPGANIN_IN1L_10K	0x10
 #define AIC32X4_RMICPGANIN_CM1R_10K	0x40
 
+#define AIC32X4_MICPGA_IN1L_NO_FLOAT	0x80
+#define AIC32X4_MICPGA_IN1R_NO_FLOAT	0x40
+#define AIC32X4_MICPGA_IN2L_NO_FLOAT	0x20
+#define AIC32X4_MICPGA_IN2R_NO_FLOAT	0x10
+#define AIC32X4_MICPGA_IN3L_NO_FLOAT	0x08
+#define AIC32X4_MICPGA_IN3R_NO_FLOAT	0x04
+
 #define AIC32X4_LMICPGAVOL_NOGAIN	0x80
 #define AIC32X4_RMICPGAVOL_NOGAIN	0x80
 
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

PATCH 5/5 ASoC: tlv320aic32x4: Update devicetree documentation

In reply to a message not in the archive
---
 .../devicetree/bindings/sound/tlv320aic32x4.txt    | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/tlv320aic32x4.txt +24 -1
index 143a192..0141aab 100644
@@ -13,12 +13,33 @@ Required properties:
     If you supply ldoin, dv and av are optional. Otherwise they are required
    See regulator/regulator.txt for more information about the detailed binding
    format.
+ - input-use: Array of input pins used by the driver, shall contain 6 values.
+    Pin input order is lin1, rin1, lin2, rin2, lin3, rin3.
+    Each value can hold value for primary function in low nybble (x & 0xf) or
+    value for secondary function in high nybble (x & 0xf0).
+    Possible values are:
+    0 = input not in use
+    1 = input connected with 10k Ohm (0dB)
+    2 = input connected with 20k Ohm (-6dB)
+    3 = input connected with 40k Ohm (-12dB)
+    If value for pin is 0, driver connects the pin weakly to common mode
 
 Optional properties:
  - reset-gpios: Reset-GPIO phandle with args as described in gpio/gpio.txt
  - clocks/clock-names: Clock named 'mclk' for the master clock of the codec.
    See clock/clock-bindings.txt for information about the detailed format.
-
+ - swapdacs: Swap dac channel
+ - powercfg: Power configuration mask for codec
+ - cmode: Array of common mode setup data when channels are used in single
+    ended mode.
+    Parameter order is cmode1, cmode2.
+    Low nybble holds config for left channel and high nybble holds config for
+    right channel.
+    Possible values are:
+    0 = cmode not in use
+    1 = cmode connected with 10k Ohm (0dB)
+    2 = cmode connected with 20k Ohm (-6dB)
+    3 = cmode connected with 40k Ohm (-12dB)
 
 Example:
 
@@ -27,4 +48,6 @@ codec: tlv320aic32x4@18 {
 	reg = <0x18>;
 	clocks = <&clks 201>;
 	clock-names = "mclk";
+	input-use = <1 1 0 0 0 0>;
+	cmode = <0x11 0>;
 };
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html