SGTL5000 audio codec with TX1

Hello,

I am trying to get Freescale SGTL5000 working with TX1. I am using L4T 28.2 . At the moment i am just trying to get the sgtl5000 codec driver to successfully complete I2C probe. I added the following device tree entry in order to do this.

i2c@7000c000 {
            sgtl5000_codec: sgtl5000@0a {
            status = "okay";
            compatible = "fsl,sgtl5000";
            reg = <0x0a>;
            clocks=<&tegra_car TEGRA210_CLK_EXTERN1>;
            VDDA-supply = <&vdd_1v8_ap>;
            VDDIO-supply = <&vdd_1v8_ap>;
            VDDD-supply = <&vdd_1v8_ap>;
        }; 
};

The driver gives the following error

sgtl5000: probe of 0-000a failed with error -121

I scoped the I2C lines and found driver is communicating on the correct bus but there is no ACK. When i scoped AUD_MCLK signal i see no clock output.

Then i found this post here https://devtalk.nvidia.com/default/topic/949616/jetson-tx1/setting-audio_mclk-to-output/post/4940627/#4940627 and tried exporting and unexporting the GPIO as suggested and the clock signal started working.
If i build the SGTL5000 driver as LKM and load it after exporting and unexporting GPIO then the probe completes successfully.

How do i get the AUD_MCLK to output correctly without exporting and unexporting the GPIO ?

So far i have tried adding the following DT entries with no luck

pinmux: pinmux@700008d4 {
    
        pinmux_default: common {
            /* SFIO Pin Configuration */
            aud_mclk_pbb0 {
                nvidia,pins = "aud_mclk_pbb0";
                nvidia,function = "aud";
                nvidia,pull = <TEGRA_PIN_PULL_UP>;
                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                nvidia,enable-input = <TEGRA_PIN_DISABLE>;
            };
        };
    };

gpio@6000d000 {
        gpio_default: default {
            gpio-init-names = "default";
            gpio-init-0 = <&gpio_default>;
    
            gpio-to-sfio = <  /* GPIO# TX1-PIN TX1-FUNC/ERA-FUNC CODEC-PIN */
                TEGRA_GPIO(B, 0)     /*   8 H1 I2S0_LRCLK/SFSYNC R335/3 */
                TEGRA_GPIO(B, 1)     /*   9 G1 I2S0_SDIN         R339/5 */
                TEGRA_GPIO(B, 2)     /*  10 H2 I2S0_SDOUT        R337/4 */
                TEGRA_GPIO(B, 3)     /*  11 G2 I2S0_CLK/SRCLK    R334/2 */
                TEGRA_GPIO(BB, 0)    /* 216 F1 AUDIO_MCLK     R1/R332/1 */
    
                /* This is commented out; we leave the CODEC enabled. */
                /*TEGRA_GPIO(BB, 3)  /* 219 F2 CODEC_RST         R331/31 */
                >;
        };
    };

Hello!

There is an example in the L4T rel28.2 documentation [0] on how to do this under “System Configuration --> Tegra ASoC Driver for Jetson TX1 and TX2 --> Troubleshooting --> Issue 2: Sound Not Audible”. Let me know if this helps. If this does not work, after making the necessary DT changes, please send the output from …

sudo cat /sys/kernel/debug/tegra_gpio
sudo grep aud_mclk /sys/kernel/debug/tegra_pinctrl_reg

Regards,
Jon

[0] https://developer.nvidia.com/embedded/dlc/l4t-documentation-28-2-ga

Thanks Jon. It is working now after i added the following block to DT.

gpio@6000d000 {
        sgtl5000_audio: sgtl5000-audio {
            gpio-hog;
            function;
            gpios = <
                TEGRA_GPIO(B, 0) 0
                TEGRA_GPIO(B, 1) 0
                TEGRA_GPIO(B, 2) 0
                TEGRA_GPIO(B, 3) 0
                TEGRA_GPIO(BB, 0) 0
                TEGRA_GPIO(BB, 3) 0
                TEGRA_GPIO(E, 4) 0
                TEGRA_GPIO(E, 5) 0
                >;
            label = "I2S0_LRCLK", "I2S0_SDIN", "I2S0_SDOUT",
                "I2S0_CLK", "AUDIO_MCLK", "AUD_RST",
                "DMIC3_CLK", "DMIC3_DAT";
            status = "okay";
        };
    };