ASoC: codecs: add support for ES8326
Subsystems (3)
PATCH v3 1/2 ASoC: codecs: add support for ES8326
The ES8326 codec is not compatible with ES8316 and requires a dedicated driver.
-----
v3 changes since v2
1. remove .non_legacy_dai_naming flag
----
v2
changes since v1:
1. add i2c_id_table
2. add .endianness .use_pmdown_time flag
3. fix dt-binding name
--- sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/es8326.c | 808 ++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/es8326.h | 187 +++++++++ 4 files changed, 1002 insertions(+) mode change 100644 => 100755 sound/soc/codecs/Kconfig mode change 100644 => 100755 sound/soc/codecs/Makefile create mode 100755 sound/soc/codecs/es8326.c create mode 100755 sound/soc/codecs/es8326.h
sound/soc/codecs/Kconfig +5 -0
@@ -98,6 +98,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_DA9055 imply SND_SOC_DMIC imply SND_SOC_ES8316 + imply SND_SOC_ES8326 imply SND_SOC_ES8328_SPI imply SND_SOC_ES8328_I2C imply SND_SOC_ES7134
@@ -911,6 +912,10 @@ config SND_SOC_ES8316 tristate "Everest Semi ES8316 CODEC" depends on I2C +config SND_SOC_ES8326 + tristate "Everest Semi ES8326 CODEC" + depends on I2C + config SND_SOC_ES8328 tristate
sound/soc/codecs/Makefile +2 -0
@@ -100,6 +100,7 @@ snd-soc-dmic-objs := dmic.o snd-soc-es7134-objs := es7134.o snd-soc-es7241-objs := es7241.o snd-soc-es8316-objs := es8316.o +snd-soc-es8326-objs := es8326.o snd-soc-es8328-objs := es8328.o snd-soc-es8328-i2c-objs := es8328-i2c.o snd-soc-es8328-spi-objs := es8328-spi.o
@@ -452,6 +453,7 @@ obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o obj-$(CONFIG_SND_SOC_ES7134) += snd-soc-es7134.o obj-$(CONFIG_SND_SOC_ES7241) += snd-soc-es7241.o obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.o +obj-$(CONFIG_SND_SOC_ES8326) += snd-soc-es8326.o obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
sound/soc/codecs/es8326.c new file +808 -0
808 lines not on this page · raw message
sound/soc/codecs/es8326.h new file +187 -0
187 lines not on this page · raw message
Signature · 1 line
2.36.1
PATCH v3 2/2 ASoC: dt-bindings: Add Everest ES8326 audio CODEC
Add device tree binding documentation for Everest ES8326
--- .../bindings/sound/everest,es8326.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 Documentation/devicetree/bindings/sound/everest,es8326.yaml
Documentation/devicetree/bindings/sound/everest,es8326.yaml new file +84 -0
@@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/everest,es8326.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Everest ES8326 audio CODEC + +maintainers: + - David Yang <[email protected]> + +properties: + compatible: + const: everest,es8326 + + reg: + maxItems: 1 + + clocks: + items: + - description: clock for master clock (MCLK) + + clock-names: + items: + - const: mclk + + "#sound-dai-cells": + const: 0 + + everest,jack-pol: + description: + just the value of reg 57. Bit(3) decides whether the jack polarity is inverted. + Bit(2) decides whether the bottom on the headset is inverted. + Bit(1)/(0) decides the mic properity to be OMTP/CTIA or auto. + $ref: /schemas/types.yaml#/definitions/uint8-array + minimum: 0 + maximum: 0x0f + default: 0x0f + + everest,mic1-src: + description: + the value of reg 2A when headset plugged. + $ref: /schemas/types.yaml#/definitions/uint8-array + minimum: 0x00 + maximum: 0x77 + default: 0x22 + + everest,mic2-src: + description: + the value of reg 2A when headset unplugged. + $ref: /schemas/types.yaml#/definitions/uint8-array + minimum: 0x00 + maximum: 0x77 + default: 0x44 + + everest,jack-detect-inverted: + description: + Defined to invert the jack detection. + $ref: /schemas/types.yaml#/definitions/flag + +required: + - compatible + - reg + - "#sound-dai-cells" + + +additionalProperties: false + +examples: + - | + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + es8326: codec@19 { + compatible = "everest,es8326"; + reg = <0x19>; + clocks = <&clks 10>; + clock-names = "mclk"; + #sound-dai-cells = <0>; + everest,mic1-src = [22]; + everest,mic2-src = [44]; + everest,jack-pol = [0e]; + }; + };
Signature · 1 line
2.36.1
Rob Herring
maintainerRe: [PATCH v3 2/2] ASoC: dt-bindings: Add Everest ES8326 audio CODEC
Quoted 38 lines · Zhu Ning
Add device tree binding documentation for Everest ES8326
Signed-off-by David Yang <[email protected]>Signed-off-by Zhu Ning <[email protected]>--- .../bindings/sound/everest,es8326.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 Documentation/devicetree/bindings/sound/everest,es8326.yamlDocumentation/devicetree/bindings/sound/everest,es8326.yaml new file +23
-0@@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/everest,es8326.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Everest ES8326 audio CODEC + +maintainers: + - David Yang <[email protected]> + +properties: + compatible: + const: everest,es8326 + + reg: + maxItems: 1 + + clocks: + items: + - description: clock for master clock (MCLK) + + clock-names:
Documentation/devicetree/bindings/sound/everest,es8326.yaml line 33
Quoted 10 lines
Documentation/devicetree/bindings/sound/everest,es8326.yaml new file +10
-0+ items: + - const: mclk + + "#sound-dai-cells": + const: 0 + + everest,jack-pol: + description: + just the value of reg 57. Bit(3) decides whether the jack polarity is inverted. + Bit(2) decides whether the bottom on the headset is inverted.
s/bottom/button/?
Documentation/devicetree/bindings/sound/everest,es8326.yaml line 35
Quoted 2 lines
Documentation/devicetree/bindings/sound/everest,es8326.yaml new file +2
-0+ Bit(1)/(0) decides the mic properity to be OMTP/CTIA or auto. + $ref: /schemas/types.yaml#/definitions/uint8-array
Array or...
Documentation/devicetree/bindings/sound/everest,es8326.yaml line 38
Quoted 3 lines
Documentation/devicetree/bindings/sound/everest,es8326.yaml new file +3
-0+ minimum: 0 + maximum: 0x0f + default: 0x0f
Scalar?
Quoted 10 lines
Documentation/devicetree/bindings/sound/everest,es8326.yaml new file +10
-0+ + everest,mic1-src: + description: + the value of reg 2A when headset plugged. + $ref: /schemas/types.yaml#/definitions/uint8-array + minimum: 0x00 + maximum: 0x77 + default: 0x22 + + everest,mic2-src:
Documentation/devicetree/bindings/sound/everest,es8326.yaml line 58
Quoted 10 lines
Documentation/devicetree/bindings/sound/everest,es8326.yaml new file +10
-0+ description: + the value of reg 2A when headset unplugged. + $ref: /schemas/types.yaml#/definitions/uint8-array + minimum: 0x00 + maximum: 0x77 + default: 0x44 + + everest,jack-detect-inverted: + description: + Defined to invert the jack detection.
What's the difference with this and bit 3 of everest,jack-pol?
We already have numerous vendor properties for jack detect. Can we come up with something common?
The problem with 'inverted' is it assumes you know the non-inverted state. Better to just state high or low.
Documentation/devicetree/bindings/sound/everest,es8326.yaml line 66
Quoted 8 lines
Documentation/devicetree/bindings/sound/everest,es8326.yaml new file +8
-0+ $ref: /schemas/types.yaml#/definitions/flag + +required: + - compatible + - reg + - "#sound-dai-cells" + +
Extra blank line.
Documentation/devicetree/bindings/sound/everest,es8326.yaml line 71
Quoted 5 lines
Documentation/devicetree/bindings/sound/everest,es8326.yaml new file +5
-0+additionalProperties: false + +examples: + - | + i2c0 {
i2c {
Quoted 17 lines
Documentation/devicetree/bindings/sound/everest,es8326.yaml new file +13
-0+ #address-cells = <1>; + #size-cells = <0>; + es8326: codec@19 { + compatible = "everest,es8326"; + reg = <0x19>; + clocks = <&clks 10>; + clock-names = "mclk"; + #sound-dai-cells = <0>; + everest,mic1-src = [22]; + everest,mic2-src = [44]; + everest,jack-pol = [0e]; + }; + };Signature · 1 line
2.36.1
Mark Brown
maintainerQuoted 10 lines · Zhu Ning
sound/soc/codecs/es8326.c new file +10
-0+static struct snd_pcm_hw_constraint_list es8326_constraints = { + .count =ARRAY_SIZE (es8326_rates), + .list = es8326_rates, +}; + +static int es8326_set_dai_sysclk (struct snd_soc_dai *codec_dai, +int clk_id,unsigned int freq,int dir) +{ +struct snd_soc_component *codec = codec_dai->component; +struct es8326_priv *es8326 =snd_soc_component_get_drvdata (codec);
sound/soc/codecs/es8326.c line 334
Quoted 10 lines
sound/soc/codecs/es8326.c new file +10
-0+ + es8326->sysclk = freq; + +if (freq ==0 ) { + es8326->sysclk_constraints->list =NULL ; + es8326->sysclk_constraints->count =0 ; +return 0 ; + } + + es8326->sysclk_constraints = &es8326_constraints;
Nothing ever restores the constraints if a clock is specified again, and in general it's odd that the enable/disable don't match up - if we're setting variable constraints I'd expect that in the freq == 0 case we should be setting ->sysclk_constraints to NULL rather than the contents. Indeed, we'll segfault here if the frequency is set to 0 without having first been set to some actual value. It's also bad to modify static data potentially shared between multiple instances of the device in a system.
Having said all that though I'm not clear why we're doing this constraint stuff at all, we never reference sysclk_constraints during startup and teardown and you'd usually do this because you want to set constraints that depend on the sysclk but this is just a constant set of constraints that should be set in the DAI desription.
Quoted 8 lines
sound/soc/codecs/es8326.c new file +8
-0+if (coeff >=0 ) { +regmap_write (es8326->regmap,ES8326_CLK_DIV1_04 , + coeff_div[coeff].reg4); +regmap_write (es8326->regmap,ES8326_CLK_DIV2_05 , + coeff_div[coeff].reg5); +regmap_write (es8326->regmap,ES8326_CLK_DLL_06 , + coeff_div[coeff].reg6); + regmap_write(es8326->regmap, ES8326_CLK_MUX_07,
sound/soc/codecs/es8326.c line 430
Quoted 10 lines
sound/soc/codecs/es8326.c new file +10
-0+ coeff_div[coeff].reg7); +regmap_write (es8326->regmap,ES8326_CLK_ADC_SEL_08 , + coeff_div[coeff].reg8); +regmap_write (es8326->regmap,ES8326_CLK_DAC_SEL_09 , + coeff_div[coeff].reg9); +regmap_write (es8326->regmap,ES8326_CLK_ADC_OSR_0A , + coeff_div[coeff].rega); +regmap_write (es8326->regmap,ES8326_CLK_DAC_OSR_0B , + coeff_div[coeff].regb); + }
This will just leave the divider setup at whatever they were last set at if we don't get a value which given the names of the registers I suspect won't go too well, it'd be better to print a warning just in case.
sound/soc/codecs/es8326.c line 598
Quoted 2 lines
sound/soc/codecs/es8326.c new file +2
-0+regmap_write (es8326->regmap,ES8326_INT_SOURCE_58 ,0x08 ); +regmap_write (es8326->regmap,ES8326_INTOUT_IO_59 ,0x45 );
This really does look like board specific configuration which should come from DT.
Much improved version, thank you. See additional comments/questions below.
sound/soc/codecs/es8326.c line 443
Quoted 9 lines
sound/soc/codecs/es8326.c new file +9
-0+static int es8326_set_bias_level (struct snd_soc_component *codec, +enum snd_soc_bias_level level) +{ +struct es8326_priv *es8326 =snd_soc_component_get_drvdata (codec); +int ret; + +switch (level) { +case SND_SOC_BIAS_ON : +if (!IS_ERR (es8326->mclk)) {
the IS_ERR case is taken care of in the probe, so should this be
if (es8326->mclk)
for symmetry with the BIAS_OFF case?
Quoted 81 lines
sound/soc/codecs/es8326.c new file +80
-0+ ret =clk_prepare_enable (es8326->mclk); +if (ret) +return ret; + } +regmap_write (es8326->regmap,ES8326_RESET_00 ,ES8326_PWRUP_SEQ_EN ); +regmap_write (es8326->regmap,ES8326_INTOUT_IO_59 ,0x45 ); +regmap_write (es8326->regmap,ES8326_SDINOUT1_IO_5A , + (ES8326_IO_DMIC_CLK <<ES8326_SDINOUT1_SHIFT )); +regmap_write (es8326->regmap,ES8326_SDINOUT23_IO_5B ,ES8326_IO_INPUT ); +regmap_write (es8326->regmap,ES8326_CLK_RESAMPLE_03 ,0x05 ); +regmap_write (es8326->regmap,ES8326_VMIDSEL_18 ,0x02 ); +regmap_write (es8326->regmap,ES8326_PGA_PDN_17 ,0x40 ); +regmap_write (es8326->regmap,ES8326_DAC2HPMIX_25 ,0xAA ); +regmap_write (es8326->regmap,ES8326_RESET_00 ,ES8326_CSM_ON ); +break ; +case SND_SOC_BIAS_PREPARE : +break ; +case SND_SOC_BIAS_STANDBY : +break ; +case SND_SOC_BIAS_OFF : + if (es8326->mclk)> + clk_disable_unprepare(es8326->mclk); +regmap_write (es8326->regmap,ES8326_DAC2HPMIX_25 ,0x11 ); +regmap_write (es8326->regmap,ES8326_RESET_00 ,ES8326_CSM_OFF ); +regmap_write (es8326->regmap,ES8326_PGA_PDN_17 ,0xF8 ); +regmap_write (es8326->regmap,ES8326_VMIDSEL_18 ,0x00 ); +regmap_write (es8326->regmap,ES8326_INT_SOURCE_58 ,0x08 ); +regmap_write (es8326->regmap,ES8326_SDINOUT1_IO_5A ,ES8326_IO_INPUT ); +regmap_write (es8326->regmap,ES8326_SDINOUT23_IO_5B ,ES8326_IO_INPUT ); +regmap_write (es8326->regmap,ES8326_RESET_00 , +ES8326_CODEC_RESET |ES8326_PWRUP_SEQ_EN ); +break ; + } + +return 0 ; +} +static irqreturn_t es8326_irq (int irq,void *dev_id) +{ +struct es8326_priv *es8326 = dev_id; +struct snd_soc_component *comp = es8326->component; + +if (!es8326->jack) + goto out; + +es8326_enable_micbias (comp); + +queue_delayed_work (system_wq, &es8326->jack_detect_work, +msecs_to_jiffies (300 )); + +out: +return IRQ_HANDLED ; +} + +static int es8326_resume (struct snd_soc_component *component) +{ +struct es8326_priv *es8326 =snd_soc_component_get_drvdata (component); + +regcache_cache_only (es8326->regmap, false); +regcache_sync (es8326->regmap); + +regmap_write (es8326->regmap,ES8326_CLK_CTL_01 ,ES8326_CLK_ON ); +/* Two channel ADC */ +regmap_write (es8326->regmap,ES8326_PULLUP_CTL_F9 ,0x02 ); +regmap_write (es8326->regmap,ES8326_CLK_INV_02 ,0x00 ); +regmap_write (es8326->regmap,ES8326_CLK_DIV_CPC_0C ,0x1F ); +regmap_write (es8326->regmap,ES8326_CLK_VMIDS1_10 ,0xC8 ); +regmap_write (es8326->regmap,ES8326_CLK_VMIDS2_11 ,0x88 ); +regmap_write (es8326->regmap,ES8326_CLK_CAL_TIME_12 ,0x20 ); +regmap_write (es8326->regmap,ES8326_SYS_BIAS_1D ,0x08 ); +regmap_write (es8326->regmap,ES8326_DAC2HPMIX_25 ,0x22 ); +regmap_write (es8326->regmap,ES8326_ADC1_SRC_2A , es8326->mic1_src); +regmap_write (es8326->regmap,ES8326_ADC2_SRC_2B , es8326->mic2_src); +regmap_write (es8326->regmap,ES8326_HPJACK_TIMER_56 ,0x88 ); +regmap_write (es8326->regmap,ES8326_HP_DET_57 , +ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol); +regmap_write (es8326->regmap,ES8326_INT_SOURCE_58 ,0x08 ); +regmap_write (es8326->regmap,ES8326_INTOUT_IO_59 ,0x45 ); +regmap_write (es8326->regmap,ES8326_RESET_00 ,ES8326_CSM_ON ); +snd_soc_component_update_bits (component,ES8326_PGAGAIN_23 , +ES8326_MIC_SEL_MASK ,ES8326_MIC1_SEL ); +
sound/soc/codecs/es8326.c line 612
Quoted 10 lines
sound/soc/codecs/es8326.c new file +10
-0+es8326_irq (es8326->irq, es8326); +return 0 ; +} + +static int es8326_suspend (struct snd_soc_component *component) +{ +struct es8326_priv *es8326 =snd_soc_component_get_drvdata (component); + +es8326_disable_micbias (component); +cancel_delayed_work_sync (&es8326->jack_detect_work);
I would have swapped the two lines above, first cancel the workqueue (which means let it run if it started already).
sound/soc/codecs/es8326.c line 619
Quoted 7 lines
sound/soc/codecs/es8326.c new file +7
-0+ +regmap_write (es8326->regmap,ES8326_CLK_CTL_01 ,ES8326_CLK_OFF ); +regcache_cache_only (es8326->regmap, true); +regcache_mark_dirty (es8326->regmap); + +return 0 ; +}
One question on the interrupt handling: should there be an interrupt disable on suspend and conversely an interrupt enable on resume?
Quoted 54 lines
sound/soc/codecs/es8326.c new file +53
-0+ +static int es8326_probe (struct snd_soc_component *component) +{ +struct es8326_priv *es8326 =snd_soc_component_get_drvdata (component); +int ret; + + es8326->component = component; + es8326->jd_inverted =device_property_read_bool (component->dev, +"everest,jack-detect-inverted" ); + + ret =device_property_read_u8 (component->dev,"everest,mic1-src" , &es8326->mic1_src); +if (ret !=0 ) { +dev_dbg (component->dev,"mic1-src return %d" , ret); + es8326->mic1_src =ES8326_ADC_AMIC ; + } +dev_dbg (component->dev,"mic1-src %x" , es8326->mic1_src); + + ret =device_property_read_u8 (component->dev,"everest,mic2-src" , &es8326->mic2_src); +if (ret !=0 ) { +dev_dbg (component->dev,"mic2-src return %d" , ret); + es8326->mic2_src =ES8326_ADC_DMIC ; + } +dev_dbg (component->dev,"mic2-src %x" , es8326->mic2_src); + + ret =device_property_read_u8 (component->dev,"everest,jack-pol" , &es8326->jack_pol); +if (ret !=0 ) { +dev_dbg (component->dev,"jack-pol return %d" , ret); + es8326->jack_pol =ES8326_HP_DET_BUTTON_POL |ES8326_HP_TYPE_OMTP ; + } +dev_dbg (component->dev,"jack-pol %x" , es8326->jack_pol); + +es8326_resume (component); +return 0 ; +} +static int es8326_i2c_probe (struct i2c_client *i2c, +const struct i2c_device_id *id) +{ +struct es8326_priv *es8326; +int ret; + + es8326 =devm_kzalloc (&i2c->dev,sizeof (struct es8326_priv ),GFP_KERNEL ); +if (!es8326) +return -ENOMEM ; + +i2c_set_clientdata (i2c, es8326); + es8326->i2c = i2c; +mutex_init (&es8326->lock); + es8326->regmap =devm_regmap_init_i2c (i2c, &es8326_regmap_config); +if (IS_ERR (es8326->regmap)) { + ret =PTR_ERR (es8326->regmap); +dev_err (&i2c->dev,"Failed to init regmap: %d\n" , ret); +return ret; + }
sound/soc/codecs/es8326.c
Quoted 10 lines
sound/soc/codecs/es8326.c new file +10
-0+ + es8326->irq = i2c->irq; +INIT_DELAYED_WORK (&es8326->jack_detect_work, + es8326_jack_detect_handler); +/* ES8316 is level-based while ES8326 is edge-based */ + ret =devm_request_threaded_irq (&i2c->dev, es8326->irq,NULL , es8326_irq, +IRQF_TRIGGER_RISING |IRQF_ONESHOT , +"es8326" , es8326); +if (ret) { + dev_warn(&i2c->dev, "Failed to reguest IRQ: %d: %d\n",
typo: request
Quoted 7 lines
sound/soc/codecs/es8326.c new file +7
-0+ es8326->irq, ret); + es8326->irq = -ENXIO ; + } + + es8326->mclk =devm_clk_get_optional (&i2c->dev,"mclk" ); +if (IS_ERR (es8326->mclk)) { +dev_err (&i2c->dev,"unable to get mclk\n" );
sound/soc/codecs/es8326.c line 767
Quoted 10 lines
sound/soc/codecs/es8326.c new file +10
-0+return PTR_ERR (es8326->mclk); + } +if (!es8326->mclk) +dev_warn (&i2c->dev,"assuming static mclk\n" ); + + ret =clk_prepare_enable (es8326->mclk); +if (ret) { +dev_err (&i2c->dev,"unable to enable mclk\n" ); +return ret; + }
I am not really following what happens if es8326->mclk is NULL. Why would you call clk_prepare_enable() with a NULL pointer? If you look at the code in es8326_set_bias_level(), you do test for that case, so why not here? Something's not right here.
Could it be that this is a scope issue? This block should be moved under the scope of the if (!es8236->mclk) test, no?
Quoted 4 lines
sound/soc/codecs/es8326.c new file +4
-0+return devm_snd_soc_register_component (&i2c->dev, + &soc_component_dev_es8326, + &es8326_dai,1 ); +}
Mark Brown
maintainerQuoted 11 lines · Pierre-Louis Bossart
Much improved version, thank you. See additional comments/questions below.
sound/soc/codecs/es8326.c line 619
Quoted 6 lines
sound/soc/codecs/es8326.c new file +6
-0+regmap_write (es8326->regmap,ES8326_CLK_CTL_01 ,ES8326_CLK_OFF ); +regcache_cache_only (es8326->regmap, true); +regcache_mark_dirty (es8326->regmap); + +return 0 ; +}One question on the interrupt handling: should there be an interrupt disable on suspend and conversely an interrupt enable on resume?
That shouldn't be needed (in general the interrupt enable/disable stuff shouldn't be needed at all).
Quoted 11 lines
sound/soc/codecs/es8326.c line 767
Quoted 5 lines
sound/soc/codecs/es8326.c new file +5
-0+ ret =clk_prepare_enable (es8326->mclk); +if (ret) { +dev_err (&i2c->dev,"unable to enable mclk\n" ); +return ret; + }I am not really following what happens if
es8326->mclkis NULL. Why would you callclk_prepare_enable()with a NULL pointer? If you look at the code ines8326_set_bias_level(), you do test for that case, so why not here? Something's not right here.
Quoted 2 lines
Could it be that this is a scope issue? This block should be moved under the scope of the if (!es8236->mclk) test, no?
The clock API will happily consume NULL clocks (it uses NULL as an equivalent to the regulator API's dummy regulator), there's no *need* to skip clock handling if you've got a NULL clock.
Quoted 13 lines · Mark Brown
Quoted 11 lines · Pierre-Louis Bossart
Much improved version, thank you. See additional comments/questions below.
sound/soc/codecs/es8326.c line 619
Quoted 6 lines
sound/soc/codecs/es8326.c new file +6
-0+regmap_write (es8326->regmap,ES8326_CLK_CTL_01 ,ES8326_CLK_OFF ); +regcache_cache_only (es8326->regmap, true); +regcache_mark_dirty (es8326->regmap); + +return 0 ; +}One question on the interrupt handling: should there be an interrupt disable on suspend and conversely an interrupt enable on resume?
Quoted 2 lines
That shouldn't be needed (in general the interrupt enable/disable stuff shouldn't be needed at all).
isn't there a risk of an interrupt being triggered after all the jack detection resources are disabled?
Quoted 12 lines
Quoted 11 lines
sound/soc/codecs/es8326.c line 767
Quoted 6 lines
sound/soc/codecs/es8326.c new file +5
-0+ ret =clk_prepare_enable (es8326->mclk); +if (ret) { +dev_err (&i2c->dev,"unable to enable mclk\n" ); +return ret; + }I am not really following what happens if
es8326->mclkis NULL. Why would you callclk_prepare_enable()with a NULL pointer? If you look at the code ines8326_set_bias_level(), you do test for that case, so why not here? Something's not right here.
Quoted 6 lines
Quoted 2 lines
Could it be that this is a scope issue? This block should be moved under the scope of the if (!es8236->mclk) test, no?
The clock API will happily consume NULL clocks (it uses NULL as an equivalent to the regulator API's dummy regulator), there's no *need* to skip clock handling if you've got a NULL clock.
Right, so the code in es8326_set_bias_level() can remove the tests for a NULL mclk.
Quoted 9 lines
Nothing ever restores the constraints if a clock is specified again, and in general it's odd that the enable/disable don't match up - if we're setting variable constraints I'd expect that in the freq == 0 case we should be setting ->sysclk_constraints to NULL rather than the contents. Indeed, we'll segfault here if the frequency is set to 0 without having first been set to some actual value. It's also bad to modify static data potentially shared between multiple instances of the device in a system.
Quoted 5 lines
Having said all that though I'm not clear why we're doing this constraint stuff at all, we never reference
sysclk_constraintsduring startup and teardown and you'd usually do this because you want to set constraints that depend on the sysclk but this is just a constant set of constraints that should be set in the DAI desription.
Comes from 8316.c. Will remove the constraints. Will submit a patch later to remove the constraints in es8316.c. We can assume that the producer(master) provides correct mclk(sysclk) rate.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
One question on the interrupt handling: should there be an interrupt disable on suspend and conversely an interrupt enable on resume?
That shouldn't be needed (in general the interrupt enable/disable stuff shouldn't be needed at all).
isn't there a risk of an interrupt being triggered after all the jack detection resources are disabled?
The jack detection resources are only disabled after codec power down?