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 / 0005-ACPI-thinkpad-acpi-resume-with-radios-disabled.patch
blobcd0c9a3507901160aced7ee8ff9698f1a4902b7c
1 From 153f82207c51193e4d6a7e6f0e3f9442eabeba1c 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:01 -0200
4 Subject: ACPI: thinkpad-acpi: resume with radios disabled
6 Instruct the firmware to not enable the radios when resuming. This
7 is safer, and the rfkill core will take care to manually enable any
8 radios that need to be enabled.
10 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
11 Signed-off-by: Len Brown <len.brown@intel.com>
12 ---
13 drivers/platform/x86/thinkpad_acpi.c | 66 ++++++++++++++++++++++++++++-----
14 1 files changed, 56 insertions(+), 10 deletions(-)
16 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
17 index a086ce8..b2c5913 100644
18 --- a/drivers/platform/x86/thinkpad_acpi.c
19 +++ b/drivers/platform/x86/thinkpad_acpi.c
20 @@ -122,6 +122,27 @@ enum {
21 #define TPACPI_HKEY_INPUT_PRODUCT 0x5054 /* "TP" */
22 #define TPACPI_HKEY_INPUT_VERSION 0x4101
24 +/* ACPI \WGSV commands */
25 +enum {
26 + TP_ACPI_WGSV_GET_STATE = 0x01, /* Get state information */
27 + TP_ACPI_WGSV_PWR_ON_ON_RESUME = 0x02, /* Resume WWAN powered on */
28 + TP_ACPI_WGSV_PWR_OFF_ON_RESUME = 0x03, /* Resume WWAN powered off */
29 + TP_ACPI_WGSV_SAVE_STATE = 0x04, /* Save state for S4/S5 */
30 +};
32 +/* TP_ACPI_WGSV_GET_STATE bits */
33 +enum {
34 + TP_ACPI_WGSV_STATE_WWANEXIST = 0x0001, /* WWAN hw available */
35 + TP_ACPI_WGSV_STATE_WWANPWR = 0x0002, /* WWAN radio enabled */
36 + TP_ACPI_WGSV_STATE_WWANPWRRES = 0x0004, /* WWAN state at resume */
37 + TP_ACPI_WGSV_STATE_WWANBIOSOFF = 0x0008, /* WWAN disabled in BIOS */
38 + TP_ACPI_WGSV_STATE_BLTHEXIST = 0x0001, /* BLTH hw available */
39 + TP_ACPI_WGSV_STATE_BLTHPWR = 0x0002, /* BLTH radio enabled */
40 + TP_ACPI_WGSV_STATE_BLTHPWRRES = 0x0004, /* BLTH state at resume */
41 + TP_ACPI_WGSV_STATE_BLTHBIOSOFF = 0x0008, /* BLTH disabled in BIOS */
42 + TP_ACPI_WGSV_STATE_UWBEXIST = 0x0010, /* UWB hw available */
43 + TP_ACPI_WGSV_STATE_UWBPWR = 0x0020, /* UWB radio enabled */
44 +};
46 /****************************************************************************
47 * Main driver
48 @@ -2766,11 +2787,28 @@ enum {
49 /* ACPI GBDC/SBDC bits */
50 TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */
51 TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */
52 - TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */
53 + TP_ACPI_BLUETOOTH_RESUMECTRL = 0x04, /* Bluetooth state at resume:
54 + off / last state */
55 +};
57 +enum {
58 + /* ACPI \BLTH commands */
59 + TP_ACPI_BLTH_GET_ULTRAPORT_ID = 0x00, /* Get Ultraport BT ID */
60 + TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
61 + TP_ACPI_BLTH_PWR_ON_ON_RESUME = 0x02, /* Resume powered on */
62 + TP_ACPI_BLTH_PWR_OFF_ON_RESUME = 0x03, /* Resume powered off */
63 + TP_ACPI_BLTH_SAVE_STATE = 0x05, /* Save state for S4/S5 */
66 static struct rfkill *tpacpi_bluetooth_rfkill;
68 +static void bluetooth_suspend(pm_message_t state)
70 + /* Try to make sure radio will resume powered off */
71 + acpi_evalf(NULL, NULL, "\\BLTH", "vd",
72 + TP_ACPI_BLTH_PWR_OFF_ON_RESUME);
75 static int bluetooth_get_radiosw(void)
77 int status;
78 @@ -2830,12 +2868,11 @@ static int bluetooth_set_radiosw(int radio_on, int update_rfk)
80 #endif
82 - if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
83 - return -EIO;
84 + /* We make sure to keep TP_ACPI_BLUETOOTH_RESUMECTRL off */
85 if (radio_on)
86 - status |= TP_ACPI_BLUETOOTH_RADIOSSW;
87 + status = TP_ACPI_BLUETOOTH_RADIOSSW;
88 else
89 - status &= ~TP_ACPI_BLUETOOTH_RADIOSSW;
90 + status = 0;
91 if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
92 return -EIO;
94 @@ -3012,6 +3049,7 @@ static struct ibm_struct bluetooth_driver_data = {
95 .read = bluetooth_read,
96 .write = bluetooth_write,
97 .exit = bluetooth_exit,
98 + .suspend = bluetooth_suspend,
101 /*************************************************************************
102 @@ -3022,11 +3060,19 @@ enum {
103 /* ACPI GWAN/SWAN bits */
104 TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */
105 TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */
106 - TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */
107 + TP_ACPI_WANCARD_RESUMECTRL = 0x04, /* Wan state at resume:
108 + off / last state */
111 static struct rfkill *tpacpi_wan_rfkill;
113 +static void wan_suspend(pm_message_t state)
115 + /* Try to make sure radio will resume powered off */
116 + acpi_evalf(NULL, NULL, "\\WGSV", "qvd",
117 + TP_ACPI_WGSV_PWR_OFF_ON_RESUME);
120 static int wan_get_radiosw(void)
122 int status;
123 @@ -3086,12 +3132,11 @@ static int wan_set_radiosw(int radio_on, int update_rfk)
125 #endif
127 - if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
128 - return -EIO;
129 + /* We make sure to keep TP_ACPI_WANCARD_RESUMECTRL off */
130 if (radio_on)
131 - status |= TP_ACPI_WANCARD_RADIOSSW;
132 + status = TP_ACPI_WANCARD_RADIOSSW;
133 else
134 - status &= ~TP_ACPI_WANCARD_RADIOSSW;
135 + status = 0;
136 if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
137 return -EIO;
139 @@ -3266,6 +3311,7 @@ static struct ibm_struct wan_driver_data = {
140 .read = wan_read,
141 .write = wan_write,
142 .exit = wan_exit,
143 + .suspend = wan_suspend,
146 /*************************************************************************
148 1.5.6.5