ASoC: add driver support for Conexant CX2092X DSP
Subsystems (3)
cover ASoC: add driver support for Conexant CX2092X DSP
From: Simon Ho <[email protected]>
This patch adds support for Conexant CX20921/CX20924 I2S AUDIO DSP
Simon Ho (2):
ASoC: cx2092x: Add DT bingings doc for CX2092X DSP
ASoC: Add driver for CX2092X I2S Audio DSP
.../devicetree/bindings/sound/cx2092x.txt | 30 ++ sound/soc/codecs/Kconfig | 17 + sound/soc/codecs/Makefile | 6 + sound/soc/codecs/cx2092x-i2c.c | 54 +++ sound/soc/codecs/cx2092x-spi.c | 57 +++ sound/soc/codecs/cx2092x.c | 419 +++++++++++++++++++++ sound/soc/codecs/cx2092x.h | 26 ++ 7 files changed, 609 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cx2092x.txt create mode 100644 sound/soc/codecs/cx2092x-i2c.c create mode 100644 sound/soc/codecs/cx2092x-spi.c create mode 100644 sound/soc/codecs/cx2092x.c create mode 100644 sound/soc/codecs/cx2092x.h
Signature · 1 line
2.7.4
PATCH 1/2 ASoC: cx2092x: Add DT bingings doc for CX2092X DSP
From: Simon Ho <[email protected]>
Initial version of CX2092X device tree bindings document.
--- .../devicetree/bindings/sound/cx2092x.txt | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cx2092x.txt
Documentation/devicetree/bindings/sound/cx2092x.txt new file +30 -0
@@ -0,0 +1,30 @@ +Conexant CX20921/CX209724 Voice Processor SoC + +The devices supports both the I2C and SPI bus. + +Required properties: + + - compatible : One of "cnxt,cx20921", "cnxt,cx20924". + - reg : the I2C address of the device for I2C, it should be <0x41> + +Optional properties: + + - reset-gpio: A GPIO spec to define which pin is connected to the chip's + !RESET pin. If specified, the driver will assert a hardware + reset at probe time. + +CODEC input pins: + "MIC" - Microphone input + + +Example: + +codec_i2c: cx20921@41 { + compatible = "cnxt,cx20921"; + reg = <0x41>; + reset-gpio = <&gpio 23 0>; +}; + +codec_spi: cx20924@0 { + compatible = "cnxt,cx20924"; +};
Signature · 1 line
2.7.4
Mark Brown
maintainerRe: [PATCH 1/2] ASoC: cx2092x: Add DT bingings doc for CX2092X DSP
Documentation/devicetree/bindings/sound/cx2092x.txt line 14
Quoted 3 lines · On Sat, Feb 18, 2017 at 10:26:30PM +0800, [email protected] wrote:
Documentation/devicetree/bindings/sound/cx2092x.txt new file +3
-0+ - reset-gpio: A GPIO spec to define which pin is connected to the chip's + !RESET pin. If specified, the driver will assert a hardware + reset at probe time.
The DT people say all GPIO specifier names have to be pluralised so this needs to be -gpios even if there's only one GPIO.
Re: [PATCH 1/2] ASoC: cx2092x: Add DT bingings doc for CX2092X DSP
Quoted 8 lines · Mark Brown
Documentation/devicetree/bindings/sound/cx2092x.txt line 14
Quoted 3 lines · On Sat, Feb 18, 2017 at 10:26:30PM +0800, [email protected] wrote:
Documentation/devicetree/bindings/sound/cx2092x.txt new file +3
-0+ - reset-gpio: A GPIO spec to define which pin is connected to the chip's + !RESET pin. If specified, the driver will assert a hardware + reset at probe time.The DT people say all GPIO specifier names have to be pluralised so this needs to be -gpios even if there's only one GPIO.
Thanks for input, I chnaged the name to -gpios.
-Simon
PATCH 2/2 ASoC: Add driver for CX2092X I2S Audio DSP
In reply to [email protected]From: Simon Ho <[email protected]>
Initial commit of the Conexant CX20921/CX20924 I2S audio DSP driver
The CX2092X is a far field voice input processor SoC with ADC.
--- sound/soc/codecs/Kconfig | 17 ++ sound/soc/codecs/Makefile | 6 + sound/soc/codecs/cx2092x-i2c.c | 54 ++++++ sound/soc/codecs/cx2092x-spi.c | 57 ++++++ sound/soc/codecs/cx2092x.c | 419 +++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/cx2092x.h | 26 +++ 6 files changed, 579 insertions(+) create mode 100644 sound/soc/codecs/cx2092x-i2c.c create mode 100644 sound/soc/codecs/cx2092x-spi.c create mode 100644 sound/soc/codecs/cx2092x.c create mode 100644 sound/soc/codecs/cx2092x.h
sound/soc/codecs/Kconfig +17 -0
@@ -63,6 +63,8 @@ config SND_SOC_ALL_CODECS select SND_SOC_CS47L24 if MFD_CS47L24 select SND_SOC_CS53L30 if I2C select SND_SOC_CX20442 if TTY + select SND_SOC_CX2092X_I2C if I2C + select SND_SOC_CX2092X_SPI if SPI_MASTER select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI select SND_SOC_DA7213 if I2C select SND_SOC_DA7218 if I2C
@@ -491,6 +493,21 @@ config SND_SOC_CX20442 tristate depends on TTY +config SND_SOC_CX2092X + tristate + +config SND_SOC_CX2092X_I2C + tristate "Conexant CX20921/CX2094 CODEC (I2C)" + depends on I2C + select SND_SOC_CX2092X + select REGMAP_I2C + +config SND_SOC_CX2092X_SPI + tristate "Conexant CX20921/CX2094 CODEC (SPI)" + depends on SPI_MASTER + select SND_SOC_CX2092X + select REGMAP_SPI + config SND_SOC_JZ4740_CODEC select REGMAP_MMIO tristate
sound/soc/codecs/Makefile +6 -0
@@ -56,6 +56,9 @@ snd-soc-cs4349-objs := cs4349.o snd-soc-cs47l24-objs := cs47l24.o snd-soc-cs53l30-objs := cs53l30.o snd-soc-cx20442-objs := cx20442.o +snd-soc-cx2092x-objs := cx2092x.o +snd-soc-cx2092x-i2c-objs := cx2092x-i2c.o +snd-soc-cx2092x-spi-objs := cx2092x-spi.o snd-soc-da7210-objs := da7210.o snd-soc-da7213-objs := da7213.o snd-soc-da7218-objs := da7218.o
@@ -286,6 +289,9 @@ obj-$(CONFIG_SND_SOC_CS4349) += snd-soc-cs4349.o obj-$(CONFIG_SND_SOC_CS47L24) += snd-soc-cs47l24.o obj-$(CONFIG_SND_SOC_CS53L30) += snd-soc-cs53l30.o obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o +obj-$(CONFIG_SND_SOC_CX2092X) += snd-soc-cx2092x.o +obj-$(CONFIG_SND_SOC_CX2092X_I2C) += snd-soc-cx2092x-i2c.o +obj-$(CONFIG_SND_SOC_CX2092X_SPI) += snd-soc-cx2092x-spi.o obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o obj-$(CONFIG_SND_SOC_DA7213) += snd-soc-da7213.o obj-$(CONFIG_SND_SOC_DA7218) += snd-soc-da7218.o
sound/soc/codecs/cx2092x-i2c.c new file +54 -0
54 lines not on this page · raw message
sound/soc/codecs/cx2092x-spi.c new file +57 -0
57 lines not on this page · raw message
sound/soc/codecs/cx2092x.c new file +419 -0
419 lines not on this page · raw message
sound/soc/codecs/cx2092x.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* cx2092x.h -- CX20921 and CX20924 Audio driver +* +* Copyright: (C) 2017 Conexant Systems, Inc. +* +* This is based on Alexander Sverdlin's CS4271 driver code. +* +* 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 __CX2092X_PRIV_H__ +#define __CX2092X_PRIV_H__ + +#include <linux/regmap.h> + +extern const struct of_device_id cx2092x_dt_ids[]; +extern const struct regmap_config cx2092x_regmap_config; + +int cx2092x_dev_probe (struct device *dev,struct regmap *regmap); + +#define CX2092X_REG_MAX 0x2000 + +#endif
Signature · 1 line
2.7.4
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: Add driver for CX2092X I2S Audio DSP
sound/soc/codecs/cx2092x.c line 266
Quoted 4 lines · On Sat, Feb 18, 2017 at 10:26:31PM +0800, [email protected] wrote:
sound/soc/codecs/cx2092x.c new file +4
-0+static const struct snd_kcontrol_new cx2092x_snd_controls[] = { +CX2092X_CONTROL ("SendCmd" , cmd_info, cmd_get, cmd_put, +SNDRV_CTL_ELEM_ACCESS_READ |SNDRV_CTL_ELEM_ACCESS_WRITE | +SNDRV_CTL_ELEM_ACCESS_VOLATILE ),
This is just tunnels commands from some magic userspace application straight through to the device, taking all the control out of standard Linux. What are these controls doing and why aren't we managing them through standard interfaces? This tends to end up creating problems with things like power management as for example userspace might not figure out that things like suspend and resume are happening.
sound/soc/codecs/cx2092x.c line 314
Quoted 8 lines
sound/soc/codecs/cx2092x.c new file +8
-0+static int cx2092x_reset (struct snd_soc_codec *codec) +{ +struct cx2092x_priv *cx2092x =snd_soc_codec_get_drvdata (codec); + +if (gpio_is_valid (cx2092x->gpio_reset)) { +gpio_set_value (cx2092x->gpio_reset,0 ); +mdelay (10 ); +gpio_set_value (cx2092x->gpio_reset,1 );
Use the _cansleep() versions unless you've got a good reason not to, that way GPIOs on slow buses can be used.
sound/soc/codecs/cx2092x.c line 390
Quoted 3 lines
sound/soc/codecs/cx2092x.c new file +3
-0+if (of_match_device (cx2092x_dt_ids, dev)) + cx2092x->gpio_reset = +of_get_named_gpio (dev->of_node,"reset-gpio" ,0 );
Why do we care if we managed to match the device ID? The GPIO is optional anyway. It's also better to use the gpiod_ APIs if you can, that's more modern and removes the need to special case DT.
sound/soc/codecs/cx2092x.c line 393
Quoted 2 lines
sound/soc/codecs/cx2092x.c new file +2
-0+if (gpio_is_valid (cx2092x->gpio_reset)) { +int ret;
Don't declare variables in the middle of functions.
Re: [PATCH 2/2] ASoC: Add driver for CX2092X I2S Audio DSP
Quoted 14 lines · Mark Brown
sound/soc/codecs/cx2092x.c line 266
Quoted 4 lines · On Sat, Feb 18, 2017 at 10:26:31PM +0800, [email protected] wrote:
sound/soc/codecs/cx2092x.c new file +4
-0+static const struct snd_kcontrol_new cx2092x_snd_controls[] = { +CX2092X_CONTROL ("SendCmd" , cmd_info, cmd_get, cmd_put, +SNDRV_CTL_ELEM_ACCESS_READ |SNDRV_CTL_ELEM_ACCESS_WRITE | +SNDRV_CTL_ELEM_ACCESS_VOLATILE ),This is just tunnels commands from some magic userspace application straight through to the device, taking all the control out of standard Linux. What are these controls doing and why aren't we managing them through standard interfaces? This tends to end up creating problems with things like power management as for example userspace might not figure out that things like suspend and resume are happening.
This device is designed for virtual assisant application need to be always open, listening for users to summon it. There is no any power saving mode support on this device. The processed voice data will be sent to automatic speech recognition (ASR) application for further processing and the processed voice data will be optimized for ASR rather than a human being. So such as mute and volume gain control are not necessary. These tunnels commands are actucally for debugging purpose only, they won't be used on normal operation.
Quoted 12 lines
sound/soc/codecs/cx2092x.c line 314
Quoted 8 lines
sound/soc/codecs/cx2092x.c new file +8
-0+static int cx2092x_reset (struct snd_soc_codec *codec) +{ +struct cx2092x_priv *cx2092x =snd_soc_codec_get_drvdata (codec); + +if (gpio_is_valid (cx2092x->gpio_reset)) { +gpio_set_value (cx2092x->gpio_reset,0 ); +mdelay (10 ); +gpio_set_value (cx2092x->gpio_reset,1 );Use the
_cansleep()versions unless you've got a good reason not to, that way GPIOs on slow buses can be used.
Thanks for input, I changed it to _cansleep() version.
Quoted 8 lines
sound/soc/codecs/cx2092x.c line 390
Quoted 3 lines
sound/soc/codecs/cx2092x.c new file +3
-0+if (of_match_device (cx2092x_dt_ids, dev)) + cx2092x->gpio_reset = +of_get_named_gpio (dev->of_node,"reset-gpio" ,0 );Why do we care if we managed to match the device ID? The GPIO is optional anyway. It's also better to use the
gpiod_APIs if you can, that's more modern and removes the need to special case DT.
No, we don't need to care the deivce ID. Remved.
Learned, will use gpiod_ APIs instead.
Quoted 4 lines
sound/soc/codecs/cx2092x.c line 393
Quoted 2 lines
sound/soc/codecs/cx2092x.c new file +2
-0+if (gpio_is_valid (cx2092x->gpio_reset)) { +int ret;Don't declare variables in the middle of functions.
Understood. corrected it.
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: Add driver for CX2092X I2S Audio DSP
Quoted 9 lines · Simon Ho
Quoted 3 lines · Mark Brown
through standard interfaces? This tends to end up creating problems with things like power management as for example userspace might not figure out that things like suspend and resume are happening.
This device is designed for virtual assisant application need to be always open, listening for users to summon it. There is no any power saving mode support on this device. The processed voice data will be sent to automatic
Power management is just one example of system integration, and frankly even there it's entirely possible that someone will want to disable the functionality some of the time and hence power down the device.
Quoted 3 lines
So such as mute and volume gain control are not necessary. These tunnels commands are actucally for debugging purpose only, they won't be used on normal operation.
So are they even needed in mainline? How will the device function within the system, there's no visible interface for reading back status...? Right now it's hard to see how this device functions usefully in a system.