AnsweredAssumed Answered

GPIO keys in device tree for external GPIO controller (PCA9554)

Question asked by Maksim Mel on May 3, 2020
Latest reply on May 4, 2020 by igorpadykov

Hello everyone!

I use iMX6qp board with PCA9554 as a button controller. I made it work with proper driver in my device tree:

i2c3 {

...

pca9554_expander1: pca9554@22 {
   compatible = "nxp,pca9554";
   reg = <0x22>;
   gpio-controller;
};

...

};

And now I see my GPIO expander in sysfs like

gpiochip7: GPIOs 504-511, parent: i2c/2-0022, pca9554

I want to configure buttons connected to PCA9554 as gpio-keys like:

enter_btn: enter_btn {
  compatible = "gpio-keys";
  pinctrl-names = "default";
  pinctrl-0 = <&pinctrl_gpiobuttons1>;
  enter-button {
   label = "enter-button";
   linux,code = <28>; /* ENTER */
   gpios = <&gpio7 2 0>;
   };
};

 

But I cannot do it in a device tree because gpio-expander gpiochip7 is created just when pca9554 driver is loaded.

How can I set this device as a correct gpio controller and configure it for gpio-buttons?

Thanks for any useful information!

Outcomes