gpio: Add a way to read 3-way strapping pins
authorSimon Glass <sjg@chromium.org>
Fri, 5 Feb 2021 04:22:09 +0000 (21:22 -0700)
committerTom Rini <trini@konsulko.com>
Wed, 3 Mar 2021 20:40:47 +0000 (15:40 -0500)
commit8a45b2205749252f61d26508d5de9dcce020b2ef
treefac56f635fb7a10236dd41868a0b1629184ab39c
parentbe04f1ab4291c724a65d86a743b8b7938f15a54c
gpio: Add a way to read 3-way strapping pins

Using the internal vs. external pull resistors it is possible to get
27 different combinations from 3 strapping pins. Add an implementation
of this.

This involves updating the sandbox GPIO driver to model external and
(weaker) internal pull resistors. The get_value() method now takes account
of what is driving a pin:

   sandbox: GPIOD_EXT_DRIVEN - in which case GPIO_EXT_HIGH provides the
          value
   outside source - in which case GPIO_EXT_PULL_UP/DOWN indicates the
          external state and we work the final state using those flags and
          the internal GPIOD_PULL_UP/DOWN flags

Of course the outside source does not really exist in sandbox. We are just
modelling it for test purpose.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/include/asm/gpio.h
drivers/gpio/gpio-uclass.c
drivers/gpio/sandbox.c
include/asm-generic/gpio.h
test/dm/gpio.c