* [PATCH v3 0/2] gpio: add possibility to search for gpio label name @ 2020-02-05 6:19 Heiko Schocher 2020-02-05 6:19 ` [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function Heiko Schocher 2020-02-05 6:19 ` [PATCH v3 2/2] gpio: search for gpio label if gpio is not found through bank name Heiko Schocher 0 siblings, 2 replies; 13+ messages in thread From: Heiko Schocher @ 2020-02-05 6:19 UTC (permalink / raw) To: u-boot search for gpio label if gpio name from bankname is not found. This makes sense on boards with different hardware verions. You can now search for the gpio label name, and can give the gpio a unique name. The real gpio pin number is not needed in board code anymore. while at it add basic gpio hog test functions in seperate patch. Travis build: https://travis-ci.org/hsdenx/u-boot-test/builds/645826819 Changes in v3: - add comment from Simon Glass make this new function configurable through Kconfig option DM_GPIO_LOOKUP_LABEL Changes in v2: - add basic gpio hog test functions - add comment from Simon Glass move code into seperate function dm_gpio_lookup_label() add test if dm_gpio_lookup_label() works Heiko Schocher (2): sandbox, test: add test for GPIO_HOG function gpio: search for gpio label if gpio is not found through bank name arch/sandbox/dts/test.dts | 24 +++++++++++++++ configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + configs/sandbox_spl_defconfig | 1 + drivers/gpio/Kconfig | 22 ++++++++++++++ drivers/gpio/gpio-uclass.c | 47 ++++++++++++++++++++++++++++++ test/dm/gpio.c | 30 +++++++++++++++++++ 8 files changed, 127 insertions(+) -- 2.24.1 ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-02-05 6:19 [PATCH v3 0/2] gpio: add possibility to search for gpio label name Heiko Schocher @ 2020-02-05 6:19 ` Heiko Schocher 2020-02-05 17:59 ` Simon Glass 2020-04-24 17:45 ` Tom Rini 2020-02-05 6:19 ` [PATCH v3 2/2] gpio: search for gpio label if gpio is not found through bank name Heiko Schocher 1 sibling, 2 replies; 13+ messages in thread From: Heiko Schocher @ 2020-02-05 6:19 UTC (permalink / raw) To: u-boot currently gpio hog function is not tested with "ut dm gpio" so add some basic tests for gpio hog functionality. For this enable GPIO_HOG in sandbox_defconfig, add in DTS some gpio hog entries, and add testcase in "ut dm gpio" command. Signed-off-by: Heiko Schocher <hs@denx.de> --- Changes in v3: None Changes in v2: - add basic gpio hog test functions arch/sandbox/dts/test.dts | 24 ++++++++++++++++++++++++ configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + configs/sandbox_spl_defconfig | 1 + test/dm/gpio.c | 23 +++++++++++++++++++++++ 6 files changed, 51 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index e529c54d8d..cff05dcf7c 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1,5 +1,7 @@ /dts-v1/; +#include <dt-bindings/gpio/gpio.h> + / { model = "sandbox"; compatible = "sandbox"; @@ -284,6 +286,28 @@ #gpio-cells = <1>; gpio-bank-name = "a"; sandbox,gpio-count = <20>; + + hog_input_active_low { + gpio-hog; + input; + gpios = <0 GPIO_ACTIVE_LOW>; + }; + hog_input_active_high { + gpio-hog; + input; + gpios = <1 GPIO_ACTIVE_HIGH>; + }; + hog_output_low { + gpio-hog; + output-low; + gpios = <2 GPIO_ACTIVE_HIGH>; + }; + hog_output_high { + gpio-hog; + output-high; + gpios = <3 GPIO_ACTIVE_HIGH>; + }; + }; gpio_b: extra-gpios { diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 7b80033c3b..f614b23666 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -92,6 +92,7 @@ CONFIG_DM_DEMO_SIMPLE=y CONFIG_DM_DEMO_SHAPE=y CONFIG_BOARD=y CONFIG_BOARD_SANDBOX=y +CONFIG_GPIO_HOG=y CONFIG_PM8916_GPIO=y CONFIG_SANDBOX_GPIO=y CONFIG_I2C_CROS_EC_TUNNEL=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index fc018bdd2c..afce8050b4 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -108,6 +108,7 @@ CONFIG_BOARD_SANDBOX=y CONFIG_DMA=y CONFIG_DMA_CHANNELS=y CONFIG_SANDBOX_DMA=y +CONFIG_GPIO_HOG=y CONFIG_PM8916_GPIO=y CONFIG_SANDBOX_GPIO=y CONFIG_DM_HWSPINLOCK=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 2c90639ecb..0518b56fd9 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -78,6 +78,7 @@ CONFIG_DM_DEMO_SIMPLE=y CONFIG_DM_DEMO_SHAPE=y CONFIG_BOARD=y CONFIG_BOARD_SANDBOX=y +CONFIG_GPIO_HOG=y CONFIG_PM8916_GPIO=y CONFIG_SANDBOX_GPIO=y CONFIG_I2C_CROS_EC_TUNNEL=y diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index b78115af61..e70f2b4aa8 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -98,6 +98,7 @@ CONFIG_DM_DEMO_SHAPE=y CONFIG_BOARD=y CONFIG_BOARD_SANDBOX=y CONFIG_SPL_FIRMWARE=y +CONFIG_GPIO_HOG=y CONFIG_PM8916_GPIO=y CONFIG_SANDBOX_GPIO=y CONFIG_I2C_CROS_EC_TUNNEL=y diff --git a/test/dm/gpio.c b/test/dm/gpio.c index bb4b20cea9..9003ea82c7 100644 --- a/test/dm/gpio.c +++ b/test/dm/gpio.c @@ -18,6 +18,7 @@ static int dm_test_gpio(struct unit_test_state *uts) unsigned int offset, gpio; struct dm_gpio_ops *ops; struct udevice *dev; + struct gpio_desc *desc; const char *name; int offset_count; char buf[80]; @@ -102,6 +103,28 @@ static int dm_test_gpio(struct unit_test_state *uts) ut_asserteq_str("a", name); ut_asserteq(20, offset_count); + /* add gpio hog tests */ + ut_assertok(gpio_hog_lookup_name("hog_input_active_low", &desc)); + ut_asserteq(GPIOD_IS_IN | GPIOD_ACTIVE_LOW, desc->flags); + ut_asserteq(0, desc->offset); + ut_asserteq(1, dm_gpio_get_value(desc)); + ut_assertok(gpio_hog_lookup_name("hog_input_active_high", &desc)); + ut_asserteq(GPIOD_IS_IN, desc->flags); + ut_asserteq(1, desc->offset); + ut_asserteq(0, dm_gpio_get_value(desc)); + ut_assertok(gpio_hog_lookup_name("hog_output_low", &desc)); + ut_asserteq(GPIOD_IS_OUT, desc->flags); + ut_asserteq(2, desc->offset); + ut_asserteq(0, dm_gpio_get_value(desc)); + ut_assertok(dm_gpio_set_value(desc, 1)); + ut_asserteq(1, dm_gpio_get_value(desc)); + ut_assertok(gpio_hog_lookup_name("hog_output_high", &desc)); + ut_asserteq(GPIOD_IS_OUT, desc->flags); + ut_asserteq(3, desc->offset); + ut_asserteq(1, dm_gpio_get_value(desc)); + ut_assertok(dm_gpio_set_value(desc, 0)); + ut_asserteq(0, dm_gpio_get_value(desc)); + return 0; } DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -- 2.24.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-02-05 6:19 ` [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function Heiko Schocher @ 2020-02-05 17:59 ` Simon Glass 2020-04-24 17:45 ` Tom Rini 1 sibling, 0 replies; 13+ messages in thread From: Simon Glass @ 2020-02-05 17:59 UTC (permalink / raw) To: u-boot On Tue, 4 Feb 2020 at 23:20, Heiko Schocher <hs@denx.de> wrote: > > currently gpio hog function is not tested with "ut dm gpio" > so add some basic tests for gpio hog functionality. > > For this enable GPIO_HOG in sandbox_defconfig, add > in DTS some gpio hog entries, and add testcase in > "ut dm gpio" command. > > Signed-off-by: Heiko Schocher <hs@denx.de> > > --- > > Changes in v3: None > Changes in v2: > - add basic gpio hog test functions > > arch/sandbox/dts/test.dts | 24 ++++++++++++++++++++++++ > configs/sandbox64_defconfig | 1 + > configs/sandbox_defconfig | 1 + > configs/sandbox_flattree_defconfig | 1 + > configs/sandbox_spl_defconfig | 1 + > test/dm/gpio.c | 23 +++++++++++++++++++++++ > 6 files changed, 51 insertions(+) Reviewed-by: Simon Glass <sjg@chromium.org> ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-02-05 6:19 ` [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function Heiko Schocher 2020-02-05 17:59 ` Simon Glass @ 2020-04-24 17:45 ` Tom Rini 2020-04-27 5:16 ` Heiko Schocher 1 sibling, 1 reply; 13+ messages in thread From: Tom Rini @ 2020-04-24 17:45 UTC (permalink / raw) To: u-boot On Wed, Feb 05, 2020 at 07:19:58AM +0100, Heiko Schocher wrote: > currently gpio hog function is not tested with "ut dm gpio" > so add some basic tests for gpio hog functionality. > > For this enable GPIO_HOG in sandbox_defconfig, add > in DTS some gpio hog entries, and add testcase in > "ut dm gpio" command. > > Signed-off-by: Heiko Schocher <hs@denx.de> > Reviewed-by: Simon Glass <sjg@chromium.org> This no longer applies cleanly/obviously, please rebase, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200424/6affe00d/attachment.sig> ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-04-24 17:45 ` Tom Rini @ 2020-04-27 5:16 ` Heiko Schocher 2020-04-27 6:47 ` Heiko Schocher 0 siblings, 1 reply; 13+ messages in thread From: Heiko Schocher @ 2020-04-27 5:16 UTC (permalink / raw) To: u-boot Hello Tom, Am 24.04.2020 um 19:45 schrieb Tom Rini: > On Wed, Feb 05, 2020 at 07:19:58AM +0100, Heiko Schocher wrote: > >> currently gpio hog function is not tested with "ut dm gpio" >> so add some basic tests for gpio hog functionality. >> >> For this enable GPIO_HOG in sandbox_defconfig, add >> in DTS some gpio hog entries, and add testcase in >> "ut dm gpio" command. >> >> Signed-off-by: Heiko Schocher <hs@denx.de> >> Reviewed-by: Simon Glass <sjg@chromium.org> > > This no longer applies cleanly/obviously, please rebase, thanks! Done, unfortunately, aristainetos2 does not boot anymore... got: ??UBOOT (ari-ub) ? ? <> ### Connect to "aristainetos" using command: /usr/bin/telnet ts2 7015 ? ? <> Trying 192.168.1.202... ? ? <> Connected to ts2. ? ? <> Escape character is '^]'. ? ? <> <debug_uart> unrecognized JEDEC id bytes: 00, 00, 00 ? ? <> *** Warning - spi_flash_probe_bus_cs() failed, using default environment ? ? <> ? ? <> alloc space exhausted ? ? <> alloc space exhausted ? ? <> alloc space exhausted ? ? <> himport_r: can't insert "loadbootscriptUSB=ext4load usb 0 ${loadaddr} ${script};" into hash table ? ? <> alloc space exhausted ? ? <> alloc space exhausted Seems early SPI NOR detection fails ... Have to start bisect, try to find some time... 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] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-04-27 5:16 ` Heiko Schocher @ 2020-04-27 6:47 ` Heiko Schocher 2020-05-12 6:26 ` Heiko Schocher 0 siblings, 1 reply; 13+ messages in thread From: Heiko Schocher @ 2020-04-27 6:47 UTC (permalink / raw) To: u-boot Hello Tom, Patrick, Am 27.04.2020 um 07:16 schrieb Heiko Schocher: > Hello Tom, > > Am 24.04.2020 um 19:45 schrieb Tom Rini: >> On Wed, Feb 05, 2020 at 07:19:58AM +0100, Heiko Schocher wrote: >> >>> currently gpio hog function is not tested with "ut dm gpio" >>> so add some basic tests for gpio hog functionality. >>> >>> For this enable GPIO_HOG in sandbox_defconfig, add >>> in DTS some gpio hog entries, and add testcase in >>> "ut dm gpio" command. >>> >>> Signed-off-by: Heiko Schocher <hs@denx.de> >>> Reviewed-by: Simon Glass <sjg@chromium.org> >> >> This no longer applies cleanly/obviously, please rebase, thanks! > > Done, unfortunately, aristainetos2 does not boot anymore... got: > > ?? ??UBOOT (ari-ub) > ??? ???? <> ### Connect to "aristainetos" using command: /usr/bin/telnet ts2 7015 > ??? ???? <> Trying 192.168.1.202... > ??? ???? <> Connected to ts2. > ??? ???? <> Escape character is '^]'. > ??? ???? <> <debug_uart> unrecognized JEDEC id bytes: 00, 00, 00 > ??? ???? <> *** Warning - spi_flash_probe_bus_cs() failed, using default environment > ??? ???? <> > ??? ???? <> alloc space exhausted > ??? ???? <> alloc space exhausted > ??? ???? <> alloc space exhausted > ??? ???? <> himport_r: can't insert "loadbootscriptUSB=ext4load usb 0 ${loadaddr} ${script};" into > hash table > ??? ???? <> alloc space exhausted > ??? ???? <> alloc space exhausted > > Seems early SPI NOR detection fails ... > > Have to start bisect, try to find some time... Ok, commit: commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 (bisect-788ea83412) Author: Patrick Delaunay <patrick.delaunay@st.com> Date: Mon Jan 13 11:35:03 2020 +0100 gpio: add function _dm_gpio_set_dir_flags Introduce the function _dm_gpio_set_dir_flags to set dir flags without check if the GPIO is reserved. Separate the reserved check for "set_dir" and "set_dir_flags". This patch is a preliminary step to add new ops. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org> breaks the aristainetos2 board ... reverting this patch (and therefore I needed some more patches to revert as it was a patchseries): * dbf06f0e6c - (HEAD -> aristainetos-denx) Revert "gpio: add function _gpio_get_value" (vor 5 Minuten) <Heiko Schocher> * 5c85a7cc26 - Revert "gpio: add function _dm_gpio_set_dir_flags" (vor 5 Minuten) <Heiko Schocher> * c226d65d88 - Revert "gpio: add function check_dir_flags" (vor 5 Minuten) <Heiko Schocher> * 1423a40c69 - Revert "gpio: add helper GPIOD_FLAGS_OUTPUT" (vor 5 Minuten) <Heiko Schocher> * fb0176450f - Revert "gpio: update dir_flags management" (vor 5 Minuten) <Heiko Schocher> * 9d74cc5ecb - Revert "gpio: add support of new GPIO direction flag" (vor 5 Minuten) <Heiko Schocher> * 3bf361c206 - Revert "gpio: add ops to get dir flags" (vor 5 Minuten) <Heiko Schocher> * beb6d3c2d9 - Revert "gpio: add ops to set dir flags" (vor 5 Minuten) <Heiko Schocher> And board boots again fine ... I do not see, why commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 makes SPI not working anymore ... Any ideas? 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] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-04-27 6:47 ` Heiko Schocher @ 2020-05-12 6:26 ` Heiko Schocher 2020-05-12 7:32 ` Heiko Schocher 0 siblings, 1 reply; 13+ messages in thread From: Heiko Schocher @ 2020-05-12 6:26 UTC (permalink / raw) To: u-boot Hello Tom, Patrick, Am 27.04.2020 um 08:47 schrieb Heiko Schocher: > Hello Tom, Patrick, > > Am 27.04.2020 um 07:16 schrieb Heiko Schocher: >> Hello Tom, >> >> Am 24.04.2020 um 19:45 schrieb Tom Rini: >>> On Wed, Feb 05, 2020 at 07:19:58AM +0100, Heiko Schocher wrote: >>> >>>> currently gpio hog function is not tested with "ut dm gpio" >>>> so add some basic tests for gpio hog functionality. >>>> >>>> For this enable GPIO_HOG in sandbox_defconfig, add >>>> in DTS some gpio hog entries, and add testcase in >>>> "ut dm gpio" command. >>>> >>>> Signed-off-by: Heiko Schocher <hs@denx.de> >>>> Reviewed-by: Simon Glass <sjg@chromium.org> >>> >>> This no longer applies cleanly/obviously, please rebase, thanks! >> >> Done, unfortunately, aristainetos2 does not boot anymore... got: >> >> ??? ??UBOOT (ari-ub) >> ??? ???? <> ### Connect to "aristainetos" using command: /usr/bin/telnet ts2 7015 >> ??? ???? <> Trying 192.168.1.202... >> ??? ???? <> Connected to ts2. >> ??? ???? <> Escape character is '^]'. >> ??? ???? <> <debug_uart> unrecognized JEDEC id bytes: 00, 00, 00 >> ??? ???? <> *** Warning - spi_flash_probe_bus_cs() failed, using default environment >> ??? ???? <> >> ??? ???? <> alloc space exhausted >> ??? ???? <> alloc space exhausted >> ??? ???? <> alloc space exhausted >> ??? ???? <> himport_r: can't insert "loadbootscriptUSB=ext4load usb 0 ${loadaddr} ${script};" into >> hash table >> ??? ???? <> alloc space exhausted >> ??? ???? <> alloc space exhausted >> >> Seems early SPI NOR detection fails ... >> >> Have to start bisect, try to find some time... > > Ok, commit: > > commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 (bisect-788ea83412) > Author: Patrick Delaunay <patrick.delaunay@st.com> > Date:?? Mon Jan 13 11:35:03 2020 +0100 > > ??? gpio: add function _dm_gpio_set_dir_flags > > ??? Introduce the function _dm_gpio_set_dir_flags to set dir flags > ??? without check if the GPIO is reserved. > > ??? Separate the reserved check for "set_dir" and "set_dir_flags". > > ??? This patch is a preliminary step to add new ops. > > ??? Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> > ??? Reviewed-by: Simon Glass <sjg@chromium.org> > > breaks the aristainetos2 board ... reverting this patch (and therefore > I needed some more patches to revert as it was a patchseries): > > * dbf06f0e6c - (HEAD -> aristainetos-denx) Revert "gpio: add function _gpio_get_value" (vor 5 > Minuten) <Heiko Schocher> > * 5c85a7cc26 - Revert "gpio: add function _dm_gpio_set_dir_flags" (vor 5 Minuten) <Heiko Schocher> > * c226d65d88 - Revert "gpio: add function check_dir_flags" (vor 5 Minuten) <Heiko Schocher> > * 1423a40c69 - Revert "gpio: add helper GPIOD_FLAGS_OUTPUT" (vor 5 Minuten) <Heiko Schocher> > * fb0176450f - Revert "gpio: update dir_flags management" (vor 5 Minuten) <Heiko Schocher> > * 9d74cc5ecb - Revert "gpio: add support of new GPIO direction flag" (vor 5 Minuten) <Heiko Schocher> > * 3bf361c206 - Revert "gpio: add ops to get dir flags" (vor 5 Minuten) <Heiko Schocher> > * beb6d3c2d9 - Revert "gpio: add ops to set dir flags" (vor 5 Minuten) <Heiko Schocher> > > And board boots again fine ... > > I do not see, why commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 > makes SPI not working anymore ... > > Any ideas? Just looking with sandbox into it ... added debug patch: diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 3fb6b6e69c..2e68f558bd 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -273,9 +273,11 @@ static int gpio_hog_probe(struct udevice *dev) struct gpio_hog_priv *priv = dev_get_priv(dev); int ret; + printf("%s: --------- dev->name: %s nr: %d flag: %d platflags: %d\n", __func__, dev->name, plat->val[0], plat->val[1], plat->gpiod_flags); ret = gpio_dev_request_index(dev->parent, dev->name, "gpio-hog", plat->val[0], plat->gpiod_flags, plat->val[1], &priv->gpiod); + printf("%s: --------- gpiod: %p\n", __func__, &priv->gpiod); if (ret < 0) { debug("%s: node %s could not get gpio.\n", __func__, dev->name); @@ -291,6 +293,10 @@ static int gpio_hog_probe(struct udevice *dev) } } + if (1) { + struct gpio_desc *gpiod = &priv->gpiod; + printf("%s: gpiod_flags: %x\n", __func__, gpiod->flags); + } return 0; } and see: => ut dm gpio Test: dm_test_gpio: gpio.c gpio_hog_probe_all: --------- gpio_hog_probe: --------- dev->name: hog_input_active_low nr: 0 flag: 1 platflags: 4 gpio_hog_probe: --------- gpiod: 0000000015901050 gpio_hog_probe: gpiod_flags: 8 gpio_hog_probe: --------- dev->name: hog_input_active_high nr: 1 flag: 0 platflags: 4 gpio_hog_probe: --------- gpiod: 00000000159010a0 gpio_hog_probe: gpiod_flags: 0 gpio_hog_probe: --------- dev->name: hog_output_low nr: 2 flag: 0 platflags: 2 gpio_hog_probe: --------- gpiod: 00000000159010f0 gpio_hog_probe: gpiod_flags: 0 gpio_hog_probe: --------- dev->name: hog_output_high nr: 3 flag: 0 platflags: 2 gpio_hog_probe: --------- gpiod: 0000000015901130 gpio_hog_probe: gpiod_flags: 0 gpio_hog_lookup_name: name: hog_input_active_low gpio_hog_lookup_name: --------- gpiod: 15901050 test/dm/gpio.c:115, dm_test_gpio(): GPIOD_IS_IN | GPIOD_ACTIVE_LOW == desc->flags: Expected 0xc (12), got 0x8 (8) It looks like the plat->gpiod_flags are not written anymore into gpiod through the gpio_dev_request_index() function ... 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 related [flat|nested] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-05-12 6:26 ` Heiko Schocher @ 2020-05-12 7:32 ` Heiko Schocher 2020-05-14 13:47 ` Patrick DELAUNAY 0 siblings, 1 reply; 13+ messages in thread From: Heiko Schocher @ 2020-05-12 7:32 UTC (permalink / raw) To: u-boot Hello tom, Patrick, Am 12.05.2020 um 08:26 schrieb Heiko Schocher: > Hello Tom, Patrick, > > Am 27.04.2020 um 08:47 schrieb Heiko Schocher: >> Hello Tom, Patrick, >> >> Am 27.04.2020 um 07:16 schrieb Heiko Schocher: >>> Hello Tom, >>> >>> Am 24.04.2020 um 19:45 schrieb Tom Rini: >>>> On Wed, Feb 05, 2020 at 07:19:58AM +0100, Heiko Schocher wrote: >>>> >>>>> currently gpio hog function is not tested with "ut dm gpio" >>>>> so add some basic tests for gpio hog functionality. >>>>> >>>>> For this enable GPIO_HOG in sandbox_defconfig, add >>>>> in DTS some gpio hog entries, and add testcase in >>>>> "ut dm gpio" command. >>>>> >>>>> Signed-off-by: Heiko Schocher <hs@denx.de> >>>>> Reviewed-by: Simon Glass <sjg@chromium.org> >>>> >>>> This no longer applies cleanly/obviously, please rebase, thanks! >>> >>> Done, unfortunately, aristainetos2 does not boot anymore... got: >>> >>> ??? ??UBOOT (ari-ub) >>> ??? ???? <> ### Connect to "aristainetos" using command: /usr/bin/telnet ts2 7015 >>> ??? ???? <> Trying 192.168.1.202... >>> ??? ???? <> Connected to ts2. >>> ??? ???? <> Escape character is '^]'. >>> ??? ???? <> <debug_uart> unrecognized JEDEC id bytes: 00, 00, 00 >>> ??? ???? <> *** Warning - spi_flash_probe_bus_cs() failed, using default environment >>> ??? ???? <> >>> ??? ???? <> alloc space exhausted >>> ??? ???? <> alloc space exhausted >>> ??? ???? <> alloc space exhausted >>> ??? ???? <> himport_r: can't insert "loadbootscriptUSB=ext4load usb 0 ${loadaddr} ${script};" >>> into hash table >>> ??? ???? <> alloc space exhausted >>> ??? ???? <> alloc space exhausted >>> >>> Seems early SPI NOR detection fails ... >>> >>> Have to start bisect, try to find some time... >> >> Ok, commit: >> >> commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 (bisect-788ea83412) >> Author: Patrick Delaunay <patrick.delaunay@st.com> >> Date:?? Mon Jan 13 11:35:03 2020 +0100 >> >> ???? gpio: add function _dm_gpio_set_dir_flags >> >> ???? Introduce the function _dm_gpio_set_dir_flags to set dir flags >> ???? without check if the GPIO is reserved. >> >> ???? Separate the reserved check for "set_dir" and "set_dir_flags". >> >> ???? This patch is a preliminary step to add new ops. >> >> ???? Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> >> ???? Reviewed-by: Simon Glass <sjg@chromium.org> >> >> breaks the aristainetos2 board ... reverting this patch (and therefore >> I needed some more patches to revert as it was a patchseries): >> >> * dbf06f0e6c - (HEAD -> aristainetos-denx) Revert "gpio: add function _gpio_get_value" (vor 5 >> Minuten) <Heiko Schocher> >> * 5c85a7cc26 - Revert "gpio: add function _dm_gpio_set_dir_flags" (vor 5 Minuten) <Heiko Schocher> >> * c226d65d88 - Revert "gpio: add function check_dir_flags" (vor 5 Minuten) <Heiko Schocher> >> * 1423a40c69 - Revert "gpio: add helper GPIOD_FLAGS_OUTPUT" (vor 5 Minuten) <Heiko Schocher> >> * fb0176450f - Revert "gpio: update dir_flags management" (vor 5 Minuten) <Heiko Schocher> >> * 9d74cc5ecb - Revert "gpio: add support of new GPIO direction flag" (vor 5 Minuten) <Heiko Schocher> >> * 3bf361c206 - Revert "gpio: add ops to get dir flags" (vor 5 Minuten) <Heiko Schocher> >> * beb6d3c2d9 - Revert "gpio: add ops to set dir flags" (vor 5 Minuten) <Heiko Schocher> >> >> And board boots again fine ... >> >> I do not see, why commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 >> makes SPI not working anymore ... >> >> Any ideas? > > Just looking with sandbox into it ... added debug patch: > > diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c > index 3fb6b6e69c..2e68f558bd 100644 > --- a/drivers/gpio/gpio-uclass.c > +++ b/drivers/gpio/gpio-uclass.c > @@ -273,9 +273,11 @@ static int gpio_hog_probe(struct udevice *dev) > ??????? struct gpio_hog_priv *priv = dev_get_priv(dev); > ??????? int ret; > > +?????? printf("%s: --------- dev->name: %s nr: %d flag: %d platflags: %d\n", __func__, dev->name, > plat->val[0], plat->val[1], plat->gpiod_flags); > ??????? ret = gpio_dev_request_index(dev->parent, dev->name, "gpio-hog", > ???????????????????????????????????? plat->val[0], plat->gpiod_flags, > ???????????????????????????????????? plat->val[1], &priv->gpiod); > +?????? printf("%s: --------- gpiod: %p\n", __func__, &priv->gpiod); > ??????? if (ret < 0) { > ??????????????? debug("%s: node %s could not get gpio.\n", __func__, > ????????????????????? dev->name); > @@ -291,6 +293,10 @@ static int gpio_hog_probe(struct udevice *dev) > ??????????????? } > ??????? } > > +?????? if (1) { > +?????????????? struct gpio_desc *gpiod = &priv->gpiod; > +?????????????? printf("%s: gpiod_flags: %x\n", __func__, gpiod->flags); > +?????? } > ??????? return 0; > ?} > > > and see: > > => ut dm gpio > Test: dm_test_gpio: gpio.c > gpio_hog_probe_all: --------- > gpio_hog_probe: --------- dev->name: hog_input_active_low nr: 0 flag: 1 platflags: 4 > gpio_hog_probe: --------- gpiod: 0000000015901050 > gpio_hog_probe: gpiod_flags: 8 > gpio_hog_probe: --------- dev->name: hog_input_active_high nr: 1 flag: 0 platflags: 4 > gpio_hog_probe: --------- gpiod: 00000000159010a0 > gpio_hog_probe: gpiod_flags: 0 > gpio_hog_probe: --------- dev->name: hog_output_low nr: 2 flag: 0 platflags: 2 > gpio_hog_probe: --------- gpiod: 00000000159010f0 > gpio_hog_probe: gpiod_flags: 0 > gpio_hog_probe: --------- dev->name: hog_output_high nr: 3 flag: 0 platflags: 2 > gpio_hog_probe: --------- gpiod: 0000000015901130 > gpio_hog_probe: gpiod_flags: 0 > gpio_hog_lookup_name: name: hog_input_active_low > gpio_hog_lookup_name: --------- gpiod: 15901050 > test/dm/gpio.c:115, dm_test_gpio(): GPIOD_IS_IN | GPIOD_ACTIVE_LOW == desc->flags: Expected 0xc > (12), got 0x8 (8) > > It looks like the? plat->gpiod_flags are not written anymore into gpiod > through the gpio_dev_request_index() function ... Ok, I did now the following change: https://github.com/hsdenx/u-boot-test/commits/aristainetos-gpio-v4 $ git show c4a3295fa6 commit c4a3295fa67f23408ba3ff5552532222f48142f6 Author: Heiko Schocher <hs@denx.de> Date: Tue May 12 08:56:40 2020 +0200 gpio-uclass.c: save the GPIOD flags also in the gpio descriptor save the GPIOD_ flags also in the gpio descriptor. Signed-off-by: Heiko Schocher <hs@denx.de> Patch-cc: Patrick Delaunay <patrick.delaunay@st.com> Series-changes: 4 - new in version 4 diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 757ab7106e..fc94334160 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -572,6 +572,9 @@ static int _dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags) return ret; } + /* save the flags also in descriptor */ + desc->flags = flags; + /* GPIOD_ are directly managed by driver in set_dir_flags*/ if (ops->set_dir_flags) { ret = ops->set_dir_flags(dev, desc->offset, flags); and with it, the sandbox tests and the aristainetos2 board works fine again. I have just started a travis build for it: https://travis-ci.org/github/hsdenx/u-boot-test/builds/685995112 If no errors pop up, I send v4 version of my patchseries. 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 related [flat|nested] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-05-12 7:32 ` Heiko Schocher @ 2020-05-14 13:47 ` Patrick DELAUNAY 2020-05-15 6:01 ` Heiko Schocher 0 siblings, 1 reply; 13+ messages in thread From: Patrick DELAUNAY @ 2020-05-14 13:47 UTC (permalink / raw) To: u-boot Hi Heiko > From: Heiko Schocher <hs@denx.de> > Sent: mardi 12 mai 2020 09:32 > > Hello tom, Patrick, > > Am 12.05.2020 um 08:26 schrieb Heiko Schocher: > > Hello Tom, Patrick, > > > > Am 27.04.2020 um 08:47 schrieb Heiko Schocher: > >> Hello Tom, Patrick, > >> > >> Am 27.04.2020 um 07:16 schrieb Heiko Schocher: > >>> Hello Tom, > >>> > >>> Am 24.04.2020 um 19:45 schrieb Tom Rini: > >>>> On Wed, Feb 05, 2020 at 07:19:58AM +0100, Heiko Schocher wrote: > >>>> > >>>>> currently gpio hog function is not tested with "ut dm gpio" > >>>>> so add some basic tests for gpio hog functionality. > >>>>> > >>>>> For this enable GPIO_HOG in sandbox_defconfig, add in DTS some > >>>>> gpio hog entries, and add testcase in "ut dm gpio" command. > >>>>> > >>>>> Signed-off-by: Heiko Schocher <hs@denx.de> > >>>>> Reviewed-by: Simon Glass <sjg@chromium.org> > >>>> > >>>> This no longer applies cleanly/obviously, please rebase, thanks! > >>> > >>> Done, unfortunately, aristainetos2 does not boot anymore... got: > >>> > >>> ??? ??UBOOT (ari-ub) > >>> ??? ???? <> ### Connect to "aristainetos" using command: > >>> /usr/bin/telnet ts2 7015 ??? ???? <> Trying 192.168.1.202... > >>> ??? ???? <> Connected to ts2. > >>> ??? ???? <> Escape character is '^]'. > >>> ??? ???? <> <debug_uart> unrecognized JEDEC id bytes: 00, 00, 00 ? > >>> ???? <> *** Warning - spi_flash_probe_bus_cs() failed, using default > >>> environment ??? ???? <> ??? ???? <> alloc space exhausted ??? ? > >>> <> alloc space exhausted ??? ???? <> alloc space exhausted ??? ? > >>> <> himport_r: can't insert "loadbootscriptUSB=ext4load usb 0 ${loadaddr} > ${script};" > >>> into hash table > >>> ??? ???? <> alloc space exhausted > >>> ??? ???? <> alloc space exhausted > >>> > >>> Seems early SPI NOR detection fails ... > >>> > >>> Have to start bisect, try to find some time... > >> > >> Ok, commit: > >> > >> commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 (bisect-788ea83412) > >> Author: Patrick Delaunay <patrick.delaunay@st.com> > >> Date:?? Mon Jan 13 11:35:03 2020 +0100 > >> > >> ???? gpio: add function _dm_gpio_set_dir_flags > >> > >> ???? Introduce the function _dm_gpio_set_dir_flags to set dir flags > >> ???? without check if the GPIO is reserved. > >> > >> ???? Separate the reserved check for "set_dir" and "set_dir_flags". > >> > >> ???? This patch is a preliminary step to add new ops. > >> > >> ???? Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> > >> ???? Reviewed-by: Simon Glass <sjg@chromium.org> > >> > >> breaks the aristainetos2 board ... reverting this patch (and > >> therefore I needed some more patches to revert as it was a patchseries): > >> > >> * dbf06f0e6c - (HEAD -> aristainetos-denx) Revert "gpio: add function > >> _gpio_get_value" (vor 5 > >> Minuten) <Heiko Schocher> > >> * 5c85a7cc26 - Revert "gpio: add function _dm_gpio_set_dir_flags" > >> (vor 5 Minuten) <Heiko Schocher> > >> * c226d65d88 - Revert "gpio: add function check_dir_flags" (vor 5 > >> Minuten) <Heiko Schocher> > >> * 1423a40c69 - Revert "gpio: add helper GPIOD_FLAGS_OUTPUT" (vor 5 > >> Minuten) <Heiko Schocher> > >> * fb0176450f - Revert "gpio: update dir_flags management" (vor 5 > >> Minuten) <Heiko Schocher> > >> * 9d74cc5ecb - Revert "gpio: add support of new GPIO direction flag" > >> (vor 5 Minuten) <Heiko Schocher> > >> * 3bf361c206 - Revert "gpio: add ops to get dir flags" (vor 5 > >> Minuten) <Heiko Schocher> > >> * beb6d3c2d9 - Revert "gpio: add ops to set dir flags" (vor 5 > >> Minuten) <Heiko Schocher> > >> > >> And board boots again fine ... > >> > >> I do not see, why commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 > >> makes SPI not working anymore ... > >> > >> Any ideas? > > > > Just looking with sandbox into it ... added debug patch: > > > > diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c > > index 3fb6b6e69c..2e68f558bd 100644 > > --- a/drivers/gpio/gpio-uclass.c > > +++ b/drivers/gpio/gpio-uclass.c > > @@ -273,9 +273,11 @@ static int gpio_hog_probe(struct udevice *dev) > > ??????? struct gpio_hog_priv *priv = dev_get_priv(dev); > > ??????? int ret; > > > > +?????? printf("%s: --------- dev->name: %s nr: %d flag: %d platflags: > > +%d\n", __func__, dev->name, > > plat->val[0], plat->val[1], plat->gpiod_flags); > > ??????? ret = gpio_dev_request_index(dev->parent, dev->name, > > "gpio-hog", > > ???????????????????????????????????? plat->val[0], plat->gpiod_flags, > > ???????????????????????????????????? plat->val[1], &priv->gpiod); > > +?????? printf("%s: --------- gpiod: %p\n", __func__, &priv->gpiod); > > ??????? if (ret < 0) { > > ??????????????? debug("%s: node %s could not get gpio.\n", __func__, > > ????????????????????? dev->name); > > @@ -291,6 +293,10 @@ static int gpio_hog_probe(struct udevice *dev) > > ??????????????? } > > ??????? } > > > > +?????? if (1) { > > +?????????????? struct gpio_desc *gpiod = &priv->gpiod; > > +?????????????? printf("%s: gpiod_flags: %x\n", __func__, > > +gpiod->flags); > > +?????? } > > ??????? return 0; > > ?} > > > > > > and see: > > > > => ut dm gpio > > Test: dm_test_gpio: gpio.c > > gpio_hog_probe_all: --------- > > gpio_hog_probe: --------- dev->name: hog_input_active_low nr: 0 flag: > > 1 platflags: 4 > > gpio_hog_probe: --------- gpiod: 0000000015901050 > > gpio_hog_probe: gpiod_flags: 8 > > gpio_hog_probe: --------- dev->name: hog_input_active_high nr: 1 flag: > > 0 platflags: 4 > > gpio_hog_probe: --------- gpiod: 00000000159010a0 > > gpio_hog_probe: gpiod_flags: 0 > > gpio_hog_probe: --------- dev->name: hog_output_low nr: 2 flag: 0 > > platflags: 2 > > gpio_hog_probe: --------- gpiod: 00000000159010f0 > > gpio_hog_probe: gpiod_flags: 0 > > gpio_hog_probe: --------- dev->name: hog_output_high nr: 3 flag: 0 > > platflags: 2 > > gpio_hog_probe: --------- gpiod: 0000000015901130 > > gpio_hog_probe: gpiod_flags: 0 > > gpio_hog_lookup_name: name: hog_input_active_low > > gpio_hog_lookup_name: --------- gpiod: 15901050 test/dm/gpio.c:115, > > dm_test_gpio(): GPIOD_IS_IN | GPIOD_ACTIVE_LOW == desc->flags: > > Expected 0xc (12), got 0x8 (8) > > > > It looks like the? plat->gpiod_flags are not written anymore into > > gpiod through the gpio_dev_request_index() function ... > > Ok, I did now the following change: > > https://github.com/hsdenx/u-boot-test/commits/aristainetos-gpio-v4 > > $ git show c4a3295fa6 > commit c4a3295fa67f23408ba3ff5552532222f48142f6 > Author: Heiko Schocher <hs@denx.de> > Date: Tue May 12 08:56:40 2020 +0200 > > gpio-uclass.c: save the GPIOD flags also in the gpio descriptor > > save the GPIOD_ flags also in the gpio descriptor. > > Signed-off-by: Heiko Schocher <hs@denx.de> > > Patch-cc: Patrick Delaunay <patrick.delaunay@st.com> > > Series-changes: 4 > - new in version 4 > > diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index > 757ab7106e..fc94334160 100644 > --- a/drivers/gpio/gpio-uclass.c > +++ b/drivers/gpio/gpio-uclass.c > @@ -572,6 +572,9 @@ static int _dm_gpio_set_dir_flags(struct gpio_desc > *desc, ulong flags) > return ret; > } > > + /* save the flags also in descriptor */ > + desc->flags = flags; > + > /* GPIOD_ are directly managed by driver in set_dir_flags*/ > if (ops->set_dir_flags) { > ret = ops->set_dir_flags(dev, desc->offset, flags); > > and with it, the sandbox tests and the aristainetos2 board works fine again. I have > just started a travis build for it: > > https://travis-ci.org/github/hsdenx/u-boot-test/builds/685995112 > > If no errors pop up, I send v4 version of my patchseries. In my serie, normally the update of the desc->flags was done in dm_gpio_set_dir_flags() with the line /* update the descriptor flags */ if (ret) desc->flags = flags; not needed in dm_gpio_set_dir (as requested with desc->flags) At first lok, I don't understood the execution path to have desc->flags not updated... But in fact I inverse the test (again :-<) /* update the descriptor flags */ + if (!ret) - if (ret) desc->flags = flags; but this test could move in _ dm_gpio_set_deit to be more clear, but I think we need continue to test ret value before to update descriptor Sorry for the issue. Do you prefer that send a sperate patch to correct this error ? Regards Patrick ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-05-14 13:47 ` Patrick DELAUNAY @ 2020-05-15 6:01 ` Heiko Schocher 2020-05-15 7:13 ` Patrick DELAUNAY 0 siblings, 1 reply; 13+ messages in thread From: Heiko Schocher @ 2020-05-15 6:01 UTC (permalink / raw) To: u-boot Hello Patrick, Am 14.05.2020 um 15:47 schrieb Patrick DELAUNAY: > Hi Heiko > >> From: Heiko Schocher <hs@denx.de> >> Sent: mardi 12 mai 2020 09:32 >> >> Hello tom, Patrick, >> >> Am 12.05.2020 um 08:26 schrieb Heiko Schocher: >>> Hello Tom, Patrick, >>> >>> Am 27.04.2020 um 08:47 schrieb Heiko Schocher: >>>> Hello Tom, Patrick, >>>> >>>> Am 27.04.2020 um 07:16 schrieb Heiko Schocher: >>>>> Hello Tom, >>>>> >>>>> Am 24.04.2020 um 19:45 schrieb Tom Rini: >>>>>> On Wed, Feb 05, 2020 at 07:19:58AM +0100, Heiko Schocher wrote: >>>>>> >>>>>>> currently gpio hog function is not tested with "ut dm gpio" >>>>>>> so add some basic tests for gpio hog functionality. >>>>>>> >>>>>>> For this enable GPIO_HOG in sandbox_defconfig, add in DTS some >>>>>>> gpio hog entries, and add testcase in "ut dm gpio" command. >>>>>>> >>>>>>> Signed-off-by: Heiko Schocher <hs@denx.de> >>>>>>> Reviewed-by: Simon Glass <sjg@chromium.org> >>>>>> >>>>>> This no longer applies cleanly/obviously, please rebase, thanks! >>>>> >>>>> Done, unfortunately, aristainetos2 does not boot anymore... got: >>>>> >>>>> ??? ??UBOOT (ari-ub) >>>>> ??? ???? <> ### Connect to "aristainetos" using command: >>>>> /usr/bin/telnet ts2 7015 ??? ???? <> Trying 192.168.1.202... >>>>> ??? ???? <> Connected to ts2. >>>>> ??? ???? <> Escape character is '^]'. >>>>> ??? ???? <> <debug_uart> unrecognized JEDEC id bytes: 00, 00, 00 ? >>>>> ???? <> *** Warning - spi_flash_probe_bus_cs() failed, using default >>>>> environment ??? ???? <> ??? ???? <> alloc space exhausted ??? ? >>>>> <> alloc space exhausted ??? ???? <> alloc space exhausted ??? ? >>>>> <> himport_r: can't insert "loadbootscriptUSB=ext4load usb 0 ${loadaddr} >> ${script};" >>>>> into hash table >>>>> ??? ???? <> alloc space exhausted >>>>> ??? ???? <> alloc space exhausted >>>>> >>>>> Seems early SPI NOR detection fails ... >>>>> >>>>> Have to start bisect, try to find some time... >>>> >>>> Ok, commit: >>>> >>>> commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 (bisect-788ea83412) >>>> Author: Patrick Delaunay <patrick.delaunay@st.com> >>>> Date:?? Mon Jan 13 11:35:03 2020 +0100 >>>> >>>> ???? gpio: add function _dm_gpio_set_dir_flags >>>> >>>> ???? Introduce the function _dm_gpio_set_dir_flags to set dir flags >>>> ???? without check if the GPIO is reserved. >>>> >>>> ???? Separate the reserved check for "set_dir" and "set_dir_flags". >>>> >>>> ???? This patch is a preliminary step to add new ops. >>>> >>>> ???? Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> >>>> ???? Reviewed-by: Simon Glass <sjg@chromium.org> >>>> >>>> breaks the aristainetos2 board ... reverting this patch (and >>>> therefore I needed some more patches to revert as it was a patchseries): >>>> >>>> * dbf06f0e6c - (HEAD -> aristainetos-denx) Revert "gpio: add function >>>> _gpio_get_value" (vor 5 >>>> Minuten) <Heiko Schocher> >>>> * 5c85a7cc26 - Revert "gpio: add function _dm_gpio_set_dir_flags" >>>> (vor 5 Minuten) <Heiko Schocher> >>>> * c226d65d88 - Revert "gpio: add function check_dir_flags" (vor 5 >>>> Minuten) <Heiko Schocher> >>>> * 1423a40c69 - Revert "gpio: add helper GPIOD_FLAGS_OUTPUT" (vor 5 >>>> Minuten) <Heiko Schocher> >>>> * fb0176450f - Revert "gpio: update dir_flags management" (vor 5 >>>> Minuten) <Heiko Schocher> >>>> * 9d74cc5ecb - Revert "gpio: add support of new GPIO direction flag" >>>> (vor 5 Minuten) <Heiko Schocher> >>>> * 3bf361c206 - Revert "gpio: add ops to get dir flags" (vor 5 >>>> Minuten) <Heiko Schocher> >>>> * beb6d3c2d9 - Revert "gpio: add ops to set dir flags" (vor 5 >>>> Minuten) <Heiko Schocher> >>>> >>>> And board boots again fine ... >>>> >>>> I do not see, why commit 788ea834124bd6169ea10b2d37d5de48a2dd28a0 >>>> makes SPI not working anymore ... >>>> >>>> Any ideas? >>> >>> Just looking with sandbox into it ... added debug patch: >>> >>> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c >>> index 3fb6b6e69c..2e68f558bd 100644 >>> --- a/drivers/gpio/gpio-uclass.c >>> +++ b/drivers/gpio/gpio-uclass.c >>> @@ -273,9 +273,11 @@ static int gpio_hog_probe(struct udevice *dev) >>> ??????? struct gpio_hog_priv *priv = dev_get_priv(dev); >>> ??????? int ret; >>> >>> +?????? printf("%s: --------- dev->name: %s nr: %d flag: %d platflags: >>> +%d\n", __func__, dev->name, >>> plat->val[0], plat->val[1], plat->gpiod_flags); >>> ??????? ret = gpio_dev_request_index(dev->parent, dev->name, >>> "gpio-hog", >>> ???????????????????????????????????? plat->val[0], plat->gpiod_flags, >>> ???????????????????????????????????? plat->val[1], &priv->gpiod); >>> +?????? printf("%s: --------- gpiod: %p\n", __func__, &priv->gpiod); >>> ??????? if (ret < 0) { >>> ??????????????? debug("%s: node %s could not get gpio.\n", __func__, >>> ????????????????????? dev->name); >>> @@ -291,6 +293,10 @@ static int gpio_hog_probe(struct udevice *dev) >>> ??????????????? } >>> ??????? } >>> >>> +?????? if (1) { >>> +?????????????? struct gpio_desc *gpiod = &priv->gpiod; >>> +?????????????? printf("%s: gpiod_flags: %x\n", __func__, >>> +gpiod->flags); >>> +?????? } >>> ??????? return 0; >>> ?} >>> >>> >>> and see: >>> >>> => ut dm gpio >>> Test: dm_test_gpio: gpio.c >>> gpio_hog_probe_all: --------- >>> gpio_hog_probe: --------- dev->name: hog_input_active_low nr: 0 flag: >>> 1 platflags: 4 >>> gpio_hog_probe: --------- gpiod: 0000000015901050 >>> gpio_hog_probe: gpiod_flags: 8 >>> gpio_hog_probe: --------- dev->name: hog_input_active_high nr: 1 flag: >>> 0 platflags: 4 >>> gpio_hog_probe: --------- gpiod: 00000000159010a0 >>> gpio_hog_probe: gpiod_flags: 0 >>> gpio_hog_probe: --------- dev->name: hog_output_low nr: 2 flag: 0 >>> platflags: 2 >>> gpio_hog_probe: --------- gpiod: 00000000159010f0 >>> gpio_hog_probe: gpiod_flags: 0 >>> gpio_hog_probe: --------- dev->name: hog_output_high nr: 3 flag: 0 >>> platflags: 2 >>> gpio_hog_probe: --------- gpiod: 0000000015901130 >>> gpio_hog_probe: gpiod_flags: 0 >>> gpio_hog_lookup_name: name: hog_input_active_low >>> gpio_hog_lookup_name: --------- gpiod: 15901050 test/dm/gpio.c:115, >>> dm_test_gpio(): GPIOD_IS_IN | GPIOD_ACTIVE_LOW == desc->flags: >>> Expected 0xc (12), got 0x8 (8) >>> >>> It looks like the? plat->gpiod_flags are not written anymore into >>> gpiod through the gpio_dev_request_index() function ... >> >> Ok, I did now the following change: >> >> https://github.com/hsdenx/u-boot-test/commits/aristainetos-gpio-v4 >> >> $ git show c4a3295fa6 >> commit c4a3295fa67f23408ba3ff5552532222f48142f6 >> Author: Heiko Schocher <hs@denx.de> >> Date: Tue May 12 08:56:40 2020 +0200 >> >> gpio-uclass.c: save the GPIOD flags also in the gpio descriptor >> >> save the GPIOD_ flags also in the gpio descriptor. >> >> Signed-off-by: Heiko Schocher <hs@denx.de> >> >> Patch-cc: Patrick Delaunay <patrick.delaunay@st.com> >> >> Series-changes: 4 >> - new in version 4 >> >> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index >> 757ab7106e..fc94334160 100644 >> --- a/drivers/gpio/gpio-uclass.c >> +++ b/drivers/gpio/gpio-uclass.c >> @@ -572,6 +572,9 @@ static int _dm_gpio_set_dir_flags(struct gpio_desc >> *desc, ulong flags) >> return ret; >> } >> >> + /* save the flags also in descriptor */ >> + desc->flags = flags; >> + >> /* GPIOD_ are directly managed by driver in set_dir_flags*/ >> if (ops->set_dir_flags) { >> ret = ops->set_dir_flags(dev, desc->offset, flags); >> >> and with it, the sandbox tests and the aristainetos2 board works fine again. I have >> just started a travis build for it: >> >> https://travis-ci.org/github/hsdenx/u-boot-test/builds/685995112 >> >> If no errors pop up, I send v4 version of my patchseries. > > In my serie, normally the update of the desc->flags was done in dm_gpio_set_dir_flags() > > with the line > > /* update the descriptor flags */ > if (ret) > desc->flags = flags; > > not needed in dm_gpio_set_dir (as requested with desc->flags) > > At first lok, I don't understood the execution path to have desc->flags not updated... > > But in fact I inverse the test (again :-<) > > /* update the descriptor flags */ > + if (!ret) > - if (ret) > desc->flags = flags; Ok, this fix works also, thanks! > but this test could move in _ dm_gpio_set_deit to be more clear, > but I think we need continue to test ret value before to update descriptor Moved this into _dm_gpio_set_dir_flags() > Sorry for the issue. No problem, more problematic was, that I missed to add sandbox tests before and patch which adds them is pending for a while! > Do you prefer that send a sperate patch to correct this error ? I would see this in this patchseries, travis build runs, and I post v5 if all is fine, thanks! https://travis-ci.org/github/hsdenx/u-boot-test/builds/687305014 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] 13+ messages in thread
* [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function 2020-05-15 6:01 ` Heiko Schocher @ 2020-05-15 7:13 ` Patrick DELAUNAY 0 siblings, 0 replies; 13+ messages in thread From: Patrick DELAUNAY @ 2020-05-15 7:13 UTC (permalink / raw) To: u-boot Hi Heiko, > From: Heiko Schocher <hs@denx.de> > Sent: vendredi 15 mai 2020 08:01 > > Hello Patrick, > > Am 14.05.2020 um 15:47 schrieb Patrick DELAUNAY: > > Hi Heiko > > > >> From: Heiko Schocher <hs@denx.de> > >> Sent: mardi 12 mai 2020 09:32 > >> > >> Hello tom, Patrick, > >> [...] > >>> > >>> It looks like the? plat->gpiod_flags are not written anymore into > >>> gpiod through the gpio_dev_request_index() function ... > >> > >> Ok, I did now the following change: > >> > >> https://github.com/hsdenx/u-boot-test/commits/aristainetos-gpio-v4 > >> > >> $ git show c4a3295fa6 > >> commit c4a3295fa67f23408ba3ff5552532222f48142f6 > >> Author: Heiko Schocher <hs@denx.de> > >> Date: Tue May 12 08:56:40 2020 +0200 > >> > >> gpio-uclass.c: save the GPIOD flags also in the gpio descriptor > >> > >> save the GPIOD_ flags also in the gpio descriptor. > >> > >> Signed-off-by: Heiko Schocher <hs@denx.de> > >> > >> Patch-cc: Patrick Delaunay <patrick.delaunay@st.com> > >> > >> Series-changes: 4 > >> - new in version 4 > >> > >> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c > >> index > >> 757ab7106e..fc94334160 100644 > >> --- a/drivers/gpio/gpio-uclass.c > >> +++ b/drivers/gpio/gpio-uclass.c > >> @@ -572,6 +572,9 @@ static int _dm_gpio_set_dir_flags(struct > >> gpio_desc *desc, ulong flags) > >> return ret; > >> } > >> > >> + /* save the flags also in descriptor */ > >> + desc->flags = flags; > >> + > >> /* GPIOD_ are directly managed by driver in set_dir_flags*/ > >> if (ops->set_dir_flags) { > >> ret = ops->set_dir_flags(dev, desc->offset, flags); > >> > >> and with it, the sandbox tests and the aristainetos2 board works fine > >> again. I have just started a travis build for it: > >> > >> https://travis-ci.org/github/hsdenx/u-boot-test/builds/685995112 > >> > >> If no errors pop up, I send v4 version of my patchseries. > > > > In my serie, normally the update of the desc->flags was done in > > dm_gpio_set_dir_flags() > > > > with the line > > > > /* update the descriptor flags */ > > if (ret) > > desc->flags = flags; > > > > not needed in dm_gpio_set_dir (as requested with desc->flags) > > > > At first lok, I don't understood the execution path to have desc->flags not > updated... > > > > But in fact I inverse the test (again :-<) > > > > /* update the descriptor flags */ > > + if (!ret) > > - if (ret) > > desc->flags = flags; > > Ok, this fix works also, thanks! > > > but this test could move in _ dm_gpio_set_deit to be more clear, but I > > think we need continue to test ret value before to update descriptor > > Moved this into _dm_gpio_set_dir_flags() > > Sorry for the issue. > > No problem, more problematic was, that I missed to add sandbox tests before and > patch which adds them is pending for a while! > > Do you prefer that send a sperate patch to correct this error ? > > I would see this in this patchseries, travis build runs, and I post > v5 if all is fine, thanks! > > https://travis-ci.org/github/hsdenx/u-boot-test/builds/687305014 Ok, your patch is good for me. Thanks Patrick ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 2/2] gpio: search for gpio label if gpio is not found through bank name 2020-02-05 6:19 [PATCH v3 0/2] gpio: add possibility to search for gpio label name Heiko Schocher 2020-02-05 6:19 ` [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function Heiko Schocher @ 2020-02-05 6:19 ` Heiko Schocher 2020-02-05 17:59 ` Simon Glass 1 sibling, 1 reply; 13+ messages in thread From: Heiko Schocher @ 2020-02-05 6:19 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: Changes in v3: - add comment from Simon Glass make this new function configurable through Kconfig option DM_GPIO_LOOKUP_LABEL Changes in v2: - add comment from Simon Glass move code into seperate function dm_gpio_lookup_label() add test if dm_gpio_lookup_label() works drivers/gpio/Kconfig | 22 ++++++++++++++++++ drivers/gpio/gpio-uclass.c | 47 ++++++++++++++++++++++++++++++++++++++ test/dm/gpio.c | 7 ++++++ 3 files changed, 76 insertions(+) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 4e5a70780a..5614f3f828 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -46,6 +46,28 @@ config GPIO_HOG is a mechanism providing automatic GPIO request and config- uration as part of the gpio-controller's driver probe function. +config DM_GPIO_LOOKUP_LABEL + bool "Enable searching for gpio labelnames" + depends on DM_GPIO + default y + help + This option enables searching for gpio names in + the defined gpio labels, if the search for the + gpio bank name failed. This makes sense if you use + different gpios on different hardware versions + for the same functionality in board code. + +config SPL_DM_GPIO_LOOKUP_LABEL + bool "Enable searching for gpio labelnames" + depends on DM_GPIO && SPL_DM && SPL_GPIO_SUPPORT + default n + help + This option enables searching for gpio names in + the defined gpio labels, if the search for the + gpio bank name failed. This makes sense if you use + different gpios on different hardware versions + for the same functionality in board code. + config ALTERA_PIO bool "Altera PIO driver" depends on DM_GPIO diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 90fbed455b..e5c1d0d7a3 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -52,6 +52,46 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc) return ret ? ret : -ENOENT; } +#if CONFIG_IS_ENABLED(DM_GPIO_LOOKUP_LABEL) +/** + * dm_gpio_lookup_label() - look for name in gpio device + * + * search in uc_priv, if there is a gpio with labelname same + * as name. + * + * @name: name which is searched + * @uc_priv: gpio_dev_priv pointer. + * @offset: gpio offset within the device + * @return: 0 if found, -ENOENT if not. + */ +static int +dm_gpio_lookup_label(const char *name, struct gpio_dev_priv *uc_priv, + ulong *offset) +{ + int len; + int i; + + *offset = -1; + len = strlen(name); + for (i = 0; i < uc_priv->gpio_count; i++) { + if (!uc_priv->name[i]) + continue; + if (!strncmp(name, uc_priv->name[i], len)) { + *offset = i; + return 0; + } + } + return -ENOENT; +} +#else +static int +dm_gpio_lookup_label(const char *name, struct gpio_dev_priv *uc_priv, + ulong *offset) +{ + return -ENOENT; +} +#endif + int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc) { struct gpio_dev_priv *uc_priv = NULL; @@ -80,6 +120,13 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc) if (!strict_strtoul(name + len, 10, &offset)) break; } + + /* + * if we did not found a gpio through its bank + * name, we search for a valid gpio label. + */ + if (!dm_gpio_lookup_label(name, uc_priv, &offset)) + break; } if (!dev) diff --git a/test/dm/gpio.c b/test/dm/gpio.c index 9003ea82c7..1f1bf680c5 100644 --- a/test/dm/gpio.c +++ b/test/dm/gpio.c @@ -125,6 +125,13 @@ static int dm_test_gpio(struct unit_test_state *uts) ut_assertok(dm_gpio_set_value(desc, 0)); ut_asserteq(0, dm_gpio_get_value(desc)); + /* Check if lookup for labels work */ + ut_assertok(gpio_lookup_name("hog_input_active_low", &dev, &offset, + &gpio)); + ut_asserteq_str(dev->name, "base-gpios"); + ut_asserteq(0, offset); + ut_asserteq(CONFIG_SANDBOX_GPIO_COUNT + 0, gpio); + return 0; } DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -- 2.24.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 2/2] gpio: search for gpio label if gpio is not found through bank name 2020-02-05 6:19 ` [PATCH v3 2/2] gpio: search for gpio label if gpio is not found through bank name Heiko Schocher @ 2020-02-05 17:59 ` Simon Glass 0 siblings, 0 replies; 13+ messages in thread From: Simon Glass @ 2020-02-05 17:59 UTC (permalink / raw) To: u-boot On Tue, 4 Feb 2020 at 23:21, 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: > > Changes in v3: > - add comment from Simon Glass > make this new function configurable through Kconfig > option DM_GPIO_LOOKUP_LABEL > > Changes in v2: > - add comment from Simon Glass > move code into seperate function dm_gpio_lookup_label() > add test if dm_gpio_lookup_label() works > > drivers/gpio/Kconfig | 22 ++++++++++++++++++ > drivers/gpio/gpio-uclass.c | 47 ++++++++++++++++++++++++++++++++++++++ > test/dm/gpio.c | 7 ++++++ > 3 files changed, 76 insertions(+) Reviewed-by: Simon Glass <sjg@chromium.org> ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2020-05-15 7:13 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-02-05 6:19 [PATCH v3 0/2] gpio: add possibility to search for gpio label name Heiko Schocher 2020-02-05 6:19 ` [PATCH v3 1/2] sandbox, test: add test for GPIO_HOG function Heiko Schocher 2020-02-05 17:59 ` Simon Glass 2020-04-24 17:45 ` Tom Rini 2020-04-27 5:16 ` Heiko Schocher 2020-04-27 6:47 ` Heiko Schocher 2020-05-12 6:26 ` Heiko Schocher 2020-05-12 7:32 ` Heiko Schocher 2020-05-14 13:47 ` Patrick DELAUNAY 2020-05-15 6:01 ` Heiko Schocher 2020-05-15 7:13 ` Patrick DELAUNAY 2020-02-05 6:19 ` [PATCH v3 2/2] gpio: search for gpio label if gpio is not found through bank name Heiko Schocher 2020-02-05 17:59 ` 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.