814a9d06e70213246cefb041a615b8719ec0e158
[openwrt/staging/pepe2k.git] /
1 From a9544caa482a7ed215117a902f04185216997831 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 44/48] net: dsa: mt7530: sort link settings ops and force link
5 down on all ports
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
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.
14
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.
17
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>
21 ---
22 drivers/net/dsa/mt7530.c | 14 ++++++++++++--
23 1 file changed, 12 insertions(+), 2 deletions(-)
24
25 --- a/drivers/net/dsa/mt7530.c
26 +++ b/drivers/net/dsa/mt7530.c
27 @@ -1222,7 +1222,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);
32
33 mutex_unlock(&priv->reg_mutex);
34
35 @@ -1242,7 +1241,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,
38 PCR_MATRIX_CLR);
39 - mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
40
41 mutex_unlock(&priv->reg_mutex);
42 }
43 @@ -2460,6 +2458,12 @@ mt7530_setup(struct dsa_switch *ds)
44 mt7530_mib_reset(ds);
45
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.
49 + */
50 + mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
51 + PMCR_FORCE_MODE, PMCR_FORCE_MODE);
52 +
53 /* Disable forwarding by default on all ports */
54 mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
55 PCR_MATRIX_CLR);
56 @@ -2565,6 +2569,12 @@ mt7531_setup_common(struct dsa_switch *d
57 UNU_FFP_MASK);
58
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.
62 + */
63 + mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
64 + MT7531_FORCE_MODE, MT7531_FORCE_MODE);
65 +
66 /* Disable forwarding by default on all ports */
67 mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
68 PCR_MATRIX_CLR);