* [U-Boot] [PATCH] gpio: search for gpio label if gpio is not found through bank name
@ 2019-10-30 10:29 Heiko Schocher
2019-12-10 12:39 ` Simon Glass
0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2019-10-30 10:29 UTC (permalink / raw)
To: u-boot
dm_gpio_lookup_name() searches for a gpio through
the bank name. But we have also gpio labels, and it
makes sense to search for a gpio also in the labels
we have defined, if no gpio is found through the
bank name definition.
This is useful for example if you have a wp pin on
different gpios on different board versions.
If dm_gpio_lookup_name() searches also for the gpio labels,
you can give the gpio an unique label name and search
for this label, and do not need to differ between
board revisions.
Signed-off-by: Heiko Schocher <hs@denx.de>
---
Example on the aristainetos board:
=> gpio clear wp_spi_nor.gpio-hog
gpio: pin wp_spi_nor.gpio-hog (gpio 47) value is 0
=>
before this patch, you need to know where your
pin is:
=> gpio clear GPIO2_15
gpio: pin GPIO2_15 (gpio 47) value is 0
=>
travis build:
https://travis-ci.org/hsdenx/u-boot-test/builds/604290746
drivers/gpio/gpio-uclass.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 90fbed455b..755744bc00 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -79,6 +79,26 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
if (!strncasecmp(name, uc_priv->bank_name, len)) {
if (!strict_strtoul(name + len, 10, &offset))
break;
+ } else {
+ /*
+ * if we did not found a gpio through its bank
+ * name, we search for a valid gpio label.
+ */
+ bool found = 0;
+
+ len = strlen(name);
+ for (offset = 0; offset < uc_priv->gpio_count;
+ offset++) {
+ if (!uc_priv->name[offset])
+ continue;
+ if (!strncmp(name, uc_priv->name[offset],
+ len)) {
+ found = 1;
+ break;
+ }
+ }
+ if (found)
+ break;
}
}
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] gpio: search for gpio label if gpio is not found through bank name
2019-10-30 10:29 [U-Boot] [PATCH] gpio: search for gpio label if gpio is not found through bank name Heiko Schocher
@ 2019-12-10 12:39 ` Simon Glass
2020-01-14 9:29 ` Heiko Schocher
0 siblings, 1 reply; 4+ messages in thread
From: Simon Glass @ 2019-12-10 12:39 UTC (permalink / raw)
To: u-boot
Hi Heiko,
On Wed, 30 Oct 2019 at 04:29, Heiko Schocher <hs@denx.de> wrote:
>
> dm_gpio_lookup_name() searches for a gpio through
> the bank name. But we have also gpio labels, and it
> makes sense to search for a gpio also in the labels
> we have defined, if no gpio is found through the
> bank name definition.
>
> This is useful for example if you have a wp pin on
> different gpios on different board versions.
>
> If dm_gpio_lookup_name() searches also for the gpio labels,
> you can give the gpio an unique label name and search
> for this label, and do not need to differ between
> board revisions.
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
>
> Example on the aristainetos board:
>
> => gpio clear wp_spi_nor.gpio-hog
> gpio: pin wp_spi_nor.gpio-hog (gpio 47) value is 0
> =>
>
> before this patch, you need to know where your
> pin is:
>
> => gpio clear GPIO2_15
> gpio: pin GPIO2_15 (gpio 47) value is 0
> =>
>
> travis build:
> https://travis-ci.org/hsdenx/u-boot-test/builds/604290746
>
> drivers/gpio/gpio-uclass.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
Thanks for making this so clear.
I have been wondering whether this should be enabled by a CONFIG but
in fact it doesn't add much and the lookup function is only called by
those who are not using the device-tree phandle mechanism.
But I think it needs two changes:
- Move code into a separate function called from dm_gpio_lookup_name()
- Add a sandbox test for both cases
Regards,
Simon
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] gpio: search for gpio label if gpio is not found through bank name
2019-12-10 12:39 ` Simon Glass
@ 2020-01-14 9:29 ` Heiko Schocher
2020-01-30 2:18 ` Simon Glass
0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2020-01-14 9:29 UTC (permalink / raw)
To: u-boot
Hello Simon,
Am 10.12.2019 um 13:39 schrieb Simon Glass:
> Hi Heiko,
>
> On Wed, 30 Oct 2019 at 04:29, Heiko Schocher <hs@denx.de> wrote:
>>
>> dm_gpio_lookup_name() searches for a gpio through
>> the bank name. But we have also gpio labels, and it
>> makes sense to search for a gpio also in the labels
>> we have defined, if no gpio is found through the
>> bank name definition.
>>
>> This is useful for example if you have a wp pin on
>> different gpios on different board versions.
>>
>> If dm_gpio_lookup_name() searches also for the gpio labels,
>> you can give the gpio an unique label name and search
>> for this label, and do not need to differ between
>> board revisions.
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> ---
>>
>> Example on the aristainetos board:
>>
>> => gpio clear wp_spi_nor.gpio-hog
>> gpio: pin wp_spi_nor.gpio-hog (gpio 47) value is 0
>> =>
>>
>> before this patch, you need to know where your
>> pin is:
>>
>> => gpio clear GPIO2_15
>> gpio: pin GPIO2_15 (gpio 47) value is 0
>> =>
>>
>> travis build:
>> https://travis-ci.org/hsdenx/u-boot-test/builds/604290746
>>
>> drivers/gpio/gpio-uclass.c | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>
> Thanks for making this so clear.
>
> I have been wondering whether this should be enabled by a CONFIG but
> in fact it doesn't add much and the lookup function is only called by
> those who are not using the device-tree phandle mechanism. >
> But I think it needs two changes:
> - Move code into a separate function called from dm_gpio_lookup_name()
done.
> - Add a sandbox test for both cases
Do you mean to add tests in "test/dm/gpio.c" ?
Thanks!
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] gpio: search for gpio label if gpio is not found through bank name
2020-01-14 9:29 ` Heiko Schocher
@ 2020-01-30 2:18 ` Simon Glass
0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2020-01-30 2:18 UTC (permalink / raw)
To: u-boot
Hi Heiko,
On Tue, 14 Jan 2020 at 02:29, Heiko Schocher <hs@denx.de> wrote:
>
> Hello Simon,
>
> Am 10.12.2019 um 13:39 schrieb Simon Glass:
> > Hi Heiko,
> >
> > On Wed, 30 Oct 2019 at 04:29, Heiko Schocher <hs@denx.de> wrote:
> >>
> >> dm_gpio_lookup_name() searches for a gpio through
> >> the bank name. But we have also gpio labels, and it
> >> makes sense to search for a gpio also in the labels
> >> we have defined, if no gpio is found through the
> >> bank name definition.
> >>
> >> This is useful for example if you have a wp pin on
> >> different gpios on different board versions.
> >>
> >> If dm_gpio_lookup_name() searches also for the gpio labels,
> >> you can give the gpio an unique label name and search
> >> for this label, and do not need to differ between
> >> board revisions.
> >>
> >> Signed-off-by: Heiko Schocher <hs@denx.de>
> >> ---
> >>
> >> Example on the aristainetos board:
> >>
> >> => gpio clear wp_spi_nor.gpio-hog
> >> gpio: pin wp_spi_nor.gpio-hog (gpio 47) value is 0
> >> =>
> >>
> >> before this patch, you need to know where your
> >> pin is:
> >>
> >> => gpio clear GPIO2_15
> >> gpio: pin GPIO2_15 (gpio 47) value is 0
> >> =>
> >>
> >> travis build:
> >> https://travis-ci.org/hsdenx/u-boot-test/builds/604290746
> >>
> >> drivers/gpio/gpio-uclass.c | 20 ++++++++++++++++++++
> >> 1 file changed, 20 insertions(+)
> >
> > Thanks for making this so clear.
> >
> > I have been wondering whether this should be enabled by a CONFIG but
> > in fact it doesn't add much and the lookup function is only called by
> > those who are not using the device-tree phandle mechanism. >
> > But I think it needs two changes:
> > - Move code into a separate function called from dm_gpio_lookup_name()
>
> done.
>
> > - Add a sandbox test for both cases
>
> Do you mean to add tests in "test/dm/gpio.c" ?
Yes that's right.
Regards,
SImon
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-30 2:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 10:29 [U-Boot] [PATCH] gpio: search for gpio label if gpio is not found through bank name Heiko Schocher
2019-12-10 12:39 ` Simon Glass
2020-01-14 9:29 ` Heiko Schocher
2020-01-30 2:18 ` Simon Glass
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.