Commit 3e8bc1b8 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: dsa: mv88e6060: Replace ds with priv

Pass around priv, not ds. This will help with changing to an mdio
driver, and makes this driver more like mv88e6xxx.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 406a4362
...@@ -14,10 +14,8 @@ ...@@ -14,10 +14,8 @@
#include <net/dsa.h> #include <net/dsa.h>
#include "mv88e6060.h" #include "mv88e6060.h"
static int reg_read(struct dsa_switch *ds, int addr, int reg) static int reg_read(struct mv88e6060_priv *priv, int addr, int reg)
{ {
struct mv88e6060_priv *priv = ds->priv;
return mdiobus_read_nested(priv->bus, priv->sw_addr + addr, reg); return mdiobus_read_nested(priv->bus, priv->sw_addr + addr, reg);
} }
...@@ -25,17 +23,15 @@ static int reg_read(struct dsa_switch *ds, int addr, int reg) ...@@ -25,17 +23,15 @@ static int reg_read(struct dsa_switch *ds, int addr, int reg)
({ \ ({ \
int __ret; \ int __ret; \
\ \
__ret = reg_read(ds, addr, reg); \ __ret = reg_read(priv, addr, reg); \
if (__ret < 0) \ if (__ret < 0) \
return __ret; \ return __ret; \
__ret; \ __ret; \
}) })
static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) static int reg_write(struct mv88e6060_priv *priv, int addr, int reg, u16 val)
{ {
struct mv88e6060_priv *priv = ds->priv;
return mdiobus_write_nested(priv->bus, priv->sw_addr + addr, reg, val); return mdiobus_write_nested(priv->bus, priv->sw_addr + addr, reg, val);
} }
...@@ -43,7 +39,7 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) ...@@ -43,7 +39,7 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
({ \ ({ \
int __ret; \ int __ret; \
\ \
__ret = reg_write(ds, addr, reg, val); \ __ret = reg_write(priv, addr, reg, val); \
if (__ret < 0) \ if (__ret < 0) \
return __ret; \ return __ret; \
}) })
...@@ -93,7 +89,7 @@ static const char *mv88e6060_drv_probe(struct device *dsa_dev, ...@@ -93,7 +89,7 @@ static const char *mv88e6060_drv_probe(struct device *dsa_dev,
return name; return name;
} }
static int mv88e6060_switch_reset(struct dsa_switch *ds) static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)
{ {
int i; int i;
int ret; int ret;
...@@ -129,7 +125,7 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds) ...@@ -129,7 +125,7 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds)
return 0; return 0;
} }
static int mv88e6060_setup_global(struct dsa_switch *ds) static int mv88e6060_setup_global(struct mv88e6060_priv *priv)
{ {
/* Disable discarding of frames with excessive collisions, /* Disable discarding of frames with excessive collisions,
* set the maximum frame size to 1536 bytes, and mask all * set the maximum frame size to 1536 bytes, and mask all
...@@ -145,7 +141,7 @@ static int mv88e6060_setup_global(struct dsa_switch *ds) ...@@ -145,7 +141,7 @@ static int mv88e6060_setup_global(struct dsa_switch *ds)
return 0; return 0;
} }
static int mv88e6060_setup_port(struct dsa_switch *ds, int p) static int mv88e6060_setup_port(struct mv88e6060_priv *priv, int p)
{ {
int addr = REG_PORT(p); int addr = REG_PORT(p);
...@@ -155,7 +151,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p) ...@@ -155,7 +151,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p)
* port, enable Ingress and Egress Trailer tagging mode. * port, enable Ingress and Egress Trailer tagging mode.
*/ */
REG_WRITE(addr, PORT_CONTROL, REG_WRITE(addr, PORT_CONTROL,
dsa_is_cpu_port(ds, p) ? dsa_is_cpu_port(priv->ds, p) ?
PORT_CONTROL_TRAILER | PORT_CONTROL_TRAILER |
PORT_CONTROL_INGRESS_MODE | PORT_CONTROL_INGRESS_MODE |
PORT_CONTROL_STATE_FORWARDING : PORT_CONTROL_STATE_FORWARDING :
...@@ -168,8 +164,8 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p) ...@@ -168,8 +164,8 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p)
*/ */
REG_WRITE(addr, PORT_VLAN_MAP, REG_WRITE(addr, PORT_VLAN_MAP,
((p & 0xf) << PORT_VLAN_MAP_DBNUM_SHIFT) | ((p & 0xf) << PORT_VLAN_MAP_DBNUM_SHIFT) |
(dsa_is_cpu_port(ds, p) ? dsa_user_ports(ds) : (dsa_is_cpu_port(priv->ds, p) ? dsa_user_ports(priv->ds) :
BIT(dsa_to_port(ds, p)->cpu_dp->index))); BIT(dsa_to_port(priv->ds, p)->cpu_dp->index)));
/* Port Association Vector: when learning source addresses /* Port Association Vector: when learning source addresses
* of packets, add the address to the address database using * of packets, add the address to the address database using
...@@ -181,7 +177,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p) ...@@ -181,7 +177,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p)
return 0; return 0;
} }
static int mv88e6060_setup_addr(struct dsa_switch *ds) static int mv88e6060_setup_addr(struct mv88e6060_priv *priv)
{ {
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
u16 val; u16 val;
...@@ -204,25 +200,28 @@ static int mv88e6060_setup_addr(struct dsa_switch *ds) ...@@ -204,25 +200,28 @@ static int mv88e6060_setup_addr(struct dsa_switch *ds)
static int mv88e6060_setup(struct dsa_switch *ds) static int mv88e6060_setup(struct dsa_switch *ds)
{ {
struct mv88e6060_priv *priv = ds->priv;
int ret; int ret;
int i; int i;
ret = mv88e6060_switch_reset(ds); priv->ds = ds;
ret = mv88e6060_switch_reset(priv);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* @@@ initialise atu */ /* @@@ initialise atu */
ret = mv88e6060_setup_global(ds); ret = mv88e6060_setup_global(priv);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = mv88e6060_setup_addr(ds); ret = mv88e6060_setup_addr(priv);
if (ret < 0) if (ret < 0)
return ret; return ret;
for (i = 0; i < MV88E6060_PORTS; i++) { for (i = 0; i < MV88E6060_PORTS; i++) {
ret = mv88e6060_setup_port(ds, i); ret = mv88e6060_setup_port(priv, i);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -239,25 +238,27 @@ static int mv88e6060_port_to_phy_addr(int port) ...@@ -239,25 +238,27 @@ static int mv88e6060_port_to_phy_addr(int port)
static int mv88e6060_phy_read(struct dsa_switch *ds, int port, int regnum) static int mv88e6060_phy_read(struct dsa_switch *ds, int port, int regnum)
{ {
struct mv88e6060_priv *priv = ds->priv;
int addr; int addr;
addr = mv88e6060_port_to_phy_addr(port); addr = mv88e6060_port_to_phy_addr(port);
if (addr == -1) if (addr == -1)
return 0xffff; return 0xffff;
return reg_read(ds, addr, regnum); return reg_read(priv, addr, regnum);
} }
static int static int
mv88e6060_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val) mv88e6060_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
{ {
struct mv88e6060_priv *priv = ds->priv;
int addr; int addr;
addr = mv88e6060_port_to_phy_addr(port); addr = mv88e6060_port_to_phy_addr(port);
if (addr == -1) if (addr == -1)
return 0xffff; return 0xffff;
return reg_write(ds, addr, regnum, val); return reg_write(priv, addr, regnum, val);
} }
static const struct dsa_switch_ops mv88e6060_switch_ops = { static const struct dsa_switch_ops mv88e6060_switch_ops = {
......
...@@ -117,6 +117,7 @@ struct mv88e6060_priv { ...@@ -117,6 +117,7 @@ struct mv88e6060_priv {
*/ */
struct mii_bus *bus; struct mii_bus *bus;
int sw_addr; int sw_addr;
struct dsa_switch *ds;
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment