[U-Boot] [PATCH 46/51] ihs_mdio: Add support to force clause45 access

Mario Six mario.six at gdsys.cc
Fri Jul 14 12:55:32 UTC 2017


Add support to ihs_mdio to force clause 45 access (in addition to
clause 22 access).

Signed-off-by: Mario Six <mario.six at gdsys.cc>
---

 board/gdsys/common/ihs_mdio.c | 26 +++++++++++++++++++++++---
 board/gdsys/common/ihs_mdio.h |  1 +
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/board/gdsys/common/ihs_mdio.c b/board/gdsys/common/ihs_mdio.c
index d67ec7d38a..85a804d5cd 100644
--- a/board/gdsys/common/ihs_mdio.c
+++ b/board/gdsys/common/ihs_mdio.c
@@ -37,6 +37,16 @@ static int ihs_mdio_reset(struct mii_dev *bus)
 	return 0;
 }
 
+static int ihs_mdio_address(struct ihs_mdio_info *info, int addr, int dev_addr,
+			 int regnum)
+{
+	FPGA_SET_REG(info->fpga, mdio.address_data, regnum);
+	FPGA_SET_REG(info->fpga, mdio.control,
+		     ((addr & 0x1f) << 5) | (dev_addr & 0x1f) | (0 << 10));
+
+	return 0;
+}
+
 static int ihs_mdio_read(struct mii_dev *bus, int addr, int dev_addr,
 			 int regnum)
 {
@@ -45,8 +55,13 @@ static int ihs_mdio_read(struct mii_dev *bus, int addr, int dev_addr,
 
 	ihs_mdio_idle(bus);
 
+	if (info->clause45) {
+		ihs_mdio_address(info, addr, dev_addr, regnum);
+		ihs_mdio_idle(bus);
+	}
+
 	FPGA_SET_REG(info->fpga, mdio.control,
-		     ((addr & 0x1f) << 5) | (regnum & 0x1f) | (2 << 10));
+		     ((addr & 0x1f) << 5) | ((info->clause45 ? dev_addr : regnum) & 0x1f) | (2 << 10));
 
 	/* wait for rx data available */
 	udelay(100);
@@ -63,9 +78,14 @@ static int ihs_mdio_write(struct mii_dev *bus, int addr, int dev_addr,
 
 	ihs_mdio_idle(bus);
 
+	if (info->clause45) {
+		ihs_mdio_address(info, addr, dev_addr, regnum);
+		ihs_mdio_idle(bus);
+	}
+
 	FPGA_SET_REG(info->fpga, mdio.address_data, value);
 	FPGA_SET_REG(info->fpga, mdio.control,
-		     ((addr & 0x1f) << 5) | (regnum & 0x1f) | (1 << 10));
+		     ((addr & 0x1f) << 5) | ((info->clause45 ? dev_addr : regnum) & 0x1f) | (1 << 10));
 
 	return 0;
 }
@@ -75,7 +95,7 @@ int ihs_mdio_init(struct ihs_mdio_info *info)
 	struct mii_dev *bus = mdio_alloc();
 
 	if (!bus) {
-		printf("Failed to allocate FSL MDIO bus\n");
+		printf("Failed to allocate IHS MDIO bus\n");
 		return -1;
 	}
 
diff --git a/board/gdsys/common/ihs_mdio.h b/board/gdsys/common/ihs_mdio.h
index 64b4049378..372f07569c 100644
--- a/board/gdsys/common/ihs_mdio.h
+++ b/board/gdsys/common/ihs_mdio.h
@@ -11,6 +11,7 @@
 struct ihs_mdio_info {
 	u32 fpga;
 	char *name;
+	bool clause45;
 };
 
 int ihs_mdio_init(struct ihs_mdio_info *info);
-- 
2.11.0



More information about the U-Boot mailing list