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.

Audio-McASP NO I2S clocks to the Codec : NO Sound : Even Sound card is detected

Other Parts Discussed in Thread: TLV320DAC3100, TLV320AIC3106, TLV320AIC3101

Hi ,

we are using AM335x and SDK-8 : for Audio codec(TLV320DAC3100) in Custom Board but the reference Sitara EVM-Starter Kit.

our Audio IOs(no change in pin-muxing) are same for the starter kit to our custom board -- 

only changes we have done is PIN-MUX:

tlv320aic3106:  here codec is clock master so , the clocks are sourced from codec to McASP 

mcasp1_pins_sleep: mcasp1_pins_sleep {
pinctrl-single,pins = <
0x10c (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x110 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x108 (PIN_INPUT_PULLDOWN | MUX_MODE7)
0x144 (PIN_INPUT_PULLDOWN | MUX_MODE7)
>;
};

to : tlv320dac3100 : here codec is slave and McASP is master so changed --  this has DAC no Line-in so  DAC will be slave for I2S

mcasp1_pins_sleep: mcasp1_pins_sleep {
pinctrl-single,pins = <
0x10c (PIN_OUTPUT_PULLUP | MUX_MODE7)
0x110 (PIN_OUTPUT_PULLUP | MUX_MODE7)
0x108 (PIN_OUTPUT_PULLUP | MUX_MODE7)
0x144 (PIN_INPUT_PULLDOWN | MUX_MODE7)
>;
};

So changed to output_pull up -- but we are getting a logic High signal on BCLK and WCLK IO's and no data on the DIN IO.

we are using aplay command to play the ".wav" file we are geting an Logic high signal from the AM335x to cdoec 

we are suspecting the I2S bus.

one more changes we have done is :

static struct snd_soc_dai_link da830_evm_dai = {
.name = "TLV320AIC3X",
.stream_name = "AIC3X",
.cpu_dai_name = "davinci-mcasp.1",
.codec_dai_name = "tlv320aic3x-hifi",
.codec_name = "tlv320aic3x-codec.1-0018",
.platform_name = "davinci-mcasp.1",
.init = evm_aic3x_init,
.ops = &evm_ops,
.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
SND_SOC_DAIFMT_IB_NF,
};

to :

.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFS |
SND_SOC_DAIFMT_NB_NF,

given in some of TI  fourm thread so we tried in that way-

e2e.ti.com/.../390265

we tried to get some solution for No Sound. 

Please correct us if we are doing wrong way

Assumption 1.   McASP is master and Codec is slave -- so we changed the pinmuxing.

Assumption 2: dai_fmt is the right we changed from DSP_B to I2S and CDM_CFM to CBM_CFM and IB_NF to NB_NF.

3#:

MCLK we are getting an triangle wave form: 2.3v amplitude and looking some offset in voltage level , is that clock is OK..??? (attached the waveform)

regards,

Viswanath K

  • VISWANATH KONDAPALLI said:
    mcasp1_pins_sleep: mcasp1_pins_sleep {
    pinctrl-single,pins = <
    0x10c (PIN_OUTPUT_PULLUP | MUX_MODE7)
    0x110 (PIN_OUTPUT_PULLUP | MUX_MODE7)
    0x108 (PIN_OUTPUT_PULLUP | MUX_MODE7)
    0x144 (PIN_INPUT_PULLDOWN | MUX_MODE7)
    >;

    You are changing the Sleep mode for the pins. You must change active mode.

  • by Mistake i copied sleep -- we are doing in the Active -- "default" place only.

    We changed ".dai_fmnt " in davinci_evm.c from DSP_B to I2S and CBM_CFM and NB_NF -- so that we got some data out.

    there is some good news in the Audio -- earlier we were not getting I2S - clocks -- and the necessary events also generating too.
    ---------------BUT NO SOUND FROM Head Phones--------
    root@am335x-evm:/media# aplay test_stereo_48000Hz_8bit_PCM.wav
    [ 123.413958] davinci_mcasp_startup:dir:1 substream->stream:0
    Playing WAVE 'test_stereo_48000Hz_8bit_PCM.wav' : Unsigned 8 bit, Rate 48000 Hz, Stereo
    [ 123.429693] davinci_mcasp_set_sysclk:mcasp->sysclk_freq:24000000 ; dir:1
    [ 123.443835] davinci-mcasp 4803c000.mcasp: Inaccurate BCLK: 24000000 Hz / 16 != 1536000 Hz
    [ 123.452508] __davinci_mcasp_set_clkdiv:
    [ 123.456554] davinci_mcasp_hw_params:mcasp->sysclk_freq:24000000 bclk_freq:1536000
    [ 123.464538] mcasp_common_hw_param
    [ 123.468121] mcasp->serial_dir[2]:1,
    [ 123.471921] mcasp_i2s_hw_param:active_serializers:1
    [ 123.477051] davinci_mcasp_hw_params:word_length:16
    [ 123.487591] davinci_mcasp_trigger:CMD:1
    [ 123.491740] davinci_mcasp_start:
    [ 123.495129] mcasp_start_tx:
    [ 123.498078] mcasp_start_tx:tdm_slots:2, op_mode:0,num_serializer:4,txnumevt:32,rxnumevt:32
    [ 123.506757] mcasp_start_tx:wait for XDATA to be cleared
    [ 123.512249] mcasp_start_tx:enable transmit underrun IRQ
    [ 123.517732] mcasp_start_tx:After IRQ enable transmit underrun IRQ
    [ 138.615740] davinci_mcasp_trigger:CMD:0
    [ 138.619914] mcasp_stop_tx:

    --------this event tells the data and necessary clocks and events(data end ) also generating -- NO hearing sound from head phones
    [ 138.615740] davinci_mcasp_trigger:CMD:0
    [ 138.619914] mcasp_stop_tx:

    but a warning :

    [ 123.443835] davinci-mcasp 4803c000.mcasp: Inaccurate BCLK: 24000000 Hz / 16 != 1536000 Hz

    Issue 1#

    this is not matching ti,codec-clock-rate = <24000000>;(sysclk) and bits in the data(16 ) is getting 15,000,000 HZ which not matching to the bclk of 1536000 HZ --- here we are not able to fix

    Issue 2 #
    due to issue:1 -- so we changed the clock-rate (48000 x 16 x 2=24576000) but for that we are getting this error log:
    oot@am335x-evm:/# aplay /usr/share/sounds/alsa/Front_Center.wav
    [ 65.478180] davinci_mcasp_startup:dir:1 substream->stream:0
    Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 o
    [ 65.496780] tlv320aic31xx-codec 0-0018: aic31xx_set_dai_sysclk: Unsupported frequency 24576000
    [ 65.508572] davinci_evm sound.10: ASoC: machine hw_params failed: -22
    aplay: set_params:1297: Unable to install hw params:
    ACCESS: RW_INTERLEAVED
    FORMAT: S16_LE
    SUBFORMAT: STD
    SAMPLE_BITS: 16
    FRAME_BITS: 16
    CHANNELS: 1
    RATE: 48000
    PERIOD_TIME: 125000
    PERIOD_SIZE: 6000
    PERIOD_BYTES: 12000
    PERIODS: 4
    BUFFER_TIME: 500000
    BUFFER_SIZE: 24000
    BUFFER_BYTES: 48000
    TICK_TIME: 0
    root@am335x-evm:/#

    This error is occurred if we change the codec clock rate to 24576000
    [ 65.496780] tlv320aic31xx-codec 0-0018: aic31xx_set_dai_sysclk: Unsupported frequency 24576000

    Issue 3#
    due to issue 2# we changed the clock rate to 12MHZ : even no sound and the log is :
    m335x-evm login: root
    root@am335x-evm:~# aplay /usr/share/sounds/alsa/Front_Center.wav
    [ 37.385864] davinci_mcasp_startup:dir:1 substream->stream:0
    Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 o
    [ 37.405234] davinci_mcasp_set_sysclk:mcasp->sysclk_freq:12000000 ; dir:1
    [ 37.424918] davinci-mcasp 4803c000.mcasp: Inaccurate BCLK: 12000000 Hz / 8 != 1536000 Hz
    [ 37.433488] __davinci_mcasp_set_clkdiv:
    [ 37.437538] davinci_mcasp_hw_params:mcasp->sysclk_freq:12000000 bclk_freq:1536000
    [ 37.445518] mcasp_common_hw_param
    [ 37.449099] mcasp->serial_dir[2]:1,
    [ 37.452896] mcasp_i2s_hw_param:active_serializers:1
    [ 37.458028] davinci_mcasp_hw_params:word_length:16
    [ 37.472727] davinci_mcasp_trigger:CMD:1
    [ 37.476914] davinci_mcasp_start:
    [ 37.480324] mcasp_start_tx:
    [ 37.483291] mcasp_start_tx:tdm_slots:2, op_mode:0,num_serializer:4,txnumevt:32,rxnumevt:32
    [ 37.492017] mcasp_start_tx:wait for XDATA to be cleared
    [ 37.497537] mcasp_start_tx:enable transmit underrun IRQ
    [ 37.503054] mcasp_start_tx:After IRQ enable transmit underrun IRQ
    [ 38.265414] davinci_mcasp_trigger:CMD:0
    [ 38.269581] mcasp_stop_tx:


    This is the situation and the log :
    1 point is as we changed the codec clock rate in the dts 24MHZ to 12MHZ -- the division is to 8 from 16 -> i dont understand -- why changed.

    here we are in the edge -- not able to move to any direction to audio from the headphones .

    Please help me here --

    regards,

    Viswanath K
  • We fixed this issue. As we are using tlv320aic31xx.c for the tlv320dac3100 audio codec.
    As in AIC3XXX series audio codecs act as a MASTER and Frame will act as slave -- this is mentioned davinci_evm.c ---".dai_fmt " we changed here to I2S and CBS_FMS and NB_NF -- plz go through those values -- we got this from one of the thread from TI posted for dac3100 only.

    so the as the codec slave and frame -- necessary changes are pinmux -- in dts file and the .dai_fmt --- in davinci-evm.c and the mode related option in codec drvier.

    there u will get the Audio clocks.

    Still we are not get any SOUND .. but this is our progress to get the clocks to the codec.

    we are changing the register values -- try for the luck.

    we are not getting proper support from TI for the TI - Audio codecs.

    i think TI- SW team having solution for all these TI-Audio codecs but they are not supporting.

    regards,

    Viswanath K.
  • Still we are hoping for some help or at-least clue.. till we succeed with TI Audio codec.

    regards,

    Viswanath K.
  • Are you following the codec porting guide: processors.wiki.ti.com/.../Sitara_Linux_Audio_DAC_Example ?

    Have you made all necessary configurations to the snd_soc_dai_link, snd_soc_ops evm_ops structures? Have you modified the Codec hw params function & configured your kernel (via menuconfig) properly?

    Best Regards,
    Yordan
  • YES Yordan.

    snd_soc_dai_link: Yes we changed to :
    static struct snd_soc_dai_link da830_evm_dai = {
    .name = "TLV320AIC31XX",
    .stream_name = "AIC31XX",
    .cpu_dai_name = "davinci-mcasp.1",
    .codec_dai_name = "tlv320aic31xx-hifi",
    .codec_name = "tlv320aic31xx-codec.0-0018",
    .platform_name = "davinci-mcasp.1",
    .init = evm_aic3x_init,
    .ops = &evm_ops,
    // .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM |
    // SND_SOC_DAIFMT_IB_NF,
    .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS |
    SND_SOC_DAIFMT_NB_NF,
    };

    snd_soc_ops evm_ops we didnt changed -- we are using same ops. and we are getting BCLK,WCLK and DIN waveforms

    Yes we are following the same link to added new codec and the necessary changes and the menuconfig -- so that our codec is loaded and the ALSA List.

    till CODEC we are getting inputs we are getting clocks. BUT NO AUDIO : Register DUMP -- can you help us in this :

    i am unable to attach here -- register file -- i am posting in the new thread -- because this thread created issue is fixed for us.

    e2e.ti.com/.../435575

    regards,

    Viswanath K
  • Finally we got Audio output. But very first time we are not getting Audio for the aplay command.
  • Hi VISWANATH,

    We are design custom board  AM335x.
    McASP0 interface with codec tlv320aic3106 chip. We are using linux kernel 3.14 & codec driver use sound/soc/codecs/tlv320aic31xx.c

    plz see my thread 

    my configuration in davinci-evm.c file :-

    static struct snd_soc_dai_link evm_dai_tlv320aic3x = {
            .name           = "TLV320AIC3X",
            .stream_name    = "AIC3X",
            .codec_dai_name = "tlv320aic31xx-hifi",
            //.codec_dai_name       = "tlv320aic3x-hifi",
            .ops            = &evm_ops,
            .init           = evm_aic3x_init,
            .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS |
                       SND_SOC_DAIFMT_NB_NF,
    };

    & dts file :-

      sound {
                    compatible = "ti,da830-evm-audio";
                    ti,model = "AM335x-EDGE";
                    ti,audio-codec = <&tlv320aic310x>;
                    ti,mcasp-controller = <&mcasp0>;
                    ti,codec-clock-rate = <24000000>;
                    ti,audio-routing =
                            "Headphone Jack",       "HPLOUT",
                            "Headphone Jack",       "HPROUT";
            };

    mcasp0_pins: mcasp0_pins {
                    pinctrl-single,pins = <
                            0x120 (PIN_OUTPUT | MUX_MODE6)  /* K15 MII1_TXD2 mcasp0_ahclkx-MCLK */
                            0x12C (PIN_OUTPUT | MUX_MODE6)  /* K18 MII1_TX_CLK mcasp0_aclkx-BCLK */
                            0x130 (PIN_OUTPUT | MUX_MODE6) /* L18 MII1_RX_CLK mcasp0_fsx-WCLK */
                            0x118 (PIN_INPUT | MUX_MODE6)  /* J17 MII1_RX_DV mcasp0_aclkr-BCLK */
                            0x11C (PIN_INPUT | MUX_MODE6)   /* J18 MII1_TXD3 mcasp0_fsr-WCLK */
                            0x134 (PIN_OUTPUT| MUX_MODE6)  /* L17 MII1_RXD3 mcasp0_axr0-TXD */
                            0x138 (PIN_INPUT | MUX_MODE6)  /* L16 MII1_RXD2 mcasp0_axr1-RXD */
                    >;
            };

            mcasp0_pins_sleep: mcasp0_pins_sleep {
                    pinctrl-single,pins = <
                            0x120 (PIN_OUTPUT | MUX_MODE7)  /* K15 MII1_TXD2 mcasp0_ahclkx-MCLK */
                            0x12C (PIN_OUTPUT | MUX_MODE7)  /* K18 MII1_TX_CLK mcasp0_aclkx-BCLK */
                            0x130 (PIN_OUTPUT | MUX_MODE7) /* L18 MII1_RX_CLK mcasp0_fsx-WCLK */
                            0x118 (PIN_INPUT | MUX_MODE7)  /* J17 MII1_RX_DV mcasp0_aclkr-BCLK */
                            0x11C (PIN_INPUT | MUX_MODE7)   /* J18 MII1_TXD3 mcasp0_fsr-WCLK */
                            0x134 (PIN_OUTPUT | MUX_MODE7)  /* L17 MII1_RXD3 mcasp0_axr0-TXD */
                            0x138 (PIN_INPUT | MUX_MODE7)  /* L16 MII1_RXD2 mcasp0_axr1-RXD */
                    >;
            };
    &mcasp0 {
            pinctrl-names = "default", "sleep";
            pinctrl-0 = <&mcasp0_pins>;
            pinctrl-1 = <&mcasp0_pins_sleep>;

            status = "okay";

            op-mode = <0>;  /* MCASP_IIS_MODE */
            tdm-slots = <2>;
            /* 4 serializers */
            serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX  AXR0-TXD AXR1-RXD */
                    1 2 0 0
            >;
            tx-num-evt = <32>;
            rx-num-evt = <32>;
    };


    &i2c0 {
            pinctrl-names = "default";
            pinctrl-0 = <&i2c0_pins>;

            status = "okay";
            clock-frequency = <400000>;

            tlv320aic310x: tlv320aic310x@18 {
                    compatible = "ti,tlv320aic310x";
                    reg = <0x18>;
                    status = "okay";
                    gpio-reset = <&gpio3 13 GPIO_ACTIVE_LOW>; /*GPIO3_13*/
                    /* Regulators */
                    AVDD-supply = <&vaux2_reg>;
                    IOVDD-supply = <&vaux2_reg>;
                    DRVDD-supply = <&vaux2_reg>;

                    DVDD-supply = <&vaux2_reg1>;
            };
    };

    aplay test.wav
    Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    [   47.821634] sysclk=24000000
    [   47.839602] davinci-mcasp 48038000.mcasp: Inaccurate BCLK: 24000000 Hz / 16 != 1536000 Hz

    any changes is need in davinci-evm.c file ?

    MCLK is comes proper but BCLK & WCLK is not proper .

    Thanks

    Tejas

  • Did u check the pin mux are correct ??
    Did u check the clocks in CRO ?? not the log statements. ??

    please mention ur problem clearly. before aplay -- there a command to check the audio device list -- did u check..??
    if u r using tlv320aic3106 -- in starter kit -- audio is coming straight away.

    regards,
    Viswanath K
  • Hi,

    We are design our board AM335x board . We are using tlv320aic3101 chip with mcasp0 port .
    I have enabled debug in tlv320aic31xx.c
    this is my logs are comes
    root@edge-shelf:~# dmesg | grep sound
    [ 2.471917] davinci_evm sound.11: ASoC: CODEC (null) not registered
    [ 2.479943] davinci_evm sound.11: snd_soc_register_card failed (-517)
    [ 2.488355] platform sound.11: Driver davinci_evm requests probe deferral
    [ 2.873347] davinci_evm sound.11: tlv320aic31xx-hifi <-> 48038000.mcasp mapping ok
    [ 2.881080] davinci_evm sound.11: ASoC: no source widget found for HPLOUT
    [ 2.887930] davinci_evm sound.11: ASoC: Failed to add route HPLOUT -> direct -> Headphone Jack
    [ 2.896594] davinci_evm sound.11: ASoC: no source widget found for HPROUT
    [ 2.903428] davinci_evm sound.11: ASoC: Failed to add route HPROUT -> direct -> Headphone Jack
    root@edge-shelf:~#
    root@edge-shelf:~# dmesg | grep tlv
    [ 2.851390] tlv320aic31xx-codec 0-0018: ASoC: DAPM unknown pin MONO_LOUT
    [ 2.858236] tlv320aic31xx-codec 0-0018: ASoC: DAPM unknown pin HPLCOM
    [ 2.865485] tlv320aic31xx-codec 0-0018: ASoC: DAPM unknown pin HPRCOM
    [ 2.873347] davinci_evm sound.11: tlv320aic31xx-hifi <-> 48038000.mcasp mapping ok
    [ 2.912082] tlv320aic31xx-codec 0-0018: Invalid DAI master/slave interface
    [ 2.919002] tlv320aic31xx-codec 0-0018: ASoC: Failed to set DAI format: -22
    [ 114.205135] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x8 (0, 0x8, 500000 us)
    [ 114.215411] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: DAC Right event failed: -1
    [ 115.247437] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x80 (0, 0x80, 500000 us)
    [ 115.257880] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: DAC Left event failed: -1
    [ 116.288313] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x2 (0, 0x2, 500000 us)
    [ 116.298590] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: HPR Driver event failed: -1
    [ 117.328371] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x20 (0, 0x20, 500000 us)
    [ 117.338814] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: HPL Driver event failed: -1
    root@edge-shelf:~#

    root@edge-shelf:~# aplay test.wav
    Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, [ 113.132343] sysclk=24000000
    Stereo
    [ 113.142438] davinci-mcasp 48038000.mcasp: Inaccurate BCLK: 24000000 Hz / 16 != 1536000 Hz
    [ 114.205135] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x8 (0, 0x8, 500000 us)
    [ 114.215411] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: DAC Right event failed: -1
    [ 115.247437] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x80 (0, 0x80, 500000 us)
    [ 115.257880] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: DAC Left event failed: -1
    [ 116.288313] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x2 (0, 0x2, 500000 us)
    [ 116.298590] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: HPR Driver event failed: -1
    [ 117.328371] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x20 (0, 0x20, 500000 us)
    [ 117.338814] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: HPL Driver event failed: -1

    i am setting amixer

    amixer sset 'DAC' 127
    amixer sset 'HP Analog' 66
    amixer sset 'HP Driver' 0 on
    amixer sset 'HP Left' on
    amixer sset 'HP Right' on
    amixer sset 'Output Left From Left DAC' on
    amixer sset 'Output Right From Right DAC' on


    I am trying to play test.wav file but no sound comes above error comes when aplay . how to solve above errors. i am checked pin muxing is correct .Master clock is comes proper 24MHz waveform but BCLK and WCLK waveform is shifted. my dai fmt is correct or not ?
    .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS |
    SND_SOC_DAIFMT_NB_NF,

    & also checked the audio device list is aplay -l sound card is register AM335x-EDGE
    Any idea why sound is not coming ?
    Thanks
    Tejas

  • 1. Did u r audio codec is came in the ALSA list ??? it will in the boot log -- related to this there is a command -- check with that command

    2. dai_fmt is corrected.

    3. why u are setting amixer .. ??

    4. can i have which codec u r using .. ??

    regards,

    Viswanath K
  • Hi,

    Yes audio codec came in ALSA list

    root@edge-shelf:~# aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: AM335xEDGE [AM335x-EDGE], device 0: AIC3X tlv320aic31xx-hifi-0 []
    Subdevices: 1/1
    Subdevice #0: subdevice #

    root@edge-shelf:~# cat /proc/device-tree/sound/
    compatible ti,audio-routing ti,model
    name ti,codec-clock-rate
    ti,audio-codec ti,mcasp-controller
    root@edge-shelf:~# cat /proc/device-tree/sound/name
    soundroot@edge-shelf:~# cat /proc/device-tree/sound/ti,model
    AM335x-EDGE
    root@edge-shelf:~# cat /proc/device-tree/sound/ti,audio-codec
    T

    I am using tlv320aic3101 chip use tlv320aic31xx.c driver used .

    Thanks
    Tejas
  • We have had some problems using the McASP driver in I2S mode. One bug we found is that the driver always puts the McASP into synchronous mode when I2S is requested. The patch below should fix that. But we still had problems with data corruption, and ended up switching to DSP B mode since both McASP and our codec supported it. DSP B mode worked fine.

    diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
    index b960e62..1cf762a 100644
    --- a/sound/soc/davinci/davinci-mcasp.c
    +++ b/sound/soc/davinci/davinci-mcasp.c
    @@ -790,8 +790,11 @@ static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream,
     	for (i = 0; i < active_slots; i++)
     		mask |= (1 << i);
     
    -	mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC);
    -
    +	if (mcasp_is_synchronous(mcasp) {
    +	    mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC);
    +	  } else {
    +            mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC);
    +	  }

  • @Tejas : can i have u r dts file config for sound. and davinci-evm.c and mcasp.c and u r codec files --

    Rob and Tejas:
    1st thing is for tlv320aic3101 the existing will work as it is -- u need not do any changes -- u can test that driver in starter kit --

    then apply patches -- patches or any not required for aic3101 codec.

    regards,
    Viswanath K
  • Hi

    /*
     * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License version 2 as
     * published by the Free Software Foundation.
     */
    /dts-v1/;
    
    #include "am33xx.dtsi"
    #include <dt-bindings/pwm/pwm.h>
    
    / {
    	model = "TI AM335x EDGE";
    	compatible = "ti,am335x-edge", "ti,am33xx";
    
    	memory {
    		device_type = "memory";
    		reg = <0x80000000 0x10000000>; /* 256 MB */
    	};
    
    	vbat: fixedregulator@0 {
    		compatible = "regulator-fixed";
    		regulator-name = "vbat";
    		regulator-min-microvolt = <5000000>;
    		regulator-max-microvolt = <5000000>;
    		regulator-boot-on;
    	};
    
    	lis3_reg: fixedregulator@1 {
    		compatible = "regulator-fixed";
    		regulator-name = "lis3_reg";
    		regulator-boot-on;
    	};
    
    	vtt_fixed: fixedregulator@2 {
    		compatible = "regulator-fixed";
    		regulator-name = "vtt";
    		regulator-min-microvolt = <1500000>;
    		regulator-max-microvolt = <1500000>;
    		gpio = <&gpio0 7 GPIO_ACTIVE_HIGH>;
    		regulator-always-on;
    		regulator-boot-on;
    		enable-active-high;
    	};
    
    	 vmmcsd_fixed: fixedregulator@3 {
                    compatible = "regulator-fixed";
                    regulator-name = "vmmcsd_fixed";
                    regulator-min-microvolt = <3300000>;
                    regulator-max-microvolt = <3300000>;
            };
    
    	vaux2_reg: fixedregulator@4 {
    		compatible = "regulator-fixed";
    		regulator-name = "vaux2_reg";
    		regulator-min-microvolt = <3300000>;
    		regulator-max-microvolt = <3300000>;
    		regulator-boot-on;
    	};
    
    	vaux2_reg1: fixedregulator@5 {
    		compatible = "regulator-fixed";
    		regulator-name = "vaux2_reg1";
    		regulator-min-microvolt = <1800000>;
    		regulator-max-microvolt = <1800000>;
    		regulator-boot-on;
    	};
    
    
    	backlight {
    		compatible = "pwm-backlight";
    		pwms = <&ecap2 0 50000 PWM_POLARITY_INVERTED>;
    		brightness-levels = <0 58 61 66 75 90 125 170 255>;
    		default-brightness-level = <8>;
    	};
    
    	sound {
    		compatible = "ti,da830-evm-audio";
    		ti,model = "AM335x-EDGE";
    		ti,audio-codec = <&tlv320aic310x>;
    		ti,mcasp-controller = <&mcasp0>;
    		ti,codec-clock-rate = <24000000>;
    		ti,audio-routing =
    			"Headphone Jack",       "HPL",
    			"Headphone Jack",       "HPR";
    	};
    
    	panel {
    		compatible = "ti,tilcdc,panel";
    		pinctrl-names = "default", "sleep";
    		pinctrl-0 = <&lcd_pins_default>;
    		pinctrl-1 = <&lcd_pins_sleep>;
    		status = "okay";
    		panel-info {
    			ac-bias           = <255>;
    			ac-bias-intrpt    = <0>;
    			dma-burst-sz      = <16>;
    			bpp               = <24>;
    			fdd               = <0x80>;
    			sync-edge         = <0>;
    			sync-ctrl         = <1>;
    			raster-order      = <0>;
    			fifo-th           = <0>;
    		};
    		display-timings {
    			1920x320 {
    				hactive         = <1920>;
    				vactive         = <320>;
    				hback-porch     = <36>;
    				hfront-porch    = <64>;
    				hsync-len       = <4>;
    				vback-porch     = <16>;
    				vfront-porch    = <14>;
    				vsync-len       = <2>;
    				clock-frequency = <42660000>;
    				hsync-active    = <0>;
    				vsync-active    = <0>;
    			};
    	};
    };
        wlan_en_reg: fixedregulator@1 {
            compatible = "regulator-fixed";
            regulator-name = "wlan-en-regulator";
            regulator-min-microvolt = <1800000>;
            regulator-max-microvolt = <1800000>;
    
            /* WLAN_EN GPIO for this board - Bank3, pin3 */
            gpio = <&gpio3 3 0>;
    
            /* WLAN card specific delay */
            startup-delay-us = <70000>;
            enable-active-high;
        };
    
        kim {
            compatible = "kim";
            nshutdown_gpio = <61>; /* Bank1, pin29 */
            dev_name = "/dev/ttyO5";
            flow_cntrl = <1>;
            baud_rate = <115200>;
        };
    
        btwilink {
            compatible = "btwilink";
        };
        
    
    };
    
    &am33xx_pinmux {
    	pinctrl-names = "default";
    	pinctrl-0 = <&ddr3_vtt_toggle &gpio_0_pins_default &gpio_1_pins_default &gpio_2_pins_default &gpio_3_pins_default &usb_3_pins_default &pru_pins>;
    
    	ddr3_vtt_toggle: ddr3_vtt_toggle {
    		pinctrl-single,pins = <
    			0x164 0x7	/* ecap0_in_pwm0_out.gpio0_7, OUTPUT | MODE7 */
    		>;
    	};
    
    	lcd_pins_default: lcd_pins_default {
    		pinctrl-single,pins = <
    			0x20 (PIN_OUTPUT | MUX_MODE1)	/* gpmc_ad8.lcd_data23 */
    			0x24 (PIN_OUTPUT | MUX_MODE1)	/* gpmc_ad9.lcd_data22 */
    			0x28 (PIN_OUTPUT | MUX_MODE1)	/* gpmc_ad10.lcd_data21 */
    			0x2c (PIN_OUTPUT | MUX_MODE1)	/* gpmc_ad11.lcd_data20 */
    			0x30 (PIN_OUTPUT | MUX_MODE1)	/* gpmc_ad12.lcd_data19 */
    			0x34 (PIN_OUTPUT | MUX_MODE1)	/* gpmc_ad13.lcd_data18 */
    			0x38 (PIN_OUTPUT | MUX_MODE1)	/* gpmc_ad14.lcd_data17 */
    			0x3c (PIN_OUTPUT | MUX_MODE1)	/* gpmc_ad15.lcd_data16 */
    			0xa0 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data0.lcd_data0 */
    			0xa4 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data1.lcd_data1 */
    			0xa8 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data2.lcd_data2 */
    			0xac (PIN_OUTPUT | MUX_MODE0)	/* lcd_data3.lcd_data3 */
    			0xb0 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data4.lcd_data4 */
    			0xb4 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data5.lcd_data5 */
    			0xb8 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data6.lcd_data6 */
    			0xbc (PIN_OUTPUT | MUX_MODE0)	/* lcd_data7.lcd_data7 */
    			0xc0 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data8.lcd_data8 */
    			0xc4 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data9.lcd_data9 */
    			0xc8 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data10.lcd_data10 */
    			0xcc (PIN_OUTPUT | MUX_MODE0)	/* lcd_data11.lcd_data11 */
    			0xd0 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data12.lcd_data12 */
    			0xd4 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data13.lcd_data13 */
    			0xd8 (PIN_OUTPUT | MUX_MODE0)	/* lcd_data14.lcd_data14 */
    			0xdc (PIN_OUTPUT | MUX_MODE0)	/* lcd_data15.lcd_data15 */
    			0xe0 (PIN_OUTPUT | MUX_MODE0)	/* lcd_vsync.lcd_vsync */
    			0xe4 (PIN_OUTPUT | MUX_MODE0)	/* lcd_hsync.lcd_hsync */
    			0xe8 (PIN_OUTPUT | MUX_MODE0)	/* lcd_pclk.lcd_pclk */
    			0xec (PIN_OUTPUT | MUX_MODE0)	/* lcd_ac_bias_en.lcd_ac_bias_en */
    		>;
    	};
    
    	lcd_pins_sleep: lcd_pins_sleep {
    		pinctrl-single,pins = <
    			0x20 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad8.lcd_data23 */
    			0x24 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad9.lcd_data22 */
    			0x28 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad10.lcd_data21 */
    			0x2c (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad11.lcd_data20 */
    			0x30 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad12.lcd_data19 */
    			0x34 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad13.lcd_data18 */
    			0x38 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad14.lcd_data17 */
    			0x3c (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad15.lcd_data16 */
    			0xa0 (PULL_DISABLE | MUX_MODE7)	/* lcd_data0.lcd_data0 */
    			0xa4 (PULL_DISABLE | MUX_MODE7)	/* lcd_data1.lcd_data1 */
    			0xa8 (PULL_DISABLE | MUX_MODE7)	/* lcd_data2.lcd_data2 */
    			0xac (PULL_DISABLE | MUX_MODE7)	/* lcd_data3.lcd_data3 */
    			0xb0 (PULL_DISABLE | MUX_MODE7)	/* lcd_data4.lcd_data4 */
    			0xb4 (PULL_DISABLE | MUX_MODE7)	/* lcd_data5.lcd_data5 */
    			0xb8 (PULL_DISABLE | MUX_MODE7)	/* lcd_data6.lcd_data6 */
    			0xbc (PULL_DISABLE | MUX_MODE7)	/* lcd_data7.lcd_data7 */
    			0xc0 (PULL_DISABLE | MUX_MODE7)	/* lcd_data8.lcd_data8 */
    			0xc4 (PULL_DISABLE | MUX_MODE7)	/* lcd_data9.lcd_data9 */
    			0xc8 (PULL_DISABLE | MUX_MODE7)	/* lcd_data10.lcd_data10 */
    			0xcc (PULL_DISABLE | MUX_MODE7)	/* lcd_data11.lcd_data11 */
    			0xd0 (PULL_DISABLE | MUX_MODE7)	/* lcd_data12.lcd_data12 */
    			0xd4 (PULL_DISABLE | MUX_MODE7)	/* lcd_data13.lcd_data13 */
    			0xd8 (PULL_DISABLE | MUX_MODE7)	/* lcd_data14.lcd_data14 */
    			0xdc (PULL_DISABLE | MUX_MODE7)	/* lcd_data15.lcd_data15 */
    			0xe0 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* lcd_vsync.lcd_vsync */
    			0xe4 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* lcd_hsync.lcd_hsync */
    			0xe8 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* lcd_pclk.lcd_pclk */
    			0xec (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* lcd_ac_bias_en.lcd_ac_bias_en */
    		>;
    	};
    
    	usb_3_pins_default: usb_3_pins_default {
    		pinctrl-single,pins = <
    		0x21c ( PIN_OUTPUT | MUX_MODE0 ) /* (F16) USB0_DRVVBUS.USB0_DRVVBUS */
    	>;
    	};
    
    	i2c0_pins: pinmux_i2c0_pins {
    		pinctrl-single,pins = <
    			0x188 (PIN_INPUT_PULLUP | MUX_MODE0)	/* C17 i2c0_sda.i2c0_sda */
    			0x18c (PIN_INPUT_PULLUP | MUX_MODE0)	/* C16 i2c0_scl.i2c0_scl */
    		>;
    	};
    
        /* Direct UART on Board */
    	uart0_pins: pinmux_uart0_pins {
    		pinctrl-single,pins = <
    			0x170 (PIN_INPUT_PULLUP | MUX_MODE0)	/* E15 uart0_rxd.uart0_rxd */
    			0x174 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* E16 uart0_txd.uart0_txd */
    		>;
    	};
    
    
        /* UART1 for Zigbee with Flow Control */
        uart1_pins_default: pinmux_uart1_pins_default {
            pinctrl-single,pins = <
                0x180 ( PIN_INPUT_PULLUP    | MUX_MODE0 )   /* (D16) uart1_rxd */
                0x184 ( PIN_OUTPUT_PULLDOWN | MUX_MODE0 )   /* (D15) uart1_txd */
                0x178 ( PIN_INPUT           | MUX_MODE0 )   /* (D18) uart1_ctsn */
                0x17c ( PIN_OUTPUT_PULLDOWN | MUX_MODE0 )   /* (D17) uart1_rtsn */
            >;
    
        };
    
        uart1_pins_sleep: pinmux_uart1_pins_sleep {
            pinctrl-single,pins = <
                0x180 ( PIN_INPUT_PULLDOWN | MUX_MODE7 )    /* (D16) uart1_rxd.gpio0_14  */
                0x184 ( PIN_INPUT_PULLDOWN | MUX_MODE7 )    /* (D15) uart1_txd.gpio0_15  */
                0x178 ( PIN_INPUT_PULLDOWN | MUX_MODE7 )    /* (D18) uart1_ctsn.gpio0_12 */
                0x17c ( PIN_INPUT_PULLDOWN | MUX_MODE7 )    /* (D17) uart1_rtsn.gpio0_13 */
            >;
    
        };
    
        /* UART4 for MCU Pin Muxing*/
        uart4_pins: pinmux_uart4_pins {
            pinctrl-single,pins = <
                0x16c (PIN_OUTPUT_PULLDOWN | MUX_MODE1)     /* (E17) uart0_rtsn.uart4_txd */
                0x168 (PIN_INPUT_PULLUP    | MUX_MODE1)     /* (E17) uart0_ctsn.uart4_rxd */
            >;
        };
    
        /* UART5 for Bluetooth Interface*/
        uart5_pins_default: pinmux_uart5_pins_default {
            pinctrl-single,pins = <
                0x108 ( PIN_INPUT_PULLUP | MUX_MODE3 )      /* (H16) gmii1_col.uart5_rxd */
                0x144 ( PIN_OUTPUT_PULLDOWN | MUX_MODE3 )   /* (H18) rmii1_refclk.uart5_txd */
                0x10c ( PIN_INPUT | MUX_MODE5 )             /* (H17) gmii1_crs.uart5_ctsn */
                0x110 ( PIN_OUTPUT_PULLDOWN | MUX_MODE5 )   /* (J15) gmii1_rxer.uart5_rtsn */
            >;
    
        };
    
        uart5_pins_sleep: pinmux_uart5_pins_sleep {
            pinctrl-single,pins = <
                0x108 ( PIN_INPUT_PULLDOWN | MUX_MODE7 )    /* (H16) gmii1_col.uart5_rxd */
                0x144 ( PIN_INPUT_PULLDOWN | MUX_MODE7 )    /* (H18) rmii1_refclk.uart5_txd */
                0x10c ( PIN_INPUT_PULLDOWN | MUX_MODE7 )    /* (H17) gmii1_crs.uart5_ctsn */
                0x110 ( PIN_INPUT_PULLDOWN | MUX_MODE7 )    /* (J15) gmii1_rxer.uart5_rtsn */
            >;
    
        };
       
    	cpsw_default: cpsw_default {
    		pinctrl-single,pins = <
    			0x78 ( PIN_INPUT | MUX_MODE1 ) /* (U18) gpmc_be1n.gmii2_col */
    			0x70 ( PIN_INPUT | MUX_MODE1 ) /* (T17) gpmc_wait0.gmii2_crs */
    			0x74 ( PIN_INPUT | MUX_MODE1 ) /* (U17) gpmc_wpn.gmii2_rxer */
    			0x40 ( PIN_OUTPUT | MUX_MODE1 ) /* (R13) gpmc_a0.gmii2_txen */
    			0x44 ( PIN_INPUT | MUX_MODE1 ) /* (V14) gpmc_a1.gmii2_rxdv */
    			0x58 ( PIN_INPUT | MUX_MODE1 ) /* (U15) gpmc_a6.gmii2_txclk */
    			0x5c ( PIN_INPUT | MUX_MODE1 ) /* (T15) gpmc_a7.gmii2_rxclk */
    			0x54 ( PIN_OUTPUT | MUX_MODE1 ) /* (V15) gpmc_a5.gmii2_txd0 */
    			0x50 ( PIN_OUTPUT | MUX_MODE1 ) /* (R14) gpmc_a4.gmii2_txd1 */
    			0x4c ( PIN_OUTPUT | MUX_MODE1 ) /* (T14) gpmc_a3.gmii2_txd2 */
    			0x48 ( PIN_OUTPUT | MUX_MODE1 ) /* (U14) gpmc_a2.gmii2_txd3 */
    			0x6c ( PIN_INPUT | MUX_MODE1 ) /* (V17) gpmc_a11.gmii2_rxd0 */
    			0x68 ( PIN_INPUT | MUX_MODE1 ) /* (T16) gpmc_a10.gmii2_rxd1 */
    			0x64 ( PIN_INPUT | MUX_MODE1 ) /* (U16) gpmc_a9.gmii2_rxd2 */
    			0x60 ( PIN_INPUT | MUX_MODE1 ) /* (V16) gpmc_a8.gmii2_rxd3 */
    		>;
    	};
    
    	cpsw_sleep: cpsw_sleep {
    		pinctrl-single,pins = <
    			0x78 ( PIN_INPUT | MUX_MODE7 ) /* (U18) gpmc_be1n.gmii2_col */
    			0x70 ( PIN_INPUT | MUX_MODE7 ) /* (T17) gpmc_wait0.gmii2_crs */
    			0x74 ( PIN_INPUT | MUX_MODE7 ) /* (U17) gpmc_wpn.gmii2_rxer */
    			0x40 ( PIN_OUTPUT | MUX_MODE7 ) /* (R13) gpmc_a0.gmii2_txen */
    			0x44 ( PIN_INPUT | MUX_MODE7 ) /* (V14) gpmc_a1.gmii2_rxdv */
    			0x58 ( PIN_INPUT | MUX_MODE7 ) /* (U15) gpmc_a6.gmii2_txclk */
    			0x5c ( PIN_INPUT | MUX_MODE7 ) /* (T15) gpmc_a7.gmii2_rxclk */
    			0x54 ( PIN_OUTPUT | MUX_MODE7 ) /* (V15) gpmc_a5.gmii2_txd0 */
    			0x50 ( PIN_OUTPUT | MUX_MODE7 ) /* (R14) gpmc_a4.gmii2_txd1 */
    			0x4c ( PIN_OUTPUT | MUX_MODE7 ) /* (T14) gpmc_a3.gmii2_txd2 */
    			0x48 ( PIN_OUTPUT | MUX_MODE7 ) /* (U14) gpmc_a2.gmii2_txd3 */
    			0x6c ( PIN_INPUT | MUX_MODE7 ) /* (V17) gpmc_a11.gmii2_rxd0 */
    			0x68 ( PIN_INPUT | MUX_MODE7 ) /* (T16) gpmc_a10.gmii2_rxd1 */
    			0x64 ( PIN_INPUT | MUX_MODE7 ) /* (U16) gpmc_a9.gmii2_rxd2 */
    			0x60 ( PIN_INPUT | MUX_MODE7 ) /* (V16) gpmc_a8.gmii2_rxd3 */
    		>;
    	};
    
    	davinci_mdio_default: davinci_mdio_default {
    		pinctrl-single,pins = <
    			/* MDIO */
    			0x148 (PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE0)	/* M17 mdio_data.mdio_data */
    			0x14c (PIN_OUTPUT_PULLUP | MUX_MODE0)			/* M18 mdio_clk.mdio_clk */
    		>;
    	};
    
    	davinci_mdio_sleep: davinci_mdio_sleep {
    		pinctrl-single,pins = <
    			/* MDIO reset value */
    			0x148 (PIN_INPUT_PULLDOWN | MUX_MODE7) /* M17 mdio_data.mdio_data */
    			0x14c (PIN_INPUT_PULLDOWN | MUX_MODE7) /* M18 mdio_clk.mdio_clk */
    		>;
    	};
    
    	gpio_2_pins_default: gpio_2_pins_default {
    		pinctrl-single,pins = <
    		0x88 ( PIN_INPUT | MUX_MODE7 ) /* (T13) gpmc_csn3.gpio2[0] ZIG_JTAG_TD */
    		0x90 ( PIN_OUTPUT | MUX_MODE7 ) /* (R7) gpmc_advn_ale.gpio2[2] Audio_AMP_EN */
    		0x94 ( PIN_OUTPUT | MUX_MODE7 ) /* (T7) gpmc_oen_ren.gpio2[3] FPGA_RSTIN */
    		0x98 ( PIN_OUTPUT | MUX_MODE7 ) /* (U6) gpmc_wen.gpio2[4] FPGA_PWR_EN */
    		0x9c ( PIN_OUTPUT | MUX_MODE7 ) /* (T6) gpmc_be0n_cle.gpio2[5] FAN_FB */
    		0x13c ( PIN_OUTPUT | MUX_MODE7 ) /* (L15) gmii1_rxd1.gpio2[20] ZIG_JTAG_TCK */
    		0x140 ( PIN_OUTPUT | MUX_MODE7 ) /* (M16) gmii1_rxd0.gpio2[21] ZIGBEE_RESET_AM335x*/
    		>;
    	};
    
    	gpio_3_pins_default: gpio_3_pins_default {
    		pinctrl-single,pins = <
    		0x234 ( PIN_OUTPUT | MUX_MODE7 ) /* (F15) USB1_DRVVBUS.gpio3[13] AUDIO_RESETn */
    		0x1a4 ( PIN_INPUT | MUX_MODE7 ) /* (C13) mcasp0_fsr.gpio3[19] FDONE_CONFIG */
    		0x1a8 ( PIN_INPUT | MUX_MODE7 ) /* (D13) mcasp0_axr1.gpio3[20] nFINFT_CONFIG */
    		>;
    	};
    
    	gpio_1_pins_default: gpio_1_pins_default {
    		pinctrl-single,pins = <
    		0x10 ( PIN_INPUT | MUX_MODE7 ) /* (U8) gpmc_ad4.gpio1[4] PWDN_L*/
    		0x14 ( PIN_OUTPUT | MUX_MODE7 ) /* (V8) gpmc_ad5.gpio1[5] NFC_EN */
    		0x18 ( PIN_OUTPUT | MUX_MODE7 ) /* (R9) gpmc_ad6.gpio1[6] SPI_SELECT*/
    		0x1c ( PIN_OUTPUT | MUX_MODE7 ) /* (T9) gpmc_ad7.gpio1[7] SPI_CSn  */
    		>;
    	};
    
    	gpio_0_pins_default: my_gpio_0_pins_default {
    		pinctrl-single,pins = <
    		0x164 ( PIN_INPUT | MUX_MODE7 ) /* (C18) eCAP0_in_PWM0_out.gpio0[7] NFC_IRQ*/
    		0x1b0 ( PIN_OUTPUT | MUX_MODE7 ) /* (A15) xdma_event_intr0.gpio0[19] ZIG_SYSTEM_PWRON*/
    		0x124 ( PIN_OUTPUT | MUX_MODE7 ) /* (K16) gmii1_txd1.gpio0[21] LCOS_BD_RESETn*/
    		0x128 ( PIN_OUTPUT | MUX_MODE7 ) /* (K17) gmii1_txd0.gpio0[28]  PHY_RESETZ*/
    		>;
    	};
    
    	mmc1_pins_default: pinmux_mmc1_pins {
    		pinctrl-single,pins = <
    			0x0F0 (PIN_INPUT_PULLUP | MUX_MODE0)	/* F17 mmc0_dat3.mmc0_dat3 CONN_SD0_DATA3 */
    			0x0F4 (PIN_INPUT_PULLUP | MUX_MODE0)	/* F18 mmc0_dat2.mmc0_dat2 CONN_SD0_DATA2 */
    			0x0F8 (PIN_INPUT_PULLUP | MUX_MODE0)	/* G15 mmc0_dat1.mmc0_dat1 CONN_SD0_DATA1 */
    			0x0FC (PIN_INPUT_PULLUP | MUX_MODE0)	/* G16 mmc0_dat0.mmc0_dat0 CONN_SD0_DATA0 */
    			0x100 (PIN_INPUT_PULLUP | MUX_MODE0)	/* G17 mmc0_clk.mmc0_clk CONN_SD0_CLK */
    			0x104 (PIN_INPUT_PULLUP | MUX_MODE0)	/* G18 mmc0_cmd.mmc0_cmd CONN_SD0_CMD */
    			0x160 (PIN_INPUT | MUX_MODE7)		/* C15 spi0_cs1.gpio0_6 SD0_CD */
    		>;
    	};
    
    	mmc1_pins_sleep: pinmux_mmc1_pins_sleep {
    		pinctrl-single,pins = <
    			0x0F0 (PIN_INPUT_PULLUP | MUX_MODE7)	/* F17 mmc0_dat3.mmc0_dat3 CONN_SD0_DATA3 */
    			0x0F4 (PIN_INPUT_PULLUP | MUX_MODE7)	/* F18 mmc0_dat2.mmc0_dat2 CONN_SD0_DATA2 */
    			0x0F8 (PIN_INPUT_PULLUP | MUX_MODE7)	/* G15 mmc0_dat1.mmc0_dat1 CONN_SD0_DATA1 */
    			0x0FC (PIN_INPUT_PULLUP | MUX_MODE7)	/* G16 mmc0_dat0.mmc0_dat0 CONN_SD0_DATA0 */
    			0x100 (PIN_INPUT_PULLUP | MUX_MODE7)	/* G17 mmc0_clk.mmc0_clk CONN_SD0_CLK */
    			0x104 (PIN_INPUT_PULLUP | MUX_MODE7)	/* G18 mmc0_cmd.mmc0_cmd CONN_SD0_CMD */
    			0x160 (PIN_INPUT | MUX_MODE7)		/* C15 spi0_cs1.gpio0_6 SD0_CD */
    		>;
    	};
    
        /* Added for edge */
        /* MMC1 interface for WLAN*/
    
        mmc2_pins_default: pinmux_mmc2_pins_default {
            pinctrl-single,pins = <
                0x0 ( PIN_INPUT_PULLUP | MUX_MODE1 ) /* (U7) gpmc_ad0.mmc1_dat0 */
                0x4 ( PIN_INPUT_PULLUP | MUX_MODE1 ) /* (V7) gpmc_ad1.mmc1_dat1 */
                0x8 ( PIN_INPUT_PULLUP | MUX_MODE1 ) /* (R8) gpmc_ad2.mmc1_dat2 */
                0xc ( PIN_INPUT_PULLUP | MUX_MODE1 ) /* (T8) gpmc_ad3.mmc1_dat3 */
                0x80 ( PIN_INPUT_PULLUP | MUX_MODE2 ) /* (U9) gpmc_csn1.mmc1_clk */
                0x84 ( PIN_INPUT_PULLUP | MUX_MODE2 ) /* (V9) gpmc_csn2.mmc1_cmd */ 
            >;
        };
    
        /*Added for edge*/
        mmc2_pins_sleep: pinmux_mmc2_pins_sleep {
            pinctrl-single,pins = <
                0x0 ( PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (U7) gpmc_ad0.mmc1_dat0 */
                0x4 ( PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (V7) gpmc_ad1.mmc1_dat1 */
                0x8 ( PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (R8) gpmc_ad2.mmc1_dat2 */
                0xc ( PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (T8) gpmc_ad3.mmc1_dat3 */
                0x80 ( PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (U9) gpmc_csn1.mmc1_clk */
                0x84 ( PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (V9) gpmc_csn2.mmc1_cmd */
            >;
        };
    
        /* wl12xx/wl18xx card enable/irq GPIOs. */
        wlan_pins: pinmux_wlan_pins {
            pinctrl-single,pins = <
                0x114 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* (J16) gmii1_txen.gpio3_3 WL_EN*/
                0x8c (PIN_INPUT_PULLUP | MUX_MODE7)     /* (V12) gpmc_clk.gpio2_1 WLAN_IRQ*/
                0x7c (PIN_OUTPUT_PULLDOWN | MUX_MODE7)  /* (V6) gpmc_csn0.gpio1_29 BT_EN*/
            >;
        };
    
        /* wl12xx/wl18xx card enable/irq GPIOs. */
        wlan_pins_sleep: pinmux_wlan_pins_sleep {
            pinctrl-single,pins = <
                0x114 (PIN_OUTPUT_PULLUP | MUX_MODE7)   /* (J16) gmii1_txen.gpio3_3 WL_EN*/
                0x8c (PIN_INPUT_PULLUP | MUX_MODE7)     /* (V12) gpmc_clk.gpio2_1 WLAN_IRQ*/
                0x7c (PIN_OUTPUT_PULLUP | MUX_MODE7)    /* (V6) gpmc_csn0.gpio1_29 BT_EN*/
            >;
        };
    
    	mcasp0_pins: mcasp0_pins {
    		pinctrl-single,pins = <
    			0x120 (PIN_OUTPUT | MUX_MODE6)  /* K15 MII1_TXD2 mcasp0_ahclkx-MCLK */ 
    			0x12C (PIN_OUTPUT | MUX_MODE6)  /* K18 MII1_TX_CLK mcasp0_aclkx-BCLK */
    			0x130 (PIN_OUTPUT | MUX_MODE6) /* L18 MII1_RX_CLK mcasp0_fsx-WCLK */
    			0x118 (PIN_INPUT | MUX_MODE6)  /* J17 MII1_RX_DV mcasp0_aclkr-BCLK */
    			0x11C (PIN_INPUT | MUX_MODE6)	/* J18 MII1_TXD3 mcasp0_fsr-WCLK */ 
    			0x134 (PIN_OUTPUT| MUX_MODE6)  /* L17 MII1_RXD3 mcasp0_axr0-TXD */ 
    			0x138 (PIN_INPUT | MUX_MODE6)  /* L16 MII1_RXD2 mcasp0_axr1-RXD */ 
    		>;
    	};
    
    	mcasp0_pins_sleep: mcasp0_pins_sleep {
    		pinctrl-single,pins = <
    			0x120 (PIN_OUTPUT | MUX_MODE7)  /* K15 MII1_TXD2 mcasp0_ahclkx-MCLK */ 
    			0x12C (PIN_OUTPUT | MUX_MODE7)  /* K18 MII1_TX_CLK mcasp0_aclkx-BCLK */
    			0x130 (PIN_OUTPUT | MUX_MODE7) /* L18 MII1_RX_CLK mcasp0_fsx-WCLK */
    			0x118 (PIN_INPUT | MUX_MODE7)  /* J17 MII1_RX_DV mcasp0_aclkr-BCLK */
    			0x11C (PIN_INPUT | MUX_MODE7)	/* J18 MII1_TXD3 mcasp0_fsr-WCLK */ 
    			0x134 (PIN_OUTPUT | MUX_MODE7)  /* L17 MII1_RXD3 mcasp0_axr0-TXD */ 
    			0x138 (PIN_INPUT | MUX_MODE7)  /* L16 MII1_RXD2 mcasp0_axr1-RXD */ 
    		>;
    	};
    
    	pru_pins: pru_pins {
    		pinctrl-single,pins = <
    		0x190 0x05
                    0x1ac 0x2e
                    0x19c 0x2e
                    /*0x194 ( PIN_INPUT | MUX_MODE6 ) /* Previous-0x194 ( PIN_INPUT | MUX_MODE5 ) (B13) mcasp0_fsx.pr1_pru0_pru_r30[1] DE_PRU_IN*/
                    /*0x198 ( PIN_OUTPUT | MUX_MODE5 ) /* (D12) mcasp0_axr0.pr1_pru0_pru_r30[2] DE_PRU_OUT*/
                    /*0x1a0 ( PIN_OUTPUT | MUX_MODE5 ) /* (B12) mcasp0_aclkr.pr1_pru0_pru_r30[4]  PCLK_PRU_OUT*/
                    /*0x1b4 ( PIN_INPUT | MUX_MODE5 ) /* (D14) xdma_event_intr1.pr1_pru0_pru_r31[16]  PCLK_PRU_IN*/
                    /*0x1a4 ( PIN_OUTPUT | MUX_MODE5 ) /* (C13) pr1_pru0_pru_r30_5  VSYNC_PRU_OUT */
    		>;
    	};
    };
    
    &uart0 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&uart0_pins>;
    
    	status = "okay";
    };
    
    &uart1 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart1_pins_default>;
        pinctrl-1 = <&uart1_pins_sleep>;
        
        status = "okay";
    };
    
    &uart4 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&uart4_pins>;
    
    	status = "okay";
    };
    
    &uart5 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart5_pins_default>;
        pinctrl-1 = <&uart5_pins_sleep>;
        
        status = "okay";
    };
    
    &i2c0 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&i2c0_pins>;
    
    	status = "okay";
    	clock-frequency = <400000>;
    
    	tlv320aic310x: tlv320aic310x@18 {
    		compatible = "ti,tlv320aic310x";
    		reg = <0x18>;
    		status = "okay";
    		gpio-reset = <&gpio3 13 GPIO_ACTIVE_LOW>; /*GPIO3_13*/
    		/* Regulators */
    		AVDD-supply = <&vaux2_reg>;
                    IOVDD-supply = <&vaux2_reg>;
                    DRVDD-supply = <&vaux2_reg>;
    
    		DVDD-supply = <&vaux2_reg1>;
    	};
    };
    
    &usb {
    	status = "okay";
    
    	control@44e10620 {
    		status = "okay";
    	};
    
    	usb-phy@47401300 {
    		status = "okay";
    	};
    
    	usb@47401000 {
    		status = "okay";
    		dr_mode = "host";
    	};
    
    	dma-controller@47402000  {
    		status = "okay";
    	};
    
    	usb-phy@47401b00 {
    		status = "okay";
    	};
    	usb@47401800 {
    		status = "okay";
    		dr_mode = "host";
    	};
    };
    
    &wkup_m3 {
    	ti,needs-vtt-toggle;
    	ti,vtt-gpio-pin = <7>;
    	ti,scale-data-fw = "am335x-evm-scale-data.bin";
    };
    
    &mac {
    	pinctrl-names = "default", "sleep";
    	pinctrl-0 = <&cpsw_default>;
    	pinctrl-1 = <&cpsw_sleep>;
    	dual_emac = <1>;
    };
    
    &davinci_mdio {
    	pinctrl-names = "default", "sleep";
    	pinctrl-0 = <&davinci_mdio_default>;
    	pinctrl-1 = <&davinci_mdio_sleep>;
    };
    
    &cpsw_emac0 {
    	phy_id = <&davinci_mdio>, <0>;
    	phy-mode = "rgmii-txid";
    	dual_emac_res_vlan = <1>;
    };
    
    &cpsw_emac1 {
    	phy_id = <&davinci_mdio>, <1>;
    	phy-mode = "mii";
    	dual_emac_res_vlan = <2>;
    };
    
    &mmc1 {
    	status = "okay";
    	vmmc-supply = <&vmmcsd_fixed>;
    	bus-width = <4>;
    	pinctrl-names = "default", "sleep";
    	pinctrl-0 = <&mmc1_pins_default>;
    	pinctrl-1 = <&mmc1_pins_sleep>;
    	cd-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
    };
    
    &mmc2 {
        status = "okay";
        vmmc-supply = <&wlan_en_reg>;
        bus-width = <4>;
        pinctrl-names = "default", "sleep";
        pinctrl-0 = <&mmc2_pins_default &wlan_pins>;
        pinctrl-1 = <&mmc2_pins_sleep &wlan_pins_sleep>;
        ti,non-removable;
        ti,needs-special-hs-handling;
        cap-power-off-card;
        keep-power-in-suspend;
    
        #address-cells = <1>;
        #size-cells = <0>;
        wlcore: wlcore@0 {
            compatible = "ti,wlcore";
            reg = <2>;
            interrupt-parent = <&gpio2>;
            interrupts = <1 IRQ_TYPE_NONE>;
        };
    };
    
    &sham {
    	status = "okay";
    };
    
    &aes {
    	status = "okay";
    };
    
    &gpio0 {
    	ti,no-reset-on-init;
    };
    
    &mcasp0 {
    	pinctrl-names = "default", "sleep";
    	pinctrl-0 = <&mcasp0_pins>;
    	pinctrl-1 = <&mcasp0_pins_sleep>;
    
    	status = "okay";
    
    	op-mode = <0>;	/* MCASP_IIS_MODE */
    	tdm-slots = <2>;
    	/* 4 serializers */
    	serial-dir = <	/* 0: INACTIVE, 1: TX, 2: RX  AXR0-TXD AXR1-RXD */
    		1 2 0 0
    	>;
    	tx-num-evt = <32>;
    	rx-num-evt = <32>;
    };
    
    &lcdc {
          status = "okay";
    };
    
    &pruss {
          pinctrl-names = "default";
          pinctrl-0 = <&pru_pins>;
    
          status = "okay";
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &gpio1 {
    	status = "okay";
    };
    
    /*
     * ASoC driver for TI DAVINCI EVM platform
     *
     * Author:      Vladimir Barinov, <vbarinov@embeddedalley.com>
     * Copyright:   (C) 2007 MontaVista Software, Inc., <source@mvista.com>
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License version 2 as
     * published by the Free Software Foundation.
     */
    
    #include <linux/module.h>
    #include <linux/moduleparam.h>
    #include <linux/timer.h>
    #include <linux/interrupt.h>
    #include <linux/platform_device.h>
    #include <linux/platform_data/edma.h>
    #include <linux/i2c.h>
    #include <linux/of_platform.h>
    #include <linux/clk.h>
    #include <sound/core.h>
    #include <sound/pcm.h>
    #include <sound/soc.h>
    #include <sound/pcm_params.h>
    #include <linux/device.h>
    #include <asm/dma.h>
    #include <asm/mach-types.h>
    
    #include <linux/edma.h>
    
    #include "davinci-pcm.h"
    #include "davinci-i2s.h"
    
    struct snd_soc_card_drvdata_davinci {
    	struct clk *mclk;
    	unsigned sysclk;
    };
    
    static int evm_startup(struct snd_pcm_substream *substream)
    {
    	struct snd_soc_pcm_runtime *rtd = substream->private_data;
    	struct snd_soc_card *soc_card = rtd->card;
    	struct snd_soc_card_drvdata_davinci *drvdata =
    		snd_soc_card_get_drvdata(soc_card);
    
    	if (drvdata->mclk)
    		return clk_prepare_enable(drvdata->mclk);
    
    	return 0;
    }
    
    static int dra7xx_evm_startup(struct snd_pcm_substream *substream)
    {
    	snd_pcm_hw_constraint_minmax(substream->runtime,
    				     SNDRV_PCM_HW_PARAM_RATE, 44100, 44100);
    
    	return evm_startup(substream);
    }
    
    static int dra7xx_evm_hw_params(struct snd_pcm_substream *substream,
    				     struct snd_pcm_hw_params *params)
    {
    	struct snd_soc_pcm_runtime *rtd = substream->private_data;
    	struct snd_soc_dai *codec_dai = rtd->codec_dai;
    	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
    	struct snd_soc_card *soc_card = rtd->card;
    	struct snd_soc_card_drvdata_davinci *drvdata =
    		snd_soc_card_get_drvdata(soc_card);
    	int ret;
    
    	/* Set MCLK as clock source for tlv320aic3106 */
    	ret = snd_soc_dai_set_sysclk(codec_dai, 0, drvdata->sysclk,
    				     SND_SOC_CLOCK_IN);
    	if (ret < 0)
    		return ret;
    
    	/* Set McASP sysclk from AHCLKX sourced from ATL */
    	ret = snd_soc_dai_set_sysclk(cpu_dai, 0, drvdata->sysclk,
    				     SND_SOC_CLOCK_IN);
    	return ret;
    }
    
    static void evm_shutdown(struct snd_pcm_substream *substream)
    {
    	struct snd_soc_pcm_runtime *rtd = substream->private_data;
    	struct snd_soc_card *soc_card = rtd->card;
    	struct snd_soc_card_drvdata_davinci *drvdata =
    		snd_soc_card_get_drvdata(soc_card);
    
    	if (drvdata->mclk)
    		clk_disable_unprepare(drvdata->mclk);
    }
    
    static int evm_hw_params(struct snd_pcm_substream *substream,
    			 struct snd_pcm_hw_params *params)
    {
    	struct snd_soc_pcm_runtime *rtd = substream->private_data;
    	struct snd_soc_dai *codec_dai = rtd->codec_dai;
    	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
    	struct snd_soc_card *soc_card = rtd->card;
    	int ret = 0;
    	unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *)
    			   snd_soc_card_get_drvdata(soc_card))->sysclk;
    
    	unsigned int bclk_freq = snd_soc_params_to_bclk(params);	
    	ret = snd_soc_dai_set_clkdiv(cpu_dai, 1, sysclk/bclk_freq);
    	if (ret < 0) {
    		printk("can't set CPU DAI clock divider %d\n",
    			ret);
    		return ret;
    	}
     
    	printk("bclk_freq=%d\n", bclk_freq);
    	printk("sysclk=%d\n", sysclk);
    	/* set the codec system clock */
    	ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
    	if (ret < 0)
    		return ret;
    
    	/* set the CPU system clock */
    	ret = snd_soc_dai_set_sysclk(cpu_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
    	if (ret < 0)
    		return ret;
    
    	return 0;
    }
    
    /* If changing sample format the tda998x configuration (REG_CTS_N) needs
       to be changed. */
    #define TDA998X_SAMPLE_FORMAT SNDRV_PCM_FORMAT_S32_LE
    static int evm_tda998x_startup(struct snd_pcm_substream *substream)
    {
    	struct snd_pcm_runtime *runtime = substream->runtime;
    	struct snd_mask *fmt = constrs_mask(&runtime->hw_constraints,
    					    SNDRV_PCM_HW_PARAM_FORMAT);
    	snd_mask_none(fmt);
    	snd_mask_set(fmt, TDA998X_SAMPLE_FORMAT);
    
    	return evm_startup(substream);
    }
    
    static int evm_tda998x_hw_params(struct snd_pcm_substream *substream,
    				 struct snd_pcm_hw_params *params)
    {
    	struct snd_soc_pcm_runtime *rtd = substream->private_data;
    	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
    	struct snd_soc_card *soc_card = rtd->card;
    	struct snd_soc_card_drvdata_davinci *drvdata =
    		snd_soc_card_get_drvdata(soc_card);
    
    	return snd_soc_dai_set_sysclk(cpu_dai, 0, drvdata->sysclk,
    				      SND_SOC_CLOCK_IN);
    }
    
    static struct snd_soc_ops evm_ops = {
    	.startup = evm_startup,
    	.shutdown = evm_shutdown,
    	.hw_params = evm_hw_params,
    };
    
    
    static struct snd_soc_ops evm_tda998x_ops = {
    	.startup = evm_tda998x_startup,
    	.shutdown = evm_shutdown,
    	.hw_params = evm_tda998x_hw_params,
    };
    
    static struct snd_soc_ops dra7xx_ops = {
    	.startup = dra7xx_evm_startup,
    	.shutdown = evm_shutdown,
    	.hw_params = dra7xx_evm_hw_params,
    };
    
    /* davinci-evm machine dapm widgets */
    static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
    	SND_SOC_DAPM_HP("Headphone Jack", NULL),
    	SND_SOC_DAPM_LINE("Line Out", NULL),
    	SND_SOC_DAPM_MIC("Mic Jack", NULL),
    	SND_SOC_DAPM_LINE("Line In", NULL),
    };
    
    /* davinci-evm machine audio_mapnections to the codec pins */
    static const struct snd_soc_dapm_route audio_map[] = {
    	/* Headphone connected to HPLOUT, HPROUT */
    	{"Headphone Jack", NULL, "HPLOUT"},
    	{"Headphone Jack", NULL, "HPROUT"},
    
    	/* Line Out connected to LLOUT, RLOUT */
    	{"Line Out", NULL, "LLOUT"},
    	{"Line Out", NULL, "RLOUT"},
    
    	/* Mic connected to (MIC3L | MIC3R) */
    	{"MIC3L", NULL, "Mic Bias"},
    	{"MIC3R", NULL, "Mic Bias"},
    	{"Mic Bias", NULL, "Mic Jack"},
    
    	/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
    	{"LINE1L", NULL, "Line In"},
    	{"LINE2L", NULL, "Line In"},
    	{"LINE1R", NULL, "Line In"},
    	{"LINE2R", NULL, "Line In"},
    };
    
    /* Logic for a aic3x as connected on a davinci-evm */
    static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd)
    {
    	struct snd_soc_card *card = rtd->card;
    	struct snd_soc_codec *codec = rtd->codec;
    	struct device_node *np = card->dev->of_node;
    	int ret;
    
    	/* Add davinci-evm specific widgets */
    	snd_soc_dapm_new_controls(&card->dapm, aic3x_dapm_widgets,
    				  ARRAY_SIZE(aic3x_dapm_widgets));
    
    	if (np) {
    		ret = snd_soc_of_parse_audio_routing(card, "ti,audio-routing");
    		if (ret)
    			return ret;
    	} else {
    		/* Set up davinci-evm specific audio path audio_map */
    		snd_soc_dapm_add_routes(&card->dapm, audio_map,
    					ARRAY_SIZE(audio_map));
    	}
    
    	/* not connected */
    	snd_soc_dapm_nc_pin(&codec->dapm, "MONO_LOUT");
    	snd_soc_dapm_nc_pin(&codec->dapm, "HPLCOM");
    	snd_soc_dapm_nc_pin(&codec->dapm, "HPRCOM");
    
    	return 0;
    }
    
    static const struct snd_soc_dapm_widget tda998x_dapm_widgets[] = {
    	SND_SOC_DAPM_OUTPUT("HDMI Out"),
    };
    
    static int evm_tda998x_init(struct snd_soc_pcm_runtime *rtd)
    {
    	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
    	struct snd_soc_dapm_context *dapm = &rtd->codec->dapm;
    	struct snd_soc_card *soc_card = rtd->card;
    	int ret;
    
    	ret = snd_soc_dai_set_clkdiv(cpu_dai, 0, 1);
    	if (ret < 0)
    		return ret;
    
    	snd_soc_dapm_new_controls(dapm, tda998x_dapm_widgets,
    				  ARRAY_SIZE(tda998x_dapm_widgets));
    
    	ret = snd_soc_of_parse_audio_routing(soc_card, "ti,audio-routing");
    
    	/* not connected */
    	snd_soc_dapm_disable_pin(dapm, "RX");
    
    	/* always connected */
    	snd_soc_dapm_enable_pin(dapm, "HDMI Out");
    
    	return 0;
    }
    
    /* davinci-evm digital audio interface glue - connects codec <--> CPU */
    static struct snd_soc_dai_link dm6446_evm_dai = {
    	.name = "TLV320AIC3X",
    	.stream_name = "AIC3X",
    	.cpu_dai_name = "davinci-mcbsp",
    	.codec_dai_name = "tlv320aic3x-hifi",
    	.codec_name = "tlv320aic3x-codec.1-001b",
    	.platform_name = "davinci-mcbsp",
    	.init = evm_aic3x_init,
    	.ops = &evm_ops,
    	.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
    		   SND_SOC_DAIFMT_IB_NF,
    };
    
    static struct snd_soc_dai_link dm355_evm_dai = {
    	.name = "TLV320AIC3X",
    	.stream_name = "AIC3X",
    	.cpu_dai_name = "davinci-mcbsp.1",
    	.codec_dai_name = "tlv320aic3x-hifi",
    	.codec_name = "tlv320aic3x-codec.1-001b",
    	.platform_name = "davinci-mcbsp.1",
    	.init = evm_aic3x_init,
    	.ops = &evm_ops,
    	.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
    		   SND_SOC_DAIFMT_IB_NF,
    };
    
    static struct snd_soc_dai_link dm365_evm_dai = {
    #ifdef CONFIG_SND_DM365_AIC3X_CODEC
    	.name = "TLV320AIC3X",
    	.stream_name = "AIC3X",
    	.cpu_dai_name = "davinci-mcbsp",
    	.codec_dai_name = "tlv320aic3x-hifi",
    	.codec_name = "tlv320aic3x-codec.1-0018",
    	.platform_name = "davinci-mcbsp",
    	.init = evm_aic3x_init,
    	.ops = &evm_ops,
    	.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
    		   SND_SOC_DAIFMT_IB_NF,
    #elif defined(CONFIG_SND_DM365_VOICE_CODEC)
    	.name = "Voice Codec - CQ93VC",
    	.stream_name = "CQ93",
    	.cpu_dai_name = "davinci-vcif",
    	.codec_dai_name = "cq93vc-hifi",
    	.codec_name = "cq93vc-codec",
    	.platform_name = "davinci-vcif",
    #endif
    };
    
    static struct snd_soc_dai_link dm6467_evm_dai[] = {
    	{
    		.name = "TLV320AIC3X",
    		.stream_name = "AIC3X",
    		.cpu_dai_name= "davinci-mcasp.0",
    		.codec_dai_name = "tlv320aic3x-hifi",
    		.platform_name = "davinci-mcasp.0",
    		.codec_name = "tlv320aic3x-codec.0-001a",
    		.init = evm_aic3x_init,
    		.ops = &evm_ops,
    		.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
    			   SND_SOC_DAIFMT_IB_NF,
    	},
    	{
    		.name = "McASP",
    		.stream_name = "spdif",
    		.cpu_dai_name= "davinci-mcasp.1",
    		.codec_dai_name = "dit-hifi",
    		.codec_name = "spdif_dit",
    		.platform_name = "davinci-mcasp.1",
    		.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
    			   SND_SOC_DAIFMT_IB_NF,
    	},
    };
    
    static struct snd_soc_dai_link da830_evm_dai = {
    	.name = "TLV320AIC3X",
    	.stream_name = "AIC3X",
    	.cpu_dai_name = "davinci-mcasp.1",
    	.codec_dai_name = "tlv320aic3x-hifi",
    	.codec_name = "tlv320aic3x-codec.1-0018",
    	.platform_name = "davinci-mcasp.1",
    	.init = evm_aic3x_init,
    	.ops = &evm_ops,
    	.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
    		   SND_SOC_DAIFMT_IB_NF,
    };
    
    static struct snd_soc_dai_link da850_evm_dai = {
    	.name = "TLV320AIC3X",
    	.stream_name = "AIC3X",
    	.cpu_dai_name= "davinci-mcasp.0",
    	.codec_dai_name = "tlv320aic3x-hifi",
    	.codec_name = "tlv320aic3x-codec.1-0018",
    	.platform_name = "davinci-mcasp.0",
    	.init = evm_aic3x_init,
    	.ops = &evm_ops,
    	.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
    		   SND_SOC_DAIFMT_IB_NF,
    };
    
    /* davinci dm6446 evm audio machine driver */
    /*
     * ASP0 in DM6446 EVM is clocked by U55, as configured by
     * board-dm644x-evm.c using GPIOs from U18.  There are six
     * options; here we "know" we use a 48 KHz sample rate.
     */
    static struct snd_soc_card_drvdata_davinci dm6446_snd_soc_card_drvdata = {
    	.sysclk = 12288000,
    };
    
    static struct snd_soc_card dm6446_snd_soc_card_evm = {
    	.name = "DaVinci DM6446 EVM",
    	.owner = THIS_MODULE,
    	.dai_link = &dm6446_evm_dai,
    	.num_links = 1,
    	.drvdata = &dm6446_snd_soc_card_drvdata,
    };
    
    /* davinci dm355 evm audio machine driver */
    /* ASP1 on DM355 EVM is clocked by an external oscillator */
    static struct snd_soc_card_drvdata_davinci dm355_snd_soc_card_drvdata = {
    	.sysclk = 27000000,
    };
    
    static struct snd_soc_card dm355_snd_soc_card_evm = {
    	.name = "DaVinci DM355 EVM",
    	.owner = THIS_MODULE,
    	.dai_link = &dm355_evm_dai,
    	.num_links = 1,
    	.drvdata = &dm355_snd_soc_card_drvdata,
    };
    
    /* davinci dm365 evm audio machine driver */
    static struct snd_soc_card_drvdata_davinci dm365_snd_soc_card_drvdata = {
    	.sysclk = 27000000,
    };
    
    static struct snd_soc_card dm365_snd_soc_card_evm = {
    	.name = "DaVinci DM365 EVM",
    	.owner = THIS_MODULE,
    	.dai_link = &dm365_evm_dai,
    	.num_links = 1,
    	.drvdata = &dm365_snd_soc_card_drvdata,
    };
    
    /* davinci dm6467 evm audio machine driver */
    static struct snd_soc_card_drvdata_davinci dm6467_snd_soc_card_drvdata = {
    	.sysclk = 27000000,
    };
    
    static struct snd_soc_card dm6467_snd_soc_card_evm = {
    	.name = "DaVinci DM6467 EVM",
    	.owner = THIS_MODULE,
    	.dai_link = dm6467_evm_dai,
    	.num_links = ARRAY_SIZE(dm6467_evm_dai),
    	.drvdata = &dm6467_snd_soc_card_drvdata,
    };
    
    static struct snd_soc_card_drvdata_davinci da830_snd_soc_card_drvdata = {
    	.sysclk = 24576000,
    };
    
    static struct snd_soc_card da830_snd_soc_card = {
    	.name = "DA830/OMAP-L137 EVM",
    	.owner = THIS_MODULE,
    	.dai_link = &da830_evm_dai,
    	.num_links = 1,
    	.drvdata = &da830_snd_soc_card_drvdata,
    };
    
    static struct snd_soc_card_drvdata_davinci da850_snd_soc_card_drvdata = {
    	.sysclk = 24576000,
    };
    
    static struct snd_soc_card da850_snd_soc_card = {
    	.name = "DA850/OMAP-L138 EVM",
    	.owner = THIS_MODULE,
    	.dai_link = &da850_evm_dai,
    	.num_links = 1,
    	.drvdata = &da850_snd_soc_card_drvdata,
    };
    
    #if defined(CONFIG_OF)
    
    /*
     * The structs are used as place holders. They will be completely
     * filled with data from dt node.
     */
    static struct snd_soc_dai_link evm_dai_tlv320aic3x = {
    	.name		= "TLV320AIC3X",
    	.stream_name	= "AIC3X",
    	.codec_dai_name	= "tlv320aic31xx-hifi",
    	//.codec_dai_name	= "tlv320aic3x-hifi",
    	.ops            = &evm_ops,
    	.init           = evm_aic3x_init,
    	.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBS_CFS |
    		   SND_SOC_DAIFMT_IB_NF,
    };
    
    static struct snd_soc_dai_link evm_dai_tda998x_hdmi = {
    	.name		= "NXP TDA998x HDMI Chip",
    	.stream_name	= "HDMI",
    	.codec_dai_name	= "hdmi-hifi",
    	.ops		= &evm_tda998x_ops,
    	.init           = evm_tda998x_init,
    	.dai_fmt	= (SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_I2S |
    			   SND_SOC_DAIFMT_IB_NF),
    };
    
    static struct snd_soc_dai_link dra7xx_evm_link = {
    	.name		= "TLV320AIC3X",
    	.stream_name	= "AIC3X",
    	.codec_dai_name	= "tlv320aic3x-hifi",
    	.ops            = &dra7xx_ops,
    	.init           = evm_aic3x_init,
    	.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBS_CFS |
    		   SND_SOC_DAIFMT_IB_NF,
    };
    
    static const struct of_device_id davinci_evm_dt_ids[] = {
    	{
    		.compatible = "ti,da830-evm-audio",
    		.data = &evm_dai_tlv320aic3x,
    	},
    	{
    		.compatible = "ti,beaglebone-black-audio",
    		.data = &evm_dai_tda998x_hdmi,
    	},
    	{
    		.compatible = "ti,dra7xx-evm-audio",
    		.data = (void *) &dra7xx_evm_link,
    	},
    	{ /* sentinel */ }
    };
    MODULE_DEVICE_TABLE(of, davinci_evm_dt_ids);
    
    /* davinci evm audio machine driver */
    static struct snd_soc_card evm_soc_card = {
    	.owner = THIS_MODULE,
    	.num_links = 1,
    };
    
    static int davinci_evm_probe(struct platform_device *pdev)
    {
    	struct device_node *np = pdev->dev.of_node;
    	const struct of_device_id *match =
    		of_match_device(of_match_ptr(davinci_evm_dt_ids), &pdev->dev);
    	struct snd_soc_dai_link *dai = (struct snd_soc_dai_link *) match->data;
    	struct snd_soc_card_drvdata_davinci *drvdata = NULL;
    	struct clk *mclk;
    	int ret = 0;
    
    	evm_soc_card.dai_link = dai;
    
    	dai->codec_of_node = of_parse_phandle(np, "ti,audio-codec", 0);
    	if (!dai->codec_of_node)
    		return -EINVAL;
    
    	dai->cpu_of_node = of_parse_phandle(np, "ti,mcasp-controller", 0);
    	if (!dai->cpu_of_node)
    		return -EINVAL;
    
    	/* Only set the platform_of_node if the platform_name is not set */
    	if (!dai->platform_name)
    		dai->platform_of_node = dai->cpu_of_node;
    
    	evm_soc_card.dev = &pdev->dev;
    	ret = snd_soc_of_parse_card_name(&evm_soc_card, "ti,model");
    	if (ret)
    		return ret;
    
    	mclk = devm_clk_get(&pdev->dev, "mclk");
    	if (PTR_ERR(mclk) == -EPROBE_DEFER) {
    		return -EPROBE_DEFER;
    	} else if (IS_ERR(mclk)) {
    		dev_dbg(&pdev->dev, "mclk not found.\n");
    		mclk = NULL;
    	}
    
    	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
    	if (!drvdata)
    		return -ENOMEM;
    
    	drvdata->mclk = mclk;
    
    	ret = of_property_read_u32(np, "ti,codec-clock-rate", &drvdata->sysclk);
    
    	if (ret < 0) {
    		if (!drvdata->mclk) {
    			dev_err(&pdev->dev,
    				"No clock or clock rate defined.\n");
    			return -EINVAL;
    		}
    		drvdata->sysclk = clk_get_rate(drvdata->mclk);
    	} else if (drvdata->mclk) {
    		unsigned int requestd_rate = drvdata->sysclk;
    		clk_set_rate(drvdata->mclk, drvdata->sysclk);
    		drvdata->sysclk = clk_get_rate(drvdata->mclk);
    		if (drvdata->sysclk != requestd_rate)
    			dev_warn(&pdev->dev,
    				 "Could not get requested rate %u using %u.\n",
    				 requestd_rate, drvdata->sysclk);
    	}
    
    	snd_soc_card_set_drvdata(&evm_soc_card, drvdata);
    	ret = devm_snd_soc_register_card(&pdev->dev, &evm_soc_card);
    
    	if (ret)
    		dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
    
    	return ret;
    }
    
    static int davinci_evm_remove(struct platform_device *pdev)
    {
    	struct snd_soc_card *card = platform_get_drvdata(pdev);
    
    	snd_soc_unregister_card(card);
    
    	return 0;
    }
    
    static struct platform_driver davinci_evm_driver = {
    	.probe		= davinci_evm_probe,
    	.remove		= davinci_evm_remove,
    	.driver		= {
    		.name	= "davinci_evm",
    		.owner	= THIS_MODULE,
    		.pm	= &snd_soc_pm_ops,
    		.of_match_table = of_match_ptr(davinci_evm_dt_ids),
    	},
    };
    #endif
    
    static struct platform_device *evm_snd_device;
    
    static int __init evm_init(void)
    {
    	struct snd_soc_card *evm_snd_dev_data;
    	int index;
    	int ret;
    
    	/*
    	 * If dtb is there, the devices will be created dynamically.
    	 * Only register platfrom driver structure.
    	 */
    #if defined(CONFIG_OF)
    	if (of_have_populated_dt())
    		return platform_driver_register(&davinci_evm_driver);
    #endif
    
    	if (machine_is_davinci_evm()) {
    		evm_snd_dev_data = &dm6446_snd_soc_card_evm;
    		index = 0;
    	} else if (machine_is_davinci_dm355_evm()) {
    		evm_snd_dev_data = &dm355_snd_soc_card_evm;
    		index = 1;
    	} else if (machine_is_davinci_dm365_evm()) {
    		evm_snd_dev_data = &dm365_snd_soc_card_evm;
    		index = 0;
    	} else if (machine_is_davinci_dm6467_evm()) {
    		evm_snd_dev_data = &dm6467_snd_soc_card_evm;
    		index = 0;
    	} else if (machine_is_davinci_da830_evm()) {
    		evm_snd_dev_data = &da830_snd_soc_card;
    		index = 1;
    	} else if (machine_is_davinci_da850_evm()) {
    		evm_snd_dev_data = &da850_snd_soc_card;
    		index = 0;
    	} else
    		return -EINVAL;
    
    	evm_snd_device = platform_device_alloc("soc-audio", index);
    	if (!evm_snd_device)
    		return -ENOMEM;
    
    	platform_set_drvdata(evm_snd_device, evm_snd_dev_data);
    	ret = platform_device_add(evm_snd_device);
    	if (ret)
    		platform_device_put(evm_snd_device);
    
    	return ret;
    }
    
    static void __exit evm_exit(void)
    {
    #if defined(CONFIG_OF)
    	if (of_have_populated_dt()) {
    		platform_driver_unregister(&davinci_evm_driver);
    		return;
    	}
    #endif
    
    	platform_device_unregister(evm_snd_device);
    }
    
    module_init(evm_init);
    module_exit(evm_exit);
    
    MODULE_AUTHOR("Vladimir Barinov");
    MODULE_DESCRIPTION("TI DAVINCI EVM ASoC driver");
    MODULE_LICENSE("GPL");
    

    Hi,

    I am uploaded davinci-evm.c & am335x-edge-dts.txt file with my configuration.

    Thanks

    Tejas