1 // SPDX-License-Identifier: GPL-2.0+
15 /* macros copied over from mdio_sandbox.c */
16 #define SANDBOX_PHY_ADDR 5
17 #define SANDBOX_PHY_REG_CNT 2
19 /* test using 1st register, 0 */
20 #define SANDBOX_PHY_REG 0
22 #define TEST_REG_VALUE 0xabcd
24 static int dm_test_mdio(struct unit_test_state *uts)
31 ut_assertok(uclass_get(UCLASS_MDIO, &uc));
33 ut_assertok(uclass_get_device_by_name(UCLASS_MDIO, "mdio-test", &dev));
35 ops = mdio_get_ops(dev);
36 ut_assertnonnull(ops);
37 ut_assertnonnull(ops->read);
38 ut_assertnonnull(ops->write);
40 ut_assertok(ops->write(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
41 SANDBOX_PHY_REG, TEST_REG_VALUE));
42 reg = ops->read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
44 ut_asserteq(reg, TEST_REG_VALUE);
46 ut_assert(ops->read(dev, SANDBOX_PHY_ADDR + 1, MDIO_DEVAD_NONE,
47 SANDBOX_PHY_REG) != 0);
49 ut_assertok(ops->reset(dev));
50 reg = ops->read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
57 DM_TEST(dm_test_mdio, DM_TESTF_SCAN_FDT);