From patchwork Mon Apr 20 03:21:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 238049 List-Id: U-Boot discussion From: chunfeng.yun at mediatek.com (Chunfeng Yun) Date: Mon, 20 Apr 2020 11:21:13 +0800 Subject: [PATCH v6 04/14] test: dm: phy: add a test item for the phy_bulk API In-Reply-To: <1587352883-8641-1-git-send-email-chunfeng.yun@mediatek.com> References: <1587352883-8641-1-git-send-email-chunfeng.yun@mediatek.com> Message-ID: <1587352883-8641-5-git-send-email-chunfeng.yun@mediatek.com> Add a test item for the phy_bulk API Signed-off-by: Chunfeng Yun Reviewed-by: Weijie Gao Reviewed-by: Simon Glass --- v6: add Reviewed-by Weijie & Simon v5: no changes v4: new patch --- arch/sandbox/dts/test.dts | 11 +++++++++++ test/dm/phy.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 6be0a5887c..25e0a5c44e 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -159,12 +159,23 @@ broken; }; + phy_provider2: gen_phy at 2 { + compatible = "sandbox,phy"; + #phy-cells = <0>; + }; + gen_phy_user: gen_phy_user { compatible = "simple-bus"; phys = <&phy_provider0 0>, <&phy_provider0 1>, <&phy_provider1>; phy-names = "phy1", "phy2", "phy3"; }; + gen_phy_user1: gen_phy_user1 { + compatible = "simple-bus"; + phys = <&phy_provider0 0>, <&phy_provider2>; + phy-names = "phy1", "phy2"; + }; + some-bus { #address-cells = <1>; #size-cells = <0>; diff --git a/test/dm/phy.c b/test/dm/phy.c index 21d92194b9..11d648c72f 100644 --- a/test/dm/phy.c +++ b/test/dm/phy.c @@ -110,3 +110,32 @@ static int dm_test_phy_ops(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_phy_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +static int dm_test_phy_bulk(struct unit_test_state *uts) +{ + struct phy_bulk phys; + struct udevice *parent; + + /* test normal operations */ + ut_assertok(uclass_get_device_by_name(UCLASS_SIMPLE_BUS, + "gen_phy_user1", &parent)); + + ut_assertok(generic_phy_get_bulk(parent, &phys)); + ut_asserteq(2, phys.count); + + ut_asserteq(0, generic_phy_enable_bulk(&phys)); + ut_asserteq(0, generic_phy_disable_bulk(&phys)); + + /* has a known problem phy */ + ut_assertok(uclass_get_device_by_name(UCLASS_SIMPLE_BUS, + "gen_phy_user", &parent)); + + ut_assertok(generic_phy_get_bulk(parent, &phys)); + ut_asserteq(3, phys.count); + + ut_asserteq(-EIO, generic_phy_enable_bulk(&phys)); + ut_asserteq(-EIO, generic_phy_disable_bulk(&phys)); + + return 0; +} +DM_TEST(dm_test_phy_bulk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);