ASoC: codecs: Add Everest ES7202 support
Subsystems (4)
v3 cover ASoC: codecs: Add Everest ES7202 support
This series adds support for the Everest ES7202, a 2-channel PDM analog-to-digital converter controlled over I2C. Patch 1 adds the DT bindings and patch 2 the ASoC codec driver.
The driver is based on the Rockchip BSP driver, reworked for mainline to use regmap and devm_ helpers, probe the device ID, and report the actual per-step PGA gain.
Changes in v3:
- Add SND_SOC_ES7202 to SND_SOC_ALL_CODECS, convert the copyright block to C++ comments and drop two unneeded includes.
- Turn the volatile check into a switch: the ID registers are now cached after the first read and marked read-only via writeable_reg, so a regcache sync never writes them back; ES7202_RESET stays volatile.
- Set use_single_read/use_single_write so a regcache sync cannot become a multi-register write.
- Use devm_regulator_get() instead of devm_regulator_get_optional().
Changes in v2:
- Drop the hard-coded 30.75 dB PGA gain from the power-up sequence; the PGA keeps its power-on default and the capture volume controls apply the requested gain.
- Keep the PDM outputs muted until a capture stream starts, instead of unmuting at the end of the init sequence.
- Re-run the power-up sequence on resume before syncing the regmap cache.
- Handle the regulator_get_voltage() error return as an int.
- Drop the unnecessary of_match_ptr().
- Fix the copyright header.
Link to v2: https://lore.kernel.org/linux-sound/[email protected]
Link to v1: https://lore.kernel.org/linux-sound/[email protected]
Jun Yan (2):
dt-bindings: sound: add Everest ES7202
ASoC: codecs: add support for Everest ES7202 PDM ADC
.../bindings/sound/everest,es7202.yaml | 56 +++ sound/soc/codecs/Kconfig | 11 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/es7202.c | 373 ++++++++++++++++++ sound/soc/codecs/es7202.h | 131 ++++++ 5 files changed, 573 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/everest,es7202.yaml create mode 100644 sound/soc/codecs/es7202.c create mode 100644 sound/soc/codecs/es7202.h
Signature · 1 line
2.56.0
PATCH v3 1/2 dt-bindings: sound: add Everest ES7202
Add the device-tree bindings for the Everest ES7202, a 2-channel PDM analog-to-digital converter controlled over I2C.
--- .../bindings/sound/everest,es7202.yaml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/everest,es7202.yaml
Documentation/devicetree/bindings/sound/everest,es7202.yaml new file +56 -0
@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/everest,es7202.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Everest ES7202 2 channel PDM analog to digital converter + +maintainers: + - Jun Yan <[email protected]> + +properties: + compatible: + enum: + - everest,es7202 + + reg: + maxItems: 1 + + reset-gpios: + maxItems: 1 + description: GPIO connected to the reset pin (active low) + + vdd-supply: + description: Main power supply, 1.8 V or 3.3 V. Optional; defaults to 3.3 V + + "#sound-dai-cells": + const: 0 + +required: + - compatible + - reg + - "#sound-dai-cells" + +allOf: + - $ref: dai-common.yaml# + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + es7202: codec@30 { + compatible = "everest,es7202"; + reg = <0x30>; + #sound-dai-cells = <0>; + reset-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; + vdd-supply = <&vcc3v3_sys>; + }; + }; +...
Signature · 1 line
2.56.0
PATCH v3 2/2 ASoC: codecs: add support for Everest ES7202 PDM ADC
In reply to Jun YanAdd support for the Everest ES7202, a 2-channel PDM analog-to-digital converter controlled over I2C. The device outputs PDM data to the SoC PDM controller and is configured through registers for supply voltage, analog front-end and per-channel PGA gain.
Based on the Rockchip BSP driver[1] by Binyuan Lan <[email protected]> (committed by Tao Huang <[email protected]>), originally written by David Yang <[email protected]>.
[1] https://github.com/rockchip-linux/kernel/blob/develop-6.1/sound/soc/codecs/es7202.c
--- sound/soc/codecs/Kconfig | 11 ++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/es7202.c | 373 ++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/es7202.h | 131 +++++++++++++ 4 files changed, 517 insertions(+) create mode 100644 sound/soc/codecs/es7202.c create mode 100644 sound/soc/codecs/es7202.h
sound/soc/codecs/Kconfig +11 -0
@@ -126,6 +126,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_ES9039Q2M imply SND_SOC_ES9356 imply SND_SOC_ES7134 + imply SND_SOC_ES7202 imply SND_SOC_ES7241 imply SND_SOC_FRAMER imply SND_SOC_FS210X
@@ -1274,6 +1275,16 @@ config SND_SOC_HDMI_CODEC config SND_SOC_ES7134 tristate "Everest Semi ES7134 CODEC" +config SND_SOC_ES7202 + tristate "Everest Semi ES7202 CODEC" + depends on I2C + select REGMAP_I2C + help + Enable support for the Everest Semiconductor ES7202, a 2-channel + PDM analog-to-digital converter controlled over I2C. The device + outputs PDM data to a SoC PDM controller and is configured through + registers for supply voltage, analog front-end and PGA gain. + config SND_SOC_ES7241 tristate "Everest Semi ES7241 CODEC"
sound/soc/codecs/Makefile +2 -0
@@ -129,6 +129,7 @@ snd-soc-da732x-y := da732x.o snd-soc-da9055-y := da9055.o snd-soc-dmic-y := dmic.o snd-soc-es7134-y := es7134.o +snd-soc-es7202-y := es7202.o snd-soc-es7241-y := es7241.o snd-soc-es83xx-dsm-common-y := es83xx-dsm-common.o snd-soc-es8311-y := es8311.o
@@ -577,6 +578,7 @@ obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o obj-$(CONFIG_SND_SOC_ES7134) += snd-soc-es7134.o +obj-$(CONFIG_SND_SOC_ES7202) += snd-soc-es7202.o obj-$(CONFIG_SND_SOC_ES7241) += snd-soc-es7241.o obj-$(CONFIG_SND_SOC_ES83XX_DSM_COMMON) += snd-soc-es83xx-dsm-common.o obj-$(CONFIG_SND_SOC_ES8311) += snd-soc-es8311.o
sound/soc/codecs/es7202.c new file +373 -0
373 lines not on this page · raw message
sound/soc/codecs/es7202.h new file +131 -0
131 lines not on this page · raw message
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH v3 2/2] ASoC: codecs: add support for Everest ES7202 PDM ADC
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] ASoC: es7202: regcache overwrite and ordering in es7202_suspend() and es7202_resume() - [Low]…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] ASoC: es7202: regcache overwrite and ordering in es7202_suspend() and es7202_resume()
- [Low] ASoC: es7202: positional initializer in es7202_i2c_id table
--
commit 8b7285d85de8871310d7776f1de182623a778972
Author: Jun Yan <[email protected]>
ASoC: codecs: add support for Everest ES7202 PDM ADC
This commit adds an ASoC codec driver for the Everest Semiconductor ES7202 2-channel PDM analog-to-digital converter controlled over I2C.
Quoted 6 lines
sound/soc/codecs/es7202.c new file +0
-0@@ -0,0 +1,373 @@
[ ... ]
Quoted 8 lines
sound/soc/codecs/es7202.c new file +8
-0+static const struct reg_default es7202_reg_defaults[] = { + {ES7202_RESET ,0x10 }, + {ES7202_SOFT_MODE ,0x00 }, + {ES7202_CLK_DIV ,0x04 }, + {ES7202_CLK_EN ,0x00 }, + {ES7202_T1_VMID ,0x01 }, + {ES7202_T2_VMID ,0x18 }, + {ES7202_PDM_INF_CTL ,0x30 },
[ ... ]
Quoted 10 lines
sound/soc/codecs/es7202.c new file +10
-0+static int es7202_suspend (struct snd_soc_component *component) +{ +struct es7202_priv *es7202 =snd_soc_component_get_drvdata (component); + +return es7202_mute_pdm (es7202, true); +} + +static int es7202_resume (struct snd_soc_component *component) +{ +struct es7202_priv *es7202 =snd_soc_component_get_drvdata (component);
sound/soc/codecs/es7202.c line 241
Quoted 10 lines
sound/soc/codecs/es7202.c new file +10
-0+int ret; + +/* re-run the power-up sequence to bring the analog front-end back up */ + ret =es7202_hw_init (es7202); +if (ret) +return ret; + +regcache_mark_dirty (es7202->regmap); +return regcache_sync (es7202->regmap); +}
[Severity: Medium]
Does the suspend and resume sequence corrupt the cached mute state in ES7202_PDM_INF_CTL and re-write the initialization sequence twice?
When a capture stream is prepared, __soc_pcm_prepare() -> snd_soc_dai_digital_mute() -> es7202_mute_stream() -> es7202_mute_pdm() clears ES7202_PDM_INF_CTL_MUTE, setting ES7202_PDM_INF_CTL to 0x30 in both hardware and the regmap cache.
During system suspend, snd_soc_suspend() calls es7202_suspend(), which calls es7202_mute_pdm(es7202, true) without bypassing the regmap cache. That overwrites the cached value of ES7202_PDM_INF_CTL with 0x33 (muted).
On resume, es7202_resume() then runs es7202_hw_init(es7202), which also writes init_seq through regmap_multi_reg_write() into both hardware and the cache (again setting ES7202_PDM_INF_CTL to 0x33), before calling regcache_mark_dirty() and regcache_sync().
In addition, even if ES7202_PDM_INF_CTL had remained 0x30 in the cache, 0x30 matches the entry in es7202_reg_defaults, so regcache_mark_dirty() tells regcache_sync() to skip syncing registers whose cached value matches the default, leaving the hardware at 0x33 as programmed by es7202_hw_init(). Meanwhile, calling regcache_mark_dirty() after es7202_hw_init() causes regcache_sync() to redundantly write all 9 non-volatile registers from init_seq that differ from es7202_reg_defaults a second time over I2C.
Since soc_resume_deferred() only unmutes playback streams via soc_playback_digital_mute(), won't a capture stream in SNDRV_PCM_STATE_PREPARED before suspend (or resumed via SNDRV_PCM_IOCTL_RESUME without re-running .prepare()) remain muted after resume?
[ ... ]
sound/soc/codecs/es7202.c line 355
Quoted 4 lines
sound/soc/codecs/es7202.c new file +4
-0+static const struct i2c_device_id es7202_i2c_id[] = { + {"es7202" }, + { } +};
[Severity: Low]
This isn't a bug, but per I2C subsystem conventions for new struct i2c_device_id tables, could the entry in es7202_i2c_id use a named initializer:
{ .name = "es7202" },Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Mark Brown
maintainerQuoted 11 lines · Jun Yan
ASoC: codecs: Add Everest ES7202 support
This series adds support for the Everest ES7202, a 2-channel PDM analog-to-digital converter controlled over I2C. Patch 1 adds the DT bindings and patch 2 the ASoC codec driver.
The driver is based on the Rockchip BSP driver, reworked for mainline to use regmap and
devm_helpers, probe the device ID, and report the actual per-step PGA gain.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5
Thanks!
[1/2] dt-bindings: sound: add Everest ES7202
https://git.kernel.org/broonie/sound/c/ded65056b6c9 [2/2] ASoC: codecs: add support for Everest ES7202 PDM ADC https://git.kernel.org/broonie/sound/c/063273b18195
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark