macb add support for phy gpio interrupt
Subsystems (4)
cover macb add support for phy gpio interrupt
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.
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 | 4 ++++ 3 files changed, 29 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.0
PATCH 1/3 net/phy/davicom: add irq functions to DM9161E and DM9161A
Both these PHYs support interrupt generation on IC pin 32.
--- drivers/net/phy/davicom.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/phy/davicom.c +4 -0
@@ -153,6 +153,8 @@ static struct phy_driver dm91xx_driver[] = { .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,
@@ -162,6 +164,8 @@ static struct phy_driver dm91xx_driver[] = { .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,
Signature · 1 line
1.8.0
PATCH 2/3 net/macb: add support for phy irq via gpio pin
In reply to Joachim Eastwood--- drivers/net/ethernet/cadence/macb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb.c +11 -1
@@ -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,
Signature · 1 line
1.8.0
PATCH 3/3 net/macb: clear unused address register
In reply to Joachim EastwoodOnly 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.
--- drivers/net/ethernet/cadence/macb.c | 8 ++++++++ drivers/net/ethernet/cadence/macb.h | 6 ++++++ 2 files changed, 14 insertions(+)
drivers/net/ethernet/cadence/macb.c +8 -0
@@ -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);
drivers/net/ethernet/cadence/macb.h +6 -0
@@ -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
Signature · 1 line
1.8.0