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.

Linux/AM5718: Audio codec clock settings

Part Number: AM5718
Other Parts Discussed in Thread: TLV320AIC3104, BEAGLEBOARD-X15

Tool/software: Linux

Hi,

We have a custom board based on am5718. The board design is based on am571x-idk with some additions from am572x-evm, for instance the Audio codec. Now I cannot get the sound card to work. I suspect that the clock setup for the sound card is incorrect because depending on setting the board does not boot properly. What should the correct clock settings be? Or are there any other obvious errors?

The differences from the am572x-evm design is that we use I2C_Bus3 instead of bus1 and we use MCASP1 with the following connections:

TLV320AIC3104 <--> am5718
MCLK          <--> MCASP1_AHCLKX (XREF_CLK0)                 
WCLK          <--> MCASP1_FSX    
BCLK          <--> MCASP1_ACLKX
DIN              <--> MCASP1_AXR6     
DOUT          <--> MCASP1_AXR7


The device tree setting regarding the sound card is as follows:
     

sound0: sound0 {
        compatible = "simple-audio-card";
        simple-audio-card,name = "BeagleBoard-X15";
        simple-audio-card,widgets =
            "Headphone", "Headphone Jack",        
            "Line", "Line Out",
            "Line", "Line In";
        simple-audio-card,routing =
            "Headphone Jack", "HPLOUT",
            "Headphone Jack", "HPROUT",
            "Line Out",    "LLOUT",
            "Line Out",    "RLOUT",
            "MIC2L",    "Line In",
            "MIC2R",    "Line In";
        simple-audio-card,format = "dsp_b";
        simple-audio-card,bitclock-master = <&sound0_master>;
        simple-audio-card,frame-master = <&sound0_master>;
        simple-audio-card,bitclock-inversion;

        simple-audio-card,cpu {
            sound-dai = <&mcasp1>;
        };

        sound0_master: simple-audio-card,codec {
            sound-dai = <&tlv320aic3104>;
            clocks = <&clkout2_clk>;
        };
    };

&mcasp1 {
    #sound-dai-cells = <0>;
    assigned-clocks = <&mcasp1_ahclkx_mux>;
    assigned-clock-parents = <&sys_clkin2>;
    status = "okay";

    op-mode = <0>;    /* MCASP_IIS_MODE */
    tdm-slots = <2>;
    /* 16 serializers */
    serial-dir = <    /* 0: INACTIVE, 1: TX, 2: RX */
        0 0 0 0
        0 0 1 2
        0 0 0 0
        0 0 0 0 >;

    tx-num-evt = <32>;
    rx-num-evt = <32>;
};

&i2c3 {
    status = "okay";
    clock-frequency = <400000>;
        
    tlv320aic3104: tlv320aic3104@18 {
        #sound-dai-cells = <0>;
        compatible = "ti,tlv320aic3104";
        reg = <0x18>;
        assigned-clocks = <&mcasp1_ahclkx_mux>;

        status = "okay";
        adc-settle-ms = <40>;

        AVDD-supply = <&v3_3d>;
        IOVDD-supply = <&v3_3d>;
        DRVDD-supply = <&v3_3d>;
        DVDD-supply = <&aic_dvdd>;
    };
};

  • Hi Fred,

    I will have a deeper look over your settings and come back to you.

    Meanwhile please check the below documents careful. These also be useful for your future work regarding Audio.

    www.ti.com/.../sprac09a.pdf
    www.ti.com/.../sprac10.pdf

    processors.wiki.ti.com/.../Sitara_Linux_Audio_Porting_Guide
    processors.wiki.ti.com/.../Processor_SDK_Linux_Audio

    Regards,
    Pavel

  • FredrikN said:
    TLV320AIC3104 <--> am5718
    MCLK          <--> MCASP1_AHCLKX (XREF_CLK0)                 
    WCLK          <--> MCASP1_FSX    
    BCLK          <--> MCASP1_ACLKX

    FredrikN said:
        simple-audio-card,bitclock-master = <&sound0_master>;
            simple-audio-card,frame-master = <&sound0_master>;

    FredrikN said:
     sound0_master: simple-audio-card,codec {
                sound-dai = <&tlv320aic3104>;
                clocks = <&clkout2_clk>;
            };

    This configuration is for AM572x McASP1 module to be slave and AIC3104 codec to be master of the bit clock and frame sync signals. Please confirm that you are planning to use that mode (audio codec to be the master).

    Regarding pin D18, do you use it in mcasp1_ahclkx mode (mode 3) or clkout2 mode (mode 9)?

    Regards,
    Pavel

  • Yes, we are planning to use that mode with audio codec to be the master.

    Pin D18 it is set to msasp1_ahclkx mode (mode 3).

    Regards

    Fredrik

  • Fredrik,

    Have you made the necessary McASP1 and I2C3 pinmux in u-boot spl stage? Refer to the below e2e post for details why pinmux is done in u-boot spl stage:

    e2e.ti.com/.../2415822

    Please provide me:

    1. Full console boot up log (u-boot + kernel + rootfs)
    2. Values of the McASP1/I2C3 pinmux registers. Get these values from user space with devmem2 or omapconf tool.

    Regards,
    Pavel
  • I think I have made the necessary settings in u-boot.

    There are 3 files attached. The first is the boot log with settings as above. Then the boot fails.

    The second is from a boot when the lines

    assigned-clocks = <&mcasp1_ahclkx_mux>;
    assigned-clock-parents = <&sys_clkin2>;

    are removed from the mcasp1 section in the linux dtb. Then the boot is completed.

    The third file contains the read out register setting (from the second boot).

    boot_fail.cap.tar.gz

    boot_no_clock_set.cap.tar.gz

    register_settings.txt.tar.gz

    Regards

    Fredrik

  • FredrikN said:
    Pin D18 it is set to msasp1_ahclkx mode (mode 3).

    Then you should modify the below code in DTS:

    sound0_master: simple-audio-card,codec {
                sound-dai = <&tlv320aic3104>;
                -  clocks = <&clkout2_clk>;
                + clocks = <&mcasp1_ahclkx_mux>;
            };

    Please refer to the below e2e thread, where they use mcasp3_ahclkx (instead mcasp1_ahclkx) to supply AIC3x codec MCLK. You should apply the same settings for McASP1, as they applied for McASP3.

    Regards,
    Pavel

  • I have made changes accordingly, but without success. I have also changed the DTS setup to be identical with am57xx-evm, but used mcasp1 instead of mcasp3, and changed pin D18 to mode M9 (clkout2) but with the same result. The boot crashes, probably when the mcasp driver is initialized.

    The first lines that differ from a successful boot, when there are no clocks specified for mcasp in the DTS, are
    [ 2.464364] omap_hwmod: mcasp1: _wait_target_ready failed: -16
    [ 2.470228] davinci-mcasp 48460000.mcasp: use pm_runtime_put_sync_suspend() in driver?
    [ 2.490958] ------------[ cut here ]------------
    [ 2.495599] WARNING: CPU: 0 PID: 1 at drivers/bus/omap_l3_noc.c:147 l3_interrupt_handler+0x25c/0x36c
    [ 2.504766] 44000000.ocp:L3 Custom Error: MASTER MPU TARGET L4_PER2_P3 (Read): Data Access in User mode during Functional access

    What might cause this?

    I have search for other errors and on the forum I found a thread where it was stated that errors like
    - /cpus/cpu@0 missing clock-frequency property
    - omap_hwmod: l3_main_2 using broken dt data from ocp
    - irq: no irq domain found for /ocp/l4@4a000000/scm@2000/pinmux@1400 !
    indicates that the DTS does not match the hardware setup. I have run the pre-built sd-card from psdk 04.02.00.09 on am571x-idk and am572x-idk and the same errors are present on those boards. Are these errors not relevant or are there errors in the reference designs?

    Regards,
    Fredrik
  • Fredrik,

    FredrikN said:
    The boot crashes, probably when the mcasp driver is initialized.

    The first lines that differ from a successful boot, when there are no clocks specified for mcasp in the DTS, are
    [ 2.464364] omap_hwmod: mcasp1: _wait_target_ready failed: -16
    [ 2.470228] davinci-mcasp 48460000.mcasp: use pm_runtime_put_sync_suspend() in driver?
    [ 2.490958] ------------[ cut here ]------------
    [ 2.495599] WARNING: CPU: 0 PID: 1 at drivers/bus/omap_l3_noc.c:147 l3_interrupt_handler+0x25c/0x36c
    [ 2.504766] 44000000.ocp:L3 Custom Error: MASTER MPU TARGET L4_PER2_P3 (Read): Data Access in User mode during Functional access

    What might cause this?

    I will check this and come back to you.

    FredrikN said:
    I have run the pre-built sd-card from psdk 04.02.00.09 on am571x-idk and am572x-idk and the same errors are present on those boards. Are these errors not relevant or are there errors in the reference designs?

    I do not have IDK board (am572x and am571x) to test, I have only AM572x EVM. But I see that IDK board do NOT use McASP/audio/codec at all. Are you sure you have mcasp related kernel errors on IDK boards during boot up the pre-built binaries? Can you share the console output of the boot log?

    Regards,
    Pavel

  • Hi,

    No, there are no mcasp related kernel errors on the IDK boards. I referred to the other errors I listed (/cpus/cpu@0 missing clock-frequency property ... ) which might indicate that there is something wrong with the DTS (?). Attached is the console output from am571x idk.

    boot_log_am571x-idk.cap.gz

    Regards,

    Fredrik

  • Fredrik,

    Make sure that you are using the correct DTB file for your AM571x EVM board:

    1. am571x-idk.dtb - when no LCD board used, no PRU ICSS ethernet board is used
    2. am571x-idk-lcd-osd101t2045.dtb - when LCD osd101t2045 board is used
    3. am571x-idk-lcd-osd101t2587.dtb - when LCD osd101t2587 board is used
    4. am571x-idk-pru-excl-uoi.dtb - when PRU ICSS ethernet board is used, no LCD used

    The dtb files are located in rootfs/boot/ folder.

    The DTB file selection is made with fdtfile in uENV.txt, check the below wikis for more info:

    processors.wiki.ti.com/.../How_to_Change_dtb_File

    processors.wiki.ti.com/.../Processor_SDK_Linux_Automotive_Software_Developers_Guide

    Regards,
    Pavel
  • FredrikN said:
    I have search for other errors and on the forum I found a thread where it was stated that errors like
    - /cpus/cpu@0 missing clock-frequency property
    - omap_hwmod: l3_main_2 using broken dt data from ocp
    - irq: no irq domain found for /ocp/l4@4a000000/scm@2000/pinmux@1400 !
    indicates that the DTS does not match the hardware setup. I have run the pre-built sd-card from psdk 04.02.00.09 on am571x-idk and am572x-idk and the same errors are present on those boards. Are these errors not relevant or are there errors in the reference designs?

    I also check PSDK 4.02 pre-built images on AM572x TI EVM, and I observe the same warnings during kernel boot up. As McASP/audio is fully tested on the AM572x TI EVM, these 3 warnings can be ignored.

    Starting kernel ...
    
    [    0.000000] Booting Linux on physical CPU 0x0
    [    0.000000] Linux version 4.9.59-ga75d8e9305 (gtbldadm@ubuntu-16) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #2 SMP PREEMPT Sat Dec
    23 10:02:24 EST 2017
    .....
    [    0.000000] OF: fdt:Machine model: TI AM5728 EVM
    ....

    [    0.001530] CPU: Testing write buffer coherency: ok
    [    0.001734] /cpus/cpu@0 missing clock-frequency property
    [    0.001749] /cpus/cpu@1 missing clock-frequency property
    .....

    [ 0.204491] omap_hwmod: l3_main_2 using broken dt data from ocp
    [ 0.318475] omap_hwmod: dcan1: _wait_target_disable failed
    ....

    [ 0.494926] irq: no irq domain found for /ocp/l4@4a000000/scm@2000/pinmux@1400 !
    [ 0.522078] No ATAGs?

    .....

    Regards,
    Pavel

  • FredrikN said:
    The first lines that differ from a successful boot, when there are no clocks specified for mcasp in the DTS, are
    [ 2.464364] omap_hwmod: mcasp1: _wait_target_ready failed: -16

    This error comes from within the below kernel file:

    linux-kernel/arch/arm/mach-omap2/omap_hwmod.c

    static int _enable(struct omap_hwmod *oh)

    Please enable the debug outputs pr_debug(), thus you will have more informative messaging output.

    Seems like McASP1 clocks in PRCM are not enabled. Can you provide the values you have in the below registers:

    CM_IPU_CLKSTCTRL

    CM_IPU_MCASP1_CLKCTRL

    Note also that mcasp1_ahclkx_mux clock comes from sys_clkin2, which is 22.5792MHz fixed clock, derived from Auxiliary oscillator (OSC1) (SYS_CLK2), available at AM572x EVM. Please confirm you have similar 22.5792MHz Auxiliary oscillator attached to the AM571x OSC1 pins. Check with scope that you have valid and stable 22.5792MHz signal output from that OSC1.

    Regards,
    Pavel

    Regards,
    Pavel

  • No, we don't have a 22.5792MHz Auxiliary oscillator attached to the AM571x OSC1 pins. Is there any way I can configure it differently to use for instance the 20MHz main clock instead, or do I have to wait until there is a new board revision?

    The registers does not seem to be set up correctly either. The register CM_IPU_CLKSTCTRL (0x4A00 5540) is set to 0x0000 0001 and CM_IPU_MCASP1_CLKCTRL (0x4A00 5550) is set to 0x003 0000. Where should these registers be set? I looked for the corresponding changes for am572x evm, but I could not find where they are set.

    Regards,
    Fredrik
  • FredrikN said:
    No, we don't have a 22.5792MHz Auxiliary oscillator attached to the AM571x OSC1 pins. Is there any way I can configure it differently to use for instance the 20MHz main clock instead, or do I have to wait until there is a new board revision?

    Yes, you can. You should change the below DTS code:

    &mcasp1 {
        #sound-dai-cells = <0>;
        assigned-clocks = <&mcasp1_ahclkx_mux>;
        -assigned-clock-parents = <&sys_clkin2>;
        +assigned-clock-parents = <&abe_24m_fclk>;
        status = "okay";

    You can use abe_24m_fclk, or another clock signal listed in CM_IPU_MCASP1_CLKCTRL[27:24] CLKSEL_AHCLKX. This correspond to the below linix code:

    mcasp1_ahclkx_mux: mcasp1_ahclkx_mux@550 {
            #clock-cells = <0>;
            compatible = "ti,mux-clock";
            clocks = <&abe_24m_fclk>, <&abe_sys_clk_div>, <&func_24m_clk>, <&atl_clkin3_ck>, <&atl_clkin2_ck>, <&atl_clkin1_ck>, <&atl_clkin0_ck>, <&sys_clkin2>, <&ref_clkin0_ck>, <&ref_clkin1_ck>, <&ref_clkin2_ck>, <&ref_clkin3_ck>, <&mlb_clk>, <&mlbp_clk>;
            ti,bit-shift = <24>;
            reg = <0x0550>;
        };

    abe_24m_fclk comes from DPLL_ABE and is 24MHz, abe_sys_clk_div comes from OSC0 and is 20MHz.

    FredrikN said:
    The registers does not seem to be set up correctly either. The register CM_IPU_CLKSTCTRL (0x4A00 5540) is set to 0x0000 0001 and CM_IPU_MCASP1_CLKCTRL (0x4A00 5550) is set to 0x003 0000. Where should these registers be set? I looked for the corresponding changes for am572x evm, but I could not find where they are set.

    McASP3 is enabled (PRCM registers are set up) in the am57xx-beagle-x15-common.dtsi file:

    &mcasp3 {
        #sound-dai-cells = <0>;
        assigned-clocks = <&mcasp3_ahclkx_mux>;
        assigned-clock-parents = <&sys_clkin2>;
        status = "okay";  --> this enables PRCM clocks

    Make sure when you are doing the same for McASP1, you are doing it in the correct DTS file, and then this file is generated to DTB file.

    Regards,
    Pavel

  • With a clock that actually existed everything worked much better. I had to change the clock to the tlv320aic3104 codec as well, but then we could play sound.

    Thanks,
    Fredrik