[1/4] RFC: net/dsa: Allow DSA PHYs to define link IRQs

Message ID 20171105231909.5599-2-linus.walleij@linaro.org
State New
Headers show
Series
  • RFC: Realtek 83xx SMI driver core
Related show

Commit Message

Linus Walleij Nov. 5, 2017, 11:19 p.m.
PHYs attached to DSAs may provide IRQs from GPIOs or other
interrupt controllers in the device tree. For these cases,
we need to go and grab the IRQ before registering the slave
so the PHY core can grab and enable this IRQ.

Cc: Antti Seppälä <a.seppala@gmail.com>
Cc: Roman Yeryomin <roman@advem.lv>
Cc: Colin Leitner <colin.leitner@googlemail.com>
Cc: Gabor Juhos <juhosg@openwrt.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 net/dsa/slave.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.13.6

Patch

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 2afa99506f8b..9909d7fe80b1 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -15,6 +15,7 @@ 
 #include <linux/phy_fixed.h>
 #include <linux/of_net.h>
 #include <linux/of_mdio.h>
+#include <linux/of_irq.h>
 #include <linux/mdio.h>
 #include <linux/list.h>
 #include <net/rtnetlink.h>
@@ -1119,6 +1120,13 @@  static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
 		return -ENODEV;
 	}
 
+	/*
+	 * If the PHY has a link IRQ associated with it in the device tree,
+	 * then assign it so it can be claimed by the core.
+	 */
+	if (of_irq_count(p->dp->dn))
+		p->phy->irq = irq_of_parse_and_map(p->dp->dn, 0);
+
 	/* Use already configured phy mode */
 	if (p->phy_interface == PHY_INTERFACE_MODE_NA)
 		p->phy_interface = p->phy->interface;