All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ioana Ciornei <ciorneiioana@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Ioana Ciornei <ioana.ciornei@nxp.com>,
	Kavya Sree Kotagiri <kavyasree.kotagiri@microchip.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH net-next 01/18] net: phy: vitesse: implement generic .handle_interrupt() callback
Date: Thu, 12 Nov 2020 17:54:56 +0200	[thread overview]
Message-ID: <20201112155513.411604-2-ciorneiioana@gmail.com> (raw)
In-Reply-To: <20201112155513.411604-1-ciorneiioana@gmail.com>

From: Ioana Ciornei <ioana.ciornei@nxp.com>

In an attempt to actually support shared IRQs in phylib, we now move the
responsibility of triggering the phylib state machine or just returning
IRQ_NONE, based on the IRQ status register, to the PHY driver. Having
3 different IRQ handling callbacks (.handle_interrupt(),
.did_interrupt() and .ack_interrupt() ) is confusing so let the PHY
driver implement directly an IRQ handler like any other device driver.
Make this driver follow the new convention.

Cc: Kavya Sree Kotagiri <kavyasree.kotagiri@microchip.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/phy/vitesse.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index bb680352708a..9f6cd6ec9747 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -40,6 +40,11 @@
 #define MII_VSC8244_ISTAT_SPEED		0x4000
 #define MII_VSC8244_ISTAT_LINK		0x2000
 #define MII_VSC8244_ISTAT_DUPLEX	0x1000
+#define MII_VSC8244_ISTAT_MASK		(MII_VSC8244_ISTAT_SPEED | \
+					 MII_VSC8244_ISTAT_LINK | \
+					 MII_VSC8244_ISTAT_DUPLEX)
+
+#define MII_VSC8221_ISTAT_MASK		MII_VSC8244_ISTAT_LINK
 
 /* Vitesse Auxiliary Control/Status Register */
 #define MII_VSC8244_AUX_CONSTAT		0x1c
@@ -311,6 +316,31 @@ static int vsc82xx_config_intr(struct phy_device *phydev)
 	return err;
 }
 
+static irqreturn_t vsc82xx_handle_interrupt(struct phy_device *phydev)
+{
+	int irq_status, irq_mask;
+
+	if (phydev->drv->phy_id == PHY_ID_VSC8244 ||
+	    phydev->drv->phy_id == PHY_ID_VSC8572 ||
+	    phydev->drv->phy_id == PHY_ID_VSC8601)
+		irq_mask = MII_VSC8244_ISTAT_MASK;
+	else
+		irq_mask = MII_VSC8221_ISTAT_MASK;
+
+	irq_status = phy_read(phydev, MII_VSC8244_ISTAT);
+	if (irq_status < 0) {
+		phy_error(phydev);
+		return IRQ_NONE;
+	}
+
+	if (!(irq_status & irq_mask))
+		return IRQ_NONE;
+
+	phy_trigger_machine(phydev);
+
+	return IRQ_HANDLED;
+}
+
 static int vsc8221_config_init(struct phy_device *phydev)
 {
 	int err;
@@ -392,6 +422,7 @@ static struct phy_driver vsc82xx_driver[] = {
 	.config_aneg    = &vsc82x4_config_aneg,
 	.ack_interrupt  = &vsc824x_ack_interrupt,
 	.config_intr    = &vsc82xx_config_intr,
+	.handle_interrupt = &vsc82xx_handle_interrupt,
 }, {
 	.phy_id		= PHY_ID_VSC8244,
 	.name		= "Vitesse VSC8244",
@@ -401,6 +432,7 @@ static struct phy_driver vsc82xx_driver[] = {
 	.config_aneg	= &vsc82x4_config_aneg,
 	.ack_interrupt	= &vsc824x_ack_interrupt,
 	.config_intr	= &vsc82xx_config_intr,
+	.handle_interrupt = &vsc82xx_handle_interrupt,
 }, {
 	.phy_id         = PHY_ID_VSC8572,
 	.name           = "Vitesse VSC8572",
@@ -410,6 +442,7 @@ static struct phy_driver vsc82xx_driver[] = {
 	.config_aneg    = &vsc82x4_config_aneg,
 	.ack_interrupt  = &vsc824x_ack_interrupt,
 	.config_intr    = &vsc82xx_config_intr,
+	.handle_interrupt = &vsc82xx_handle_interrupt,
 }, {
 	.phy_id         = PHY_ID_VSC8601,
 	.name           = "Vitesse VSC8601",
@@ -418,6 +451,7 @@ static struct phy_driver vsc82xx_driver[] = {
 	.config_init    = &vsc8601_config_init,
 	.ack_interrupt  = &vsc824x_ack_interrupt,
 	.config_intr    = &vsc82xx_config_intr,
+	.handle_interrupt = &vsc82xx_handle_interrupt,
 }, {
 	.phy_id         = PHY_ID_VSC7385,
 	.name           = "Vitesse VSC7385",
@@ -463,6 +497,7 @@ static struct phy_driver vsc82xx_driver[] = {
 	.config_aneg    = &vsc82x4_config_aneg,
 	.ack_interrupt  = &vsc824x_ack_interrupt,
 	.config_intr    = &vsc82xx_config_intr,
+	.handle_interrupt = &vsc82xx_handle_interrupt,
 }, {
 	/* Vitesse 8221 */
 	.phy_id		= PHY_ID_VSC8221,
@@ -472,6 +507,7 @@ static struct phy_driver vsc82xx_driver[] = {
 	.config_init	= &vsc8221_config_init,
 	.ack_interrupt	= &vsc824x_ack_interrupt,
 	.config_intr	= &vsc82xx_config_intr,
+	.handle_interrupt = &vsc82xx_handle_interrupt,
 }, {
 	/* Vitesse 8211 */
 	.phy_id		= PHY_ID_VSC8211,
@@ -481,6 +517,7 @@ static struct phy_driver vsc82xx_driver[] = {
 	.config_init	= &vsc8221_config_init,
 	.ack_interrupt	= &vsc824x_ack_interrupt,
 	.config_intr	= &vsc82xx_config_intr,
+	.handle_interrupt = &vsc82xx_handle_interrupt,
 } };
 
 module_phy_driver(vsc82xx_driver);
-- 
2.28.0


  reply	other threads:[~2020-11-12 15:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 15:54 [PATCH net-next 00/18] net: phy: add support for shared interrupts (part 2) Ioana Ciornei
2020-11-12 15:54 ` Ioana Ciornei [this message]
2020-11-12 15:54 ` [PATCH net-next 02/18] net: phy: vitesse: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-12 15:54 ` [PATCH net-next 03/18] net: phy: microchip: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-12 15:54 ` [PATCH net-next 04/18] net: phy: microchip: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 05/18] net: phy: marvell: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 06/18] net: phy: marvell: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 07/18] net: phy: lxt: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 08/18] net: phy: lxt: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 09/18] net: phy: nxp-tja11xx: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 10/18] net: phy: nxp-tja11xx: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 11/18] net: phy: amd: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 12/18] net: phy: amd: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 13/18] net: phy: smsc: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 14/18] net: phy: smsc: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 15/18] net: phy: ste10Xp: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 16/18] net: phy: ste10Xp: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 17/18] net: phy: adin: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-12 15:55 ` [PATCH net-next 18/18] net: phy: adin: remove the use of the .ack_interrupt() Ioana Ciornei
2020-11-13  2:19 ` [PATCH net-next 00/18] net: phy: add support for shared interrupts (part 2) Jakub Kicinski
2020-11-13  8:17   ` Ioana Ciornei
2020-11-13 19:54     ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201112155513.411604-2-ciorneiioana@gmail.com \
    --to=ciorneiioana@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=kavyasree.kotagiri@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.