From: Linus Walleij <linus.walleij@linaro.org>
To: netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
Steve Glendinning <steve.glendinning@smsc.com>
Cc: Guenter Roeck <linux@roeck-us.net>,
Jeremy Linton <jeremy.linton@arm.com>,
Kamlakant Patel <kamlakant.patel@broadcom.com>,
Pavel Fedin <p.fedin@samsung.com>,
Linus Walleij <linus.walleij@linaro.org>,
Sudeep Holla <sudeep.holla@arm.com>,
Tony Lindgren <tony@atomide.com>,
Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH 3/3 v2] net: smsc911x: add wake-up event interrupt support
Date: Wed, 24 Aug 2016 14:59:42 +0200 [thread overview]
Message-ID: <1472043582-7653-3-git-send-email-linus.walleij@linaro.org> (raw)
In-Reply-To: <1472043582-7653-1-git-send-email-linus.walleij@linaro.org>
The SMSC911x have a line out of the chip called "PME",
Power Management Event. When connected to an asynchronous
interrupt controller this is able to wake the system up
from sleep in response to certain network events.
This is the first attempt to support this in the Linux
driver: the Qualcomm APQ8060 Dragonboard has this line
routed to a GPIO line on the primary SoC padring, and as
such it can be armed as a wakeup interrupt.
The patch is inspired by the wakeup code in the RTC
subsystem.
The code looks for an additional interrupt - apart from the
ordinary device interrupt - and in case that is present,
we register an interrupt handler to respons to this,
and flag the device and this interrupt as a wakeup.
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Call pm_wakeup_event() in the wakeup IRQ thread to
account for the wakeup event.
- Drop the enable/disable_irq_wake() calls from suspend/resume:
this is handled from the irq core when you call
dev_pm_set_wake_irq() as we do.
---
drivers/net/ethernet/smsc/smsc911x.c | 42 ++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 8ab8d4b9614b..8fffc1dc2bdd 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -63,6 +63,7 @@
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/gpio/consumer.h>
+#include <linux/pm_wakeirq.h>
#include "smsc911x.h"
@@ -151,6 +152,9 @@ struct smsc911x_data {
/* Reset GPIO */
struct gpio_desc *reset_gpiod;
+ /* PME interrupt */
+ int pme_irq;
+
/* clock */
struct clk *clk;
};
@@ -1881,6 +1885,19 @@ static irqreturn_t smsc911x_irqhandler(int irq, void *dev_id)
return serviced;
}
+static irqreturn_t smsc911x_pme_irq_thread(int irq, void *dev_id)
+{
+ struct net_device *dev = dev_id;
+ struct smsc911x_data *pdata __maybe_unused = netdev_priv(dev);
+
+ SMSC_TRACE(pdata, pm, "wakeup event");
+ pm_wakeup_event(&dev->dev, 50);
+ /* This signal is active for 50 ms, wait for it to deassert */
+ usleep_range(50000, 100000);
+
+ return IRQ_HANDLED;
+}
+
#ifdef CONFIG_NET_POLL_CONTROLLER
static void smsc911x_poll_controller(struct net_device *dev)
{
@@ -2501,6 +2518,31 @@ static int smsc911x_drv_probe(struct platform_device *pdev)
goto out_disable_resources;
}
+ irq = platform_get_irq(pdev, 1);
+ if (irq == -EPROBE_DEFER) {
+ retval = -EPROBE_DEFER;
+ goto out_disable_resources;
+ /* It's perfectly fine to not have a PME IRQ */
+ } else if (irq > 0) {
+ /*
+ * The Power Management Event (PME) IRQ appears as
+ * a pulse waking up the system from sleep in response to a
+ * network event.
+ */
+ retval = request_threaded_irq(irq, NULL,
+ smsc911x_pme_irq_thread,
+ IRQF_ONESHOT, "smsc911x-pme",
+ dev);
+ if (retval) {
+ SMSC_WARN(pdata, probe,
+ "Unable to claim requested PME irq: %d", irq);
+ goto out_disable_resources;
+ }
+ pdata->pme_irq = irq;
+ device_init_wakeup(&pdev->dev, true);
+ dev_pm_set_wake_irq(&pdev->dev, irq);
+ }
+
netif_carrier_off(dev);
retval = register_netdev(dev);
--
2.7.4
next prev parent reply other threads:[~2016-08-24 13:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 12:59 [PATCH 1/3 v2] net: smsc911x: augment device tree bindings Linus Walleij
2016-08-24 12:59 ` [PATCH 2/3 v2] net: smsc911x: request and deassert optional RESET GPIO Linus Walleij
2016-08-31 15:08 ` Jeremy Linton
2016-09-07 9:59 ` Linus Walleij
2016-08-24 12:59 ` Linus Walleij [this message]
2016-08-26 14:40 ` [PATCH 3/3 v2] net: smsc911x: add wake-up event interrupt support Tony Lindgren
2016-08-31 15:27 ` Jeremy Linton
2016-09-07 13:51 ` Linus Walleij
2016-08-31 15:32 ` Jeremy Linton
2016-08-24 15:55 ` [PATCH 1/3 v2] net: smsc911x: augment device tree bindings Arnd Bergmann
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=1472043582-7653-3-git-send-email-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=jeremy.linton@arm.com \
--cc=kamlakant.patel@broadcom.com \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=p.fedin@samsung.com \
--cc=steve.glendinning@smsc.com \
--cc=sudeep.holla@arm.com \
--cc=tony@atomide.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).