gpio: mmio: Support two direction registers
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 22 Feb 2019 10:14:44 +0000 (11:14 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 4 Apr 2019 17:04:13 +0000 (00:04 +0700)
commitf69e00bd21aa6a1961c521b6eb199137fcb8a76a
tree0875c21d01d88d2ab5224de0548246f25dcb2d15
parent9e98c678c2d6ae3a17cb2de55d17f69dddaa231b
gpio: mmio: Support two direction registers

It turns out that one specific hardware has two direction
registers: one to set a GPIO line as input and another one
to set a GPIO line as output. So in theory a line can be
configured as input and output at the same time.

Make the MMIO GPIO helper deal with this: store both
registers in the state container, use both in the generic
code if present. Synchronize the input register to the
output register when we register a GPIO chip, with the
output settings taking precedence.

Keep the helper variable to detect inverted direction
semantics (only direction in register) but augment the
code to be more straight-forward for the generic case
when setting the registers.

Fix some flunky with unreadable direction registers at
the same time as we're touching this code.

Cc: David Woods <dwoods@mellanox.com>
Cc: Shravan Kumar Ramani <sramani@mellanox.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-mmio.c
include/linux/gpio/driver.h