How export i2c gpio number

I have a mt7621 chip board with i2c extended gpio.

device tree configured as follows:

&i2c {
        status = "okay";

        jxr160: rtc@32 {
                status = "okay";
                compatible = "jxr,jxr160";
                reg = <0x32>;

        gpio_tca9539: gpio@20 {
                compatible = "nxp,pca9539";
                reg = <0x20>;

                interrupt-parent = <&gpio>;
                interrupts = <&gpio 0 GPIO_ACTIVE_LOW>;

                #gpio-cells = <2>;
  1. Want to export i2c gpio to sysfs, how to write the dts gpio_export field?
  2. How can I find out all the exported gpio numbers for i2c?
        gpio_export {
                compatible = "gpio-export";
                #size-cells = <0>;

                // how to export i2c gpio???

Any advice and steps are appreciated!

You can't. If a GPIO is used by i2c, you cannot export it to sysfs. You have to disable i2c and change the function of the pins to GPIO, then you can export them.

By checking the datasheet. The hardware i2c pins on the MT7621 are fixed (GPIO3 and GPIO4).

Edit: I read your post again, and I think I completely misinterpreted your questions. You want to export the GPIOs of the GPIO expander connected via i2c, right?

In this case, you can refer to the gpio_tca9539 node when exporting the GPIO:

gpios = <&gpio_tca9539 0 GPIO_ACTIVE_LOW>;

The GPIO numbers start with 0 again for every GPIO expander.


Hi. @andyboeh

Refer to the gpio_tca9539 node, can exporting the GPIO.

gpios = <&gpio_tca9539 0 GPIO_ACTIVE_LOW>;

Thank you.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.