[U-Boot] [PATCH v6 3/4] test: dm_mdio: add a 2nd register to the emulated PHY

Alex Marginean alexandru.marginean at nxp.com
Fri Jul 12 07:13:52 UTC 2019


This 2nd register is used by the follow-up MDIO MUX test.

Signed-off-by: Alex Marginean <alexm.osslist at gmail.com>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
Acked-by: Joe Hershberger <joe.hershberger at ni.com>
---

Changes in v2:
	- no change
Changes in v3:
	- no change, just fighting with the email server
Changes in v4:
	- no change
Changes in v5:
	- no change
Changes in v6:
	- no change

 drivers/net/mdio_sandbox.c | 16 +++++++++-------
 test/dm/mdio.c             |  3 +++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mdio_sandbox.c b/drivers/net/mdio_sandbox.c
index 07515e078c..df053f5381 100644
--- a/drivers/net/mdio_sandbox.c
+++ b/drivers/net/mdio_sandbox.c
@@ -9,11 +9,11 @@
 #include <miiphy.h>
 
 #define SANDBOX_PHY_ADDR	5
-#define SANDBOX_PHY_REG		0
+#define SANDBOX_PHY_REG_CNT	2
 
 struct mdio_sandbox_priv {
 	int enabled;
-	u16 reg;
+	u16 reg[SANDBOX_PHY_REG_CNT];
 };
 
 static int mdio_sandbox_read(struct udevice *dev, int addr, int devad, int reg)
@@ -27,10 +27,10 @@ static int mdio_sandbox_read(struct udevice *dev, int addr, int devad, int reg)
 		return -ENODEV;
 	if (devad != MDIO_DEVAD_NONE)
 		return -ENODEV;
-	if (reg != SANDBOX_PHY_REG)
+	if (reg < 0 || reg > SANDBOX_PHY_REG_CNT)
 		return -ENODEV;
 
-	return priv->reg;
+	return priv->reg[reg];
 }
 
 static int mdio_sandbox_write(struct udevice *dev, int addr, int devad, int reg,
@@ -45,10 +45,10 @@ static int mdio_sandbox_write(struct udevice *dev, int addr, int devad, int reg,
 		return -ENODEV;
 	if (devad != MDIO_DEVAD_NONE)
 		return -ENODEV;
-	if (reg != SANDBOX_PHY_REG)
+	if (reg < 0 || reg > SANDBOX_PHY_REG_CNT)
 		return -ENODEV;
 
-	priv->reg = val;
+	priv->reg[reg] = val;
 
 	return 0;
 }
@@ -56,8 +56,10 @@ static int mdio_sandbox_write(struct udevice *dev, int addr, int devad, int reg,
 static int mdio_sandbox_reset(struct udevice *dev)
 {
 	struct mdio_sandbox_priv *priv = dev_get_priv(dev);
+	int i;
 
-	priv->reg = 0;
+	for (i = 0; i < SANDBOX_PHY_REG_CNT; i++)
+		priv->reg[i] = 0;
 
 	return 0;
 }
diff --git a/test/dm/mdio.c b/test/dm/mdio.c
index 5b66255f7d..dc229aed6d 100644
--- a/test/dm/mdio.c
+++ b/test/dm/mdio.c
@@ -13,6 +13,9 @@
 
 /* macros copied over from mdio_sandbox.c */
 #define SANDBOX_PHY_ADDR	5
+#define SANDBOX_PHY_REG_CNT	2
+
+/* test using 1st register, 0 */
 #define SANDBOX_PHY_REG		0
 
 #define TEST_REG_VALUE		0xabcd
-- 
2.17.1



More information about the U-Boot mailing list