netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anatolij Gustschin <agust@denx.de>
To: netdev@vger.kernel.org
Cc: Anatolij Gustschin <agust@denx.de>
Subject: [PATCH 2/3] phylib: add support for shared PHY interrupts
Date: Mon, 16 Feb 2009 21:53:50 +0100	[thread overview]
Message-ID: <1234817631-7981-2-git-send-email-agust@denx.de> (raw)
In-Reply-To: <1234817631-7981-1-git-send-email-agust@denx.de>

Marvell 88E1121R PHY device can be hardware-configured
to use shared interrupt pin for both PHY ports. This
patch adds support for shared PHY interrupts to the PHY
framework to enable support for such PHY configurations.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 drivers/net/phy/phy.c        |   13 +++++++++++++
 drivers/net/phy/phy_device.c |    2 ++
 include/linux/phy.h          |    4 ++++
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index df4e625..93d387e 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -657,9 +657,17 @@ EXPORT_SYMBOL(phy_stop_interrupts);
 static void phy_change(struct work_struct *work)
 {
 	int err;
+	int src;
 	struct phy_device *phydev =
 		container_of(work, struct phy_device, phy_queue);
 
+	if (phydev->drv->flags & PHY_INTERRUPTS_SHARED
+	    && phydev->drv->interrupt_src) {
+		src = phydev->drv->interrupt_src(phydev);
+		if ((src == -1) || (src != phydev->addr))
+			goto ignore;
+	}
+
 	err = phy_disable_interrupts(phydev);
 
 	if (err)
@@ -688,6 +696,11 @@ static void phy_change(struct work_struct *work)
 
 	return;
 
+ignore:
+	atomic_dec(&phydev->irq_disable);
+	enable_irq(phydev->irq);
+	return;
+
 irq_enable_err:
 	disable_irq(phydev->irq);
 	atomic_inc(&phydev->irq_disable);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index e11b03b..dccc445 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -401,6 +401,8 @@ void phy_detach(struct phy_device *phydev)
 	 * real driver could be loaded */
 	if (phydev->dev.driver == &genphy_driver.driver)
 		device_release_driver(&phydev->dev);
+	else if (phydev->drv->remove)
+		phydev->drv->remove(phydev);
 }
 EXPORT_SYMBOL(phy_detach);
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 77c4ed6..a844c2a 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -49,6 +49,7 @@
 
 #define PHY_HAS_INTERRUPT	0x00000001
 #define PHY_HAS_MAGICANEG	0x00000002
+#define PHY_INTERRUPTS_SHARED	0x00000004
 
 /* Interface Mode definitions */
 typedef enum {
@@ -389,6 +390,9 @@ struct phy_driver {
 	/* Enables or disables interrupts */
 	int (*config_intr)(struct phy_device *phydev);
 
+	/* Returns interrupt source if interrupt pin is shared */
+	int (*interrupt_src)(struct phy_device *phydev);
+
 	/* Clears up any memory if needed */
 	void (*remove)(struct phy_device *phydev);
 
-- 
1.5.4.3


  reply	other threads:[~2009-02-16 20:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-16 20:53 [PATCH 1/3] phylib: Basic support for the M88E1121R Marvell chip Anatolij Gustschin
2009-02-16 20:53 ` Anatolij Gustschin [this message]
2009-02-16 20:53   ` [PATCH 3/3] phylib: shared interrupts support for Marvell 88E1121R PHY Anatolij Gustschin
2009-02-18  1:12     ` Andy Fleming
2009-02-18  0:47   ` [PATCH 2/3] phylib: add support for shared PHY interrupts Andy Fleming
2009-02-27  6:39 ` [PATCH 1/3] phylib: Basic support for the M88E1121R Marvell chip David Miller

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=1234817631-7981-2-git-send-email-agust@denx.de \
    --to=agust@denx.de \
    --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).