[PATCH] arm: gpio: Add set_flags callback to the Tegra gpio driver
Svyatoslav Ryhel
clamor95 at gmail.com
Fri Sep 19 15:13:06 CEST 2025
пт, 19 вер. 2025 р. о 13:11 Lukasz Majewski <lukma at nabladev.com> пише:
>
> In some Tegra SoC (like e.g. T30) there is a possibility that one will
> configure at early boot state a pin as GPIO (to use it for e.g. carrier
> board detection). However, afterwards (i.e. in Linux) the same pin will
> be used as the special function one.
>
> Current Tegra gpio driver doesn't allow this, so callback for set_flags()
> has been defined to properly setup the GPIO when required.
Please write the commit message in the imperative mood.
> For now following flags are supported:
> - GPIOD_IS_AF (i.e. "alternate function").
> - GPIOD_IS_IN
> - GPIOD_IS_OUT
>
> In long term the tegra_gpio_set_flags() is going to replace
> direction_{input|output} callbacks.
>
It is not a book chapter, describe what the commit does briefly.
> Signed-off-by: Lukasz Majewski <lukma at nabladev.com>
> ---
> drivers/gpio/tegra_gpio.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c
> index 3d1e18854f2..1e8bd051875 100644
> --- a/drivers/gpio/tegra_gpio.c
> +++ b/drivers/gpio/tegra_gpio.c
> @@ -258,6 +258,29 @@ static int tegra_gpio_rfree(struct udevice *dev, unsigned int offset)
> return 0;
> }
>
> +static int tegra_gpio_set_flags(struct udevice *dev, unsigned int offset,
> + ulong flags)
> +{
> + struct tegra_port_info *state = dev_get_priv(dev);
> + int gpio = state->base_gpio + offset;
> +
> + debug("gpio_set_flags: pin = %d (port %d:bit %d), flag = %d\n",
> + gpio, GPIO_FULLPORT(gpio), GPIO_BIT(gpio), flags);
> +
Have you even built this code yourself? "flags" is of type ulong, not int
> + if (flags & GPIOD_IS_AF) {
> + set_config(gpio, CFG_SFIO);
> + return 0;
> + } else if (flags & GPIOD_IS_IN) {
> + return tegra_gpio_direction_input(dev, offset);
> + } else if (flags & GPIOD_IS_OUT) {
> + bool value = flags & GPIOD_IS_OUT_ACTIVE;
> +
> + return tegra_gpio_direction_output(dev, offset, value);
> + }
> +
> + return -EINVAL;
> +}
> +
> static const struct dm_gpio_ops gpio_tegra_ops = {
> .direction_input = tegra_gpio_direction_input,
> .direction_output = tegra_gpio_direction_output,
> @@ -266,6 +289,7 @@ static const struct dm_gpio_ops gpio_tegra_ops = {
> .get_function = tegra_gpio_get_function,
> .xlate = tegra_gpio_xlate,
> .rfree = tegra_gpio_rfree,
> + .set_flags = tegra_gpio_set_flags,
If you are already touching this anyway, then touch it properly. Since
set_flags op is meant to remove direction ops, then remove latter too.
> };
>
> /*
> --
> 2.39.5
>
This commit causes regression on LG P990 board, backlight is located
on gpio i2c line and with this patch gpio i2c refuses to work
(bootloader) Core: 114 devices, 27 uclasses, devicetree: separate
(bootloader) MMC: sdhci at c8000400: 1, sdhci at c8000600: 0
(bootloader) Loading Environment from MMC... Reading from MMC(0)... ***
(bootloader) Warning - bad CRC, using default environment
(bootloader)
(bootloader) Can't get i2c-5 gpios! Error: -22
(bootloader) Can't get i2c-5 gpios! Error: -16
(bootloader) In: serial,usbkbd,button-kbd
(bootloader) Out: serial,vidconsole
(bootloader) Err: serial,vidconsole
(bootloader) Net: No ethernet found.
(bootloader)
(bootloader) Autoboot in 0 seconds
More information about the U-Boot
mailing list