netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] macb add support for phy gpio interrupt
@ 2012-11-11 23:56 Joachim Eastwood
  2012-11-11 23:56 ` [PATCH v2 1/3] net/phy/davicom: add irq functions to DM9161E and DM9161A Joachim Eastwood
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Joachim Eastwood @ 2012-11-11 23:56 UTC (permalink / raw)
  To: nicolas.ferre, davem; +Cc: plagnioj, netdev, Joachim Eastwood

Main feature of this patch set is phy gpio interrupt for macb.

There is a couple of concerns about this patch series.
* PHY interrupt support has never been supported with macb before but many board have set phy_irq_pin variable. These board will be swapped over to interrupt handing now and while this should work but one can never be 100% certain.
* at91_ether driver supported interrupt on some PHYs which does not have PHY drivers in phylib or doesn't have interrupt support hooked up.

Patch 1 add interrupt handing to a couple of Davicom PHY that is used on most (all?) Atmel eval boards and was also popular on custom boards.

If the 2nd patch breaks any boards there are 2 possible ways to fix the issue. One would be to go back to polling by setting phy_irq_pin to EINVAL. The other would be add a proper PHY driver with interrupt support for the PHY in question.

I would be grateful if anyone can test the 2 first patches on any AT91 boards that they might have access to. If there is any breakage I am more than willing to help out.
Patch series was tested on a custom board with DM9161AEP and AT91RM9200 EMAC.


Last patch in this series is unrelated to the phy stuff. It's is a small fix for macb hw set addr functions when used in at91_ether.

v2: set PHY_HAS_INTERRUPT in phy_driver flags.

Joachim Eastwood (3):
  net/phy/davicom: add irq functions to DM9161E and DM9161A
  net/macb: add support for phy irq via gpio pin
  net/macb: clear unused address register

 drivers/net/ethernet/cadence/macb.c | 20 +++++++++++++++++++-
 drivers/net/ethernet/cadence/macb.h |  6 ++++++
 drivers/net/phy/davicom.c           |  6 ++++++
 3 files changed, 31 insertions(+), 1 deletion(-)

-- 
1.8.0

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

* [PATCH v2 1/3] net/phy/davicom: add irq functions to DM9161E and DM9161A
  2012-11-11 23:56 [PATCH v2 0/3] macb add support for phy gpio interrupt Joachim Eastwood
@ 2012-11-11 23:56 ` Joachim Eastwood
  2012-11-11 23:56 ` [PATCH v2 2/3] net/macb: add support for phy irq via gpio pin Joachim Eastwood
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Joachim Eastwood @ 2012-11-11 23:56 UTC (permalink / raw)
  To: nicolas.ferre, davem; +Cc: plagnioj, netdev, Joachim Eastwood

Both these PHYs support interrupt generation on IC pin 32.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/phy/davicom.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
index 81c7bc0..383e833 100644
--- a/drivers/net/phy/davicom.c
+++ b/drivers/net/phy/davicom.c
@@ -150,18 +150,24 @@ static struct phy_driver dm91xx_driver[] = {
 	.name		= "Davicom DM9161E",
 	.phy_id_mask	= 0x0ffffff0,
 	.features	= PHY_BASIC_FEATURES,
+	.flags		= PHY_HAS_INTERRUPT,
 	.config_init	= dm9161_config_init,
 	.config_aneg	= dm9161_config_aneg,
 	.read_status	= genphy_read_status,
+	.ack_interrupt	= dm9161_ack_interrupt,
+	.config_intr	= dm9161_config_intr,
 	.driver		= { .owner = THIS_MODULE,},
 }, {
 	.phy_id		= 0x0181b8a0,
 	.name		= "Davicom DM9161A",
 	.phy_id_mask	= 0x0ffffff0,
 	.features	= PHY_BASIC_FEATURES,
+	.flags		= PHY_HAS_INTERRUPT,
 	.config_init	= dm9161_config_init,
 	.config_aneg	= dm9161_config_aneg,
 	.read_status	= genphy_read_status,
+	.ack_interrupt	= dm9161_ack_interrupt,
+	.config_intr	= dm9161_config_intr,
 	.driver		= { .owner = THIS_MODULE,},
 }, {
 	.phy_id		= 0x00181b80,
-- 
1.8.0

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

* [PATCH v2 2/3] net/macb: add support for phy irq via gpio pin
  2012-11-11 23:56 [PATCH v2 0/3] macb add support for phy gpio interrupt Joachim Eastwood
  2012-11-11 23:56 ` [PATCH v2 1/3] net/phy/davicom: add irq functions to DM9161E and DM9161A Joachim Eastwood
@ 2012-11-11 23:56 ` Joachim Eastwood
  2012-11-11 23:56 ` [PATCH v2 3/3] net/macb: clear unused address register Joachim Eastwood
  2012-11-15  3:23 ` [PATCH v2 0/3] macb add support for phy gpio interrupt David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Joachim Eastwood @ 2012-11-11 23:56 UTC (permalink / raw)
  To: nicolas.ferre, davem; +Cc: plagnioj, netdev, Joachim Eastwood

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/cadence/macb.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 1fac769..ca34efc 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -16,6 +16,7 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/gpio.h>
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -261,7 +262,9 @@ static void macb_handle_link_change(struct net_device *dev)
 static int macb_mii_probe(struct net_device *dev)
 {
 	struct macb *bp = netdev_priv(dev);
+	struct macb_platform_data *pdata;
 	struct phy_device *phydev;
+	int phy_irq;
 	int ret;
 
 	phydev = phy_find_first(bp->mii_bus);
@@ -270,7 +273,14 @@ static int macb_mii_probe(struct net_device *dev)
 		return -1;
 	}
 
-	/* TODO : add pin_irq */
+	pdata = dev_get_platdata(&bp->pdev->dev);
+	if (pdata && gpio_is_valid(pdata->phy_irq_pin)) {
+		ret = devm_gpio_request(&bp->pdev->dev, pdata->phy_irq_pin, "phy int");
+		if (!ret) {
+			phy_irq = gpio_to_irq(pdata->phy_irq_pin);
+			phydev->irq = (phy_irq < 0) ? PHY_POLL : phy_irq;
+		}
+	}
 
 	/* attach the mac to the phy */
 	ret = phy_connect_direct(dev, phydev, &macb_handle_link_change, 0,
-- 
1.8.0

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

* [PATCH v2 3/3] net/macb: clear unused address register
  2012-11-11 23:56 [PATCH v2 0/3] macb add support for phy gpio interrupt Joachim Eastwood
  2012-11-11 23:56 ` [PATCH v2 1/3] net/phy/davicom: add irq functions to DM9161E and DM9161A Joachim Eastwood
  2012-11-11 23:56 ` [PATCH v2 2/3] net/macb: add support for phy irq via gpio pin Joachim Eastwood
@ 2012-11-11 23:56 ` Joachim Eastwood
  2012-11-15  3:23 ` [PATCH v2 0/3] macb add support for phy gpio interrupt David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Joachim Eastwood @ 2012-11-11 23:56 UTC (permalink / raw)
  To: nicolas.ferre, davem; +Cc: plagnioj, netdev, Joachim Eastwood

Only the first register set is used for matching but
we support getting the initial hw addr from any of
the registers.

To prevent stale entries and false matches clear unused
register sets. This most important for the at91_ether
driver where u-boot always uses the 2nd register set.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/cadence/macb.c | 8 ++++++++
 drivers/net/ethernet/cadence/macb.h | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index ca34efc..edb2aba 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -108,6 +108,14 @@ void macb_set_hwaddr(struct macb *bp)
 	macb_or_gem_writel(bp, SA1B, bottom);
 	top = cpu_to_le16(*((u16 *)(bp->dev->dev_addr + 4)));
 	macb_or_gem_writel(bp, SA1T, top);
+
+	/* Clear unused address register sets */
+	macb_or_gem_writel(bp, SA2B, 0);
+	macb_or_gem_writel(bp, SA2T, 0);
+	macb_or_gem_writel(bp, SA3B, 0);
+	macb_or_gem_writel(bp, SA3T, 0);
+	macb_or_gem_writel(bp, SA4B, 0);
+	macb_or_gem_writel(bp, SA4T, 0);
 }
 EXPORT_SYMBOL_GPL(macb_set_hwaddr);
 
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 864e380..4414421 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -74,6 +74,12 @@
 #define GEM_HRT					0x0084
 #define GEM_SA1B				0x0088
 #define GEM_SA1T				0x008C
+#define GEM_SA2B				0x0090
+#define GEM_SA2T				0x0094
+#define GEM_SA3B				0x0098
+#define GEM_SA3T				0x009C
+#define GEM_SA4B				0x00A0
+#define GEM_SA4T				0x00A4
 #define GEM_OTX					0x0100
 #define GEM_DCFG1				0x0280
 #define GEM_DCFG2				0x0284
-- 
1.8.0

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

* Re: [PATCH v2 0/3] macb add support for phy gpio interrupt
  2012-11-11 23:56 [PATCH v2 0/3] macb add support for phy gpio interrupt Joachim Eastwood
                   ` (2 preceding siblings ...)
  2012-11-11 23:56 ` [PATCH v2 3/3] net/macb: clear unused address register Joachim Eastwood
@ 2012-11-15  3:23 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2012-11-15  3:23 UTC (permalink / raw)
  To: manabian; +Cc: nicolas.ferre, plagnioj, netdev

From: Joachim Eastwood <manabian@gmail.com>
Date: Mon, 12 Nov 2012 00:56:25 +0100

> Main feature of this patch set is phy gpio interrupt for macb.
 ...
> Patch series was tested on a custom board with DM9161AEP and AT91RM9200 EMAC.

Applied.

If there are problems found during testing we can fix or revert.

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

end of thread, other threads:[~2012-11-15  3:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-11 23:56 [PATCH v2 0/3] macb add support for phy gpio interrupt Joachim Eastwood
2012-11-11 23:56 ` [PATCH v2 1/3] net/phy/davicom: add irq functions to DM9161E and DM9161A Joachim Eastwood
2012-11-11 23:56 ` [PATCH v2 2/3] net/macb: add support for phy irq via gpio pin Joachim Eastwood
2012-11-11 23:56 ` [PATCH v2 3/3] net/macb: clear unused address register Joachim Eastwood
2012-11-15  3:23 ` [PATCH v2 0/3] macb add support for phy gpio interrupt David Miller

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).