@@ -40,6 +40,40 @@ static int enetc_dev_id(struct udevice *dev)
return 0;
}
+/* register accessors */
+static u32 enetc_read_reg(void __iomem *addr)
+{
+ return readl(addr);
+}
+
+static void enetc_write_reg(void __iomem *addr, u32 val)
+{
+ writel(val, addr);
+}
+
+static void enetc_write(struct enetc_priv *priv, u32 off, u32 val)
+{
+ enetc_write_reg(priv->regs_base + off, val);
+}
+
+/* port register accessors */
+static u32 enetc_read_port(struct enetc_priv *priv, u32 off)
+{
+ return enetc_read_reg(priv->port_regs + off);
+}
+
+static void enetc_write_port(struct enetc_priv *priv, u32 off, u32 val)
+{
+ enetc_write_reg(priv->port_regs + off, val);
+}
+
+/* BDR register accessor, see also ENETC_BDR() */
+static void enetc_bdr_write(struct enetc_priv *priv, int type, int n,
+ u32 off, u32 val)
+{
+ enetc_write(priv, ENETC_BDR(type, n, off), val);
+}
+
/*
* sets the MAC address in IERB registers, this setting is persistent and
* carried over to Linux.
@@ -163,26 +163,6 @@ struct enetc_priv {
struct phy_device *phy;
};
-/* register accessors */
-#define enetc_read_reg(x) readl((x))
-#define enetc_write_reg(x, val) writel((val), (x))
-#define enetc_read(priv, off) enetc_read_reg((priv)->regs_base + (off))
-#define enetc_write(priv, off, v) \
- enetc_write_reg((priv)->regs_base + (off), v)
-
-/* port register accessors */
-#define enetc_port_regs(priv, off) ((priv)->port_regs + (off))
-#define enetc_read_port(priv, off) \
- enetc_read_reg(enetc_port_regs((priv), (off)))
-#define enetc_write_port(priv, off, v) \
- enetc_write_reg(enetc_port_regs((priv), (off)), v)
-
-/* BDR register accessors, see ENETC_BDR() */
-#define enetc_bdr_read(priv, t, n, off) \
- enetc_read(priv, ENETC_BDR(t, n, off))
-#define enetc_bdr_write(priv, t, n, off, val) \
- enetc_write(priv, ENETC_BDR(t, n, off), val)
-
/* PCS / internal SoC PHY ID, it defaults to 0 on all interfaces */
#define ENETC_PCS_PHY_ADDR 0
@@ -14,6 +14,16 @@
#include "fsl_enetc.h"
+static u32 enetc_read(struct enetc_mdio_priv *priv, u32 off)
+{
+ return readl(priv->regs_base + off);
+}
+
+static void enetc_write(struct enetc_mdio_priv *priv, u32 off, u32 val)
+{
+ writel(val, priv->regs_base + off);
+}
+
static void enetc_mdio_wait_bsy(struct enetc_mdio_priv *priv)
{
int to = 10000;
Move register accessors from header files and turn them into proper inline functions, so typechecking can be done on them. Drop no longer enetc_port_regs() and unused enetc_read() and enetc_bdr_read(). Signed-off-by: Marek Vasut <marex@denx.de> --- Cc: Alice Guo <alice.guo@nxp.com> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jerome Forissier <jerome.forissier@linaro.org> Cc: Joe Hershberger <joe.hershberger@ni.com> Cc: Markus Gothe <markus.gothe@genexis.eu> Cc: Peng Fan <peng.fan@nxp.com> Cc: Ramon Fried <rfried.dev@gmail.com> Cc: Robert Marko <robert.marko@sartura.hr> Cc: Romain Naour <romain.naour@smile.fr> Cc: Simon Glass <sjg@chromium.org> Cc: Tim Harvey <tharvey@gateworks.com> Cc: Tom Rini <trini@konsulko.com> Cc: Ye Li <ye.li@nxp.com> Cc: u-boot@lists.denx.de --- drivers/net/fsl_enetc.c | 34 ++++++++++++++++++++++++++++++++++ drivers/net/fsl_enetc.h | 20 -------------------- drivers/net/fsl_enetc_mdio.c | 10 ++++++++++ 3 files changed, 44 insertions(+), 20 deletions(-)