netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: netdev <netdev@vger.kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Jason Cooper <jason@lakedaemon.net>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Subject: [RFC PATCH 7/8] net: dsa: Support phy interrupt property for switch ports.
Date: Mon, 14 Mar 2016 01:33:50 +0100	[thread overview]
Message-ID: <1457915631-16696-8-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1457915631-16696-1-git-send-email-andrew@lunn.ch>

Switch ports can be connected to phys. These phys can support
interrupts when the link goes up/down. Allow the phy interrupt to be
expressed in device tree, and pass it to the phylib when the phy is
bound to the switch port.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 Documentation/devicetree/bindings/net/dsa/dsa.txt |  3 +++
 net/dsa/dsa_priv.h                                |  1 +
 net/dsa/slave.c                                   | 11 ++++++++++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt
index 90a4fe115e50..780c96f37508 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.txt
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt
@@ -55,6 +55,9 @@ Optionnal property:
 			  Documentation/devicetree/bindings/net/ethernet.txt
 			  for details.
 
+- interrupt-parent	: property with a value describing the phy
+- interrupts		  interrupt number. See Documentation/devicetree/bindings/net/phy.txt
+
 - phy-mode		: String representing the connection to the designated
 			  PHY node specified by the 'phy-handle' property. See
 			  Documentation/devicetree/bindings/net/ethernet.txt
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 1d1a54687e4a..5ce368ea0464 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -46,6 +46,7 @@ struct dsa_slave_priv {
 	int			old_link;
 	int			old_pause;
 	int			old_duplex;
+	int			phy_irq;
 
 	struct net_device	*bridge_dev;
 #ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 27bf03d11670..155bddc43624 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -13,6 +13,7 @@
 #include <linux/netdevice.h>
 #include <linux/phy.h>
 #include <linux/phy_fixed.h>
+#include <linux/of_irq.h>
 #include <linux/of_net.h>
 #include <linux/of_mdio.h>
 #include <linux/mdio.h>
@@ -921,6 +922,10 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
 	/* Use already configured phy mode */
 	if (p->phy_interface == PHY_INTERFACE_MODE_NA)
 		p->phy_interface = p->phy->interface;
+
+	if (p->phy_irq)
+		p->phy->irq = p->phy_irq;
+
 	phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
 			   p->phy_interface);
 
@@ -935,7 +940,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 	struct device_node *phy_dn, *port_dn;
 	bool phy_is_fixed = false;
 	u32 phy_flags = 0;
-	int mode, ret;
+	int mode, ret, irq;
 
 	port_dn = cd->port_dn[p->port];
 	mode = of_get_phy_mode(port_dn);
@@ -943,6 +948,10 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 		mode = PHY_INTERFACE_MODE_NA;
 	p->phy_interface = mode;
 
+	irq = irq_of_parse_and_map(port_dn, 0);
+	if (irq > 0)
+		p->phy_irq = irq;
+
 	phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
 	if (of_phy_is_fixed_link(port_dn)) {
 		/* In the case of a fixed PHY, the DT node associated
-- 
2.7.0

  parent reply	other threads:[~2016-03-14  0:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14  0:33 [RFC PATCH 0/8] Add irq controller support to Marvell switches Andrew Lunn
2016-03-14  0:33 ` [RFC PATCH 1/8] net: dsa: Add parsing of an interrupt property Andrew Lunn
2016-03-14  0:33 ` [RFC PATCH 2/8] dsa: mv88e6xxx: Add support for switch and device interrupts Andrew Lunn
2016-03-14  0:33 ` [RFC PATCH 3/8] dsa: mv88e6352: Wire up the mv88e6xxx interrupt code Andrew Lunn
2016-03-14  0:33 ` [RFC PATCH 4/8] dsa: mv88e6171: " Andrew Lunn
2016-03-14  0:33 ` [RFC PATCH 5/8] dsa: mv88e6123_61_65: " Andrew Lunn
2016-03-14  0:33 ` [RFC PATCH 6/8] dsa: mv88e6131: " Andrew Lunn
2016-03-14  0:33 ` Andrew Lunn [this message]
2016-03-14  0:33 ` [RFC PATCH 8/8] net: phy: Use threaded IRQ, to allow IRQ from sleeping devices Andrew Lunn

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=1457915631-16696-8-git-send-email-andrew@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=jason@lakedaemon.net \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.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).