From: Michael Walle <michael@walle.cc>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S . Miller" <davem@davemloft.net>,
Richard Cochran <richardcochran@gmail.com>,
Michael Walle <michael@walle.cc>
Subject: [RFC PATCH v2 1/2] net: phy: let the driver register its own IRQ handler
Date: Fri, 28 Feb 2020 19:02:25 +0100 [thread overview]
Message-ID: <20200228180226.22986-2-michael@walle.cc> (raw)
In-Reply-To: <20200228180226.22986-1-michael@walle.cc>
There are more and more PHY drivers which has more than just the PHY
link change interrupts. For example, temperature thresholds or PTP
interrupts.
At the moment it is not possible to correctly handle interrupts for PHYs
which has a clear-on-read interrupt status register. It is also likely
that the current approach of the phylib isn't working for all PHYs out
there.
Therefore, this patch let the PHY driver register its own interrupt
handler. To notify the phylib about a link change, the interrupt handler
has to call the new function phy_drv_interrupt().
Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/net/phy/phy_device.c | 6 ++++--
include/linux/phy.h | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 6a5056e0ae77..a30a5472fa46 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -965,7 +965,8 @@ int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
return rc;
phy_prepare_link(phydev, handler);
- if (phy_interrupt_is_valid(phydev))
+ if (phy_interrupt_is_valid(phydev)
+ && !(phydev->drv->flags & PHY_HAS_OWN_IRQ_HANDLER))
phy_request_interrupt(phydev);
return 0;
@@ -2411,7 +2412,8 @@ EXPORT_SYMBOL(phy_validate_pause);
static bool phy_drv_supports_irq(struct phy_driver *phydrv)
{
- return phydrv->config_intr && phydrv->ack_interrupt;
+ return ((phydrv->config_intr && phydrv->ack_interrupt)
+ || phydrv->flags & PHY_HAS_OWN_IRQ_HANDLER);
}
/**
diff --git a/include/linux/phy.h b/include/linux/phy.h
index c570e162e05e..9cadc8ae4e87 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -75,6 +75,7 @@ extern const int phy_10gbit_features_array[1];
#define PHY_IS_INTERNAL 0x00000001
#define PHY_RST_AFTER_CLK_EN 0x00000002
+#define PHY_HAS_OWN_IRQ_HANDLER 0x00000004
#define MDIO_DEVICE_IS_PHY 0x80000000
/* Interface Mode definitions */
--
2.20.1
next prev parent reply other threads:[~2020-02-28 18:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 18:02 [RFC PATCH v2 0/2] AT8031 PHY timestamping support Michael Walle
2020-02-28 18:02 ` Michael Walle [this message]
2020-02-28 18:02 ` [RFC PATCH v2 2/2] net: phy: at803x: add PTP support for AR8031 Michael Walle
2020-03-01 12:22 ` Richard Cochran
2020-02-28 18:15 ` [RFC PATCH v2 0/2] AT8031 PHY timestamping support Richard Cochran
2020-02-28 19:43 ` Michael Walle
2020-02-29 14:48 ` Richard Cochran
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=20200228180226.22986-2-michael@walle.cc \
--to=michael@walle.cc \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
/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).