forked from OERV-BSP/u-boot
net: fsl_enetc: Inline register accessors
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>
This commit is contained in:
committed by
Fabio Estevam
parent
4eb5ef73a9
commit
f0faa5a0de
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user