Hi Svyatoslav, > пт, 19 вер. 2025 р. о 13:11 Lukasz Majewski <[email protected]> пише: > > > > 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.
Sorry, but the commit message is a pretty nice form of the documentation. For example when you come back to a project, after a few years each extra sentence is priceless. > > > Signed-off-by: Lukasz Majewski <[email protected]> > > --- > > 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 It was compiling, but I will double check it. > > > + 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. > Ok. > > }; > > > > /* > > -- > > 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@c8000400: 1, sdhci@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 Apparently, some flags are not yet supported - like GPIOD_PULL_UP/DOWN or GPIOD_OPEN_DRAIN. Is this the one from u-boot/board/lg/star/star.c function star_fix_panel()? Or is it somewhere else - for example in drivers/i2c/i2c-gpio.c ? For the latter it looks like I do support all the required flags. At least on my Colibri T30 it works correctly - so extra help is appreciated. -- Best regards, Lukasz Majewski -- Nabla Software Engineering GmbH HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschftsfhrer : Stefano Babic

