gpio: pca953x: fix address calculation for pcal6524
authorH. Nikolaus Schaller <hns@goldelico.com>
Thu, 17 May 2018 04:59:49 +0000 (06:59 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 23 May 2018 11:49:40 +0000 (13:49 +0200)
commitd5dbf9c266ccf632cdf259146e4ec62b381db655
tree6341a38990fd5a0e97eb2a09989930f32f73d2a8
parent394aeef83c7080c9fd850e3479e0cd58e510163b
gpio: pca953x: fix address calculation for pcal6524

The register constants are so far defined in a way that they fit
for the pcal9555a when shifted by the number of banks, i.e. are
multiplied by 2 in the accessor function.

Now, the pcal6524 has 3 banks which means the relative offset
is multiplied by 4 for the standard registers.

Simply applying the bit shift to the extended registers gives
a wrong result, since the base offset is already included in
the offset.

Therefore, we have to add code to the 24 bit accessor functions
that adjusts the register number for these exended registers.

The formula finally used was developed and proposed by
Andy Shevchenko <andy.shevchenko@gmail.com>.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-pca953x.c