generic: 6.6: sync mt7530 DSA driver with upstream
[openwrt/staging/stintel.git] / target / linux / generic / backport-6.6 / 790-13-v6.9-net-dsa-mt7530-move-XTAL-check-to-mt7530_setup.patch
1 From 12c511cd31c2dc6bd96e4a89f7709d515aa8a76b 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: Tue, 6 Feb 2024 01:08:03 +0300
4 Subject: [PATCH 13/30] net: dsa: mt7530: move XTAL check to mt7530_setup()
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 The crystal frequency concerns the switch core. The frequency should be
10 checked when the switch is being set up so the driver can reject the
11 unsupported hardware earlier and without requiring port 6 to be used.
12
13 Move it to mt7530_setup(). Drop the unnecessary function printing.
14
15 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
16 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
17 Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
18 Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
19 Link: https://lore.kernel.org/r/20240206-for-netnext-mt7530-improvements-2-v5-2-d7d92a185cb1@arinc9.com
20 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
21 ---
22 drivers/net/dsa/mt7530.c | 13 ++++++-------
23 1 file changed, 6 insertions(+), 7 deletions(-)
24
25 --- a/drivers/net/dsa/mt7530.c
26 +++ b/drivers/net/dsa/mt7530.c
27 @@ -422,13 +422,6 @@ mt7530_pad_clk_setup(struct dsa_switch *
28
29 xtal = mt7530_read(priv, MT7530_MHWTRAP) & HWTRAP_XTAL_MASK;
30
31 - if (xtal == HWTRAP_XTAL_20MHZ) {
32 - dev_err(priv->dev,
33 - "%s: MT7530 with a 20MHz XTAL is not supported!\n",
34 - __func__);
35 - return -EINVAL;
36 - }
37 -
38 switch (interface) {
39 case PHY_INTERFACE_MODE_RGMII:
40 trgint = 0;
41 @@ -2295,6 +2288,12 @@ mt7530_setup(struct dsa_switch *ds)
42 return -ENODEV;
43 }
44
45 + if ((val & HWTRAP_XTAL_MASK) == HWTRAP_XTAL_20MHZ) {
46 + dev_err(priv->dev,
47 + "MT7530 with a 20MHz XTAL is not supported!\n");
48 + return -EINVAL;
49 + }
50 +
51 /* Reset the switch through internal reset */
52 mt7530_write(priv, MT7530_SYS_CTRL,
53 SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |