Jump to content

Pine64-R18 - Setup GPIO inputs via Device Tree


Gavinb

Recommended Posts

Hi

 

I have been trying to allocate specific gpio's as input via the Device Tree, this ultimately being for a custom made board.

I can and have successfully allocated pins PB0, PB1, PB3 & PB5, which are showing in /dev/inputs/by-path and have been verified working with evtest.

 

Working code :-

/dts-v1/;
/plugin/;

/ {

  fragment@0 {
    target = <&pio>;
    __overlay__ {
      input_0: input_0 {
        pins = "PB0";
        function = "gpio_in";
        bias-pull-up;
      };
    };
  };

  fragment@1 {
    target-path = "/";
    __overlay__ {
      button_1 {
        compatible = "gpio-keys";
        pinctrl-names = "default";
        pinctrl-0 = <&input_0>;
        
        Button_1 {
          label = "Button_1";
          linux,code = <2>;
          gpios = <&pio 1 0 1>;
        };
      };
    };
  };
};

However, I need to use GPIO PG2, PG3 PG4 & PG5.

When changing the allocation, both 'pins = "PB0";' in fragment0 and 'gpios = <&pio 1 0 1>;' to PG2 and &pio 6 2 1, then overlay is successfully installed, but however not working.

 

/dts-v1/;
/plugin/;

/ {

  fragment@0 {
    target = <&pio>;
    __overlay__ {
      input_0: input_0 {
        pins = "PG2";
        function = "gpio_in";
        bias-pull-up;
      };
    };
  };

  fragment@1 {
    target-path = "/";
    __overlay__ {
      button_1 {
        compatible = "gpio-keys";
        pinctrl-names = "default";
        pinctrl-0 = <&input_0>;
        
        Button_1 {
          label = "Button_1";
          linux,code = <2>;
          gpios = <&pio 6 2 1>;
        };
      };
    };
  };
};

I have verified that the pins I intend to use are in fact IRQ pins, and can control the pins via sysfs, by manually exporting, setup and echo to toggle them.

I've haven't seen anything that stands out in the balance of the std Device Tree structure that might be causing this issue.

 

Any suggestions as to where else I could look into resolving this would be appreciated.

 

Regards

Gavin B

Link to comment
Share on other sites

According to schematic and also DTS, the PGx pins you are trying to use are already in use by MMC1/SDIO for the WiFi module, so it cannot be used as plain GPIO, except if you remove all those things in device-tree.

Link to comment
Share on other sites

I agree the pins are used for the WiFi module, however I do not have a physical device connected. I am in the process of trying to isolate those pins from it.

However there seems to be a different issue that's arisen with the current merges going on, in the sense that the working PB based overlay, tested in 4.14.41, causes the board to go into kernel-panic mode when the kernel starts up on any newer version, I.e 42 and 43.

I'll open a different thread for that after a bit more testing, as this can wait until we start piecing everything together in the project with it own full device-tree.

 

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines