From 6a4f059ec83132af8c13d39921539b22f5ff8205 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Mon, 6 Aug 2018 16:15:05 +0200 Subject: [PATCH] ar71xx: allow to override at803x sgmii aneg status When checking the outcome of the PHY autonegotiation status, at803x currently returns false in case the SGMII side is not established. Due to a hardware-bug, ag71xx needs to fixup the SoCs SGMII side, which it can't as it is not aware of the link-establishment. This commit allows to ignore the SGMII side autonegotiation status to allow ag71xx to do the fixup work. Signed-off-by: David Bauer (cherry picked from commit 4e39e213af7e3e0cd747403e8c227e145cfef988) --- .../files/arch/mips/ath79/mach-fritz450e.c | 1 + ...at803x-add-sgmii-aneg-override-pdata.patch | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 target/linux/ar71xx/patches-4.9/903-at803x-add-sgmii-aneg-override-pdata.patch diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-fritz450e.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-fritz450e.c index e48ddd65e7..4e99834d27 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-fritz450e.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-fritz450e.c @@ -122,6 +122,7 @@ static struct gpio_keys_button fritz450E_gpio_keys[] __initdata = { static struct at803x_platform_data fritz450E_at803x_data = { .disable_smarteee = 1, .has_reset_gpio = 1, + .override_sgmii_aneg = 1, .reset_gpio = FRITZ450E_GPIO_PHY_RESET, }; diff --git a/target/linux/ar71xx/patches-4.9/903-at803x-add-sgmii-aneg-override-pdata.patch b/target/linux/ar71xx/patches-4.9/903-at803x-add-sgmii-aneg-override-pdata.patch new file mode 100644 index 0000000000..9c922d155d --- /dev/null +++ b/target/linux/ar71xx/patches-4.9/903-at803x-add-sgmii-aneg-override-pdata.patch @@ -0,0 +1,42 @@ +Index: linux-4.9.111/drivers/net/phy/at803x.c +=================================================================== +--- linux-4.9.111.orig/drivers/net/phy/at803x.c ++++ linux-4.9.111/drivers/net/phy/at803x.c +@@ -461,12 +461,15 @@ static void at803x_link_change_notify(st + + static int at803x_aneg_done(struct phy_device *phydev) + { ++ struct at803x_platform_data *pdata; + int ccr; + + int aneg_done = genphy_aneg_done(phydev); + if (aneg_done != BMSR_ANEGCOMPLETE) + return aneg_done; + ++ pdata = dev_get_platdata(&phydev->mdio.dev); ++ + /* + * in SGMII mode, if copper side autoneg is successful, + * also check SGMII side autoneg result +@@ -481,7 +484,8 @@ static int at803x_aneg_done(struct phy_d + /* check if the SGMII link is OK. */ + if (!(phy_read(phydev, AT803X_PSSR) & AT803X_PSSR_MR_AN_COMPLETE)) { + pr_warn("803x_aneg_done: SGMII link is not ok\n"); +- aneg_done = 0; ++ if (!pdata || !pdata->override_sgmii_aneg) ++ aneg_done = 0; + } + /* switch back to copper page */ + phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr | AT803X_BT_BX_REG_SEL); +Index: linux-4.9.111/include/linux/platform_data/phy-at803x.h +=================================================================== +--- linux-4.9.111.orig/include/linux/platform_data/phy-at803x.h ++++ linux-4.9.111/include/linux/platform_data/phy-at803x.h +@@ -7,6 +7,7 @@ struct at803x_platform_data { + int enable_rgmii_rx_delay:1; + int fixup_rgmii_tx_delay:1; + int has_reset_gpio:1; ++ int override_sgmii_aneg:1; + int reset_gpio; + }; + -- 2.25.1