Skip to contentSkip to conversation

ASoC: add TI ts3a227e headset chip driver

PATCH Superseded Dylan Reid 2 participants 3 messages Nov 13, 2014

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Dylan Reid

author
#0 lore raw

PATCH v2 1/1 ASoC: add TI ts3a227e headset chip driver

The TS3A227E is an autonomous audio accessory detection and configuration switch that detects 3-pole or 4-pole audio accessories and configures internal switches to route the signals accordingly.

This chip also has built-in support for the new button standard described in the Android "Wired audio headset specification" v1.0. These buttons will be reported on the jack as buttons 0-3 mapped to KEY_MEDIA, KEY_VOLUMEUP, KEY_VOLUMEDOWN, and KEY_VOICE_COMMAND.

This will be added as an aux_dev and have the jack passed in from the machine driver.

---
Changes since v1:
Use button to key mapping instead of separate input device

---
 .../devicetree/bindings/sound/ts3a227e.txt         |  26 ++
 sound/soc/codecs/Kconfig                           |   5 +
 sound/soc/codecs/Makefile                          |   2 +
 sound/soc/codecs/ts3a227e.c                        | 321 +++++++++++++++++++++
 sound/soc/codecs/ts3a227e.h                        |  17 ++
 5 files changed, 371 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/ts3a227e.txt
 create mode 100644 sound/soc/codecs/ts3a227e.c
 create mode 100644 sound/soc/codecs/ts3a227e.h
Documentation/devicetree/bindings/sound/ts3a227e.txt new file +26 -0
new file mode 100644
index 0000000..e8bf23e
@@ -0,0 +1,26 @@
+Texas Instruments TS3A227E
+Autonomous Audio Accessory Detection and Configuration Switch
+
+The TS3A227E detect headsets of 3-ring and 4-ring standards and
+switches automatically to route the microphone correctly.  It also
+handles key press detection in accordance with the Android audio
+headset specification v1.0.
+
+Required properties:
+
+ - compatible:		Should contain "ti,ts3a227e".
+ - reg:			The i2c address. Should contain <0x3b>.
+ - interrupt-parent:	The parent interrupt controller
+ - interrupts:		Interrupt number for /INT pin from the 227e
+
+
+Examples:
+
+	i2c {
+		ts3a227e@3b {
+			compatible = "ti,ts3a227e";
+			reg = <0x3b>;
+			interrupt-parent = <&gpio>;
+			interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+		};
+	};
sound/soc/codecs/Kconfig +5 -0
index a68d173..243ec86 100644
@@ -109,6 +109,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_TLV320AIC3X if I2C
 	select SND_SOC_TPA6130A2 if I2C
 	select SND_SOC_TLV320DAC33 if I2C
+	select SND_SOC_TS3A227E if I2C
 	select SND_SOC_TWL4030 if TWL4030_CORE
 	select SND_SOC_TWL6040 if TWL6040_CORE
 	select SND_SOC_UDA134X
@@ -607,6 +608,10 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
 	tristate
 
+config SND_SOC_TS3A227E
+	tristate "TI Headset/Mic detect and keypress chip"
+	depends on I2C
+
 config SND_SOC_TWL4030
 	select MFD_TWL4030_AUDIO
 	tristate
sound/soc/codecs/Makefile +2 -0
index 5dce451..a1eb7ef 100644
@@ -109,6 +109,7 @@ snd-soc-tlv320aic31xx-objs := tlv320aic31xx.o
 snd-soc-tlv320aic32x4-objs := tlv320aic32x4.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 snd-soc-tlv320dac33-objs := tlv320dac33.o
+snd-soc-ts3a227e-objs := ts3a227e.o
 snd-soc-twl4030-objs := twl4030.o
 snd-soc-twl6040-objs := twl6040.o
 snd-soc-uda134x-objs := uda134x.o
@@ -282,6 +283,7 @@ obj-$(CONFIG_SND_SOC_TLV320AIC31XX)     += snd-soc-tlv320aic31xx.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4)     += snd-soc-tlv320aic32x4.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)	+= snd-soc-tlv320aic3x.o
 obj-$(CONFIG_SND_SOC_TLV320DAC33)	+= snd-soc-tlv320dac33.o
+obj-$(CONFIG_SND_SOC_TS3A227E)	+= snd-soc-ts3a227e.o
 obj-$(CONFIG_SND_SOC_TWL4030)	+= snd-soc-twl4030.o
 obj-$(CONFIG_SND_SOC_TWL6040)	+= snd-soc-twl6040.o
 obj-$(CONFIG_SND_SOC_UDA134X)	+= snd-soc-uda134x.o
sound/soc/codecs/ts3a227e.c new file +321 -0

321 lines not on this page · raw message

sound/soc/codecs/ts3a227e.h new file +17 -0
new file mode 100644
index 0000000..8a58886
@@ -0,0 +1,17 @@
+/*
+ * TS3A227E Autonous Audio Accessory Detection and Configureation Switch
+ *
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _TS3A227E_H
+#define _TS3A227E_H
+
+int ts3a227e_enable_jack_detect(struct snd_soc_codec *codec,
+				struct snd_soc_jack *jack);
+
+#endif
Signature · 1 line
2.1.2.330.g565301e
#1 lore raw

sound/soc/codecs/ts3a227e.c line 277

Quoted 5 lines · Dylan Reid
sound/soc/codecs/ts3a227e.c new file +3 -0
+static struct snd_soc_codec_driver ts3a227e_codec_driver;
[...]
+	ret = snd_soc_register_codec(&i2c->dev, &ts3a227e_codec_driver,
+				     NULL, 0);
[...]

Since the driver doesn't need anything CODEC specific it could be made a component driver and then you can also use devm_snd_soc_register_component.

author
#2 lore raw
Quoted 9 lines · Lars-Peter Clausen

sound/soc/codecs/ts3a227e.c line 277

Quoted 6 lines · Dylan Reid
sound/soc/codecs/ts3a227e.c new file +3 -0
+static struct snd_soc_codec_driver ts3a227e_codec_driver;
[...]
+       ret = snd_soc_register_codec(&i2c->dev, &ts3a227e_codec_driver,
+                                    NULL, 0);
[...]
Quoted 3 lines

Since the driver doesn't need anything CODEC specific it could be made a component driver and then you can also use devm_snd_soc_register_component.

Thanks Lars. That makes registering the jack from the platform driver simpler too.