I'm working on an audio codec driver for cs4245 device. It's controlled by i2c. I have 2 hardwares (devel-board), one of the them has the codec attached to i2c-1 and another to i2c-2. The first one is working, but the second not.

I've tested the communication (using i2cdetect, i2cget) with codec in the second board and it's working. Its communicates and receive the chip ID.

Looking into the code I can find the definition of i2c bus that should be used to set the bus communication:

static struct snd_soc_dai_link mod_duo_dai =
    .name = "MOD-DUO-I2S",
    .stream_name = "MOD-DUO-SUNXI-I2S",
    .cpu_dai_name = "sunxi-i2s.0",
    .codec_dai_name = "cs4245-dai",
    .platform_name = "sunxi-i2s-pcm-audio.0",
    .codec_name = "cs4245-codec.1-004c", // EDITED
    .ops = &mod_duo_ops,
    .init = &mod_duo_dai_link_init,

So, I edited highlighted line to "cs4245-codec.2-004c" but the driver still looking for i2c-1. The kernel prints bellow shows that:

bus: 'i2c': really_probe: probing driver cs4245-codec with device 1-004c
[i2c_device_probe] client name: cs4245, adapter name: sunxi-i2c.1, adapter nr: 1

Also I inserted a print inside function snd_soc_instantiate_card in soc-core.c to be sure it's getting my changes:

snd_soc_instantiate_card: cs4245-codec.2-004c

Later, kernel reaches codec probe function, it shows:

[   11.907394] [CS4245]Failed to read i2c at addr 0x4C.
[   11.919643] cs4245-codec: probe of 1-004c failed with error -70

Should edited line be enough to change the i2c bus?

The code is available at: https://github.com/moddevices/linux-sunxi/blob/mod-duo/sound/soc/sunxi/mod-duo.c

I've tried also change the bellow line as described in the comment:

static const struct i2c_device_id cs4245_id[] = {
    {"cs4245", 1}, // changed to {"cs4245", 2}

Does not work too. This piece of code is present in the codec driver: https://github.com/moddevices/linux-sunxi/blob/mod-duo/sound/soc/codecs/cs4245.c


The i2c bus option is being set at arch/arm/plat-sunxi/devices.c file, following commit fixing it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.