Specifying GPIO Numbers for the IO Extender in the Linux Device Tree

I am trying to add a PCA9557 I / O expander to an I2C bus based system. The system already has another I / O expander on another I2C bus. I am trying to figure out how to specify which GPIO numbers are displayed on the new expander, and how to make both work.

Here is a section of the device tree for an existing expander, under the I2C 2 bus:

        i2c2: i2c@e8007000 {
        status = "ok";

        pca9539: pca9539@74 {
            compatible = "nxp,pca9539";
            reg = <0x74>;
            interrupt-parent = <&gpio>;
            interrupts = <9 0x0>;
            gpio-controller;
            #gpio-cells = <2>;
            interrupt-controller;
            #interrupt-cells = <2>;
        };
        };

Using the above, the existing I / O expander (with 16 GPIOs) appears on linux as / sys / class / gpio / gpiochip128 , exposing GPIO numbers 128 - 143. GPIO 0-127 is built into the main processor.

I added the following for the new expander on the I2C 0 bus:

   i2c0: i2c@e8003000 {
        status = "ok";

        pca9557: pca9557@18 {
            compatible = "nxp,pca9557";
            reg = <0x18>;
            gpio-controller;
            #gpio-cells = <2>;
        };

I also changed the kernel configuration to build the GPIO_PCA953X driver, which should support PCA9557.

, (PCA9557), /sys/class/gpio/gpiochip136, ( IO 0 GPIO128).

GPIO. - /sys/devices/... "driver..." "i2c-2", .

, BOTH /sys/class/gpio/ GPIO, ?

, "128" GPIO GPIO? GPIO 136?

: GPIO , .

+4

Source: https://habr.com/ru/post/1617151/


All Articles