Re: [PATCH v3 3/4] ASoC: es9039q2m: add ESS Technology ES9039Q2M codec driver

From: Mark Brown

Date: Fri Sep 18 2026 - 06:56:28 EST


On Fri, Sep 18, 2026 at 06:13:25AM +0300, Karl Asseily wrote:
> The ES9039Q2M is a 32-bit two-channel audio DAC with an asynchronous
> sample rate converter. It selects between two control personalities with
> its MODE pin: hardware mode, strapped by HW0/HW1/HW2 with no control bus
> at all, and software mode over I2C or SPI. This driver implements
> software mode over I2C, which MODE = GND selects.

> +static int es9039_fir_put(struct snd_kcontrol *kcontrol,
> + const unsigned int __user *bytes, unsigned int size)
> +{
> + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol);
> + struct es9039q2m_priv *priv = snd_soc_component_get_drvdata(c);
> + struct soc_bytes_ext *be = (void *)kcontrol->private_value;
> + struct es9039_fir_ctl *p = container_of(be, struct es9039_fir_ctl, be);
> + u8 *buf;
> + int ret, i;
> +
> + if (size != p->taps * ES9039_COEFF_BYTES)
> + return -EINVAL;
> +
> + buf = memdup_user(bytes, size);
> + if (IS_ERR(buf))
> + return PTR_ERR(buf);
> +
> + /*
> + * PROG_COEFF_WE is a per-coefficient strobe, not a gate held open
> + * across the upload. The datasheet's sequence is address, data, raise
> + * WE, lower WE, once per coefficient. Holding it high for the whole
> + * loop also appears to work on ES9039Q2M silicon, but "appears to
> + * work" is not a specification.
> + */
> + for (i = 0; i < p->taps; i++) {
> + ret = regmap_write(priv->regmap, ES9039_PROG_RAM_ADDR,
> + (p->stage_4x ? ES9039_PROG_STAGE_4X : 0) |
> + FIELD_PREP(ES9039_PROG_ADDR_MASK, i));
> + if (ret)
> + goto out;

...

> +out:
> + regmap_update_bits(priv->regmap, ES9039_PROG_RAM_CTRL,
> + ES9039_PROG_COEFF_WE, 0);
> + kfree(buf);
> + if (ret)
> + return ret;

How does this work with suspend and resume if the device is powered down
in suspend? It looks like this is doing some windowing stuff and needs
a specific write sequence.

Attachment: signature.asc
Description: PGP signature