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>,
Christophe Leroy <christophe.leroy@c-s.fr>
Subject: [PATCH RESEND net-next 07/18] net: phy: lxt: implement generic .handle_interrupt() callback
Date: Fri, 13 Nov 2020 18:52:15 +0200 [thread overview]
Message-ID: <20201113165226.561153-8-ciorneiioana@gmail.com> (raw)
In-Reply-To: <20201113165226.561153-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: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
drivers/net/phy/lxt.c | 50 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index fec58ad69e02..716d9936bc90 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -37,6 +37,8 @@
#define MII_LXT970_ISR 18 /* Interrupt Status Register */
+#define MII_LXT970_IRS_MINT BIT(15)
+
#define MII_LXT970_CONFIG 19 /* Configuration Register */
/* ------------------------------------------------------------------------- */
@@ -47,6 +49,7 @@
#define MII_LXT971_IER_IEN 0x00f2
#define MII_LXT971_ISR 19 /* Interrupt Status Register */
+#define MII_LXT971_ISR_MASK 0x00f0
/* register definitions for the 973 */
#define MII_LXT973_PCR 16 /* Port Configuration Register */
@@ -81,6 +84,33 @@ static int lxt970_config_intr(struct phy_device *phydev)
return phy_write(phydev, MII_LXT970_IER, 0);
}
+static irqreturn_t lxt970_handle_interrupt(struct phy_device *phydev)
+{
+ int irq_status;
+
+ /* The interrupt status register is cleared by reading BMSR
+ * followed by MII_LXT970_ISR
+ */
+ irq_status = phy_read(phydev, MII_BMSR);
+ if (irq_status < 0) {
+ phy_error(phydev);
+ return IRQ_NONE;
+ }
+
+ irq_status = phy_read(phydev, MII_LXT970_ISR);
+ if (irq_status < 0) {
+ phy_error(phydev);
+ return IRQ_NONE;
+ }
+
+ if (!(irq_status & MII_LXT970_IRS_MINT))
+ return IRQ_NONE;
+
+ phy_trigger_machine(phydev);
+
+ return IRQ_HANDLED;
+}
+
static int lxt970_config_init(struct phy_device *phydev)
{
return phy_write(phydev, MII_LXT970_CONFIG, 0);
@@ -105,6 +135,24 @@ static int lxt971_config_intr(struct phy_device *phydev)
return phy_write(phydev, MII_LXT971_IER, 0);
}
+static irqreturn_t lxt971_handle_interrupt(struct phy_device *phydev)
+{
+ int irq_status;
+
+ irq_status = phy_read(phydev, MII_LXT971_ISR);
+ if (irq_status < 0) {
+ phy_error(phydev);
+ return IRQ_NONE;
+ }
+
+ if (!(irq_status & MII_LXT971_ISR_MASK))
+ return IRQ_NONE;
+
+ phy_trigger_machine(phydev);
+
+ return IRQ_HANDLED;
+}
+
/*
* A2 version of LXT973 chip has an ERRATA: it randomly return the contents
* of the previous even register when you read a odd register regularly
@@ -239,6 +287,7 @@ static struct phy_driver lxt97x_driver[] = {
.config_init = lxt970_config_init,
.ack_interrupt = lxt970_ack_interrupt,
.config_intr = lxt970_config_intr,
+ .handle_interrupt = lxt970_handle_interrupt,
}, {
.phy_id = 0x001378e0,
.name = "LXT971",
@@ -246,6 +295,7 @@ static struct phy_driver lxt97x_driver[] = {
/* PHY_BASIC_FEATURES */
.ack_interrupt = lxt971_ack_interrupt,
.config_intr = lxt971_config_intr,
+ .handle_interrupt = lxt971_handle_interrupt,
.suspend = genphy_suspend,
.resume = genphy_resume,
}, {
--
2.28.0
next prev parent reply other threads:[~2020-11-13 16:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-13 16:52 [PATCH RESEND net-next 00/18] net: phy: add support for shared interrupts (part 2) Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 01/18] net: phy: vitesse: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 02/18] net: phy: vitesse: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 03/18] net: phy: microchip: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 04/18] net: phy: microchip: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 05/18] net: phy: marvell: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 06/18] net: phy: marvell: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-15 20:56 ` Andrew Lunn
2020-11-13 16:52 ` Ioana Ciornei [this message]
2020-11-13 16:52 ` [PATCH RESEND net-next 08/18] net: phy: lxt: " Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 09/18] net: phy: nxp-tja11xx: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 10/18] net: phy: nxp-tja11xx: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 11/18] net: phy: amd: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 12/18] net: phy: amd: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 13/18] net: phy: smsc: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 14/18] net: phy: smsc: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 15/18] net: phy: ste10Xp: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 16/18] net: phy: ste10Xp: remove the use of .ack_interrupt() Ioana Ciornei
2020-11-13 16:52 ` [PATCH RESEND net-next 17/18] net: phy: adin: implement generic .handle_interrupt() callback Ioana Ciornei
2020-11-14 6:38 ` Ardelean, Alexandru
2020-11-13 16:52 ` [PATCH RESEND net-next 18/18] net: phy: adin: remove the use of the .ack_interrupt() Ioana Ciornei
2020-11-14 6:38 ` Ardelean, Alexandru
2020-11-17 19:40 ` [PATCH RESEND net-next 00/18] net: phy: add support for shared interrupts (part 2) patchwork-bot+netdevbpf
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=20201113165226.561153-8-ciorneiioana@gmail.com \
--to=ciorneiioana@gmail.com \
--cc=andrew@lunn.ch \
--cc=christophe.leroy@c-s.fr \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).