arm: gpio: Add set_flags callback to the Tegra gpio driver
Subsystems (2)
PATCH v2 1/1 arm: gpio: Add set_flags callback to the Tegra gpio driver
This patch adds support for the .set_flags callback. For now following flags are supported:
- GPIOD_IS_AF (i.e. "alternate function").
- GPIOD_IS_IN
- GPIOD_IS_OUT
Currently, the .set_flags in gpio-uclass.c (function dm_gpio_set_value()) is used before .set_value callback, so functionally replaces it. As a result the corresponding tegra_gpio_set_value() can be removed.
---
Changes for v2:
- Fix the format specifier for flags in debug() function
- Update commit message
- Remove tegra_gpio_set_value() method (as it is functionally replaced by set_value()
- Prevent from returning errors when flags = 0 (problem with e.g. I2C GPIO support)
--- drivers/gpio/tegra_gpio.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/gpio/tegra_gpio.c +23 -16
@@ -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,14 +243,36 @@ 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 = 0x%lx\n" , + gpio,GPIO_FULLPORT (gpio),GPIO_BIT (gpio), flags); + +if (flags &GPIOD_IS_AF ) { +set_config (gpio,CFG_SFIO ); + }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, .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, + .set_flags = tegra_gpio_set_flags, };/*
Signature · 1 line
2.39.5
пн, 22 вер. 2025 р. о 17:16 Lukasz Majewski <[email protected]> пише:
Quoted 21 lines
This patch adds support for the .set_flags callback. For now following flags are supported:
-GPIOD_IS_AF(i.e. "alternate function").
-GPIOD_IS_IN
-GPIOD_IS_OUTCurrently, the .set_flags in
gpio-uclass.c(functiondm_gpio_set_value()) is used before .set_value callback, so functionally replaces it. As a result the correspondingtegra_gpio_set_value()can be removed.Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:
- Fix the format specifier for flags indebug()function
- Update commit message
- Removetegra_gpio_set_value()method (as it is functionally replaced byset_value()
- Prevent from returning errors when flags = 0 (problem with e.g. I2C GPIO support)
Quoted 4 lines
--- drivers/gpio/tegra_gpio.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
Lukasz, thank you for this change I would really like to see it in mainline. ATM I have no capabilities to debug this and I will return to it but that may not be soon unfortunately. In case you really need switch GPIO back to SFIO and Linux cannot handle this, you an use dm_gpio_free to release gpios in board_preboot_os in the board as a temporary measure.
Overall issue you are describing is not u-boot's it is kernels, kernel must reconfigure gpios for proper work regardless of their previous state. If it is not the case, then kernel device configuration is incomplete or wrong.
Hi Svyatoslav,
Quoted 28 lines
пн, 22 вер. 2025 р. о 17:16 Lukasz Majewski <[email protected]> пише:
Quoted 22 lines
This patch adds support for the .set_flags callback. For now following flags are supported:
-GPIOD_IS_AF(i.e. "alternate function").
-GPIOD_IS_IN
-GPIOD_IS_OUTCurrently, the .set_flags in
gpio-uclass.c(functiondm_gpio_set_value()) is used before .set_value callback, so functionally replaces it. As a result the correspondingtegra_gpio_set_value()can be removed.Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:
- Fix the format specifier for flags indebug()function
- Update commit message
- Removetegra_gpio_set_value()method (as it is functionally replaced byset_value()
- Prevent from returning errors when flags = 0 (problem with e.g. I2C GPIO support)Quoted 4 lines
--- drivers/gpio/tegra_gpio.c | 39+++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
Quoted 2 lines
Lukasz, thank you for this change I would really like to see it in mainline. ATM I have no capabilities to debug
You mean test if it works?
Quoted 2 lines
this and I will return
to it but that may not be soon unfortunately.
This is a bit problematic for me, as:
1. Some future work depends on it (more details below).
2. The "set_flags()" callback seems like being now the one to be advised to being implemented and used.
Can you predict when you will be able to come back to this task? Is this the matter of weeks or months?
Quoted 4 lines
In case you really need
switch GPIO back to SFIO and Linux cannot handle this, you an usedm_gpio_freeto release gpios inboard_preboot_osin the board as a temporary measure.
Yes, this is a temporary solution - i.e. dm_gpio_free() is supposed to "free" the pin. IMHO, the set_flags() shall be used, as I in fact do want to set the CFG_SFIO flag, not release the gpio.
Quoted 5 lines
Overall issue you are describing is not u-boot's it is kernels, kernel must reconfigure gpios for proper work regardless of their previous state. If it is not the case, then kernel device configuration is incomplete or wrong.
This is how the pinmux in Linux for Tegra is written. You can setup the PAD parameters, but you cannot set the pin's function.
In other words - you have to do it in bootloader (u-boot in this case).
In my case - customer uses the pin in u-boot as GPIO to check carrier board version, then the same pin in Linux is going to be used as special function one.
Unfortunately, above "reconfiguration" cannot be done in Linux.
As other "rework" of gpio code depends on it (use dm) - I would like to postpone my work until this functionality is available in mainline (and hence avoid "temporal solutions").
Signature · 10 lines
Best regards, Lukasz Majewski -- Nabla Software Engineering GmbH HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschftsfhrer : Stefano Babic
пн, 29 вер. 2025 р. о 10:23 Łukasz Majewski <[email protected]> пише:
Quoted 41 lines
Hi Svyatoslav,
Quoted 28 lines
пн, 22 вер. 2025 р. о 17:16 Lukasz Majewski <[email protected]> пише:
Quoted 22 lines
This patch adds support for the .set_flags callback. For now following flags are supported:
-GPIOD_IS_AF(i.e. "alternate function").
-GPIOD_IS_IN
-GPIOD_IS_OUTCurrently, the .set_flags in
gpio-uclass.c(functiondm_gpio_set_value()) is used before .set_value callback, so functionally replaces it. As a result the correspondingtegra_gpio_set_value()can be removed.Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:
- Fix the format specifier for flags indebug()function
- Update commit message
- Removetegra_gpio_set_value()method (as it is functionally replaced byset_value()
- Prevent from returning errors when flags = 0 (problem with e.g. I2C GPIO support)Quoted 4 lines
--- drivers/gpio/tegra_gpio.c | 39+++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
Quoted 2 lines
Lukasz, thank you for this change I would really like to see it in mainline. ATM I have no capabilities to debug
You mean test if it works?
Quoted 2 lines
this and I will return
to it but that may not be soon unfortunately.This is a bit problematic for me, as:
Quoted 9 lines
1. Some future work depends on it (more details below).
2. The "set_flags()" callback seems like being now the one to be advised to being implemented and used.Can you predict when you will be able to come back to this task? Is this the matter of weeks or months?
Weeks maybe, I will try to look into this when I have some spare time
Quoted 9 lines
Quoted 4 lines
In case you really need
switch GPIO back to SFIO and Linux cannot handle this, you an usedm_gpio_freeto release gpios inboard_preboot_osin the board as a temporary measure.Yes, this is a temporary solution - i.e.
dm_gpio_free()is supposed to "free" the pin. IMHO, theset_flags()shall be used, as I in fact do want to set theCFG_SFIOflag, not release the gpio.
dm_gpio_free in tegra case calls CFG_SFIO
Quoted 9 lines
Quoted 5 lines
Overall issue you are describing is not u-boot's it is kernels, kernel must reconfigure gpios for proper work regardless of their previous state. If it is not the case, then kernel device configuration is incomplete or wrong.
This is how the pinmux in Linux for Tegra is written. You can setup the PAD parameters, but you cannot set the pin's function.
WDYM? Tegra30+ has per-pin configuration, this includes FUNCTION, direction, tristate and pull for all pins
Quoted 23 lines
In other words - you have to do it in bootloader (u-boot in this case).
In my case - customer uses the pin in u-boot as GPIO to check carrier board version, then the same pin in Linux is going to be used as special function one.
Unfortunately, above "reconfiguration" cannot be done in Linux.
As other "rework" of gpio code depends on it (use dm) - I would like to postpone my work until this functionality is available in mainline (and hence avoid "temporal solutions").
--
Best regards,Lukasz Majewski
--
Nabla Software Engineering GmbH
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: [email protected]
Geschftsfhrer : Stefano Babic
Hi Svyatoslav,
Quoted 49 lines
пн, 29 вер. 2025 р. о 10:23 Łukasz Majewski <[email protected]> пише:
Quoted 48 lines
Hi Svyatoslav,
Quoted 29 lines
пн, 22 вер. 2025 р. о 17:16 Lukasz Majewski <[email protected]> пише:
Quoted 22 lines
This patch adds support for the .set_flags callback. For now following flags are supported:
-GPIOD_IS_AF(i.e. "alternate function").
-GPIOD_IS_IN
-GPIOD_IS_OUTCurrently, the .set_flags in
gpio-uclass.c(functiondm_gpio_set_value()) is used before .set_value callback, so functionally replaces it. As a result the correspondingtegra_gpio_set_value()can be removed.Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:
- Fix the format specifier for flags indebug()function
- Update commit message
- Removetegra_gpio_set_value()method (as it is functionally replaced byset_value()
- Prevent from returning errors when flags = 0 (problem with e.g. I2C GPIO support)Quoted 4 lines
--- drivers/gpio/tegra_gpio.c | 39+++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
Quoted 2 lines
Lukasz, thank you for this change I would really like to see it in mainline. ATM I have no capabilities to debug
You mean test if it works?
Quoted 2 lines
this and I will return
to it but that may not be soon unfortunately.This is a bit problematic for me, as:
1. Some future work depends on it (more details below).
2. The "set_flags()" callback seems like being now the one to be advised to being implemented and used.
Quoted 6 lines
Quoted 3 lines
Can you predict when you will be able to come back to this task? Is this the matter of weeks or months?
Weeks maybe, I will try to look into this when I have some spare time
Ok.
Quoted 11 lines
Quoted 9 lines
Quoted 4 lines
In case you really need
switch GPIO back to SFIO and Linux cannot handle this, you an usedm_gpio_freeto release gpios inboard_preboot_osin the board as a temporary measure.Yes, this is a temporary solution - i.e.
dm_gpio_free()is supposed to "free" the pin. IMHO, theset_flags()shall be used, as I in fact do want to set theCFG_SFIOflag, not release the gpio.
dm_gpio_freein tegra case callsCFG_SFIO
Yes, but as you said - this is not the "proper" solution.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Overall issue you are describing is not u-boot's it is kernels, kernel must reconfigure gpios for proper work regardless of their previous state. If it is not the case, then kernel device configuration is incomplete or wrong.
Quoted 6 lines
Quoted 3 lines
This is how the pinmux in Linux for Tegra is written. You can setup the PAD parameters, but you cannot set the pin's function.
WDYM? Tegra30+ has per-pin configuration, this includes FUNCTION, direction, tristate and pull for all pins
With DTS pinmux description, you cannot change the PAD function (special vs gpio) in Linux. It is assumed that bootloader would set the function (which, yes, is IMHO a bug).
Quoted 25 lines
Quoted 25 lines
In other words - you have to do it in bootloader (u-boot in this case).
In my case - customer uses the pin in u-boot as GPIO to check carrier board version, then the same pin in Linux is going to be used as special function one.
Unfortunately, above "reconfiguration" cannot be done in Linux.
As other "rework" of gpio code depends on it (use dm) - I would like to postpone my work until this functionality is available in mainline (and hence avoid "temporal solutions").
--
Best regards,Lukasz Majewski
--
Nabla Software Engineering GmbH
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: [email protected]
Geschftsfhrer : Stefano Babic
Signature · 10 lines
Best regards, Lukasz Majewski -- Nabla Software Engineering GmbH HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschftsfhrer : Stefano Babic
пн, 29 вер. 2025 р. о 13:22 Łukasz Majewski <[email protected]> пише:
Quoted 86 lines
Hi Svyatoslav,
Quoted 49 lines
пн, 29 вер. 2025 р. о 10:23 Łukasz Majewski <[email protected]> пише:
Quoted 48 lines
Hi Svyatoslav,
Quoted 29 lines
пн, 22 вер. 2025 р. о 17:16 Lukasz Majewski <[email protected]> пише:
Quoted 22 lines
This patch adds support for the .set_flags callback. For now following flags are supported:
-GPIOD_IS_AF(i.e. "alternate function").
-GPIOD_IS_IN
-GPIOD_IS_OUTCurrently, the .set_flags in
gpio-uclass.c(functiondm_gpio_set_value()) is used before .set_value callback, so functionally replaces it. As a result the correspondingtegra_gpio_set_value()can be removed.Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:
- Fix the format specifier for flags indebug()function
- Update commit message
- Removetegra_gpio_set_value()method (as it is functionally replaced byset_value()
- Prevent from returning errors when flags = 0 (problem with e.g. I2C GPIO support)Quoted 4 lines
--- drivers/gpio/tegra_gpio.c | 39+++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
Quoted 2 lines
Lukasz, thank you for this change I would really like to see it in mainline. ATM I have no capabilities to debug
You mean test if it works?
Quoted 2 lines
this and I will return
to it but that may not be soon unfortunately.This is a bit problematic for me, as:
1. Some future work depends on it (more details below).
2. The "set_flags()" callback seems like being now the one to be advised to being implemented and used.Quoted 6 lines
Quoted 3 lines
Can you predict when you will be able to come back to this task? Is this the matter of weeks or months?
Weeks maybe, I will try to look into this when I have some spare time
Ok.
Quoted 11 lines
Quoted 9 lines
Quoted 4 lines
In case you really need
switch GPIO back to SFIO and Linux cannot handle this, you an usedm_gpio_freeto release gpios inboard_preboot_osin the board as a temporary measure.Yes, this is a temporary solution - i.e.
dm_gpio_free()is supposed to "free" the pin. IMHO, theset_flags()shall be used, as I in fact do want to set theCFG_SFIOflag, not release the gpio.
dm_gpio_freein tegra case callsCFG_SFIOYes, but as you said - this is not the "proper" solution.
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
Overall issue you are describing is not u-boot's it is kernels, kernel must reconfigure gpios for proper work regardless of their previous state. If it is not the case, then kernel device configuration is incomplete or wrong.
This is how the pinmux in Linux for Tegra is written. You can setup the PAD parameters, but you cannot set the pin's function.
Quoted 23 lines
Quoted 2 lines
WDYM? Tegra30+ has per-pin configuration, this includes FUNCTION, direction, tristate and pull for all pins
With DTS pinmux description, you cannot change the PAD function (special vs gpio) in Linux. It is assumed that bootloader would set the function (which, yes, is IMHO a bug).
Quoted 16 lines
Quoted 16 lines
In other words - you have to do it in bootloader (u-boot in this case).
In my case - customer uses the pin in u-boot as GPIO to check carrier board version, then the same pin in Linux is going to be used as special function one.
Unfortunately, above "reconfiguration" cannot be done in Linux.
As other "rework" of gpio code depends on it (use dm) - I would like to postpone my work until this functionality is available in mainline (and hence avoid "temporal solutions").
--
Best regards,
Try this https://source.denx.de/u-boot/custodians/u-boot-tegra/-/commit/d95d942b6e796429342845d153d95330f5257cdd
I have combined your v1 and v2 and added a few tweaks. It works on
star and olympus (tegra20), p895 and grouper (tegra30), tegratab and
tf701t (tegra114) and mocha (tegra124).
Łukasz Majewski
Tested-byHi Svyatoslav,
Quoted 109 lines
пн, 29 вер. 2025 р. о 13:22 Łukasz Majewski <[email protected]> пише:
Quoted 108 lines
Hi Svyatoslav,
Quoted 50 lines
пн, 29 вер. 2025 р. о 10:23 Łukasz Majewski <[email protected]> пише:
Quoted 48 lines
Hi Svyatoslav,
Quoted 29 lines
пн, 22 вер. 2025 р. о 17:16 Lukasz Majewski
<[email protected]> пише:Quoted 22 lines
This patch adds support for the .set_flags callback. For now following flags are supported:
-GPIOD_IS_AF(i.e. "alternate function").
-GPIOD_IS_IN
-GPIOD_IS_OUTCurrently, the .set_flags in
gpio-uclass.c(functiondm_gpio_set_value()) is used before .set_value callback, so functionally replaces it. As a result the correspondingtegra_gpio_set_value()can be removed.Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:
- Fix the format specifier for flags indebug()function
- Update commit message
- Removetegra_gpio_set_value()method (as it is functionally replaced byset_value()
- Prevent from returning errors when flags = 0 (problem with e.g. I2C GPIO support)Quoted 4 lines
--- drivers/gpio/tegra_gpio.c | 39+++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
Quoted 2 lines
Lukasz, thank you for this change I would really like to see it in mainline. ATM I have no capabilities to debug
You mean test if it works?
Quoted 2 lines
this and I will return
to it but that may not be soon unfortunately.This is a bit problematic for me, as:
1. Some future work depends on it (more details below).
2. The "set_flags()" callback seems like being now the one to be advised to being implemented and used.Quoted 6 lines
Quoted 3 lines
Can you predict when you will be able to come back to this task? Is this the matter of weeks or months?
Weeks maybe, I will try to look into this when I have some spare time
Ok.
Quoted 11 lines
Quoted 9 lines
Quoted 4 lines
In case you really need
switch GPIO back to SFIO and Linux cannot handle this, you an usedm_gpio_freeto release gpios inboard_preboot_osin the board as a temporary measure.Yes, this is a temporary solution - i.e.
dm_gpio_free()is supposed to "free" the pin. IMHO, theset_flags()shall be used, as I in fact do want to set theCFG_SFIOflag, not release the gpio.
dm_gpio_freein tegra case callsCFG_SFIOYes, but as you said - this is not the "proper" solution.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Overall issue you are describing is not u-boot's it is kernels, kernel must reconfigure gpios for proper work regardless of their previous state. If it is not the case, then kernel device configuration is incomplete or wrong.
Quoted 6 lines
Quoted 3 lines
This is how the pinmux in Linux for Tegra is written. You can setup the PAD parameters, but you cannot set the pin's function.
WDYM? Tegra30+ has per-pin configuration, this includes FUNCTION, direction, tristate and pull for all pins
With DTS pinmux description, you cannot change the PAD function (special vs gpio) in Linux. It is assumed that bootloader would set the function (which, yes, is IMHO a bug).
Quoted 14 lines
Quoted 14 lines
In other words - you have to do it in bootloader (u-boot in this case).
In my case - customer uses the pin in u-boot as GPIO to check carrier board version, then the same pin in Linux is going to be used as special function one.
Unfortunately, above "reconfiguration" cannot be done in Linux.
As other "rework" of gpio code depends on it (use dm) - I would like to postpone my work until this functionality is available in mainline (and hence avoid "temporal solutions").
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
--
Best regards,Try this
https://source.denx.de/u-boot/custodians/u-boot-tegra/-/commit/d95d942b6e796429342845d153d95330f5257cdd
I have combined your v1 and v2 and added a few tweaks. It works on star and olympus (tegra20), p895 and grouper (tegra30), tegratab and tf701t (tegra114) and mocha (tegra124).
I've tested it on Colibri T30. No issues observed.
Thanks for your tweaks.
Please add mine:
Signature · 10 lines
Best regards, Lukasz Majewski -- Nabla Software Engineering GmbH HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschftsfhrer : Stefano Babic
Svyatoslav Ryhel
Reviewed-byпн, 6 жовт. 2025 р. о 10:15 Łukasz Majewski <[email protected]> пише:
Quoted 121 lines
Hi Svyatoslav,
Quoted 109 lines
пн, 29 вер. 2025 р. о 13:22 Łukasz Majewski <[email protected]> пише:
Quoted 108 lines
Hi Svyatoslav,
Quoted 50 lines
пн, 29 вер. 2025 р. о 10:23 Łukasz Majewski <[email protected]> пише:
Quoted 48 lines
Hi Svyatoslav,
Quoted 29 lines
пн, 22 вер. 2025 р. о 17:16 Lukasz Majewski
<[email protected]> пише:Quoted 22 lines
This patch adds support for the .set_flags callback. For now following flags are supported:
-GPIOD_IS_AF(i.e. "alternate function").
-GPIOD_IS_IN
-GPIOD_IS_OUTCurrently, the .set_flags in
gpio-uclass.c(functiondm_gpio_set_value()) is used before .set_value callback, so functionally replaces it. As a result the correspondingtegra_gpio_set_value()can be removed.Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:
- Fix the format specifier for flags indebug()function
- Update commit message
- Removetegra_gpio_set_value()method (as it is functionally replaced byset_value()
- Prevent from returning errors when flags = 0 (problem with e.g. I2C GPIO support)Quoted 4 lines
--- drivers/gpio/tegra_gpio.c | 39+++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
Quoted 2 lines
Lukasz, thank you for this change I would really like to see it in mainline. ATM I have no capabilities to debug
You mean test if it works?
Quoted 2 lines
this and I will return
to it but that may not be soon unfortunately.This is a bit problematic for me, as:
1. Some future work depends on it (more details below).
2. The "set_flags()" callback seems like being now the one to be advised to being implemented and used.Quoted 6 lines
Quoted 3 lines
Can you predict when you will be able to come back to this task? Is this the matter of weeks or months?
Weeks maybe, I will try to look into this when I have some spare time
Ok.
Quoted 11 lines
Quoted 9 lines
Quoted 4 lines
In case you really need
switch GPIO back to SFIO and Linux cannot handle this, you an usedm_gpio_freeto release gpios inboard_preboot_osin the board as a temporary measure.Yes, this is a temporary solution - i.e.
dm_gpio_free()is supposed to "free" the pin. IMHO, theset_flags()shall be used, as I in fact do want to set theCFG_SFIOflag, not release the gpio.
dm_gpio_freein tegra case callsCFG_SFIOYes, but as you said - this is not the "proper" solution.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Overall issue you are describing is not u-boot's it is kernels, kernel must reconfigure gpios for proper work regardless of their previous state. If it is not the case, then kernel device configuration is incomplete or wrong.
Quoted 6 lines
Quoted 3 lines
This is how the pinmux in Linux for Tegra is written. You can setup the PAD parameters, but you cannot set the pin's function.
WDYM? Tegra30+ has per-pin configuration, this includes FUNCTION, direction, tristate and pull for all pins
With DTS pinmux description, you cannot change the PAD function (special vs gpio) in Linux. It is assumed that bootloader would set the function (which, yes, is IMHO a bug).
Quoted 14 lines
Quoted 14 lines
In other words - you have to do it in bootloader (u-boot in this case).
In my case - customer uses the pin in u-boot as GPIO to check carrier board version, then the same pin in Linux is going to be used as special function one.
Unfortunately, above "reconfiguration" cannot be done in Linux.
As other "rework" of gpio code depends on it (use dm) - I would like to postpone my work until this functionality is available in mainline (and hence avoid "temporal solutions").
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
--
Best regards,Try this
https://source.denx.de/u-boot/custodians/u-boot-tegra/-/commit/d95d942b6e796429342845d153d95330f5257cdd
I have combined your v1 and v2 and added a few tweaks. It works on star and olympus (tegra20), p895 and grouper (tegra30), tegratab and tf701t (tegra114) and mocha (tegra124).
Quoted 7 lines
I've tested it on Colibri T30. No issues observed.
Thanks for your tweaks.
Please add mine:
Tested-by Łukasz Majewski <[email protected]>
Applied to u-boot-tegra/staging, thank you!