diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/hardware/Makefile | 2 | ||||
-rw-r--r-- | drivers/acpi/hardware/hwregs.c | 498 | ||||
-rw-r--r-- | drivers/acpi/hardware/hwxface.c | 555 |
3 files changed, 558 insertions, 497 deletions
diff --git a/drivers/acpi/hardware/Makefile b/drivers/acpi/hardware/Makefile index 438ad373b9ad..238fbe513b82 100644 --- a/drivers/acpi/hardware/Makefile +++ b/drivers/acpi/hardware/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for all Linux ACPI interpreter subdirectories | 2 | # Makefile for all Linux ACPI interpreter subdirectories |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := hwacpi.o hwgpe.o hwregs.o hwsleep.o | 5 | obj-y := hwacpi.o hwgpe.o hwregs.o hwsleep.o hwxface.o |
6 | 6 | ||
7 | obj-$(ACPI_FUTURE_USAGE) += hwtimer.o | 7 | obj-$(ACPI_FUTURE_USAGE) += hwtimer.o |
8 | 8 | ||
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index d6d2ec6969f4..981e5db21a3b 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c | |||
@@ -56,7 +56,7 @@ ACPI_MODULE_NAME("hwregs") | |||
56 | * | 56 | * |
57 | * PARAMETERS: None | 57 | * PARAMETERS: None |
58 | * | 58 | * |
59 | * RETURN: None | 59 | * RETURN: Status |
60 | * | 60 | * |
61 | * DESCRIPTION: Clears all fixed and general purpose status bits | 61 | * DESCRIPTION: Clears all fixed and general purpose status bits |
62 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED | 62 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
@@ -102,125 +102,6 @@ acpi_status acpi_hw_clear_acpi_status(void) | |||
102 | 102 | ||
103 | /******************************************************************************* | 103 | /******************************************************************************* |
104 | * | 104 | * |
105 | * FUNCTION: acpi_get_sleep_type_data | ||
106 | * | ||
107 | * PARAMETERS: sleep_state - Numeric sleep state | ||
108 | * *sleep_type_a - Where SLP_TYPa is returned | ||
109 | * *sleep_type_b - Where SLP_TYPb is returned | ||
110 | * | ||
111 | * RETURN: Status - ACPI status | ||
112 | * | ||
113 | * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep | ||
114 | * state. | ||
115 | * | ||
116 | ******************************************************************************/ | ||
117 | |||
118 | acpi_status | ||
119 | acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b) | ||
120 | { | ||
121 | acpi_status status = AE_OK; | ||
122 | struct acpi_evaluate_info *info; | ||
123 | |||
124 | ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data); | ||
125 | |||
126 | /* Validate parameters */ | ||
127 | |||
128 | if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) { | ||
129 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
130 | } | ||
131 | |||
132 | /* Allocate the evaluation information block */ | ||
133 | |||
134 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); | ||
135 | if (!info) { | ||
136 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
137 | } | ||
138 | |||
139 | info->pathname = | ||
140 | ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); | ||
141 | |||
142 | /* Evaluate the namespace object containing the values for this state */ | ||
143 | |||
144 | status = acpi_ns_evaluate(info); | ||
145 | if (ACPI_FAILURE(status)) { | ||
146 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
147 | "%s while evaluating SleepState [%s]\n", | ||
148 | acpi_format_exception(status), | ||
149 | info->pathname)); | ||
150 | |||
151 | goto cleanup; | ||
152 | } | ||
153 | |||
154 | /* Must have a return object */ | ||
155 | |||
156 | if (!info->return_object) { | ||
157 | ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", | ||
158 | info->pathname)); | ||
159 | status = AE_NOT_EXIST; | ||
160 | } | ||
161 | |||
162 | /* It must be of type Package */ | ||
163 | |||
164 | else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) { | ||
165 | ACPI_ERROR((AE_INFO, | ||
166 | "Sleep State return object is not a Package")); | ||
167 | status = AE_AML_OPERAND_TYPE; | ||
168 | } | ||
169 | |||
170 | /* | ||
171 | * The package must have at least two elements. NOTE (March 2005): This | ||
172 | * goes against the current ACPI spec which defines this object as a | ||
173 | * package with one encoded DWORD element. However, existing practice | ||
174 | * by BIOS vendors seems to be to have 2 or more elements, at least | ||
175 | * one per sleep type (A/B). | ||
176 | */ | ||
177 | else if (info->return_object->package.count < 2) { | ||
178 | ACPI_ERROR((AE_INFO, | ||
179 | "Sleep State return package does not have at least two elements")); | ||
180 | status = AE_AML_NO_OPERAND; | ||
181 | } | ||
182 | |||
183 | /* The first two elements must both be of type Integer */ | ||
184 | |||
185 | else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0]) | ||
186 | != ACPI_TYPE_INTEGER) || | ||
187 | (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1]) | ||
188 | != ACPI_TYPE_INTEGER)) { | ||
189 | ACPI_ERROR((AE_INFO, | ||
190 | "Sleep State return package elements are not both Integers (%s, %s)", | ||
191 | acpi_ut_get_object_type_name(info->return_object-> | ||
192 | package.elements[0]), | ||
193 | acpi_ut_get_object_type_name(info->return_object-> | ||
194 | package.elements[1]))); | ||
195 | status = AE_AML_OPERAND_TYPE; | ||
196 | } else { | ||
197 | /* Valid _Sx_ package size, type, and value */ | ||
198 | |||
199 | *sleep_type_a = (u8) | ||
200 | (info->return_object->package.elements[0])->integer.value; | ||
201 | *sleep_type_b = (u8) | ||
202 | (info->return_object->package.elements[1])->integer.value; | ||
203 | } | ||
204 | |||
205 | if (ACPI_FAILURE(status)) { | ||
206 | ACPI_EXCEPTION((AE_INFO, status, | ||
207 | "While evaluating SleepState [%s], bad Sleep object %p type %s", | ||
208 | info->pathname, info->return_object, | ||
209 | acpi_ut_get_object_type_name(info-> | ||
210 | return_object))); | ||
211 | } | ||
212 | |||
213 | acpi_ut_remove_reference(info->return_object); | ||
214 | |||
215 | cleanup: | ||
216 | ACPI_FREE(info); | ||
217 | return_ACPI_STATUS(status); | ||
218 | } | ||
219 | |||
220 | ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data) | ||
221 | |||
222 | /******************************************************************************* | ||
223 | * | ||
224 | * FUNCTION: acpi_hw_get_register_bit_mask | 105 | * FUNCTION: acpi_hw_get_register_bit_mask |
225 | * | 106 | * |
226 | * PARAMETERS: register_id - Index of ACPI Register to access | 107 | * PARAMETERS: register_id - Index of ACPI Register to access |
@@ -230,6 +111,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data) | |||
230 | * DESCRIPTION: Map register_id into a register bitmask. | 111 | * DESCRIPTION: Map register_id into a register bitmask. |
231 | * | 112 | * |
232 | ******************************************************************************/ | 113 | ******************************************************************************/ |
114 | |||
233 | struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) | 115 | struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) |
234 | { | 116 | { |
235 | ACPI_FUNCTION_ENTRY(); | 117 | ACPI_FUNCTION_ENTRY(); |
@@ -243,223 +125,6 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) | |||
243 | return (&acpi_gbl_bit_register_info[register_id]); | 125 | return (&acpi_gbl_bit_register_info[register_id]); |
244 | } | 126 | } |
245 | 127 | ||
246 | ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked) | ||
247 | |||
248 | /******************************************************************************* | ||
249 | * | ||
250 | * FUNCTION: acpi_get_register | ||
251 | * | ||
252 | * PARAMETERS: register_id - ID of ACPI bit_register to access | ||
253 | * return_value - Value that was read from the register | ||
254 | * | ||
255 | * RETURN: Status and the value read from specified Register. Value | ||
256 | * returned is normalized to bit0 (is shifted all the way right) | ||
257 | * | ||
258 | * DESCRIPTION: ACPI bit_register read function. | ||
259 | * | ||
260 | ******************************************************************************/ | ||
261 | |||
262 | acpi_status acpi_get_register_unlocked(u32 register_id, u32 * return_value) | ||
263 | { | ||
264 | u32 register_value = 0; | ||
265 | struct acpi_bit_register_info *bit_reg_info; | ||
266 | acpi_status status; | ||
267 | |||
268 | ACPI_FUNCTION_TRACE(acpi_get_register); | ||
269 | |||
270 | /* Get the info structure corresponding to the requested ACPI Register */ | ||
271 | |||
272 | bit_reg_info = acpi_hw_get_bit_register_info(register_id); | ||
273 | if (!bit_reg_info) { | ||
274 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
275 | } | ||
276 | |||
277 | /* Read from the register */ | ||
278 | |||
279 | status = acpi_hw_register_read(bit_reg_info->parent_register, | ||
280 | ®ister_value); | ||
281 | |||
282 | if (ACPI_SUCCESS(status)) { | ||
283 | |||
284 | /* Normalize the value that was read */ | ||
285 | |||
286 | register_value = | ||
287 | ((register_value & bit_reg_info->access_bit_mask) | ||
288 | >> bit_reg_info->bit_position); | ||
289 | |||
290 | *return_value = register_value; | ||
291 | |||
292 | ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read value %8.8X register %X\n", | ||
293 | register_value, | ||
294 | bit_reg_info->parent_register)); | ||
295 | } | ||
296 | |||
297 | return_ACPI_STATUS(status); | ||
298 | } | ||
299 | |||
300 | acpi_status acpi_get_register(u32 register_id, u32 * return_value) | ||
301 | { | ||
302 | acpi_status status; | ||
303 | acpi_cpu_flags flags; | ||
304 | flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
305 | status = acpi_get_register_unlocked(register_id, return_value); | ||
306 | acpi_os_release_lock(acpi_gbl_hardware_lock, flags); | ||
307 | return status; | ||
308 | } | ||
309 | |||
310 | ACPI_EXPORT_SYMBOL(acpi_get_register) | ||
311 | |||
312 | /******************************************************************************* | ||
313 | * | ||
314 | * FUNCTION: acpi_set_register | ||
315 | * | ||
316 | * PARAMETERS: register_id - ID of ACPI bit_register to access | ||
317 | * Value - (only used on write) value to write to the | ||
318 | * Register, NOT pre-normalized to the bit pos | ||
319 | * | ||
320 | * RETURN: Status | ||
321 | * | ||
322 | * DESCRIPTION: ACPI Bit Register write function. | ||
323 | * | ||
324 | ******************************************************************************/ | ||
325 | acpi_status acpi_set_register(u32 register_id, u32 value) | ||
326 | { | ||
327 | u32 register_value = 0; | ||
328 | struct acpi_bit_register_info *bit_reg_info; | ||
329 | acpi_status status; | ||
330 | acpi_cpu_flags lock_flags; | ||
331 | |||
332 | ACPI_FUNCTION_TRACE_U32(acpi_set_register, register_id); | ||
333 | |||
334 | /* Get the info structure corresponding to the requested ACPI Register */ | ||
335 | |||
336 | bit_reg_info = acpi_hw_get_bit_register_info(register_id); | ||
337 | if (!bit_reg_info) { | ||
338 | ACPI_ERROR((AE_INFO, "Bad ACPI HW RegisterId: %X", | ||
339 | register_id)); | ||
340 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
341 | } | ||
342 | |||
343 | lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
344 | |||
345 | /* Always do a register read first so we can insert the new bits */ | ||
346 | |||
347 | status = acpi_hw_register_read(bit_reg_info->parent_register, | ||
348 | ®ister_value); | ||
349 | if (ACPI_FAILURE(status)) { | ||
350 | goto unlock_and_exit; | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | * Decode the Register ID | ||
355 | * Register ID = [Register block ID] | [bit ID] | ||
356 | * | ||
357 | * Check bit ID to fine locate Register offset. | ||
358 | * Check Mask to determine Register offset, and then read-write. | ||
359 | */ | ||
360 | switch (bit_reg_info->parent_register) { | ||
361 | case ACPI_REGISTER_PM1_STATUS: | ||
362 | |||
363 | /* | ||
364 | * Status Registers are different from the rest. Clear by | ||
365 | * writing 1, and writing 0 has no effect. So, the only relevant | ||
366 | * information is the single bit we're interested in, all others should | ||
367 | * be written as 0 so they will be left unchanged. | ||
368 | */ | ||
369 | value = ACPI_REGISTER_PREPARE_BITS(value, | ||
370 | bit_reg_info->bit_position, | ||
371 | bit_reg_info-> | ||
372 | access_bit_mask); | ||
373 | if (value) { | ||
374 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, | ||
375 | (u16) value); | ||
376 | register_value = 0; | ||
377 | } | ||
378 | break; | ||
379 | |||
380 | case ACPI_REGISTER_PM1_ENABLE: | ||
381 | |||
382 | ACPI_REGISTER_INSERT_VALUE(register_value, | ||
383 | bit_reg_info->bit_position, | ||
384 | bit_reg_info->access_bit_mask, | ||
385 | value); | ||
386 | |||
387 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_ENABLE, | ||
388 | (u16) register_value); | ||
389 | break; | ||
390 | |||
391 | case ACPI_REGISTER_PM1_CONTROL: | ||
392 | |||
393 | /* | ||
394 | * Write the PM1 Control register. | ||
395 | * Note that at this level, the fact that there are actually TWO | ||
396 | * registers (A and B - and B may not exist) is abstracted. | ||
397 | */ | ||
398 | ACPI_DEBUG_PRINT((ACPI_DB_IO, "PM1 control: Read %X\n", | ||
399 | register_value)); | ||
400 | |||
401 | ACPI_REGISTER_INSERT_VALUE(register_value, | ||
402 | bit_reg_info->bit_position, | ||
403 | bit_reg_info->access_bit_mask, | ||
404 | value); | ||
405 | |||
406 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, | ||
407 | (u16) register_value); | ||
408 | break; | ||
409 | |||
410 | case ACPI_REGISTER_PM2_CONTROL: | ||
411 | |||
412 | status = acpi_hw_register_read(ACPI_REGISTER_PM2_CONTROL, | ||
413 | ®ister_value); | ||
414 | if (ACPI_FAILURE(status)) { | ||
415 | goto unlock_and_exit; | ||
416 | } | ||
417 | |||
418 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
419 | "PM2 control: Read %X from %8.8X%8.8X\n", | ||
420 | register_value, | ||
421 | ACPI_FORMAT_UINT64(acpi_gbl_FADT. | ||
422 | xpm2_control_block. | ||
423 | address))); | ||
424 | |||
425 | ACPI_REGISTER_INSERT_VALUE(register_value, | ||
426 | bit_reg_info->bit_position, | ||
427 | bit_reg_info->access_bit_mask, | ||
428 | value); | ||
429 | |||
430 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
431 | "About to write %4.4X to %8.8X%8.8X\n", | ||
432 | register_value, | ||
433 | ACPI_FORMAT_UINT64(acpi_gbl_FADT. | ||
434 | xpm2_control_block. | ||
435 | address))); | ||
436 | |||
437 | status = acpi_hw_register_write(ACPI_REGISTER_PM2_CONTROL, | ||
438 | (u8) (register_value)); | ||
439 | break; | ||
440 | |||
441 | default: | ||
442 | break; | ||
443 | } | ||
444 | |||
445 | unlock_and_exit: | ||
446 | |||
447 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); | ||
448 | |||
449 | /* Normalize the value that was read */ | ||
450 | |||
451 | ACPI_DEBUG_EXEC(register_value = | ||
452 | ((register_value & bit_reg_info->access_bit_mask) >> | ||
453 | bit_reg_info->bit_position)); | ||
454 | |||
455 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
456 | "Set bits: %8.8X actual %8.8X register %X\n", value, | ||
457 | register_value, bit_reg_info->parent_register)); | ||
458 | return_ACPI_STATUS(status); | ||
459 | } | ||
460 | |||
461 | ACPI_EXPORT_SYMBOL(acpi_set_register) | ||
462 | |||
463 | /****************************************************************************** | 128 | /****************************************************************************** |
464 | * | 129 | * |
465 | * FUNCTION: acpi_hw_register_read | 130 | * FUNCTION: acpi_hw_register_read |
@@ -685,162 +350,3 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) | |||
685 | exit: | 350 | exit: |
686 | return_ACPI_STATUS(status); | 351 | return_ACPI_STATUS(status); |
687 | } | 352 | } |
688 | |||
689 | /****************************************************************************** | ||
690 | * | ||
691 | * FUNCTION: acpi_read | ||
692 | * | ||
693 | * PARAMETERS: Value - Where the value is returned | ||
694 | * Reg - GAS register structure | ||
695 | * | ||
696 | * RETURN: Status | ||
697 | * | ||
698 | * DESCRIPTION: Read from either memory or IO space. | ||
699 | * | ||
700 | ******************************************************************************/ | ||
701 | |||
702 | acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg) | ||
703 | { | ||
704 | u32 width; | ||
705 | u64 address; | ||
706 | acpi_status status; | ||
707 | |||
708 | ACPI_FUNCTION_NAME(acpi_read); | ||
709 | |||
710 | /* | ||
711 | * Must have a valid pointer to a GAS structure, and | ||
712 | * a non-zero address within. However, don't return an error | ||
713 | * because the PM1A/B code must not fail if B isn't present. | ||
714 | */ | ||
715 | if (!reg) { | ||
716 | return (AE_OK); | ||
717 | } | ||
718 | |||
719 | /* Get a local copy of the address. Handles possible alignment issues */ | ||
720 | |||
721 | ACPI_MOVE_64_TO_64(&address, ®->address); | ||
722 | if (!address) { | ||
723 | return (AE_OK); | ||
724 | } | ||
725 | |||
726 | /* Supported widths are 8/16/32 */ | ||
727 | |||
728 | width = reg->bit_width; | ||
729 | if ((width != 8) && (width != 16) && (width != 32)) { | ||
730 | return (AE_SUPPORT); | ||
731 | } | ||
732 | |||
733 | /* Initialize entire 32-bit return value to zero */ | ||
734 | |||
735 | *value = 0; | ||
736 | |||
737 | /* | ||
738 | * Two address spaces supported: Memory or IO. | ||
739 | * PCI_Config is not supported here because the GAS struct is insufficient | ||
740 | */ | ||
741 | switch (reg->space_id) { | ||
742 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | ||
743 | |||
744 | status = acpi_os_read_memory((acpi_physical_address) address, | ||
745 | value, width); | ||
746 | break; | ||
747 | |||
748 | case ACPI_ADR_SPACE_SYSTEM_IO: | ||
749 | |||
750 | status = | ||
751 | acpi_os_read_port((acpi_io_address) address, value, width); | ||
752 | break; | ||
753 | |||
754 | default: | ||
755 | ACPI_ERROR((AE_INFO, | ||
756 | "Unsupported address space: %X", reg->space_id)); | ||
757 | return (AE_BAD_PARAMETER); | ||
758 | } | ||
759 | |||
760 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
761 | "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", | ||
762 | *value, width, ACPI_FORMAT_UINT64(address), | ||
763 | acpi_ut_get_region_name(reg->space_id))); | ||
764 | |||
765 | return (status); | ||
766 | } | ||
767 | |||
768 | ACPI_EXPORT_SYMBOL(acpi_read) | ||
769 | |||
770 | /****************************************************************************** | ||
771 | * | ||
772 | * FUNCTION: acpi_write | ||
773 | * | ||
774 | * PARAMETERS: Value - To be written | ||
775 | * Reg - GAS register structure | ||
776 | * | ||
777 | * RETURN: Status | ||
778 | * | ||
779 | * DESCRIPTION: Write to either memory or IO space. | ||
780 | * | ||
781 | ******************************************************************************/ | ||
782 | |||
783 | acpi_status | ||
784 | acpi_write(u32 value, struct acpi_generic_address *reg) | ||
785 | { | ||
786 | u32 width; | ||
787 | u64 address; | ||
788 | acpi_status status; | ||
789 | |||
790 | ACPI_FUNCTION_NAME(acpi_write); | ||
791 | |||
792 | /* | ||
793 | * Must have a valid pointer to a GAS structure, and | ||
794 | * a non-zero address within. However, don't return an error | ||
795 | * because the PM1A/B code must not fail if B isn't present. | ||
796 | */ | ||
797 | if (!reg) { | ||
798 | return (AE_OK); | ||
799 | } | ||
800 | |||
801 | /* Get a local copy of the address. Handles possible alignment issues */ | ||
802 | |||
803 | ACPI_MOVE_64_TO_64(&address, ®->address); | ||
804 | if (!address) { | ||
805 | return (AE_OK); | ||
806 | } | ||
807 | |||
808 | /* Supported widths are 8/16/32 */ | ||
809 | |||
810 | width = reg->bit_width; | ||
811 | if ((width != 8) && (width != 16) && (width != 32)) { | ||
812 | return (AE_SUPPORT); | ||
813 | } | ||
814 | |||
815 | /* | ||
816 | * Two address spaces supported: Memory or IO. | ||
817 | * PCI_Config is not supported here because the GAS struct is insufficient | ||
818 | */ | ||
819 | switch (reg->space_id) { | ||
820 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | ||
821 | |||
822 | status = acpi_os_write_memory((acpi_physical_address) address, | ||
823 | value, width); | ||
824 | break; | ||
825 | |||
826 | case ACPI_ADR_SPACE_SYSTEM_IO: | ||
827 | |||
828 | status = acpi_os_write_port((acpi_io_address) address, value, | ||
829 | width); | ||
830 | break; | ||
831 | |||
832 | default: | ||
833 | ACPI_ERROR((AE_INFO, | ||
834 | "Unsupported address space: %X", reg->space_id)); | ||
835 | return (AE_BAD_PARAMETER); | ||
836 | } | ||
837 | |||
838 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
839 | "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", | ||
840 | value, width, ACPI_FORMAT_UINT64(address), | ||
841 | acpi_ut_get_region_name(reg->space_id))); | ||
842 | |||
843 | return (status); | ||
844 | } | ||
845 | |||
846 | ACPI_EXPORT_SYMBOL(acpi_write) | ||
diff --git a/drivers/acpi/hardware/hwxface.c b/drivers/acpi/hardware/hwxface.c new file mode 100644 index 000000000000..b6244a0fcf4c --- /dev/null +++ b/drivers/acpi/hardware/hwxface.c | |||
@@ -0,0 +1,555 @@ | |||
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/acnamesp.h> | ||
47 | |||
48 | #define _COMPONENT ACPI_HARDWARE | ||
49 | ACPI_MODULE_NAME("hwxface") | ||
50 | |||
51 | /****************************************************************************** | ||
52 | * | ||
53 | * FUNCTION: acpi_read | ||
54 | * | ||
55 | * PARAMETERS: Value - Where the value is returned | ||
56 | * Reg - GAS register structure | ||
57 | * | ||
58 | * RETURN: Status | ||
59 | * | ||
60 | * DESCRIPTION: Read from either memory or IO space. | ||
61 | * | ||
62 | ******************************************************************************/ | ||
63 | acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg) | ||
64 | { | ||
65 | u32 width; | ||
66 | u64 address; | ||
67 | acpi_status status; | ||
68 | |||
69 | ACPI_FUNCTION_NAME(acpi_read); | ||
70 | |||
71 | /* | ||
72 | * Must have a valid pointer to a GAS structure, and | ||
73 | * a non-zero address within. However, don't return an error | ||
74 | * because the PM1A/B code must not fail if B isn't present. | ||
75 | */ | ||
76 | if (!reg) { | ||
77 | return (AE_OK); | ||
78 | } | ||
79 | |||
80 | /* Get a local copy of the address. Handles possible alignment issues */ | ||
81 | |||
82 | ACPI_MOVE_64_TO_64(&address, ®->address); | ||
83 | if (!address) { | ||
84 | return (AE_OK); | ||
85 | } | ||
86 | |||
87 | /* Supported widths are 8/16/32 */ | ||
88 | |||
89 | width = reg->bit_width; | ||
90 | if ((width != 8) && (width != 16) && (width != 32)) { | ||
91 | return (AE_SUPPORT); | ||
92 | } | ||
93 | |||
94 | /* Initialize entire 32-bit return value to zero */ | ||
95 | |||
96 | *value = 0; | ||
97 | |||
98 | /* | ||
99 | * Two address spaces supported: Memory or IO. | ||
100 | * PCI_Config is not supported here because the GAS struct is insufficient | ||
101 | */ | ||
102 | switch (reg->space_id) { | ||
103 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | ||
104 | |||
105 | status = acpi_os_read_memory((acpi_physical_address) address, | ||
106 | value, width); | ||
107 | break; | ||
108 | |||
109 | case ACPI_ADR_SPACE_SYSTEM_IO: | ||
110 | |||
111 | status = | ||
112 | acpi_os_read_port((acpi_io_address) address, value, width); | ||
113 | break; | ||
114 | |||
115 | default: | ||
116 | ACPI_ERROR((AE_INFO, | ||
117 | "Unsupported address space: %X", reg->space_id)); | ||
118 | return (AE_BAD_PARAMETER); | ||
119 | } | ||
120 | |||
121 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
122 | "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", | ||
123 | *value, width, ACPI_FORMAT_UINT64(address), | ||
124 | acpi_ut_get_region_name(reg->space_id))); | ||
125 | |||
126 | return (status); | ||
127 | } | ||
128 | |||
129 | ACPI_EXPORT_SYMBOL(acpi_read) | ||
130 | |||
131 | /****************************************************************************** | ||
132 | * | ||
133 | * FUNCTION: acpi_write | ||
134 | * | ||
135 | * PARAMETERS: Value - To be written | ||
136 | * Reg - GAS register structure | ||
137 | * | ||
138 | * RETURN: Status | ||
139 | * | ||
140 | * DESCRIPTION: Write to either memory or IO space. | ||
141 | * | ||
142 | ******************************************************************************/ | ||
143 | acpi_status acpi_write(u32 value, struct acpi_generic_address *reg) | ||
144 | { | ||
145 | u32 width; | ||
146 | u64 address; | ||
147 | acpi_status status; | ||
148 | |||
149 | ACPI_FUNCTION_NAME(acpi_write); | ||
150 | |||
151 | /* | ||
152 | * Must have a valid pointer to a GAS structure, and | ||
153 | * a non-zero address within. However, don't return an error | ||
154 | * because the PM1A/B code must not fail if B isn't present. | ||
155 | */ | ||
156 | if (!reg) { | ||
157 | return (AE_OK); | ||
158 | } | ||
159 | |||
160 | /* Get a local copy of the address. Handles possible alignment issues */ | ||
161 | |||
162 | ACPI_MOVE_64_TO_64(&address, ®->address); | ||
163 | if (!address) { | ||
164 | return (AE_OK); | ||
165 | } | ||
166 | |||
167 | /* Supported widths are 8/16/32 */ | ||
168 | |||
169 | width = reg->bit_width; | ||
170 | if ((width != 8) && (width != 16) && (width != 32)) { | ||
171 | return (AE_SUPPORT); | ||
172 | } | ||
173 | |||
174 | /* | ||
175 | * Two address spaces supported: Memory or IO. | ||
176 | * PCI_Config is not supported here because the GAS struct is insufficient | ||
177 | */ | ||
178 | switch (reg->space_id) { | ||
179 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | ||
180 | |||
181 | status = acpi_os_write_memory((acpi_physical_address) address, | ||
182 | value, width); | ||
183 | break; | ||
184 | |||
185 | case ACPI_ADR_SPACE_SYSTEM_IO: | ||
186 | |||
187 | status = acpi_os_write_port((acpi_io_address) address, value, | ||
188 | width); | ||
189 | break; | ||
190 | |||
191 | default: | ||
192 | ACPI_ERROR((AE_INFO, | ||
193 | "Unsupported address space: %X", reg->space_id)); | ||
194 | return (AE_BAD_PARAMETER); | ||
195 | } | ||
196 | |||
197 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
198 | "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", | ||
199 | value, width, ACPI_FORMAT_UINT64(address), | ||
200 | acpi_ut_get_region_name(reg->space_id))); | ||
201 | |||
202 | return (status); | ||
203 | } | ||
204 | |||
205 | ACPI_EXPORT_SYMBOL(acpi_write) | ||
206 | |||
207 | /******************************************************************************* | ||
208 | * | ||
209 | * FUNCTION: acpi_get_register_unlocked | ||
210 | * | ||
211 | * PARAMETERS: register_id - ID of ACPI bit_register to access | ||
212 | * return_value - Value that was read from the register | ||
213 | * | ||
214 | * RETURN: Status and the value read from specified Register. Value | ||
215 | * returned is normalized to bit0 (is shifted all the way right) | ||
216 | * | ||
217 | * DESCRIPTION: ACPI bit_register read function. Does not acquire the HW lock. | ||
218 | * | ||
219 | ******************************************************************************/ | ||
220 | acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value) | ||
221 | { | ||
222 | u32 register_value = 0; | ||
223 | struct acpi_bit_register_info *bit_reg_info; | ||
224 | acpi_status status; | ||
225 | |||
226 | ACPI_FUNCTION_TRACE(acpi_get_register_unlocked); | ||
227 | |||
228 | /* Get the info structure corresponding to the requested ACPI Register */ | ||
229 | |||
230 | bit_reg_info = acpi_hw_get_bit_register_info(register_id); | ||
231 | if (!bit_reg_info) { | ||
232 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
233 | } | ||
234 | |||
235 | /* Read from the register */ | ||
236 | |||
237 | status = acpi_hw_register_read(bit_reg_info->parent_register, | ||
238 | ®ister_value); | ||
239 | |||
240 | if (ACPI_SUCCESS(status)) { | ||
241 | |||
242 | /* Normalize the value that was read */ | ||
243 | |||
244 | register_value = | ||
245 | ((register_value & bit_reg_info->access_bit_mask) | ||
246 | >> bit_reg_info->bit_position); | ||
247 | |||
248 | *return_value = register_value; | ||
249 | |||
250 | ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read value %8.8X register %X\n", | ||
251 | register_value, | ||
252 | bit_reg_info->parent_register)); | ||
253 | } | ||
254 | |||
255 | return_ACPI_STATUS(status); | ||
256 | } | ||
257 | |||
258 | ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked) | ||
259 | |||
260 | /******************************************************************************* | ||
261 | * | ||
262 | * FUNCTION: acpi_get_register | ||
263 | * | ||
264 | * PARAMETERS: register_id - ID of ACPI bit_register to access | ||
265 | * return_value - Value that was read from the register | ||
266 | * | ||
267 | * RETURN: Status and the value read from specified Register. Value | ||
268 | * returned is normalized to bit0 (is shifted all the way right) | ||
269 | * | ||
270 | * DESCRIPTION: ACPI bit_register read function. | ||
271 | * | ||
272 | ******************************************************************************/ | ||
273 | acpi_status acpi_get_register(u32 register_id, u32 *return_value) | ||
274 | { | ||
275 | acpi_status status; | ||
276 | acpi_cpu_flags flags; | ||
277 | |||
278 | flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
279 | status = acpi_get_register_unlocked(register_id, return_value); | ||
280 | acpi_os_release_lock(acpi_gbl_hardware_lock, flags); | ||
281 | |||
282 | return (status); | ||
283 | } | ||
284 | |||
285 | ACPI_EXPORT_SYMBOL(acpi_get_register) | ||
286 | |||
287 | /******************************************************************************* | ||
288 | * | ||
289 | * FUNCTION: acpi_set_register | ||
290 | * | ||
291 | * PARAMETERS: register_id - ID of ACPI bit_register to access | ||
292 | * Value - (only used on write) value to write to the | ||
293 | * Register, NOT pre-normalized to the bit pos | ||
294 | * | ||
295 | * RETURN: Status | ||
296 | * | ||
297 | * DESCRIPTION: ACPI Bit Register write function. | ||
298 | * | ||
299 | ******************************************************************************/ | ||
300 | acpi_status acpi_set_register(u32 register_id, u32 value) | ||
301 | { | ||
302 | u32 register_value = 0; | ||
303 | struct acpi_bit_register_info *bit_reg_info; | ||
304 | acpi_status status; | ||
305 | acpi_cpu_flags lock_flags; | ||
306 | |||
307 | ACPI_FUNCTION_TRACE_U32(acpi_set_register, register_id); | ||
308 | |||
309 | /* Get the info structure corresponding to the requested ACPI Register */ | ||
310 | |||
311 | bit_reg_info = acpi_hw_get_bit_register_info(register_id); | ||
312 | if (!bit_reg_info) { | ||
313 | ACPI_ERROR((AE_INFO, "Bad ACPI HW RegisterId: %X", | ||
314 | register_id)); | ||
315 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
316 | } | ||
317 | |||
318 | lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); | ||
319 | |||
320 | /* Always do a register read first so we can insert the new bits */ | ||
321 | |||
322 | status = acpi_hw_register_read(bit_reg_info->parent_register, | ||
323 | ®ister_value); | ||
324 | if (ACPI_FAILURE(status)) { | ||
325 | goto unlock_and_exit; | ||
326 | } | ||
327 | |||
328 | /* | ||
329 | * Decode the Register ID | ||
330 | * Register ID = [Register block ID] | [bit ID] | ||
331 | * | ||
332 | * Check bit ID to fine locate Register offset. | ||
333 | * Check Mask to determine Register offset, and then read-write. | ||
334 | */ | ||
335 | switch (bit_reg_info->parent_register) { | ||
336 | case ACPI_REGISTER_PM1_STATUS: | ||
337 | |||
338 | /* | ||
339 | * Status Registers are different from the rest. Clear by | ||
340 | * writing 1, and writing 0 has no effect. So, the only relevant | ||
341 | * information is the single bit we're interested in, all others should | ||
342 | * be written as 0 so they will be left unchanged. | ||
343 | */ | ||
344 | value = ACPI_REGISTER_PREPARE_BITS(value, | ||
345 | bit_reg_info->bit_position, | ||
346 | bit_reg_info-> | ||
347 | access_bit_mask); | ||
348 | if (value) { | ||
349 | status = | ||
350 | acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, | ||
351 | (u16) value); | ||
352 | register_value = 0; | ||
353 | } | ||
354 | break; | ||
355 | |||
356 | case ACPI_REGISTER_PM1_ENABLE: | ||
357 | |||
358 | ACPI_REGISTER_INSERT_VALUE(register_value, | ||
359 | bit_reg_info->bit_position, | ||
360 | bit_reg_info->access_bit_mask, | ||
361 | value); | ||
362 | |||
363 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_ENABLE, | ||
364 | (u16) register_value); | ||
365 | break; | ||
366 | |||
367 | case ACPI_REGISTER_PM1_CONTROL: | ||
368 | |||
369 | /* | ||
370 | * Write the PM1 Control register. | ||
371 | * Note that at this level, the fact that there are actually TWO | ||
372 | * registers (A and B - and B may not exist) is abstracted. | ||
373 | */ | ||
374 | ACPI_DEBUG_PRINT((ACPI_DB_IO, "PM1 control: Read %X\n", | ||
375 | register_value)); | ||
376 | |||
377 | ACPI_REGISTER_INSERT_VALUE(register_value, | ||
378 | bit_reg_info->bit_position, | ||
379 | bit_reg_info->access_bit_mask, | ||
380 | value); | ||
381 | |||
382 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, | ||
383 | (u16) register_value); | ||
384 | break; | ||
385 | |||
386 | case ACPI_REGISTER_PM2_CONTROL: | ||
387 | |||
388 | status = acpi_hw_register_read(ACPI_REGISTER_PM2_CONTROL, | ||
389 | ®ister_value); | ||
390 | if (ACPI_FAILURE(status)) { | ||
391 | goto unlock_and_exit; | ||
392 | } | ||
393 | |||
394 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
395 | "PM2 control: Read %X from %8.8X%8.8X\n", | ||
396 | register_value, | ||
397 | ACPI_FORMAT_UINT64(acpi_gbl_FADT. | ||
398 | xpm2_control_block. | ||
399 | address))); | ||
400 | |||
401 | ACPI_REGISTER_INSERT_VALUE(register_value, | ||
402 | bit_reg_info->bit_position, | ||
403 | bit_reg_info->access_bit_mask, | ||
404 | value); | ||
405 | |||
406 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
407 | "About to write %4.4X to %8.8X%8.8X\n", | ||
408 | register_value, | ||
409 | ACPI_FORMAT_UINT64(acpi_gbl_FADT. | ||
410 | xpm2_control_block. | ||
411 | address))); | ||
412 | |||
413 | status = acpi_hw_register_write(ACPI_REGISTER_PM2_CONTROL, | ||
414 | (u8) (register_value)); | ||
415 | break; | ||
416 | |||
417 | default: | ||
418 | break; | ||
419 | } | ||
420 | |||
421 | unlock_and_exit: | ||
422 | |||
423 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); | ||
424 | |||
425 | /* Normalize the value that was read */ | ||
426 | |||
427 | ACPI_DEBUG_EXEC(register_value = | ||
428 | ((register_value & bit_reg_info->access_bit_mask) >> | ||
429 | bit_reg_info->bit_position)); | ||
430 | |||
431 | ACPI_DEBUG_PRINT((ACPI_DB_IO, | ||
432 | "Set bits: %8.8X actual %8.8X register %X\n", value, | ||
433 | register_value, bit_reg_info->parent_register)); | ||
434 | return_ACPI_STATUS(status); | ||
435 | } | ||
436 | |||
437 | ACPI_EXPORT_SYMBOL(acpi_set_register) | ||
438 | |||
439 | /******************************************************************************* | ||
440 | * | ||
441 | * FUNCTION: acpi_get_sleep_type_data | ||
442 | * | ||
443 | * PARAMETERS: sleep_state - Numeric sleep state | ||
444 | * *sleep_type_a - Where SLP_TYPa is returned | ||
445 | * *sleep_type_b - Where SLP_TYPb is returned | ||
446 | * | ||
447 | * RETURN: Status - ACPI status | ||
448 | * | ||
449 | * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep | ||
450 | * state. | ||
451 | * | ||
452 | ******************************************************************************/ | ||
453 | acpi_status | ||
454 | acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) | ||
455 | { | ||
456 | acpi_status status = AE_OK; | ||
457 | struct acpi_evaluate_info *info; | ||
458 | |||
459 | ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data); | ||
460 | |||
461 | /* Validate parameters */ | ||
462 | |||
463 | if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) { | ||
464 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
465 | } | ||
466 | |||
467 | /* Allocate the evaluation information block */ | ||
468 | |||
469 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); | ||
470 | if (!info) { | ||
471 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
472 | } | ||
473 | |||
474 | info->pathname = | ||
475 | ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); | ||
476 | |||
477 | /* Evaluate the namespace object containing the values for this state */ | ||
478 | |||
479 | status = acpi_ns_evaluate(info); | ||
480 | if (ACPI_FAILURE(status)) { | ||
481 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
482 | "%s while evaluating SleepState [%s]\n", | ||
483 | acpi_format_exception(status), | ||
484 | info->pathname)); | ||
485 | |||
486 | goto cleanup; | ||
487 | } | ||
488 | |||
489 | /* Must have a return object */ | ||
490 | |||
491 | if (!info->return_object) { | ||
492 | ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", | ||
493 | info->pathname)); | ||
494 | status = AE_NOT_EXIST; | ||
495 | } | ||
496 | |||
497 | /* It must be of type Package */ | ||
498 | |||
499 | else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) { | ||
500 | ACPI_ERROR((AE_INFO, | ||
501 | "Sleep State return object is not a Package")); | ||
502 | status = AE_AML_OPERAND_TYPE; | ||
503 | } | ||
504 | |||
505 | /* | ||
506 | * The package must have at least two elements. NOTE (March 2005): This | ||
507 | * goes against the current ACPI spec which defines this object as a | ||
508 | * package with one encoded DWORD element. However, existing practice | ||
509 | * by BIOS vendors seems to be to have 2 or more elements, at least | ||
510 | * one per sleep type (A/B). | ||
511 | */ | ||
512 | else if (info->return_object->package.count < 2) { | ||
513 | ACPI_ERROR((AE_INFO, | ||
514 | "Sleep State return package does not have at least two elements")); | ||
515 | status = AE_AML_NO_OPERAND; | ||
516 | } | ||
517 | |||
518 | /* The first two elements must both be of type Integer */ | ||
519 | |||
520 | else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0]) | ||
521 | != ACPI_TYPE_INTEGER) || | ||
522 | (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1]) | ||
523 | != ACPI_TYPE_INTEGER)) { | ||
524 | ACPI_ERROR((AE_INFO, | ||
525 | "Sleep State return package elements are not both Integers (%s, %s)", | ||
526 | acpi_ut_get_object_type_name(info->return_object-> | ||
527 | package.elements[0]), | ||
528 | acpi_ut_get_object_type_name(info->return_object-> | ||
529 | package.elements[1]))); | ||
530 | status = AE_AML_OPERAND_TYPE; | ||
531 | } else { | ||
532 | /* Valid _Sx_ package size, type, and value */ | ||
533 | |||
534 | *sleep_type_a = (u8) | ||
535 | (info->return_object->package.elements[0])->integer.value; | ||
536 | *sleep_type_b = (u8) | ||
537 | (info->return_object->package.elements[1])->integer.value; | ||
538 | } | ||
539 | |||
540 | if (ACPI_FAILURE(status)) { | ||
541 | ACPI_EXCEPTION((AE_INFO, status, | ||
542 | "While evaluating SleepState [%s], bad Sleep object %p type %s", | ||
543 | info->pathname, info->return_object, | ||
544 | acpi_ut_get_object_type_name(info-> | ||
545 | return_object))); | ||
546 | } | ||
547 | |||
548 | acpi_ut_remove_reference(info->return_object); | ||
549 | |||
550 | cleanup: | ||
551 | ACPI_FREE(info); | ||
552 | return_ACPI_STATUS(status); | ||
553 | } | ||
554 | |||
555 | ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data) | ||