kernel: remove duplicate #define's in at803x Ethernet PHY driver
[openwrt/openwrt.git] / target / linux / generic / pending-4.14 / 735-net-phy-at803x-fix-at8033-sgmii-mode.patch
1 From: Roman Yeryomin <roman@advem.lv>
2 Subject: kernel: add at803x fix for sgmii mode
3
4 Some (possibly broken) bootloaders incorreclty initialize at8033
5 phy. This patch enables sgmii autonegotiation mode.
6
7 [john@phrozen.org: felix added this to his upstream queue]
8
9 Signed-off-by: Roman Yeryomin <roman@advem.lv>
10 ---
11 drivers/net/phy/at803x.c | 25 +++++++++++++++++++++++++
12 1 file changed, 25 insertions(+)
13
14 --- a/drivers/net/phy/at803x.c
15 +++ b/drivers/net/phy/at803x.c
16 @@ -46,6 +46,7 @@
17 #define AT803X_FUNC_DATA 0x4003
18 #define AT803X_REG_CHIP_CONFIG 0x1f
19 #define AT803X_BT_BX_REG_SEL 0x8000
20 +#define AT803X_SGMII_ANEG_EN 0x1000
21
22 #define AT803X_PCS_SMART_EEE_CTRL3 0x805D
23 #define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_MASK 0x3
24 @@ -295,6 +296,27 @@ static int at803x_config_init(struct phy
25 {
26 struct at803x_platform_data *pdata;
27 int ret;
28 + u32 v;
29 +
30 + if (phydev->drv->phy_id == ATH8031_PHY_ID &&
31 + phydev->interface == PHY_INTERFACE_MODE_SGMII)
32 + {
33 + v = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
34 + /* select SGMII/fiber page */
35 + ret = phy_write(phydev, AT803X_REG_CHIP_CONFIG,
36 + v & ~AT803X_BT_BX_REG_SEL);
37 + if (ret)
38 + return ret;
39 + /* enable SGMII autonegotiation */
40 + ret = phy_write(phydev, MII_BMCR, AT803X_SGMII_ANEG_EN);
41 + if (ret)
42 + return ret;
43 + /* select copper page */
44 + ret = phy_write(phydev, AT803X_REG_CHIP_CONFIG,
45 + v | AT803X_BT_BX_REG_SEL);
46 + if (ret)
47 + return ret;
48 + }
49
50 ret = genphy_config_init(phydev);
51 if (ret < 0)