diff options
author | Len Brown <len.brown@intel.com> | 2009-01-09 00:13:17 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-01-09 03:30:47 -0500 |
commit | 95b482a8d31116f3f5c2a5089569393234d06385 (patch) | |
tree | f32aec8673a285a9d188948be97af3034ee06e93 /drivers/acpi/hardware | |
parent | 6620e0c49f577454b772fb381543d60ae53eb885 (diff) |
ACPICA: create acpica/ directory
also, delete sleep/ and delete ACPI_CFLAGS from Makefile
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/hardware')
-rw-r--r-- | drivers/acpi/hardware/Makefile | 9 | ||||
-rw-r--r-- | drivers/acpi/hardware/hwacpi.c | 185 | ||||
-rw-r--r-- | drivers/acpi/hardware/hwgpe.c | 469 | ||||
-rw-r--r-- | drivers/acpi/hardware/hwregs.c | 353 | ||||
-rw-r--r-- | drivers/acpi/hardware/hwsleep.c | 629 | ||||
-rw-r--r-- | drivers/acpi/hardware/hwtimer.c | 188 | ||||
-rw-r--r-- | drivers/acpi/hardware/hwxface.c | 593 |
7 files changed, 0 insertions, 2426 deletions
diff --git a/drivers/acpi/hardware/Makefile b/drivers/acpi/hardware/Makefile deleted file mode 100644 index 238fbe513b82..000000000000 --- a/drivers/acpi/hardware/Makefile +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | # | ||
2 | # Makefile for all Linux ACPI interpreter subdirectories | ||
3 | # | ||
4 | |||
5 | obj-y := hwacpi.o hwgpe.o hwregs.o hwsleep.o hwxface.o | ||
6 | |||
7 | obj-$(ACPI_FUTURE_USAGE) += hwtimer.o | ||
8 | |||
9 | EXTRA_CFLAGS += $(ACPI_CFLAGS) | ||
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c deleted file mode 100644 index c76e3cd7e749..000000000000 --- a/drivers/acpi/hardware/hwacpi.c +++ /dev/null | |||
@@ -1,185 +0,0 @@ | |||
1 | |||
2 | /****************************************************************************** | ||
3 | * | ||
4 | * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface | ||
5 | * | ||
6 | *****************************************************************************/ | ||
7 | |||
8 | /* | ||
9 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
10 | * All rights reserved. | ||
11 | * | ||
12 | * Redistribution and use in source and binary forms, with or without | ||
13 | * modification, are permitted provided that the following conditions | ||
14 | * are met: | ||
15 | * 1. Redistributions of source code must retain the above copyright | ||
16 | * notice, this list of conditions, and the following disclaimer, | ||
17 | * without modification. | ||
18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
19 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
20 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
21 | * including a substantially similar Disclaimer requirement for further | ||
22 | * binary redistribution. | ||
23 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
24 | * of any contributors may be used to endorse or promote products derived | ||
25 | * from this software without specific prior written permission. | ||
26 | * | ||
27 | * Alternatively, this software may be distributed under the terms of the | ||
28 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
29 | * Software Foundation. | ||
30 | * | ||
31 | * NO WARRANTY | ||
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
42 | * POSSIBILITY OF SUCH DAMAGES. | ||
43 | */ | ||
44 | |||
45 | #include <acpi/acpi.h> | ||
46 | #include <acpi/accommon.h> | ||
47 | |||
48 | #define _COMPONENT ACPI_HARDWARE | ||
49 | ACPI_MODULE_NAME("hwacpi") | ||
50 | |||
51 | /****************************************************************************** | ||
52 | * | ||
53 | * FUNCTION: acpi_hw_set_mode | ||
54 | * | ||
55 | * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY | ||
56 | * | ||
57 | * RETURN: Status | ||
58 | * | ||
59 | * DESCRIPTION: Transitions the system into the requested mode. | ||
60 | * | ||
61 | ******************************************************************************/ | ||
62 | acpi_status acpi_hw_set_mode(u32 mode) | ||
63 | { | ||
64 | |||
65 | acpi_status status; | ||
66 | u32 retry; | ||
67 | |||
68 | ACPI_FUNCTION_TRACE(hw_set_mode); | ||
69 | |||
70 | /* | ||
71 | * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, | ||
72 | * system does not support mode transition. | ||
73 | */ | ||
74 | if (!acpi_gbl_FADT.smi_command) { | ||
75 | ACPI_ERROR((AE_INFO, | ||
76 | "No SMI_CMD in FADT, mode transition failed")); | ||
77 | return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); | ||
78 | } | ||
79 | |||
80 | /* | ||
81 | * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE | ||
82 | * in FADT: If it is zero, enabling or disabling is not supported. | ||
83 | * As old systems may have used zero for mode transition, | ||
84 | * we make sure both the numbers are zero to determine these | ||
85 | * transitions are not supported. | ||
86 | */ | ||
87 | if (!acpi_gbl_FADT.acpi_enable && !acpi_gbl_FADT.acpi_disable) { | ||
88 | ACPI_ERROR((AE_INFO, | ||
89 | "No ACPI mode transition supported in this system (enable/disable both zero)")); | ||
90 | return_ACPI_STATUS(AE_OK); | ||
91 | } | ||
92 | |||
93 | switch (mode) { | ||
94 | case ACPI_SYS_MODE_ACPI: | ||
95 | |||
96 | /* BIOS should have disabled ALL fixed and GP events */ | ||
97 | |||
98 | status = acpi_os_write_port(acpi_gbl_FADT.smi_command, | ||
99 | (u32) acpi_gbl_FADT.acpi_enable, 8); | ||
100 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
101 | "Attempting to enable ACPI mode\n")); | ||
102 | break; | ||
103 | |||
104 | case ACPI_SYS_MODE_LEGACY: | ||
105 | |||
106 | /* | ||
107 | * BIOS should clear all fixed status bits and restore fixed event | ||
108 | * enable bits to default | ||
109 | */ | ||
110 | status = acpi_os_write_port(acpi_gbl_FADT.smi_command, | ||
111 | (u32) acpi_gbl_FADT.acpi_disable, | ||
112 | 8); | ||
113 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
114 | "Attempting to enable Legacy (non-ACPI) mode\n")); | ||
115 | break; | ||
116 | |||
117 | default: | ||
118 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
119 | } | ||
120 | |||
121 | if (ACPI_FAILURE(status)) { | ||
122 | ACPI_EXCEPTION((AE_INFO, status, | ||
123 | "Could not write ACPI mode change")); | ||
124 | return_ACPI_STATUS(status); | ||
125 | } | ||
126 | |||
127 | /* | ||
128 | * Some hardware takes a LONG time to switch modes. Give them 3 sec to | ||
129 | * do so, but allow faster systems to proceed more quickly. | ||
130 | */ | ||
131 | retry = 3000; | ||
132 | while (retry) { | ||
133 | if (acpi_hw_get_mode() == mode) { | ||
134 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
135 | "Mode %X successfully enabled\n", | ||
136 | mode)); | ||
137 | return_ACPI_STATUS(AE_OK); | ||
138 | } | ||
139 | acpi_os_stall(1000); | ||
140 | retry--; | ||
141 | } | ||
142 | |||
143 | ACPI_ERROR((AE_INFO, "Hardware did not change modes")); | ||
144 | return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); | ||
145 | } | ||
146 | |||
147 | /******************************************************************************* | ||
148 | * | ||
149 | * FUNCTION: acpi_hw_get_mode | ||
150 | * | ||
151 | * PARAMETERS: none | ||
152 | * | ||
153 | * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY | ||
154 | * | ||
155 | * DESCRIPTION: Return current operating state of system. Determined by | ||
156 | * querying the SCI_EN bit. | ||
157 | * | ||
158 | ******************************************************************************/ | ||
159 | |||
160 | u32 acpi_hw_get_mode(void) | ||
161 | { | ||
162 | acpi_status status; | ||
163 | u32 value; | ||
164 | |||
165 | ACPI_FUNCTION_TRACE(hw_get_mode); | ||
166 | |||
167 | /* | ||
168 | * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, | ||
169 | * system does not support mode transition. | ||
170 | */ | ||
171 | if (!acpi_gbl_FADT.smi_command) { | ||
172 | return_UINT32(ACPI_SYS_MODE_ACPI); | ||
173 | } | ||
174 | |||
175 | status = acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value); | ||
176 | if (ACPI_FAILURE(status)) { | ||
177 | return_UINT32(ACPI_SYS_MODE_LEGACY); | ||
178 | } | ||
179 | |||
180 | if (value) { | ||
181 | return_UINT32(ACPI_SYS_MODE_ACPI); | ||
182 | } else { | ||
183 | return_UINT32(ACPI_SYS_MODE_LEGACY); | ||
184 | } | ||
185 | } | ||
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c deleted file mode 100644 index 2b4a85a839d1..000000000000 --- a/drivers/acpi/hardware/hwgpe.c +++ /dev/null | |||
@@ -1,469 +0,0 @@ | |||
1 | |||
2 | /****************************************************************************** | ||
3 | * | ||
4 | * Module Name: hwgpe - Low level GPE enable/disable/clear functions | ||
5 | * | ||
6 | *****************************************************************************/ | ||
7 | |||
8 | /* | ||
9 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
10 | * All rights reserved. | ||
11 | * | ||
12 | * Redistribution and use in source and binary forms, with or without | ||
13 | * modification, are permitted provided that the following conditions | ||
14 | * are met: | ||
15 | * 1. Redistributions of source code must retain the above copyright | ||
16 | * notice, this list of conditions, and the following disclaimer, | ||
17 | * without modification. | ||
18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
19 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
20 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
21 | * including a substantially similar Disclaimer requirement for further | ||
22 | * binary redistribution. | ||
23 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
24 | * of any contributors may be used to endorse or promote products derived | ||
25 | * from this software without specific prior written permission. | ||
26 | * | ||
27 | * Alternatively, this software may be distributed under the terms of the | ||
28 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
29 | * Software Foundation. | ||
30 | * | ||
31 | * NO WARRANTY | ||
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
42 | * POSSIBILITY OF SUCH DAMAGES. | ||
43 | */ | ||
44 | |||
45 | #include <acpi/acpi.h> | ||
46 | #include <acpi/accommon.h> | ||
47 | #include <acpi/acevents.h> | ||
48 | |||
49 | #define _COMPONENT ACPI_HARDWARE | ||
50 | ACPI_MODULE_NAME("hwgpe") | ||
51 | |||
52 | /* Local prototypes */ | ||
53 | static acpi_status | ||
54 | acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
55 | struct acpi_gpe_block_info *gpe_block, | ||
56 | void *context); | ||
57 | |||
58 | /****************************************************************************** | ||
59 | * | ||
60 | * FUNCTION: acpi_hw_low_disable_gpe | ||
61 | * | ||
62 | * PARAMETERS: gpe_event_info - Info block for the GPE to be disabled | ||
63 | * | ||
64 | * RETURN: Status | ||
65 | * | ||
66 | * DESCRIPTION: Disable a single GPE in the enable register. | ||
67 | * | ||
68 | ******************************************************************************/ | ||
69 | |||
70 | acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) | ||
71 | { | ||
72 | struct acpi_gpe_register_info *gpe_register_info; | ||
73 | acpi_status status; | ||
74 | u32 enable_mask; | ||
75 | |||
76 | /* Get the info block for the entire GPE register */ | ||
77 | |||
78 | gpe_register_info = gpe_event_info->register_info; | ||
79 | if (!gpe_register_info) { | ||
80 | return (AE_NOT_EXIST); | ||
81 | } | ||
82 | |||
83 | /* Get current value of the enable register that contains this GPE */ | ||
84 | |||
85 | status = acpi_read(&enable_mask, &gpe_register_info->enable_address); | ||
86 | if (ACPI_FAILURE(status)) { | ||
87 | return (status); | ||
88 | } | ||
89 | |||
90 | /* Clear just the bit that corresponds to this GPE */ | ||
91 | |||
92 | ACPI_CLEAR_BIT(enable_mask, | ||
93 | ((u32) 1 << | ||
94 | (gpe_event_info->gpe_number - | ||
95 | gpe_register_info->base_gpe_number))); | ||
96 | |||
97 | /* Write the updated enable mask */ | ||
98 | |||
99 | status = acpi_write(enable_mask, &gpe_register_info->enable_address); | ||
100 | return (status); | ||
101 | } | ||
102 | |||
103 | /****************************************************************************** | ||
104 | * | ||
105 | * FUNCTION: acpi_hw_write_gpe_enable_reg | ||
106 | * | ||
107 | * PARAMETERS: gpe_event_info - Info block for the GPE to be enabled | ||
108 | * | ||
109 | * RETURN: Status | ||
110 | * | ||
111 | * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must | ||
112 | * already be cleared or set in the parent register | ||
113 | * enable_for_run mask. | ||
114 | * | ||
115 | ******************************************************************************/ | ||
116 | |||
117 | acpi_status | ||
118 | acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info) | ||
119 | { | ||
120 | struct acpi_gpe_register_info *gpe_register_info; | ||
121 | acpi_status status; | ||
122 | |||
123 | ACPI_FUNCTION_ENTRY(); | ||
124 | |||
125 | /* Get the info block for the entire GPE register */ | ||
126 | |||
127 | gpe_register_info = gpe_event_info->register_info; | ||
128 | if (!gpe_register_info) { | ||
129 | return (AE_NOT_EXIST); | ||
130 | } | ||
131 | |||
132 | /* Write the entire GPE (runtime) enable register */ | ||
133 | |||
134 | status = acpi_write(gpe_register_info->enable_for_run, | ||
135 | &gpe_register_info->enable_address); | ||
136 | |||
137 | return (status); | ||
138 | } | ||
139 | |||
140 | /****************************************************************************** | ||
141 | * | ||
142 | * FUNCTION: acpi_hw_clear_gpe | ||
143 | * | ||
144 | * PARAMETERS: gpe_event_info - Info block for the GPE to be cleared | ||
145 | * | ||
146 | * RETURN: Status | ||
147 | * | ||
148 | * DESCRIPTION: Clear the status bit for a single GPE. | ||
149 | * | ||
150 | ******************************************************************************/ | ||
151 | |||
152 | acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) | ||
153 | { | ||
154 | acpi_status status; | ||
155 | u8 register_bit; | ||
156 | |||
157 | ACPI_FUNCTION_ENTRY(); | ||
158 | |||
159 | register_bit = (u8) | ||
160 | (1 << | ||
161 | (gpe_event_info->gpe_number - | ||
162 | gpe_event_info->register_info->base_gpe_number)); | ||
163 | |||
164 | /* | ||
165 | * Write a one to the appropriate bit in the status register to | ||
166 | * clear this GPE. | ||
167 | */ | ||
168 | status = acpi_write(register_bit, | ||
169 | &gpe_event_info->register_info->status_address); | ||
170 | |||
171 | return (status); | ||
172 | } | ||
173 | |||
174 | /****************************************************************************** | ||
175 | * | ||
176 | * FUNCTION: acpi_hw_get_gpe_status | ||
177 | * | ||
178 | * PARAMETERS: gpe_event_info - Info block for the GPE to queried | ||
179 | * event_status - Where the GPE status is returned | ||
180 | * | ||
181 | * RETURN: Status | ||
182 | * | ||
183 | * DESCRIPTION: Return the status of a single GPE. | ||
184 | * | ||
185 | ******************************************************************************/ | ||
186 | |||
187 | acpi_status | ||
188 | acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, | ||
189 | acpi_event_status * event_status) | ||
190 | { | ||
191 | u32 in_byte; | ||
192 | u8 register_bit; | ||
193 | struct acpi_gpe_register_info *gpe_register_info; | ||
194 | acpi_status status; | ||
195 | acpi_event_status local_event_status = 0; | ||
196 | |||
197 | ACPI_FUNCTION_ENTRY(); | ||
198 | |||
199 | if (!event_status) { | ||
200 | return (AE_BAD_PARAMETER); | ||
201 | } | ||
202 | |||
203 | /* Get the info block for the entire GPE register */ | ||
204 | |||
205 | gpe_register_info = gpe_event_info->register_info; | ||
206 | |||
207 | /* Get the register bitmask for this GPE */ | ||
208 | |||
209 | register_bit = (u8) | ||
210 | (1 << | ||
211 | (gpe_event_info->gpe_number - | ||
212 | gpe_event_info->register_info->base_gpe_number)); | ||
213 | |||
214 | /* GPE currently enabled? (enabled for runtime?) */ | ||
215 | |||
216 | if (register_bit & gpe_register_info->enable_for_run) { | ||
217 | local_event_status |= ACPI_EVENT_FLAG_ENABLED; | ||
218 | } | ||
219 | |||
220 | /* GPE enabled for wake? */ | ||
221 | |||
222 | if (register_bit & gpe_register_info->enable_for_wake) { | ||
223 | local_event_status |= ACPI_EVENT_FLAG_WAKE_ENABLED; | ||
224 | } | ||
225 | |||
226 | /* GPE currently active (status bit == 1)? */ | ||
227 | |||
228 | status = acpi_read(&in_byte, &gpe_register_info->status_address); | ||
229 | if (ACPI_FAILURE(status)) { | ||
230 | goto unlock_and_exit; | ||
231 | } | ||
232 | |||
233 | if (register_bit & in_byte) { | ||
234 | local_event_status |= ACPI_EVENT_FLAG_SET; | ||
235 | } | ||
236 | |||
237 | /* Set return value */ | ||
238 | |||
239 | (*event_status) = local_event_status; | ||
240 | |||
241 | unlock_and_exit: | ||
242 | return (status); | ||
243 | } | ||
244 | |||
245 | /****************************************************************************** | ||
246 | * | ||
247 | * FUNCTION: acpi_hw_disable_gpe_block | ||
248 | * | ||
249 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info | ||
250 | * gpe_block - Gpe Block info | ||
251 | * | ||
252 | * RETURN: Status | ||
253 | * | ||
254 | * DESCRIPTION: Disable all GPEs within a single GPE block | ||
255 | * | ||
256 | ******************************************************************************/ | ||
257 | |||
258 | acpi_status | ||
259 | acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
260 | struct acpi_gpe_block_info *gpe_block, void *context) | ||
261 | { | ||
262 | u32 i; | ||
263 | acpi_status status; | ||
264 | |||
265 | /* Examine each GPE Register within the block */ | ||
266 | |||
267 | for (i = 0; i < gpe_block->register_count; i++) { | ||
268 | |||
269 | /* Disable all GPEs in this register */ | ||
270 | |||
271 | status = | ||
272 | acpi_write(0x00, | ||
273 | &gpe_block->register_info[i].enable_address); | ||
274 | if (ACPI_FAILURE(status)) { | ||
275 | return (status); | ||
276 | } | ||
277 | } | ||
278 | |||
279 | return (AE_OK); | ||
280 | } | ||
281 | |||
282 | /****************************************************************************** | ||
283 | * | ||
284 | * FUNCTION: acpi_hw_clear_gpe_block | ||
285 | * | ||
286 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info | ||
287 | * gpe_block - Gpe Block info | ||
288 | * | ||
289 | * RETURN: Status | ||
290 | * | ||
291 | * DESCRIPTION: Clear status bits for all GPEs within a single GPE block | ||
292 | * | ||
293 | ******************************************************************************/ | ||
294 | |||
295 | acpi_status | ||
296 | acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
297 | struct acpi_gpe_block_info *gpe_block, void *context) | ||
298 | { | ||
299 | u32 i; | ||
300 | acpi_status status; | ||
301 | |||
302 | /* Examine each GPE Register within the block */ | ||
303 | |||
304 | for (i = 0; i < gpe_block->register_count; i++) { | ||
305 | |||
306 | /* Clear status on all GPEs in this register */ | ||
307 | |||
308 | status = | ||
309 | acpi_write(0xFF, | ||
310 | &gpe_block->register_info[i].status_address); | ||
311 | if (ACPI_FAILURE(status)) { | ||
312 | return (status); | ||
313 | } | ||
314 | } | ||
315 | |||
316 | return (AE_OK); | ||
317 | } | ||
318 | |||
319 | /****************************************************************************** | ||
320 | * | ||
321 | * FUNCTION: acpi_hw_enable_runtime_gpe_block | ||
322 | * | ||
323 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info | ||
324 | * gpe_block - Gpe Block info | ||
325 | * | ||
326 | * RETURN: Status | ||
327 | * | ||
328 | * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes | ||
329 | * combination wake/run GPEs. | ||
330 | * | ||
331 | ******************************************************************************/ | ||
332 | |||
333 | acpi_status | ||
334 | acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
335 | struct acpi_gpe_block_info *gpe_block, void *context) | ||
336 | { | ||
337 | u32 i; | ||
338 | acpi_status status; | ||
339 | |||
340 | /* NOTE: assumes that all GPEs are currently disabled */ | ||
341 | |||
342 | /* Examine each GPE Register within the block */ | ||
343 | |||
344 | for (i = 0; i < gpe_block->register_count; i++) { | ||
345 | if (!gpe_block->register_info[i].enable_for_run) { | ||
346 | continue; | ||
347 | } | ||
348 | |||
349 | /* Enable all "runtime" GPEs in this register */ | ||
350 | |||
351 | status = acpi_write(gpe_block->register_info[i].enable_for_run, | ||
352 | &gpe_block->register_info[i]. | ||
353 | enable_address); | ||
354 | if (ACPI_FAILURE(status)) { | ||
355 | return (status); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | return (AE_OK); | ||
360 | } | ||
361 | |||
362 | /****************************************************************************** | ||
363 | * | ||
364 | * FUNCTION: acpi_hw_enable_wakeup_gpe_block | ||
365 | * | ||
366 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info | ||
367 | * gpe_block - Gpe Block info | ||
368 | * | ||
369 | * RETURN: Status | ||
370 | * | ||
371 | * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes | ||
372 | * combination wake/run GPEs. | ||
373 | * | ||
374 | ******************************************************************************/ | ||
375 | |||
376 | static acpi_status | ||
377 | acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
378 | struct acpi_gpe_block_info *gpe_block, | ||
379 | void *context) | ||
380 | { | ||
381 | u32 i; | ||
382 | acpi_status status; | ||
383 | |||
384 | /* Examine each GPE Register within the block */ | ||
385 | |||
386 | for (i = 0; i < gpe_block->register_count; i++) { | ||
387 | if (!gpe_block->register_info[i].enable_for_wake) { | ||
388 | continue; | ||
389 | } | ||
390 | |||
391 | /* Enable all "wake" GPEs in this register */ | ||
392 | |||
393 | status = acpi_write(gpe_block->register_info[i].enable_for_wake, | ||
394 | &gpe_block->register_info[i]. | ||
395 | enable_address); | ||
396 | if (ACPI_FAILURE(status)) { | ||
397 | return (status); | ||
398 | } | ||
399 | } | ||
400 | |||
401 | return (AE_OK); | ||
402 | } | ||
403 | |||
404 | /****************************************************************************** | ||
405 | * | ||
406 | * FUNCTION: acpi_hw_disable_all_gpes | ||
407 | * | ||
408 | * PARAMETERS: None | ||
409 | * | ||
410 | * RETURN: Status | ||
411 | * | ||
412 | * DESCRIPTION: Disable and clear all GPEs in all GPE blocks | ||
413 | * | ||
414 | ******************************************************************************/ | ||
415 | |||
416 | acpi_status acpi_hw_disable_all_gpes(void) | ||
417 | { | ||
418 | acpi_status status; | ||
419 | |||
420 | ACPI_FUNCTION_TRACE(hw_disable_all_gpes); | ||
421 | |||
422 | status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL); | ||
423 | status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); | ||
424 | return_ACPI_STATUS(status); | ||
425 | } | ||
426 | |||
427 | /****************************************************************************** | ||
428 | * | ||
429 | * FUNCTION: acpi_hw_enable_all_runtime_gpes | ||
430 | * | ||
431 | * PARAMETERS: None | ||
432 | * | ||
433 | * RETURN: Status | ||
434 | * | ||
435 | * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks | ||
436 | * | ||
437 | ******************************************************************************/ | ||
438 | |||
439 | acpi_status acpi_hw_enable_all_runtime_gpes(void) | ||
440 | { | ||
441 | acpi_status status; | ||
442 | |||
443 | ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes); | ||
444 | |||
445 | status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block, NULL); | ||
446 | return_ACPI_STATUS(status); | ||
447 | } | ||
448 | |||
449 | /****************************************************************************** | ||
450 | * | ||
451 | * FUNCTION: acpi_hw_enable_all_wakeup_gpes | ||
452 | * | ||
453 | * PARAMETERS: None | ||
454 | * | ||
455 | * RETURN: Status | ||
456 | * | ||
457 | * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks | ||
458 | * | ||
459 | ******************************************************************************/ | ||
460 | |||
461 | acpi_status acpi_hw_enable_all_wakeup_gpes(void) | ||
462 | { | ||
463 | acpi_status status; | ||
464 | |||
465 | ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes); | ||
466 | |||
467 | status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL); | ||
468 | return_ACPI_STATUS(status); | ||
469 | } | ||
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c deleted file mode 100644 index 4bc3bbba6e9c..000000000000 --- a/drivers/acpi/hardware/hwregs.c +++ /dev/null | |||
@@ -1,353 +0,0 @@ | |||
1 | |||
2 | /******************************************************************************* | ||
3 | * | ||
4 | * Module Name: hwregs - Read/write access functions for the various ACPI | ||
5 | * control and status registers. | ||
6 | * | ||
7 | ******************************************************************************/ | ||
8 | |||
9 | /* | ||
10 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
11 | * All rights reserved. | ||
12 | * | ||
13 | * Redistribution and use in source and binary forms, with or without | ||
14 | * modification, are permitted provided that the following conditions | ||
15 | * are met: | ||
16 | * 1. Redistributions of source code must retain the above copyright | ||
17 | * notice, this list of conditions, and the following disclaimer, | ||
18 | * without modification. | ||
19 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
20 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
21 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
22 | * including a substantially similar Disclaimer requirement for further | ||
23 | * binary redistribution. | ||
24 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
25 | * of any contributors may be used to endorse or promote products derived | ||
26 | * from this software without specific prior written permission. | ||
27 | * | ||
28 | * Alternatively, this software may be distributed under the terms of the | ||
29 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
30 | * Software Foundation. | ||
31 | * | ||
32 | * NO WARRANTY | ||
33 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
34 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
36 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
37 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
38 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
39 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
40 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
41 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
42 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
43 | * POSSIBILITY OF SUCH DAMAGES. | ||
44 | */ | ||
45 | |||
46 | #include <acpi/acpi.h> | ||
47 | #include <acpi/accommon.h> | ||
48 | #include <acpi/acnamesp.h> | ||
49 | #include <acpi/acevents.h> | ||
50 | |||
51 | #define _COMPONENT ACPI_HARDWARE | ||
52 | ACPI_MODULE_NAME("hwregs") | ||
53 | |||
54 | /******************************************************************************* | ||
55 | * | ||
56 | * FUNCTION: acpi_hw_clear_acpi_status | ||
57 | * | ||
58 | * PARAMETERS: None | ||
59 | * | ||
60 | * RETURN: Status | ||
61 | * | ||
62 | * DESCRIPTION: Clears all fixed and general purpose status bits | ||
63 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED | ||
64 | * | ||
65 | ******************************************************************************/ | ||
66 | acpi_status acpi_hw_clear_acpi_status(void) | ||
67 | { | ||
68 | acpi_status status; | ||
69 | acpi_cpu_flags lock_flags = 0; | ||
70 | |||
71 | ACPI_FUNCTION_TRACE(hw_clear_acpi_status); | ||
72 | |||
73 | ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n", | ||
74 | ACPI_BITMASK_ALL_FIXED_STATUS, | ||
75 | (u16) acpi_gbl_FADT.xpm1a_event_block.address)); | ||
76 | |||
77 | lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
78 | |||
79 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, | ||
80 | ACPI_BITMASK_ALL_FIXED_STATUS); | ||
81 | if (ACPI_FAILURE(status)) { | ||
82 | goto unlock_and_exit; | ||
83 | } | ||
84 | |||
85 | /* Clear the fixed events */ | ||
86 | |||
87 | if (acpi_gbl_FADT.xpm1b_event_block.address) { | ||
88 | status = acpi_write(ACPI_BITMASK_ALL_FIXED_STATUS, | ||
89 | &acpi_gbl_FADT.xpm1b_event_block); | ||
90 | if (ACPI_FAILURE(status)) { | ||
91 | goto unlock_and_exit; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | /* Clear the GPE Bits in all GPE registers in all GPE blocks */ | ||
96 | |||
97 | status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); | ||
98 | |||
99 | unlock_and_exit: | ||
100 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); | ||
101 | return_ACPI_STATUS(status); | ||
102 | } | ||
103 | |||
104 | /******************************************************************************* | ||
105 | * | ||
106 | * FUNCTION: acpi_hw_get_register_bit_mask | ||
107 | * | ||
108 | * PARAMETERS: register_id - Index of ACPI Register to access | ||
109 | * | ||
110 | * RETURN: The bitmask to be used when accessing the register | ||
111 | * | ||
112 | * DESCRIPTION: Map register_id into a register bitmask. | ||
113 | * | ||
114 | ******************************************************************************/ | ||
115 | |||
116 | struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) | ||
117 | { | ||
118 | ACPI_FUNCTION_ENTRY(); | ||
119 | |||
120 | if (register_id > ACPI_BITREG_MAX) { | ||
121 | ACPI_ERROR((AE_INFO, "Invalid BitRegister ID: %X", | ||
122 | register_id)); | ||
123 | return (NULL); | ||
124 | } | ||
125 | |||
126 | return (&acpi_gbl_bit_register_info[register_id]); | ||
127 | } | ||
128 | |||
129 | /****************************************************************************** | ||
130 | * | ||
131 | * FUNCTION: acpi_hw_register_read | ||
132 | * | ||
133 | * PARAMETERS: register_id - ACPI Register ID | ||
134 | * return_value - Where the register value is returned | ||
135 | * | ||
136 | * RETURN: Status and the value read. | ||
137 | * | ||
138 | * DESCRIPTION: Read from the specified ACPI register | ||
139 | * | ||
140 | ******************************************************************************/ | ||
141 | acpi_status | ||
142 | acpi_hw_register_read(u32 register_id, u32 * return_value) | ||
143 | { | ||
144 | u32 value1 = 0; | ||
145 | u32 value2 = 0; | ||
146 | acpi_status status; | ||
147 | |||
148 | ACPI_FUNCTION_TRACE(hw_register_read); | ||
149 | |||
150 | switch (register_id) { | ||
151 | case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ | ||
152 | |||
153 | status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_event_block); | ||
154 | if (ACPI_FAILURE(status)) { | ||
155 | goto exit; | ||
156 | } | ||
157 | |||
158 | /* PM1B is optional */ | ||
159 | |||
160 | status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_event_block); | ||
161 | value1 |= value2; | ||
162 | break; | ||
163 | |||
164 | case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ | ||
165 | |||
166 | status = acpi_read(&value1, &acpi_gbl_xpm1a_enable); | ||
167 | if (ACPI_FAILURE(status)) { | ||
168 | goto exit; | ||
169 | } | ||
170 | |||
171 | /* PM1B is optional */ | ||
172 | |||
173 | status = acpi_read(&value2, &acpi_gbl_xpm1b_enable); | ||
174 | value1 |= value2; | ||
175 | break; | ||
176 | |||
177 | case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ | ||
178 | |||
179 | status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_control_block); | ||
180 | if (ACPI_FAILURE(status)) { | ||
181 | goto exit; | ||
182 | } | ||
183 | |||
184 | status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_control_block); | ||
185 | value1 |= value2; | ||
186 | break; | ||
187 | |||
188 | case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ | ||
189 | |||
190 | status = acpi_read(&value1, &acpi_gbl_FADT.xpm2_control_block); | ||
191 | break; | ||
192 | |||
193 | case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ | ||
194 | |||
195 | status = acpi_read(&value1, &acpi_gbl_FADT.xpm_timer_block); | ||
196 | break; | ||
197 | |||
198 | case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ | ||
199 | |||
200 | status = | ||
201 | acpi_os_read_port(acpi_gbl_FADT.smi_command, &value1, 8); | ||
202 | break; | ||
203 | |||
204 | default: | ||
205 | ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id)); | ||
206 | status = AE_BAD_PARAMETER; | ||
207 | break; | ||
208 | } | ||
209 | |||
210 | exit: | ||
211 | |||
212 | if (ACPI_SUCCESS(status)) { | ||
213 | *return_value = value1; | ||
214 | } | ||
215 | |||
216 | return_ACPI_STATUS(status); | ||
217 | } | ||
218 | |||
219 | /****************************************************************************** | ||
220 | * | ||
221 | * FUNCTION: acpi_hw_register_write | ||
222 | * | ||
223 | * PARAMETERS: register_id - ACPI Register ID | ||
224 | * Value - The value to write | ||
225 | * | ||
226 | * RETURN: Status | ||
227 | * | ||
228 | * DESCRIPTION: Write to the specified ACPI register | ||
229 | * | ||
230 | * NOTE: In accordance with the ACPI specification, this function automatically | ||
231 | * preserves the value of the following bits, meaning that these bits cannot be | ||
232 | * changed via this interface: | ||
233 | * | ||
234 | * PM1_CONTROL[0] = SCI_EN | ||
235 | * PM1_CONTROL[9] | ||
236 | * PM1_STATUS[11] | ||
237 | * | ||
238 | * ACPI References: | ||
239 | * 1) Hardware Ignored Bits: When software writes to a register with ignored | ||
240 | * bit fields, it preserves the ignored bit fields | ||
241 | * 2) SCI_EN: OSPM always preserves this bit position | ||
242 | * | ||
243 | ******************************************************************************/ | ||
244 | |||
245 | acpi_status acpi_hw_register_write(u32 register_id, u32 value) | ||
246 | { | ||
247 | acpi_status status; | ||
248 | u32 read_value; | ||
249 | |||
250 | ACPI_FUNCTION_TRACE(hw_register_write); | ||
251 | |||
252 | switch (register_id) { | ||
253 | case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ | ||
254 | |||
255 | /* Perform a read first to preserve certain bits (per ACPI spec) */ | ||
256 | |||
257 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, | ||
258 | &read_value); | ||
259 | if (ACPI_FAILURE(status)) { | ||
260 | goto exit; | ||
261 | } | ||
262 | |||
263 | /* Insert the bits to be preserved */ | ||
264 | |||
265 | ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS, | ||
266 | read_value); | ||
267 | |||
268 | /* Now we can write the data */ | ||
269 | |||
270 | status = acpi_write(value, &acpi_gbl_FADT.xpm1a_event_block); | ||
271 | if (ACPI_FAILURE(status)) { | ||
272 | goto exit; | ||
273 | } | ||
274 | |||
275 | /* PM1B is optional */ | ||
276 | |||
277 | status = acpi_write(value, &acpi_gbl_FADT.xpm1b_event_block); | ||
278 | break; | ||
279 | |||
280 | case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ | ||
281 | |||
282 | status = acpi_write(value, &acpi_gbl_xpm1a_enable); | ||
283 | if (ACPI_FAILURE(status)) { | ||
284 | goto exit; | ||
285 | } | ||
286 | |||
287 | /* PM1B is optional */ | ||
288 | |||
289 | status = acpi_write(value, &acpi_gbl_xpm1b_enable); | ||
290 | break; | ||
291 | |||
292 | case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ | ||
293 | |||
294 | /* | ||
295 | * Perform a read first to preserve certain bits (per ACPI spec) | ||
296 | */ | ||
297 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, | ||
298 | &read_value); | ||
299 | if (ACPI_FAILURE(status)) { | ||
300 | goto exit; | ||
301 | } | ||
302 | |||
303 | /* Insert the bits to be preserved */ | ||
304 | |||
305 | ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS, | ||
306 | read_value); | ||
307 | |||
308 | /* Now we can write the data */ | ||
309 | |||
310 | status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block); | ||
311 | if (ACPI_FAILURE(status)) { | ||
312 | goto exit; | ||
313 | } | ||
314 | |||
315 | status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block); | ||
316 | break; | ||
317 | |||
318 | case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ | ||
319 | |||
320 | status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block); | ||
321 | break; | ||
322 | |||
323 | case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ | ||
324 | |||
325 | status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block); | ||
326 | break; | ||
327 | |||
328 | case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ | ||
329 | |||
330 | status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block); | ||
331 | break; | ||
332 | |||
333 | case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ | ||
334 | |||
335 | status = acpi_write(value, &acpi_gbl_FADT.xpm_timer_block); | ||
336 | break; | ||
337 | |||
338 | case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ | ||
339 | |||
340 | /* SMI_CMD is currently always in IO space */ | ||
341 | |||
342 | status = | ||
343 | acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8); | ||
344 | break; | ||
345 | |||
346 | default: | ||
347 | status = AE_BAD_PARAMETER; | ||
348 | break; | ||
349 | } | ||
350 | |||
351 | exit: | ||
352 | return_ACPI_STATUS(status); | ||
353 | } | ||
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c deleted file mode 100644 index 54dd3ee0760c..000000000000 --- a/drivers/acpi/hardware/hwsleep.c +++ /dev/null | |||
@@ -1,629 +0,0 @@ | |||
1 | |||
2 | /****************************************************************************** | ||
3 | * | ||
4 | * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface | ||
5 | * | ||
6 | *****************************************************************************/ | ||
7 | |||
8 | /* | ||
9 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
10 | * All rights reserved. | ||
11 | * | ||
12 | * Redistribution and use in source and binary forms, with or without | ||
13 | * modification, are permitted provided that the following conditions | ||
14 | * are met: | ||
15 | * 1. Redistributions of source code must retain the above copyright | ||
16 | * notice, this list of conditions, and the following disclaimer, | ||
17 | * without modification. | ||
18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
19 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
20 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
21 | * including a substantially similar Disclaimer requirement for further | ||
22 | * binary redistribution. | ||
23 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
24 | * of any contributors may be used to endorse or promote products derived | ||
25 | * from this software without specific prior written permission. | ||
26 | * | ||
27 | * Alternatively, this software may be distributed under the terms of the | ||
28 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
29 | * Software Foundation. | ||
30 | * | ||
31 | * NO WARRANTY | ||
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
42 | * POSSIBILITY OF SUCH DAMAGES. | ||
43 | */ | ||
44 | |||
45 | #include <acpi/acpi.h> | ||
46 | #include <acpi/accommon.h> | ||
47 | #include <acpi/actables.h> | ||
48 | |||
49 | #define _COMPONENT ACPI_HARDWARE | ||
50 | ACPI_MODULE_NAME("hwsleep") | ||
51 | |||
52 | /******************************************************************************* | ||
53 | * | ||
54 | * FUNCTION: acpi_set_firmware_waking_vector | ||
55 | * | ||
56 | * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode | ||
57 | * entry point. | ||
58 | * | ||
59 | * RETURN: Status | ||
60 | * | ||
61 | * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS | ||
62 | * | ||
63 | ******************************************************************************/ | ||
64 | acpi_status | ||
65 | acpi_set_firmware_waking_vector(u32 physical_address) | ||
66 | { | ||
67 | ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector); | ||
68 | |||
69 | |||
70 | /* | ||
71 | * According to the ACPI specification 2.0c and later, the 64-bit | ||
72 | * waking vector should be cleared and the 32-bit waking vector should | ||
73 | * be used, unless we want the wake-up code to be called by the BIOS in | ||
74 | * Protected Mode. Some systems (for example HP dv5-1004nr) are known | ||
75 | * to fail to resume if the 64-bit vector is used. | ||
76 | */ | ||
77 | |||
78 | /* Set the 32-bit vector */ | ||
79 | |||
80 | acpi_gbl_FACS->firmware_waking_vector = physical_address; | ||
81 | |||
82 | /* Clear the 64-bit vector if it exists */ | ||
83 | |||
84 | if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) { | ||
85 | acpi_gbl_FACS->xfirmware_waking_vector = 0; | ||
86 | } | ||
87 | |||
88 | return_ACPI_STATUS(AE_OK); | ||
89 | } | ||
90 | |||
91 | ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector) | ||
92 | |||
93 | /******************************************************************************* | ||
94 | * | ||
95 | * FUNCTION: acpi_set_firmware_waking_vector64 | ||
96 | * | ||
97 | * PARAMETERS: physical_address - 64-bit physical address of ACPI protected | ||
98 | * mode entry point. | ||
99 | * | ||
100 | * RETURN: Status | ||
101 | * | ||
102 | * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if | ||
103 | * it exists in the table. | ||
104 | * | ||
105 | ******************************************************************************/ | ||
106 | acpi_status | ||
107 | acpi_set_firmware_waking_vector64(u64 physical_address) | ||
108 | { | ||
109 | ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64); | ||
110 | |||
111 | |||
112 | /* Determine if the 64-bit vector actually exists */ | ||
113 | |||
114 | if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) { | ||
115 | return_ACPI_STATUS(AE_NOT_EXIST); | ||
116 | } | ||
117 | |||
118 | /* Clear 32-bit vector, set the 64-bit X_ vector */ | ||
119 | |||
120 | acpi_gbl_FACS->firmware_waking_vector = 0; | ||
121 | acpi_gbl_FACS->xfirmware_waking_vector = physical_address; | ||
122 | |||
123 | return_ACPI_STATUS(AE_OK); | ||
124 | } | ||
125 | |||
126 | ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64) | ||
127 | |||
128 | /******************************************************************************* | ||
129 | * | ||
130 | * FUNCTION: acpi_enter_sleep_state_prep | ||
131 | * | ||
132 | * PARAMETERS: sleep_state - Which sleep state to enter | ||
133 | * | ||
134 | * RETURN: Status | ||
135 | * | ||
136 | * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) | ||
137 | * This function must execute with interrupts enabled. | ||
138 | * We break sleeping into 2 stages so that OSPM can handle | ||
139 | * various OS-specific tasks between the two steps. | ||
140 | * | ||
141 | ******************************************************************************/ | ||
142 | acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) | ||
143 | { | ||
144 | acpi_status status; | ||
145 | struct acpi_object_list arg_list; | ||
146 | union acpi_object arg; | ||
147 | |||
148 | ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep); | ||
149 | |||
150 | /* | ||
151 | * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. | ||
152 | */ | ||
153 | status = acpi_get_sleep_type_data(sleep_state, | ||
154 | &acpi_gbl_sleep_type_a, | ||
155 | &acpi_gbl_sleep_type_b); | ||
156 | if (ACPI_FAILURE(status)) { | ||
157 | return_ACPI_STATUS(status); | ||
158 | } | ||
159 | |||
160 | /* Setup parameter object */ | ||
161 | |||
162 | arg_list.count = 1; | ||
163 | arg_list.pointer = &arg; | ||
164 | |||
165 | arg.type = ACPI_TYPE_INTEGER; | ||
166 | arg.integer.value = sleep_state; | ||
167 | |||
168 | /* Run the _PTS method */ | ||
169 | |||
170 | status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL); | ||
171 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
172 | return_ACPI_STATUS(status); | ||
173 | } | ||
174 | |||
175 | /* Setup the argument to _SST */ | ||
176 | |||
177 | switch (sleep_state) { | ||
178 | case ACPI_STATE_S0: | ||
179 | arg.integer.value = ACPI_SST_WORKING; | ||
180 | break; | ||
181 | |||
182 | case ACPI_STATE_S1: | ||
183 | case ACPI_STATE_S2: | ||
184 | case ACPI_STATE_S3: | ||
185 | arg.integer.value = ACPI_SST_SLEEPING; | ||
186 | break; | ||
187 | |||
188 | case ACPI_STATE_S4: | ||
189 | arg.integer.value = ACPI_SST_SLEEP_CONTEXT; | ||
190 | break; | ||
191 | |||
192 | default: | ||
193 | arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */ | ||
194 | break; | ||
195 | } | ||
196 | |||
197 | /* | ||
198 | * Set the system indicators to show the desired sleep state. | ||
199 | * _SST is an optional method (return no error if not found) | ||
200 | */ | ||
201 | status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); | ||
202 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
203 | ACPI_EXCEPTION((AE_INFO, status, | ||
204 | "While executing method _SST")); | ||
205 | } | ||
206 | |||
207 | return_ACPI_STATUS(AE_OK); | ||
208 | } | ||
209 | |||
210 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) | ||
211 | |||
212 | /******************************************************************************* | ||
213 | * | ||
214 | * FUNCTION: acpi_enter_sleep_state | ||
215 | * | ||
216 | * PARAMETERS: sleep_state - Which sleep state to enter | ||
217 | * | ||
218 | * RETURN: Status | ||
219 | * | ||
220 | * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231) | ||
221 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED | ||
222 | * | ||
223 | ******************************************************************************/ | ||
224 | acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) | ||
225 | { | ||
226 | u32 PM1Acontrol; | ||
227 | u32 PM1Bcontrol; | ||
228 | struct acpi_bit_register_info *sleep_type_reg_info; | ||
229 | struct acpi_bit_register_info *sleep_enable_reg_info; | ||
230 | u32 in_value; | ||
231 | struct acpi_object_list arg_list; | ||
232 | union acpi_object arg; | ||
233 | acpi_status status; | ||
234 | |||
235 | ACPI_FUNCTION_TRACE(acpi_enter_sleep_state); | ||
236 | |||
237 | if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || | ||
238 | (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { | ||
239 | ACPI_ERROR((AE_INFO, "Sleep values out of range: A=%X B=%X", | ||
240 | acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); | ||
241 | return_ACPI_STATUS(AE_AML_OPERAND_VALUE); | ||
242 | } | ||
243 | |||
244 | sleep_type_reg_info = | ||
245 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); | ||
246 | sleep_enable_reg_info = | ||
247 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); | ||
248 | |||
249 | /* Clear wake status */ | ||
250 | |||
251 | status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); | ||
252 | if (ACPI_FAILURE(status)) { | ||
253 | return_ACPI_STATUS(status); | ||
254 | } | ||
255 | |||
256 | /* Clear all fixed and general purpose status bits */ | ||
257 | |||
258 | status = acpi_hw_clear_acpi_status(); | ||
259 | if (ACPI_FAILURE(status)) { | ||
260 | return_ACPI_STATUS(status); | ||
261 | } | ||
262 | |||
263 | /* | ||
264 | * 1) Disable/Clear all GPEs | ||
265 | * 2) Enable all wakeup GPEs | ||
266 | */ | ||
267 | status = acpi_hw_disable_all_gpes(); | ||
268 | if (ACPI_FAILURE(status)) { | ||
269 | return_ACPI_STATUS(status); | ||
270 | } | ||
271 | acpi_gbl_system_awake_and_running = FALSE; | ||
272 | |||
273 | status = acpi_hw_enable_all_wakeup_gpes(); | ||
274 | if (ACPI_FAILURE(status)) { | ||
275 | return_ACPI_STATUS(status); | ||
276 | } | ||
277 | |||
278 | /* Execute the _GTS method */ | ||
279 | |||
280 | arg_list.count = 1; | ||
281 | arg_list.pointer = &arg; | ||
282 | arg.type = ACPI_TYPE_INTEGER; | ||
283 | arg.integer.value = sleep_state; | ||
284 | |||
285 | status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL); | ||
286 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
287 | return_ACPI_STATUS(status); | ||
288 | } | ||
289 | |||
290 | /* Get current value of PM1A control */ | ||
291 | |||
292 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); | ||
293 | if (ACPI_FAILURE(status)) { | ||
294 | return_ACPI_STATUS(status); | ||
295 | } | ||
296 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, | ||
297 | "Entering sleep state [S%d]\n", sleep_state)); | ||
298 | |||
299 | /* Clear SLP_EN and SLP_TYP fields */ | ||
300 | |||
301 | PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | | ||
302 | sleep_enable_reg_info->access_bit_mask); | ||
303 | PM1Bcontrol = PM1Acontrol; | ||
304 | |||
305 | /* Insert SLP_TYP bits */ | ||
306 | |||
307 | PM1Acontrol |= | ||
308 | (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); | ||
309 | PM1Bcontrol |= | ||
310 | (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); | ||
311 | |||
312 | /* | ||
313 | * We split the writes of SLP_TYP and SLP_EN to workaround | ||
314 | * poorly implemented hardware. | ||
315 | */ | ||
316 | |||
317 | /* Write #1: fill in SLP_TYP data */ | ||
318 | |||
319 | status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, | ||
320 | PM1Acontrol); | ||
321 | if (ACPI_FAILURE(status)) { | ||
322 | return_ACPI_STATUS(status); | ||
323 | } | ||
324 | |||
325 | status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, | ||
326 | PM1Bcontrol); | ||
327 | if (ACPI_FAILURE(status)) { | ||
328 | return_ACPI_STATUS(status); | ||
329 | } | ||
330 | |||
331 | /* Insert SLP_ENABLE bit */ | ||
332 | |||
333 | PM1Acontrol |= sleep_enable_reg_info->access_bit_mask; | ||
334 | PM1Bcontrol |= sleep_enable_reg_info->access_bit_mask; | ||
335 | |||
336 | /* Write #2: SLP_TYP + SLP_EN */ | ||
337 | |||
338 | ACPI_FLUSH_CPU_CACHE(); | ||
339 | |||
340 | status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, | ||
341 | PM1Acontrol); | ||
342 | if (ACPI_FAILURE(status)) { | ||
343 | return_ACPI_STATUS(status); | ||
344 | } | ||
345 | |||
346 | status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, | ||
347 | PM1Bcontrol); | ||
348 | if (ACPI_FAILURE(status)) { | ||
349 | return_ACPI_STATUS(status); | ||
350 | } | ||
351 | |||
352 | if (sleep_state > ACPI_STATE_S3) { | ||
353 | /* | ||
354 | * We wanted to sleep > S3, but it didn't happen (by virtue of the | ||
355 | * fact that we are still executing!) | ||
356 | * | ||
357 | * Wait ten seconds, then try again. This is to get S4/S5 to work on | ||
358 | * all machines. | ||
359 | * | ||
360 | * We wait so long to allow chipsets that poll this reg very slowly to | ||
361 | * still read the right value. Ideally, this block would go | ||
362 | * away entirely. | ||
363 | */ | ||
364 | acpi_os_stall(10000000); | ||
365 | |||
366 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, | ||
367 | sleep_enable_reg_info-> | ||
368 | access_bit_mask); | ||
369 | if (ACPI_FAILURE(status)) { | ||
370 | return_ACPI_STATUS(status); | ||
371 | } | ||
372 | } | ||
373 | |||
374 | /* Wait until we enter sleep state */ | ||
375 | |||
376 | do { | ||
377 | status = acpi_get_register_unlocked(ACPI_BITREG_WAKE_STATUS, | ||
378 | &in_value); | ||
379 | if (ACPI_FAILURE(status)) { | ||
380 | return_ACPI_STATUS(status); | ||
381 | } | ||
382 | |||
383 | /* Spin until we wake */ | ||
384 | |||
385 | } while (!in_value); | ||
386 | |||
387 | return_ACPI_STATUS(AE_OK); | ||
388 | } | ||
389 | |||
390 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state) | ||
391 | |||
392 | /******************************************************************************* | ||
393 | * | ||
394 | * FUNCTION: acpi_enter_sleep_state_s4bios | ||
395 | * | ||
396 | * PARAMETERS: None | ||
397 | * | ||
398 | * RETURN: Status | ||
399 | * | ||
400 | * DESCRIPTION: Perform a S4 bios request. | ||
401 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED | ||
402 | * | ||
403 | ******************************************************************************/ | ||
404 | acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) | ||
405 | { | ||
406 | u32 in_value; | ||
407 | acpi_status status; | ||
408 | |||
409 | ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios); | ||
410 | |||
411 | status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); | ||
412 | if (ACPI_FAILURE(status)) { | ||
413 | return_ACPI_STATUS(status); | ||
414 | } | ||
415 | |||
416 | status = acpi_hw_clear_acpi_status(); | ||
417 | if (ACPI_FAILURE(status)) { | ||
418 | return_ACPI_STATUS(status); | ||
419 | } | ||
420 | |||
421 | /* | ||
422 | * 1) Disable/Clear all GPEs | ||
423 | * 2) Enable all wakeup GPEs | ||
424 | */ | ||
425 | status = acpi_hw_disable_all_gpes(); | ||
426 | if (ACPI_FAILURE(status)) { | ||
427 | return_ACPI_STATUS(status); | ||
428 | } | ||
429 | acpi_gbl_system_awake_and_running = FALSE; | ||
430 | |||
431 | status = acpi_hw_enable_all_wakeup_gpes(); | ||
432 | if (ACPI_FAILURE(status)) { | ||
433 | return_ACPI_STATUS(status); | ||
434 | } | ||
435 | |||
436 | ACPI_FLUSH_CPU_CACHE(); | ||
437 | |||
438 | status = acpi_os_write_port(acpi_gbl_FADT.smi_command, | ||
439 | (u32) acpi_gbl_FADT.S4bios_request, 8); | ||
440 | |||
441 | do { | ||
442 | acpi_os_stall(1000); | ||
443 | status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value); | ||
444 | if (ACPI_FAILURE(status)) { | ||
445 | return_ACPI_STATUS(status); | ||
446 | } | ||
447 | } while (!in_value); | ||
448 | |||
449 | return_ACPI_STATUS(AE_OK); | ||
450 | } | ||
451 | |||
452 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios) | ||
453 | |||
454 | /******************************************************************************* | ||
455 | * | ||
456 | * FUNCTION: acpi_leave_sleep_state_prep | ||
457 | * | ||
458 | * PARAMETERS: sleep_state - Which sleep state we are exiting | ||
459 | * | ||
460 | * RETURN: Status | ||
461 | * | ||
462 | * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a | ||
463 | * sleep. | ||
464 | * Called with interrupts DISABLED. | ||
465 | * | ||
466 | ******************************************************************************/ | ||
467 | acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) | ||
468 | { | ||
469 | struct acpi_object_list arg_list; | ||
470 | union acpi_object arg; | ||
471 | acpi_status status; | ||
472 | struct acpi_bit_register_info *sleep_type_reg_info; | ||
473 | struct acpi_bit_register_info *sleep_enable_reg_info; | ||
474 | u32 PM1Acontrol; | ||
475 | u32 PM1Bcontrol; | ||
476 | |||
477 | ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); | ||
478 | |||
479 | /* | ||
480 | * Set SLP_TYPE and SLP_EN to state S0. | ||
481 | * This is unclear from the ACPI Spec, but it is required | ||
482 | * by some machines. | ||
483 | */ | ||
484 | status = acpi_get_sleep_type_data(ACPI_STATE_S0, | ||
485 | &acpi_gbl_sleep_type_a, | ||
486 | &acpi_gbl_sleep_type_b); | ||
487 | if (ACPI_SUCCESS(status)) { | ||
488 | sleep_type_reg_info = | ||
489 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); | ||
490 | sleep_enable_reg_info = | ||
491 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); | ||
492 | |||
493 | /* Get current value of PM1A control */ | ||
494 | |||
495 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, | ||
496 | &PM1Acontrol); | ||
497 | if (ACPI_SUCCESS(status)) { | ||
498 | |||
499 | /* Clear SLP_EN and SLP_TYP fields */ | ||
500 | |||
501 | PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | | ||
502 | sleep_enable_reg_info-> | ||
503 | access_bit_mask); | ||
504 | PM1Bcontrol = PM1Acontrol; | ||
505 | |||
506 | /* Insert SLP_TYP bits */ | ||
507 | |||
508 | PM1Acontrol |= | ||
509 | (acpi_gbl_sleep_type_a << sleep_type_reg_info-> | ||
510 | bit_position); | ||
511 | PM1Bcontrol |= | ||
512 | (acpi_gbl_sleep_type_b << sleep_type_reg_info-> | ||
513 | bit_position); | ||
514 | |||
515 | /* Just ignore any errors */ | ||
516 | |||
517 | (void)acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, | ||
518 | PM1Acontrol); | ||
519 | (void)acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, | ||
520 | PM1Bcontrol); | ||
521 | } | ||
522 | } | ||
523 | |||
524 | /* Execute the _BFS method */ | ||
525 | |||
526 | arg_list.count = 1; | ||
527 | arg_list.pointer = &arg; | ||
528 | arg.type = ACPI_TYPE_INTEGER; | ||
529 | arg.integer.value = sleep_state; | ||
530 | |||
531 | status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); | ||
532 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
533 | ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS")); | ||
534 | } | ||
535 | |||
536 | return_ACPI_STATUS(status); | ||
537 | } | ||
538 | |||
539 | /******************************************************************************* | ||
540 | * | ||
541 | * FUNCTION: acpi_leave_sleep_state | ||
542 | * | ||
543 | * PARAMETERS: sleep_state - Which sleep state we just exited | ||
544 | * | ||
545 | * RETURN: Status | ||
546 | * | ||
547 | * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep | ||
548 | * Called with interrupts ENABLED. | ||
549 | * | ||
550 | ******************************************************************************/ | ||
551 | acpi_status acpi_leave_sleep_state(u8 sleep_state) | ||
552 | { | ||
553 | struct acpi_object_list arg_list; | ||
554 | union acpi_object arg; | ||
555 | acpi_status status; | ||
556 | |||
557 | ACPI_FUNCTION_TRACE(acpi_leave_sleep_state); | ||
558 | |||
559 | /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */ | ||
560 | |||
561 | acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID; | ||
562 | |||
563 | /* Setup parameter object */ | ||
564 | |||
565 | arg_list.count = 1; | ||
566 | arg_list.pointer = &arg; | ||
567 | arg.type = ACPI_TYPE_INTEGER; | ||
568 | |||
569 | /* Ignore any errors from these methods */ | ||
570 | |||
571 | arg.integer.value = ACPI_SST_WAKING; | ||
572 | status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); | ||
573 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
574 | ACPI_EXCEPTION((AE_INFO, status, "During Method _SST")); | ||
575 | } | ||
576 | |||
577 | /* | ||
578 | * GPEs must be enabled before _WAK is called as GPEs | ||
579 | * might get fired there | ||
580 | * | ||
581 | * Restore the GPEs: | ||
582 | * 1) Disable/Clear all GPEs | ||
583 | * 2) Enable all runtime GPEs | ||
584 | */ | ||
585 | status = acpi_hw_disable_all_gpes(); | ||
586 | if (ACPI_FAILURE(status)) { | ||
587 | return_ACPI_STATUS(status); | ||
588 | } | ||
589 | status = acpi_hw_enable_all_runtime_gpes(); | ||
590 | if (ACPI_FAILURE(status)) { | ||
591 | return_ACPI_STATUS(status); | ||
592 | } | ||
593 | |||
594 | arg.integer.value = sleep_state; | ||
595 | status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); | ||
596 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
597 | ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK")); | ||
598 | } | ||
599 | /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ | ||
600 | |||
601 | /* | ||
602 | * Some BIOSes assume that WAK_STS will be cleared on resume and use | ||
603 | * it to determine whether the system is rebooting or resuming. Clear | ||
604 | * it for compatibility. | ||
605 | */ | ||
606 | acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); | ||
607 | |||
608 | acpi_gbl_system_awake_and_running = TRUE; | ||
609 | |||
610 | /* Enable power button */ | ||
611 | |||
612 | (void) | ||
613 | acpi_set_register(acpi_gbl_fixed_event_info | ||
614 | [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1); | ||
615 | |||
616 | (void) | ||
617 | acpi_set_register(acpi_gbl_fixed_event_info | ||
618 | [ACPI_EVENT_POWER_BUTTON].status_register_id, 1); | ||
619 | |||
620 | arg.integer.value = ACPI_SST_WORKING; | ||
621 | status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); | ||
622 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | ||
623 | ACPI_EXCEPTION((AE_INFO, status, "During Method _SST")); | ||
624 | } | ||
625 | |||
626 | return_ACPI_STATUS(status); | ||
627 | } | ||
628 | |||
629 | ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state) | ||
diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c deleted file mode 100644 index d1eac2aad728..000000000000 --- a/drivers/acpi/hardware/hwtimer.c +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | |||
2 | /****************************************************************************** | ||
3 | * | ||
4 | * Name: hwtimer.c - ACPI Power Management Timer Interface | ||
5 | * | ||
6 | *****************************************************************************/ | ||
7 | |||
8 | /* | ||
9 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
10 | * All rights reserved. | ||
11 | * | ||
12 | * Redistribution and use in source and binary forms, with or without | ||
13 | * modification, are permitted provided that the following conditions | ||
14 | * are met: | ||
15 | * 1. Redistributions of source code must retain the above copyright | ||
16 | * notice, this list of conditions, and the following disclaimer, | ||
17 | * without modification. | ||
18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
19 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
20 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
21 | * including a substantially similar Disclaimer requirement for further | ||
22 | * binary redistribution. | ||
23 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
24 | * of any contributors may be used to endorse or promote products derived | ||
25 | * from this software without specific prior written permission. | ||
26 | * | ||
27 | * Alternatively, this software may be distributed under the terms of the | ||
28 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
29 | * Software Foundation. | ||
30 | * | ||
31 | * NO WARRANTY | ||
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
42 | * POSSIBILITY OF SUCH DAMAGES. | ||
43 | */ | ||
44 | |||
45 | #include <acpi/acpi.h> | ||
46 | #include <acpi/accommon.h> | ||
47 | |||
48 | #define _COMPONENT ACPI_HARDWARE | ||
49 | ACPI_MODULE_NAME("hwtimer") | ||
50 | |||
51 | /****************************************************************************** | ||
52 | * | ||
53 | * FUNCTION: acpi_get_timer_resolution | ||
54 | * | ||
55 | * PARAMETERS: Resolution - Where the resolution is returned | ||
56 | * | ||
57 | * RETURN: Status and timer resolution | ||
58 | * | ||
59 | * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits). | ||
60 | * | ||
61 | ******************************************************************************/ | ||
62 | acpi_status acpi_get_timer_resolution(u32 * resolution) | ||
63 | { | ||
64 | ACPI_FUNCTION_TRACE(acpi_get_timer_resolution); | ||
65 | |||
66 | if (!resolution) { | ||
67 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
68 | } | ||
69 | |||
70 | if ((acpi_gbl_FADT.flags & ACPI_FADT_32BIT_TIMER) == 0) { | ||
71 | *resolution = 24; | ||
72 | } else { | ||
73 | *resolution = 32; | ||
74 | } | ||
75 | |||
76 | return_ACPI_STATUS(AE_OK); | ||
77 | } | ||
78 | |||
79 | ACPI_EXPORT_SYMBOL(acpi_get_timer_resolution) | ||
80 | |||
81 | /****************************************************************************** | ||
82 | * | ||
83 | * FUNCTION: acpi_get_timer | ||
84 | * | ||
85 | * PARAMETERS: Ticks - Where the timer value is returned | ||
86 | * | ||
87 | * RETURN: Status and current timer value (ticks) | ||
88 | * | ||
89 | * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks). | ||
90 | * | ||
91 | ******************************************************************************/ | ||
92 | acpi_status acpi_get_timer(u32 * ticks) | ||
93 | { | ||
94 | acpi_status status; | ||
95 | |||
96 | ACPI_FUNCTION_TRACE(acpi_get_timer); | ||
97 | |||
98 | if (!ticks) { | ||
99 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
100 | } | ||
101 | |||
102 | status = | ||
103 | acpi_hw_low_level_read(32, ticks, &acpi_gbl_FADT.xpm_timer_block); | ||
104 | |||
105 | return_ACPI_STATUS(status); | ||
106 | } | ||
107 | |||
108 | ACPI_EXPORT_SYMBOL(acpi_get_timer) | ||
109 | |||
110 | /****************************************************************************** | ||
111 | * | ||
112 | * FUNCTION: acpi_get_timer_duration | ||
113 | * | ||
114 | * PARAMETERS: start_ticks - Starting timestamp | ||
115 | * end_ticks - End timestamp | ||
116 | * time_elapsed - Where the elapsed time is returned | ||
117 | * | ||
118 | * RETURN: Status and time_elapsed | ||
119 | * | ||
120 | * DESCRIPTION: Computes the time elapsed (in microseconds) between two | ||
121 | * PM Timer time stamps, taking into account the possibility of | ||
122 | * rollovers, the timer resolution, and timer frequency. | ||
123 | * | ||
124 | * The PM Timer's clock ticks at roughly 3.6 times per | ||
125 | * _microsecond_, and its clock continues through Cx state | ||
126 | * transitions (unlike many CPU timestamp counters) -- making it | ||
127 | * a versatile and accurate timer. | ||
128 | * | ||
129 | * Note that this function accommodates only a single timer | ||
130 | * rollover. Thus for 24-bit timers, this function should only | ||
131 | * be used for calculating durations less than ~4.6 seconds | ||
132 | * (~20 minutes for 32-bit timers) -- calculations below: | ||
133 | * | ||
134 | * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec | ||
135 | * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes | ||
136 | * | ||
137 | ******************************************************************************/ | ||
138 | acpi_status | ||
139 | acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed) | ||
140 | { | ||
141 | acpi_status status; | ||
142 | u32 delta_ticks; | ||
143 | acpi_integer quotient; | ||
144 | |||
145 | ACPI_FUNCTION_TRACE(acpi_get_timer_duration); | ||
146 | |||
147 | if (!time_elapsed) { | ||
148 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
149 | } | ||
150 | |||
151 | /* | ||
152 | * Compute Tick Delta: | ||
153 | * Handle (max one) timer rollovers on 24-bit versus 32-bit timers. | ||
154 | */ | ||
155 | if (start_ticks < end_ticks) { | ||
156 | delta_ticks = end_ticks - start_ticks; | ||
157 | } else if (start_ticks > end_ticks) { | ||
158 | if ((acpi_gbl_FADT.flags & ACPI_FADT_32BIT_TIMER) == 0) { | ||
159 | |||
160 | /* 24-bit Timer */ | ||
161 | |||
162 | delta_ticks = | ||
163 | (((0x00FFFFFF - start_ticks) + | ||
164 | end_ticks) & 0x00FFFFFF); | ||
165 | } else { | ||
166 | /* 32-bit Timer */ | ||
167 | |||
168 | delta_ticks = (0xFFFFFFFF - start_ticks) + end_ticks; | ||
169 | } | ||
170 | } else { /* start_ticks == end_ticks */ | ||
171 | |||
172 | *time_elapsed = 0; | ||
173 | return_ACPI_STATUS(AE_OK); | ||
174 | } | ||
175 | |||
176 | /* | ||
177 | * Compute Duration (Requires a 64-bit multiply and divide): | ||
178 | * | ||
179 | * time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY; | ||
180 | */ | ||
181 | status = acpi_ut_short_divide(((u64) delta_ticks) * 1000000, | ||
182 | PM_TIMER_FREQUENCY, "ient, NULL); | ||
183 | |||
184 | *time_elapsed = (u32) quotient; | ||
185 | return_ACPI_STATUS(status); | ||
186 | } | ||
187 | |||
188 | ACPI_EXPORT_SYMBOL(acpi_get_timer_duration) | ||
diff --git a/drivers/acpi/hardware/hwxface.c b/drivers/acpi/hardware/hwxface.c deleted file mode 100644 index a4456fc9462d..000000000000 --- a/drivers/acpi/hardware/hwxface.c +++ /dev/null | |||
@@ -1,593 +0,0 @@ | |||
1 | |||
2 | /****************************************************************************** | ||
3 | * | ||
4 | * Module Name: hwxface - Public ACPICA hardware interfaces | ||
5 | * | ||
6 | *****************************************************************************/ | ||
7 | |||
8 | /* | ||
9 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
10 | * All rights reserved. | ||
11 | * | ||
12 | * Redistribution and use in source and binary forms, with or without | ||
13 | * modification, are permitted provided that the following conditions | ||
14 | * are met: | ||
15 | * 1. Redistributions of source code must retain the above copyright | ||
16 | * notice, this list of conditions, and the following disclaimer, | ||
17 | * without modification. | ||
18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
19 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
20 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
21 | * including a substantially similar Disclaimer requirement for further | ||
22 | * binary redistribution. | ||
23 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
24 | * of any contributors may be used to endorse or promote products derived | ||
25 | * from this software without specific prior written permission. | ||
26 | * | ||
27 | * Alternatively, this software may be distributed under the terms of the | ||
28 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
29 | * Software Foundation. | ||
30 | * | ||
31 | * NO WARRANTY | ||
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
42 | * POSSIBILITY OF SUCH DAMAGES. | ||
43 | */ | ||
44 | |||
45 | #include <acpi/acpi.h> | ||
46 | #include <acpi/accommon.h> | ||
47 | #include <acpi/acnamesp.h> | ||
48 | |||
49 | #define _COMPONENT ACPI_HARDWARE | ||
50 | ACPI_MODULE_NAME("hwxface") | ||
51 | |||
52 | /****************************************************************************** | ||
53 | * | ||
54 | * FUNCTION: acpi_reset | ||
55 | * | ||
56 | * PARAMETERS: None | ||
57 | * | ||
58 | * RETURN: Status | ||
59 | * | ||
60 | * DESCRIPTION: Set reset register in memory or IO space. Note: Does not | ||
61 | * support reset register in PCI config space, this must be | ||
62 | * handled separately. | ||
63 | * | ||
64 | ******************************************************************************/ | ||
65 | acpi_status acpi_reset(void) | ||
66 | { | ||
67 | struct acpi_generic_address *reset_reg; | ||
68 | acpi_status status; | ||
69 | |||
70 | ACPI_FUNCTION_TRACE(acpi_reset); | ||
71 | |||
72 | reset_reg = &acpi_gbl_FADT.reset_register; | ||
73 | |||
74 | /* Check if the reset register is supported */ | ||
75 | |||
76 | if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) || | ||
77 | !reset_reg->address) { | ||
78 | return_ACPI_STATUS(AE_NOT_EXIST); | ||
79 | } | ||
80 | |||
81 | /* Write the reset value to the reset register */ | ||
82 | |||
83 | status = acpi_write(acpi_gbl_FADT.reset_value, reset_reg); | ||
84 | return_ACPI_STATUS(status); | ||
85 | } | ||
86 | |||
87 | ACPI_EXPORT_SYMBOL(acpi_reset) | ||
88 | |||
89 | /****************************************************************************** | ||
90 | * | ||
91 | * FUNCTION: acpi_read | ||
92 | * | ||
93 | * PARAMETERS: Value - Where the value is returned | ||
94 | * Reg - GAS register structure | ||
95 | * | ||
96 | * RETURN: Status | ||
97 | * | ||
98 | * DESCRIPTION: Read from either memory or IO space. | ||
99 | * | ||
100 | ******************************************************************************/ | ||
101 | acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg) | ||
102 | { | ||
103 | u32 width; | ||
104 | u64 address; | ||
105 | acpi_status status; | ||
106 | |||
107 | ACPI_FUNCTION_NAME(acpi_read); | ||
108 | |||
109 | /* | ||
110 | * Must have a valid pointer to a GAS structure, and | ||
111 | * a non-zero address within. However, don't return an error | ||
112 | * because the PM1A/B code must not fail if B isn't present. | ||
113 | */ | ||
114 | if (!reg) { | ||
115 | return (AE_OK); | ||
116 | } | ||
117 | |||
118 | /* Get a local copy of the address. Handles possible alignment issues */ | ||
119 | |||
120 | ACPI_MOVE_64_TO_64(&address, ®->address); | ||
121 | if (!address) { | ||
122 | return (AE_OK); | ||
123 | } | ||
124 | |||
125 | /* Supported widths are 8/16/32 */ | ||
126 | |||
127 | width = reg->bit_width; | ||
128 | if ((width != 8) && (width != 16) && (width != 32)) { | ||
129 | return (AE_SUPPORT); | ||
130 | } | ||
131 | |||
132 | /* Initialize entire 32-bit return value to zero */ | ||
133 | |||
134 | *value = 0; | ||
135 | |||
136 | /* | ||
137 | * Two address spaces supported: Memory or IO. | ||
138 | * PCI_Config is not supported here because the GAS struct is insufficient | ||
139 | */ | ||
140 | switch (reg->space_id) { | ||
141 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | ||
142 | |||
143 | status = acpi_os_read_memory((acpi_physical_address) address, | ||
144 | value, width); | ||
145 | break; | ||
146 | |||
147 | case ACPI_ADR_SPACE_SYSTEM_IO: | ||
148 | |||
149 | status = | ||
150 | acpi_os_read_port((acpi_io_address) address, value, width); | ||
151 | break; | ||
152 | |||
153 | default: | ||
154 | ACPI_ERROR((AE_INFO, | ||
155 | "Unsupported address space: %X", reg->space_id)); | ||
156 | return (AE_BAD_PARAMETER); | ||
157 | } | ||
158 | |||
159 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
160 | "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", | ||
161 | *value, width, ACPI_FORMAT_UINT64(address), | ||
162 | acpi_ut_get_region_name(reg->space_id))); | ||
163 | |||
164 | return (status); | ||
165 | } | ||
166 | |||
167 | ACPI_EXPORT_SYMBOL(acpi_read) | ||
168 | |||
169 | /****************************************************************************** | ||
170 | * | ||
171 | * FUNCTION: acpi_write | ||
172 | * | ||
173 | * PARAMETERS: Value - To be written | ||
174 | * Reg - GAS register structure | ||
175 | * | ||
176 | * RETURN: Status | ||
177 | * | ||
178 | * DESCRIPTION: Write to either memory or IO space. | ||
179 | * | ||
180 | ******************************************************************************/ | ||
181 | acpi_status acpi_write(u32 value, struct acpi_generic_address *reg) | ||
182 | { | ||
183 | u32 width; | ||
184 | u64 address; | ||
185 | acpi_status status; | ||
186 | |||
187 | ACPI_FUNCTION_NAME(acpi_write); | ||
188 | |||
189 | /* | ||
190 | * Must have a valid pointer to a GAS structure, and | ||
191 | * a non-zero address within. However, don't return an error | ||
192 | * because the PM1A/B code must not fail if B isn't present. | ||
193 | */ | ||
194 | if (!reg) { | ||
195 | return (AE_OK); | ||
196 | } | ||
197 | |||
198 | /* Get a local copy of the address. Handles possible alignment issues */ | ||
199 | |||
200 | ACPI_MOVE_64_TO_64(&address, ®->address); | ||
201 | if (!address) { | ||
202 | return (AE_OK); | ||
203 | } | ||
204 | |||
205 | /* Supported widths are 8/16/32 */ | ||
206 | |||
207 | width = reg->bit_width; | ||
208 | if ((width != 8) && (width != 16) && (width != 32)) { | ||
209 | return (AE_SUPPORT); | ||
210 | } | ||
211 | |||
212 | /* | ||
213 | * Two address spaces supported: Memory or IO. | ||
214 | * PCI_Config is not supported here because the GAS struct is insufficient | ||
215 | */ | ||
216 | switch (reg->space_id) { | ||
217 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | ||
218 | |||
219 | status = acpi_os_write_memory((acpi_physical_address) address, | ||
220 | value, width); | ||
221 | break; | ||
222 | |||
223 | case ACPI_ADR_SPACE_SYSTEM_IO: | ||
224 | |||
225 | status = acpi_os_write_port((acpi_io_address) address, value, | ||
226 | width); | ||
227 | break; | ||
228 | |||
229 | default: | ||
230 | ACPI_ERROR((AE_INFO, | ||
231 | "Unsupported address space: %X", reg->space_id)); | ||
232 | return (AE_BAD_PARAMETER); | ||
233 | } | ||
234 | |||
235 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
236 | "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", | ||
237 | value, width, ACPI_FORMAT_UINT64(address), | ||
238 | acpi_ut_get_region_name(reg->space_id))); | ||
239 | |||
240 | return (status); | ||
241 | } | ||
242 | |||
243 | ACPI_EXPORT_SYMBOL(acpi_write) | ||
244 | |||
245 | /******************************************************************************* | ||
246 | * | ||
247 | * FUNCTION: acpi_get_register_unlocked | ||
248 | * | ||
249 | * PARAMETERS: register_id - ID of ACPI bit_register to access | ||
250 | * return_value - Value that was read from the register | ||
251 | * | ||
252 | * RETURN: Status and the value read from specified Register. Value | ||
253 | * returned is normalized to bit0 (is shifted all the way right) | ||
254 | * | ||
255 | * DESCRIPTION: ACPI bit_register read function. Does not acquire the HW lock. | ||
256 | * | ||
257 | ******************************************************************************/ | ||
258 | acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value) | ||
259 | { | ||
260 | u32 register_value = 0; | ||
261 | struct acpi_bit_register_info *bit_reg_info; | ||
262 | acpi_status status; | ||
263 | |||
264 | ACPI_FUNCTION_TRACE(acpi_get_register_unlocked); | ||
265 | |||
266 | /* Get the info structure corresponding to the requested ACPI Register */ | ||
267 | |||
268 | bit_reg_info = acpi_hw_get_bit_register_info(register_id); | ||
269 | if (!bit_reg_info) { | ||
270 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
271 | } | ||
272 | |||
273 | /* Read from the register */ | ||
274 | |||
275 | status = acpi_hw_register_read(bit_reg_info->parent_register, | ||
276 | ®ister_value); | ||
277 | |||
278 | if (ACPI_SUCCESS(status)) { | ||
279 | |||
280 | /* Normalize the value that was read */ | ||
281 | |||
282 | register_value = | ||
283 | ((register_value & bit_reg_info->access_bit_mask) | ||
284 | >> bit_reg_info->bit_position); | ||
285 | |||
286 | *return_value = register_value; | ||
287 | |||
288 | ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read value %8.8X register %X\n", | ||
289 | register_value, | ||
290 | bit_reg_info->parent_register)); | ||
291 | } | ||
292 | |||
293 | return_ACPI_STATUS(status); | ||
294 | } | ||
295 | |||
296 | ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked) | ||
297 | |||
298 | /******************************************************************************* | ||
299 | * | ||
300 | * FUNCTION: acpi_get_register | ||
301 | * | ||
302 | * PARAMETERS: register_id - ID of ACPI bit_register to access | ||
303 | * return_value - Value that was read from the register | ||
304 | * | ||
305 | * RETURN: Status and the value read from specified Register. Value | ||
306 | * returned is normalized to bit0 (is shifted all the way right) | ||
307 | * | ||
308 | * DESCRIPTION: ACPI bit_register read function. | ||
309 | * | ||
310 | ******************************************************************************/ | ||
311 | acpi_status acpi_get_register(u32 register_id, u32 *return_value) | ||
312 | { | ||
313 | acpi_status status; | ||
314 | acpi_cpu_flags flags; | ||
315 | |||
316 | flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
317 | status = acpi_get_register_unlocked(register_id, return_value); | ||
318 | acpi_os_release_lock(acpi_gbl_hardware_lock, flags); | ||
319 | |||
320 | return (status); | ||
321 | } | ||
322 | |||
323 | ACPI_EXPORT_SYMBOL(acpi_get_register) | ||
324 | |||
325 | /******************************************************************************* | ||
326 | * | ||
327 | * FUNCTION: acpi_set_register | ||
328 | * | ||
329 | * PARAMETERS: register_id - ID of ACPI bit_register to access | ||
330 | * Value - (only used on write) value to write to the | ||
331 | * Register, NOT pre-normalized to the bit pos | ||
332 | * | ||
333 | * RETURN: Status | ||
334 | * | ||
335 | * DESCRIPTION: ACPI Bit Register write function. | ||
336 | * | ||
337 | ******************************************************************************/ | ||
338 | acpi_status acpi_set_register(u32 register_id, u32 value) | ||
339 | { | ||
340 | u32 register_value = 0; | ||
341 | struct acpi_bit_register_info *bit_reg_info; | ||
342 | acpi_status status; | ||
343 | acpi_cpu_flags lock_flags; | ||
344 | |||
345 | ACPI_FUNCTION_TRACE_U32(acpi_set_register, register_id); | ||
346 | |||
347 | /* Get the info structure corresponding to the requested ACPI Register */ | ||
348 | |||
349 | bit_reg_info = acpi_hw_get_bit_register_info(register_id); | ||
350 | if (!bit_reg_info) { | ||
351 | ACPI_ERROR((AE_INFO, "Bad ACPI HW RegisterId: %X", | ||
352 | register_id)); | ||
353 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
354 | } | ||
355 | |||
356 | lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
357 | |||
358 | /* Always do a register read first so we can insert the new bits */ | ||
359 | |||
360 | status = acpi_hw_register_read(bit_reg_info->parent_register, | ||
361 | ®ister_value); | ||
362 | if (ACPI_FAILURE(status)) { | ||
363 | goto unlock_and_exit; | ||
364 | } | ||
365 | |||
366 | /* | ||
367 | * Decode the Register ID | ||
368 | * Register ID = [Register block ID] | [bit ID] | ||
369 | * | ||
370 | * Check bit ID to fine locate Register offset. | ||
371 | * Check Mask to determine Register offset, and then read-write. | ||
372 | */ | ||
373 | switch (bit_reg_info->parent_register) { | ||
374 | case ACPI_REGISTER_PM1_STATUS: | ||
375 | |||
376 | /* | ||
377 | * Status Registers are different from the rest. Clear by | ||
378 | * writing 1, and writing 0 has no effect. So, the only relevant | ||
379 | * information is the single bit we're interested in, all others should | ||
380 | * be written as 0 so they will be left unchanged. | ||
381 | */ | ||
382 | value = ACPI_REGISTER_PREPARE_BITS(value, | ||
383 | bit_reg_info->bit_position, | ||
384 | bit_reg_info-> | ||
385 | access_bit_mask); | ||
386 | if (value) { | ||
387 | status = | ||
388 | acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, | ||
389 | (u16) value); | ||
390 | register_value = 0; | ||
391 | } | ||
392 | break; | ||
393 | |||
394 | case ACPI_REGISTER_PM1_ENABLE: | ||
395 | |||
396 | ACPI_REGISTER_INSERT_VALUE(register_value, | ||
397 | bit_reg_info->bit_position, | ||
398 | bit_reg_info->access_bit_mask, | ||
399 | value); | ||
400 | |||
401 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_ENABLE, | ||
402 | (u16) register_value); | ||
403 | break; | ||
404 | |||
405 | case ACPI_REGISTER_PM1_CONTROL: | ||
406 | |||
407 | /* | ||
408 | * Write the PM1 Control register. | ||
409 | * Note that at this level, the fact that there are actually TWO | ||
410 | * registers (A and B - and B may not exist) is abstracted. | ||
411 | */ | ||
412 | ACPI_DEBUG_PRINT((ACPI_DB_IO, "PM1 control: Read %X\n", | ||
413 | register_value)); | ||
414 | |||
415 | ACPI_REGISTER_INSERT_VALUE(register_value, | ||
416 | bit_reg_info->bit_position, | ||
417 | bit_reg_info->access_bit_mask, | ||
418 | value); | ||
419 | |||
420 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, | ||
421 | (u16) register_value); | ||
422 | break; | ||
423 | |||
424 | case ACPI_REGISTER_PM2_CONTROL: | ||
425 | |||
426 | status = acpi_hw_register_read(ACPI_REGISTER_PM2_CONTROL, | ||
427 | ®ister_value); | ||
428 | if (ACPI_FAILURE(status)) { | ||
429 | goto unlock_and_exit; | ||
430 | } | ||
431 | |||
432 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
433 | "PM2 control: Read %X from %8.8X%8.8X\n", | ||
434 | register_value, | ||
435 | ACPI_FORMAT_UINT64(acpi_gbl_FADT. | ||
436 | xpm2_control_block. | ||
437 | address))); | ||
438 | |||
439 | ACPI_REGISTER_INSERT_VALUE(register_value, | ||
440 | bit_reg_info->bit_position, | ||
441 | bit_reg_info->access_bit_mask, | ||
442 | value); | ||
443 | |||
444 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
445 | "About to write %4.4X to %8.8X%8.8X\n", | ||
446 | register_value, | ||
447 | ACPI_FORMAT_UINT64(acpi_gbl_FADT. | ||
448 | xpm2_control_block. | ||
449 | address))); | ||
450 | |||
451 | status = acpi_hw_register_write(ACPI_REGISTER_PM2_CONTROL, | ||
452 | (u8) (register_value)); | ||
453 | break; | ||
454 | |||
455 | default: | ||
456 | break; | ||
457 | } | ||
458 | |||
459 | unlock_and_exit: | ||
460 | |||
461 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); | ||
462 | |||
463 | /* Normalize the value that was read */ | ||
464 | |||
465 | ACPI_DEBUG_EXEC(register_value = | ||
466 | ((register_value & bit_reg_info->access_bit_mask) >> | ||
467 | bit_reg_info->bit_position)); | ||
468 | |||
469 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
470 | "Set bits: %8.8X actual %8.8X register %X\n", value, | ||
471 | register_value, bit_reg_info->parent_register)); | ||
472 | return_ACPI_STATUS(status); | ||
473 | } | ||
474 | |||
475 | ACPI_EXPORT_SYMBOL(acpi_set_register) | ||
476 | |||
477 | /******************************************************************************* | ||
478 | * | ||
479 | * FUNCTION: acpi_get_sleep_type_data | ||
480 | * | ||
481 | * PARAMETERS: sleep_state - Numeric sleep state | ||
482 | * *sleep_type_a - Where SLP_TYPa is returned | ||
483 | * *sleep_type_b - Where SLP_TYPb is returned | ||
484 | * | ||
485 | * RETURN: Status - ACPI status | ||
486 | * | ||
487 | * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep | ||
488 | * state. | ||
489 | * | ||
490 | ******************************************************************************/ | ||
491 | acpi_status | ||
492 | acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) | ||
493 | { | ||
494 | acpi_status status = AE_OK; | ||
495 | struct acpi_evaluate_info *info; | ||
496 | |||
497 | ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data); | ||
498 | |||
499 | /* Validate parameters */ | ||
500 | |||
501 | if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) { | ||
502 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
503 | } | ||
504 | |||
505 | /* Allocate the evaluation information block */ | ||
506 | |||
507 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); | ||
508 | if (!info) { | ||
509 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
510 | } | ||
511 | |||
512 | info->pathname = | ||
513 | ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); | ||
514 | |||
515 | /* Evaluate the namespace object containing the values for this state */ | ||
516 | |||
517 | status = acpi_ns_evaluate(info); | ||
518 | if (ACPI_FAILURE(status)) { | ||
519 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
520 | "%s while evaluating SleepState [%s]\n", | ||
521 | acpi_format_exception(status), | ||
522 | info->pathname)); | ||
523 | |||
524 | goto cleanup; | ||
525 | } | ||
526 | |||
527 | /* Must have a return object */ | ||
528 | |||
529 | if (!info->return_object) { | ||
530 | ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", | ||
531 | info->pathname)); | ||
532 | status = AE_NOT_EXIST; | ||
533 | } | ||
534 | |||
535 | /* It must be of type Package */ | ||
536 | |||
537 | else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) { | ||
538 | ACPI_ERROR((AE_INFO, | ||
539 | "Sleep State return object is not a Package")); | ||
540 | status = AE_AML_OPERAND_TYPE; | ||
541 | } | ||
542 | |||
543 | /* | ||
544 | * The package must have at least two elements. NOTE (March 2005): This | ||
545 | * goes against the current ACPI spec which defines this object as a | ||
546 | * package with one encoded DWORD element. However, existing practice | ||
547 | * by BIOS vendors seems to be to have 2 or more elements, at least | ||
548 | * one per sleep type (A/B). | ||
549 | */ | ||
550 | else if (info->return_object->package.count < 2) { | ||
551 | ACPI_ERROR((AE_INFO, | ||
552 | "Sleep State return package does not have at least two elements")); | ||
553 | status = AE_AML_NO_OPERAND; | ||
554 | } | ||
555 | |||
556 | /* The first two elements must both be of type Integer */ | ||
557 | |||
558 | else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0]) | ||
559 | != ACPI_TYPE_INTEGER) || | ||
560 | (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1]) | ||
561 | != ACPI_TYPE_INTEGER)) { | ||
562 | ACPI_ERROR((AE_INFO, | ||
563 | "Sleep State return package elements are not both Integers (%s, %s)", | ||
564 | acpi_ut_get_object_type_name(info->return_object-> | ||
565 | package.elements[0]), | ||
566 | acpi_ut_get_object_type_name(info->return_object-> | ||
567 | package.elements[1]))); | ||
568 | status = AE_AML_OPERAND_TYPE; | ||
569 | } else { | ||
570 | /* Valid _Sx_ package size, type, and value */ | ||
571 | |||
572 | *sleep_type_a = (u8) | ||
573 | (info->return_object->package.elements[0])->integer.value; | ||
574 | *sleep_type_b = (u8) | ||
575 | (info->return_object->package.elements[1])->integer.value; | ||
576 | } | ||
577 | |||
578 | if (ACPI_FAILURE(status)) { | ||
579 | ACPI_EXCEPTION((AE_INFO, status, | ||
580 | "While evaluating SleepState [%s], bad Sleep object %p type %s", | ||
581 | info->pathname, info->return_object, | ||
582 | acpi_ut_get_object_type_name(info-> | ||
583 | return_object))); | ||
584 | } | ||
585 | |||
586 | acpi_ut_remove_reference(info->return_object); | ||
587 | |||
588 | cleanup: | ||
589 | ACPI_FREE(info); | ||
590 | return_ACPI_STATUS(status); | ||
591 | } | ||
592 | |||
593 | ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data) | ||