[U-Boot] [PATCH 2/2] ihs_mdio: Make DM-compatible

Mario Six mario.six at gdsys.cc
Wed Mar 28 12:37:57 UTC 2018


Make the ihs_mdio driver DM-compatible, while retaining the old
functionality for not-yet-converted boards.

Signed-off-by: Mario Six <mario.six at gdsys.cc>
---
 board/gdsys/common/ihs_mdio.c | 38 +++++++++++++++++++++++++++++++++-----
 board/gdsys/common/ihs_mdio.h |  5 +++++
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/board/gdsys/common/ihs_mdio.c b/board/gdsys/common/ihs_mdio.c
index b5fe3dbbdc..43355f0069 100644
--- a/board/gdsys/common/ihs_mdio.c
+++ b/board/gdsys/common/ihs_mdio.c
@@ -7,36 +7,64 @@

 #include <common.h>

-#include <gdsys_fpga.h>
 #include <miiphy.h>
+#ifdef CONFIG_GDSYS_LEGACY_DRIVERS
+#include <gdsys_fpga.h>
+#else
+#include <fpgamap.h>
+#endif

 #include "ihs_mdio.h"

+#ifndef CONFIG_GDSYS_LEGACY_DRIVERS
+enum {
+	REG_MDIO_CONTROL = 0x0,
+	REG_MDIO_ADDR_DATA = 0x2,
+	REG_MDIO_RX_DATA = 0x4,
+};
+#endif
+
 static inline u16 read_control(struct ihs_mdio_info *info)
 {
 	u16 val;
-
+#ifdef CONFIG_GDSYS_LEGACY_DRIVERS
 	FPGA_GET_REG(info->fpga, mdio.control, &val);
-
+#else
+	fpgamap_read(info->fpga, info->base + REG_MDIO_CONTROL, &val,
+		     FPGAMAP_SIZE_16);
+#endif
 	return val;
 }

 static inline void write_control(struct ihs_mdio_info *info, u16 val)
 {
+#ifdef CONFIG_GDSYS_LEGACY_DRIVERS
 	FPGA_SET_REG(info->fpga, mdio.control, val);
+#else
+	fpgamap_write(info->fpga, info->base + REG_MDIO_CONTROL, &val,
+		      FPGAMAP_SIZE_16);
+#endif
 }

 static inline void write_addr_data(struct ihs_mdio_info *info, u16 val)
 {
+#ifdef CONFIG_GDSYS_LEGACY_DRIVERS
 	FPGA_SET_REG(info->fpga, mdio.address_data, val);
+#else
+	fpgamap_write(info->fpga, info->base + REG_MDIO_ADDR_DATA, &val,
+		      FPGAMAP_SIZE_16);
+#endif
 }

 static inline u16 read_rx_data(struct ihs_mdio_info *info)
 {
 	u16 val;
-
+#ifdef CONFIG_GDSYS_LEGACY_DRIVERS
 	FPGA_GET_REG(info->fpga, mdio.rx_data, &val);
-
+#else
+	fpgamap_read(info->fpga, info->base + REG_MDIO_RX_DATA, &val,
+		     FPGAMAP_SIZE_16);
+#endif
 	return val;
 }

diff --git a/board/gdsys/common/ihs_mdio.h b/board/gdsys/common/ihs_mdio.h
index 64b4049378..3e3ba25bc6 100644
--- a/board/gdsys/common/ihs_mdio.h
+++ b/board/gdsys/common/ihs_mdio.h
@@ -9,7 +9,12 @@
 #define _IHS_MDIO_H_

 struct ihs_mdio_info {
+#ifdef CONFIG_GDSYS_LEGACY_DRIVERS
 	u32 fpga;
+#else
+	struct udevice *fpga;
+	int base;
+#endif
 	char *name;
 };

--
2.16.1



More information about the U-Boot mailing list