0d284c3d2418add13758f59bf5eda5e66f306b7b
[openwrt/staging/blocktrron.git] /
1 From 30dd62191d3dd97c08f7f9dc9ce77ffab457e4fb Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 8 Dec 2023 15:51:56 +0100
4 Subject: [PATCH 09/13] net: phy: at803x: move specific at8031 config_intr to
5 dedicated function
6
7 Move specific at8031 config_intr bits to dedicated function to make
8 at803x_config_initr more generic.
9
10 This is needed in preparation for PHY driver split as qca8081 share the
11 same function to setup interrupts.
12
13 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 ---
16 drivers/net/phy/at803x.c | 30 ++++++++++++++++++++++++------
17 1 file changed, 24 insertions(+), 6 deletions(-)
18
19 --- a/drivers/net/phy/at803x.c
20 +++ b/drivers/net/phy/at803x.c
21 @@ -990,7 +990,6 @@ static int at803x_ack_interrupt(struct p
22
23 static int at803x_config_intr(struct phy_device *phydev)
24 {
25 - struct at803x_priv *priv = phydev->priv;
26 int err;
27 int value;
28
29 @@ -1007,10 +1006,6 @@ static int at803x_config_intr(struct phy
30 value |= AT803X_INTR_ENABLE_DUPLEX_CHANGED;
31 value |= AT803X_INTR_ENABLE_LINK_FAIL;
32 value |= AT803X_INTR_ENABLE_LINK_SUCCESS;
33 - if (priv->is_fiber) {
34 - value |= AT803X_INTR_ENABLE_LINK_FAIL_BX;
35 - value |= AT803X_INTR_ENABLE_LINK_SUCCESS_BX;
36 - }
37
38 err = phy_write(phydev, AT803X_INTR_ENABLE, value);
39 } else {
40 @@ -1617,6 +1612,29 @@ static int at8031_set_wol(struct phy_dev
41 return ret;
42 }
43
44 +static int at8031_config_intr(struct phy_device *phydev)
45 +{
46 + struct at803x_priv *priv = phydev->priv;
47 + int err, value = 0;
48 +
49 + if (phydev->interrupts == PHY_INTERRUPT_ENABLED &&
50 + priv->is_fiber) {
51 + /* Clear any pending interrupts */
52 + err = at803x_ack_interrupt(phydev);
53 + if (err)
54 + return err;
55 +
56 + value |= AT803X_INTR_ENABLE_LINK_FAIL_BX;
57 + value |= AT803X_INTR_ENABLE_LINK_SUCCESS_BX;
58 +
59 + err = phy_set_bits(phydev, AT803X_INTR_ENABLE, value);
60 + if (err)
61 + return err;
62 + }
63 +
64 + return at803x_config_intr(phydev);
65 +}
66 +
67 static int qca83xx_config_init(struct phy_device *phydev)
68 {
69 u8 switch_revision;
70 @@ -2137,7 +2155,7 @@ static struct phy_driver at803x_driver[]
71 .write_page = at803x_write_page,
72 .get_features = at803x_get_features,
73 .read_status = at803x_read_status,
74 - .config_intr = at803x_config_intr,
75 + .config_intr = at8031_config_intr,
76 .handle_interrupt = at803x_handle_interrupt,
77 .get_tunable = at803x_get_tunable,
78 .set_tunable = at803x_set_tunable,