
/ {
        rt5640-sound {
                compatible = "simple-audio-card";
                simple-audio-card,format = "i2s";
                simple-audio-card,name = "rockchip,rt5640-codec";
                simple-audio-card,mclk-fs = <256>;
                simple-audio-card,widgets =
                        "Microphone", "Mic Jack",
                        //"Headphone", "Headphone Jack",    //fix for headphone dapm name to match drivers
                        "Headphone", "Headphones",
                        "Speaker", "Speaker";
                simple-audio-card,routing =
                        "Mic Jack", "MICBIAS1",
                        "IN1P", "Mic Jack",
                        //"Headphone Jack", "HPOL",         //fix for headphone dapm name to match drivers
                        //"Headphone Jack", "HPOR",
                        "Headphones", "HPOL",
                        "Headphones", "HPOR",
                        "Speaker", "SPOLP",
                        "Speaker", "SPOLN",
                        "Speaker", "SPORP",
                        "Speaker", "SPORN";
                pinctrl-names = "default";
                pinctrl-0 = <&rt5640_hp_det_gpio>;
                simple-audio-card,hp-det-gpio = <&gpio4 28 GPIO_ACTIVE_HIGH>;
                simple-audio-card,cpu {
                        sound-dai = <&i2s0>;
                };
                simple-audio-card,codec {
                        sound-dai = <&rt5640>;
                };
        };        
};


&i2c1 {
        status = "okay";
        i2c-scl-rising-time-ns = <300>;
        i2c-scl-falling-time-ns = <15>;

        rt5640: rt5640@1c {
                #sound-dai-cells = <0>;
                compatible = "realtek,rt5640";
                reg = <0x1c>;
                clocks = <&cru SCLK_I2S_8CH_OUT>;
                clock-names = "mclk";
                realtek,in1-differential;
                pinctrl-names = "default";
                pinctrl-0 = <&i2s_8ch_mclk>;
                io-channels = <&saradc 4>;
                //hp-con-gpio = <&gpio4 21 GPIO_ACTIVE_HIGH>;
                //hp-det-gpio = <&gpio4 28 GPIO_ACTIVE_HIGH>;
                hp-det-adc-value = <500>;
                status = "okay";
        };
};

&i2s0 {
    status = "okay";
    rockchip,playback-channels = <8>;
    rockchip,capture-channels = <8>;
    #sound-dai-cells = <0>;
};

&pinctrl {
        rt5640 {
                rt5640_hp_det_gpio: rt5640_hp_det_gpio {
                        rockchip,pins = <4 28 RK_FUNC_GPIO &pcfg_pull_none>;
                };
        };
        
        
    /** redefine for sdo1, sdo2 and sdo3 to be gpio */
    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 31 RK_FUNC_1 &pcfg_pull_none>;
        };
    };
};
