From: tip-bot for Daniel Drake <dsd@laptop.org>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
dsd@laptop.org, dilinger@queued.net, tglx@linutronix.de,
hpa@linux.intel.com
Subject: [tip:x86/olpc] x86, olpc-xo1-sci: Propagate power supply/battery events
Date: Thu, 7 Jul 2011 00:50:42 GMT [thread overview]
Message-ID: <tip-e1040ac693bac19eaeafbd6c5fd24d9429b5eeb8@git.kernel.org> (raw)
In-Reply-To: <1309019658-1712-10-git-send-email-dsd@laptop.org>
Commit-ID: e1040ac693bac19eaeafbd6c5fd24d9429b5eeb8
Gitweb: http://git.kernel.org/tip/e1040ac693bac19eaeafbd6c5fd24d9429b5eeb8
Author: Daniel Drake <dsd@laptop.org>
AuthorDate: Sat, 25 Jun 2011 17:34:16 +0100
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Wed, 6 Jul 2011 14:44:40 -0700
x86, olpc-xo1-sci: Propagate power supply/battery events
EC events indicate change in AC power connectivity, battery state of
charge, battery error, battery presence, etc. Send notifications to
the power supply subsystem when changes are detected.
Signed-off-by: Daniel Drake <dsd@laptop.org>
Link: http://lkml.kernel.org/r/1309019658-1712-10-git-send-email-dsd@laptop.org
Acked-by: Andres Salomon <dilinger@queued.net>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/Kconfig | 4 ++-
arch/x86/platform/olpc/olpc-xo1-sci.c | 37 +++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 350ccbb..a6aefbb 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2082,7 +2082,7 @@ config OLPC_XO1_PM
config OLPC_XO1_SCI
bool "OLPC XO-1 SCI extras"
- depends on OLPC && OLPC_XO1_PM
+ depends on OLPC && OLPC_XO1_PM && POWER_SUPPLY
select GPIO_CS5535
select MFD_CORE
---help---
@@ -2091,6 +2091,8 @@ config OLPC_XO1_SCI
- Power button
- Ebook switch
- Lid switch
+ - AC adapter status updates
+ - Battery status updates
endif # X86_32
diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c
index ad0670b..1d4c783 100644
--- a/arch/x86/platform/olpc/olpc-xo1-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo1-sci.c
@@ -19,6 +19,7 @@
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/mfd/core.h>
+#include <linux/power_supply.h>
#include <linux/suspend.h>
#include <linux/workqueue.h>
@@ -52,6 +53,26 @@ static const char * const lid_wake_mode_names[] = {
[LID_WAKE_CLOSE] = "close",
};
+static void battery_status_changed(void)
+{
+ struct power_supply *psy = power_supply_get_by_name("olpc-battery");
+
+ if (psy) {
+ power_supply_changed(psy);
+ put_device(psy->dev);
+ }
+}
+
+static void ac_status_changed(void)
+{
+ struct power_supply *psy = power_supply_get_by_name("olpc-ac");
+
+ if (psy) {
+ power_supply_changed(psy);
+ put_device(psy->dev);
+ }
+}
+
/* Report current ebook switch state through input layer */
static void send_ebook_state(void)
{
@@ -151,6 +172,18 @@ static void process_sci_queue(bool propagate_events)
pr_debug(PFX "SCI 0x%x received\n", data);
+ switch (data) {
+ case EC_SCI_SRC_BATERR:
+ case EC_SCI_SRC_BATSOC:
+ case EC_SCI_SRC_BATTERY:
+ case EC_SCI_SRC_BATCRIT:
+ battery_status_changed();
+ break;
+ case EC_SCI_SRC_ACPWR:
+ ac_status_changed();
+ break;
+ }
+
if (data == EC_SCI_SRC_EBOOK && propagate_events)
send_ebook_state();
} while (data);
@@ -240,6 +273,10 @@ static int xo1_sci_resume(struct platform_device *pdev)
/* Enable all EC events */
olpc_ec_mask_write(EC_SCI_SRC_ALL);
+
+ /* Power/battery status might have changed too */
+ battery_status_changed();
+ ac_status_changed();
return 0;
}
next prev parent reply other threads:[~2011-07-07 0:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-25 16:34 [PATCH v3 00/11] OLPC Power Management Daniel Drake
2011-06-25 16:34 ` [PATCH v3 01/11] x86, olpc: add missing elements to device tree Daniel Drake
2011-07-07 0:46 ` [tip:x86/olpc] x86, olpc: Add " tip-bot for Daniel Drake
2011-06-25 16:34 ` [PATCH v3 02/11] x86, olpc: Move CS5536-related constants to cs5535.h Daniel Drake
2011-07-07 0:47 ` [tip:x86/olpc] " tip-bot for Daniel Drake
2011-06-25 16:34 ` [PATCH v3 03/11] x86, olpc: rename olpc-xo1 to olpc-xo1-pm Daniel Drake
2011-07-07 0:47 ` [tip:x86/olpc] x86, olpc: Rename " tip-bot for Daniel Drake
2011-06-25 16:34 ` [PATCH v3 04/11] x86, olpc: Add XO-1 suspend/resume support Daniel Drake
2011-07-07 0:48 ` [tip:x86/olpc] " tip-bot for Daniel Drake
2011-06-25 16:34 ` [PATCH v3 05/11] x86, olpc: Add XO-1 SCI driver and power button control Daniel Drake
2011-07-07 0:48 ` [tip:x86/olpc] " tip-bot for Daniel Drake
2011-06-25 16:34 ` [PATCH v3 06/11] x86, olpc: EC SCI wakeup mask functionality Daniel Drake
2011-07-07 0:49 ` [tip:x86/olpc] " tip-bot for Daniel Drake
2011-06-25 16:34 ` [PATCH v3 07/11] x86, olpc-xo1-sci: Add GPE handler and ebook switch functionality Daniel Drake
2011-07-07 0:49 ` [tip:x86/olpc] " tip-bot for Daniel Drake
2011-06-25 16:34 ` [PATCH v3 08/11] x86, olpc-xo1-sci: Add lid " Daniel Drake
2011-07-07 0:50 ` [tip:x86/olpc] " tip-bot for Daniel Drake
2011-06-25 16:34 ` [PATCH v3 09/11] x86, olpc-xo1-sci: Propagate power supply/battery events Daniel Drake
2011-07-07 0:50 ` tip-bot for Daniel Drake [this message]
2011-06-25 16:34 ` [PATCH v3 10/11] x86, olpc: Add XO-1 RTC driver Daniel Drake
2011-07-07 0:51 ` [tip:x86/olpc] " tip-bot for Daniel Drake
2011-06-25 16:34 ` [PATCH v3 11/11] x86, olpc: Add XO-1.5 SCI driver Daniel Drake
2011-07-07 0:51 ` [tip:x86/olpc] " tip-bot for 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=tip-e1040ac693bac19eaeafbd6c5fd24d9429b5eeb8@git.kernel.org \
--to=dsd@laptop.org \
--cc=dilinger@queued.net \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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).