ASoC: add driver support for CX2092X DSP
Subsystems (3)
v4 cover ASoC: add driver support for CX2092X DSP
From: Simon Ho <[email protected]>
Hi Pierre, Mark and Takashi
I corrected the driver based on your input as below.
- Corrected coding style.
- Removed ".owner" assignment.
- Removed SPI interface support since SPI fearure is removed from this new chip.
Thanks,
Simon
Simon Ho (2):
doc: cx2092x: Add DT bingings doc for CX2092X DSP
ASoC: Add support for Conexant CX2092X DSP
.../devicetree/bindings/sound/cnxt,cx2092x.txt | 25 ++ sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/cx2092x.c | 436 +++++++++++++++++++++ sound/soc/codecs/cx2092x.h | 19 + 5 files changed, 488 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cnxt,cx2092x.txt create mode 100644 sound/soc/codecs/cx2092x.c create mode 100644 sound/soc/codecs/cx2092x.h
Signature · 1 line
2.7.4
PATCH v4 1/2 doc: cx2092x: Add DT bingings doc for CX2092X DSP
From: Simon Ho <[email protected]>
Initial version of CX2092X device tree bindings document.
--- .../devicetree/bindings/sound/cnxt,cx2092x.txt | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cnxt,cx2092x.txt
Documentation/devicetree/bindings/sound/cnxt,cx2092x.txt new file +25 -0
@@ -0,0 +1,25 @@ +Conexant CX20921/CX209724 Voice Processor DSP + +The devices supports the I2C 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-gpios: 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: cx20921@41 { + compatible = "cnxt,cx20921"; + reg = <0x41>; + reset-gpios = <&gpio1 23 0>; +};
Signature · 1 line
2.7.4
PATCH v4 2/2 ASoC: Add support for Conexant CX2092X DSP
In reply to [email protected]From: Simon Ho <[email protected]>
Initial commit of Conexant CX20921/CX20924 I2S Audio DSP driver
The CX2092X devices are 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.
--- sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/cx2092x.c | 436 +++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/cx2092x.h | 19 ++ 4 files changed, 463 insertions(+) create mode 100644 sound/soc/codecs/cx2092x.c create mode 100644 sound/soc/codecs/cx2092x.h
sound/soc/codecs/Kconfig +6 -0
@@ -64,6 +64,7 @@ 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 if I2C select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI select SND_SOC_DA7213 if I2C select SND_SOC_DA7218 if I2C
@@ -500,6 +501,11 @@ config SND_SOC_CX20442 tristate depends on TTY +config SND_SOC_CX2092X + tristate "Conexant CX20921/CX2094 CODEC (I2C)" + depends on I2C + select REGMAP_I2C + config SND_SOC_JZ4740_CODEC select REGMAP_MMIO tristate
sound/soc/codecs/Makefile +2 -0
@@ -57,6 +57,7 @@ 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-da7210-objs := da7210.o snd-soc-da7213-objs := da7213.o snd-soc-da7218-objs := da7218.o
@@ -290,6 +291,7 @@ 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_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.c new file +436 -0
436 lines not on this page · raw message
sound/soc/codecs/cx2092x.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* 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__ + +#define CX2092X_REG_MAX 0x2000 + +#endif
Signature · 1 line
2.7.4
Re: [PATCH v4 2/2] ASoC: Add support for Conexant CX2092X DSP
Quoted 11 lines · On Wed, Apr 05, 2017 at 06:27:13PM +0800, [email protected] wrote:
From: Simon Ho <[email protected]>
Initial commit of Conexant CX20921/CX20924 I2S Audio DSP driver
The CX2092X devices are 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.
Signed-off-by Simon Ho <[email protected]>---
Just a couple of very minor points.
Quoted 9 lines
sound/soc/codecs/cx2092x.c new file +9
-0+static int cx2092x_sendcmd (struct snd_soc_codec *codec, +struct cx2092x_cmd *cmd) +{ +struct cx2092x_priv *cx2092x =snd_soc_codec_get_drvdata (codec); +int ret =0 ; +int num_32b_words = cmd->num_32b_words; +unsigned long time_out; +u32 *i2c_data = (u32 *)cmd; +int size = num_32b_words +2 ;
sound/soc/codecs/cx2092x.c line 103
Quoted 10 lines
sound/soc/codecs/cx2092x.c new file +10
-0+ +/* calculate how many WORD that will be wrote to device*/ + cmd->num_32b_words = cmd->command_id &CX2092X_CMD_GET (0 ) ? +CX2092X_CMD_SIZE : num_32b_words; + +/* write all command data except fo frist 4 bytes*/ + ret =regmap_bulk_write (cx2092x->regmap,4 , &i2c_data[1 ], size -1 ); +if (ret <0 ) { +dev_err (cx2092x->dev,"Failed to write command data\n" ); + goto LEAVE;
All caps for a label is a bit unusual probably would be more normal kernel style to make this lower case.
Quoted 9 lines
sound/soc/codecs/cx2092x.c new file +9
-0+ } + +/* write first 4 bytes command data*/ + ret =regmap_bulk_write (cx2092x->regmap,0 , i2c_data,1 ); +if (ret <0 ) { +dev_err (cx2092x->dev,"Failed to write command\n" ); + goto LEAVE; + } +
sound/soc/codecs/cx2092x.c line 122
Quoted 10 lines
sound/soc/codecs/cx2092x.c new file +10
-0+/* continuously read the first bytes data from device until +* either timeout or the flag 'reply' is set. +*/ + time_out =msecs_to_jiffies (2000 ); + time_out += jiffies; + do { + regmap_bulk_read(cx2092x->regmap, 0, &i2c_data[0], 1); + if (cmd->reply == 1) + break; + mdelay(10);
Do you really want to use mdelay's, they are busy wait loops so thrash the processor, a usleep_range or an msleep might be a more friendly.
Thanks,
Charles
Re: [PATCH v4 2/2] ASoC: Add support for Conexant CX2092X DSP
Quoted 10 lines · Charles Keepax
Quoted 9 lines · On Wed, Apr 05, 2017 at 06:27:13PM +0800, [email protected] wrote:
From: Simon Ho <[email protected]>
Initial commit of Conexant CX20921/CX20924 I2S Audio DSP driver
The CX2092X devices are 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.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Simon Ho <[email protected]>---
Just a couple of very minor points.
Thank you for your useful comments, I will fix them.
Quoted 49 lines
Quoted 9 lines
sound/soc/codecs/cx2092x.c new file +9
-0+static int cx2092x_sendcmd (struct snd_soc_codec *codec, +struct cx2092x_cmd *cmd) +{ +struct cx2092x_priv *cx2092x =snd_soc_codec_get_drvdata (codec); +int ret =0 ; +int num_32b_words = cmd->num_32b_words; +unsigned long time_out; +u32 *i2c_data = (u32 *)cmd; +int size = num_32b_words +2 ;sound/soc/codecs/cx2092x.c line 103
Quoted 10 lines
sound/soc/codecs/cx2092x.c new file +10
-0+ +/* calculate how many WORD that will be wrote to device*/ + cmd->num_32b_words = cmd->command_id &CX2092X_CMD_GET (0 ) ? +CX2092X_CMD_SIZE : num_32b_words; + +/* write all command data except fo frist 4 bytes*/ + ret =regmap_bulk_write (cx2092x->regmap,4 , &i2c_data[1 ], size -1 ); +if (ret <0 ) { +dev_err (cx2092x->dev,"Failed to write command data\n" ); + goto LEAVE;All caps for a label is a bit unusual probably would be more normal kernel style to make this lower case.
Quoted 9 lines
sound/soc/codecs/cx2092x.c new file +9
-0+ } + +/* write first 4 bytes command data*/ + ret =regmap_bulk_write (cx2092x->regmap,0 , i2c_data,1 ); +if (ret <0 ) { +dev_err (cx2092x->dev,"Failed to write command\n" ); + goto LEAVE; + } +sound/soc/codecs/cx2092x.c line 122
Quoted 10 lines
sound/soc/codecs/cx2092x.c new file +10
-0+/* continuously read the first bytes data from device until +* either timeout or the flag 'reply' is set. +*/ + time_out =msecs_to_jiffies (2000 ); + time_out += jiffies; + do { + regmap_bulk_read(cx2092x->regmap, 0, &i2c_data[0], 1); + if (cmd->reply == 1) + break; + mdelay(10);Do you really want to use mdelay's, they are busy wait loops so thrash the processor, a
usleep_rangeor an msleep might be a more friendly.Thanks,
Charles