]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
gpio: tegra_gpio: convert to use set_flags
authorLukasz Majewski <lukma@nabladev.com>
Fri, 3 Oct 2025 17:44:14 +0000 (20:44 +0300)
committerSvyatoslav Ryhel <clamor95@gmail.com>
Tue, 28 Oct 2025 09:27:44 +0000 (11:27 +0200)
Convert to use set_flags operation.

For now following flags are supported:
- GPIOD_IS_AF (i.e. "alternate function").
- GPIOD_IS_IN
- GPIOD_IS_OUT

Tested-by: Ɓukasz Majewski <lukma@nabladev.com> # Colibri T30
Signed-off-by: Lukasz Majewski <lukma@nabladev.com>
Reviewed-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
drivers/gpio/tegra_gpio.c

index 3d1e18854f272d77ec5905bd17b3105615d8a130..c61419ef9803cd5f41b397e4299c4eb4e1d0b452 100644 (file)
@@ -182,21 +182,6 @@ static int tegra_gpio_get_value(struct udevice *dev, unsigned offset)
        return (val >> GPIO_BIT(gpio)) & 1;
 }
 
-/* write GPIO OUT value to pin 'gpio' */
-static int tegra_gpio_set_value(struct udevice *dev, unsigned offset, int value)
-{
-       struct tegra_port_info *state = dev_get_priv(dev);
-       int gpio = state->base_gpio + offset;
-
-       debug("gpio_set_value: pin = %d (port %d:bit %d), value = %d\n",
-             gpio, GPIO_FULLPORT(gpio), GPIO_BIT(gpio), value);
-
-       /* Configure GPIO output value. */
-       set_level(gpio, value);
-
-       return 0;
-}
-
 void gpio_config_table(const struct tegra_gpio_config *config, int len)
 {
        int i;
@@ -258,11 +243,30 @@ 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 = %lx\n",
+             gpio, GPIO_FULLPORT(gpio), GPIO_BIT(gpio), flags);
+
+       if (flags & GPIOD_IS_AF) {
+               return tegra_gpio_rfree(dev, offset);
+       } 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 0;
+}
+
 static const struct dm_gpio_ops gpio_tegra_ops = {
-       .direction_input        = tegra_gpio_direction_input,
-       .direction_output       = tegra_gpio_direction_output,
+       .set_flags              = tegra_gpio_set_flags,
        .get_value              = tegra_gpio_get_value,
-       .set_value              = tegra_gpio_set_value,
        .get_function           = tegra_gpio_get_function,
        .xlate                  = tegra_gpio_xlate,
        .rfree                  = tegra_gpio_rfree,