9e10e000e5b9b62ae582dfa2dd7ef9e71d0f89d7
[openwrt/staging/wigyori.git] /
1 From 25d2ba94005fac18fe68878cddff59a67e115554 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 8 Dec 2023 15:51:53 +0100
4 Subject: [PATCH 06/13] net: phy: at803x: move specific at8031 probe mode check
5 to dedicated probe
6
7 Move specific at8031 probe mode check to dedicated probe to make
8 at803x_probe more generic and keep code tidy.
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 | 39 +++++++++++++++++++--------------------
15 1 file changed, 19 insertions(+), 20 deletions(-)
16
17 --- a/drivers/net/phy/at803x.c
18 +++ b/drivers/net/phy/at803x.c
19 @@ -844,26 +844,6 @@ static int at803x_probe(struct phy_devic
20 if (ret)
21 return ret;
22
23 - if (phydev->drv->phy_id == ATH8031_PHY_ID) {
24 - int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
25 - int mode_cfg;
26 -
27 - if (ccr < 0)
28 - return ccr;
29 - mode_cfg = ccr & AT803X_MODE_CFG_MASK;
30 -
31 - switch (mode_cfg) {
32 - case AT803X_MODE_CFG_BX1000_RGMII_50OHM:
33 - case AT803X_MODE_CFG_BX1000_RGMII_75OHM:
34 - priv->is_1000basex = true;
35 - fallthrough;
36 - case AT803X_MODE_CFG_FX100_RGMII_50OHM:
37 - case AT803X_MODE_CFG_FX100_RGMII_75OHM:
38 - priv->is_fiber = true;
39 - break;
40 - }
41 - }
42 -
43 return 0;
44 }
45
46 @@ -1584,6 +1564,9 @@ static int at8031_parse_dt(struct phy_de
47
48 static int at8031_probe(struct phy_device *phydev)
49 {
50 + struct at803x_priv *priv = phydev->priv;
51 + int mode_cfg;
52 + int ccr;
53 int ret;
54
55 ret = at803x_probe(phydev);
56 @@ -1597,6 +1580,22 @@ static int at8031_probe(struct phy_devic
57 if (ret)
58 return ret;
59
60 + ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
61 + if (ccr < 0)
62 + return ccr;
63 + mode_cfg = ccr & AT803X_MODE_CFG_MASK;
64 +
65 + switch (mode_cfg) {
66 + case AT803X_MODE_CFG_BX1000_RGMII_50OHM:
67 + case AT803X_MODE_CFG_BX1000_RGMII_75OHM:
68 + priv->is_1000basex = true;
69 + fallthrough;
70 + case AT803X_MODE_CFG_FX100_RGMII_50OHM:
71 + case AT803X_MODE_CFG_FX100_RGMII_75OHM:
72 + priv->is_fiber = true;
73 + break;
74 + }
75 +
76 /* Disable WoL in 1588 register which is enabled
77 * by default
78 */