]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox, test: add test for GPIO_HOG function
authorHeiko Schocher <hs@denx.de>
Fri, 22 May 2020 09:08:58 +0000 (11:08 +0200)
committerTom Rini <trini@konsulko.com>
Sun, 5 Jul 2020 12:06:09 +0000 (08:06 -0400)
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>
arch/sandbox/dts/test.dts
configs/sandbox64_defconfig
configs/sandbox_defconfig
configs/sandbox_flattree_defconfig
configs/sandbox_spl_defconfig
test/dm/gpio.c

index 5ce5e28476423a50b615ac5c5f391fbab447ab15..24bb3ce36fc2879e427fef7cb56ff152264c7041 100644 (file)
                        #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 {
index a3f049e124e1bf84a88d5335c0bb778b5dec8fe0..0f9a27c39cdc8bbf32b39263ec063aa1870f36f4 100644 (file)
@@ -97,6 +97,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
index 5b7569319b73537d9125b079c55ab9c5325b4b66..6f450aa637a482d6779a8473c94ba93dc90a334a 100644 (file)
@@ -114,6 +114,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
index 21f9047046a3c0ae0a885d77c10f184e8237d2e3..05ce9bda3790027edfc0f09bbdf74cd936060dcd 100644 (file)
@@ -82,6 +82,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
index fc8b26e88cfe51272c692584c7dc3a1cc8661dfd..f5e90f7488d8d5dffdec36df748578362d48323b 100644 (file)
@@ -101,6 +101,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
index b5ee4e4f871da1595ea67fb0d55c9264cbef63b7..ecba5669838987a445d7980c742e8699c01fb898 100644 (file)
@@ -20,6 +20,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];
@@ -109,6 +110,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);