diff options
author | Marek Vasut <marek.vasut+renesas@mailbox.org> | 2024-09-08 23:09:05 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2024-09-09 17:18:04 +0200 |
commit | e72e683e36a83214dbb2547d88d553b5fd816dc8 (patch) | |
tree | 68db84a91d50e1732e6c492bec881784f4d6bcd3 /test | |
parent | a1f841a33c4e0b90721468a28030cecdb1cfd953 (diff) |
phy: test: Implement sandbox PHY .set_mode and DM test
Implement trivial extension to the sandbox PHY, which makes it pretend
to support selecting USB Host mode and nothing else. Any other mode is
rejected with -EINVAL. Any submode except for default submode 0 is
rejected with -EOPNOTSUPP . The implementation behaves in this trivial
way to permit easy unit testing using test which is also added in this
commit.
To run the test, use e.g. sandbox64_defconfig and run U-Boot as follows:
$ ./u-boot -Tc 'ut dm phy_setup'
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/phy.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/dm/phy.c b/test/dm/phy.c index 8808ca3689c..194cad0bf70 100644 --- a/test/dm/phy.c +++ b/test/dm/phy.c @@ -246,6 +246,13 @@ static int dm_test_phy_setup(struct unit_test_state *uts) ut_assertok(generic_setup_phy(parent, &phy, 0, PHY_MODE_USB_HOST, 0)); ut_assertok(generic_shutdown_phy(&phy)); + /* set_mode as USB Host passes, anything else is not supported */ + ut_assertok(generic_setup_phy(parent, &phy, 0, PHY_MODE_USB_HOST, 0)); + ut_assertok(generic_phy_set_mode(&phy, PHY_MODE_USB_HOST, 0)); + ut_asserteq(-EOPNOTSUPP, generic_phy_set_mode(&phy, PHY_MODE_USB_HOST, 1)); + ut_asserteq(-EINVAL, generic_phy_set_mode(&phy, PHY_MODE_USB_DEVICE, 0)); + ut_assertok(generic_shutdown_phy(&phy)); + /* power_off fail with -EIO */ ut_assertok(generic_setup_phy(parent, &phy, 1, PHY_MODE_USB_HOST, 0)); ut_asserteq(-EIO, generic_shutdown_phy(&phy)); |