rw1968
Posts: 3
Joined: Mon Oct 16, 2017 4:33 pm

[SOLVED] phandle problems with machine driver

Tue Oct 17, 2017 8:25 am

Hi All,

I'm new to device tree, and trying to use it to develop a machine driver to link simple-audio-card to a Cirrus Logic CS4271 device.
Hardware is CM3
uname -r returns:
4.9.52-v7+
The CS4271 is connected to the I2S bus and I2C1
The overlay file is called cs4271-overlay.dts.
I've built a new kernel with CS4271 support enabled.

Here's what I have so far:

Code: Select all

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

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


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

                codec_i2c: cs4271@10 {
                #sound-dai-cells = <0>;
                compatible = "cirrus,cs4271";
                reg = <0x10>;
                reset-gpio = <&gpio 23 0>;
                vd-supply = <&vdd_3v3_reg>;
                vl-supply = <&vdd_3v3_reg>;
                va-supply = <&vdd_3v3_reg>;
                status = "okay";
            };
        };
    };


    fragment@2 {
        target = <&sound>;
        sound_overlay: __overlay__ {
            compatible = "simple-audio-card";
            simple-audio-card,format = "i2s";
            simple-audio-card,name = "cs4271";
            simple-audio-card,bitclock-slave = <&dailink0_slave>;
            simple-audio-card,frame-slave = <&dailink0_slave>;
            simple-audio-card,widgets =
                    "Line", "Line In",
                    "Line", "Line Out";
            simple-audio-card,routing =
                    "AINL", "Line In",
                    "AINR", "Line In",
                    "Line Out", "AOUTL",
                    "Line Out", "AOUTR";
            status = "okay";

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

            dailink0_slave: simple-audio-card,codec {
                sound-dai = <&codec_i2c>;
            };
        };
    };

    __overrides__ {
        card-name = <&sound_overlay>,"simple-audio-card,name";
    };
};


I'm loading it with

Code: Select all

dtoverlay -v ./cs4271.dtbo
dmesg shows the following:

Code: Select all

[  215.489232] OF: /soc/sound/simple-audio-card,codec: could not find phandle
[  215.489250] asoc-simple-card soc:sound: parse error -22
[  215.489277] asoc-simple-card: probe of soc:sound failed with error -22
Which, I think, indicates a problem in of_phandle_iterator_next().
Although the dts compiles without error, I've clearly got something missing, but I've been looking at it for a while now and can't see what it is.
Any advice or ideas would be greatly appreciated.

Cheers,

Richard.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1419
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: phandle problems with machine driver

Tue Oct 17, 2017 10:00 am

There's a problem with this line:

Code: Select all

        target = "i2c1";
The "target" property is used with phandles, while "target-path" is used with path strings, but the dtc compiler doesn't know this. The kernel is trying to interpret the string "i2c1" as a phandle and failing.

What you meant to write is:

Code: Select all

        target = <&i2c1>;
This puts an unresolved symbol into the dtbo which the kernel replaces with the phandle of the node with the label "i2c1".

rw1968
Posts: 3
Joined: Mon Oct 16, 2017 4:33 pm

Re: phandle problems with machine driver

Wed Oct 18, 2017 4:10 pm

Hi Phil,
Thanks for your reply - yep that was it.
I've now got some problems with sample rates, but thats more of an ALSA problem I think.
I'll post the working dts here when I'm happy with it in case anyone else is interested.

Cheers.

rw1968
Posts: 3
Joined: Mon Oct 16, 2017 4:33 pm

Re: phandle problems with machine driver

Tue Oct 31, 2017 11:57 am

It wasn't and ALSA problem - I can't set the sample rate because the driver thinks the mclk is 0Hz.
Here's the fix in case anyone is interested:

Code: Select all

dailink0_slave: simple-audio-card,codec {
	sound-dai = <&codec_i2c>;
	system-clock-frequency = <12288000>;
}
Replace the number with the frequency of your choice.

Return to “Device Tree”

Who is online

Users browsing this forum: No registered users and 2 guests