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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

3,509 Views
adrocohen
Contributor II

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!

Labels (1)
Tags (2)
0 Kudos
1 Reply

3,415 Views
igorpadykov
NXP Employee
NXP Employee

Hi Maksim

one can look at PCA95x dts examples, for example:

linux-fslc/imx28-tx28.dts at 4.14.x+fslc · Freescale/linux-fslc · GitHub 

linux-fslc/imx6q-gw5400-a.dts at 4.14.x+fslc · Freescale/linux-fslc · GitHub 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos