OSDN Git Service

Merge branch 'mv88e6xxx-Disable-ports-to-save-power'
authorDavid S. Miller <davem@davemloft.net>
Sat, 4 May 2019 03:53:06 +0000 (23:53 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sat, 4 May 2019 03:53:06 +0000 (23:53 -0400)
Andrew Lunn says:

====================
mv88e6xxx: Disable ports to save power

Save some power by disabling ports. The first patch fully disables a
port when it is runtime disabled. The second disables any ports which
are not used at all.

Depending on configuration strapping, this can lower the temperature
of an idle switch a few degrees.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6xxx/chip.c

index 489a899..46020fe 100644 (file)
@@ -2428,6 +2428,9 @@ static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
 
        mutex_lock(&chip->reg_lock);
 
+       if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED))
+               dev_err(chip->dev, "failed to disable port\n");
+
        if (chip->info->ops->serdes_irq_free)
                chip->info->ops->serdes_irq_free(chip, port);
 
@@ -2596,8 +2599,18 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
 
        /* Setup Switch Port Registers */
        for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
-               if (dsa_is_unused_port(ds, i))
+               if (dsa_is_unused_port(ds, i)) {
+                       err = mv88e6xxx_port_set_state(chip, i,
+                                                      BR_STATE_DISABLED);
+                       if (err)
+                               goto unlock;
+
+                       err = mv88e6xxx_serdes_power(chip, i, false);
+                       if (err)
+                               goto unlock;
+
                        continue;
+               }
 
                err = mv88e6xxx_setup_port(chip, i);
                if (err)