Message ID | 20200205061959.907501-2-hs@denx.de |
---|---|
State | Superseded |
Headers | show |
Series | gpio: add possibility to search for gpio label name | expand |
On Tue, 4 Feb 2020 at 23:20, Heiko Schocher <hs at 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 at 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 at chromium.org>
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 at denx.de> > Reviewed-by: Simon Glass <sjg at chromium.org> This no longer applies cleanly/obviously, please rebase, thanks!
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 at denx.de> >> Reviewed-by: Simon Glass <sjg at 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
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 at denx.de> >>> Reviewed-by: Simon Glass <sjg at 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 at 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 at st.com> Reviewed-by: Simon Glass <sjg at 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
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);
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 at 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(+)