* [PATCH 0/3] gpio: update gpio_get_status()
@ 2022-08-02 9:09 Patrice Chotard
2022-08-02 9:09 ` [PATCH 1/3] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function Patrice Chotard
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Patrice Chotard @ 2022-08-02 9:09 UTC (permalink / raw)
To: u-boot
Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Andrew Jeffery,
Eddie James, Heinrich Schuchardt, Samuel Holland, Simon Glass
Currently, if pin's function is GPIOF_FUNC, only "func" if displayed
without any other information. It would be interesting, if information is
available, to indicate which pinmuxing's name is used.
Patrice Chotard (3):
gpio: Allow to print pin's label even for pin with GPIOF_FUNC function
gpio: Fix pin's status display for pin with GPIOF_UNUSED function
pinctrl: pinctrl_stm32: Populate uc_priv->name[] with pinmux node's
name
drivers/gpio/gpio-uclass.c | 18 ++++++++++++------
drivers/pinctrl/pinctrl_stm32.c | 8 ++++++--
2 files changed, 18 insertions(+), 8 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function
2022-08-02 9:09 [PATCH 0/3] gpio: update gpio_get_status() Patrice Chotard
@ 2022-08-02 9:09 ` Patrice Chotard
2022-08-02 12:41 ` Simon Glass
2022-08-02 9:09 ` [PATCH 2/3] gpio: Fix pin's status display for pin with GPIOF_UNUSED function Patrice Chotard
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Patrice Chotard @ 2022-08-02 9:09 UTC (permalink / raw)
To: u-boot
Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Andrew Jeffery,
Eddie James, Heinrich Schuchardt, Samuel Holland, Simon Glass
Currently, if pin's function is GPIOF_FUNC, only "func" if displayed
without any other information. It would be interesting, if information is
available, to indicate which pinmuxing's name is used.
For example, for STM32 SoC's based platform, "gpio status" command
output :
before
Bank GPIOZ:
GPIOZ0: unused : 0 [ ]
GPIOZ1: unused : 0 [ ]
GPIOZ2: unused : 0 [ ]
GPIOZ3: unused : 0 [ ]
GPIOZ4: func
GPIOZ5: func
GPIOZ6: unused : 0 [ ]
GPIOZ7: unused : 0 [ ]
GPIOZ8: unknown
GPIOZ9: unknown
GPIOZ10: unknown
GPIOZ11: unknown
GPIOZ12: unknown
GPIOZ13: unknown
GPIOZ14: unknown
GPIOZ15: unknown
After
Bank GPIOZ:
GPIOZ0: unused : 0 [ ]
GPIOZ1: unused : 0 [ ]
GPIOZ2: unused : 0 [ ]
GPIOZ3: unused : 0 [ ]
GPIOZ4: func i2c4-0
GPIOZ5: func i2c4-0
GPIOZ6: unused : 0 [ ]
GPIOZ7: unused : 0 [ ]
GPIOZ8: unknown
GPIOZ9: unknown
GPIOZ10: unknown
GPIOZ11: unknown
GPIOZ12: unknown
GPIOZ13: unknown
GPIOZ14: unknown
GPIOZ15: unknown
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---
drivers/gpio/gpio-uclass.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 0ed32b7217..d60e46159a 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -884,26 +884,31 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
const struct dm_gpio_ops *ops = gpio_get_ops(dev);
struct gpio_dev_priv *priv;
char *str = buf;
+ const char *label;
int func;
int ret;
int len;
+ bool used;
BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
*buf = 0;
priv = dev_get_uclass_priv(dev);
- ret = gpio_get_raw_function(dev, offset, NULL);
+ ret = gpio_get_raw_function(dev, offset, &label);
if (ret < 0)
return ret;
func = ret;
len = snprintf(str, buffsize, "%s%d: %s",
priv->bank_name ? priv->bank_name : "",
offset, gpio_function[func]);
- if (func == GPIOF_INPUT || func == GPIOF_OUTPUT ||
- func == GPIOF_UNUSED) {
- const char *label;
- bool used;
+ switch (func) {
+ case GPIOF_FUNC:
+ snprintf(str + len, buffsize - len, " %s", label ? label : "");
+ break;
+ case GPIOF_INPUT:
+ case GPIOF_OUTPUT:
+ case GPIOF_UNUSED:
ret = ops->get_value(dev, offset);
if (ret < 0)
return ret;
@@ -913,6 +918,7 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
used ? 'x' : ' ',
used ? " " : "",
label ? label : "");
+ break;
}
return 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] gpio: Fix pin's status display for pin with GPIOF_UNUSED function
2022-08-02 9:09 [PATCH 0/3] gpio: update gpio_get_status() Patrice Chotard
2022-08-02 9:09 ` [PATCH 1/3] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function Patrice Chotard
@ 2022-08-02 9:09 ` Patrice Chotard
2022-08-02 12:41 ` Simon Glass
2022-08-02 9:09 ` [PATCH 3/3] pinctrl: pinctrl_stm32: Populate uc_priv->name[] with pinmux node's name Patrice Chotard
2022-08-02 14:56 ` [PATCH 0/3] gpio: update gpio_get_status() Heinrich Schuchardt
3 siblings, 1 reply; 9+ messages in thread
From: Patrice Chotard @ 2022-08-02 9:09 UTC (permalink / raw)
To: u-boot
Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Andrew Jeffery,
Eddie James, Heinrich Schuchardt, Samuel Holland, Simon Glass
Even pin with GPIOF_UNUSED function can have a label.
The criteria to add or not a space character is linked to label not to
the used/unused status.
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---
drivers/gpio/gpio-uclass.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index d60e46159a..a00880e446 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -916,7 +916,7 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
snprintf(str + len, buffsize - len, ": %d [%c]%s%s",
ret,
used ? 'x' : ' ',
- used ? " " : "",
+ label ? " " : "",
label ? label : "");
break;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] pinctrl: pinctrl_stm32: Populate uc_priv->name[] with pinmux node's name
2022-08-02 9:09 [PATCH 0/3] gpio: update gpio_get_status() Patrice Chotard
2022-08-02 9:09 ` [PATCH 1/3] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function Patrice Chotard
2022-08-02 9:09 ` [PATCH 2/3] gpio: Fix pin's status display for pin with GPIOF_UNUSED function Patrice Chotard
@ 2022-08-02 9:09 ` Patrice Chotard
2022-08-02 14:56 ` [PATCH 0/3] gpio: update gpio_get_status() Heinrich Schuchardt
3 siblings, 0 replies; 9+ messages in thread
From: Patrice Chotard @ 2022-08-02 9:09 UTC (permalink / raw)
To: u-boot; +Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32
Populate uc_priv->name[] with pinmux node's name in order to indicate
the pinmuxing's name in case GPIO is configured in alternate.
For example, for STM32 SoC's based platform, "gpio status" command
output :
before
Bank GPIOZ:
GPIOZ0: unused : 0 [ ]
GPIOZ1: unused : 0 [ ]
GPIOZ2: unused : 0 [ ]
GPIOZ3: unused : 0 [ ]
GPIOZ4: func
GPIOZ5: func
GPIOZ6: unused : 0 [ ]
GPIOZ7: unused : 0 [ ]
GPIOZ8: unknown
GPIOZ9: unknown
GPIOZ10: unknown
GPIOZ11: unknown
GPIOZ12: unknown
GPIOZ13: unknown
GPIOZ14: unknown
GPIOZ15: unknown
After
Bank GPIOZ:
GPIOZ0: unused : 0 [ ]
GPIOZ1: unused : 0 [ ]
GPIOZ2: unused : 0 [ ]
GPIOZ3: unused : 0 [ ]
GPIOZ4: func i2c4-0
GPIOZ5: func i2c4-0
GPIOZ6: unused : 0 [ ]
GPIOZ7: unused : 0 [ ]
GPIOZ8: unknown
GPIOZ9: unknown
GPIOZ10: unknown
GPIOZ11: unknown
GPIOZ12: unknown
GPIOZ13: unknown
GPIOZ14: unknown
GPIOZ15: unknown
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---
drivers/pinctrl/pinctrl_stm32.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
index 990cd19286..b755fa42b4 100644
--- a/drivers/pinctrl/pinctrl_stm32.c
+++ b/drivers/pinctrl/pinctrl_stm32.c
@@ -257,10 +257,12 @@ static int stm32_pinctrl_probe(struct udevice *dev)
return 0;
}
-static int stm32_gpio_config(struct gpio_desc *desc,
+static int stm32_gpio_config(ofnode node,
+ struct gpio_desc *desc,
const struct stm32_gpio_ctl *ctl)
{
struct stm32_gpio_priv *priv = dev_get_priv(desc->dev);
+ struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(desc->dev);
struct stm32_gpio_regs *regs = priv->regs;
struct stm32_pinctrl_priv *ctrl_priv;
int ret;
@@ -291,6 +293,8 @@ static int stm32_gpio_config(struct gpio_desc *desc,
index = desc->offset;
clrsetbits_le32(®s->otyper, OTYPE_MSK << index, ctl->otype << index);
+ uc_priv->name[desc->offset] = strdup(ofnode_get_name(node));
+
hwspinlock_unlock(&ctrl_priv->hws);
return 0;
@@ -385,7 +389,7 @@ static int stm32_pinctrl_config(ofnode node)
if (rv)
return rv;
desc.offset = gpio_dsc.pin;
- rv = stm32_gpio_config(&desc, &gpio_ctl);
+ rv = stm32_gpio_config(node, &desc, &gpio_ctl);
log_debug("rv = %d\n\n", rv);
if (rv)
return rv;
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function
2022-08-02 9:09 ` [PATCH 1/3] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function Patrice Chotard
@ 2022-08-02 12:41 ` Simon Glass
2022-08-03 13:12 ` Patrice CHOTARD
0 siblings, 1 reply; 9+ messages in thread
From: Simon Glass @ 2022-08-02 12:41 UTC (permalink / raw)
To: Patrice Chotard
Cc: U-Boot Mailing List, Patrick DELAUNAY, U-Boot STM32,
Andrew Jeffery, Eddie James, Heinrich Schuchardt, Samuel Holland
On Tue, 2 Aug 2022 at 03:09, Patrice Chotard
<patrice.chotard@foss.st.com> wrote:
>
> Currently, if pin's function is GPIOF_FUNC, only "func" if displayed
> without any other information. It would be interesting, if information is
> available, to indicate which pinmuxing's name is used.
>
> For example, for STM32 SoC's based platform, "gpio status" command
> output :
>
> before
> Bank GPIOZ:
> GPIOZ0: unused : 0 [ ]
> GPIOZ1: unused : 0 [ ]
> GPIOZ2: unused : 0 [ ]
> GPIOZ3: unused : 0 [ ]
> GPIOZ4: func
> GPIOZ5: func
> GPIOZ6: unused : 0 [ ]
> GPIOZ7: unused : 0 [ ]
> GPIOZ8: unknown
> GPIOZ9: unknown
> GPIOZ10: unknown
> GPIOZ11: unknown
> GPIOZ12: unknown
> GPIOZ13: unknown
> GPIOZ14: unknown
> GPIOZ15: unknown
>
> After
> Bank GPIOZ:
> GPIOZ0: unused : 0 [ ]
> GPIOZ1: unused : 0 [ ]
> GPIOZ2: unused : 0 [ ]
> GPIOZ3: unused : 0 [ ]
> GPIOZ4: func i2c4-0
> GPIOZ5: func i2c4-0
> GPIOZ6: unused : 0 [ ]
> GPIOZ7: unused : 0 [ ]
> GPIOZ8: unknown
> GPIOZ9: unknown
> GPIOZ10: unknown
> GPIOZ11: unknown
> GPIOZ12: unknown
> GPIOZ13: unknown
> GPIOZ14: unknown
> GPIOZ15: unknown
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
> drivers/gpio/gpio-uclass.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
Do you think you could create a basic test for the gpio command? See
test/dm/acpi.c for an example.
Regards,
Simon
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] gpio: Fix pin's status display for pin with GPIOF_UNUSED function
2022-08-02 9:09 ` [PATCH 2/3] gpio: Fix pin's status display for pin with GPIOF_UNUSED function Patrice Chotard
@ 2022-08-02 12:41 ` Simon Glass
0 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2022-08-02 12:41 UTC (permalink / raw)
To: Patrice Chotard
Cc: U-Boot Mailing List, Patrick DELAUNAY, U-Boot STM32,
Andrew Jeffery, Eddie James, Heinrich Schuchardt, Samuel Holland
On Tue, 2 Aug 2022 at 03:09, Patrice Chotard
<patrice.chotard@foss.st.com> wrote:
>
> Even pin with GPIOF_UNUSED function can have a label.
> The criteria to add or not a space character is linked to label not to
> the used/unused status.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
> drivers/gpio/gpio-uclass.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] gpio: update gpio_get_status()
2022-08-02 9:09 [PATCH 0/3] gpio: update gpio_get_status() Patrice Chotard
` (2 preceding siblings ...)
2022-08-02 9:09 ` [PATCH 3/3] pinctrl: pinctrl_stm32: Populate uc_priv->name[] with pinmux node's name Patrice Chotard
@ 2022-08-02 14:56 ` Heinrich Schuchardt
2022-08-03 13:11 ` Patrice CHOTARD
3 siblings, 1 reply; 9+ messages in thread
From: Heinrich Schuchardt @ 2022-08-02 14:56 UTC (permalink / raw)
To: Patrice Chotard
Cc: Patrick DELAUNAY, U-Boot STM32, Andrew Jeffery, Eddie James,
Samuel Holland, Simon Glass, u-boot
On 8/2/22 11:09, Patrice Chotard wrote:
>
> Currently, if pin's function is GPIOF_FUNC, only "func" if displayed
> without any other information. It would be interesting, if information is
> available, to indicate which pinmuxing's name is used.
Maybe you can add on top of my gpio man-page patch a description of the
output fields of gpio status.
[PATCH 1/1] doc: man-page for gpio command
https://lists.denx.de/pipermail/u-boot/2022-August/490666.html
Best regards
Heinrich
>
>
> Patrice Chotard (3):
> gpio: Allow to print pin's label even for pin with GPIOF_FUNC function
> gpio: Fix pin's status display for pin with GPIOF_UNUSED function
> pinctrl: pinctrl_stm32: Populate uc_priv->name[] with pinmux node's
> name
>
> drivers/gpio/gpio-uclass.c | 18 ++++++++++++------
> drivers/pinctrl/pinctrl_stm32.c | 8 ++++++--
> 2 files changed, 18 insertions(+), 8 deletions(-)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] gpio: update gpio_get_status()
2022-08-02 14:56 ` [PATCH 0/3] gpio: update gpio_get_status() Heinrich Schuchardt
@ 2022-08-03 13:11 ` Patrice CHOTARD
0 siblings, 0 replies; 9+ messages in thread
From: Patrice CHOTARD @ 2022-08-03 13:11 UTC (permalink / raw)
To: Heinrich Schuchardt
Cc: Patrick DELAUNAY, U-Boot STM32, Andrew Jeffery, Eddie James,
Samuel Holland, Simon Glass, u-boot
Hi Heinrich
On 8/2/22 16:56, Heinrich Schuchardt wrote:
> On 8/2/22 11:09, Patrice Chotard wrote:
>>
>> Currently, if pin's function is GPIOF_FUNC, only "func" if displayed
>> without any other information. It would be interesting, if information is
>> available, to indicate which pinmuxing's name is used.
>
> Maybe you can add on top of my gpio man-page patch a description of the
> output fields of gpio status.
>
> [PATCH 1/1] doc: man-page for gpio command
> https://lists.denx.de/pipermail/u-boot/2022-August/490666.html
Yes for sure, thanks for the link
Patrice
>
> Best regards
>
> Heinrich
>
>>
>>
>> Patrice Chotard (3):
>> gpio: Allow to print pin's label even for pin with GPIOF_FUNC function
>> gpio: Fix pin's status display for pin with GPIOF_UNUSED function
>> pinctrl: pinctrl_stm32: Populate uc_priv->name[] with pinmux node's
>> name
>>
>> drivers/gpio/gpio-uclass.c | 18 ++++++++++++------
>> drivers/pinctrl/pinctrl_stm32.c | 8 ++++++--
>> 2 files changed, 18 insertions(+), 8 deletions(-)
>>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function
2022-08-02 12:41 ` Simon Glass
@ 2022-08-03 13:12 ` Patrice CHOTARD
0 siblings, 0 replies; 9+ messages in thread
From: Patrice CHOTARD @ 2022-08-03 13:12 UTC (permalink / raw)
To: Simon Glass
Cc: U-Boot Mailing List, Patrick DELAUNAY, U-Boot STM32,
Andrew Jeffery, Eddie James, Heinrich Schuchardt, Samuel Holland
Hi Simon
On 8/2/22 14:41, Simon Glass wrote:
> On Tue, 2 Aug 2022 at 03:09, Patrice Chotard
> <patrice.chotard@foss.st.com> wrote:
>>
>> Currently, if pin's function is GPIOF_FUNC, only "func" if displayed
>> without any other information. It would be interesting, if information is
>> available, to indicate which pinmuxing's name is used.
>>
>> For example, for STM32 SoC's based platform, "gpio status" command
>> output :
>>
>> before
>> Bank GPIOZ:
>> GPIOZ0: unused : 0 [ ]
>> GPIOZ1: unused : 0 [ ]
>> GPIOZ2: unused : 0 [ ]
>> GPIOZ3: unused : 0 [ ]
>> GPIOZ4: func
>> GPIOZ5: func
>> GPIOZ6: unused : 0 [ ]
>> GPIOZ7: unused : 0 [ ]
>> GPIOZ8: unknown
>> GPIOZ9: unknown
>> GPIOZ10: unknown
>> GPIOZ11: unknown
>> GPIOZ12: unknown
>> GPIOZ13: unknown
>> GPIOZ14: unknown
>> GPIOZ15: unknown
>>
>> After
>> Bank GPIOZ:
>> GPIOZ0: unused : 0 [ ]
>> GPIOZ1: unused : 0 [ ]
>> GPIOZ2: unused : 0 [ ]
>> GPIOZ3: unused : 0 [ ]
>> GPIOZ4: func i2c4-0
>> GPIOZ5: func i2c4-0
>> GPIOZ6: unused : 0 [ ]
>> GPIOZ7: unused : 0 [ ]
>> GPIOZ8: unknown
>> GPIOZ9: unknown
>> GPIOZ10: unknown
>> GPIOZ11: unknown
>> GPIOZ12: unknown
>> GPIOZ13: unknown
>> GPIOZ14: unknown
>> GPIOZ15: unknown
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>> drivers/gpio/gpio-uclass.c | 16 +++++++++++-----
>> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> Do you think you could create a basic test for the gpio command? See
> test/dm/acpi.c for an example.
OK i will send a v2 with a test
Thanks
Patrice
>
> Regards,
> Simon
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-08-03 13:12 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 9:09 [PATCH 0/3] gpio: update gpio_get_status() Patrice Chotard
2022-08-02 9:09 ` [PATCH 1/3] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function Patrice Chotard
2022-08-02 12:41 ` Simon Glass
2022-08-03 13:12 ` Patrice CHOTARD
2022-08-02 9:09 ` [PATCH 2/3] gpio: Fix pin's status display for pin with GPIOF_UNUSED function Patrice Chotard
2022-08-02 12:41 ` Simon Glass
2022-08-02 9:09 ` [PATCH 3/3] pinctrl: pinctrl_stm32: Populate uc_priv->name[] with pinmux node's name Patrice Chotard
2022-08-02 14:56 ` [PATCH 0/3] gpio: update gpio_get_status() Heinrich Schuchardt
2022-08-03 13:11 ` Patrice CHOTARD
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.