aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/hardware
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/hardware
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/hardware')
-rw-r--r--drivers/acpi/hardware/hwacpi.c116
-rw-r--r--drivers/acpi/hardware/hwgpe.c197
-rw-r--r--drivers/acpi/hardware/hwregs.c600
-rw-r--r--drivers/acpi/hardware/hwsleep.c415
-rw-r--r--drivers/acpi/hardware/hwtimer.c77
5 files changed, 661 insertions, 744 deletions
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c
index b51001e74eea..1bb3463d7040 100644
--- a/drivers/acpi/hardware/hwacpi.c
+++ b/drivers/acpi/hardware/hwacpi.c
@@ -42,13 +42,10 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47 46
48
49#define _COMPONENT ACPI_HARDWARE 47#define _COMPONENT ACPI_HARDWARE
50 ACPI_MODULE_NAME ("hwacpi") 48ACPI_MODULE_NAME("hwacpi")
51
52 49
53/****************************************************************************** 50/******************************************************************************
54 * 51 *
@@ -62,36 +59,30 @@
62 * the FADT. 59 * the FADT.
63 * 60 *
64 ******************************************************************************/ 61 ******************************************************************************/
65 62acpi_status acpi_hw_initialize(void)
66acpi_status
67acpi_hw_initialize (
68 void)
69{ 63{
70 acpi_status status; 64 acpi_status status;
71
72
73 ACPI_FUNCTION_TRACE ("hw_initialize");
74 65
66 ACPI_FUNCTION_TRACE("hw_initialize");
75 67
76 /* We must have the ACPI tables by the time we get here */ 68 /* We must have the ACPI tables by the time we get here */
77 69
78 if (!acpi_gbl_FADT) { 70 if (!acpi_gbl_FADT) {
79 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT is present\n")); 71 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No FADT is present\n"));
80 72
81 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 73 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
82 } 74 }
83 75
84 /* Sanity check the FADT for valid values */ 76 /* Sanity check the FADT for valid values */
85 77
86 status = acpi_ut_validate_fadt (); 78 status = acpi_ut_validate_fadt();
87 if (ACPI_FAILURE (status)) { 79 if (ACPI_FAILURE(status)) {
88 return_ACPI_STATUS (status); 80 return_ACPI_STATUS(status);
89 } 81 }
90 82
91 return_ACPI_STATUS (AE_OK); 83 return_ACPI_STATUS(AE_OK);
92} 84}
93 85
94
95/****************************************************************************** 86/******************************************************************************
96 * 87 *
97 * FUNCTION: acpi_hw_set_mode 88 * FUNCTION: acpi_hw_set_mode
@@ -104,24 +95,21 @@ acpi_hw_initialize (
104 * 95 *
105 ******************************************************************************/ 96 ******************************************************************************/
106 97
107acpi_status 98acpi_status acpi_hw_set_mode(u32 mode)
108acpi_hw_set_mode (
109 u32 mode)
110{ 99{
111 100
112 acpi_status status; 101 acpi_status status;
113 u32 retry; 102 u32 retry;
114
115 103
116 ACPI_FUNCTION_TRACE ("hw_set_mode"); 104 ACPI_FUNCTION_TRACE("hw_set_mode");
117 105
118 /* 106 /*
119 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, 107 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
120 * system does not support mode transition. 108 * system does not support mode transition.
121 */ 109 */
122 if (!acpi_gbl_FADT->smi_cmd) { 110 if (!acpi_gbl_FADT->smi_cmd) {
123 ACPI_REPORT_ERROR (("No SMI_CMD in FADT, mode transition failed.\n")); 111 ACPI_REPORT_ERROR(("No SMI_CMD in FADT, mode transition failed.\n"));
124 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); 112 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
125 } 113 }
126 114
127 /* 115 /*
@@ -132,9 +120,8 @@ acpi_hw_set_mode (
132 * transitions are not supported. 120 * transitions are not supported.
133 */ 121 */
134 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) { 122 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) {
135 ACPI_REPORT_ERROR (( 123 ACPI_REPORT_ERROR(("No ACPI mode transition supported in this system (enable/disable both zero)\n"));
136 "No ACPI mode transition supported in this system (enable/disable both zero)\n")); 124 return_ACPI_STATUS(AE_OK);
137 return_ACPI_STATUS (AE_OK);
138 } 125 }
139 126
140 switch (mode) { 127 switch (mode) {
@@ -142,9 +129,11 @@ acpi_hw_set_mode (
142 129
143 /* BIOS should have disabled ALL fixed and GP events */ 130 /* BIOS should have disabled ALL fixed and GP events */
144 131
145 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, 132 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd,
146 (u32) acpi_gbl_FADT->acpi_enable, 8); 133 (u32) acpi_gbl_FADT->acpi_enable,
147 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); 134 8);
135 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
136 "Attempting to enable ACPI mode\n"));
148 break; 137 break;
149 138
150 case ACPI_SYS_MODE_LEGACY: 139 case ACPI_SYS_MODE_LEGACY:
@@ -153,20 +142,21 @@ acpi_hw_set_mode (
153 * BIOS should clear all fixed status bits and restore fixed event 142 * BIOS should clear all fixed status bits and restore fixed event
154 * enable bits to default 143 * enable bits to default
155 */ 144 */
156 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, 145 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd,
157 (u32) acpi_gbl_FADT->acpi_disable, 8); 146 (u32) acpi_gbl_FADT->acpi_disable,
158 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 147 8);
159 "Attempting to enable Legacy (non-ACPI) mode\n")); 148 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
149 "Attempting to enable Legacy (non-ACPI) mode\n"));
160 break; 150 break;
161 151
162 default: 152 default:
163 return_ACPI_STATUS (AE_BAD_PARAMETER); 153 return_ACPI_STATUS(AE_BAD_PARAMETER);
164 } 154 }
165 155
166 if (ACPI_FAILURE (status)) { 156 if (ACPI_FAILURE(status)) {
167 ACPI_REPORT_ERROR (("Could not write mode change, %s\n", 157 ACPI_REPORT_ERROR(("Could not write mode change, %s\n",
168 acpi_format_exception (status))); 158 acpi_format_exception(status)));
169 return_ACPI_STATUS (status); 159 return_ACPI_STATUS(status);
170 } 160 }
171 161
172 /* 162 /*
@@ -176,19 +166,19 @@ acpi_hw_set_mode (
176 retry = 3000; 166 retry = 3000;
177 while (retry) { 167 while (retry) {
178 if (acpi_hw_get_mode() == mode) { 168 if (acpi_hw_get_mode() == mode) {
179 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", 169 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
180 mode)); 170 "Mode %X successfully enabled\n",
181 return_ACPI_STATUS (AE_OK); 171 mode));
172 return_ACPI_STATUS(AE_OK);
182 } 173 }
183 acpi_os_stall(1000); 174 acpi_os_stall(1000);
184 retry--; 175 retry--;
185 } 176 }
186 177
187 ACPI_REPORT_ERROR (("Hardware never changed modes\n")); 178 ACPI_REPORT_ERROR(("Hardware never changed modes\n"));
188 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); 179 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
189} 180}
190 181
191
192/******************************************************************************* 182/*******************************************************************************
193 * 183 *
194 * FUNCTION: acpi_hw_get_mode 184 * FUNCTION: acpi_hw_get_mode
@@ -202,34 +192,30 @@ acpi_hw_set_mode (
202 * 192 *
203 ******************************************************************************/ 193 ******************************************************************************/
204 194
205u32 195u32 acpi_hw_get_mode(void)
206acpi_hw_get_mode (
207 void)
208{ 196{
209 acpi_status status; 197 acpi_status status;
210 u32 value; 198 u32 value;
211
212
213 ACPI_FUNCTION_TRACE ("hw_get_mode");
214 199
200 ACPI_FUNCTION_TRACE("hw_get_mode");
215 201
216 /* 202 /*
217 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, 203 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
218 * system does not support mode transition. 204 * system does not support mode transition.
219 */ 205 */
220 if (!acpi_gbl_FADT->smi_cmd) { 206 if (!acpi_gbl_FADT->smi_cmd) {
221 return_VALUE (ACPI_SYS_MODE_ACPI); 207 return_VALUE(ACPI_SYS_MODE_ACPI);
222 } 208 }
223 209
224 status = acpi_get_register (ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK); 210 status =
225 if (ACPI_FAILURE (status)) { 211 acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK);
226 return_VALUE (ACPI_SYS_MODE_LEGACY); 212 if (ACPI_FAILURE(status)) {
213 return_VALUE(ACPI_SYS_MODE_LEGACY);
227 } 214 }
228 215
229 if (value) { 216 if (value) {
230 return_VALUE (ACPI_SYS_MODE_ACPI); 217 return_VALUE(ACPI_SYS_MODE_ACPI);
231 } 218 } else {
232 else { 219 return_VALUE(ACPI_SYS_MODE_LEGACY);
233 return_VALUE (ACPI_SYS_MODE_LEGACY);
234 } 220 }
235} 221}
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c
index 3536bbb990c3..5c8e5dfd024e 100644
--- a/drivers/acpi/hardware/hwgpe.c
+++ b/drivers/acpi/hardware/hwgpe.c
@@ -46,15 +46,12 @@
46#include <acpi/acevents.h> 46#include <acpi/acevents.h>
47 47
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49 ACPI_MODULE_NAME ("hwgpe") 49ACPI_MODULE_NAME("hwgpe")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52
53static acpi_status 52static acpi_status
54acpi_hw_enable_wakeup_gpe_block ( 53acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
55 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 54 struct acpi_gpe_block_info *gpe_block);
56 struct acpi_gpe_block_info *gpe_block);
57
58 55
59/****************************************************************************** 56/******************************************************************************
60 * 57 *
@@ -71,15 +68,12 @@ acpi_hw_enable_wakeup_gpe_block (
71 ******************************************************************************/ 68 ******************************************************************************/
72 69
73acpi_status 70acpi_status
74acpi_hw_write_gpe_enable_reg ( 71acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info)
75 struct acpi_gpe_event_info *gpe_event_info)
76{ 72{
77 struct acpi_gpe_register_info *gpe_register_info; 73 struct acpi_gpe_register_info *gpe_register_info;
78 acpi_status status; 74 acpi_status status;
79
80
81 ACPI_FUNCTION_ENTRY ();
82 75
76 ACPI_FUNCTION_ENTRY();
83 77
84 /* Get the info block for the entire GPE register */ 78 /* Get the info block for the entire GPE register */
85 79
@@ -90,13 +84,12 @@ acpi_hw_write_gpe_enable_reg (
90 84
91 /* Write the entire GPE (runtime) enable register */ 85 /* Write the entire GPE (runtime) enable register */
92 86
93 status = acpi_hw_low_level_write (8, gpe_register_info->enable_for_run, 87 status = acpi_hw_low_level_write(8, gpe_register_info->enable_for_run,
94 &gpe_register_info->enable_address); 88 &gpe_register_info->enable_address);
95 89
96 return (status); 90 return (status);
97} 91}
98 92
99
100/****************************************************************************** 93/******************************************************************************
101 * 94 *
102 * FUNCTION: acpi_hw_clear_gpe 95 * FUNCTION: acpi_hw_clear_gpe
@@ -109,27 +102,23 @@ acpi_hw_write_gpe_enable_reg (
109 * 102 *
110 ******************************************************************************/ 103 ******************************************************************************/
111 104
112acpi_status 105acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
113acpi_hw_clear_gpe (
114 struct acpi_gpe_event_info *gpe_event_info)
115{ 106{
116 acpi_status status; 107 acpi_status status;
117
118
119 ACPI_FUNCTION_ENTRY ();
120 108
109 ACPI_FUNCTION_ENTRY();
121 110
122 /* 111 /*
123 * Write a one to the appropriate bit in the status register to 112 * Write a one to the appropriate bit in the status register to
124 * clear this GPE. 113 * clear this GPE.
125 */ 114 */
126 status = acpi_hw_low_level_write (8, gpe_event_info->register_bit, 115 status = acpi_hw_low_level_write(8, gpe_event_info->register_bit,
127 &gpe_event_info->register_info->status_address); 116 &gpe_event_info->register_info->
117 status_address);
128 118
129 return (status); 119 return (status);
130} 120}
131 121
132
133/****************************************************************************** 122/******************************************************************************
134 * 123 *
135 * FUNCTION: acpi_hw_get_gpe_status 124 * FUNCTION: acpi_hw_get_gpe_status
@@ -145,19 +134,16 @@ acpi_hw_clear_gpe (
145 134
146#ifdef ACPI_FUTURE_USAGE 135#ifdef ACPI_FUTURE_USAGE
147acpi_status 136acpi_status
148acpi_hw_get_gpe_status ( 137acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
149 struct acpi_gpe_event_info *gpe_event_info, 138 acpi_event_status * event_status)
150 acpi_event_status *event_status)
151{ 139{
152 u32 in_byte; 140 u32 in_byte;
153 u8 register_bit; 141 u8 register_bit;
154 struct acpi_gpe_register_info *gpe_register_info; 142 struct acpi_gpe_register_info *gpe_register_info;
155 acpi_status status; 143 acpi_status status;
156 acpi_event_status local_event_status = 0; 144 acpi_event_status local_event_status = 0;
157
158
159 ACPI_FUNCTION_ENTRY ();
160 145
146 ACPI_FUNCTION_ENTRY();
161 147
162 if (!event_status) { 148 if (!event_status) {
163 return (AE_BAD_PARAMETER); 149 return (AE_BAD_PARAMETER);
@@ -185,8 +171,10 @@ acpi_hw_get_gpe_status (
185 171
186 /* GPE currently active (status bit == 1)? */ 172 /* GPE currently active (status bit == 1)? */
187 173
188 status = acpi_hw_low_level_read (8, &in_byte, &gpe_register_info->status_address); 174 status =
189 if (ACPI_FAILURE (status)) { 175 acpi_hw_low_level_read(8, &in_byte,
176 &gpe_register_info->status_address);
177 if (ACPI_FAILURE(status)) {
190 goto unlock_and_exit; 178 goto unlock_and_exit;
191 } 179 }
192 180
@@ -198,12 +186,10 @@ acpi_hw_get_gpe_status (
198 186
199 (*event_status) = local_event_status; 187 (*event_status) = local_event_status;
200 188
201 189 unlock_and_exit:
202unlock_and_exit:
203 return (status); 190 return (status);
204} 191}
205#endif /* ACPI_FUTURE_USAGE */ 192#endif /* ACPI_FUTURE_USAGE */
206
207 193
208/****************************************************************************** 194/******************************************************************************
209 * 195 *
@@ -219,22 +205,21 @@ unlock_and_exit:
219 ******************************************************************************/ 205 ******************************************************************************/
220 206
221acpi_status 207acpi_status
222acpi_hw_disable_gpe_block ( 208acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
223 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 209 struct acpi_gpe_block_info * gpe_block)
224 struct acpi_gpe_block_info *gpe_block)
225{ 210{
226 u32 i; 211 u32 i;
227 acpi_status status; 212 acpi_status status;
228
229 213
230 /* Examine each GPE Register within the block */ 214 /* Examine each GPE Register within the block */
231 215
232 for (i = 0; i < gpe_block->register_count; i++) { 216 for (i = 0; i < gpe_block->register_count; i++) {
233 /* Disable all GPEs in this register */ 217 /* Disable all GPEs in this register */
234 218
235 status = acpi_hw_low_level_write (8, 0x00, 219 status = acpi_hw_low_level_write(8, 0x00,
236 &gpe_block->register_info[i].enable_address); 220 &gpe_block->register_info[i].
237 if (ACPI_FAILURE (status)) { 221 enable_address);
222 if (ACPI_FAILURE(status)) {
238 return (status); 223 return (status);
239 } 224 }
240 } 225 }
@@ -242,7 +227,6 @@ acpi_hw_disable_gpe_block (
242 return (AE_OK); 227 return (AE_OK);
243} 228}
244 229
245
246/****************************************************************************** 230/******************************************************************************
247 * 231 *
248 * FUNCTION: acpi_hw_clear_gpe_block 232 * FUNCTION: acpi_hw_clear_gpe_block
@@ -257,22 +241,21 @@ acpi_hw_disable_gpe_block (
257 ******************************************************************************/ 241 ******************************************************************************/
258 242
259acpi_status 243acpi_status
260acpi_hw_clear_gpe_block ( 244acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
261 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 245 struct acpi_gpe_block_info * gpe_block)
262 struct acpi_gpe_block_info *gpe_block)
263{ 246{
264 u32 i; 247 u32 i;
265 acpi_status status; 248 acpi_status status;
266
267 249
268 /* Examine each GPE Register within the block */ 250 /* Examine each GPE Register within the block */
269 251
270 for (i = 0; i < gpe_block->register_count; i++) { 252 for (i = 0; i < gpe_block->register_count; i++) {
271 /* Clear status on all GPEs in this register */ 253 /* Clear status on all GPEs in this register */
272 254
273 status = acpi_hw_low_level_write (8, 0xFF, 255 status = acpi_hw_low_level_write(8, 0xFF,
274 &gpe_block->register_info[i].status_address); 256 &gpe_block->register_info[i].
275 if (ACPI_FAILURE (status)) { 257 status_address);
258 if (ACPI_FAILURE(status)) {
276 return (status); 259 return (status);
277 } 260 }
278 } 261 }
@@ -280,7 +263,6 @@ acpi_hw_clear_gpe_block (
280 return (AE_OK); 263 return (AE_OK);
281} 264}
282 265
283
284/****************************************************************************** 266/******************************************************************************
285 * 267 *
286 * FUNCTION: acpi_hw_enable_runtime_gpe_block 268 * FUNCTION: acpi_hw_enable_runtime_gpe_block
@@ -296,13 +278,11 @@ acpi_hw_clear_gpe_block (
296 ******************************************************************************/ 278 ******************************************************************************/
297 279
298acpi_status 280acpi_status
299acpi_hw_enable_runtime_gpe_block ( 281acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
300 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 282 struct acpi_gpe_block_info * gpe_block)
301 struct acpi_gpe_block_info *gpe_block)
302{ 283{
303 u32 i; 284 u32 i;
304 acpi_status status; 285 acpi_status status;
305
306 286
307 /* NOTE: assumes that all GPEs are currently disabled */ 287 /* NOTE: assumes that all GPEs are currently disabled */
308 288
@@ -315,9 +295,13 @@ acpi_hw_enable_runtime_gpe_block (
315 295
316 /* Enable all "runtime" GPEs in this register */ 296 /* Enable all "runtime" GPEs in this register */
317 297
318 status = acpi_hw_low_level_write (8, gpe_block->register_info[i].enable_for_run, 298 status =
319 &gpe_block->register_info[i].enable_address); 299 acpi_hw_low_level_write(8,
320 if (ACPI_FAILURE (status)) { 300 gpe_block->register_info[i].
301 enable_for_run,
302 &gpe_block->register_info[i].
303 enable_address);
304 if (ACPI_FAILURE(status)) {
321 return (status); 305 return (status);
322 } 306 }
323 } 307 }
@@ -325,7 +309,6 @@ acpi_hw_enable_runtime_gpe_block (
325 return (AE_OK); 309 return (AE_OK);
326} 310}
327 311
328
329/****************************************************************************** 312/******************************************************************************
330 * 313 *
331 * FUNCTION: acpi_hw_enable_wakeup_gpe_block 314 * FUNCTION: acpi_hw_enable_wakeup_gpe_block
@@ -341,13 +324,11 @@ acpi_hw_enable_runtime_gpe_block (
341 ******************************************************************************/ 324 ******************************************************************************/
342 325
343static acpi_status 326static acpi_status
344acpi_hw_enable_wakeup_gpe_block ( 327acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
345 struct acpi_gpe_xrupt_info *gpe_xrupt_info, 328 struct acpi_gpe_block_info *gpe_block)
346 struct acpi_gpe_block_info *gpe_block)
347{ 329{
348 u32 i; 330 u32 i;
349 acpi_status status; 331 acpi_status status;
350
351 332
352 /* Examine each GPE Register within the block */ 333 /* Examine each GPE Register within the block */
353 334
@@ -358,10 +339,12 @@ acpi_hw_enable_wakeup_gpe_block (
358 339
359 /* Enable all "wake" GPEs in this register */ 340 /* Enable all "wake" GPEs in this register */
360 341
361 status = acpi_hw_low_level_write (8, 342 status = acpi_hw_low_level_write(8,
362 gpe_block->register_info[i].enable_for_wake, 343 gpe_block->register_info[i].
363 &gpe_block->register_info[i].enable_address); 344 enable_for_wake,
364 if (ACPI_FAILURE (status)) { 345 &gpe_block->register_info[i].
346 enable_address);
347 if (ACPI_FAILURE(status)) {
365 return (status); 348 return (status);
366 } 349 }
367 } 350 }
@@ -369,7 +352,6 @@ acpi_hw_enable_wakeup_gpe_block (
369 return (AE_OK); 352 return (AE_OK);
370} 353}
371 354
372
373/****************************************************************************** 355/******************************************************************************
374 * 356 *
375 * FUNCTION: acpi_hw_disable_all_gpes 357 * FUNCTION: acpi_hw_disable_all_gpes
@@ -382,22 +364,17 @@ acpi_hw_enable_wakeup_gpe_block (
382 * 364 *
383 ******************************************************************************/ 365 ******************************************************************************/
384 366
385acpi_status 367acpi_status acpi_hw_disable_all_gpes(void)
386acpi_hw_disable_all_gpes (
387 void)
388{ 368{
389 acpi_status status; 369 acpi_status status;
390
391 370
392 ACPI_FUNCTION_TRACE ("hw_disable_all_gpes"); 371 ACPI_FUNCTION_TRACE("hw_disable_all_gpes");
393 372
394 373 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block);
395 status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block); 374 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block);
396 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block); 375 return_ACPI_STATUS(status);
397 return_ACPI_STATUS (status);
398} 376}
399 377
400
401/****************************************************************************** 378/******************************************************************************
402 * 379 *
403 * FUNCTION: acpi_hw_enable_all_runtime_gpes 380 * FUNCTION: acpi_hw_enable_all_runtime_gpes
@@ -410,21 +387,16 @@ acpi_hw_disable_all_gpes (
410 * 387 *
411 ******************************************************************************/ 388 ******************************************************************************/
412 389
413acpi_status 390acpi_status acpi_hw_enable_all_runtime_gpes(void)
414acpi_hw_enable_all_runtime_gpes (
415 void)
416{ 391{
417 acpi_status status; 392 acpi_status status;
418
419 393
420 ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes"); 394 ACPI_FUNCTION_TRACE("hw_enable_all_runtime_gpes");
421 395
422 396 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block);
423 status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block); 397 return_ACPI_STATUS(status);
424 return_ACPI_STATUS (status);
425} 398}
426 399
427
428/****************************************************************************** 400/******************************************************************************
429 * 401 *
430 * FUNCTION: acpi_hw_enable_all_wakeup_gpes 402 * FUNCTION: acpi_hw_enable_all_wakeup_gpes
@@ -437,17 +409,12 @@ acpi_hw_enable_all_runtime_gpes (
437 * 409 *
438 ******************************************************************************/ 410 ******************************************************************************/
439 411
440acpi_status 412acpi_status acpi_hw_enable_all_wakeup_gpes(void)
441acpi_hw_enable_all_wakeup_gpes (
442 void)
443{ 413{
444 acpi_status status; 414 acpi_status status;
445
446 415
447 ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes"); 416 ACPI_FUNCTION_TRACE("hw_enable_all_wakeup_gpes");
448 417
449 418 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block);
450 status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block); 419 return_ACPI_STATUS(status);
451 return_ACPI_STATUS (status);
452} 420}
453
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index 04a058565d8d..536a7aea80c9 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -50,8 +50,7 @@
50#include <acpi/acevents.h> 50#include <acpi/acevents.h>
51 51
52#define _COMPONENT ACPI_HARDWARE 52#define _COMPONENT ACPI_HARDWARE
53 ACPI_MODULE_NAME ("hwregs") 53ACPI_MODULE_NAME("hwregs")
54
55 54
56/******************************************************************************* 55/*******************************************************************************
57 * 56 *
@@ -65,57 +64,52 @@
65 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 64 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
66 * 65 *
67 ******************************************************************************/ 66 ******************************************************************************/
68 67acpi_status acpi_hw_clear_acpi_status(u32 flags)
69acpi_status
70acpi_hw_clear_acpi_status (
71 u32 flags)
72{ 68{
73 acpi_status status; 69 acpi_status status;
74
75 70
76 ACPI_FUNCTION_TRACE ("hw_clear_acpi_status"); 71 ACPI_FUNCTION_TRACE("hw_clear_acpi_status");
77 72
78 73 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n",
79 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n", 74 ACPI_BITMASK_ALL_FIXED_STATUS,
80 ACPI_BITMASK_ALL_FIXED_STATUS, 75 (u16) acpi_gbl_FADT->xpm1a_evt_blk.address));
81 (u16) acpi_gbl_FADT->xpm1a_evt_blk.address));
82 76
83 if (flags & ACPI_MTX_LOCK) { 77 if (flags & ACPI_MTX_LOCK) {
84 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 78 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
85 if (ACPI_FAILURE (status)) { 79 if (ACPI_FAILURE(status)) {
86 return_ACPI_STATUS (status); 80 return_ACPI_STATUS(status);
87 } 81 }
88 } 82 }
89 83
90 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 84 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
91 ACPI_REGISTER_PM1_STATUS, 85 ACPI_REGISTER_PM1_STATUS,
92 ACPI_BITMASK_ALL_FIXED_STATUS); 86 ACPI_BITMASK_ALL_FIXED_STATUS);
93 if (ACPI_FAILURE (status)) { 87 if (ACPI_FAILURE(status)) {
94 goto unlock_and_exit; 88 goto unlock_and_exit;
95 } 89 }
96 90
97 /* Clear the fixed events */ 91 /* Clear the fixed events */
98 92
99 if (acpi_gbl_FADT->xpm1b_evt_blk.address) { 93 if (acpi_gbl_FADT->xpm1b_evt_blk.address) {
100 status = acpi_hw_low_level_write (16, ACPI_BITMASK_ALL_FIXED_STATUS, 94 status =
101 &acpi_gbl_FADT->xpm1b_evt_blk); 95 acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS,
102 if (ACPI_FAILURE (status)) { 96 &acpi_gbl_FADT->xpm1b_evt_blk);
97 if (ACPI_FAILURE(status)) {
103 goto unlock_and_exit; 98 goto unlock_and_exit;
104 } 99 }
105 } 100 }
106 101
107 /* Clear the GPE Bits in all GPE registers in all GPE blocks */ 102 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
108 103
109 status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block); 104 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block);
110 105
111unlock_and_exit: 106 unlock_and_exit:
112 if (flags & ACPI_MTX_LOCK) { 107 if (flags & ACPI_MTX_LOCK) {
113 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 108 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
114 } 109 }
115 return_ACPI_STATUS (status); 110 return_ACPI_STATUS(status);
116} 111}
117 112
118
119/******************************************************************************* 113/*******************************************************************************
120 * 114 *
121 * FUNCTION: acpi_get_sleep_type_data 115 * FUNCTION: acpi_get_sleep_type_data
@@ -132,53 +126,48 @@ unlock_and_exit:
132 ******************************************************************************/ 126 ******************************************************************************/
133 127
134acpi_status 128acpi_status
135acpi_get_sleep_type_data ( 129acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
136 u8 sleep_state,
137 u8 *sleep_type_a,
138 u8 *sleep_type_b)
139{ 130{
140 acpi_status status = AE_OK; 131 acpi_status status = AE_OK;
141 struct acpi_parameter_info info; 132 struct acpi_parameter_info info;
142 char *sleep_state_name; 133 char *sleep_state_name;
143
144
145 ACPI_FUNCTION_TRACE ("acpi_get_sleep_type_data");
146 134
135 ACPI_FUNCTION_TRACE("acpi_get_sleep_type_data");
147 136
148 /* Validate parameters */ 137 /* Validate parameters */
149 138
150 if ((sleep_state > ACPI_S_STATES_MAX) || 139 if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) {
151 !sleep_type_a || !sleep_type_b) { 140 return_ACPI_STATUS(AE_BAD_PARAMETER);
152 return_ACPI_STATUS (AE_BAD_PARAMETER);
153 } 141 }
154 142
155 /* Evaluate the namespace object containing the values for this state */ 143 /* Evaluate the namespace object containing the values for this state */
156 144
157 info.parameters = NULL; 145 info.parameters = NULL;
158 info.return_object = NULL; 146 info.return_object = NULL;
159 sleep_state_name = (char *) acpi_gbl_sleep_state_names[sleep_state]; 147 sleep_state_name = (char *)acpi_gbl_sleep_state_names[sleep_state];
160 148
161 status = acpi_ns_evaluate_by_name (sleep_state_name, &info); 149 status = acpi_ns_evaluate_by_name(sleep_state_name, &info);
162 if (ACPI_FAILURE (status)) { 150 if (ACPI_FAILURE(status)) {
163 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 151 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
164 "%s while evaluating sleep_state [%s]\n", 152 "%s while evaluating sleep_state [%s]\n",
165 acpi_format_exception (status), sleep_state_name)); 153 acpi_format_exception(status),
154 sleep_state_name));
166 155
167 return_ACPI_STATUS (status); 156 return_ACPI_STATUS(status);
168 } 157 }
169 158
170 /* Must have a return object */ 159 /* Must have a return object */
171 160
172 if (!info.return_object) { 161 if (!info.return_object) {
173 ACPI_REPORT_ERROR (("No Sleep State object returned from [%s]\n", 162 ACPI_REPORT_ERROR(("No Sleep State object returned from [%s]\n",
174 sleep_state_name)); 163 sleep_state_name));
175 status = AE_NOT_EXIST; 164 status = AE_NOT_EXIST;
176 } 165 }
177 166
178 /* It must be of type Package */ 167 /* It must be of type Package */
179 168
180 else if (ACPI_GET_OBJECT_TYPE (info.return_object) != ACPI_TYPE_PACKAGE) { 169 else if (ACPI_GET_OBJECT_TYPE(info.return_object) != ACPI_TYPE_PACKAGE) {
181 ACPI_REPORT_ERROR (("Sleep State return object is not a Package\n")); 170 ACPI_REPORT_ERROR(("Sleep State return object is not a Package\n"));
182 status = AE_AML_OPERAND_TYPE; 171 status = AE_AML_OPERAND_TYPE;
183 } 172 }
184 173
@@ -190,45 +179,41 @@ acpi_get_sleep_type_data (
190 * one per sleep type (A/B). 179 * one per sleep type (A/B).
191 */ 180 */
192 else if (info.return_object->package.count < 2) { 181 else if (info.return_object->package.count < 2) {
193 ACPI_REPORT_ERROR (( 182 ACPI_REPORT_ERROR(("Sleep State return package does not have at least two elements\n"));
194 "Sleep State return package does not have at least two elements\n"));
195 status = AE_AML_NO_OPERAND; 183 status = AE_AML_NO_OPERAND;
196 } 184 }
197 185
198 /* The first two elements must both be of type Integer */ 186 /* The first two elements must both be of type Integer */
199 187
200 else if ((ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[0]) 188 else if ((ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[0])
201 != ACPI_TYPE_INTEGER) || 189 != ACPI_TYPE_INTEGER) ||
202 (ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[1]) 190 (ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[1])
203 != ACPI_TYPE_INTEGER)) { 191 != ACPI_TYPE_INTEGER)) {
204 ACPI_REPORT_ERROR (( 192 ACPI_REPORT_ERROR(("Sleep State return package elements are not both Integers (%s, %s)\n", acpi_ut_get_object_type_name(info.return_object->package.elements[0]), acpi_ut_get_object_type_name(info.return_object->package.elements[1])));
205 "Sleep State return package elements are not both Integers (%s, %s)\n",
206 acpi_ut_get_object_type_name (info.return_object->package.elements[0]),
207 acpi_ut_get_object_type_name (info.return_object->package.elements[1])));
208 status = AE_AML_OPERAND_TYPE; 193 status = AE_AML_OPERAND_TYPE;
209 } 194 } else {
210 else {
211 /* Valid _Sx_ package size, type, and value */ 195 /* Valid _Sx_ package size, type, and value */
212 196
213 *sleep_type_a = (u8) 197 *sleep_type_a = (u8)
214 (info.return_object->package.elements[0])->integer.value; 198 (info.return_object->package.elements[0])->integer.value;
215 *sleep_type_b = (u8) 199 *sleep_type_b = (u8)
216 (info.return_object->package.elements[1])->integer.value; 200 (info.return_object->package.elements[1])->integer.value;
217 } 201 }
218 202
219 if (ACPI_FAILURE (status)) { 203 if (ACPI_FAILURE(status)) {
220 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 204 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
221 "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n", 205 "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n",
222 acpi_format_exception (status), 206 acpi_format_exception(status),
223 sleep_state_name, info.return_object, 207 sleep_state_name, info.return_object,
224 acpi_ut_get_object_type_name (info.return_object))); 208 acpi_ut_get_object_type_name(info.
209 return_object)));
225 } 210 }
226 211
227 acpi_ut_remove_reference (info.return_object); 212 acpi_ut_remove_reference(info.return_object);
228 return_ACPI_STATUS (status); 213 return_ACPI_STATUS(status);
229} 214}
230EXPORT_SYMBOL(acpi_get_sleep_type_data);
231 215
216EXPORT_SYMBOL(acpi_get_sleep_type_data);
232 217
233/******************************************************************************* 218/*******************************************************************************
234 * 219 *
@@ -242,22 +227,20 @@ EXPORT_SYMBOL(acpi_get_sleep_type_data);
242 * 227 *
243 ******************************************************************************/ 228 ******************************************************************************/
244 229
245struct acpi_bit_register_info * 230struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
246acpi_hw_get_bit_register_info (
247 u32 register_id)
248{ 231{
249 ACPI_FUNCTION_NAME ("hw_get_bit_register_info"); 232 ACPI_FUNCTION_NAME("hw_get_bit_register_info");
250
251 233
252 if (register_id > ACPI_BITREG_MAX) { 234 if (register_id > ACPI_BITREG_MAX) {
253 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid bit_register ID: %X\n", register_id)); 235 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
236 "Invalid bit_register ID: %X\n",
237 register_id));
254 return (NULL); 238 return (NULL);
255 } 239 }
256 240
257 return (&acpi_gbl_bit_register_info[register_id]); 241 return (&acpi_gbl_bit_register_info[register_id]);
258} 242}
259 243
260
261/******************************************************************************* 244/*******************************************************************************
262 * 245 *
263 * FUNCTION: acpi_get_register 246 * FUNCTION: acpi_get_register
@@ -273,59 +256,56 @@ acpi_hw_get_bit_register_info (
273 * 256 *
274 ******************************************************************************/ 257 ******************************************************************************/
275 258
276acpi_status 259acpi_status acpi_get_register(u32 register_id, u32 * return_value, u32 flags)
277acpi_get_register (
278 u32 register_id,
279 u32 *return_value,
280 u32 flags)
281{ 260{
282 u32 register_value = 0; 261 u32 register_value = 0;
283 struct acpi_bit_register_info *bit_reg_info; 262 struct acpi_bit_register_info *bit_reg_info;
284 acpi_status status; 263 acpi_status status;
285
286
287 ACPI_FUNCTION_TRACE ("acpi_get_register");
288 264
265 ACPI_FUNCTION_TRACE("acpi_get_register");
289 266
290 /* Get the info structure corresponding to the requested ACPI Register */ 267 /* Get the info structure corresponding to the requested ACPI Register */
291 268
292 bit_reg_info = acpi_hw_get_bit_register_info (register_id); 269 bit_reg_info = acpi_hw_get_bit_register_info(register_id);
293 if (!bit_reg_info) { 270 if (!bit_reg_info) {
294 return_ACPI_STATUS (AE_BAD_PARAMETER); 271 return_ACPI_STATUS(AE_BAD_PARAMETER);
295 } 272 }
296 273
297 if (flags & ACPI_MTX_LOCK) { 274 if (flags & ACPI_MTX_LOCK) {
298 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 275 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
299 if (ACPI_FAILURE (status)) { 276 if (ACPI_FAILURE(status)) {
300 return_ACPI_STATUS (status); 277 return_ACPI_STATUS(status);
301 } 278 }
302 } 279 }
303 280
304 /* Read from the register */ 281 /* Read from the register */
305 282
306 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 283 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
307 bit_reg_info->parent_register, &register_value); 284 bit_reg_info->parent_register,
285 &register_value);
308 286
309 if (flags & ACPI_MTX_LOCK) { 287 if (flags & ACPI_MTX_LOCK) {
310 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 288 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
311 } 289 }
312 290
313 if (ACPI_SUCCESS (status)) { 291 if (ACPI_SUCCESS(status)) {
314 /* Normalize the value that was read */ 292 /* Normalize the value that was read */
315 293
316 register_value = ((register_value & bit_reg_info->access_bit_mask) 294 register_value =
317 >> bit_reg_info->bit_position); 295 ((register_value & bit_reg_info->access_bit_mask)
296 >> bit_reg_info->bit_position);
318 297
319 *return_value = register_value; 298 *return_value = register_value;
320 299
321 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %8.8X register %X\n", 300 ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read value %8.8X register %X\n",
322 register_value, bit_reg_info->parent_register)); 301 register_value,
302 bit_reg_info->parent_register));
323 } 303 }
324 304
325 return_ACPI_STATUS (status); 305 return_ACPI_STATUS(status);
326} 306}
327EXPORT_SYMBOL(acpi_get_register);
328 307
308EXPORT_SYMBOL(acpi_get_register);
329 309
330/******************************************************************************* 310/*******************************************************************************
331 * 311 *
@@ -342,40 +322,36 @@ EXPORT_SYMBOL(acpi_get_register);
342 * 322 *
343 ******************************************************************************/ 323 ******************************************************************************/
344 324
345acpi_status 325acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags)
346acpi_set_register (
347 u32 register_id,
348 u32 value,
349 u32 flags)
350{ 326{
351 u32 register_value = 0; 327 u32 register_value = 0;
352 struct acpi_bit_register_info *bit_reg_info; 328 struct acpi_bit_register_info *bit_reg_info;
353 acpi_status status; 329 acpi_status status;
354
355
356 ACPI_FUNCTION_TRACE_U32 ("acpi_set_register", register_id);
357 330
331 ACPI_FUNCTION_TRACE_U32("acpi_set_register", register_id);
358 332
359 /* Get the info structure corresponding to the requested ACPI Register */ 333 /* Get the info structure corresponding to the requested ACPI Register */
360 334
361 bit_reg_info = acpi_hw_get_bit_register_info (register_id); 335 bit_reg_info = acpi_hw_get_bit_register_info(register_id);
362 if (!bit_reg_info) { 336 if (!bit_reg_info) {
363 ACPI_REPORT_ERROR (("Bad ACPI HW register_id: %X\n", register_id)); 337 ACPI_REPORT_ERROR(("Bad ACPI HW register_id: %X\n",
364 return_ACPI_STATUS (AE_BAD_PARAMETER); 338 register_id));
339 return_ACPI_STATUS(AE_BAD_PARAMETER);
365 } 340 }
366 341
367 if (flags & ACPI_MTX_LOCK) { 342 if (flags & ACPI_MTX_LOCK) {
368 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 343 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
369 if (ACPI_FAILURE (status)) { 344 if (ACPI_FAILURE(status)) {
370 return_ACPI_STATUS (status); 345 return_ACPI_STATUS(status);
371 } 346 }
372 } 347 }
373 348
374 /* Always do a register read first so we can insert the new bits */ 349 /* Always do a register read first so we can insert the new bits */
375 350
376 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 351 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
377 bit_reg_info->parent_register, &register_value); 352 bit_reg_info->parent_register,
378 if (ACPI_FAILURE (status)) { 353 &register_value);
354 if (ACPI_FAILURE(status)) {
379 goto unlock_and_exit; 355 goto unlock_and_exit;
380 } 356 }
381 357
@@ -395,26 +371,30 @@ acpi_set_register (
395 * information is the single bit we're interested in, all others should 371 * information is the single bit we're interested in, all others should
396 * be written as 0 so they will be left unchanged. 372 * be written as 0 so they will be left unchanged.
397 */ 373 */
398 value = ACPI_REGISTER_PREPARE_BITS (value, 374 value = ACPI_REGISTER_PREPARE_BITS(value,
399 bit_reg_info->bit_position, bit_reg_info->access_bit_mask); 375 bit_reg_info->bit_position,
376 bit_reg_info->
377 access_bit_mask);
400 if (value) { 378 if (value) {
401 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 379 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
402 ACPI_REGISTER_PM1_STATUS, (u16) value); 380 ACPI_REGISTER_PM1_STATUS,
381 (u16) value);
403 register_value = 0; 382 register_value = 0;
404 } 383 }
405 break; 384 break;
406 385
407
408 case ACPI_REGISTER_PM1_ENABLE: 386 case ACPI_REGISTER_PM1_ENABLE:
409 387
410 ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, 388 ACPI_REGISTER_INSERT_VALUE(register_value,
411 bit_reg_info->access_bit_mask, value); 389 bit_reg_info->bit_position,
390 bit_reg_info->access_bit_mask,
391 value);
412 392
413 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 393 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
414 ACPI_REGISTER_PM1_ENABLE, (u16) register_value); 394 ACPI_REGISTER_PM1_ENABLE,
395 (u16) register_value);
415 break; 396 break;
416 397
417
418 case ACPI_REGISTER_PM1_CONTROL: 398 case ACPI_REGISTER_PM1_CONTROL:
419 399
420 /* 400 /*
@@ -422,65 +402,73 @@ acpi_set_register (
422 * Note that at this level, the fact that there are actually TWO 402 * Note that at this level, the fact that there are actually TWO
423 * registers (A and B - and B may not exist) is abstracted. 403 * registers (A and B - and B may not exist) is abstracted.
424 */ 404 */
425 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", register_value)); 405 ACPI_DEBUG_PRINT((ACPI_DB_IO, "PM1 control: Read %X\n",
406 register_value));
426 407
427 ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, 408 ACPI_REGISTER_INSERT_VALUE(register_value,
428 bit_reg_info->access_bit_mask, value); 409 bit_reg_info->bit_position,
410 bit_reg_info->access_bit_mask,
411 value);
429 412
430 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 413 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
431 ACPI_REGISTER_PM1_CONTROL, (u16) register_value); 414 ACPI_REGISTER_PM1_CONTROL,
415 (u16) register_value);
432 break; 416 break;
433 417
434
435 case ACPI_REGISTER_PM2_CONTROL: 418 case ACPI_REGISTER_PM2_CONTROL:
436 419
437 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 420 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
438 ACPI_REGISTER_PM2_CONTROL, &register_value); 421 ACPI_REGISTER_PM2_CONTROL,
439 if (ACPI_FAILURE (status)) { 422 &register_value);
423 if (ACPI_FAILURE(status)) {
440 goto unlock_and_exit; 424 goto unlock_and_exit;
441 } 425 }
442 426
443 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n", 427 ACPI_DEBUG_PRINT((ACPI_DB_IO,
444 register_value, 428 "PM2 control: Read %X from %8.8X%8.8X\n",
445 ACPI_FORMAT_UINT64 ( 429 register_value,
446 acpi_gbl_FADT->xpm2_cnt_blk.address))); 430 ACPI_FORMAT_UINT64(acpi_gbl_FADT->
447 431 xpm2_cnt_blk.address)));
448 ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position, 432
449 bit_reg_info->access_bit_mask, value); 433 ACPI_REGISTER_INSERT_VALUE(register_value,
450 434 bit_reg_info->bit_position,
451 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", 435 bit_reg_info->access_bit_mask,
452 register_value, 436 value);
453 ACPI_FORMAT_UINT64 ( 437
454 acpi_gbl_FADT->xpm2_cnt_blk.address))); 438 ACPI_DEBUG_PRINT((ACPI_DB_IO,
455 439 "About to write %4.4X to %8.8X%8.8X\n",
456 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 440 register_value,
457 ACPI_REGISTER_PM2_CONTROL, (u8) (register_value)); 441 ACPI_FORMAT_UINT64(acpi_gbl_FADT->
442 xpm2_cnt_blk.address)));
443
444 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
445 ACPI_REGISTER_PM2_CONTROL,
446 (u8) (register_value));
458 break; 447 break;
459 448
460
461 default: 449 default:
462 break; 450 break;
463 } 451 }
464 452
465 453 unlock_and_exit:
466unlock_and_exit:
467 454
468 if (flags & ACPI_MTX_LOCK) { 455 if (flags & ACPI_MTX_LOCK) {
469 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 456 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
470 } 457 }
471 458
472 /* Normalize the value that was read */ 459 /* Normalize the value that was read */
473 460
474 ACPI_DEBUG_EXEC (register_value = 461 ACPI_DEBUG_EXEC(register_value =
475 ((register_value & bit_reg_info->access_bit_mask) >> 462 ((register_value & bit_reg_info->access_bit_mask) >>
476 bit_reg_info->bit_position)); 463 bit_reg_info->bit_position));
477 464
478 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", 465 ACPI_DEBUG_PRINT((ACPI_DB_IO,
479 value, register_value, bit_reg_info->parent_register)); 466 "Set bits: %8.8X actual %8.8X register %X\n", value,
480 return_ACPI_STATUS (status); 467 register_value, bit_reg_info->parent_register));
468 return_ACPI_STATUS(status);
481} 469}
482EXPORT_SYMBOL(acpi_set_register);
483 470
471EXPORT_SYMBOL(acpi_set_register);
484 472
485/****************************************************************************** 473/******************************************************************************
486 * 474 *
@@ -498,103 +486,107 @@ EXPORT_SYMBOL(acpi_set_register);
498 ******************************************************************************/ 486 ******************************************************************************/
499 487
500acpi_status 488acpi_status
501acpi_hw_register_read ( 489acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
502 u8 use_lock,
503 u32 register_id,
504 u32 *return_value)
505{ 490{
506 u32 value1 = 0; 491 u32 value1 = 0;
507 u32 value2 = 0; 492 u32 value2 = 0;
508 acpi_status status; 493 acpi_status status;
509
510
511 ACPI_FUNCTION_TRACE ("hw_register_read");
512 494
495 ACPI_FUNCTION_TRACE("hw_register_read");
513 496
514 if (ACPI_MTX_LOCK == use_lock) { 497 if (ACPI_MTX_LOCK == use_lock) {
515 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 498 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
516 if (ACPI_FAILURE (status)) { 499 if (ACPI_FAILURE(status)) {
517 return_ACPI_STATUS (status); 500 return_ACPI_STATUS(status);
518 } 501 }
519 } 502 }
520 503
521 switch (register_id) { 504 switch (register_id) {
522 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 505 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
523 506
524 status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_FADT->xpm1a_evt_blk); 507 status =
525 if (ACPI_FAILURE (status)) { 508 acpi_hw_low_level_read(16, &value1,
509 &acpi_gbl_FADT->xpm1a_evt_blk);
510 if (ACPI_FAILURE(status)) {
526 goto unlock_and_exit; 511 goto unlock_and_exit;
527 } 512 }
528 513
529 /* PM1B is optional */ 514 /* PM1B is optional */
530 515
531 status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_FADT->xpm1b_evt_blk); 516 status =
517 acpi_hw_low_level_read(16, &value2,
518 &acpi_gbl_FADT->xpm1b_evt_blk);
532 value1 |= value2; 519 value1 |= value2;
533 break; 520 break;
534 521
522 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
535 523
536 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ 524 status =
537 525 acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable);
538 status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_xpm1a_enable); 526 if (ACPI_FAILURE(status)) {
539 if (ACPI_FAILURE (status)) {
540 goto unlock_and_exit; 527 goto unlock_and_exit;
541 } 528 }
542 529
543 /* PM1B is optional */ 530 /* PM1B is optional */
544 531
545 status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_xpm1b_enable); 532 status =
533 acpi_hw_low_level_read(16, &value2, &acpi_gbl_xpm1b_enable);
546 value1 |= value2; 534 value1 |= value2;
547 break; 535 break;
548 536
537 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
549 538
550 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 539 status =
551 540 acpi_hw_low_level_read(16, &value1,
552 status = acpi_hw_low_level_read (16, &value1, &acpi_gbl_FADT->xpm1a_cnt_blk); 541 &acpi_gbl_FADT->xpm1a_cnt_blk);
553 if (ACPI_FAILURE (status)) { 542 if (ACPI_FAILURE(status)) {
554 goto unlock_and_exit; 543 goto unlock_and_exit;
555 } 544 }
556 545
557 status = acpi_hw_low_level_read (16, &value2, &acpi_gbl_FADT->xpm1b_cnt_blk); 546 status =
547 acpi_hw_low_level_read(16, &value2,
548 &acpi_gbl_FADT->xpm1b_cnt_blk);
558 value1 |= value2; 549 value1 |= value2;
559 break; 550 break;
560 551
552 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
561 553
562 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 554 status =
563 555 acpi_hw_low_level_read(8, &value1,
564 status = acpi_hw_low_level_read (8, &value1, &acpi_gbl_FADT->xpm2_cnt_blk); 556 &acpi_gbl_FADT->xpm2_cnt_blk);
565 break; 557 break;
566 558
559 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
567 560
568 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 561 status =
569 562 acpi_hw_low_level_read(32, &value1,
570 status = acpi_hw_low_level_read (32, &value1, &acpi_gbl_FADT->xpm_tmr_blk); 563 &acpi_gbl_FADT->xpm_tmr_blk);
571 break; 564 break;
572 565
573 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 566 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
574 567
575 status = acpi_os_read_port (acpi_gbl_FADT->smi_cmd, &value1, 8); 568 status = acpi_os_read_port(acpi_gbl_FADT->smi_cmd, &value1, 8);
576 break; 569 break;
577 570
578 default: 571 default:
579 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", 572 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown Register ID: %X\n",
580 register_id)); 573 register_id));
581 status = AE_BAD_PARAMETER; 574 status = AE_BAD_PARAMETER;
582 break; 575 break;
583 } 576 }
584 577
585unlock_and_exit: 578 unlock_and_exit:
586 if (ACPI_MTX_LOCK == use_lock) { 579 if (ACPI_MTX_LOCK == use_lock) {
587 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 580 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
588 } 581 }
589 582
590 if (ACPI_SUCCESS (status)) { 583 if (ACPI_SUCCESS(status)) {
591 *return_value = value1; 584 *return_value = value1;
592 } 585 }
593 586
594 return_ACPI_STATUS (status); 587 return_ACPI_STATUS(status);
595} 588}
596 589
597
598/****************************************************************************** 590/******************************************************************************
599 * 591 *
600 * FUNCTION: acpi_hw_register_write 592 * FUNCTION: acpi_hw_register_write
@@ -610,109 +602,112 @@ unlock_and_exit:
610 * 602 *
611 ******************************************************************************/ 603 ******************************************************************************/
612 604
613acpi_status 605acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
614acpi_hw_register_write (
615 u8 use_lock,
616 u32 register_id,
617 u32 value)
618{ 606{
619 acpi_status status; 607 acpi_status status;
620
621
622 ACPI_FUNCTION_TRACE ("hw_register_write");
623 608
609 ACPI_FUNCTION_TRACE("hw_register_write");
624 610
625 if (ACPI_MTX_LOCK == use_lock) { 611 if (ACPI_MTX_LOCK == use_lock) {
626 status = acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE); 612 status = acpi_ut_acquire_mutex(ACPI_MTX_HARDWARE);
627 if (ACPI_FAILURE (status)) { 613 if (ACPI_FAILURE(status)) {
628 return_ACPI_STATUS (status); 614 return_ACPI_STATUS(status);
629 } 615 }
630 } 616 }
631 617
632 switch (register_id) { 618 switch (register_id) {
633 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 619 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
634 620
635 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_evt_blk); 621 status =
636 if (ACPI_FAILURE (status)) { 622 acpi_hw_low_level_write(16, value,
623 &acpi_gbl_FADT->xpm1a_evt_blk);
624 if (ACPI_FAILURE(status)) {
637 goto unlock_and_exit; 625 goto unlock_and_exit;
638 } 626 }
639 627
640 /* PM1B is optional */ 628 /* PM1B is optional */
641 629
642 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_evt_blk); 630 status =
631 acpi_hw_low_level_write(16, value,
632 &acpi_gbl_FADT->xpm1b_evt_blk);
643 break; 633 break;
644 634
635 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
645 636
646 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/ 637 status =
647 638 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable);
648 status = acpi_hw_low_level_write (16, value, &acpi_gbl_xpm1a_enable); 639 if (ACPI_FAILURE(status)) {
649 if (ACPI_FAILURE (status)) {
650 goto unlock_and_exit; 640 goto unlock_and_exit;
651 } 641 }
652 642
653 /* PM1B is optional */ 643 /* PM1B is optional */
654 644
655 status = acpi_hw_low_level_write (16, value, &acpi_gbl_xpm1b_enable); 645 status =
646 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1b_enable);
656 break; 647 break;
657 648
649 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
658 650
659 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 651 status =
660 652 acpi_hw_low_level_write(16, value,
661 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_cnt_blk); 653 &acpi_gbl_FADT->xpm1a_cnt_blk);
662 if (ACPI_FAILURE (status)) { 654 if (ACPI_FAILURE(status)) {
663 goto unlock_and_exit; 655 goto unlock_and_exit;
664 } 656 }
665 657
666 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_cnt_blk); 658 status =
659 acpi_hw_low_level_write(16, value,
660 &acpi_gbl_FADT->xpm1b_cnt_blk);
667 break; 661 break;
668 662
663 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
669 664
670 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ 665 status =
671 666 acpi_hw_low_level_write(16, value,
672 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1a_cnt_blk); 667 &acpi_gbl_FADT->xpm1a_cnt_blk);
673 break; 668 break;
674 669
670 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
675 671
676 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ 672 status =
677 673 acpi_hw_low_level_write(16, value,
678 status = acpi_hw_low_level_write (16, value, &acpi_gbl_FADT->xpm1b_cnt_blk); 674 &acpi_gbl_FADT->xpm1b_cnt_blk);
679 break; 675 break;
680 676
677 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
681 678
682 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 679 status =
683 680 acpi_hw_low_level_write(8, value,
684 status = acpi_hw_low_level_write (8, value, &acpi_gbl_FADT->xpm2_cnt_blk); 681 &acpi_gbl_FADT->xpm2_cnt_blk);
685 break; 682 break;
686 683
684 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
687 685
688 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 686 status =
689 687 acpi_hw_low_level_write(32, value,
690 status = acpi_hw_low_level_write (32, value, &acpi_gbl_FADT->xpm_tmr_blk); 688 &acpi_gbl_FADT->xpm_tmr_blk);
691 break; 689 break;
692 690
693 691 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
694 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
695 692
696 /* SMI_CMD is currently always in IO space */ 693 /* SMI_CMD is currently always in IO space */
697 694
698 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, value, 8); 695 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd, value, 8);
699 break; 696 break;
700 697
701
702 default: 698 default:
703 status = AE_BAD_PARAMETER; 699 status = AE_BAD_PARAMETER;
704 break; 700 break;
705 } 701 }
706 702
707unlock_and_exit: 703 unlock_and_exit:
708 if (ACPI_MTX_LOCK == use_lock) { 704 if (ACPI_MTX_LOCK == use_lock) {
709 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE); 705 (void)acpi_ut_release_mutex(ACPI_MTX_HARDWARE);
710 } 706 }
711 707
712 return_ACPI_STATUS (status); 708 return_ACPI_STATUS(status);
713} 709}
714 710
715
716/****************************************************************************** 711/******************************************************************************
717 * 712 *
718 * FUNCTION: acpi_hw_low_level_read 713 * FUNCTION: acpi_hw_low_level_read
@@ -728,17 +723,12 @@ unlock_and_exit:
728 ******************************************************************************/ 723 ******************************************************************************/
729 724
730acpi_status 725acpi_status
731acpi_hw_low_level_read ( 726acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
732 u32 width,
733 u32 *value,
734 struct acpi_generic_address *reg)
735{ 727{
736 u64 address; 728 u64 address;
737 acpi_status status; 729 acpi_status status;
738
739
740 ACPI_FUNCTION_NAME ("hw_low_level_read");
741 730
731 ACPI_FUNCTION_NAME("hw_low_level_read");
742 732
743 /* 733 /*
744 * Must have a valid pointer to a GAS structure, and 734 * Must have a valid pointer to a GAS structure, and
@@ -751,7 +741,7 @@ acpi_hw_low_level_read (
751 741
752 /* Get a local copy of the address. Handles possible alignment issues */ 742 /* Get a local copy of the address. Handles possible alignment issues */
753 743
754 ACPI_MOVE_64_TO_64 (&address, &reg->address); 744 ACPI_MOVE_64_TO_64(&address, &reg->address);
755 if (!address) { 745 if (!address) {
756 return (AE_OK); 746 return (AE_OK);
757 } 747 }
@@ -764,35 +754,32 @@ acpi_hw_low_level_read (
764 switch (reg->address_space_id) { 754 switch (reg->address_space_id) {
765 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 755 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
766 756
767 status = acpi_os_read_memory ( 757 status = acpi_os_read_memory((acpi_physical_address) address,
768 (acpi_physical_address) address, 758 value, width);
769 value, width);
770 break; 759 break;
771 760
772
773 case ACPI_ADR_SPACE_SYSTEM_IO: 761 case ACPI_ADR_SPACE_SYSTEM_IO:
774 762
775 status = acpi_os_read_port ((acpi_io_address) address, 763 status = acpi_os_read_port((acpi_io_address) address,
776 value, width); 764 value, width);
777 break; 765 break;
778 766
779
780 default: 767 default:
781 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 768 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
782 "Unsupported address space: %X\n", reg->address_space_id)); 769 "Unsupported address space: %X\n",
770 reg->address_space_id));
783 return (AE_BAD_PARAMETER); 771 return (AE_BAD_PARAMETER);
784 } 772 }
785 773
786 ACPI_DEBUG_PRINT ((ACPI_DB_IO, 774 ACPI_DEBUG_PRINT((ACPI_DB_IO,
787 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", 775 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
788 *value, width, 776 *value, width,
789 ACPI_FORMAT_UINT64 (address), 777 ACPI_FORMAT_UINT64(address),
790 acpi_ut_get_region_name (reg->address_space_id))); 778 acpi_ut_get_region_name(reg->address_space_id)));
791 779
792 return (status); 780 return (status);
793} 781}
794 782
795
796/****************************************************************************** 783/******************************************************************************
797 * 784 *
798 * FUNCTION: acpi_hw_low_level_write 785 * FUNCTION: acpi_hw_low_level_write
@@ -808,17 +795,12 @@ acpi_hw_low_level_read (
808 ******************************************************************************/ 795 ******************************************************************************/
809 796
810acpi_status 797acpi_status
811acpi_hw_low_level_write ( 798acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
812 u32 width,
813 u32 value,
814 struct acpi_generic_address *reg)
815{ 799{
816 u64 address; 800 u64 address;
817 acpi_status status; 801 acpi_status status;
818
819
820 ACPI_FUNCTION_NAME ("hw_low_level_write");
821 802
803 ACPI_FUNCTION_NAME("hw_low_level_write");
822 804
823 /* 805 /*
824 * Must have a valid pointer to a GAS structure, and 806 * Must have a valid pointer to a GAS structure, and
@@ -831,7 +813,7 @@ acpi_hw_low_level_write (
831 813
832 /* Get a local copy of the address. Handles possible alignment issues */ 814 /* Get a local copy of the address. Handles possible alignment issues */
833 815
834 ACPI_MOVE_64_TO_64 (&address, &reg->address); 816 ACPI_MOVE_64_TO_64(&address, &reg->address);
835 if (!address) { 817 if (!address) {
836 return (AE_OK); 818 return (AE_OK);
837 } 819 }
@@ -843,30 +825,28 @@ acpi_hw_low_level_write (
843 switch (reg->address_space_id) { 825 switch (reg->address_space_id) {
844 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 826 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
845 827
846 status = acpi_os_write_memory ( 828 status = acpi_os_write_memory((acpi_physical_address) address,
847 (acpi_physical_address) address, 829 value, width);
848 value, width);
849 break; 830 break;
850 831
851
852 case ACPI_ADR_SPACE_SYSTEM_IO: 832 case ACPI_ADR_SPACE_SYSTEM_IO:
853 833
854 status = acpi_os_write_port ((acpi_io_address) address, 834 status = acpi_os_write_port((acpi_io_address) address,
855 value, width); 835 value, width);
856 break; 836 break;
857 837
858
859 default: 838 default:
860 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 839 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
861 "Unsupported address space: %X\n", reg->address_space_id)); 840 "Unsupported address space: %X\n",
841 reg->address_space_id));
862 return (AE_BAD_PARAMETER); 842 return (AE_BAD_PARAMETER);
863 } 843 }
864 844
865 ACPI_DEBUG_PRINT ((ACPI_DB_IO, 845 ACPI_DEBUG_PRINT((ACPI_DB_IO,
866 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", 846 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
867 value, width, 847 value, width,
868 ACPI_FORMAT_UINT64 (address), 848 ACPI_FORMAT_UINT64(address),
869 acpi_ut_get_region_name (reg->address_space_id))); 849 acpi_ut_get_region_name(reg->address_space_id)));
870 850
871 return (status); 851 return (status);
872} 852}
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index cedee0c43b5f..34519069050c 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -46,8 +46,7 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47 47
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49 ACPI_MODULE_NAME ("hwsleep") 49ACPI_MODULE_NAME("hwsleep")
50
51 50
52/******************************************************************************* 51/*******************************************************************************
53 * 52 *
@@ -61,30 +60,25 @@
61 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS 60 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
62 * 61 *
63 ******************************************************************************/ 62 ******************************************************************************/
64
65acpi_status 63acpi_status
66acpi_set_firmware_waking_vector ( 64acpi_set_firmware_waking_vector(acpi_physical_address physical_address)
67 acpi_physical_address physical_address)
68{ 65{
69 66
70 ACPI_FUNCTION_TRACE ("acpi_set_firmware_waking_vector"); 67 ACPI_FUNCTION_TRACE("acpi_set_firmware_waking_vector");
71
72 68
73 /* Set the vector */ 69 /* Set the vector */
74 70
75 if (acpi_gbl_common_fACS.vector_width == 32) { 71 if (acpi_gbl_common_fACS.vector_width == 32) {
76 *(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector)) 72 *(ACPI_CAST_PTR
77 = (u32) physical_address; 73 (u32, acpi_gbl_common_fACS.firmware_waking_vector))
78 } 74 = (u32) physical_address;
79 else { 75 } else {
80 *acpi_gbl_common_fACS.firmware_waking_vector 76 *acpi_gbl_common_fACS.firmware_waking_vector = physical_address;
81 = physical_address;
82 } 77 }
83 78
84 return_ACPI_STATUS (AE_OK); 79 return_ACPI_STATUS(AE_OK);
85} 80}
86 81
87
88/******************************************************************************* 82/*******************************************************************************
89 * 83 *
90 * FUNCTION: acpi_get_firmware_waking_vector 84 * FUNCTION: acpi_get_firmware_waking_vector
@@ -101,33 +95,31 @@ acpi_set_firmware_waking_vector (
101 95
102#ifdef ACPI_FUTURE_USAGE 96#ifdef ACPI_FUTURE_USAGE
103acpi_status 97acpi_status
104acpi_get_firmware_waking_vector ( 98acpi_get_firmware_waking_vector(acpi_physical_address * physical_address)
105 acpi_physical_address *physical_address)
106{ 99{
107 100
108 ACPI_FUNCTION_TRACE ("acpi_get_firmware_waking_vector"); 101 ACPI_FUNCTION_TRACE("acpi_get_firmware_waking_vector");
109
110 102
111 if (!physical_address) { 103 if (!physical_address) {
112 return_ACPI_STATUS (AE_BAD_PARAMETER); 104 return_ACPI_STATUS(AE_BAD_PARAMETER);
113 } 105 }
114 106
115 /* Get the vector */ 107 /* Get the vector */
116 108
117 if (acpi_gbl_common_fACS.vector_width == 32) { 109 if (acpi_gbl_common_fACS.vector_width == 32) {
118 *physical_address = (acpi_physical_address) 110 *physical_address = (acpi_physical_address)
119 *(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector)); 111 *
120 } 112 (ACPI_CAST_PTR
121 else { 113 (u32, acpi_gbl_common_fACS.firmware_waking_vector));
114 } else {
122 *physical_address = 115 *physical_address =
123 *acpi_gbl_common_fACS.firmware_waking_vector; 116 *acpi_gbl_common_fACS.firmware_waking_vector;
124 } 117 }
125 118
126 return_ACPI_STATUS (AE_OK); 119 return_ACPI_STATUS(AE_OK);
127} 120}
128#endif 121#endif
129 122
130
131/******************************************************************************* 123/*******************************************************************************
132 * 124 *
133 * FUNCTION: acpi_enter_sleep_state_prep 125 * FUNCTION: acpi_enter_sleep_state_prep
@@ -143,25 +135,22 @@ acpi_get_firmware_waking_vector (
143 * 135 *
144 ******************************************************************************/ 136 ******************************************************************************/
145 137
146acpi_status 138acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
147acpi_enter_sleep_state_prep (
148 u8 sleep_state)
149{ 139{
150 acpi_status status; 140 acpi_status status;
151 struct acpi_object_list arg_list; 141 struct acpi_object_list arg_list;
152 union acpi_object arg; 142 union acpi_object arg;
153
154
155 ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_prep");
156 143
144 ACPI_FUNCTION_TRACE("acpi_enter_sleep_state_prep");
157 145
158 /* 146 /*
159 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. 147 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
160 */ 148 */
161 status = acpi_get_sleep_type_data (sleep_state, 149 status = acpi_get_sleep_type_data(sleep_state,
162 &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); 150 &acpi_gbl_sleep_type_a,
163 if (ACPI_FAILURE (status)) { 151 &acpi_gbl_sleep_type_b);
164 return_ACPI_STATUS (status); 152 if (ACPI_FAILURE(status)) {
153 return_ACPI_STATUS(status);
165 } 154 }
166 155
167 /* Setup parameter object */ 156 /* Setup parameter object */
@@ -174,14 +163,14 @@ acpi_enter_sleep_state_prep (
174 163
175 /* Run the _PTS and _GTS methods */ 164 /* Run the _PTS and _GTS methods */
176 165
177 status = acpi_evaluate_object (NULL, METHOD_NAME__PTS, &arg_list, NULL); 166 status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL);
178 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 167 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
179 return_ACPI_STATUS (status); 168 return_ACPI_STATUS(status);
180 } 169 }
181 170
182 status = acpi_evaluate_object (NULL, METHOD_NAME__GTS, &arg_list, NULL); 171 status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
183 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 172 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
184 return_ACPI_STATUS (status); 173 return_ACPI_STATUS(status);
185 } 174 }
186 175
187 /* Setup the argument to _SST */ 176 /* Setup the argument to _SST */
@@ -202,22 +191,21 @@ acpi_enter_sleep_state_prep (
202 break; 191 break;
203 192
204 default: 193 default:
205 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */ 194 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */
206 break; 195 break;
207 } 196 }
208 197
209 /* Set the system indicators to show the desired sleep state. */ 198 /* Set the system indicators to show the desired sleep state. */
210 199
211 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 200 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
212 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 201 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
213 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", 202 ACPI_REPORT_ERROR(("Method _SST failed, %s\n",
214 acpi_format_exception (status))); 203 acpi_format_exception(status)));
215 } 204 }
216 205
217 return_ACPI_STATUS (AE_OK); 206 return_ACPI_STATUS(AE_OK);
218} 207}
219 208
220
221/******************************************************************************* 209/*******************************************************************************
222 * 210 *
223 * FUNCTION: acpi_enter_sleep_state 211 * FUNCTION: acpi_enter_sleep_state
@@ -231,80 +219,82 @@ acpi_enter_sleep_state_prep (
231 * 219 *
232 ******************************************************************************/ 220 ******************************************************************************/
233 221
234acpi_status asmlinkage 222acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
235acpi_enter_sleep_state (
236 u8 sleep_state)
237{ 223{
238 u32 PM1Acontrol; 224 u32 PM1Acontrol;
239 u32 PM1Bcontrol; 225 u32 PM1Bcontrol;
240 struct acpi_bit_register_info *sleep_type_reg_info; 226 struct acpi_bit_register_info *sleep_type_reg_info;
241 struct acpi_bit_register_info *sleep_enable_reg_info; 227 struct acpi_bit_register_info *sleep_enable_reg_info;
242 u32 in_value; 228 u32 in_value;
243 acpi_status status; 229 acpi_status status;
244
245
246 ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state");
247 230
231 ACPI_FUNCTION_TRACE("acpi_enter_sleep_state");
248 232
249 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || 233 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
250 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { 234 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
251 ACPI_REPORT_ERROR (("Sleep values out of range: A=%X B=%X\n", 235 ACPI_REPORT_ERROR(("Sleep values out of range: A=%X B=%X\n",
252 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); 236 acpi_gbl_sleep_type_a,
253 return_ACPI_STATUS (AE_AML_OPERAND_VALUE); 237 acpi_gbl_sleep_type_b));
238 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
254 } 239 }
255 240
256 sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A); 241 sleep_type_reg_info =
257 sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE); 242 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A);
243 sleep_enable_reg_info =
244 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
258 245
259 /* Clear wake status */ 246 /* Clear wake status */
260 247
261 status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); 248 status =
262 if (ACPI_FAILURE (status)) { 249 acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
263 return_ACPI_STATUS (status); 250 if (ACPI_FAILURE(status)) {
251 return_ACPI_STATUS(status);
264 } 252 }
265 253
266 /* Clear all fixed and general purpose status bits */ 254 /* Clear all fixed and general purpose status bits */
267 255
268 status = acpi_hw_clear_acpi_status (ACPI_MTX_DO_NOT_LOCK); 256 status = acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK);
269 if (ACPI_FAILURE (status)) { 257 if (ACPI_FAILURE(status)) {
270 return_ACPI_STATUS (status); 258 return_ACPI_STATUS(status);
271 } 259 }
272 260
273 /* 261 /*
274 * 1) Disable/Clear all GPEs 262 * 1) Disable/Clear all GPEs
275 * 2) Enable all wakeup GPEs 263 * 2) Enable all wakeup GPEs
276 */ 264 */
277 status = acpi_hw_disable_all_gpes (); 265 status = acpi_hw_disable_all_gpes();
278 if (ACPI_FAILURE (status)) { 266 if (ACPI_FAILURE(status)) {
279 return_ACPI_STATUS (status); 267 return_ACPI_STATUS(status);
280 } 268 }
281 acpi_gbl_system_awake_and_running = FALSE; 269 acpi_gbl_system_awake_and_running = FALSE;
282 270
283 status = acpi_hw_enable_all_wakeup_gpes (); 271 status = acpi_hw_enable_all_wakeup_gpes();
284 if (ACPI_FAILURE (status)) { 272 if (ACPI_FAILURE(status)) {
285 return_ACPI_STATUS (status); 273 return_ACPI_STATUS(status);
286 } 274 }
287 275
288 /* Get current value of PM1A control */ 276 /* Get current value of PM1A control */
289 277
290 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 278 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
291 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); 279 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
292 if (ACPI_FAILURE (status)) { 280 if (ACPI_FAILURE(status)) {
293 return_ACPI_STATUS (status); 281 return_ACPI_STATUS(status);
294 } 282 }
295 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 283 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
296 "Entering sleep state [S%d]\n", sleep_state)); 284 "Entering sleep state [S%d]\n", sleep_state));
297 285
298 /* Clear SLP_EN and SLP_TYP fields */ 286 /* Clear SLP_EN and SLP_TYP fields */
299 287
300 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | 288 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
301 sleep_enable_reg_info->access_bit_mask); 289 sleep_enable_reg_info->access_bit_mask);
302 PM1Bcontrol = PM1Acontrol; 290 PM1Bcontrol = PM1Acontrol;
303 291
304 /* Insert SLP_TYP bits */ 292 /* Insert SLP_TYP bits */
305 293
306 PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); 294 PM1Acontrol |=
307 PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); 295 (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
296 PM1Bcontrol |=
297 (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
308 298
309 /* 299 /*
310 * We split the writes of SLP_TYP and SLP_EN to workaround 300 * We split the writes of SLP_TYP and SLP_EN to workaround
@@ -313,16 +303,18 @@ acpi_enter_sleep_state (
313 303
314 /* Write #1: fill in SLP_TYP data */ 304 /* Write #1: fill in SLP_TYP data */
315 305
316 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 306 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
317 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 307 ACPI_REGISTER_PM1A_CONTROL,
318 if (ACPI_FAILURE (status)) { 308 PM1Acontrol);
319 return_ACPI_STATUS (status); 309 if (ACPI_FAILURE(status)) {
310 return_ACPI_STATUS(status);
320 } 311 }
321 312
322 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 313 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
323 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 314 ACPI_REGISTER_PM1B_CONTROL,
324 if (ACPI_FAILURE (status)) { 315 PM1Bcontrol);
325 return_ACPI_STATUS (status); 316 if (ACPI_FAILURE(status)) {
317 return_ACPI_STATUS(status);
326 } 318 }
327 319
328 /* Insert SLP_ENABLE bit */ 320 /* Insert SLP_ENABLE bit */
@@ -332,18 +324,20 @@ acpi_enter_sleep_state (
332 324
333 /* Write #2: SLP_TYP + SLP_EN */ 325 /* Write #2: SLP_TYP + SLP_EN */
334 326
335 ACPI_FLUSH_CPU_CACHE (); 327 ACPI_FLUSH_CPU_CACHE();
336 328
337 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 329 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
338 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 330 ACPI_REGISTER_PM1A_CONTROL,
339 if (ACPI_FAILURE (status)) { 331 PM1Acontrol);
340 return_ACPI_STATUS (status); 332 if (ACPI_FAILURE(status)) {
333 return_ACPI_STATUS(status);
341 } 334 }
342 335
343 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 336 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
344 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 337 ACPI_REGISTER_PM1B_CONTROL,
345 if (ACPI_FAILURE (status)) { 338 PM1Bcontrol);
346 return_ACPI_STATUS (status); 339 if (ACPI_FAILURE(status)) {
340 return_ACPI_STATUS(status);
347 } 341 }
348 342
349 if (sleep_state > ACPI_STATE_S3) { 343 if (sleep_state > ACPI_STATE_S3) {
@@ -358,33 +352,34 @@ acpi_enter_sleep_state (
358 * still read the right value. Ideally, this block would go 352 * still read the right value. Ideally, this block would go
359 * away entirely. 353 * away entirely.
360 */ 354 */
361 acpi_os_stall (10000000); 355 acpi_os_stall(10000000);
362 356
363 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 357 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
364 ACPI_REGISTER_PM1_CONTROL, 358 ACPI_REGISTER_PM1_CONTROL,
365 sleep_enable_reg_info->access_bit_mask); 359 sleep_enable_reg_info->
366 if (ACPI_FAILURE (status)) { 360 access_bit_mask);
367 return_ACPI_STATUS (status); 361 if (ACPI_FAILURE(status)) {
362 return_ACPI_STATUS(status);
368 } 363 }
369 } 364 }
370 365
371 /* Wait until we enter sleep state */ 366 /* Wait until we enter sleep state */
372 367
373 do { 368 do {
374 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, 369 status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value,
375 ACPI_MTX_DO_NOT_LOCK); 370 ACPI_MTX_DO_NOT_LOCK);
376 if (ACPI_FAILURE (status)) { 371 if (ACPI_FAILURE(status)) {
377 return_ACPI_STATUS (status); 372 return_ACPI_STATUS(status);
378 } 373 }
379 374
380 /* Spin until we wake */ 375 /* Spin until we wake */
381 376
382 } while (!in_value); 377 } while (!in_value);
383 378
384 return_ACPI_STATUS (AE_OK); 379 return_ACPI_STATUS(AE_OK);
385} 380}
386EXPORT_SYMBOL(acpi_enter_sleep_state);
387 381
382EXPORT_SYMBOL(acpi_enter_sleep_state);
388 383
389/******************************************************************************* 384/*******************************************************************************
390 * 385 *
@@ -399,60 +394,57 @@ EXPORT_SYMBOL(acpi_enter_sleep_state);
399 * 394 *
400 ******************************************************************************/ 395 ******************************************************************************/
401 396
402acpi_status asmlinkage 397acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
403acpi_enter_sleep_state_s4bios (
404 void)
405{ 398{
406 u32 in_value; 399 u32 in_value;
407 acpi_status status; 400 acpi_status status;
408
409 401
410 ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_s4bios"); 402 ACPI_FUNCTION_TRACE("acpi_enter_sleep_state_s4bios");
411 403
412 404 status =
413 status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); 405 acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
414 if (ACPI_FAILURE (status)) { 406 if (ACPI_FAILURE(status)) {
415 return_ACPI_STATUS (status); 407 return_ACPI_STATUS(status);
416 } 408 }
417 409
418 status = acpi_hw_clear_acpi_status (ACPI_MTX_DO_NOT_LOCK); 410 status = acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK);
419 if (ACPI_FAILURE (status)) { 411 if (ACPI_FAILURE(status)) {
420 return_ACPI_STATUS (status); 412 return_ACPI_STATUS(status);
421 } 413 }
422 414
423 /* 415 /*
424 * 1) Disable/Clear all GPEs 416 * 1) Disable/Clear all GPEs
425 * 2) Enable all wakeup GPEs 417 * 2) Enable all wakeup GPEs
426 */ 418 */
427 status = acpi_hw_disable_all_gpes (); 419 status = acpi_hw_disable_all_gpes();
428 if (ACPI_FAILURE (status)) { 420 if (ACPI_FAILURE(status)) {
429 return_ACPI_STATUS (status); 421 return_ACPI_STATUS(status);
430 } 422 }
431 acpi_gbl_system_awake_and_running = FALSE; 423 acpi_gbl_system_awake_and_running = FALSE;
432 424
433 status = acpi_hw_enable_all_wakeup_gpes (); 425 status = acpi_hw_enable_all_wakeup_gpes();
434 if (ACPI_FAILURE (status)) { 426 if (ACPI_FAILURE(status)) {
435 return_ACPI_STATUS (status); 427 return_ACPI_STATUS(status);
436 } 428 }
437 429
438 ACPI_FLUSH_CPU_CACHE (); 430 ACPI_FLUSH_CPU_CACHE();
439 431
440 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, 432 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd,
441 (u32) acpi_gbl_FADT->S4bios_req, 8); 433 (u32) acpi_gbl_FADT->S4bios_req, 8);
442 434
443 do { 435 do {
444 acpi_os_stall(1000); 436 acpi_os_stall(1000);
445 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, 437 status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value,
446 ACPI_MTX_DO_NOT_LOCK); 438 ACPI_MTX_DO_NOT_LOCK);
447 if (ACPI_FAILURE (status)) { 439 if (ACPI_FAILURE(status)) {
448 return_ACPI_STATUS (status); 440 return_ACPI_STATUS(status);
449 } 441 }
450 } while (!in_value); 442 } while (!in_value);
451 443
452 return_ACPI_STATUS (AE_OK); 444 return_ACPI_STATUS(AE_OK);
453} 445}
454EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
455 446
447EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
456 448
457/******************************************************************************* 449/*******************************************************************************
458 * 450 *
@@ -467,55 +459,62 @@ EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
467 * 459 *
468 ******************************************************************************/ 460 ******************************************************************************/
469 461
470acpi_status 462acpi_status acpi_leave_sleep_state(u8 sleep_state)
471acpi_leave_sleep_state (
472 u8 sleep_state)
473{ 463{
474 struct acpi_object_list arg_list; 464 struct acpi_object_list arg_list;
475 union acpi_object arg; 465 union acpi_object arg;
476 acpi_status status; 466 acpi_status status;
477 struct acpi_bit_register_info *sleep_type_reg_info; 467 struct acpi_bit_register_info *sleep_type_reg_info;
478 struct acpi_bit_register_info *sleep_enable_reg_info; 468 struct acpi_bit_register_info *sleep_enable_reg_info;
479 u32 PM1Acontrol; 469 u32 PM1Acontrol;
480 u32 PM1Bcontrol; 470 u32 PM1Bcontrol;
481
482
483 ACPI_FUNCTION_TRACE ("acpi_leave_sleep_state");
484 471
472 ACPI_FUNCTION_TRACE("acpi_leave_sleep_state");
485 473
486 /* 474 /*
487 * Set SLP_TYPE and SLP_EN to state S0. 475 * Set SLP_TYPE and SLP_EN to state S0.
488 * This is unclear from the ACPI Spec, but it is required 476 * This is unclear from the ACPI Spec, but it is required
489 * by some machines. 477 * by some machines.
490 */ 478 */
491 status = acpi_get_sleep_type_data (ACPI_STATE_S0, 479 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
492 &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); 480 &acpi_gbl_sleep_type_a,
493 if (ACPI_SUCCESS (status)) { 481 &acpi_gbl_sleep_type_b);
494 sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A); 482 if (ACPI_SUCCESS(status)) {
495 sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE); 483 sleep_type_reg_info =
484 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A);
485 sleep_enable_reg_info =
486 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
496 487
497 /* Get current value of PM1A control */ 488 /* Get current value of PM1A control */
498 489
499 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 490 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
500 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); 491 ACPI_REGISTER_PM1_CONTROL,
501 if (ACPI_SUCCESS (status)) { 492 &PM1Acontrol);
493 if (ACPI_SUCCESS(status)) {
502 /* Clear SLP_EN and SLP_TYP fields */ 494 /* Clear SLP_EN and SLP_TYP fields */
503 495
504 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | 496 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
505 sleep_enable_reg_info->access_bit_mask); 497 sleep_enable_reg_info->
498 access_bit_mask);
506 PM1Bcontrol = PM1Acontrol; 499 PM1Bcontrol = PM1Acontrol;
507 500
508 /* Insert SLP_TYP bits */ 501 /* Insert SLP_TYP bits */
509 502
510 PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); 503 PM1Acontrol |=
511 PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); 504 (acpi_gbl_sleep_type_a << sleep_type_reg_info->
505 bit_position);
506 PM1Bcontrol |=
507 (acpi_gbl_sleep_type_b << sleep_type_reg_info->
508 bit_position);
512 509
513 /* Just ignore any errors */ 510 /* Just ignore any errors */
514 511
515 (void) acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 512 (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
516 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 513 ACPI_REGISTER_PM1A_CONTROL,
517 (void) acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 514 PM1Acontrol);
518 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 515 (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
516 ACPI_REGISTER_PM1B_CONTROL,
517 PM1Bcontrol);
519 } 518 }
520 } 519 }
521 520
@@ -532,23 +531,23 @@ acpi_leave_sleep_state (
532 /* Ignore any errors from these methods */ 531 /* Ignore any errors from these methods */
533 532
534 arg.integer.value = ACPI_SST_WAKING; 533 arg.integer.value = ACPI_SST_WAKING;
535 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 534 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
536 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 535 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
537 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", 536 ACPI_REPORT_ERROR(("Method _SST failed, %s\n",
538 acpi_format_exception (status))); 537 acpi_format_exception(status)));
539 } 538 }
540 539
541 arg.integer.value = sleep_state; 540 arg.integer.value = sleep_state;
542 status = acpi_evaluate_object (NULL, METHOD_NAME__BFS, &arg_list, NULL); 541 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
543 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 542 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
544 ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", 543 ACPI_REPORT_ERROR(("Method _BFS failed, %s\n",
545 acpi_format_exception (status))); 544 acpi_format_exception(status)));
546 } 545 }
547 546
548 status = acpi_evaluate_object (NULL, METHOD_NAME__WAK, &arg_list, NULL); 547 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
549 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 548 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
550 ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", 549 ACPI_REPORT_ERROR(("Method _WAK failed, %s\n",
551 acpi_format_exception (status))); 550 acpi_format_exception(status)));
552 } 551 }
553 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ 552 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
554 553
@@ -557,33 +556,35 @@ acpi_leave_sleep_state (
557 * 1) Disable/Clear all GPEs 556 * 1) Disable/Clear all GPEs
558 * 2) Enable all runtime GPEs 557 * 2) Enable all runtime GPEs
559 */ 558 */
560 status = acpi_hw_disable_all_gpes (); 559 status = acpi_hw_disable_all_gpes();
561 if (ACPI_FAILURE (status)) { 560 if (ACPI_FAILURE(status)) {
562 return_ACPI_STATUS (status); 561 return_ACPI_STATUS(status);
563 } 562 }
564 acpi_gbl_system_awake_and_running = TRUE; 563 acpi_gbl_system_awake_and_running = TRUE;
565 564
566 status = acpi_hw_enable_all_runtime_gpes (); 565 status = acpi_hw_enable_all_runtime_gpes();
567 if (ACPI_FAILURE (status)) { 566 if (ACPI_FAILURE(status)) {
568 return_ACPI_STATUS (status); 567 return_ACPI_STATUS(status);
569 } 568 }
570 569
571 /* Enable power button */ 570 /* Enable power button */
572 571
573 (void) acpi_set_register( 572 (void)
574 acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].enable_register_id, 573 acpi_set_register(acpi_gbl_fixed_event_info
575 1, ACPI_MTX_DO_NOT_LOCK); 574 [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1,
575 ACPI_MTX_DO_NOT_LOCK);
576 576
577 (void) acpi_set_register( 577 (void)
578 acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].status_register_id, 578 acpi_set_register(acpi_gbl_fixed_event_info
579 1, ACPI_MTX_DO_NOT_LOCK); 579 [ACPI_EVENT_POWER_BUTTON].status_register_id, 1,
580 ACPI_MTX_DO_NOT_LOCK);
580 581
581 arg.integer.value = ACPI_SST_WORKING; 582 arg.integer.value = ACPI_SST_WORKING;
582 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 583 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
583 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 584 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
584 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", 585 ACPI_REPORT_ERROR(("Method _SST failed, %s\n",
585 acpi_format_exception (status))); 586 acpi_format_exception(status)));
586 } 587 }
587 588
588 return_ACPI_STATUS (status); 589 return_ACPI_STATUS(status);
589} 590}
diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c
index 49d7b395322e..aff6dc141784 100644
--- a/drivers/acpi/hardware/hwtimer.c
+++ b/drivers/acpi/hardware/hwtimer.c
@@ -46,8 +46,7 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47 47
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49 ACPI_MODULE_NAME ("hwtimer") 49ACPI_MODULE_NAME("hwtimer")
50
51 50
52/****************************************************************************** 51/******************************************************************************
53 * 52 *
@@ -60,29 +59,23 @@
60 * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits). 59 * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits).
61 * 60 *
62 ******************************************************************************/ 61 ******************************************************************************/
63 62acpi_status acpi_get_timer_resolution(u32 * resolution)
64acpi_status
65acpi_get_timer_resolution (
66 u32 *resolution)
67{ 63{
68 ACPI_FUNCTION_TRACE ("acpi_get_timer_resolution"); 64 ACPI_FUNCTION_TRACE("acpi_get_timer_resolution");
69
70 65
71 if (!resolution) { 66 if (!resolution) {
72 return_ACPI_STATUS (AE_BAD_PARAMETER); 67 return_ACPI_STATUS(AE_BAD_PARAMETER);
73 } 68 }
74 69
75 if (0 == acpi_gbl_FADT->tmr_val_ext) { 70 if (0 == acpi_gbl_FADT->tmr_val_ext) {
76 *resolution = 24; 71 *resolution = 24;
77 } 72 } else {
78 else {
79 *resolution = 32; 73 *resolution = 32;
80 } 74 }
81 75
82 return_ACPI_STATUS (AE_OK); 76 return_ACPI_STATUS(AE_OK);
83} 77}
84 78
85
86/****************************************************************************** 79/******************************************************************************
87 * 80 *
88 * FUNCTION: acpi_get_timer 81 * FUNCTION: acpi_get_timer
@@ -95,26 +88,22 @@ acpi_get_timer_resolution (
95 * 88 *
96 ******************************************************************************/ 89 ******************************************************************************/
97 90
98acpi_status 91acpi_status acpi_get_timer(u32 * ticks)
99acpi_get_timer (
100 u32 *ticks)
101{ 92{
102 acpi_status status; 93 acpi_status status;
103
104
105 ACPI_FUNCTION_TRACE ("acpi_get_timer");
106 94
95 ACPI_FUNCTION_TRACE("acpi_get_timer");
107 96
108 if (!ticks) { 97 if (!ticks) {
109 return_ACPI_STATUS (AE_BAD_PARAMETER); 98 return_ACPI_STATUS(AE_BAD_PARAMETER);
110 } 99 }
111 100
112 status = acpi_hw_low_level_read (32, ticks, &acpi_gbl_FADT->xpm_tmr_blk); 101 status = acpi_hw_low_level_read(32, ticks, &acpi_gbl_FADT->xpm_tmr_blk);
113 102
114 return_ACPI_STATUS (status); 103 return_ACPI_STATUS(status);
115} 104}
116EXPORT_SYMBOL(acpi_get_timer);
117 105
106EXPORT_SYMBOL(acpi_get_timer);
118 107
119/****************************************************************************** 108/******************************************************************************
120 * 109 *
@@ -146,21 +135,16 @@ EXPORT_SYMBOL(acpi_get_timer);
146 ******************************************************************************/ 135 ******************************************************************************/
147 136
148acpi_status 137acpi_status
149acpi_get_timer_duration ( 138acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
150 u32 start_ticks,
151 u32 end_ticks,
152 u32 *time_elapsed)
153{ 139{
154 acpi_status status; 140 acpi_status status;
155 u32 delta_ticks; 141 u32 delta_ticks;
156 acpi_integer quotient; 142 acpi_integer quotient;
157
158
159 ACPI_FUNCTION_TRACE ("acpi_get_timer_duration");
160 143
144 ACPI_FUNCTION_TRACE("acpi_get_timer_duration");
161 145
162 if (!time_elapsed) { 146 if (!time_elapsed) {
163 return_ACPI_STATUS (AE_BAD_PARAMETER); 147 return_ACPI_STATUS(AE_BAD_PARAMETER);
164 } 148 }
165 149
166 /* 150 /*
@@ -169,22 +153,22 @@ acpi_get_timer_duration (
169 */ 153 */
170 if (start_ticks < end_ticks) { 154 if (start_ticks < end_ticks) {
171 delta_ticks = end_ticks - start_ticks; 155 delta_ticks = end_ticks - start_ticks;
172 } 156 } else if (start_ticks > end_ticks) {
173 else if (start_ticks > end_ticks) {
174 if (0 == acpi_gbl_FADT->tmr_val_ext) { 157 if (0 == acpi_gbl_FADT->tmr_val_ext) {
175 /* 24-bit Timer */ 158 /* 24-bit Timer */
176 159
177 delta_ticks = (((0x00FFFFFF - start_ticks) + end_ticks) & 0x00FFFFFF); 160 delta_ticks =
178 } 161 (((0x00FFFFFF - start_ticks) +
179 else { 162 end_ticks) & 0x00FFFFFF);
163 } else {
180 /* 32-bit Timer */ 164 /* 32-bit Timer */
181 165
182 delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks; 166 delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks;
183 } 167 }
184 } 168 } else { /* start_ticks == end_ticks */
185 else /* start_ticks == end_ticks */ { 169
186 *time_elapsed = 0; 170 *time_elapsed = 0;
187 return_ACPI_STATUS (AE_OK); 171 return_ACPI_STATUS(AE_OK);
188 } 172 }
189 173
190 /* 174 /*
@@ -192,12 +176,11 @@ acpi_get_timer_duration (
192 * 176 *
193 * time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY; 177 * time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY;
194 */ 178 */
195 status = acpi_ut_short_divide (((u64) delta_ticks) * 1000000, 179 status = acpi_ut_short_divide(((u64) delta_ticks) * 1000000,
196 PM_TIMER_FREQUENCY, &quotient, NULL); 180 PM_TIMER_FREQUENCY, &quotient, NULL);
197 181
198 *time_elapsed = (u32) quotient; 182 *time_elapsed = (u32) quotient;
199 return_ACPI_STATUS (status); 183 return_ACPI_STATUS(status);
200} 184}
201 185
202EXPORT_SYMBOL(acpi_get_timer_duration); 186EXPORT_SYMBOL(acpi_get_timer_duration);
203