summaryrefslogtreecommitdiff
path: root/drivers/net/tsec.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/tsec.c')
-rw-r--r--drivers/net/tsec.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 2271eb8251..2d124732cf 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -131,11 +131,17 @@ static int tsec_mcast_addr(struct eth_device *dev, const u8 *mcast_mac,
static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int join)
#endif
{
- struct tsec_private *priv = (struct tsec_private *)dev->priv;
- struct tsec __iomem *regs = priv->regs;
+ struct tsec_private *priv;
+ struct tsec __iomem *regs;
u32 result, value;
u8 whichbit, whichreg;
+#ifndef CONFIG_DM_ETH
+ priv = (struct tsec_private *)dev->priv;
+#else
+ priv = dev_get_priv(dev);
+#endif
+ regs = priv->regs;
result = ether_crc(MAC_ADDR_LEN, mcast_mac);
whichbit = (result >> 24) & 0x1f; /* the 5 LSB = which bit to set */
whichreg = result >> 29; /* the 3 MSB = which reg to set it in */
@@ -260,12 +266,18 @@ static int tsec_send(struct eth_device *dev, void *packet, int length)
static int tsec_send(struct udevice *dev, void *packet, int length)
#endif
{
- struct tsec_private *priv = (struct tsec_private *)dev->priv;
- struct tsec __iomem *regs = priv->regs;
+ struct tsec_private *priv;
+ struct tsec __iomem *regs;
int result = 0;
u16 status;
int i;
+#ifndef CONFIG_DM_ETH
+ priv = (struct tsec_private *)dev->priv;
+#else
+ priv = dev_get_priv(dev);
+#endif
+ regs = priv->regs;
/* Find an empty buffer descriptor */
for (i = 0;
in_be16(&priv->txbd[priv->tx_idx].status) & TXBD_READY;
@@ -339,7 +351,7 @@ static int tsec_recv(struct eth_device *dev)
#else
static int tsec_recv(struct udevice *dev, int flags, uchar **packetp)
{
- struct tsec_private *priv = (struct tsec_private *)dev->priv;
+ struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev);
struct tsec __iomem *regs = priv->regs;
int ret = -1;
@@ -368,7 +380,7 @@ static int tsec_recv(struct udevice *dev, int flags, uchar **packetp)
static int tsec_free_pkt(struct udevice *dev, uchar *packet, int length)
{
- struct tsec_private *priv = (struct tsec_private *)dev->priv;
+ struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev);
u16 status;
out_be16(&priv->rxbd[priv->rx_idx].length, 0);
@@ -392,8 +404,14 @@ static void tsec_halt(struct eth_device *dev)
static void tsec_halt(struct udevice *dev)
#endif
{
- struct tsec_private *priv = (struct tsec_private *)dev->priv;
- struct tsec __iomem *regs = priv->regs;
+ struct tsec_private *priv;
+ struct tsec __iomem *regs;
+#ifndef CONFIG_DM_ETH
+ priv = (struct tsec_private *)dev->priv;
+#else
+ priv = dev_get_priv(dev);
+#endif
+ regs = priv->regs;
clrbits_be32(&regs->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
setbits_be32(&regs->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
@@ -560,16 +578,22 @@ static int tsec_init(struct eth_device *dev, struct bd_info *bd)
static int tsec_init(struct udevice *dev)
#endif
{
- struct tsec_private *priv = (struct tsec_private *)dev->priv;
+ struct tsec_private *priv;
+ struct tsec __iomem *regs;
#ifdef CONFIG_DM_ETH
struct eth_pdata *pdata = dev_get_plat(dev);
#else
struct eth_device *pdata = dev;
#endif
- struct tsec __iomem *regs = priv->regs;
u32 tempval;
int ret;
+#ifndef CONFIG_DM_ETH
+ priv = (struct tsec_private *)dev->priv;
+#else
+ priv = dev_get_priv(dev);
+#endif
+ regs = priv->regs;
/* Make sure the controller is stopped */
tsec_halt(dev);
@@ -865,7 +889,7 @@ int tsec_probe(struct udevice *dev)
int tsec_remove(struct udevice *dev)
{
- struct tsec_private *priv = dev->priv;
+ struct tsec_private *priv = dev_get_priv(dev);
free(priv->phydev);
mdio_unregister(priv->bus);