kernel: allow device-tree configuration of at803x
[oweals/openwrt.git] / target / linux / generic / pending-4.14 / 736-net-phy-at803x-allow-to-configure-via-dt.patch
1 Index: linux-4.14.60/drivers/net/phy/at803x.c
2 ===================================================================
3 --- linux-4.14.60.orig/drivers/net/phy/at803x.c
4 +++ linux-4.14.60/drivers/net/phy/at803x.c
5 @@ -354,6 +354,14 @@ static int at803x_config_init(struct phy
6                                 AT803X_DEBUG_TX_CLK_DLY_EN, 0);
7         }
8  
9 +#ifdef CONFIG_OF_MDIO
10 +       if (phydev->mdio.dev.of_node &&
11 +               of_property_read_bool(phydev->mdio.dev.of_node,
12 +                                     "at803x-disable-smarteee")) {
13 +               at803x_disable_smarteee(phydev);
14 +       }
15 +#endif
16 +
17         return 0;
18  }
19  
20 @@ -392,6 +400,7 @@ static void at803x_link_change_notify(st
21  {
22         struct at803x_priv *priv = phydev->priv;
23         struct at803x_platform_data *pdata;
24 +       u8 fixup_rgmii_tx_delay = 0;
25         pdata = dev_get_platdata(&phydev->mdio.dev);
26  
27         /*
28 @@ -421,8 +430,19 @@ static void at803x_link_change_notify(st
29         } else {
30                 priv->phy_reset = false;
31         }
32 -       if (pdata && pdata->fixup_rgmii_tx_delay &&
33 -           phydev->speed != priv->prev_speed) {
34 +
35 +       if (pdata && pdata->fixup_rgmii_tx_delay)
36 +               fixup_rgmii_tx_delay = 1;
37 +
38 +#ifdef CONFIG_OF_MDIO
39 +       if (phydev->mdio.dev.of_node &&
40 +               of_property_read_bool(phydev->mdio.dev.of_node,
41 +                                     "at803x-fixup-rgmii-tx-delay")) {
42 +                       fixup_rgmii_tx_delay = 1;
43 +       }
44 +#endif
45 +
46 +       if (fixup_rgmii_tx_delay && phydev->speed != priv->prev_speed) {
47                 switch (phydev->speed) {
48                 case SPEED_10:
49                 case SPEED_100: