gpio: gpio-aspeed-sgpio: Add AST2600 sgpio support
authorSteven Lee <steven_lee@aspeedtech.com>
Mon, 12 Jul 2021 10:03:12 +0000 (18:03 +0800)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Thu, 5 Aug 2021 19:15:59 +0000 (21:15 +0200)
commite1f85d25638cce2c5535efb608adf7a6ee817794
tree0e528ec5e916ded26891e04b809ecccbe9ca745e
parente5de9d283a36a2923f7f309050b8c51b14753c3a
gpio: gpio-aspeed-sgpio: Add AST2600 sgpio support

The maximum number of gpio pins of SoC is hardcoded as 80 and the gpio pin
count mask for GPIO Configuration register is hardcode as GENMASK(9,6).
However, AST2600 has 2 sgpio master interfaces, one of them supports up
to 128 gpio pins and pin count mask of GPIO Configuration Register is 5
bits.

The patch adds ast2600 compatibles, removes MAX_NR_HW_SGPIO and
corresponding design to make the gpio input/output pin base are determined
by ngpios.
The patch also removed hardcoded pin mask and adds ast2400, ast2500,
ast2600 platform data that include gpio pin count mask for GPIO
Configuration Register.

The original pin order is as follows:
(suppose MAX_NR_HW_SGPIO is 80 and ngpios is 10 as well)
Input:
0 1 2 3 ... 9
Output:
80 81 82 ... 89

The new pin order is as follows:
Input:
0 2 4 6 ... 18
Output:
1 3 5 7 ... 19

SGPIO pin id and input/output pin mapping is as follows:
SGPIO0(0,1), SGPIO1(2,3), ..., SGPIO79(158,159)

For example:
Access SGPIO5(10,11)
Get SGPIO pin 5 (suppose sgpio chip id is 2)
gpioget 2 10

Set SGPIO pin 5 (suppose sgpio chip id is 2)
gpioset 2 11=1
gpioset 2 11=0

Signed-off-by: Steven Lee <steven_lee@aspeedtech.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
drivers/gpio/gpio-aspeed-sgpio.c