1 From aa474698f75f4790a4de2052dd487736d2361b2e Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
3 Date: Fri, 1 Mar 2024 12:43:04 +0200
4 Subject: [PATCH 26/30] net: dsa: mt7530: sort link settings ops and force link
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 port_enable and port_disable clears the link settings. Move that to
11 mt7530_setup() and mt7531_setup_common() which set up the switches. This
12 way, the link settings are cleared on all ports at setup, and then only
13 once with phylink_mac_link_down() when a link goes down.
15 Enable force mode at setup to apply the force part of the link settings.
16 This ensures that disabled ports will have their link down.
18 Suggested-by: Vladimir Oltean <olteanv@gmail.com>
19 Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
20 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
22 drivers/net/dsa/mt7530.c | 14 ++++++++++++--
23 1 file changed, 12 insertions(+), 2 deletions(-)
25 --- a/drivers/net/dsa/mt7530.c
26 +++ b/drivers/net/dsa/mt7530.c
27 @@ -1215,7 +1215,6 @@ mt7530_port_enable(struct dsa_switch *ds
28 priv->ports[port].enable = true;
29 mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
30 priv->ports[port].pm);
31 - mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
33 mutex_unlock(&priv->reg_mutex);
35 @@ -1235,7 +1234,6 @@ mt7530_port_disable(struct dsa_switch *d
36 priv->ports[port].enable = false;
37 mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
39 - mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
41 mutex_unlock(&priv->reg_mutex);
43 @@ -2454,6 +2452,12 @@ mt7530_setup(struct dsa_switch *ds)
46 for (i = 0; i < MT7530_NUM_PORTS; i++) {
47 + /* Clear link settings and enable force mode to force link down
48 + * on all ports until they're enabled later.
50 + mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
51 + PMCR_FORCE_MODE, PMCR_FORCE_MODE);
53 /* Disable forwarding by default on all ports */
54 mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
56 @@ -2556,6 +2560,12 @@ mt7531_setup_common(struct dsa_switch *d
59 for (i = 0; i < MT7530_NUM_PORTS; i++) {
60 + /* Clear link settings and enable force mode to force link down
61 + * on all ports until they're enabled later.
63 + mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
64 + MT7531_FORCE_MODE, MT7531_FORCE_MODE);
66 /* Disable forwarding by default on all ports */
67 mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,