aboutsummaryrefslogtreecommitdiff
path: root/test/dm/usb.c
diff options
context:
space:
mode:
authorMichael Walle2020-06-02 01:47:07 +0200
committerSimon Glass2020-06-11 20:52:11 -0600
commitc03b7612ea346ad7454086d1623fb57098faf315 (patch)
treeda4ebd8231c72e896d0de8dd9b09ea254934fa13 /test/dm/usb.c
parent77007f9543a0fac8c4f60800de6ddccfacd9af5d (diff)
usb: provide a device tree node to USB devices
It is possible to specify a device tree node for an USB device. This is useful if you have a static USB setup and want to use aliases which point to these nodes, like on the Raspberry Pi. The nodes are matched against their hub port number, the compatible strings are not matched for now. Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/usb.c')
-rw-r--r--test/dm/usb.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/dm/usb.c b/test/dm/usb.c
index a25c2c14820..b273a515efd 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -78,6 +78,28 @@ static int dm_test_usb_multi(struct unit_test_state *uts)
}
DM_TEST(dm_test_usb_multi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+/* test that we have an associated ofnode with the usb device */
+static int dm_test_usb_fdt_node(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+ ofnode node;
+
+ state_set_skip_delays(true);
+ ut_assertok(usb_init());
+ ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &dev));
+ node = ofnode_path("/usb@1/hub/usbstor@1");
+ ut_asserteq(1, ofnode_equal(node, dev_ofnode(dev)));
+ ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 1, &dev));
+ ut_asserteq(1, ofnode_equal(ofnode_null(), dev_ofnode(dev)));
+ ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 2, &dev));
+ node = ofnode_path("/usb@1/hub/usbstor@3");
+ ut_asserteq(1, ofnode_equal(node, dev_ofnode(dev)));
+ ut_assertok(usb_stop());
+
+ return 0;
+}
+DM_TEST(dm_test_usb_fdt_node, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
static int count_usb_devices(void)
{
struct udevice *hub;