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,

    Thank you for clarifying your issue.

    But I think this has been discussed in various other tickets. For eg: Look at this ticket from my colleague there he shows how to add this in overlay file.

    Let me know if this not what you are looking for. Please expect a delay after this response as I will be away for Christmas vacation and whole Devzone is working understaffed.

    Kind Regards,

    Abhijith

  • Just to close this out - your link above helped me figure out my issue (which was due to my unfamiliarity with devicetree syntax!)

    To add new nodes, the correct syntax is 

    /{
    SampleSignals
        {
         compatible = "gpio-keys";
          input_signal1: input_signal1
          {
             gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
              label = "Name your GPIO Signal";
            };
        };
    };

    However, if you are overriding something like an i2c bus, then no 'root'  syntax is required:
    &i2c0
    {
        new_i2c_device0: i2c_device@30
        {
            compatible = "i2c-device";
            reg = < 0x30 >;
            label = "First new I2C device";
        };
    };
    Adding the two snippets above to an .overlay file works and does not require modifying the original .dts file in the sdk directories.

    Thanks again for the help!
Reply
  • Just to close this out - your link above helped me figure out my issue (which was due to my unfamiliarity with devicetree syntax!)

    To add new nodes, the correct syntax is 

    /{
    SampleSignals
        {
         compatible = "gpio-keys";
          input_signal1: input_signal1
          {
             gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
              label = "Name your GPIO Signal";
            };
        };
    };

    However, if you are overriding something like an i2c bus, then no 'root'  syntax is required:
    &i2c0
    {
        new_i2c_device0: i2c_device@30
        {
            compatible = "i2c-device";
            reg = < 0x30 >;
            label = "First new I2C device";
        };
    };
    Adding the two snippets above to an .overlay file works and does not require modifying the original .dts file in the sdk directories.

    Thanks again for the help!
Children
No Data
Related