ath25: switch default kernel to 5.15
[openwrt/staging/ldir.git] / target / linux / generic / backport-5.10 / 775-v5.18-01-net-phy-at803x-move-page-selection-fix-to-config_init.patch
1 From 4f3a00c7f5b2cfe4e127fd3fe49b55e1b318c01f Mon Sep 17 00:00:00 2001
2 From: Robert Hancock <robert.hancock@calian.com>
3 Date: Tue, 25 Jan 2022 10:54:08 -0600
4 Subject: [PATCH] net: phy: at803x: move page selection fix to config_init
5
6 The fix to select the copper page on AR8031 was being done in the probe
7 function rather than config_init, so it would not be redone after resume
8 from suspend. Move this to config_init so it is always redone when
9 needed.
10
11 Fixes: c329e5afb42f ("net: phy: at803x: select correct page on config init")
12 Signed-off-by: Robert Hancock <robert.hancock@calian.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/net/phy/at803x.c | 40 ++++++++++++++++------------------------
16 1 file changed, 16 insertions(+), 24 deletions(-)
17
18 --- a/drivers/net/phy/at803x.c
19 +++ b/drivers/net/phy/at803x.c
20 @@ -651,25 +651,7 @@ static int at803x_probe(struct phy_devic
21 return ret;
22 }
23
24 - /* Some bootloaders leave the fiber page selected.
25 - * Switch to the copper page, as otherwise we read
26 - * the PHY capabilities from the fiber side.
27 - */
28 - if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) {
29 - phy_lock_mdio_bus(phydev);
30 - ret = at803x_write_page(phydev, AT803X_PAGE_COPPER);
31 - phy_unlock_mdio_bus(phydev);
32 - if (ret)
33 - goto err;
34 - }
35 -
36 return 0;
37 -
38 -err:
39 - if (priv->vddio)
40 - regulator_disable(priv->vddio);
41 -
42 - return ret;
43 }
44
45 static void at803x_remove(struct phy_device *phydev)
46 @@ -745,6 +727,22 @@ static int at803x_config_init(struct phy
47 {
48 int ret;
49
50 + if (phydev->drv->phy_id == ATH8031_PHY_ID) {
51 + /* Some bootloaders leave the fiber page selected.
52 + * Switch to the copper page, as otherwise we read
53 + * the PHY capabilities from the fiber side.
54 + */
55 + phy_lock_mdio_bus(phydev);
56 + ret = at803x_write_page(phydev, AT803X_PAGE_COPPER);
57 + phy_unlock_mdio_bus(phydev);
58 + if (ret)
59 + return ret;
60 +
61 + ret = at8031_pll_config(phydev);
62 + if (ret < 0)
63 + return ret;
64 + }
65 +
66 /* The RX and TX delay default is:
67 * after HW reset: RX delay enabled and TX delay disabled
68 * after SW reset: RX delay enabled, while TX delay retains the
69 @@ -770,12 +768,6 @@ static int at803x_config_init(struct phy
70 if (ret < 0)
71 return ret;
72
73 - if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) {
74 - ret = at8031_pll_config(phydev);
75 - if (ret < 0)
76 - return ret;
77 - }
78 -
79 return 0;
80 }
81