aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa/mv88e6131.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2015-04-01 22:06:34 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-01 22:55:40 -0400
commit143a83073aaea145aa050cd0ebb80454c9362608 (patch)
tree291485b615cb19d4b8f93831da0ba0e2ba53e0cb /drivers/net/dsa/mv88e6131.c
parent44e50ddbc74a4bd6a862be9e6de22bce8c0b4150 (diff)
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/mv88e6131.c')
-rw-r--r--drivers/net/dsa/mv88e6131.c36
1 files changed, 1 insertions, 35 deletions
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 6b818fde2216..534a8f0b1c28 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -42,40 +42,6 @@ static char *mv88e6131_probe(struct device *host_dev, int sw_addr)
42 return NULL; 42 return NULL;
43} 43}
44 44
45static int mv88e6131_switch_reset(struct dsa_switch *ds)
46{
47 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
48 int i;
49 int ret;
50 unsigned long timeout;
51
52 /* Set all ports to the disabled state. */
53 for (i = 0; i < ps->num_ports; i++) {
54 ret = REG_READ(REG_PORT(i), 0x04);
55 REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
56 }
57
58 /* Wait for transmit queues to drain. */
59 usleep_range(2000, 4000);
60
61 /* Reset the switch. */
62 REG_WRITE(REG_GLOBAL, 0x04, 0xc400);
63
64 /* Wait up to one second for reset to complete. */
65 timeout = jiffies + 1 * HZ;
66 while (time_before(jiffies, timeout)) {
67 ret = REG_READ(REG_GLOBAL, 0x00);
68 if ((ret & 0xc800) == 0xc800)
69 break;
70
71 usleep_range(1000, 2000);
72 }
73 if (time_after(jiffies, timeout))
74 return -ETIMEDOUT;
75
76 return 0;
77}
78
79static int mv88e6131_setup_global(struct dsa_switch *ds) 45static int mv88e6131_setup_global(struct dsa_switch *ds)
80{ 46{
81 int ret; 47 int ret;
@@ -281,7 +247,7 @@ static int mv88e6131_setup(struct dsa_switch *ds)
281 return -ENODEV; 247 return -ENODEV;
282 } 248 }
283 249
284 ret = mv88e6131_switch_reset(ds); 250 ret = mv88e6xxx_switch_reset(ds, false);
285 if (ret < 0) 251 if (ret < 0)
286 return ret; 252 return ret;
287 253