aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/qca-ssdk/patches/0006-qca8081-convert-to-5.11-IRQ-model.patch
blob: 4eb7483d2bc593fb0c8d18f3a9e25a7727bc6235 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From 9278b2794d984f5a8ec2350b9607a35aea2cc106 Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Fri, 24 Dec 2021 20:02:32 +0100
Subject: [PATCH 06/11] qca8081: convert to 5.11 IRQ model

Kernel 5.11 introduced new IRQ handling model for PHY-s,
so provide those if 5.11 or later is used.

Signed-off-by: Robert Marko <robimarko@gmail.com>
---
 src/hsl/phy/qca808x.c | 46 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

--- a/src/hsl/phy/qca808x.c
+++ b/src/hsl/phy/qca808x.c
@@ -247,6 +247,7 @@ static int qca808x_config_intr(struct ph
 	return err;
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 static int qca808x_ack_interrupt(struct phy_device *phydev)
 {
 	int err;
@@ -266,6 +267,47 @@ static int qca808x_ack_interrupt(struct
 
 	return (err < 0) ? err : 0;
 }
+#endif
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 11, 0))
+static irqreturn_t qca808x_handle_interrupt(struct phy_device *phydev)
+{
+	a_uint16_t irq_status, int_enabled;
+	a_uint32_t dev_id = 0, phy_id = 0;
+	qca808x_priv *priv = phydev->priv;
+	const struct qca808x_phy_info *pdata = priv->phy_info;
+
+	if (!pdata) {
+		return SW_FAIL;
+	}
+
+	dev_id = pdata->dev_id;
+	phy_id = pdata->phy_addr;
+
+	irq_status = qca808x_phy_reg_read(dev_id, phy_id,
+					  QCA808X_PHY_INTR_STATUS);
+	if (irq_status < 0) {
+		phy_error(phydev);
+		return IRQ_NONE;
+	}
+
+	/* Read the current enabled interrupts */
+	int_enabled = qca808x_phy_reg_read(dev_id, phy_id,
+					   QCA808X_PHY_INTR_MASK);
+	if (int_enabled < 0) {
+		phy_error(phydev);
+		return IRQ_NONE;
+	}
+
+	/* See if this was one of our enabled interrupts */
+	if (!(irq_status & int_enabled))
+		return IRQ_NONE;
+
+	phy_trigger_machine(phydev);
+
+	return IRQ_HANDLED;
+}
+#endif
 
 /* switch linux negtiation capability to fal avariable */
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0))
@@ -638,7 +680,11 @@ struct phy_driver qca808x_phy_driver = {
 	.config_intr	= qca808x_config_intr,
 	.config_aneg	= qca808x_config_aneg,
 	.aneg_done	= qca808x_aneg_done,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 	.ack_interrupt	= qca808x_ack_interrupt,
+#else
+	.handle_interrupt = qca808x_handle_interrupt,
+#endif
 	.read_status	= qca808x_read_status,
 	.suspend	= qca808x_suspend,
 	.resume		= qca808x_resume,