All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Marginean <alexandru.marginean@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4 v3] test: dm_mdio: add a 2nd register to the emulated PHY
Date: Tue, 18 Jun 2019 14:58:36 +0000	[thread overview]
Message-ID: <20190618145823.606-3-alexandru.marginean@nxp.com> (raw)
In-Reply-To: <20190618145823.606-1-alexandru.marginean@nxp.com>

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

Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
---

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

 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

  parent reply	other threads:[~2019-06-18 14:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 14:58 [U-Boot] [PATCH 1/4 v3] net: add MDIO_MUX DM class Alexandru Marginean
2019-06-18 14:58 ` [U-Boot] [PATCH 2/4 v3] doc: bindings: Add description for MDIO MUX dts nodes Alexandru Marginean
2019-07-08  7:40   ` Bin Meng
2019-07-08 14:33     ` Alex Marginean
2019-06-18 14:58 ` Alexandru Marginean [this message]
2019-07-08  7:40   ` [U-Boot] [PATCH 3/4 v3] test: dm_mdio: add a 2nd register to the emulated PHY Bin Meng
2019-07-09 23:54   ` Joe Hershberger
2019-06-18 14:58 ` [U-Boot] [PATCH 4/4 v3] test: dm: add a test for MDIO MUX DM uclass Alexandru Marginean
2019-07-08  7:40   ` Bin Meng
2019-07-08 15:43     ` Alex Marginean
2019-07-08  7:40 ` [U-Boot] [PATCH 1/4 v3] net: add MDIO_MUX DM class Bin Meng
2019-07-09 23:49 ` Joe Hershberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190618145823.606-3-alexandru.marginean@nxp.com \
    --to=alexandru.marginean@nxp.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.