diff options
author | Andrew Lunn <andrew@lunn.ch> | 2015-04-02 04:06:34 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-02 04:55:40 +0200 |
commit | 143a83073aaea145aa050cd0ebb80454c9362608 (patch) | |
tree | 291485b615cb19d4b8f93831da0ba0e2ba53e0cb /drivers/net/dsa/mv88e6171.c | |
parent | net: dsa: Consistently set and use ps->num_ports (diff) | |
download | linux-143a83073aaea145aa050cd0ebb80454c9362608.tar.xz linux-143a83073aaea145aa050cd0ebb80454c9362608.zip |
net: dsa: Centralize Marvell switch reset
Marvell switches are all reset in nearly the same way. The only
difference is if the PPU should be enabled or not. Move this
code into the shared mv88x6xxx.c.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa/mv88e6171.c')
-rw-r--r-- | drivers/net/dsa/mv88e6171.c | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c index 5a295533ff20..69b35d124de5 100644 --- a/drivers/net/dsa/mv88e6171.c +++ b/drivers/net/dsa/mv88e6171.c @@ -36,52 +36,6 @@ static char *mv88e6171_probe(struct device *host_dev, int sw_addr) return NULL; } -static int mv88e6171_switch_reset(struct dsa_switch *ds) -{ - struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); - int i; - int ret; - unsigned long timeout; - - /* Set all ports to the disabled state. */ - for (i = 0; i < ps->num_ports; i++) { - ret = REG_READ(REG_PORT(i), 0x04); - REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc); - } - - /* Wait for transmit queues to drain. */ - usleep_range(2000, 4000); - - /* Reset the switch. Keep PPU active. The PPU needs to be - * active to support indirect phy register accesses through - * global registers 0x18 and 0x19. - */ - REG_WRITE(REG_GLOBAL, 0x04, 0xc000); - - /* Wait up to one second for reset to complete. */ - timeout = jiffies + 1 * HZ; - while (time_before(jiffies, timeout)) { - ret = REG_READ(REG_GLOBAL, 0x00); - if ((ret & 0xc800) == 0xc800) - break; - - usleep_range(1000, 2000); - } - if (time_after(jiffies, timeout)) - return -ETIMEDOUT; - - /* Enable ports not under DSA, e.g. WAN port */ - for (i = 0; i < ps->num_ports; i++) { - if (dsa_is_cpu_port(ds, i) || ds->phys_port_mask & (1 << i)) - continue; - - ret = REG_READ(REG_PORT(i), 0x04); - REG_WRITE(REG_PORT(i), 0x04, ret | 0x03); - } - - return 0; -} - static int mv88e6171_setup_global(struct dsa_switch *ds) { struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); @@ -282,7 +236,7 @@ static int mv88e6171_setup(struct dsa_switch *ds) ps->num_ports = 7; - ret = mv88e6171_switch_reset(ds); + ret = mv88e6xxx_switch_reset(ds, true); if (ret < 0) return ret; |