generic: 6.1: backport qca808x LED support patch
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 707-v6.8-07-net-phy-at803x-move-specific-at8031-config_init-to-d.patch
1 From 3ae3bc426eaf57ca8f53d75777d9a5ef779bc7b7 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 8 Dec 2023 15:51:54 +0100
4 Subject: [PATCH 07/13] net: phy: at803x: move specific at8031 config_init to
5 dedicated function
6
7 Move specific at8031 config_init to dedicated function to make
8 at803x_config_init more generic and tidy things up.
9
10 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
11 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14 drivers/net/phy/at803x.c | 45 ++++++++++++++++++++++------------------
15 1 file changed, 25 insertions(+), 20 deletions(-)
16
17 --- a/drivers/net/phy/at803x.c
18 +++ b/drivers/net/phy/at803x.c
19 @@ -951,27 +951,8 @@ static int at803x_hibernation_mode_confi
20
21 static int at803x_config_init(struct phy_device *phydev)
22 {
23 - struct at803x_priv *priv = phydev->priv;
24 int ret;
25
26 - if (phydev->drv->phy_id == ATH8031_PHY_ID) {
27 - /* Some bootloaders leave the fiber page selected.
28 - * Switch to the appropriate page (fiber or copper), as otherwise we
29 - * read the PHY capabilities from the wrong page.
30 - */
31 - phy_lock_mdio_bus(phydev);
32 - ret = at803x_write_page(phydev,
33 - priv->is_fiber ? AT803X_PAGE_FIBER :
34 - AT803X_PAGE_COPPER);
35 - phy_unlock_mdio_bus(phydev);
36 - if (ret)
37 - return ret;
38 -
39 - ret = at8031_pll_config(phydev);
40 - if (ret < 0)
41 - return ret;
42 - }
43 -
44 /* The RX and TX delay default is:
45 * after HW reset: RX delay enabled and TX delay disabled
46 * after SW reset: RX delay enabled, while TX delay retains the
47 @@ -1604,6 +1585,30 @@ static int at8031_probe(struct phy_devic
48 AT803X_WOL_EN, 0);
49 }
50
51 +static int at8031_config_init(struct phy_device *phydev)
52 +{
53 + struct at803x_priv *priv = phydev->priv;
54 + int ret;
55 +
56 + /* Some bootloaders leave the fiber page selected.
57 + * Switch to the appropriate page (fiber or copper), as otherwise we
58 + * read the PHY capabilities from the wrong page.
59 + */
60 + phy_lock_mdio_bus(phydev);
61 + ret = at803x_write_page(phydev,
62 + priv->is_fiber ? AT803X_PAGE_FIBER :
63 + AT803X_PAGE_COPPER);
64 + phy_unlock_mdio_bus(phydev);
65 + if (ret)
66 + return ret;
67 +
68 + ret = at8031_pll_config(phydev);
69 + if (ret < 0)
70 + return ret;
71 +
72 + return at803x_config_init(phydev);
73 +}
74 +
75 static int qca83xx_config_init(struct phy_device *phydev)
76 {
77 u8 switch_revision;
78 @@ -2113,7 +2118,7 @@ static struct phy_driver at803x_driver[]
79 .name = "Qualcomm Atheros AR8031/AR8033",
80 .flags = PHY_POLL_CABLE_TEST,
81 .probe = at8031_probe,
82 - .config_init = at803x_config_init,
83 + .config_init = at8031_config_init,
84 .config_aneg = at803x_config_aneg,
85 .soft_reset = genphy_soft_reset,
86 .set_wol = at803x_set_wol,