OSDN Git Service

net: dsa: sja1105: Export the sja1105_inhibit_tx function
authorVladimir Oltean <olteanv@gmail.com>
Sat, 8 Jun 2019 13:03:43 +0000 (16:03 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 10 Jun 2019 02:58:58 +0000 (19:58 -0700)
This will be used to stop egress traffic in .phylink_mac_link_up.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105.h
drivers/net/dsa/sja1105/sja1105_spi.c

index 0fc6fe9..8c7bc55 100644 (file)
@@ -131,6 +131,8 @@ int sja1105_spi_send_long_packed_buf(const struct sja1105_private *priv,
                                     sja1105_spi_rw_mode_t rw, u64 base_addr,
                                     void *packed_buf, u64 buf_len);
 int sja1105_static_config_upload(struct sja1105_private *priv);
+int sja1105_inhibit_tx(const struct sja1105_private *priv,
+                      unsigned long port_bitmap, bool tx_inhibited);
 
 extern struct sja1105_info sja1105e_info;
 extern struct sja1105_info sja1105t_info;
index d729a0f..d7ff742 100644 (file)
@@ -285,20 +285,22 @@ static int sja1105_cold_reset(const struct sja1105_private *priv)
        return priv->info->reset_cmd(priv, &reset);
 }
 
-static int sja1105_inhibit_tx(const struct sja1105_private *priv,
-                             const unsigned long *port_bitmap)
+int sja1105_inhibit_tx(const struct sja1105_private *priv,
+                      unsigned long port_bitmap, bool tx_inhibited)
 {
        const struct sja1105_regs *regs = priv->info->regs;
        u64 inhibit_cmd;
-       int port, rc;
+       int rc;
 
        rc = sja1105_spi_send_int(priv, SPI_READ, regs->port_control,
                                  &inhibit_cmd, SJA1105_SIZE_PORT_CTRL);
        if (rc < 0)
                return rc;
 
-       for_each_set_bit(port, port_bitmap, SJA1105_NUM_PORTS)
-               inhibit_cmd |= BIT(port);
+       if (tx_inhibited)
+               inhibit_cmd |= port_bitmap;
+       else
+               inhibit_cmd &= ~port_bitmap;
 
        return sja1105_spi_send_int(priv, SPI_WRITE, regs->port_control,
                                    &inhibit_cmd, SJA1105_SIZE_PORT_CTRL);
@@ -415,7 +417,7 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
         * Tx on all ports and waiting for current packet to drain.
         * Otherwise, the PHY will see an unterminated Ethernet packet.
         */
-       rc = sja1105_inhibit_tx(priv, &port_bitmap);
+       rc = sja1105_inhibit_tx(priv, port_bitmap, true);
        if (rc < 0) {
                dev_err(dev, "Failed to inhibit Tx on ports\n");
                return -ENXIO;