JonnyHelp
Posts: 3
Joined: Mon Feb 19, 2018 5:07 am

@i2c device tree drive

Mon Feb 19, 2018 5:32 am

Hello guys, I would like your help,

I started a project with Raspberry pi 3 and NFC and bought the board OM5577/PN7150 - from this moment I started to follow the guide AN11690 - NXP to install the drive.

My knowledge in the area is very limited so I got stuck in this part:

Device node /dev/pn544 - Device tree
Below is an example of definition to be added to the platform device tree file (.dts file located for instance under arch/arm/boot/dts kernel sub-folder for ARM based platform).

Code: Select all

&i2c{
    status = "okay";
    pn547: [email protected] {
        compatible = "nxp,pn547";
        reg = <0x28>;
        clock-frequency = <400000>;
        interrupt-gpios = <&gpio2 17 0>;
        enable-gpios = <&gpio4 21 0>;
    };
};

I do not know anything (only what I read so far) about "device tree" so... I do not know how to proceed, in my attempts I tried:

- I created a .dts file with the same content in arch/arm/boot/dts/ and tried dtc -I dts -O dtb -o ... (without success, syntax error)
- by logic I thought I could add this node in: arch/arm/boot/dts/bcm2710-rpi-3-b.dts (same error)

What is the procedure to follow this guide instruction (which seemed very simple at first)

I am using linux-rpi-4.9.y.

Any help will be welcome.

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

Re: @i2c device tree drive

Mon Feb 19, 2018 11:02 am

That's an old-looking driver - I'm not sure how well its going to integrate with a 4.9 kernel.

This overlay should make the expected device tree changes:

Code: Select all

/dts-v1/;
/plugin/;

/ {
    [email protected] {
        target = <&i2c1>;
        __overlay__ {
            status = "okay";
            #address-cells = <1>;
            #size-cells = <0>;

            pn547: [email protected] {
                compatible = "nxp,pn547";
                reg = <0x28>;
                clock-frequency = <400000>;
                interrupt-gpios = <&gpio 17 4>; /* active high */
                enable-gpios = <&gpio 21 0>;
            };
        };
    };
};
Call it something like pn547-overlay.dts and compile it with:

Code: Select all

dtc [email protected] -I dts -O -dtb -o pn547.dtbo pn547-overlay.dts
Don't worry about the warning message. Then copy pn547.dtbo to /boot/overlays and add the following line to config.txt:

Code: Select all

dtoverlay=pn547

JonnyHelp
Posts: 3
Joined: Mon Feb 19, 2018 5:07 am

Re: @i2c device tree drive

Mon Feb 19, 2018 4:49 pm

Thanks PhilE,

I was able to generate dtbo now (I'll give a read about overlays and 4.9 today)

I will carry out all the tests to verify that everything went well, as soon as I finish I send the feedback.

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

Re: @i2c device tree drive

Mon Feb 19, 2018 4:56 pm

The thing I noticed particularly is that the driver appears to be explicitly getting a GPIO pin from the Device Tree and making an interrupt source out of it, whereas in a modern kernel you would just call "platform_get_irq" and it would automatically look for an "interrupts" property and take all the required actions.

JonnyHelp
Posts: 3
Joined: Mon Feb 19, 2018 5:07 am

Re: @i2c device tree drive

Mon Feb 19, 2018 5:17 pm

I also noticed, but as I said before, my experience in the area is very limited to adapt the drive and create the entry in the device tree, if it does not work I will try to develop and adapt.

I hope to count on you :lol:

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

Re: @i2c device tree drive

Mon Feb 19, 2018 5:20 pm

A bit of optimism never hurts. ;)

Return to “Device Tree”