a499b8e5b10606a722f55bed306d350ae9efce1b
[librecmc/librecmc.git] /
1 From 3c1d788a62dc648d1846049b66119ebb69dedd52 Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Mon, 11 Apr 2022 10:46:17 +0100
4 Subject: [PATCH 05/13] net: dsa: mt7530: only indicate linkmodes that can be
5  supported
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Now that mt7530 is not using the basex helper, it becomes unnecessary to
11 indicate support for both 1000baseX and 2500baseX when one of the 803.3z
12 PHY interface modes is being selected. Ensure that the driver indicates
13 only those linkmodes that can actually be supported by the PHY interface
14 mode.
15
16 Tested-by: Marek BehĂșn <kabel@kernel.org>
17 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
18 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
19 ---
20  drivers/net/dsa/mt7530.c | 12 ++++++++----
21  drivers/net/dsa/mt7530.h |  1 +
22  2 files changed, 9 insertions(+), 4 deletions(-)
23
24 --- a/drivers/net/dsa/mt7530.c
25 +++ b/drivers/net/dsa/mt7530.c
26 @@ -2793,12 +2793,13 @@ static int mt7531_rgmii_setup(struct mt7
27  }
28  
29  static void mt7531_sgmii_validate(struct mt7530_priv *priv, int port,
30 +                                 phy_interface_t interface,
31                                   unsigned long *supported)
32  {
33         /* Port5 supports ethier RGMII or SGMII.
34          * Port6 supports SGMII only.
35          */
36 -       if (port == 6) {
37 +       if (port == 6 && interface == PHY_INTERFACE_MODE_2500BASEX) {
38                 phylink_set(supported, 2500baseX_Full);
39                 phylink_set(supported, 2500baseT_Full);
40         }
41 @@ -3171,16 +3172,18 @@ static void mt753x_phylink_get_caps(stru
42  
43  static void
44  mt7530_mac_port_validate(struct dsa_switch *ds, int port,
45 +                        phy_interface_t interface,
46                          unsigned long *supported)
47  {
48  }
49  
50  static void mt7531_mac_port_validate(struct dsa_switch *ds, int port,
51 +                                    phy_interface_t interface,
52                                      unsigned long *supported)
53  {
54         struct mt7530_priv *priv = ds->priv;
55  
56 -       mt7531_sgmii_validate(priv, port, supported);
57 +       mt7531_sgmii_validate(priv, port, interface, supported);
58  }
59  
60  static void
61 @@ -3203,12 +3206,13 @@ mt753x_phylink_validate(struct dsa_switc
62         }
63  
64         /* This switch only supports 1G full-duplex. */
65 -       if (state->interface != PHY_INTERFACE_MODE_MII) {
66 +       if (state->interface != PHY_INTERFACE_MODE_MII &&
67 +           state->interface != PHY_INTERFACE_MODE_2500BASEX) {
68                 phylink_set(mask, 1000baseT_Full);
69                 phylink_set(mask, 1000baseX_Full);
70         }
71  
72 -       priv->info->mac_port_validate(ds, port, mask);
73 +       priv->info->mac_port_validate(ds, port, state->interface, mask);
74  
75         phylink_set(mask, Pause);
76         phylink_set(mask, Asym_Pause);
77 --- a/drivers/net/dsa/mt7530.h
78 +++ b/drivers/net/dsa/mt7530.h
79 @@ -804,6 +804,7 @@ struct mt753x_info {
80         void (*mac_port_get_caps)(struct dsa_switch *ds, int port,
81                                   struct phylink_config *config);
82         void (*mac_port_validate)(struct dsa_switch *ds, int port,
83 +                                 phy_interface_t interface,
84                                   unsigned long *supported);
85         int (*mac_port_get_state)(struct dsa_switch *ds, int port,
86                                   struct phylink_link_state *state);