mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: phy: microchip_t1: Interrupt support for lan887x
@ 2024-10-01 14:44 Divya Koppera
  2024-10-02 23:23 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Divya Koppera @ 2024-10-01 14:44 UTC (permalink / raw)
  To: arun.ramadoss, UNGLinuxDriver, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, netdev, linux-kernel,
	kalesh-anakkur.purayil, Parthiban.Veerasooran

Add support for link up and link down interrupts in lan887x.

Signed-off-by: Divya Koppera <divya.koppera@microchip.com>
---
v1 -> v2
- Replaced ret with rc return variable.
- Moved interrupt APIs to proper place and removed forward declaration.
- Removed redundant return variable declaration.
---
 drivers/net/phy/microchip_t1.c | 61 ++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/drivers/net/phy/microchip_t1.c b/drivers/net/phy/microchip_t1.c
index a5ef8fe50704..f99f37634d5e 100644
--- a/drivers/net/phy/microchip_t1.c
+++ b/drivers/net/phy/microchip_t1.c
@@ -226,6 +226,18 @@
 #define MICROCHIP_CABLE_MAX_TIME_DIFF	\
 	(MICROCHIP_CABLE_MIN_TIME_DIFF + MICROCHIP_CABLE_TIME_MARGIN)
 
+#define LAN887X_INT_STS				0xf000
+#define LAN887X_INT_MSK				0xf001
+#define LAN887X_INT_MSK_T1_PHY_INT_MSK		BIT(2)
+#define LAN887X_INT_MSK_LINK_UP_MSK		BIT(1)
+#define LAN887X_INT_MSK_LINK_DOWN_MSK		BIT(0)
+
+#define LAN887X_MX_CHIP_TOP_LINK_MSK	(LAN887X_INT_MSK_LINK_UP_MSK |\
+					 LAN887X_INT_MSK_LINK_DOWN_MSK)
+
+#define LAN887X_MX_CHIP_TOP_ALL_MSK	(LAN887X_INT_MSK_T1_PHY_INT_MSK |\
+					 LAN887X_MX_CHIP_TOP_LINK_MSK)
+
 #define DRIVER_AUTHOR	"Nisar Sayed <nisar.sayed@microchip.com>"
 #define DRIVER_DESC	"Microchip LAN87XX/LAN937x/LAN887x T1 PHY driver"
 
@@ -1474,6 +1486,49 @@ static void lan887x_get_strings(struct phy_device *phydev, u8 *data)
 		ethtool_puts(&data, lan887x_hw_stats[i].string);
 }
 
+static int lan887x_config_intr(struct phy_device *phydev)
+{
+	int rc;
+
+	if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
+		/* Clear the interrupt status before enabling interrupts */
+		rc = phy_read_mmd(phydev, MDIO_MMD_VEND1, LAN887X_INT_STS);
+		if (rc < 0)
+			return rc;
+
+		/* Unmask for enabling interrupt */
+		rc = phy_write_mmd(phydev, MDIO_MMD_VEND1, LAN887X_INT_MSK,
+				   (u16)~LAN887X_MX_CHIP_TOP_ALL_MSK);
+	} else {
+		rc = phy_write_mmd(phydev, MDIO_MMD_VEND1, LAN887X_INT_MSK,
+				   GENMASK(15, 0));
+		if (rc < 0)
+			return rc;
+
+		rc = phy_read_mmd(phydev, MDIO_MMD_VEND1, LAN887X_INT_STS);
+	}
+
+	return rc < 0 ? rc : 0;
+}
+
+static irqreturn_t lan887x_handle_interrupt(struct phy_device *phydev)
+{
+	int irq_status;
+
+	irq_status = phy_read_mmd(phydev, MDIO_MMD_VEND1, LAN887X_INT_STS);
+	if (irq_status < 0) {
+		phy_error(phydev);
+		return IRQ_NONE;
+	}
+
+	if (irq_status & LAN887X_MX_CHIP_TOP_LINK_MSK) {
+		phy_trigger_machine(phydev);
+		return IRQ_HANDLED;
+	}
+
+	return IRQ_NONE;
+}
+
 static int lan887x_cd_reset(struct phy_device *phydev,
 			    enum cable_diag_state cd_done)
 {
@@ -1504,6 +1559,10 @@ static int lan887x_cd_reset(struct phy_device *phydev,
 		if (rc < 0)
 			return rc;
 
+		rc = lan887x_config_intr(phydev);
+		if (rc < 0)
+			return rc;
+
 		rc = lan887x_phy_reconfig(phydev);
 		if (rc < 0)
 			return rc;
@@ -1881,6 +1940,8 @@ static struct phy_driver microchip_t1_phy_driver[] = {
 		.read_status	= genphy_c45_read_status,
 		.cable_test_start = lan887x_cable_test_start,
 		.cable_test_get_status = lan887x_cable_test_get_status,
+		.config_intr    = lan887x_config_intr,
+		.handle_interrupt = lan887x_handle_interrupt,
 	}
 };
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] net: phy: microchip_t1: Interrupt support for lan887x
  2024-10-01 14:44 [PATCH net-next v2] net: phy: microchip_t1: Interrupt support for lan887x Divya Koppera
@ 2024-10-02 23:23 ` Andrew Lunn
  2024-10-03  8:24 ` Kalesh Anakkur Purayil
  2024-10-03 23:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2024-10-02 23:23 UTC (permalink / raw)
  To: Divya Koppera
  Cc: arun.ramadoss, UNGLinuxDriver, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, netdev, linux-kernel,
	kalesh-anakkur.purayil, Parthiban.Veerasooran

On Tue, Oct 01, 2024 at 08:14:21PM +0530, Divya Koppera wrote:
> Add support for link up and link down interrupts in lan887x.
> 
> Signed-off-by: Divya Koppera <divya.koppera@microchip.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] net: phy: microchip_t1: Interrupt support for lan887x
  2024-10-01 14:44 [PATCH net-next v2] net: phy: microchip_t1: Interrupt support for lan887x Divya Koppera
  2024-10-02 23:23 ` Andrew Lunn
@ 2024-10-03  8:24 ` Kalesh Anakkur Purayil
  2024-10-03 23:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kalesh Anakkur Purayil @ 2024-10-03  8:24 UTC (permalink / raw)
  To: Divya Koppera
  Cc: arun.ramadoss, UNGLinuxDriver, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, netdev, linux-kernel,
	Parthiban.Veerasooran

[-- Attachment #1: Type: text/plain, Size: 320 bytes --]

On Tue, Oct 1, 2024 at 8:08 PM Divya Koppera
<divya.koppera@microchip.com> wrote:
>
> Add support for link up and link down interrupts in lan887x.
>
> Signed-off-by: Divya Koppera <divya.koppera@microchip.com>

LGTM,
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>


-- 
Regards,
Kalesh A P

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] net: phy: microchip_t1: Interrupt support for lan887x
  2024-10-01 14:44 [PATCH net-next v2] net: phy: microchip_t1: Interrupt support for lan887x Divya Koppera
  2024-10-02 23:23 ` Andrew Lunn
  2024-10-03  8:24 ` Kalesh Anakkur Purayil
@ 2024-10-03 23:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-03 23:40 UTC (permalink / raw)
  To: Divya Koppera
  Cc: arun.ramadoss, UNGLinuxDriver, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, netdev, linux-kernel,
	kalesh-anakkur.purayil, Parthiban.Veerasooran

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 1 Oct 2024 20:14:21 +0530 you wrote:
> Add support for link up and link down interrupts in lan887x.
> 
> Signed-off-by: Divya Koppera <divya.koppera@microchip.com>
> ---
> v1 -> v2
> - Replaced ret with rc return variable.
> - Moved interrupt APIs to proper place and removed forward declaration.
> - Removed redundant return variable declaration.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: phy: microchip_t1: Interrupt support for lan887x
    https://git.kernel.org/netdev/net-next/c/5fad1c1a09ac

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-03 23:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-01 14:44 [PATCH net-next v2] net: phy: microchip_t1: Interrupt support for lan887x Divya Koppera
2024-10-02 23:23 ` Andrew Lunn
2024-10-03  8:24 ` Kalesh Anakkur Purayil
2024-10-03 23:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®