need help setting device tree overlay for PCM1862 ADC to use it as system input!

July 18, 2024, 22:14

pingu3884

Hello! I'm having some troubles setting up an appropriate .dts file that sets up the PCM1862 as a valid audio device on CM4. I have two different pieces of code that are correctly compiling and not hiting any error while setting them using sudo dtoverlay. The first one of them is to enable the PCM1862 as a valid i2c device and the second one tries to integrates it with the sound system.
dts
/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2711";

    fragment@0 {
        target = <&i2c1>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@1 {
        target = <&i2c1>;
        __overlay__ {
            pcm1862: pcm1862@4a {
                compatible = "ti,pcm1862";
                reg = <0x4a>;
                status = "okay";
            };
        };
    };
};
This one is working ok, when I use the i2cdetect -y 1 I can see that the corresponding address turns into UU. The next piece is where the issue starts, i can run this dtoverlay without kernel errors, but it's not adding them as a valid audio device, I could check this by using aplay-l and arecord-l and alsamixer:

pingu3884

dts
/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2711";

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

    fragment@1 {
        target = <&i2c1>;
        __overlay__ {
            status = "okay";
            #address-cells =  
; #size-cells =
; }; }; fragment@2 { target = <&i2c1>; __overlay__ { pcm1862: codec@4a { compatible = "ti,pcm1862"; reg = <0x4a>; #sound-dai-cells =
; status = "okay"; }; }; }; fragment@3 { target = <&sound>; __overlay__ { compatible = "simple-audio-card"; simple-audio-card,name = "PCM1862 Audio Input"; simple-audio-card,format = "i2s"; simple-audio-card,mclk-fs =
; simple-audio-card,cpu { sound-dai = <&i2s>; }; simple-audio-card,codec { sound-dai = <&pcm1862>; }; }; }; };

pingu3884

This is the log from building and running
bash
pi@raspberrypi:~ $ dtc -@ -I dts -O dtb -o testoverlay.dtbo testoverlay.dts
testoverlay.dts:29.17-30: Warning (reg_format): /fragment@2/__overlay__/codec@4a:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
testoverlay.dtbo: Warning (pci_device_reg): Failed prerequisite 'reg_format'
testoverlay.dtbo: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
testoverlay.dtbo: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
testoverlay.dtbo: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
testoverlay.dtbo: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
testoverlay.dts:26.31-31.15: Warning (avoid_default_addr_size): /fragment@2/__overlay__/codec@4a: Relying on default #address-cells value
testoverlay.dts:26.31-31.15: Warning (avoid_default_addr_size): /fragment@2/__overlay__/codec@4a: Relying on default #size-cells value
testoverlay.dtbo: Warning (avoid_unnecessary_addr_size): Failed prerequisite 'avoid_default_addr_size'
testoverlay.dtbo: Warning (unique_unit_address): Failed prerequisite 'avoid_default_addr_size'
pi@raspberrypi:~ $ sudo dtoverlay -v testoverlay   
DTOVERLAY[debug]: using platform 'bcm2711'
DTOVERLAY[debug]: overlay map loaded
run_cmd: which dtoverlay-pre >/dev/null 2>&1 && dtoverlay-pre
DTOVERLAY[debug]: loading file '/boot/overlays/testoverlay.dtbo'
DTOVERLAY[debug]: wrote 1208 bytes to '/tmp/.dtoverlays/0_testoverlay.dtbo'
DTOVERLAY[debug]: wrote 1208 bytes to '/sys/kernel/config/device-tree/overlays/0_testoverlay/dtbo'
run_cmd: which dtoverlay-post >/dev/null 2>&1 && dtoverlay-post
pi@raspberrypi:~ $