gpio: pca953x: Repair multi-byte IO address increment on PCA9575
authorMarek Vasut <marek.vasut@gmail.com>
Wed, 12 Dec 2018 01:39:51 +0000 (02:39 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 14 Dec 2018 14:18:50 +0000 (15:18 +0100)
commit8958262af3fb832c9817e50f599c5552957ceaba
tree3bbd935bf833aaacb1224c2c79c3214f13641e00
parent92f45ebe68181c2d7f76633ffae55bc9447d62cd
gpio: pca953x: Repair multi-byte IO address increment on PCA9575

The multi-byte IO on various pca953x chips requires the auto-increment bit,
while other chips toggle the LSbit automatically. Note that LSbit toggling
only alternates between two registers during the IO, it is not the same as
address auto-increment. The driver currently assumes that #gpios > 16 implies
auto-increment, while #gpios <= 16 implies LSbit toggling. This is incorrect
at there are chips with 16 GPIOs which require the auto-increment bit.

The PCA9575, according to NXP datasheet rev. 4.2 from 16 April 2015, section
7.3 Command Register, the bit 7 in command register is the auto-increment
bit, which allows programming multiple registers sequentially.

Set this bit both in pca953x_gpio_set_multiple(), where it fixes the multi
register programming, and in pca957x_write_regs_16(), where is simplifies
the function. In fact, the pca957x_write_regs_16() now looks rather similar
to pca953x_write_regs_24() and pca953x_write_regs_16(), which is intended
for subsequent patches.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-pca953x.c