mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Drake <dsd@laptop.org>
To: cbou@mail.ru
To: dwmw2@infradead.org
Cc: dilinger@queued.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] olpc_battery: add wakeup support
Date: Wed, 27 Jul 2011 19:24:26 +0100 (BST)	[thread overview]
Message-ID: <20110727182426.9EE599D401D@zog.reactivated.net> (raw)

Battery and AC events can now be used to wake up the system from suspend.

Signed-off-by: Daniel Drake <dsd@laptop.org>
---
 drivers/power/olpc_battery.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

Depends on power management patches that were merged into linus master
yesterday.

diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 9972268..46a2f07 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -533,6 +533,24 @@ void olpc_battery_trigger_uevent(unsigned long cause)
 		kobject_uevent(&olpc_bat.dev->kobj, KOBJ_CHANGE);
 }
 
+static int olpc_battery_suspend(struct platform_device *pdev,
+				pm_message_t state)
+{
+	if (device_may_wakeup(olpc_ac.dev))
+		olpc_ec_wakeup_set(EC_SCI_SRC_ACPWR);
+	else
+		olpc_ec_wakeup_clear(EC_SCI_SRC_ACPWR);
+
+	if (device_may_wakeup(olpc_bat.dev))
+		olpc_ec_wakeup_set(EC_SCI_SRC_BATTERY | EC_SCI_SRC_BATSOC
+				   | EC_SCI_SRC_BATERR);
+	else
+		olpc_ec_wakeup_clear(EC_SCI_SRC_BATTERY | EC_SCI_SRC_BATSOC
+				     | EC_SCI_SRC_BATERR);
+
+	return 0;
+}
+
 static int __devinit olpc_battery_probe(struct platform_device *pdev)
 {
 	int ret;
@@ -578,6 +596,11 @@ static int __devinit olpc_battery_probe(struct platform_device *pdev)
 	if (ret)
 		goto error_failed;
 
+	if (olpc_ec_wakeup_available()) {
+		device_set_wakeup_capable(olpc_ac.dev, true);
+		device_set_wakeup_capable(olpc_bat.dev, true);
+	}
+
 	return 0;
 
 error_failed:
@@ -612,6 +635,7 @@ static struct platform_driver olpc_battery_drv = {
 	},
 	.probe = olpc_battery_probe,
 	.remove = __devexit_p(olpc_battery_remove),
+	.suspend = olpc_battery_suspend,
 };
 
 static int __init olpc_bat_init(void)
-- 
1.7.6


             reply	other threads:[~2011-07-27 18:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27 18:24 Daniel Drake [this message]
2011-08-10 20:46 Daniel Drake

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=20110727182426.9EE599D401D@zog.reactivated.net \
    --to=dsd@laptop.org \
    --cc=cbou@mail.ru \
    --cc=dilinger@queued.net \
    /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

all inboxes | Powered by JetHome®