How to create Boss Audio i2s PCM5122 DAC Board Device Tree? (custom clocks)

Hi,

I am trying to get the Boss i2S DAC ( https://www.allo.com/sparky/boss-dac.html ) and other variants working on the rockpi s. It is basically a PCM5122 with its own generated clock. This means that the rock chip will need to use its MCLK as a slave clock. I have been able to compile the drivers into the kernel but I am having problems trying to figure out where to include the clocks since the /clocks node isn’t present in the rockchip’s DTS.

Thanks for your help!

Here is the device tree overlay meant for the raspberry pi:

/*
 * Definitions for Allo Boss DAC board
 */

/dts-v1/;
/plugin/;

/ {
	compatible = "brcm,bcm2835";

	fragment@0 {
		target-path = "/clocks";
		__overlay__ {
			boss_osc: boss_osc {
				compatible = "allo,dac-clk";
				#clock-cells = <0>;
			};
		};
	};

	fragment@1 {
		target = <&i2s>;
		__overlay__ {
			status = "okay";
		};
	};

	fragment@2 {
		target = <&i2c1>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";

			pcm5122@4d {
				#sound-dai-cells = <0>;
				compatible = "ti,pcm5122";
				clocks = <&boss_osc>;
				reg = <0x4d>;
				status = "okay";
			};
		};
	};

	fragment@3 {
		target = <&sound>;
		boss_dac: __overlay__ {
			compatible = "allo,boss-dac";
			i2s-controller = <&i2s>;
			mute-gpios = <&gpio 6 1>;
			status = "okay";
		};
	};

	__overrides__ {
		24db_digital_gain = <&boss_dac>,"allo,24db_digital_gain?";
		slave = <&boss_dac>,"allo,slave?";
	};
};

I could give you a hint to start with. The only i2s routed to the pins is i2s@ff300000 try to replace &i2s with &i2s_8ch_0.
You should also disable i2s_8ch_2
fragment@1 {
target = <&i2s_8ch_2>;

            __overlay__ {
                    #sound-dai-cells = <0>;
                    status = "disabled";
                    };
           };

that is enabled in DTB.
Have you find your device at 4d with i2cdetect?

Did you manage to source an external clock to PIS?

Not yet, I think I am close though. I have done extensive research into the acodec and multicodec driver.

After comparing the drivers and device trees to the chip datasheet I believe this is why the dummy codec was developed. To be able to set the clocks and other settings on the chipset without affecting the other drivers. I am investigating this further. This is definitely more complicated than a raspberry pi since there are multiple channels.

What application are you trying to get to work? Maybe we could work together and get this solved.

Adam

I am hardware designer and have done a lot of network audio streamers for several years now. From cubieboard to RPI nanopi and PIs. I have now a PIs HAT that is in the final stage offering NOS DAC and balanced output.
Why I want to source the clock from an external clock source is to get rid of the jitter from the built in clock.
There are workarounds to get a masterclock by setting the driver on a bitclock ratio that generates your master clock and then derive from that with some hardware to get the bitclock I have done that But the audible result always suffers of the jitter originating from the built in clock.

Here is an update of where I am at. I am using below as a device tree. I compiled the drivers for the allo boss dac, allo boss clk, and TI PCM512x. The card initializes and the status light turns on after boot up. The card shows under aplay -L. However when I try to do a speake-test i get the following error. I am not sure what argument is invalid or where to look for more clues. Also, the status light immediately turns off after attempting to run the test, so i think it caused an error on the daughter board as well. Things look good during init in dmesg.

Thanks!

dmesg:
[ 4.183338] snd-allo-boss-dac sound-ext-card: GPIO lookup for consumer mute
[ 4.183366] snd-allo-boss-dac sound-ext-card: using device tree for GPIO lookup
[ 4.183404] of_get_named_gpiod_flags: parsed ‘mute-gpios’ property of node ‘/sound-ext-card[0]’ - status (0)
[ 4.224612] snd-allo-boss-dac sound-ext-card: pcm512x-hifi <-> ff300000.i2s mapping ok

Error:
speaker-test 1.1.9
Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
ALSA lib …/…/…/alsa-lib-1.1.9/src/pcm/pcm_params.c:2226:(snd1_pcm_hw_refine_slave) Slave PCM not usable
Broken configuration for playback: no configurations available: Invalid argument
Setting of hwparams failed: Invalid argument

DTS:
/*
* Definitions for Allo Boss DAC board
*/

 /dts-v1/;
 /plugin/;
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/pinctrl/rockchip.h>
 #include <dt-bindings/clock/rk3308-cru.h>
 / {
    compatible = "rockchip,rk3308";

    
      fragment@0 {
        target = <&i2s_8ch_2>;
        
        __overlay__ {
                #sound-dai-cells = <0>;
                status = "disabled";
        };
      };    

      fragment@1 {
          target = <&acodec>;

          __overlay__ {
            status = "disabled";
          };
      };

    fragment@2 {
        target = <&i2s_8ch_0>;
        __overlay__ {
            #sound-dai-cells = <0>;
            status = "okay";
        };
    };

    
     fragment@3 {
         target-path = "/";
         __overlay__ {
             
            boss_osc: boss_osc {
                 compatible = "allo,dac-clk";
                 #clock-cells = <0>;
             };

         };
     };
 
 
 
     fragment@4 {
         target = <&i2c1>;
         __overlay__ {
             #address-cells = <1>;
             #size-cells = <0>;
             status = "okay";
 
             pcm5122@4d {
                 #sound-dai-cells = <0>;
                 compatible = "ti,pcm5122";
                 clocks = <&boss_osc>;
                 reg = <0x4d>;
                 AVDD-supply = <&vcc_3v3_codec>;
				 DVDD-supply = <&vcc_3v3_codec>;
				 CPVDD-supply = <&vcc_3v3_codec>;
                 status = "okay";
             };
         };
     };
 

    fragment@5 {
        target-path = "/sound-ext-card";

        __overlay__ {

            compatible = "allo,boss-dac";
            i2s-controller = <&i2s_8ch_0>;
            mute-gpios = <&gpio1 RK_PC6 GPIO_ACTIVE_LOW>;
            status = "okay";
            
        };
    };

 };

Do you have an oscilloscope? I think you should verify if the PIS really acting as a slave.