test: dm: phy: add a test item for the phy_bulk API
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Sat, 2 May 2020 09:35:12 +0000 (11:35 +0200)
committerMarek Vasut <marek.vasut+renesas@gmail.com>
Sat, 2 May 2020 10:32:28 +0000 (12:32 +0200)
Add a test item for the phy_bulk API

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
Reviewed-by: Weijie Gao <weijie.gao@mediatek.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
arch/sandbox/dts/test.dts
test/dm/phy.c

index 9c00e945010289f398a77a945173b928a1f55c5c..15cd2330a38109d64a9842fd8b67d1bc0f1fdb6f 100644 (file)
                broken;
        };
 
+       phy_provider2: gen_phy@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>;
index 21d92194b976d43fedca7b007ef7cc3d80190443..92455d94affac090642f6a5f914b5a576f24c68b 100644 (file)
@@ -110,3 +110,36 @@ 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_init_bulk(&phys));
+       ut_asserteq(0, generic_phy_power_on_bulk(&phys));
+       ut_asserteq(0, generic_phy_power_off_bulk(&phys));
+       ut_asserteq(0, generic_phy_exit_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(0, generic_phy_init_bulk(&phys));
+       ut_asserteq(-EIO, generic_phy_power_on_bulk(&phys));
+       ut_asserteq(-EIO, generic_phy_power_off_bulk(&phys));
+       ut_asserteq(0, generic_phy_exit_bulk(&phys));
+
+       return 0;
+}
+DM_TEST(dm_test_phy_bulk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);