Add patches accepted for 2.6.29-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.29-rc2 / 0010-ACPI-thinkpad-acpi-handle-HKEY-thermal-and-battery.patch
blobbc5676ebe541ce91a9ad5c2e07a5ea387c1a0663
1 From 106b4e6657e10831f35c32afa26d9c11e6312783 Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sun, 11 Jan 2009 03:01:06 -0200
4 Subject: ACPI: thinkpad-acpi: handle HKEY thermal and battery alarms
6 Handle some HKEY events that are actually firmware alarms. For
7 now, we do the simple thing: log specific messages to the log and let
8 the thinkpad-specific event pass to userspace.
10 In the future, these events will be migrated to generic notifications
11 and subsystems.
13 These alarms are NOT available on all ThinkPads. E.g. the T43 only
14 issues 0x6011 and 0x6012.
16 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
17 Signed-off-by: Len Brown <len.brown@intel.com>
18 ---
19 drivers/platform/x86/thinkpad_acpi.c | 63 +++++++++++++++++++++++++++++++--
20 1 files changed, 59 insertions(+), 4 deletions(-)
22 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
23 index d833ee6..c4e4b64 100644
24 --- a/drivers/platform/x86/thinkpad_acpi.c
25 +++ b/drivers/platform/x86/thinkpad_acpi.c
26 @@ -174,10 +174,12 @@ enum {
28 /* Debugging */
29 #define TPACPI_LOG TPACPI_FILE ": "
30 -#define TPACPI_ERR KERN_ERR TPACPI_LOG
31 -#define TPACPI_NOTICE KERN_NOTICE TPACPI_LOG
32 -#define TPACPI_INFO KERN_INFO TPACPI_LOG
33 -#define TPACPI_DEBUG KERN_DEBUG TPACPI_LOG
34 +#define TPACPI_ALERT KERN_ALERT TPACPI_LOG
35 +#define TPACPI_CRIT KERN_CRIT TPACPI_LOG
36 +#define TPACPI_ERR KERN_ERR TPACPI_LOG
37 +#define TPACPI_NOTICE KERN_NOTICE TPACPI_LOG
38 +#define TPACPI_INFO KERN_INFO TPACPI_LOG
39 +#define TPACPI_DEBUG KERN_DEBUG TPACPI_LOG
41 #define TPACPI_DBG_ALL 0xffff
42 #define TPACPI_DBG_INIT 0x0001
43 @@ -2614,6 +2616,15 @@ static bool hotkey_notify_wakeup(const u32 hkey,
44 *ignore_acpi_ev = true;
45 break;
47 + case 0x2313: /* Battery on critical low level (S3) */
48 + case 0x2413: /* Battery on critical low level (S4) */
49 + printk(TPACPI_ALERT
50 + "EMERGENCY WAKEUP: battery almost empty\n");
51 + /* how to auto-heal: */
52 + /* 2313: woke up from S3, go to S4/S5 */
53 + /* 2413: woke up from S4, go to S5 */
54 + break;
56 default:
57 return false;
59 @@ -2659,6 +2670,45 @@ static bool hotkey_notify_usrevent(const u32 hkey,
63 +static bool hotkey_notify_thermal(const u32 hkey,
64 + bool *send_acpi_ev,
65 + bool *ignore_acpi_ev)
67 + /* 0x6000-0x6FFF: thermal alarms */
68 + *send_acpi_ev = true;
69 + *ignore_acpi_ev = false;
71 + switch (hkey) {
72 + case 0x6011:
73 + printk(TPACPI_CRIT
74 + "THERMAL ALARM: battery is too hot!\n");
75 + /* recommended action: warn user through gui */
76 + return true;
77 + case 0x6012:
78 + printk(TPACPI_ALERT
79 + "THERMAL EMERGENCY: battery is extremely hot!\n");
80 + /* recommended action: immediate sleep/hibernate */
81 + return true;
82 + case 0x6021:
83 + printk(TPACPI_CRIT
84 + "THERMAL ALARM: "
85 + "a sensor reports something is too hot!\n");
86 + /* recommended action: warn user through gui, that */
87 + /* some internal component is too hot */
88 + return true;
89 + case 0x6022:
90 + printk(TPACPI_ALERT
91 + "THERMAL EMERGENCY: "
92 + "a sensor reports something is extremely hot!\n");
93 + /* recommended action: immediate sleep/hibernate */
94 + return true;
95 + default:
96 + printk(TPACPI_ALERT
97 + "THERMAL ALERT: unknown thermal alarm received\n");
98 + return false;
99 + }
102 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
104 u32 hkey;
105 @@ -2731,6 +2781,11 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
106 known_ev = hotkey_notify_usrevent(hkey, &send_acpi_ev,
107 &ignore_acpi_ev);
108 break;
109 + case 6:
110 + /* 0x6000-0x6FFF: thermal alarms */
111 + known_ev = hotkey_notify_thermal(hkey, &send_acpi_ev,
112 + &ignore_acpi_ev);
113 + break;
114 case 7:
115 /* 0x7000-0x7FFF: misc */
116 if (tp_features.hotkey_wlsw && hkey == 0x7000) {
118 1.5.6.5