kernel: qca-ssdk: renumber patches
[openwrt/staging/jow.git] / package / kernel / qca-ssdk / patches / 0004-qca8081-convert-to-5.11-IRQ-model.patch
1 From aaac91b5e8756dce1c0242d58074a0b5d4607b57 Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Fri, 24 Dec 2021 20:02:32 +0100
4 Subject: [PATCH 04/14] qca8081: convert to 5.11 IRQ model
5
6 Kernel 5.11 introduced new IRQ handling model for PHY-s,
7 so provide those if 5.11 or later is used.
8
9 Signed-off-by: Robert Marko <robimarko@gmail.com>
10 ---
11 src/hsl/phy/qca808x.c | 46 +++++++++++++++++++++++++++++++++++++++++++
12 1 file changed, 46 insertions(+)
13
14 --- a/src/hsl/phy/qca808x.c
15 +++ b/src/hsl/phy/qca808x.c
16 @@ -247,6 +247,7 @@ static int qca808x_config_intr(struct ph
17 return err;
18 }
19
20 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
21 static int qca808x_ack_interrupt(struct phy_device *phydev)
22 {
23 int err;
24 @@ -266,6 +267,47 @@ static int qca808x_ack_interrupt(struct
25
26 return (err < 0) ? err : 0;
27 }
28 +#endif
29 +
30 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 11, 0))
31 +static irqreturn_t qca808x_handle_interrupt(struct phy_device *phydev)
32 +{
33 + a_uint16_t irq_status, int_enabled;
34 + a_uint32_t dev_id = 0, phy_id = 0;
35 + qca808x_priv *priv = phydev->priv;
36 + const struct qca808x_phy_info *pdata = priv->phy_info;
37 +
38 + if (!pdata) {
39 + return SW_FAIL;
40 + }
41 +
42 + dev_id = pdata->dev_id;
43 + phy_id = pdata->phy_addr;
44 +
45 + irq_status = qca808x_phy_reg_read(dev_id, phy_id,
46 + QCA808X_PHY_INTR_STATUS);
47 + if (irq_status < 0) {
48 + phy_error(phydev);
49 + return IRQ_NONE;
50 + }
51 +
52 + /* Read the current enabled interrupts */
53 + int_enabled = qca808x_phy_reg_read(dev_id, phy_id,
54 + QCA808X_PHY_INTR_MASK);
55 + if (int_enabled < 0) {
56 + phy_error(phydev);
57 + return IRQ_NONE;
58 + }
59 +
60 + /* See if this was one of our enabled interrupts */
61 + if (!(irq_status & int_enabled))
62 + return IRQ_NONE;
63 +
64 + phy_trigger_machine(phydev);
65 +
66 + return IRQ_HANDLED;
67 +}
68 +#endif
69
70 /* switch linux negtiation capability to fal avariable */
71 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0))
72 @@ -638,7 +680,11 @@ struct phy_driver qca808x_phy_driver = {
73 .config_intr = qca808x_config_intr,
74 .config_aneg = qca808x_config_aneg,
75 .aneg_done = qca808x_aneg_done,
76 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
77 .ack_interrupt = qca808x_ack_interrupt,
78 +#else
79 + .handle_interrupt = qca808x_handle_interrupt,
80 +#endif
81 .read_status = qca808x_read_status,
82 .suspend = qca808x_suspend,
83 .resume = qca808x_resume,