aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-04-17 11:08:08 -0400
committerTom Rini <trini@konsulko.com>2020-04-17 11:17:29 -0400
commit8d5d3bcf3c53d798bd7f3fe7092e994593bcc41c (patch)
treedd145ccf787512306926b0e5f327046ccfbee33c /test
parent0f238dab6d17caabe4f9781d23aaa6087139f2bd (diff)
parent65c141ebbd68b70d6934b4fb965f3219d0e99817 (diff)
Merge branch '2020-04-16-master-imports'
- DM GPIO improvements - BTRFS fixes - Corrections around gd->new_bootstage alignment - Start documentation improvements to support 'make refcheckdocs'
Diffstat (limited to 'test')
-rw-r--r--test/dm/Makefile3
-rw-r--r--test/dm/gpio.c69
-rw-r--r--test/dm/ofread.c50
-rw-r--r--test/dm/test-fdt.c2
-rw-r--r--test/py/tests/test_pinmux.py38
5 files changed, 139 insertions, 23 deletions
diff --git a/test/dm/Makefile b/test/dm/Makefile
index f55874c0f2..6c18fd04ce 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -31,8 +31,9 @@ obj-y += irq.o
obj-$(CONFIG_LED) += led.o
obj-$(CONFIG_DM_MAILBOX) += mailbox.o
obj-$(CONFIG_DM_MMC) += mmc.o
-obj-y += ofnode.o
obj-y += fdtdec.o
+obj-y += ofnode.o
+obj-y += ofread.o
obj-$(CONFIG_OSD) += osd.o
obj-$(CONFIG_DM_VIDEO) += panel.o
obj-$(CONFIG_DM_PCI) += pci.o
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index 349123a657..f5c7aaf3bc 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -24,9 +24,9 @@ static int dm_test_gpio(struct unit_test_state *uts)
char buf[80];
/*
- * We expect to get 3 banks. One is anonymous (just numbered) and
- * comes from platdata. The other two are named a (20 gpios)
- * and b (10 gpios) and come from the device tree. See
+ * We expect to get 4 banks. One is anonymous (just numbered) and
+ * comes from platdata. The other are named a (20 gpios),
+ * b (10 gpios) and c (10 gpios) and come from the device tree. See
* test/dm/test.dts.
*/
ut_assertok(gpio_lookup_name("b4", &dev, &offset, &gpio));
@@ -74,11 +74,16 @@ static int dm_test_gpio(struct unit_test_state *uts)
ut_asserteq(1, ops->get_value(dev, offset));
/* Make it an open drain output, and reset it */
- ut_asserteq(0, sandbox_gpio_get_open_drain(dev, offset));
- ut_assertok(ops->set_open_drain(dev, offset, 1));
- ut_asserteq(1, sandbox_gpio_get_open_drain(dev, offset));
- ut_assertok(ops->set_open_drain(dev, offset, 0));
- ut_asserteq(0, sandbox_gpio_get_open_drain(dev, offset));
+ ut_asserteq(GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE,
+ sandbox_gpio_get_dir_flags(dev, offset));
+ ut_assertok(ops->set_dir_flags(dev, offset,
+ GPIOD_IS_OUT | GPIOD_OPEN_DRAIN));
+ ut_asserteq(GPIOD_IS_OUT | GPIOD_OPEN_DRAIN,
+ sandbox_gpio_get_dir_flags(dev, offset));
+ ut_assertok(ops->set_dir_flags(dev, offset,
+ GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE));
+ ut_asserteq(GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE,
+ sandbox_gpio_get_dir_flags(dev, offset));
/* Make it an input */
ut_assertok(ops->direction_input(dev, offset));
@@ -215,11 +220,14 @@ static int dm_test_gpio_phandles(struct unit_test_state *uts)
desc_list2,
ARRAY_SIZE(desc_list2),
0));
+ ut_asserteq(GPIOF_INPUT, gpio_get_function(gpio_a, 4, NULL));
ut_assertok(gpio_free_list(dev, desc_list, 3));
+ ut_asserteq(GPIOF_UNUSED, gpio_get_function(gpio_a, 4, NULL));
ut_asserteq(3, gpio_request_list_by_name(dev, "test-gpios", desc_list,
ARRAY_SIZE(desc_list),
GPIOD_IS_OUT |
GPIOD_IS_OUT_ACTIVE));
+ ut_asserteq(GPIOF_OUTPUT, gpio_get_function(gpio_a, 4, NULL));
ut_asserteq_ptr(gpio_a, desc_list[0].dev);
ut_asserteq(1, desc_list[0].offset);
ut_asserteq_ptr(gpio_a, desc_list[1].dev);
@@ -229,10 +237,14 @@ static int dm_test_gpio_phandles(struct unit_test_state *uts)
ut_asserteq(1, dm_gpio_get_value(desc_list));
ut_assertok(gpio_free_list(dev, desc_list, 3));
+ ut_asserteq(GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE,
+ sandbox_gpio_get_dir_flags(gpio_a, 1));
ut_asserteq(6, gpio_request_list_by_name(dev, "test2-gpios", desc_list,
ARRAY_SIZE(desc_list), 0));
- /* This was set to output previously, so still will be */
- ut_asserteq(GPIOF_OUTPUT, gpio_get_function(gpio_a, 1, NULL));
+
+ /* This was set to output previously but flags resetted to 0 = INPUT */
+ ut_asserteq(0, sandbox_gpio_get_dir_flags(gpio_a, 1));
+ ut_asserteq(GPIOF_INPUT, gpio_get_function(gpio_a, 1, NULL));
/* Active low should invert the input value */
ut_asserteq(GPIOF_INPUT, gpio_get_function(gpio_b, 6, NULL));
@@ -244,7 +256,42 @@ static int dm_test_gpio_phandles(struct unit_test_state *uts)
ut_asserteq(GPIOF_OUTPUT, gpio_get_function(gpio_b, 9, NULL));
ut_asserteq(1, dm_gpio_get_value(&desc_list[5]));
-
return 0;
}
DM_TEST(dm_test_gpio_phandles, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Check the gpio pin configuration get from device tree information */
+static int dm_test_gpio_get_dir_flags(struct unit_test_state *uts)
+{
+ struct gpio_desc desc_list[6];
+ struct udevice *dev;
+ ulong flags;
+
+ ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
+
+ ut_asserteq(6, gpio_request_list_by_name(dev, "test3-gpios", desc_list,
+ ARRAY_SIZE(desc_list), 0));
+
+ ut_assertok(dm_gpio_get_dir_flags(&desc_list[0], &flags));
+ ut_asserteq(GPIOD_IS_OUT | GPIOD_OPEN_DRAIN, flags);
+
+ ut_assertok(dm_gpio_get_dir_flags(&desc_list[1], &flags));
+ ut_asserteq(GPIOD_IS_OUT | GPIOD_OPEN_SOURCE, flags);
+
+ ut_assertok(dm_gpio_get_dir_flags(&desc_list[2], &flags));
+ ut_asserteq(GPIOD_IS_OUT, flags);
+
+ ut_assertok(dm_gpio_get_dir_flags(&desc_list[3], &flags));
+ ut_asserteq(GPIOD_IS_IN | GPIOD_PULL_UP, flags);
+
+ ut_assertok(dm_gpio_get_dir_flags(&desc_list[4], &flags));
+ ut_asserteq(GPIOD_IS_IN | GPIOD_PULL_DOWN, flags);
+
+ ut_assertok(dm_gpio_get_dir_flags(&desc_list[5], &flags));
+ ut_asserteq(GPIOD_IS_IN, flags);
+
+ ut_assertok(gpio_free_list(dev, desc_list, 6));
+
+ return 0;
+}
+DM_TEST(dm_test_gpio_get_dir_flags, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
diff --git a/test/dm/ofread.c b/test/dm/ofread.c
new file mode 100644
index 0000000000..f2a1382259
--- /dev/null
+++ b/test/dm/ofread.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <common.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <test/ut.h>
+
+static int dm_test_ofnode_get_property_by_prop(struct unit_test_state *uts)
+{
+ ofnode node;
+ struct ofprop prop;
+ const void *value;
+ const char *propname;
+ int res, len, count = 0;
+
+ node = ofnode_path("/cros-ec/flash");
+ for (res = ofnode_get_first_property(node, &prop);
+ !res;
+ res = ofnode_get_next_property(&prop)) {
+ value = ofnode_get_property_by_prop(&prop, &propname, &len);
+ ut_assertnonnull(value);
+ switch (count) {
+ case 0:
+ ut_asserteq_str("image-pos", propname);
+ ut_asserteq(4, len);
+ break;
+ case 1:
+ ut_asserteq_str("size", propname);
+ ut_asserteq(4, len);
+ break;
+ case 2:
+ ut_asserteq_str("erase-value", propname);
+ ut_asserteq(4, len);
+ break;
+ case 3:
+ /* only for platdata */
+ ut_asserteq_str("name", propname);
+ ut_asserteq(6, len);
+ ut_asserteq_str("flash", value);
+ break;
+ default:
+ break;
+ }
+ count++;
+ }
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_get_property_by_prop,
+ DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index a56275aef9..1128c420a3 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -286,7 +286,7 @@ static int dm_test_alias_highest_id(struct unit_test_state *uts)
ut_asserteq(5, ret);
ret = dev_read_alias_highest_id("gpio");
- ut_asserteq(2, ret);
+ ut_asserteq(3, ret);
ret = dev_read_alias_highest_id("pci");
ut_asserteq(2, ret);
diff --git a/test/py/tests/test_pinmux.py b/test/py/tests/test_pinmux.py
index 25394f1faf..4e6df992a4 100644
--- a/test/py/tests/test_pinmux.py
+++ b/test/py/tests/test_pinmux.py
@@ -22,11 +22,21 @@ def test_pinmux_usage_2(u_boot_console):
def test_pinmux_status_all(u_boot_console):
"""Test that 'pinmux status -a' displays pin's muxing."""
output = u_boot_console.run_command('pinmux status -a')
- assert ('SCL : I2C SCL' in output)
- assert ('SDA : I2C SDA' in output)
- assert ('TX : Uart TX' in output)
- assert ('RX : Uart RX' in output)
- assert ('W1 : 1-wire gpio' in output)
+
+ assert ('pinctrl-gpio:' in output)
+ assert ('a5 : gpio output .' in output)
+ assert ('a6 : gpio output .' in output)
+
+ assert ('pinctrl:' in output)
+ assert ('SCL : I2C SCL.' in output)
+ assert ('SDA : I2C SDA.' in output)
+ assert ('TX : Uart TX.' in output)
+ assert ('RX : Uart RX.' in output)
+ assert ('W1 : 1-wire gpio.' in output)
+ assert ('GPIO0 : gpio bias-pull-up input-disable.' in output)
+ assert ('GPIO1 : gpio drive-open-drain.' in output)
+ assert ('GPIO2 : gpio bias-pull-down input-enable.' in output)
+ assert ('GPIO3 : gpio bias-disable.' in output)
@pytest.mark.buildconfigspec('cmd_pinmux')
@pytest.mark.boardspec('sandbox')
@@ -59,8 +69,16 @@ def test_pinmux_status(u_boot_console):
"""Test that 'pinmux status' displays selected pincontroller's pin
muxing descriptions."""
output = u_boot_console.run_command('pinmux status')
- assert ('SCL : I2C SCL' in output)
- assert ('SDA : I2C SDA' in output)
- assert ('TX : Uart TX' in output)
- assert ('RX : Uart RX' in output)
- assert ('W1 : 1-wire gpio' in output)
+
+ assert (not 'pinctrl-gpio:' in output)
+ assert (not 'pinctrl:' in output)
+
+ assert ('SCL : I2C SCL.' in output)
+ assert ('SDA : I2C SDA.' in output)
+ assert ('TX : Uart TX.' in output)
+ assert ('RX : Uart RX.' in output)
+ assert ('W1 : 1-wire gpio.' in output)
+ assert ('GPIO0 : gpio bias-pull-up input-disable.' in output)
+ assert ('GPIO1 : gpio drive-open-drain.' in output)
+ assert ('GPIO2 : gpio bias-pull-down input-enable.' in output)
+ assert ('GPIO3 : gpio bias-disable.' in output)