2 Codec problem: Device tree syntax problem

  • We have 2 codecs,(cs4271IO and cs4271OUT), which use the same clocks, one connected to I2S0 Channel 0 and the other connected to I2S0 Channel 1. Both the Codecs, (CS4271), are controlled via I2C3, addresses 10 and 11 respectively. We can bring up only one of the the Codecs at a time, (the first one listed in the Device Tree I2C3 definition), and it will instantiate the driver for the Codec, but only play audio on I2S Channel 0.

    We have an error reported during instantiation (NOTE: gpio4-0 or pin 128, is the mclk):

    rockchip-pinctrl pinctrl: pin gpio4-0 already requested by 3-0010; cannot claim for 3-0011

    rockchip-pinctrl pinctrl: pin-128 (3-0011) status -22

    rockchip-pinctrl pinctrl: could not request pin 128 (gpio4-0) from group i2s-8ch-mclk on device rockchip-pinctrl

    cs4271 3-0011: Error applying setting, reverse things back

    asoc-simple-card cs4271-sound: cs4271-hifi <-> ff880000.i2s mapping ok

    rockchip-i2s ff880000.i2s: Trying to bind component to card "cs4271OUT" but is already bound to card "cs4271IO"

    asoc-simple-card cs4271-out: ASoC: failed to instantiate card -19

    We have not modified the Device Tree from Kernel 4.4 in file rk3399.dtsi so this is still the original definition for I2S0:

    i2s0 {

    i2s0_8ch_bus: i2s0-8ch-bus {

    rockchip,pins =

    < 3 24 RK_FUNC_1 &pcfg_pull_none>,

    < 3 25 RK_FUNC_1 &pcfg_pull_none>,

    < 3 26 RK_FUNC_1 &pcfg_pull_none>,

    < 3 27 RK_FUNC_1 &pcfg_pull_none>,

    < 3 28 RK_FUNC_1 &pcfg_pull_none>,

    < 3 29 RK_FUNC_1 &pcfg_pull_none>,

    < 3 30 RK_FUNC_1 &pcfg_pull_none>,

    < 3 31 RK_FUNC_1 &pcfg_pull_none>;

    };

    i2s_8ch_mclk: i2s-8ch-mclk {

    rockchip,pins = <4 0 RK_FUNC_1 &pcfg_pull_none>;

    };

    };

    This is our definition for our sound cards:

    cs4271_sound: cs4271-sound {

    status = "okay";

    compatible = "cirrus,cs4271","simple-audio-card";

    simple-audio-card,format = "i2s";

    simple-audio-card,name = "cs4271IO";

    simple-audio-card,mclk-fs = <256>;

    simple-audio,cpu = <&i2s0>;

    simple-audio,codec = <&cs4271io>;

    simple-audio-card,cpu {

    sound-dai = <&i2s0>;

    };

    simple-audio-card,codec {

    sound-dai = <&cs4271io>;

    };

    };

    cs4271_out: cs4271-out {

    status = "okay";

    compatible = "cirrus,cs4271","simple-audio-card";

    simple-audio-card,format = "i2s";

    simple-audio-card,name = "cs4271OUT";

    simple-audio-card,mclk-fs = <256>;

    simple-audio,cpu = <&i2s0>;

    simple-audio,codec = <&cs4271out>;

    simple-audio-card,cpu {

    sound-dai = <&i2s0>;

    };

    simple-audio-card,codec {

    sound-dai = <&cs4271out>;

    };

    };

    };


    And for the I2C3 with Codecs at addresses 10 and 11:

    &i2c3 {

    status = "okay";

    sda-gpios = <&gpio4 RK_PC0 GPIO_ACTIVE_LOW>; //GPIO4_C0/I2C3_SDA

    scl_gpios = <&gpio4 RK_PC1 GPIO_ACTIVE_LOW>; //GPIO4_C1/I2C3_SCL

    cs4271io: cs4271-io@10 {

    reg = <0x10>;

    #address-cells = <1>;

    #size-cells = <0>;

    #sound-dai-cells = <0>;

    clocks = <&cru SCLK_I2S_8CH_OUT>;

    clock-names = "mclk";

    single-master =<1>;

    reset-property = "cirrus,enable-soft-reset";

    compatible = "cirrus,cs4271";

    pinctrl-names = "default";

    pinctrl-0 = <&i2s_8ch_mclk>;

    reset-gpio = <&gpio4 RK_PC7 GPIO_ACTIVE_LOW>;

    };

    cs4271out: cs4271-out@11 {

    reg = <0x11>;

    #address-cells = <1>;

    #size-cells = <0>;

    #sound-dai-cells = <0>;

    clocks = <&cru SCLK_I2S_8CH_OUT>;

    clock-names = "mclk";

    single-master =<1>;

    reset-property = "cirrus,enable-soft-reset";

    compatible = "cirrus,cs4271";

    pinctrl-names = "default";

    pinctrl-0 = <&i2s_8ch_mclk>;

    reset-gpio = <&gpio4 RK_PD4 GPIO_ACTIVE_LOW>;

    };

    };

    As mentioned, if we swap the I2C3 order of the Codec initialization, (I.E. initialize 11 before 10, as above), then the cs4271-out@11 Codec will be initialized, but any audio will still be output on I2S0 channel 0 and not, as connected, on I2S0 channel 1.

    Question: How do we stipulate that the Codec at I2C3 address 11 outputs on I2S0 channel 1?

    Question: What is the correct syntax so we can instantiate both Codecs on the same clock and the correct I2S channels?