[PATCH v2 00/15] gpio: Update and simplify the uclass API
Simon Glass
sjg at chromium.org
Thu Jan 21 04:11:44 CET 2021
At present the GPIO uclass mirrors what was in U-Boot before driver model.
It works well in most cases but is becoming cumbersome with things like
pull-up/down and drive strength. In those cases it is easier for the
driver to deal with all the flags at one, rather than piece by piece.
In fact the current API does not officially have a method for adjusting
anything other than the direction flags. While set_dir_flags() and
get_dir_flags() do in fact support changing other flags, this is not
documented.
Secondly, set_dir_flags actually ORs the current flags with the new ones
so it is not possible to clear flags. It seems better to use a clr/set
interface (bit clear followed by OR) to provide more flexibility.
Finally, direction_input() and direction_output() are really just the same
thing as set_dir_flags(), with a different name. We currently use the
latter if available, failing back to the former. But it makes sense to
deprecate the old methods.
This series makes the above changes. Existing drivers are mostly left
alone, since they should continue to operate as is. The sandbox driver is
updated to add the required new tests and the x86 driver is switched over
to the new API.
The STM32 driver should be checked to make sure the open source/open drain
features still work as intended.
Changes in v2:
- Use set_flags() instead of update_flags()
- Fix 'provide' typo while we are here
- Make operation of set_flags() deterministic
- Swap newf and flags in sb_gpio_set_flags()
Simon Glass (15):
gpio: Disable functions not used with of-platdata
dm: gpio: Rename set_dir_flags() method to update_flags()
dm: gpio: Rename get_dir_flags() method to get_flags()
gpio: Rename dm_gpio_get_dir_flags() to dm_gpio_get_flags()
gpio: Drop dm_gpio_set_dir()
gpio: sandbox: Rename GPIO dir_flags to flags
gpio: sandbox: Use a separate flag for the value
gpio: sandbox: Fully separate pin value from output value
gpio: sandbox: Make sandbox_gpio_set_flags() set all flags
dm: gpio: Add a way to update flags
gpio: Replace direction_input() and direction_output()
gpio: Use an 'ops' variable everywhere
gpio: x86: Drop the deprecated methods in intel_gpio
gpio: sandbox: Track whether a GPIO is driven
gpio: Add a way to read 3-way strapping pins
arch/sandbox/include/asm/gpio.h | 17 +-
arch/x86/include/asm/intel_pinctrl_defs.h | 5 +
drivers/gpio/gpio-uclass.c | 228 ++++++++++++++-----
drivers/gpio/intel_gpio.c | 72 +++---
drivers/gpio/sandbox.c | 138 ++++++++----
drivers/gpio/stm32_gpio.c | 14 +-
drivers/pinctrl/pinctrl-stmfx.c | 14 +-
include/asm-generic/gpio.h | 130 +++++++++--
test/dm/gpio.c | 261 +++++++++++++++++++---
9 files changed, 663 insertions(+), 216 deletions(-)
--
2.30.0.296.g2bfb1c46d8-goog
More information about the U-Boot
mailing list