|
@@ -38,12 +38,13 @@ static char *mv88e6171_probe(struct device *host_dev, int sw_addr)
|
|
|
|
|
|
|
|
static int mv88e6171_switch_reset(struct dsa_switch *ds)
|
|
static int mv88e6171_switch_reset(struct dsa_switch *ds)
|
|
|
{
|
|
{
|
|
|
|
|
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
|
int i;
|
|
int i;
|
|
|
int ret;
|
|
int ret;
|
|
|
unsigned long timeout;
|
|
unsigned long timeout;
|
|
|
|
|
|
|
|
/* Set all ports to the disabled state. */
|
|
/* Set all ports to the disabled state. */
|
|
|
- for (i = 0; i < 8; i++) {
|
|
|
|
|
|
|
+ for (i = 0; i < ps->num_ports; i++) {
|
|
|
ret = REG_READ(REG_PORT(i), 0x04);
|
|
ret = REG_READ(REG_PORT(i), 0x04);
|
|
|
REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
|
|
REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
|
|
|
}
|
|
}
|
|
@@ -70,7 +71,7 @@ static int mv88e6171_switch_reset(struct dsa_switch *ds)
|
|
|
return -ETIMEDOUT;
|
|
return -ETIMEDOUT;
|
|
|
|
|
|
|
|
/* Enable ports not under DSA, e.g. WAN port */
|
|
/* Enable ports not under DSA, e.g. WAN port */
|
|
|
- for (i = 0; i < 8; i++) {
|
|
|
|
|
|
|
+ for (i = 0; i < ps->num_ports; i++) {
|
|
|
if (dsa_is_cpu_port(ds, i) || ds->phys_port_mask & (1 << i))
|
|
if (dsa_is_cpu_port(ds, i) || ds->phys_port_mask & (1 << i))
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
@@ -83,6 +84,7 @@ static int mv88e6171_switch_reset(struct dsa_switch *ds)
|
|
|
|
|
|
|
|
static int mv88e6171_setup_global(struct dsa_switch *ds)
|
|
static int mv88e6171_setup_global(struct dsa_switch *ds)
|
|
|
{
|
|
{
|
|
|
|
|
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
|
int ret;
|
|
int ret;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
@@ -147,7 +149,7 @@ static int mv88e6171_setup_global(struct dsa_switch *ds)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Clear all trunk masks. */
|
|
/* Clear all trunk masks. */
|
|
|
- for (i = 0; i < 8; i++)
|
|
|
|
|
|
|
+ for (i = 0; i < ps->num_ports; i++)
|
|
|
REG_WRITE(REG_GLOBAL2, 0x07, 0x8000 | (i << 12) | 0xff);
|
|
REG_WRITE(REG_GLOBAL2, 0x07, 0x8000 | (i << 12) | 0xff);
|
|
|
|
|
|
|
|
/* Clear all trunk mappings. */
|
|
/* Clear all trunk mappings. */
|
|
@@ -270,6 +272,7 @@ static int mv88e6171_setup_port(struct dsa_switch *ds, int p)
|
|
|
|
|
|
|
|
static int mv88e6171_setup(struct dsa_switch *ds)
|
|
static int mv88e6171_setup(struct dsa_switch *ds)
|
|
|
{
|
|
{
|
|
|
|
|
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
|
int i;
|
|
int i;
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
@@ -277,6 +280,8 @@ static int mv88e6171_setup(struct dsa_switch *ds)
|
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
+ ps->num_ports = 7;
|
|
|
|
|
+
|
|
|
ret = mv88e6171_switch_reset(ds);
|
|
ret = mv88e6171_switch_reset(ds);
|
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
|
return ret;
|
|
return ret;
|
|
@@ -287,7 +292,7 @@ static int mv88e6171_setup(struct dsa_switch *ds)
|
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
|
|
- for (i = 0; i < 8; i++) {
|
|
|
|
|
|
|
+ for (i = 0; i < ps->num_ports; i++) {
|
|
|
if (!(dsa_is_cpu_port(ds, i) || ds->phys_port_mask & (1 << i)))
|
|
if (!(dsa_is_cpu_port(ds, i) || ds->phys_port_mask & (1 << i)))
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
@@ -299,9 +304,11 @@ static int mv88e6171_setup(struct dsa_switch *ds)
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static int mv88e6171_port_to_phy_addr(int port)
|
|
|
|
|
|
|
+static int mv88e6171_port_to_phy_addr(struct dsa_switch *ds, int port)
|
|
|
{
|
|
{
|
|
|
- if (port >= 0 && port <= 4)
|
|
|
|
|
|
|
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
|
|
|
+
|
|
|
|
|
+ if (port >= 0 && port < ps->num_ports)
|
|
|
return port;
|
|
return port;
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
@@ -310,7 +317,7 @@ static int
|
|
|
mv88e6171_phy_read(struct dsa_switch *ds, int port, int regnum)
|
|
mv88e6171_phy_read(struct dsa_switch *ds, int port, int regnum)
|
|
|
{
|
|
{
|
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
|
- int addr = mv88e6171_port_to_phy_addr(port);
|
|
|
|
|
|
|
+ int addr = mv88e6171_port_to_phy_addr(ds, port);
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&ps->phy_mutex);
|
|
mutex_lock(&ps->phy_mutex);
|
|
@@ -324,7 +331,7 @@ mv88e6171_phy_write(struct dsa_switch *ds,
|
|
|
int port, int regnum, u16 val)
|
|
int port, int regnum, u16 val)
|
|
|
{
|
|
{
|
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
|
|
- int addr = mv88e6171_port_to_phy_addr(port);
|
|
|
|
|
|
|
+ int addr = mv88e6171_port_to_phy_addr(ds, port);
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&ps->phy_mutex);
|
|
mutex_lock(&ps->phy_mutex);
|