Skip to content
  • Patrick Delaunay's avatar
    gpio: add support of new GPIO direction flag · 477ca57b
    Patrick Delaunay authored and Tom Rini's avatar Tom Rini committed
    
    
    This commit manages the new dir flags that can be used in gpio
    specifiers to indicate the pull-up or pull-down resistor
    configuration for output gpio (GPIO_PULL_UP, GPIO_PULL_DOWN)
    or the Open Drain/Open Source configuration for input gpio
    (GPIO_OPEN_DRAIN, GPIO_OPEN_SOURCE).
    
    These flags are already supported in Linux kernel in gpio lib.
    
    This patch only parse and save the direction flags in GPIO
    descriptor (desc->flags), it prepares the introduction of new ops
    to manage them.
    The GPIO uclass supports new GPIO flags from device-tree
    (GPIO_XXX define in include/dt-bindings/gpio/gpio.h)
    and translate them in the dir flags (GPIOD_XXX):
    - GPIO_PULL_UP     => GPIOD_PULL_UP
    - GPIO_PULL_DOWN   => GPIOD_PULL_DOWN
    - GPIO_OPEN_DRAIN  => GPIOD_OPEN_DRAIN
    - GPIO_OPEN_SOURCE => GPIOD_OPEN_SOURCE
    
    This patch also adds protection in the check_dir_flags function for
    new invalid configuration of the dir flags.
    
    Signed-off-by: default avatarPatrick Delaunay <patrick.delaunay@st.com>
    Reviewed-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
    477ca57b