gpio: pca953x_gpio: Add support for 24 bit IO expander
authorVignesh Raghavendra <vigneshr@ti.com>
Mon, 27 Jan 2020 17:49:00 +0000 (23:19 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Tue, 4 Feb 2020 03:37:24 +0000 (09:07 +0530)
J721e EVM has a TCA6424 IO expander that has 24 GPIOs. Add support for
the same

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
drivers/gpio/pca953x_gpio.c

index 07a3356b3c8713c003212d0b0b719acfc53d473f..5c2944067bc15374519e7ec5f7c87a167460f27f 100644 (file)
@@ -15,8 +15,7 @@
  *
  * TODO:
  * 1. Support PCA957X_TYPE
- * 2. Support 24 gpio pins
- * 3. Support Polarity Inversion
+ * 2. Support Polarity Inversion
  */
 
 #include <common.h>
@@ -118,6 +117,10 @@ static int pca953x_read_regs(struct udevice *dev, int reg, u8 *val)
                ret = dm_i2c_read(dev, reg, val, 1);
        } else if (info->gpio_count <= 16) {
                ret = dm_i2c_read(dev, reg << 1, val, info->bank_count);
+       } else if (info->gpio_count <= 24) {
+               /* Auto increment */
+               ret = dm_i2c_read(dev, (reg << 2) | 0x80, val,
+                                 info->bank_count);
        } else if (info->gpio_count == 40) {
                /* Auto increment */
                ret = dm_i2c_read(dev, (reg << 3) | 0x80, val,
@@ -139,6 +142,10 @@ static int pca953x_write_regs(struct udevice *dev, int reg, u8 *val)
                ret = dm_i2c_write(dev, reg, val, 1);
        } else if (info->gpio_count <= 16) {
                ret = dm_i2c_write(dev, reg << 1, val, info->bank_count);
+       } else if (info->gpio_count <= 24) {
+               /* Auto increment */
+               ret = dm_i2c_write(dev, (reg << 2) | 0x80, val,
+                                  info->bank_count);
        } else if (info->gpio_count == 40) {
                /* Auto increment */
                ret = dm_i2c_write(dev, (reg << 3) | 0x80, val, info->bank_count);