430329e23b6e765a17f19513ccb318f0a27e89a8
[openwrt/staging/dedeckeh.git] /
1 From 3b00a07c2443745d62babfe08dbb2ad8e649526e Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Fri, 19 Nov 2021 03:03:49 +0100
4 Subject: [PATCH] net: dsa: qca8k: fix internal delay applied to the wrong PAD
5 config
6
7 With SGMII phy the internal delay is always applied to the PAD0 config.
8 This is caused by the falling edge configuration that hardcode the reg
9 to PAD0 (as the falling edge bits are present only in PAD0 reg)
10 Move the delay configuration before the reg overwrite to correctly apply
11 the delay.
12
13 Fixes: cef08115846e ("net: dsa: qca8k: set internal delay also for sgmii")
14 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
15 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 ---
18 drivers/net/dsa/qca8k.c | 12 ++++++------
19 1 file changed, 6 insertions(+), 6 deletions(-)
20
21 diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
22 index a429c9750add1b..d7bcecbc1c5300 100644
23 --- a/drivers/net/dsa/qca8k.c
24 +++ b/drivers/net/dsa/qca8k.c
25 @@ -1433,6 +1433,12 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
26
27 qca8k_write(priv, QCA8K_REG_SGMII_CTRL, val);
28
29 + /* From original code is reported port instability as SGMII also
30 + * require delay set. Apply advised values here or take them from DT.
31 + */
32 + if (state->interface == PHY_INTERFACE_MODE_SGMII)
33 + qca8k_mac_config_setup_internal_delay(priv, cpu_port_index, reg);
34 +
35 /* For qca8327/qca8328/qca8334/qca8338 sgmii is unique and
36 * falling edge is set writing in the PORT0 PAD reg
37 */
38 @@ -1455,12 +1461,6 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
39 QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE,
40 val);
41
42 - /* From original code is reported port instability as SGMII also
43 - * require delay set. Apply advised values here or take them from DT.
44 - */
45 - if (state->interface == PHY_INTERFACE_MODE_SGMII)
46 - qca8k_mac_config_setup_internal_delay(priv, cpu_port_index, reg);
47 -
48 break;
49 default:
50 dev_err(ds->dev, "xMII mode %s not supported for port %d\n",