thinkpad_acpi.c: Expose AC power on newer models

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

when running Win7 and the lenovo tools on a new T520, I noticed that Win7
had a display for the AC Power input when running with the AC Adapter
active.  Actually the "ac-power" is the dc-power at the yellow plug,
normally coming from a AC Adapter.

After installing Linux (Opensuse 12.1) and carefully looking at the
dump of the embedded controller memory, the value at offset 0xcc looked
suspicious like this "ac-power" in units of 100 mW. The value tracks well
the value measured with an AC power meter on the AC side, with some losses
for the AC adapter. Ac-power is measured as 0 with the AC-Adapter off.

Appended patch against recent
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
exposes this value like

# cat /proc/acpi/ibm/ac_power
ac_power:               14100

http://repo.or.cz/w/linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git seems hopeless
out of date, so I hope this is the right place to discuss. I tested the
patch on an old R50, where the ac-power is not yet measured. In that case,
the embedded memory reads 0, so I think this patch doesn't do any harm in
the case when the ac-power is not yet measured in the model. However I don't
see any chance to programmatically find out, if some thinkpad model has or
has not this ac-power measurement. The returned ac-power "0" in the case
with  no power measurement available for the given model is undistiguishable
from the case "ac-adapter off, running from battery".

Any comments welcome

--
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
>From 7486016e63c1f4a7c79205a0544d9bb6d7f41d96 Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 6 May 2012 14:43:39 +0200
Subject: Expose the AC power value from recent Thinkpads

Signed-off-by: Uwe Bonnes bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

---
 drivers/platform/x86/thinkpad_acpi.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 8b5610d..f032f42 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -1849,6 +1849,31 @@ static struct ibm_struct thinkpad_acpi_driver_data = {
 };
 
 /*************************************************************************
+ * thinkpad-acpi AC Power data readout
+ *
+ * 0xcc: High Byte
+ * 0xcd: Low Byte
+ *
+ * Unit seems to be 100 mW
+ */
+
+#define AC_POWER_OFFSET 0xCC
+static int thinkpad_acpi_ac_power_read(struct seq_file *m)
+{
+	u8 hi=0, lo=0;
+
+	acpi_ec_read(AC_POWER_OFFSET, &hi);
+	acpi_ec_read(AC_POWER_OFFSET+1, &lo);
+	seq_printf(m, "ac_power:\t\t%d\n",(lo + (hi<<8))*100);
+	return 0;
+}
+
+static struct ibm_struct thinkpad_acpi_ac_power_data = {
+	.name = "ac_power",
+	.read = thinkpad_acpi_ac_power_read,
+};
+
+/*************************************************************************
  * Hotkey subdriver
  */
 
@@ -8736,6 +8761,9 @@ static struct ibm_init_struct ibms_init[] __initdata = {
 		.data = &thinkpad_acpi_driver_data,
 	},
 	{
+		.data = &thinkpad_acpi_ac_power_data,
+	},
+	{
 		.init = hotkey_init,
 		.data = &hotkey_driver_data,
 	},
-- 
1.7.7
                                      

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


[Index of Archives]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Photo]     [Yosemite Photos]     [Yosemite Advice]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux