Devicetree overlay for simple GPIO

It seems like there are lots of questions regarding simple GPIOs and devicetree, but I can't quite find something that describes my problem:

I am using the nrf52840dk, and I successfully created an overlay file to read/write to an I2C device, but I am having trouble adding a simple GPIO pin to my overlay file.

First, I tried adding the following to my overlay file:

columnswitchint: column_switch_input
    {
             compatible = "gpio-keys";
            gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
            label = "Column Switch Input Signal";
    };

When I try to build, I get the error "Property not mentioned in "/" ".  

Next, I tried declaring the pin like the 'buttons' definition in the .dts file for the blinky example:

sample_gpio_signals
{

    compatible = "gpio-keys";
    columnswitchint: column_switch_input
    {
           
            gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
            label = "Column Switch Interrupt Signal";
    };
};

This results in the error "Node column_switch_input should have "compatible" property".

Finally, I tried moving the compatible property down into the node:

sample_gpio_signals
{

    columnswitchint: column_switch_input
    {
   
            compatible = "gpio-keys";
            gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
            label = "Column Switch Interrupt Signal";
    };
};

And this results in the error "Property not mentioned in "gpio-keys".  Obviously 'gpios' is one of the only two properties declared in gpio-keys, so I'm stuck.

What am I missing here?  

Parents
  • Hello,

     I think the issue is with the compatible section here. AFAIK, the system always looks for the matching binding file and for this compatible properties are used. Take a look at this page which explains more on this. I think you need to create a binding file inside ncs\v2.x.x\nrf\dts\bindings and then add this to your dts node.
    Creating binding file is explained here. Something like below need to be created. Each section inside the yaml file is described here.

    .

    description: GPIO test
    
    compatible: "xyz,test"
    
    include: base.yaml
    
    properties:
      status:
        required: true
    
      gpios:
        type: phandle-array
        required: true
        description: |
          GPIO to use as testpin.

    Try adding this to your dts node. Something like below

    xyz: test {
    	compatible = "xyz,test";
    	gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
    };

    I am not completely sure on this as I haven't tried this before. Give it a shot and let me know.

    Kind Regards,

    Abhijith

  • Also, just to be clear, if I add

    sample_gpio_signals

    {
        compatible = "gpio-keys";
        columnswitchint: column_switch_input

        {   
                gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
                label = "Column Switch Interrupt Signal";
        };
    };

    To the .dts file (and not the overlay file), the project builds and works just fine.  My concern with this is that now I've modified a file that is not in my project directory and I can't easily commit it to my repository.

Reply
  • Also, just to be clear, if I add

    sample_gpio_signals

    {
        compatible = "gpio-keys";
        columnswitchint: column_switch_input

        {   
                gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
                label = "Column Switch Interrupt Signal";
        };
    };

    To the .dts file (and not the overlay file), the project builds and works just fine.  My concern with this is that now I've modified a file that is not in my project directory and I can't easily commit it to my repository.

Children
No Data
Related