From patchwork Mon Jan 27 17:49:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 240321 List-Id: U-Boot discussion From: vigneshr at ti.com (Vignesh Raghavendra) Date: Mon, 27 Jan 2020 23:19:00 +0530 Subject: [PATCH] gpio: pca953x_gpio: Add support for 24 bit IO expander Message-ID: <20200127174900.9875-1-vigneshr@ti.com> J721e EVM has a TCA6424 IO expander that has 24 GPIOs. Add support for the same Signed-off-by: Vignesh Raghavendra --- drivers/gpio/pca953x_gpio.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c index 07a3356b3c87..5c2944067bc1 100644 --- a/drivers/gpio/pca953x_gpio.c +++ b/drivers/gpio/pca953x_gpio.c @@ -15,8 +15,7 @@ * * TODO: * 1. Support PCA957X_TYPE - * 2. Support 24 gpio pins - * 3. Support Polarity Inversion + * 2. Support Polarity Inversion */ #include @@ -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);