5008ca5c776cab7558f519622b77a6f0a1af7365
[openwrt/openwrt.git] /
1 From 2a2ccfa44e56c45dfd1230f6efb3ec0a4a677f0a Mon Sep 17 00:00:00 2001
2 From: Alex Marginean <alexandru.marginean@nxp.com>
3 Date: Wed, 15 Jan 2020 15:49:11 +0200
4 Subject: [PATCH] drivers: net: dsa: felix: don't restart PCS SGMII AN if not
5 needed
6
7 Some PHYs like VSC8234 don't like it when AN restarts on their system side
8 and they restart line side AN too, going into an endless link up/down loop.
9 Don't restart PCS AN if link is up already.
10
11 Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
12 Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
13 ---
14 drivers/net/dsa/ocelot/felix_vsc9959.c | 15 +++++++++++++++
15 1 file changed, 15 insertions(+)
16
17 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
18 +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
19 @@ -648,7 +648,22 @@ static void vsc9959_pcs_init_sgmii(struc
20 unsigned int link_an_mode,
21 const struct phylink_link_state *state)
22 {
23 + int bmsr, bmcr;
24 +
25 if (link_an_mode == MLO_AN_INBAND) {
26 + /* Some PHYs like VSC8234 don't like it when AN restarts on
27 + * their system side and they restart line side AN too, going
28 + * into an endless link up/down loop. Don't restart PCS AN if
29 + * link is up already.
30 + * We do check that AN is enabled just in case this is the 1st
31 + * call, PCS detects a carrier but AN is disabled from power on
32 + * or by boot loader.
33 + */
34 + bmcr = phy_read(pcs, MII_BMCR);
35 + bmsr = phy_read(pcs, MII_BMSR);
36 + if ((bmcr & BMCR_ANENABLE) && (bmsr & BMSR_LSTATUS))
37 + return;
38 +
39 /* SGMII spec requires tx_config_Reg[15:0] to be exactly 0x4001
40 * for the MAC PCS in order to acknowledge the AN.
41 */