netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next v2 05/11] net: bcmgenet: request Wake-on-LAN interrupt
Date: Mon, 21 Jul 2014 15:29:23 -0700	[thread overview]
Message-ID: <1405981769-24618-6-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1405981769-24618-1-git-send-email-f.fainelli@gmail.com>

Attempt to the request the Wake-on-LAN interrupt bit, and if successful,
advertise wakeup capability instead of doing this unconditionnally.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- update wol_irq_disabled to be a real boolean type

 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 19 +++++++++++++++++--
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |  2 ++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index bbd8bf326a35..344a889deaaa 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1918,6 +1918,15 @@ static irqreturn_t bcmgenet_isr0(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t bcmgenet_wol_isr(int irq, void *dev_id)
+{
+	struct bcmgenet_priv *priv = dev_id;
+
+	pm_wakeup_event(&priv->pdev->dev, 0);
+
+	return IRQ_HANDLED;
+}
+
 static void bcmgenet_umac_reset(struct bcmgenet_priv *priv)
 {
 	u32 reg;
@@ -2046,8 +2055,6 @@ static int bcmgenet_open(struct net_device *dev)
 		bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
 	}
 
-	device_set_wakeup_capable(&dev->dev, 1);
-
 	/* Disable RX/TX DMA and flush TX queues */
 	dma_ctrl = bcmgenet_dma_disable(priv);
 
@@ -2473,6 +2480,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
 	priv = netdev_priv(dev);
 	priv->irq0 = platform_get_irq(pdev, 0);
 	priv->irq1 = platform_get_irq(pdev, 1);
+	priv->wol_irq = platform_get_irq(pdev, 2);
 	if (!priv->irq0 || !priv->irq1) {
 		dev_err(&pdev->dev, "can't find IRQs\n");
 		err = -EINVAL;
@@ -2507,6 +2515,13 @@ static int bcmgenet_probe(struct platform_device *pdev)
 	dev->hw_features |= NETIF_F_SG | NETIF_F_IP_CSUM |
 		NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM;
 
+	/* Request the WOL interrupt and advertise suspend if available */
+	priv->wol_irq_disabled = true;
+	err = devm_request_irq(&pdev->dev, priv->wol_irq, bcmgenet_wol_isr, 0,
+			       dev->name, priv);
+	if (!err)
+		device_set_wakeup_capable(&pdev->dev, 1);
+
 	/* Set the needed headroom to account for any possible
 	 * features enabling/disabling at runtime
 	 */
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
index f4891a1b6758..64bc53d86480 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
@@ -569,6 +569,8 @@ struct bcmgenet_priv {
 	int irq1;
 	unsigned int irq0_stat;
 	unsigned int irq1_stat;
+	int wol_irq;
+	bool wol_irq_disabled;
 
 	/* HW descriptors/checksum variables */
 	bool desc_64b_en;
-- 
1.9.1

  parent reply	other threads:[~2014-07-21 22:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 22:29 [PATCH net-next v2 00/11] net: bcmgenet: PM and Wake-on-LAN Florian Fainelli
2014-07-21 22:29 ` [PATCH net-next v2 01/11] net: bcmgenet: remove wol_enabled conditional code Florian Fainelli
2014-07-21 22:29 ` [PATCH net-next v2 02/11] net: bcmgenet: add umac_enable_set helper Florian Fainelli
2014-07-21 22:29 ` [PATCH net-next v2 03/11] net: bcmgenet: modularize bcmgenet_{open,close} Florian Fainelli
2014-07-21 22:29 ` [PATCH net-next v2 04/11] net: bcmgenet: add suspend/resume callbacks Florian Fainelli
2014-07-21 22:29 ` Florian Fainelli [this message]
2014-07-21 22:29 ` [PATCH net-next v2 06/11] net: bcmgenet: add Wake-on-LAN support code Florian Fainelli
2014-07-21 22:29 ` [PATCH net-next v2 07/11] net: bcmgenet: handle GENET_POWER_WOL_MAGIC Florian Fainelli
2014-07-21 22:29 ` [PATCH net-next v2 08/11] net: bcmgenet: handle UMAC_IRQ_MPD_R interrupt bit Florian Fainelli
2014-07-21 22:29 ` [PATCH net-next v2 09/11] net: bcmgenet: fix bcmgenet_wol_resume Florian Fainelli
2014-07-21 22:29 ` [PATCH net-next v2 10/11] net: bcmgenet: suspend and resume from Wake-on-LAN Florian Fainelli
2014-07-21 22:29 ` [PATCH net-next v2 11/11] net: bcmgenet: hook ethtool set/get_wol operations Florian Fainelli
2014-07-21 23:07 ` [PATCH net-next v2 00/11] net: bcmgenet: PM and Wake-on-LAN David Miller
2014-07-22 20:20 ` Francois Romieu
2014-07-22 20:29   ` Florian Fainelli

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=1405981769-24618-6-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=davem@davemloft.net \
    --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).