kernel: bump 6.1 to 6.1.36
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 790-v6.4-0013-net-dsa-mt7530-fix-support-for-MT7531BE.patch
1 From eb1dd407b4be7ca38166a38c56c8edf52c6a399f Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Sun, 16 Apr 2023 13:08:14 +0100
4 Subject: [PATCH 13/13] net: dsa: mt7530: fix support for MT7531BE
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 There are two variants of the MT7531 switch IC which got different
10 features (and pins) regarding port 5:
11 * MT7531AE: SGMII/1000Base-X/2500Base-X SerDes PCS
12 * MT7531BE: RGMII
13
14 Moving the creation of the SerDes PCS from mt753x_setup to mt7530_probe
15 with commit 6de285229773 ("net: dsa: mt7530: move SGMII PCS creation
16 to mt7530_probe function") works fine for MT7531AE which got two
17 instances of mtk-pcs-lynxi, however, MT7531BE requires mt7531_pll_setup
18 to setup clocks before the single PCS on port 6 (usually used as CPU
19 port) starts to work and hence the PCS creation failed on MT7531BE.
20
21 Fix this by introducing a pointer to mt7531_create_sgmii function in
22 struct mt7530_priv and call it again at the end of mt753x_setup like it
23 was before commit 6de285229773 ("net: dsa: mt7530: move SGMII PCS
24 creation to mt7530_probe function").
25
26 Fixes: 6de285229773 ("net: dsa: mt7530: move SGMII PCS creation to mt7530_probe function")
27 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
28 Acked-by: Arınç ÜNAL <arinc.unal@arinc9.com>
29 Link: https://lore.kernel.org/r/ZDvlLhhqheobUvOK@makrotopia.org
30 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
31 ---
32 drivers/net/dsa/mt7530-mdio.c | 16 ++++++++--------
33 drivers/net/dsa/mt7530.c | 6 ++++++
34 drivers/net/dsa/mt7530.h | 4 ++--
35 3 files changed, 16 insertions(+), 10 deletions(-)
36
37 --- a/drivers/net/dsa/mt7530-mdio.c
38 +++ b/drivers/net/dsa/mt7530-mdio.c
39 @@ -81,14 +81,17 @@ static const struct regmap_bus mt7530_re
40 };
41
42 static int
43 -mt7531_create_sgmii(struct mt7530_priv *priv)
44 +mt7531_create_sgmii(struct mt7530_priv *priv, bool dual_sgmii)
45 {
46 - struct regmap_config *mt7531_pcs_config[2];
47 + struct regmap_config *mt7531_pcs_config[2] = {};
48 struct phylink_pcs *pcs;
49 struct regmap *regmap;
50 int i, ret = 0;
51
52 - for (i = 0; i < 2; i++) {
53 + /* MT7531AE has two SGMII units for port 5 and port 6
54 + * MT7531BE has only one SGMII unit for port 6
55 + */
56 + for (i = dual_sgmii ? 0 : 1; i < 2; i++) {
57 mt7531_pcs_config[i] = devm_kzalloc(priv->dev,
58 sizeof(struct regmap_config),
59 GFP_KERNEL);
60 @@ -208,11 +211,8 @@ mt7530_probe(struct mdio_device *mdiodev
61 if (IS_ERR(priv->regmap))
62 return PTR_ERR(priv->regmap);
63
64 - if (priv->id == ID_MT7531) {
65 - ret = mt7531_create_sgmii(priv);
66 - if (ret)
67 - return ret;
68 - }
69 + if (priv->id == ID_MT7531)
70 + priv->create_sgmii = mt7531_create_sgmii;
71
72 return dsa_register_switch(priv->ds);
73 }
74 --- a/drivers/net/dsa/mt7530.c
75 +++ b/drivers/net/dsa/mt7530.c
76 @@ -3044,6 +3044,12 @@ mt753x_setup(struct dsa_switch *ds)
77 if (ret && priv->irq)
78 mt7530_free_irq_common(priv);
79
80 + if (priv->create_sgmii) {
81 + ret = priv->create_sgmii(priv, mt7531_dual_sgmii_supported(priv));
82 + if (ret && priv->irq)
83 + mt7530_free_irq(priv);
84 + }
85 +
86 return ret;
87 }
88
89 --- a/drivers/net/dsa/mt7530.h
90 +++ b/drivers/net/dsa/mt7530.h
91 @@ -746,10 +746,10 @@ struct mt753x_info {
92 * registers
93 * @p6_interface Holding the current port 6 interface
94 * @p5_intf_sel: Holding the current port 5 interface select
95 - *
96 * @irq: IRQ number of the switch
97 * @irq_domain: IRQ domain of the switch irq_chip
98 * @irq_enable: IRQ enable bits, synced to SYS_INT_EN
99 + * @create_sgmii: Pointer to function creating SGMII PCS instance(s)
100 */
101 struct mt7530_priv {
102 struct device *dev;
103 @@ -768,7 +768,6 @@ struct mt7530_priv {
104 unsigned int p5_intf_sel;
105 u8 mirror_rx;
106 u8 mirror_tx;
107 -
108 struct mt7530_port ports[MT7530_NUM_PORTS];
109 struct mt753x_pcs pcs[MT7530_NUM_PORTS];
110 /* protect among processes for registers access*/
111 @@ -776,6 +775,7 @@ struct mt7530_priv {
112 int irq;
113 struct irq_domain *irq_domain;
114 u32 irq_enable;
115 + int (*create_sgmii)(struct mt7530_priv *priv, bool dual_sgmii);
116 };
117
118 struct mt7530_hw_vlan_entry {