[PATCH v6 0/2] gpio: Update and simplify the uclass API

Simon Glass sjg at chromium.org
Sun Mar 21 05:29:30 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 v6:
- Use dm_gpio_clrset_flags() so that direction can be changed
- Simplify the code since masking is not needed

Changes in v5:
- Drop patches previously applied

Simon Glass (2):
  gpio: i2c-gpio: Drop use of dm_gpio_set_dir()
  gpio: Drop dm_gpio_set_dir()

 drivers/gpio/gpio-uclass.c | 11 -----------
 drivers/i2c/i2c-gpio.c     | 19 +++++++++----------
 include/asm-generic/gpio.h | 11 -----------
 3 files changed, 9 insertions(+), 32 deletions(-)

-- 
2.31.0.rc2.261.g7f71774620-goog



More information about the U-Boot mailing list