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.

BEAGL-BONE-BLACK: How to interface multiple I2S devices in arago Linux.

Part Number: BEAGL-BONE-BLACK
Other Parts Discussed in Thread: PCM5102A, PCM5102

Hello All,

I am trying to interface multiple I2S devices on beagle bone black for different audio codecs. I have successfully interfaced one one device using PCM5102A dummy codec driver. Now I want to use multiple I2S interfaced devices at same time. I have tried with doing some changes in ".dtsi" file But It doesn't work. Can anyone Please help me to sort out this issue.

1.There is only one sound card shown while I enters "arecord -l" command. I want multiple sound cards there.

2. The Working .dtsi file for PCM5102A  is as follow. Should I have to made changes in the same file or create seperate .dtsi file for another I2S device?

&am33xx_pinmux {
	mcasp1_pins: mcasp1_pins {
		pinctrl-single,pins = <
 		/* sink must enable receivers */
   		AM33XX_IOPAD(0x9a0, PIN_INPUT_PULLDOWN | 	MUX_MODE3) /* P9_42 mcasp1_aclkx - bit clock */
		AM33XX_IOPAD(0x9a4, PIN_INPUT_PULLDOWN | MUX_MODE3) /* P9_27 mcasp1_fsx - frame sync */
   		0x1a8 0x23 /* P9_41 mcasp1_axr0 - i2s input */
		>;	
	};
	
};
&mcasp1 {
	#sound-dai-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&mcasp1_pins>;
	status = "okay";
	op-mode = <0>; /* MCASP_IIS_MODE */
	tdm-slots = <2>;
	num-serializer = <4>;
	serial-dir = < /* 1 TX 2 RX 0 unused */
		2 1 0 0
	>;
	rx-num-evt = <8>;
	tx-num-evt = <8>;
};

/ {
	pcm5102a: pcm5102a {
		#sound-dai-cells = <0>;
		compatible = "ti,pcm5102a";
		status = "okay";
};

clk_mcasp1_fixed: clk_mcasp1_fixed {
  #clock-cells = <0>;
  compatible = "fixed-clock";
  clock-frequency = <24576000>;
 };

clk_mcasp1: clk_mcasp1 {
  #clock-cells = <0>;
  compatible = "gpio-gate-clock";
  clocks = <&clk_mcasp1_fixed>;
  enable-gpios = <&gpio1 27 0>; /* BeagleBone Black Clk enable on GPIO1_27 */
 };

sound1: sound@1 {
compatible = "simple-audio-card";
simple-audio-card,name = "PCM5102a";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&sound1_master>;
simple-audio-card,frame-master = <&sound1_master>;
simple-audio-card,bitclock-inversion;

sound1_master: simple-audio-card,cpu {
sound-dai = <&mcasp1>;
system-clock-direction = "out";
   system-clock-frequency = <24576000>;
   clocks = <&clk_mcasp1>;
};

simple-audio-card,codec {
#sound-dai-cells = <0>;
sound-dai = <&pcm5102a>;
/*clocks = <&mcasp1_fck>;
clock-names = "mclk";*/
};
};
};

3. I have tried for different I2S pinmux i.e mcasp0. It is also working but only one device is shown at a time.

How to add the second audio card into the sound node in the kernel device tree? any examples?

Any help will be grateful!!!

Thanks,

Shantanu

  • Hello Shantanu,

    Please share your configuration for multiple I2S configuration.

    Regards,
    Krunal

  • Hello,

    For I2S 1, I am using following pinmux:

    P9_42 - clock

    P9_41 - data

    P9_27 - frame sync

    For I2S 2, I am using following pinmux:

    P8_35 - clock

    P8_36 - data

    P8_38 - frame sync

    I want both the devices should works at same time.

    Thanks,

    Shantanu

  • Hello Shantanu,

    Please send your DT file with both configuration enabled and the errors that you are running into. Also, refer to the following document: https://www.ti.com/lit/an/sprac97/sprac97.pdf?ts=1613771096259&ref_url=https%253A%252F%252Fwww.google.com%252F It shows how to enable a single McASP but same concept would apply to another McASP.

    Regards,
    Krunal

  • Hello,

    I have tried with the following DT file for using multiple I2S configurations. But it doesn't work for me. It is still showing only one device while running "arecord -l" command.

    /*
    * Copyright (C) 2016 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. 
    */
    
    &am33xx_pinmux {
    	mcasp1_pins: mcasp1_pins {
    		pinctrl-single,pins = <
     		/* sink must enable receivers */
       		AM33XX_IOPAD(0x9a0, PIN_INPUT_PULLDOWN | 	MUX_MODE3) /* P9_42 mcasp1_aclkx - bit clock */
    		AM33XX_IOPAD(0x9a4, PIN_INPUT_PULLDOWN | MUX_MODE3) /* P9_27 mcasp1_fsx - frame sync */
       		0x1a8 0x23 /* P9_41 mcasp1_axr0 - i2s input */
    		>;	
    	};
    	mcasp0_pins: mcasp0_pins {
    		pinctrl-single,pins = <
     		/* sink must enable receivers */
       		AM33XX_IOPAD(0x8d0, PIN_INPUT_PULLDOWN | 	MUX_MODE3) /* P8_35 mcasp1_aclkx - bit clock */
    		AM33XX_IOPAD(0x8c4, PIN_INPUT_PULLDOWN | MUX_MODE3) /* P8_38 mcasp1_fsx - frame sync */
       		0x0c8 0x23 /* P8_36 mcasp1_axr0 - i2s input */
    		>;
    	};
    };
    &mcasp1 {
    	#sound-dai-cells = <0>;
    	pinctrl-names = "default";
    	pinctrl-0 = <&mcasp1_pins>;
    	status = "okay";
    	op-mode = <0>; /* MCASP_IIS_MODE */
    	tdm-slots = <2>;
    	num-serializer = <4>;
    	serial-dir = < /* 1 TX 2 RX 0 unused */
    		2 1 0 0
    	>;
    	rx-num-evt = <8>;
    	tx-num-evt = <8>;
    };
    &mcasp0 {
    	#sound-dai-cells = <0>;
    	pinctrl-names = "default";
    	pinctrl-0 = <&mcasp0_pins>;
    	status = "okay";
    	op-mode = <0>; /* MCASP_IIS_MODE */
    	tdm-slots = <10>;
    	num-serializer = <4>;
    	serial-dir = < /* 1 TX 2 RX 0 unused */
    		2 1 0 0
    	>;
    	rx-num-evt = <32>;
    	tx-num-evt = <32>;
    };
    / {
    	pcm5102a: pcm5102a {
    		#sound-dai-cells = <0>;
    		compatible = "ti,pcm5102a";
    		status = "okay";
    };
    
    clk_mcasp1_fixed: clk_mcasp1_fixed {
      #clock-cells = <0>;
      compatible = "fixed-clock";
      clock-frequency = <24576000>;
     };
    
    clk_mcasp1: clk_mcasp1 {
      #clock-cells = <0>;
      compatible = "gpio-gate-clock";
      clocks = <&clk_mcasp1_fixed>;
      enable-gpios = <&gpio1 27 0>; /* BeagleBone Black Clk enable on GPIO1_27 */
     };
    
    clk_mcasp0_fixed: clk_mcasp0_fixed {
      #clock-cells = <0>;
      compatible = "fixed-clock";
      clock-frequency = <24576000>;
     };
    
    clk_mcasp0: clk_mcasp0 {
      #clock-cells = <0>;
      compatible = "gpio-gate-clock";
      clocks = <&clk_mcasp0_fixed>;
      enable-gpios = <&gpio1 38 0>; /* BeagleBone Black Clk enable on GPIO1_27 */
     };
    
    sound1: sound@1 {
    compatible = "simple-audio-card";
    simple-audio-card,name = "PCM5102a";
    simple-audio-card,format = "i2s";
    simple-audio-card,bitclock-master = <&sound1_master>;
    simple-audio-card,frame-master = <&sound1_master>;
    simple-audio-card,bitclock-inversion;
    
    sound1_master: simple-audio-card,cpu {
    sound-dai = <&mcasp1>;
    system-clock-direction = "out";
       system-clock-frequency = <24576000>;
       clocks = <&clk_mcasp1>;
    };
    
    simple-audio-card,codec {
    #sound-dai-cells = <0>;
    sound-dai = <&pcm5102a>;
    /*clocks = <&mcasp1_fck>;
    clock-names = "mclk";*/
    };
    };
    
    sound0: sound@0 {
    compatible = "simple-audio-card";
    simple-audio-card,name = "PCM5102a";
    simple-audio-card,format = "i2s";
    simple-audio-card,bitclock-master = <&sound0_master>;
    simple-audio-card,frame-master = <&sound0_master>;
    simple-audio-card,bitclock-inversion;
    
    sound0_master: simple-audio-card,cpu {
    sound-dai = <&mcasp0>;
    system-clock-direction = "out";
       system-clock-frequency = <24576000>;
       clocks = <&clk_mcasp0>;
    };
    
    simple-audio-card,codec {
    #sound-dai-cells = <0>;
    sound-dai = <&pcm5102a>;
    /*clocks = <&mcasp1_fck>;
    clock-names = "mclk";*/
    };
    };
    
    };

    Thank you,

    Shantanu

  • Hi Shantanu,

    Please correct me if I am wrong but McASP 0 also works if McASP 1 is not defined. Based on your configuration, I believe you many need to create another instance of the dummy codec. For example, in the sound node, simple-audio-card name point to PCM5102a for both McASPs. I am not sure if that is the correct config and as an experiment, try creating two instances of dummy codec and let me know your observations.  

    Regards,
    Krunal

  • Hello,

    Yes, McASP 0 is working when McASP 1 is  not defined.

    I have created separate DT file for McASP 0, In that I have used same dummy codec i.e. PCM5102a but it doesn't work for me. Is there any other dummy codec for that will be used for I2S? OR I have to use PCM5102 twice?

    Thanks,

    Shantanu

  • Hello Shantanu,

    Defining McASP0 instance in another file is equivalent of defining it in a single file. We have not tested the above usecase and I would try to create another instance of the dummy codec and see if that helps?

    Regards,
    Krunal

  • Hello Sir,

    Have you tried with another dummy codec? If it's working can you please help me with that.

    Thanks and regards,

    Shantanu

  • Hello,

    We did not test the above usecase as part of our SDK and please share what errors you are observing. 

    Regards,
    Krunal

  • Hello,

    Is there any sample C code to run I2S on Beagle-bone black. or Is there any other method to run I2S without using 'arecord' command.

    Thanks and regards,

    Shantanu

  • Hello Shantanu,

    Unfortunately, we do not provide any C code examples.

    Regards,
    Krunal