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.

AM625: Running MCASP as master with external AUDIO_EXT_REFCLK

Part Number: AM625

About two months ago, I successfully played 4-channel audio using McASP on the BeagleBone Black (AM335x). However, since the BeagleBone is an older platform, I am now trying to implement the same functionality on the PocketBeagle2 (AM6254) for a more modern and lower-cost system.

One thing I noticed is that, unlike the BeagleBone Black, the PocketBeagle2 does not appear to have an onboard audio X-TAL (24.576MHz), so it seems that the audio clock must be generated differently.

I was able to get audio playback working, but the playback speed is completely incorrect — the audio finishes within about 1 second, which makes me suspect that McASP is running from an incorrect AUX clock source or an unintended clock configuration. (when I explicitly set the clock inside simple-audio-card,cpu, so I kept only sound-dai=<&mcasp0>;)

This thread was extremely helpful:
https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1487650/am625-running-mcasp-as-master-with-external-audio_ext_refclk-of-24-576mhz

https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/am62x/clocks.html#clocks-for-mcasp0-device

However, even after checking the clock summary and trying several debugging approaches, it still seems like my clock configuration is not being applied correctly.

I would appreciate any advice on the proper way to configure the McASP audio clocks on AM6254 when running McASP as master.

Results:
locofield@loco-adp:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: locofieldmcasp [locofield-mcasp], device 0: davinci-mcasp.0-a2b24xx-hifi a2b24xx.2-0068-0 [davinci-mcasp.0-a2b24xx-hifi a2b24xx.2-0068-0]
locofield@loco-adp:~$ speaker-test -c4 -r48000 -FS32_LE

speaker-test 1.2.14

Playback device is default
Stream parameters are 48000Hz, S32_LE, 4 channels
Using 16 octaves of pink noise
ALSA lib pcm_params.c:2235:(snd1_pcm_hw_refine_slave) Slave PCM not usable
Broken configuration for playback: no configurations available: Invalid argument
Setting of hwparams failed: Invalid argument
#include "k3-am6232-pocketbeagle2.dts"

/ {
	compatible = "beagle,am62-pocketbeagle2", "ti,am625";
	model = "BeagleBoard.org PocketBeagle2";

	sound {
		compatible = "simple-audio-card";
		simple-audio-card,name = "locofield-mcasp";
		simple-audio-card,format = "i2s";

		simple-audio-card,bitclock-master = <&dailink0_master>;
		simple-audio-card,frame-master = <&dailink0_master>;

		dailink0_master: simple-audio-card,cpu {
			sound-dai = <&mcasp0>;
		};

		simple-audio-card,codec {
			sound-dai = <&a2b24xx>;
		};
	};
};

...

&main_pmx0 {
	mcasp0_pins: mcasp0-default-pins {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x1a0, PIN_INPUT, 2)  // P1.02 AUDIO EXT REFCLK0
			AM62X_IOPAD(0x1a4, PIN_OUTPUT, 0) // ACLKX
			AM62X_IOPAD(0x1a8, PIN_OUTPUT, 0) // AFSX
			AM62X_IOPAD(0x194, PIN_OUTPUT, 0) // AXR3
			AM62X_IOPAD(0x198, PIN_OUTPUT, 0) // AXR2
		>;
	};

...

&mcasp0 {
	status = "okay";
	#sound-dai-cells = <0>;

	pinctrl-names = "default";
	pinctrl-0 = <&mcasp0_pins>;

	op-mode = <0>;
	tdm-slots = <2>;
	slot-width = <32>;

	num-serializer = <4>;
	serial-dir = <0 0 1 1>;

	clocks = <&k3_clks 190 0>, <&k3_clks 190 15>;
	clock-names = "fck", "ahclkx";

	assigned-clocks = <&k3_clks 190 0>, <&k3_clks 190 15>;
	assigned-clock-parents = <&k3_clks 190 2>, <&k3_clks 190 18>;
	assigned-clock-rates = <0>, <6144000>;
};
locofield@loco-adp:~$ sudo k3conf dump clock2 190
|------------------------------------------------------------------------------------------------|
| VERSION INFO                                                                                   |
|------------------------------------------------------------------------------------------------|
| K3CONF           | (version 0.4-nogit built Thu Dec 04 20:24:55 UTC 2025)                      |
| SoC              | AM62X SR1.0                                                                 |
| SoC identifiers  | [0x3a247529] 0x1d123 Func-Safe Secure 'T' Grade -40 C to 125 C ALW Package  |
| SYSFW            | ABI: 4.0 (firmware version 0x000b '11.2.5--v11.02.05 (Fancy Rat))')         |
| DM ABI Info      | 3.0                                                                         |
| DM F/w rev       | 11.2.5                                                                      |
| DM Component rev | RM/PM HAL:'v11.02.05' SCI_SERV:'MSDK.11.02.00.11'                           |
| F/w Capabilities | 0x7b7: GEN DEEP_SLP MCU_ONLY PART_IO DM_MGD_LPM IO_ISO DM-SPLT              |
|------------------------------------------------------------------------------------------------|

|-----------------------------------------------------------------------------------------------------------------------------|
| Device ID | Clock ID | Clock Name                                                       | Status          | Clock Frequency |
|-----------------------------------------------------------------------------------------------------------------------------|
|   190     |     0    | DEV_MCASP0_AUX_CLK                                               | CLK_STATE_READY | 96000000        |
|   190     |     1    | DEV_MCASP0_AUX_CLK_PARENT_POSTDIV4_16FF_MAIN_2_HSDIVOUT8_CLK     | CLK_STATE_READY | 100000000       |
|   190     |     2    | DEV_MCASP0_AUX_CLK_PARENT_POSTDIV1_16FFT_MAIN_1_HSDIVOUT6_CLK    | CLK_STATE_READY | 96000000        |
|   190     |     3    | DEV_MCASP0_MCASP_ACLKR_PIN                                       | CLK_STATE_READY | 0               |
|   190     |     4    | DEV_MCASP0_MCASP_ACLKR_POUT                                      | CLK_STATE_READY | 0               |
|   190     |     5    | DEV_MCASP0_MCASP_ACLKX_PIN                                       | CLK_STATE_READY | 0               |
|   190     |     6    | DEV_MCASP0_MCASP_ACLKX_POUT                                      | CLK_STATE_READY | 0               |
|   190     |     7    | DEV_MCASP0_MCASP_AFSR_POUT                                       | CLK_STATE_READY | 0               |
|   190     |     8    | DEV_MCASP0_MCASP_AFSX_POUT                                       | CLK_STATE_READY | 0               |
|   190     |     9    | DEV_MCASP0_MCASP_AHCLKR_PIN                                      | CLK_STATE_READY | 0               |
|   190     |    10    | DEV_MCASP0_MCASP_AHCLKR_PIN_PARENT_BOARD_0_EXT_REFCLK1_OUT       | CLK_STATE_READY | 0               |
|   190     |    11    | DEV_MCASP0_MCASP_AHCLKR_PIN_PARENT_GLUELOGIC_HFOSC0_CLKOUT       | CLK_STATE_READY | 25000000        |
|   190     |    12    | DEV_MCASP0_MCASP_AHCLKR_PIN_PARENT_BOARD_0_AUDIO_EXT_REFCLK0_OUT | CLK_STATE_READY | 0               |
|   190     |    13    | DEV_MCASP0_MCASP_AHCLKR_PIN_PARENT_BOARD_0_AUDIO_EXT_REFCLK1_OUT | CLK_STATE_READY | 0               |
|   190     |    14    | DEV_MCASP0_MCASP_AHCLKR_POUT                                     | CLK_STATE_READY | 0               |
|   190     |    15    | DEV_MCASP0_MCASP_AHCLKX_PIN                                      | CLK_STATE_READY | 0               |
|   190     |    16    | DEV_MCASP0_MCASP_AHCLKX_PIN_PARENT_BOARD_0_EXT_REFCLK1_OUT       | CLK_STATE_READY | 0               |
|   190     |    17    | DEV_MCASP0_MCASP_AHCLKX_PIN_PARENT_GLUELOGIC_HFOSC0_CLKOUT       | CLK_STATE_READY | 25000000        |
|   190     |    18    | DEV_MCASP0_MCASP_AHCLKX_PIN_PARENT_BOARD_0_AUDIO_EXT_REFCLK0_OUT | CLK_STATE_READY | 0               |
|   190     |    19    | DEV_MCASP0_MCASP_AHCLKX_PIN_PARENT_BOARD_0_AUDIO_EXT_REFCLK1_OUT | CLK_STATE_READY | 0               |
|   190     |    20    | DEV_MCASP0_MCASP_AHCLKX_POUT                                     | CLK_STATE_READY | 0               |
|   190     |    21    | DEV_MCASP0_VBUSP_CLK                                             | CLK_STATE_READY | 250000000       |
|-----------------------------------------------------------------------------------------------------------------------------|

locofield@loco-adp:~$ cat /sys/kernel/debug/pinctrl/*/pinmux-pins | grep "mcasp"
pin 101 (PIN101): 2b00000.audio-controller (GPIO UNCLAIMED) function mcasp0-default-pins group mcasp0-default-pins
pin 102 (PIN102): 2b00000.audio-controller (GPIO UNCLAIMED) function mcasp0-default-pins group mcasp0-default-pins
pin 104 (PIN104): 2b00000.audio-controller (GPIO UNCLAIMED) function mcasp0-default-pins group mcasp0-default-pins
pin 105 (PIN105): 2b00000.audio-controller (GPIO UNCLAIMED) function mcasp0-default-pins group mcasp0-default-pins
pin 106 (PIN106): 2b00000.audio-controller (GPIO UNCLAIMED) function mcasp0-default-pins group mcasp0-default-pins
  • Hi Ko,
    Not sure if you have looked at this AppNote: https://www.ti.com/lit/an/sdaa199/sdaa199.pdf 
    There are some software examples towards the end, let me know if they help.

  • I think it would have been helpful if there had been a more complete DTS example.
    In my case, I need to use an external clock as MCLK and then divide it down to generate BCLK.
    For now, based on the example, I think separating the clock configuration from mcasp0.

    Here is my updated example:

    &main_pmx0 {
    	mcasp0_pins: mcasp0-default-pins {
    		pinctrl-single,pins = <
    			AM62X_IOPAD(0x1a4, PIN_OUTPUT, 0)
    			AM62X_IOPAD(0x1a8, PIN_OUTPUT, 0)
    			AM62X_IOPAD(0x194, PIN_OUTPUT, 0)
    			AM62X_IOPAD(0x198, PIN_OUTPUT, 0)
    		>;
    	};
    
    	ext_refclk0_pins: ext-refclk0-default-pins {
    		pinctrl-single,pins = <
    			AM62X_IOPAD(0x1a0, PIN_INPUT, 2)
    		>;
    	};
    	
    	...
    
    &mcasp0 {
    	status = "okay";
    	#sound-dai-cells = <0>;
    
    	pinctrl-names = "default";
    	pinctrl-0 = <&mcasp0_pins>;
    
    	op-mode = <0>;
    	tdm-slots = <2>;
    	slot-width = <32>;
    
    	num-serializer = <4>;
    	serial-dir = <0 0 1 1>;
    
    	assigned-clocks = <&k3_clks 190 9>, <&k3_clks 190 15>;
    	assigned-clock-parents = <&k3_clks 190 12>, <&k3_clks 190 18>;
    	assigned-clock-rates = <6144000>, <6144000>;
    };
    
    &audio_refclk0 {
        pinctrl-names = "default";
        pinctrl-0 = <&ext_refclk0_pins>;
    
        assigned-clocks = <&k3_clks 157 9>;
        assigned-clock-parents = <>;
    };

  • Hi Ko,

    With AUXCLK did you add system-clock-direction-out; in the device tree where you are making MCASP as the dailink master.

    Also, if you are planning to supply cloc externally on Audio External Refclk can you share the changes in order to route that clock ( 6.144MHz) as AHCLKX on MCASP?

    Best Regards,

    Suren 

  • Hi Suren!!

    The speaker-test error was resolved after adding the mclk-fs property.

    However, it still does not seem to be running from the clock that I provide to audio_ext_clk0.
    Instead, based on the clock summary, it looks like McASP is still deriving the clock from the 100 MHz source (clk:157:8) and dividing it down from there.

    If my understanding is correct, when I disconnect the external clock supplied to refclk0, BCLK should no longer be generated.
    However, BCLK is still being generated even after disconnecting the external clock, so I suspect that McASP is not actually using refclk0 as its clock source.

    My system design should be below: (desired)

    6.144MHz ---> Audio External Refclk0 (E18)
    AHCLKX (internal) = 6.144MHz
    ACLKX (B20) = 3.072 MHz (32 bits * 2 Ch * 48000Hz)
    AFSX
    AXR2 and AXR3 as output (two serializers with 50% duty cycle)

    Could you please let me know what is wrong with the device tree below?

    / {
    	compatible = "beagle,am62-pocketbeagle2", "ti,am625";
    	model = "BeagleBoard.org PocketBeagle2";
    
    	sound {
    		compatible = "simple-audio-card";
    		simple-audio-card,name = "locofield-mcasp";
    		simple-audio-card,format = "i2s";
    
    		simple-audio-card,mclk-fs = <128>;
    
    		simple-audio-card,bitclock-master = <&dailink0_master>;
    		simple-audio-card,frame-master = <&dailink0_master>;
    
    		dailink0_master: simple-audio-card,cpu {
    			sound-dai = <&mcasp0>;
    		};
    
    		simple-audio-card,codec {
    			sound-dai = <&a2b24xx>;
    		};
    	};
    };
    
    &main_pmx0 {
    	mcasp0_pins: mcasp0-default-pins {
    		pinctrl-single,pins = <
    			AM62X_IOPAD(0x1a4, PIN_OUTPUT, 0)
    			AM62X_IOPAD(0x1a8, PIN_OUTPUT, 0)
    			AM62X_IOPAD(0x194, PIN_OUTPUT, 0)
    			AM62X_IOPAD(0x198, PIN_OUTPUT, 0)
    		>;
    	};
    
    	ext_refclk0_pins: ext-refclk0-default-pins {
    		pinctrl-single,pins = <
    			AM62X_IOPAD(0x1a0, PIN_INPUT, 2)
    		>;
    	};

    &mcasp0 {
    	status = "okay";
    	#sound-dai-cells = <0>;
    
    	pinctrl-names = "default";
    	pinctrl-0 = <&mcasp0_pins>;
    
    	op-mode = <0>;
    	tdm-slots = <2>;
    	slot-width = <32>;
    
    	num-serializer = <4>;
    	serial-dir = <0 0 1 1>;
    
    	clocks = <&k3_clks 190 9>;
    
    	assigned-clocks = <&k3_clks 190 9>, <&k3_clks 190 15>;
    	assigned-clock-parents = <&k3_clks 190 12>, <&k3_clks 190 18>;
    	assigned-clock-rates = <6144000>, <6144000>;
    };
    
    &audio_refclk0 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&ext_refclk0_pins>;
    
    	clocks = <&k3_clks 157 0>;
    
    	assigned-clocks = <&k3_clks 157 0>;
    	/delete-property/ assigned-clock-parents; // << not worked!!
    	assigned-clock-rates = <6144000>;
    };

    Right now, the generated BCLK frequency is exactly 7874015 / 2

    locofield@loco-adp:~$ sudo cat /sys/kernel/debug/clk/clk_summary | grep clk:157
     clk:157:18                          0       0        0        100000000   0          0     50000      Y   deviceless                      no_connection_id 
        clk:157:10                       0       0        0        100000000   0          0     50000      Y      deviceless                      no_connection_id
           audio_refclk:clk:157:10       0       0        0        100000000   0          0     50000      N         deviceless                      no_connection_id
     clk:157:8                           0       0        0        100000000   0          0     50000      Y   deviceless                      no_connection_id 
        clk:157:0                        0       0        0        7874015     0          0     50000      Y      deviceless                      no_connection_id
           audio_refclk:clk:157:0        0       0        0        7874015     0          0     50000      N         deviceless                      no_connection_id

  • Hi Ko,

    Can you take a look at the below thread where I helped customer to use Audio_external_refclk for playback functionality.

     AM62P: MCASP data only streams on AXR0 

    Have you modified the audio_refclk0 node in the device tree?

    Best regards

    Suren

  • Thank you, Suren.

    I still do not understand why the McASP clock keeps being derived from clk:157:8.

    locofield@loco-adp:~$ sudo cat /sys/kernel/debug/clk/clk_summary | grep clk:157
     clk:157:9                           0       0        0        0           0          0     50000      Y   deviceless                      no_connection_id 
     clk:157:8                           0       0        0        100000000   0          0     50000      Y   deviceless                      no_connection_id 
        clk:157:0                        0       0        0        7874015     0          0     50000      Y      deviceless                      no_connection_id
           audio_refclk:clk:157:0        0       0        0        7874015     0          0     50000      N         simple-audio-card,codec         no_connection_id

    &main_pmx0 {
    	mcasp0_pins: mcasp0-default-pins {
    		pinctrl-single,pins = <
    			AM62X_IOPAD(0x1a4, PIN_OUTPUT, 0)
    			AM62X_IOPAD(0x1a8, PIN_OUTPUT, 0)
    			AM62X_IOPAD(0x194, PIN_OUTPUT, 0)
    			AM62X_IOPAD(0x198, PIN_OUTPUT, 0)
    		>;
    	};
    
    	ext_refclk0_pins: ext-refclk0-default-pins {
    		pinctrl-single,pins = <
    			AM62X_IOPAD(0x1a0, PIN_INPUT, 2) // AUDIO EXT REFCLK0
    		>;
    	};
    	
    	...
    	
    &mcasp0 {
    	status = "okay";
    	#sound-dai-cells = <0>;
    
    	pinctrl-names = "default";
    	pinctrl-0 = <&mcasp0_pins>;
    
    	op-mode = <0>;
    	tdm-slots = <2>;
    	slot-width = <32>;
    
    	num-serializer = <4>;
    	serial-dir = <0 0 1 1>;
    
    	clocks = <&k3_clks 190 15>;
    
    	assigned-clocks = <&k3_clks 190 15>;
    	assigned-clock-parents = <&k3_clks 190 18>;
    	assigned-clock-rates = <6144000>;
    };
    
    &audio_refclk0 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&ext_refclk0_pins>;
    
    	clocks = <&k3_clks 157 0>;
    
    	assigned-clocks = <&k3_clks 157 0>;
    	assigned-clock-parents = <&k3_clks 157 9>;
    	assigned-clock-rates = <6144000>;
    };
    
    &audio_refclk1 {
    	status = "disabled";
    };

  • Hi Ko,
    Suren is currently out till tomorrow, please expect a delayed response.

  • Dear Suren and Divyansh,

    I ended up giving up on using audio_ext_refclk as the MCLK (AHCLKX) source.

    Instead, I directly supplied the clock to ACLKX, and configured McASP to output AFSX, AXR2, and AXR3.
    That configuration works correctly now.

    Thank you very much for your help!