This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

snd_soc_write with multiple pages and register cache

Other Parts Discussed in Thread: AM3352

Dear support,

    I have a aic32x4 codec for an am3352 based custom board. The aic32x4 registers are allocated on multiple pages.

So I have the following structure:

static const struct regmap_range_cfg aic32x4_regmap_pages[] = {
	{
		.selector_reg = 0,
		.selector_mask  = 0xff,
		.window_start = 0,
		.window_len = 128,
		.range_min = 0,
		.range_max = AIC32X4_RMICPGAVOL,
	},
};

static const struct regmap_config aic3254_regmap = {
	.reg_bits = 8,
	.val_bits = 8,

	.max_register = AIC32X4_RMICPGAVOL,
	.ranges = aic32x4_regmap_pages, 
	.num_ranges = ARRAY_SIZE(aic32x4_regmap_pages), 
	
};

So that when i call snd_soc_write(...) with register address greater or equal to 128 (lower than 256) I should write on page 1.

But in my case it seems that the registers on page 1 ore not written (I try with a read and write operation on a RW reg value).

I suppose there some issue on the multiple page setup maybe related to the reg cache.

It seems correct to me to set:

 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);

but I found that with

ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);

i can write correctly on page 1.

In particular the affect of the command above (snd_soc_codec_set_cache_io) is not perfectly clear to me. Moreover if I remove that line the linux boot crash.

Thank you.

  • Hello Peregrinus,

    The AIC32x4 is programmed by writing to registers that can be accessed by using the I2C™ or SPI™ communication protocols. The fact that this device has many pages with hundreds of registers may seem overwhelming at first, but in reality, many registers do not need to be configured for most typical audio applications.

    I checked that the patches for this codec are applied in SW release. patchwork.ozlabs.org/.../329036
    I suggest you to try some examples, described in the user guide - www.ti.com/.../slaa404c.pdf

    Best regards,
    Yanko
  • Thank you for the reply Yanko,

        the fact is that the driver for the aic31xx the patch refers to, does not support the aic32x4. (It supports AIC33, the aic3106 but not the aic3204 or the aic3254).

    The kernel git however contains a 32x4 driver. What I found strange is that this driver does not contains the 

    ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);

    and, without that line, the system crash at boot time. I wonder if behind this line of code there is some other issue.

    Regards.

  • Hello Peregrinus,

    SND_SOC_REGMAP is defined in Linux/sound/soc/soc-io.c

    case SND_SOC_REGMAP:
    /* Device has made its own regmap arrangements */
    codec->using_regmap = true;
    if (!codec->control_data)
    codec->control_data = dev_get_regmap(codec->dev, NULL);

    if (codec->control_data) {
    ret = regmap_get_val_bytes(codec->control_data);
    /* Errors are legitimate for non-integer byte
    * multiples */
    if (ret > 0)
    codec->val_bytes = ret;
    }
    break;

    Best regards,
    Yanko