Re: [PATCH v5] ASoC: tlv320aic31xx: Add basic codec driver implementation

2014-03-13 Thread Jyri Sarha

On 03/13/2014 02:20 PM, Mark Brown wrote:

On Tue, Mar 11, 2014 at 12:57:32PM +0200, Jyri Sarha wrote:

This commit adds a bare bones driver support for TLV320AIC31XX family
audio codecs. The driver adds basic stereo playback trough headphone
and speaker outputs and mono capture trough microphone inputs.


Applied, thanks.  One thing it'd be good to fix:


+Optional properties:
+
+- gpio-reset - gpio pin number used for codec reset
+- ai31xx-micbias-vg - MicBias Voltage setting


This is optional but...


+   of_property_read_u32(np, "ai31xx-micbias-vg", &value);
+   switch (value) {
+   case MICBIAS_2_0V:
+   case MICBIAS_2_5V:
+   case MICBIAS_AVDDV:
+   aic31xx->pdata.micbias_vg = value;
+   break;
+   default:
+   dev_err(aic31xx->dev,
+   "Bad ai31xx-micbias-vg value %d DT\n",
+   value);
+   aic31xx->pdata.micbias_vg = MICBIAS_2_0V;
+   }


...you'll get an error if it's missing (and an uninitialised memory
read).



Actually you don't. The value-variable is initialized to MICBIAS_2_0V 
and if "ai31xx-micbias-vg" is not present of_property_read_u32 leaves 
the variable untouched, but I'll send a patch for fixing the unused 
variable working shortly.


Forget about the v6 version of the patch.

Thanks,
Jyri

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5] ASoC: tlv320aic31xx: Add basic codec driver implementation

2014-03-13 Thread Mark Brown
On Tue, Mar 11, 2014 at 12:57:32PM +0200, Jyri Sarha wrote:
> This commit adds a bare bones driver support for TLV320AIC31XX family
> audio codecs. The driver adds basic stereo playback trough headphone
> and speaker outputs and mono capture trough microphone inputs.

Applied, thanks.  One thing it'd be good to fix:

> +Optional properties:
> +
> +- gpio-reset - gpio pin number used for codec reset
> +- ai31xx-micbias-vg - MicBias Voltage setting

This is optional but...

> + of_property_read_u32(np, "ai31xx-micbias-vg", &value);
> + switch (value) {
> + case MICBIAS_2_0V:
> + case MICBIAS_2_5V:
> + case MICBIAS_AVDDV:
> + aic31xx->pdata.micbias_vg = value;
> + break;
> + default:
> + dev_err(aic31xx->dev,
> + "Bad ai31xx-micbias-vg value %d DT\n",
> + value);
> + aic31xx->pdata.micbias_vg = MICBIAS_2_0V;
> + }

...you'll get an error if it's missing (and an uninitialised memory
read).


signature.asc
Description: Digital signature


[PATCH v5] ASoC: tlv320aic31xx: Add basic codec driver implementation

2014-03-11 Thread Jyri Sarha
This commit adds a bare bones driver support for TLV320AIC31XX family
audio codecs. The driver adds basic stereo playback trough headphone
and speaker outputs and mono capture trough microphone inputs.

The driver is currently missing support at least for mini DSP features
and jack detection. I have tested the driver only on TLV320AIC3111,
but based on the data sheets TLV320AIC3100, TLV320AIC3110, and
TLV320AIC3120 should work Ok too.

The base for the implementation was taken from:
g...@gitorious.org:ti-codecs/ti-codecs.git ajitk/topics/k3.10.1-aic31xx
-branch at commit 77504eba0294764e9e63b4a0c696b44db187cd13.

Signed-off-by: Jyri Sarha 
---
Since v4 version:
- Remove MICBIAS_OFF DT parameter
- Remove logging and add missing default: to aic31xx_dapm_power_event() 
- Take control, widget, and route adding errors into account
- Don't try soft reset in power event handler
- Remove route to MICBIAS from codec driver damp routing table and add it
  as output pin to DT doc
- Update year in copyright message and change triple newlines to double
- Remove internal DAC/ADC routes that were still haunting in the previous patch
- Allow PLL reprogramming on the fly as it appears to work just fine

BR,
Jyri

 .../devicetree/bindings/sound/tlv320aic31xx.txt|   61 +
 include/dt-bindings/sound/tlv320aic31xx-micbias.h  |8 +
 sound/soc/codecs/Kconfig   |4 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tlv320aic31xx.c   | 1295 
 sound/soc/codecs/tlv320aic31xx.h   |  258 
 6 files changed, 1628 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tlv320aic31xx.txt
 create mode 100644 include/dt-bindings/sound/tlv320aic31xx-micbias.h
 create mode 100644 sound/soc/codecs/tlv320aic31xx.c
 create mode 100644 sound/soc/codecs/tlv320aic31xx.h

diff --git a/Documentation/devicetree/bindings/sound/tlv320aic31xx.txt 
b/Documentation/devicetree/bindings/sound/tlv320aic31xx.txt
new file mode 100644
index 000..74c66de
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tlv320aic31xx.txt
@@ -0,0 +1,61 @@
+Texas Instruments - tlv320aic31xx Codec module
+
+The tlv320aic31xx serial control bus communicates through I2C protocols
+
+Required properties:
+
+- compatible - "string" - One of:
+"ti,tlv320aic310x" - Generic TLV320AIC31xx with mono speaker amp
+"ti,tlv320aic311x" - Generic TLV320AIC31xx with stereo speaker amp
+"ti,tlv320aic3100" - TLV320AIC3100 (mono speaker amp, no MiniDSP)
+"ti,tlv320aic3110" - TLV320AIC3110 (stereo speaker amp, no MiniDSP)
+"ti,tlv320aic3120" - TLV320AIC3120 (mono speaker amp, MiniDSP)
+"ti,tlv320aic3111" - TLV320AIC3111 (stereo speaker amp, MiniDSP)
+
+- reg -  -  I2C slave address
+
+
+Optional properties:
+
+- gpio-reset - gpio pin number used for codec reset
+- ai31xx-micbias-vg - MicBias Voltage setting
+1 or MICBIAS_2_0V - MICBIAS output is powered to 2.0V
+2 or MICBIAS_2_5V - MICBIAS output is powered to 2.5V
+3 or MICBIAS_AVDD - MICBIAS output is connected to AVDD
+   If this node is not mentioned or if the value is unknown, then
+   micbias is set to 2.0V.
+- HPVDD-supply, SPRVDD-supply, SPLVDD-supply, AVDD-supply, IOVDD-supply,
+  DVDD-supply : power supplies for the device as covered in
+  Documentation/devicetree/bindings/regulator/regulator.txt
+
+CODEC output pins:
+  * HPL
+  * HPR
+  * SPL, devices with stereo speaker amp
+  * SPR, devices with stereo speaker amp
+  * SPK, devices with mono speaker amp
+  * MICBIAS
+
+CODEC input pins:
+  * MIC1LP
+  * MIC1RP
+  * MIC1LM
+
+The pins can be used in referring sound node's audio-routing property.
+
+Example:
+#include 
+
+tlv320aic31xx: tlv320aic31xx@18 {
+   compatible = "ti,tlv320aic311x";
+   reg = <0x18>;
+
+   ai31xx-micbias-vg = ;
+
+   HPVDD-supply = <®ulator>;
+   SPRVDD-supply = <®ulator>;
+   SPLVDD-supply = <®ulator>;
+   AVDD-supply = <®ulator>;
+   IOVDD-supply = <®ulator>;
+   DVDD-supply = <®ulator>;
+};
diff --git a/include/dt-bindings/sound/tlv320aic31xx-micbias.h 
b/include/dt-bindings/sound/tlv320aic31xx-micbias.h
new file mode 100644
index 000..f5cb772
--- /dev/null
+++ b/include/dt-bindings/sound/tlv320aic31xx-micbias.h
@@ -0,0 +1,8 @@
+#ifndef __DT_TLV320AIC31XX_MICBIAS_H
+#define __DT_TLV320AIC31XX_MICBIAS_H
+
+#define MICBIAS_2_0V   1
+#define MICBIAS_2_5V   2
+#define MICBIAS_AVDDV  3
+
+#endif /* __DT_TLV320AIC31XX_MICBIAS_H */
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index e19b64f..af3c049 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -83,6 +83,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TAS5086 if I2C
select SND_SOC_TLV320AIC23 if I2C
select SND_SOC_TLV320AIC26 if SPI_MASTER
+   select SND_SOC_TLV320AIC31XX if I2C
select SND_SOC_TLV320AIC32X4 if I2C
sel