diff mbox series

[v3,14/22] test: dm: Add a case to test ofnode_phy_is_fixed_link()

Message ID 20210314051510.26628-15-bmeng.cn@gmail.com
State Superseded
Delegated to: Priyanka Jain
Headers show
Series ppc: qemu: Add eTSEC support | expand

Commit Message

Bin Meng March 14, 2021, 5:15 a.m. UTC
This adds a test case to test the new ofnode_phy_is_fixed_link() API.
Both the new and old DT bindings are covered.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

---

Changes in v3:
- reuse the sandbox dsa nodes for the fixed-link testing

 arch/sandbox/dts/test.dts |  6 +-----
 test/dm/of_extra.c        | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 5 deletions(-)

Comments

Vladimir Oltean March 14, 2021, 8:06 a.m. UTC | #1
On Sun, Mar 14, 2021 at 01:15:02PM +0800, Bin Meng wrote:
> This adds a test case to test the new ofnode_phy_is_fixed_link() API.
> Both the new and old DT bindings are covered.
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
diff mbox series

Patch

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 3ef3ba0b17..7ad16635ad 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -507,11 +507,7 @@ 
 				reg = <1>;
 				label = "lan1";
 				phy-mode = "rgmii-txid";
-
-				fixed-link {
-					speed = <100>;
-					full-duplex;
-				};
+				fixed-link = <0 1 100 0 0>;
 			};
 
 			port@2 {
diff --git a/test/dm/of_extra.c b/test/dm/of_extra.c
index b19cd3787d..ac2d886892 100644
--- a/test/dm/of_extra.c
+++ b/test/dm/of_extra.c
@@ -36,3 +36,21 @@  static int dm_test_ofnode_read_fmap_entry(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_ofnode_read_fmap_entry, 0);
+
+static int dm_test_ofnode_phy_is_fixed_link(struct unit_test_state *uts)
+{
+	ofnode eth_node, phy_node, node;
+
+	eth_node = ofnode_path("/dsa-test/ports/port@0");
+	ut_assert(ofnode_phy_is_fixed_link(eth_node, &phy_node));
+	node = ofnode_path("/dsa-test/ports/port@0/fixed-link");
+	ut_asserteq_mem(&phy_node, &node, sizeof(ofnode));
+
+	eth_node = ofnode_path("/dsa-test/ports/port@1");
+	ut_assert(ofnode_phy_is_fixed_link(eth_node, &phy_node));
+	node = eth_node;
+	ut_asserteq_mem(&phy_node, &node, sizeof(ofnode));
+
+	return 0;
+}
+DM_TEST(dm_test_ofnode_phy_is_fixed_link, 0);