All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlo Caione <ccaione@baylibre.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 3/3] cmd: mdio: Add new parameter to access MMD PHY registers
Date: Wed, 23 Jan 2019 13:13:14 +0000	[thread overview]
Message-ID: <20190123131314.4514-4-ccaione@baylibre.com> (raw)
In-Reply-To: <20190123131314.4514-1-ccaione@baylibre.com>

Two new parameters (rmmd and wmmd) are added to allow the `mdio` command
to access the content of the MMD PHY registers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
 cmd/mdio.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/cmd/mdio.c b/cmd/mdio.c
index 184868063a..010632b562 100644
--- a/cmd/mdio.c
+++ b/cmd/mdio.c
@@ -43,7 +43,7 @@ static int mdio_write_ranges(struct phy_device *phydev, struct mii_dev *bus,
 			     int addrlo,
 			     int addrhi, int devadlo, int devadhi,
 			     int reglo, int reghi, unsigned short data,
-			     int extended)
+			     int extended, int mmd)
 {
 	int addr, devad, reg;
 	int err = 0;
@@ -51,7 +51,9 @@ static int mdio_write_ranges(struct phy_device *phydev, struct mii_dev *bus,
 	for (addr = addrlo; addr <= addrhi; addr++) {
 		for (devad = devadlo; devad <= devadhi; devad++) {
 			for (reg = reglo; reg <= reghi; reg++) {
-				if (!extended)
+				if (mmd)
+					err = phy_write_mmd(phydev, devad, reg, data);
+				else if (!extended)
 					err = bus->write(bus, addr, devad,
 							 reg, data);
 				else
@@ -71,7 +73,7 @@ err_out:
 static int mdio_read_ranges(struct phy_device *phydev, struct mii_dev *bus,
 			    int addrlo,
 			    int addrhi, int devadlo, int devadhi,
-			    int reglo, int reghi, int extended)
+			    int reglo, int reghi, int extended, int mmd)
 {
 	int addr, devad, reg;
 
@@ -83,7 +85,9 @@ static int mdio_read_ranges(struct phy_device *phydev, struct mii_dev *bus,
 			for (reg = reglo; reg <= reghi; reg++) {
 				int val;
 
-				if (!extended)
+				if (mmd)
+					val = phy_read_mmd(phydev, devad, reg);
+				else if (!extended)
 					val = bus->read(bus, addr, devad, reg);
 				else
 					val = phydev->drv->readext(phydev, addr,
@@ -189,6 +193,7 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	struct mii_dev *bus;
 	struct phy_device *phydev = NULL;
 	int extended = 0;
+	int mmd = 0;
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
@@ -232,6 +237,18 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				return -1;
 			}
 		}
+		if (op[1] == 'm') {
+			phydev = mdio_phydev_for_ethname(argv[2]);
+
+			if (phydev) {
+				addrlo = phydev->addr;
+				addrhi = addrlo;
+				bus = phydev->bus;
+				mmd = 1;
+			} else {
+				return -1;
+			}
+		}
 	}
 
 	switch (op[0]) {
@@ -265,12 +282,12 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	switch (op[0]) {
 	case 'w':
 		mdio_write_ranges(phydev, bus, addrlo, addrhi, devadlo, devadhi,
-				  reglo, reghi, data, extended);
+				  reglo, reghi, data, extended, mmd);
 		break;
 
 	case 'r':
 		mdio_read_ranges(phydev, bus, addrlo, addrhi, devadlo, devadhi,
-				 reglo, reghi, extended);
+				 reglo, reghi, extended, mmd);
 		break;
 	}
 
@@ -303,6 +320,10 @@ U_BOOT_CMD(
 		"read PHY's extended register at <devad>.<reg>\n"
 	"mdio wx <phydev> [<devad>.]<reg> <data> - "
 		"write PHY's extended register at <devad>.<reg>\n"
+	"mdio rmmd <phydev> [<devad>.]<reg> - "
+		"read PHY's extended register at <devad>.<reg>\n"
+	"mdio wmmd <phydev> [<devad>.]<reg> <data> - "
+		"write PHY's extended register at <devad>.<reg>\n"
 	"<phydev> may be:\n"
 	"   <busname>  <addr>\n"
 	"   <addr>\n"
-- 
2.19.1

  parent reply	other threads:[~2019-01-23 13:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-23 13:13 [U-Boot] [PATCH v2 0/3] Add MMD PHY helpers Carlo Caione
2019-01-23 13:13 ` [U-Boot] [PATCH v2 1/3] net: phy: Add support for accessing MMD PHY registers Carlo Caione
2019-01-23 14:12   ` Joe Hershberger
2019-01-23 13:13 ` [U-Boot] [PATCH v2 2/3] net: phy: ti: use generic helpers to access MMD registers Carlo Caione
2019-01-23 14:15   ` Joe Hershberger
2019-01-23 13:13 ` Carlo Caione [this message]
2019-01-23 14:01   ` [U-Boot] [PATCH v2 3/3] cmd: mdio: Add new parameter to access MMD PHY registers 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=20190123131314.4514-4-ccaione@baylibre.com \
    --to=ccaione@baylibre.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.