ASoC: nau8825: Add driver for headset chip Nuvoton 8825
Subsystems (3)
PATCH 1/1 ASoC: nau8825: Add driver for headset chip Nuvoton 8825
--- .../devicetree/bindings/sound/nau8825.txt | 18 + sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/nau8825.c | 874 +++++++++++++++++++++ sound/soc/codecs/nau8825.h | 262 ++++++ 5 files changed, 1160 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/nau8825.txt create mode 100644 sound/soc/codecs/nau8825.c create mode 100644 sound/soc/codecs/nau8825.h
Documentation/devicetree/bindings/sound/nau8825.txt new file +18 -0
@@ -0,0 +1,18 @@ +Nuvoton NAU8825 audio codec + +This device supports I2C only. + +Required properties: + - compatible : Must be "nuvoton,nau8825" + - reg : the I2C address of the device. This is either 0x1a (CSB=0) or 0x1b (CSB=1). + +Optional properties: + - nuvoton,jkdet-pullup: Pull-up JKDET pin. Boolean. + +Example: + + codec: nau8825@1a { + compatible = "nuvoton,nau8825"; + reg = <0x1a>; + nuvoton,jkdet-pullup = "true"; + };
sound/soc/codecs/Kconfig +4 -0
@@ -78,6 +78,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_MAX9877 if I2C select SND_SOC_MC13783 if MFD_MC13XXX select SND_SOC_ML26124 if I2C + select SND_SOC_NAU8825 if I2C select SND_SOC_HDMI_CODEC select SND_SOC_PCM1681 if I2C select SND_SOC_PCM1792A if SPI_MASTER
@@ -892,6 +893,9 @@ config SND_SOC_MC13783 config SND_SOC_ML26124 tristate +config SND_SOC_NAU8825 + tristate + config SND_SOC_TPA6130A2 tristate "Texas Instruments TPA6130A2 headphone amplifier" depends on I2C
sound/soc/codecs/Makefile +2 -0
@@ -71,6 +71,7 @@ snd-soc-max98925-objs := max98925.o snd-soc-max9850-objs := max9850.o snd-soc-mc13783-objs := mc13783.o snd-soc-ml26124-objs := ml26124.o +snd-soc-nau8825-objs := nau8825.o snd-soc-hdmi-codec-objs := hdmi.o snd-soc-pcm1681-objs := pcm1681.o snd-soc-pcm1792a-codec-objs := pcm1792a.o
@@ -262,6 +263,7 @@ obj-$(CONFIG_SND_SOC_MAX98925) += snd-soc-max98925.o obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o +obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o obj-$(CONFIG_SND_SOC_HDMI_CODEC) += snd-soc-hdmi-codec.o obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o obj-$(CONFIG_SND_SOC_PCM1792A) += snd-soc-pcm1792a-codec.o
sound/soc/codecs/nau8825.c new file +874 -0
874 lines not on this page · raw message
sound/soc/codecs/nau8825.h new file +262 -0
262 lines not on this page · raw message
Signature · 1 line
2.5.0
Mark Brown
maintainerQuoted 1 line · Anatol Pomozov
Signed-off-by Anatol Pomozov <[email protected]>
My previous comments about the magic number sequences still apply. Also...
Documentation/devicetree/bindings/sound/nau8825.txt line 17
Quoted 4 lines
Documentation/devicetree/bindings/sound/nau8825.txt new file +4
-0+ codec: nau8825@1a { + compatible = "nuvoton,nau8825"; + reg = <0x1a>; + nuvoton,jkdet-pullup = "true";
...this isn't how boolean properties are done, the property simply needs to exist.
Quoted 9 lines
sound/soc/codecs/nau8825.c new file +9
-0+static int nau8825_output_driver_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct snd_soc_codec *codec =snd_soc_dapm_to_codec (w->dapm); +struct nau8825 *nau8825 =snd_soc_codec_get_drvdata (codec); +struct regmap *regmap = nau8825->regmap; + +if (SND_SOC_DAPM_EVENT_ON (event)) { +/* Power Up L and R Output Drivers */
sound/soc/codecs/nau8825.c line 233
Quoted 10 lines
sound/soc/codecs/nau8825.c new file +10
-0+regmap_update_bits (regmap,NAU8825_REG_POWER_UP_CONTROL ,0x3c , +0x3c ); +/* Power up Main Output Drivers (The main driver must be turned +on after the predriver to avoid pops) */ +regmap_update_bits (regmap,NAU8825_REG_POWER_UP_CONTROL ,0x3 , +0x3 ); + }else { +/* Power Down L and R Output Drivers */ +regmap_update_bits (regmap,NAU8825_REG_POWER_UP_CONTROL ,0x3f , +0x0 );
You should be able to implement this with _S widgets without requiring explicit code, they're designed for exactly this situation.
sound/soc/codecs/nau8825.c line 489
Quoted 9 lines
sound/soc/codecs/nau8825.c new file +9
-0+int nau8825_enable_jack_detect (struct snd_soc_codec *codec, +struct snd_soc_jack *jack) +{ +struct nau8825 *nau8825 =snd_soc_codec_get_drvdata (codec); + +snd_jack_set_key (jack->jack,SND_JACK_BTN_0 ,KEY_MEDIA ); +snd_jack_set_key (jack->jack,SND_JACK_BTN_1 ,KEY_VOICECOMMAND ); +snd_jack_set_key (jack->jack,SND_JACK_BTN_2 ,KEY_VOLUMEUP ); +snd_jack_set_key (jack->jack,SND_JACK_BTN_3 ,KEY_VOLUMEDOWN );
The driver shouldn't do this - it's up to the system integration to define how the buttons are mapped.
sound/soc/codecs/nau8825.c line 495
Quoted 6 lines
sound/soc/codecs/nau8825.c new file +6
-0+ + nau8825->jack = jack; + +return 0 ; +} +EXPORT_SYMBOL_GPL (nau8825_enable_jack_detect);
This function doesn't appear to affect the hardware. I would expect that the jack detection hardware is turned off when not in use.
Quoted 5 lines
sound/soc/codecs/nau8825.c new file +5
-0+static void nau8825_setup_buttons (struct regmap *regmap) +{ +/* Setup Button Detect (Debounce, number of buttons, and Hysteresis) */ +regmap_write (regmap,NAU8825_REG_KEYDET_CTRL ,0x7311 ); +
sound/soc/codecs/nau8825.c line 686
Quoted 10 lines
sound/soc/codecs/nau8825.c new file +10
-0+/* Setup 4 buttons impedane according to Android specification +* https://source.android.com/accessories/headset-spec.html +* Button 0 - 0-70 Ohm +* Button 1 - 110-180 Ohm +* Button 2 - 210-290 Ohm +* Button 3 - 360-680 Ohm +*/ +regmap_write (regmap,NAU8825_REG_VDET_THRESHOLD_1 ,0x0f1f ); +regmap_write (regmap,NAU8825_REG_VDET_THRESHOLD_2 ,0x325f ); +}
This looks like system configuration...
sound/soc/codecs/nau8825.c line 761
Quoted 5 lines
sound/soc/codecs/nau8825.c new file +5
-0+/* The interrupt clock is gated by x1[10:8], +* one of them needs to be enabled all the time for +* interrupts to happen. */ +snd_soc_dapm_force_enable_pin (&codec->dapm,"DDACR" ); +snd_soc_dapm_sync (&codec->dapm);
This should be tied to jack detection, not done unconditionally.