[U-Boot] [PATCH 1/3] gpio: omap_gpio: Add xlate function to support GPIO_ACTIVE_LOW
Jean-Jacques Hiblot
jjhiblot at ti.com
Wed Sep 5 12:29:26 UTC 2018
Adam,
On 05/09/2018 11:35, Adam Ford wrote:
> The gpio driver doesn't current support knowing whether or not
> GPIO is active low or high. It simply returns the value. The
> side effect of this, is that the MMC routines which check
> the status card detect or write protect must use a u-boot specific
> dts modification to enable inverting the pin values when
> GPIO_ACTIVE_LOW is used. This allows the invert option to be removed
>
> Signed-off-by: Adam Ford <aford173 at gmail.com>
>
> diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
> index 555eba2662..0ecd2f374a 100644
> --- a/drivers/gpio/omap_gpio.c
> +++ b/drivers/gpio/omap_gpio.c
> @@ -24,6 +24,7 @@
> #include <asm/io.h>
> #include <linux/errno.h>
> #include <malloc.h>
> +#include <dt-bindings/gpio/gpio.h>
>
> DECLARE_GLOBAL_DATA_PTR;
>
> @@ -275,12 +276,25 @@ static int omap_gpio_get_function(struct udevice *dev, unsigned offset)
> return GPIOF_INPUT;
> }
>
> +static int omap_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
> + struct ofnode_phandle_args *args)
> +{
> + desc->offset = args->args[0];
> +
> + if (args->args[1] & GPIO_ACTIVE_LOW)
> + desc->flags = GPIOD_ACTIVE_LOW;
> + else
> + desc->flags = 0;
> + return 0;
> +}
Do we need this ? It looks a lot like the default behaviour (see
gpio_xlate_offs_flags in gpio-uclass.c).
JJ
> Do we need this ? It looks like the default behaviour
> static const struct dm_gpio_ops gpio_omap_ops = {
> .direction_input = omap_gpio_direction_input,
> .direction_output = omap_gpio_direction_output,
> .get_value = omap_gpio_get_value,
> .set_value = omap_gpio_set_value,
> .get_function = omap_gpio_get_function,
> + .xlate = omap_gpio_xlate,
> };
>
> static int omap_gpio_probe(struct udevice *dev)
>
More information about the U-Boot
mailing list