2024-04-09 16:39:46 +00:00
|
|
|
From d7943c31d57c11e1a517aa3ce2006fca44866870 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jianhui Zhao <zhaojh329@gmail.com>
|
|
|
|
Date: Sun, 24 Sep 2023 22:15:00 +0800
|
|
|
|
Subject: [PATCH] net: phy: realtek: add interrupt support for RTL8221B
|
|
|
|
|
|
|
|
This commit introduces interrupt support for RTL8221B.
|
|
|
|
|
|
|
|
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
|
|
|
|
---
|
|
|
|
drivers/net/phy/realtek.c | 47 +++++++++++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 47 insertions(+)
|
|
|
|
|
2024-01-03 11:57:28 +00:00
|
|
|
--- a/drivers/net/phy/realtek.c
|
|
|
|
+++ b/drivers/net/phy/realtek.c
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1282,6 +1282,51 @@ static irqreturn_t rtl9000a_handle_inter
|
2024-06-24 17:22:51 +00:00
|
|
|
return IRQ_HANDLED;
|
2024-01-03 11:57:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+static int rtl8221b_ack_interrupt(struct phy_device *phydev)
|
|
|
|
+{
|
|
|
|
+ int err;
|
|
|
|
+
|
2024-06-24 17:22:51 +00:00
|
|
|
+ err = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0xa4d4);
|
2024-01-03 11:57:28 +00:00
|
|
|
+
|
|
|
|
+ return (err < 0) ? err : 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int rtl8221b_config_intr(struct phy_device *phydev)
|
|
|
|
+{
|
|
|
|
+ int err;
|
|
|
|
+
|
|
|
|
+ if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
|
|
|
|
+ err = rtl8221b_ack_interrupt(phydev);
|
|
|
|
+ if (err)
|
|
|
|
+ return err;
|
|
|
|
+
|
2024-06-24 17:22:51 +00:00
|
|
|
+ err = phy_write_mmd(phydev, MDIO_MMD_VEND2, 0xa4d2, 0x7ff);
|
2024-01-03 11:57:28 +00:00
|
|
|
+ } else {
|
2024-06-24 17:22:51 +00:00
|
|
|
+ err = phy_write_mmd(phydev, MDIO_MMD_VEND2, 0xa4d2, 0x0);
|
2024-01-03 11:57:28 +00:00
|
|
|
+ if (err)
|
|
|
|
+ return err;
|
|
|
|
+
|
|
|
|
+ err = rtl8221b_ack_interrupt(phydev);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return err;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static irqreturn_t rtl8221b_handle_interrupt(struct phy_device *phydev)
|
|
|
|
+{
|
|
|
|
+ int err;
|
|
|
|
+
|
|
|
|
+ err = rtl8221b_ack_interrupt(phydev);
|
|
|
|
+ if (err) {
|
|
|
|
+ phy_error(phydev);
|
|
|
|
+ return IRQ_NONE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ phy_trigger_machine(phydev);
|
|
|
|
+
|
|
|
|
+ return IRQ_HANDLED;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static struct phy_driver realtek_drvs[] = {
|
|
|
|
{
|
|
|
|
PHY_ID_MATCH_EXACT(0x00008201),
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1448,6 +1493,8 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
.match_phy_device = rtl8221b_vb_cg_c22_match_phy_device,
|
|
|
|
.name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)",
|
|
|
|
+ .config_intr = rtl8221b_config_intr,
|
|
|
|
+ .handle_interrupt = rtl8221b_handle_interrupt,
|
|
|
|
.probe = rtl822x_probe,
|
|
|
|
.soft_reset = genphy_soft_reset,
|
|
|
|
.get_features = rtl822x_get_features,
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1462,6 +1509,8 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
.match_phy_device = rtl8221b_vb_cg_c45_match_phy_device,
|
|
|
|
.name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)",
|
|
|
|
+ .config_intr = rtl8221b_config_intr,
|
|
|
|
+ .handle_interrupt = rtl8221b_handle_interrupt,
|
|
|
|
.probe = rtl822x_probe,
|
|
|
|
.soft_reset = genphy_soft_reset,
|
|
|
|
.config_init = rtl822xb_config_init,
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1474,6 +1523,8 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
.match_phy_device = rtl8221b_vn_cg_c22_match_phy_device,
|
|
|
|
.name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)",
|
|
|
|
+ .config_intr = rtl8221b_config_intr,
|
|
|
|
+ .handle_interrupt = rtl8221b_handle_interrupt,
|
|
|
|
.probe = rtl822x_probe,
|
|
|
|
.soft_reset = genphy_soft_reset,
|
2024-01-03 11:57:28 +00:00
|
|
|
.get_features = rtl822x_get_features,
|
2024-10-08 23:19:26 +00:00
|
|
|
@@ -1488,6 +1539,8 @@ static struct phy_driver realtek_drvs[]
|
2024-06-24 17:22:51 +00:00
|
|
|
}, {
|
|
|
|
.match_phy_device = rtl8221b_vn_cg_c45_match_phy_device,
|
|
|
|
.name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)",
|
2024-01-03 11:57:28 +00:00
|
|
|
+ .config_intr = rtl8221b_config_intr,
|
|
|
|
+ .handle_interrupt = rtl8221b_handle_interrupt,
|
|
|
|
.probe = rtl822x_probe,
|
2024-06-24 17:22:51 +00:00
|
|
|
.soft_reset = genphy_soft_reset,
|
|
|
|
.config_init = rtl822xb_config_init,
|