blob: b3c6e439933c56e428ff6d58485c594ca959b4cd [file] [log] [blame]
Bob Moore7db5d822008-12-30 11:04:48 +08001/******************************************************************************
2 *
3 * Module Name: hwxface - Public ACPICA hardware interfaces
4 *
5 *****************************************************************************/
6
7/*
Bob Moore7735ca02017-02-08 11:00:08 +08008 * Copyright (C) 2000 - 2017, Intel Corp.
Bob Moore7db5d822008-12-30 11:04:48 +08009 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
Lv Zheng839e9282013-10-29 09:29:51 +080044#define EXPORT_ACPI_INTERFACES
45
Bob Moore7db5d822008-12-30 11:04:48 +080046#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050047#include "accommon.h"
48#include "acnamesp.h"
Bob Moore7db5d822008-12-30 11:04:48 +080049
50#define _COMPONENT ACPI_HARDWARE
51ACPI_MODULE_NAME("hwxface")
52
53/******************************************************************************
54 *
Bob Moored3fd9022008-12-30 11:11:57 +080055 * FUNCTION: acpi_reset
56 *
57 * PARAMETERS: None
58 *
59 * RETURN: Status
60 *
61 * DESCRIPTION: Set reset register in memory or IO space. Note: Does not
62 * support reset register in PCI config space, this must be
63 * handled separately.
64 *
65 ******************************************************************************/
66acpi_status acpi_reset(void)
67{
68 struct acpi_generic_address *reset_reg;
69 acpi_status status;
70
71 ACPI_FUNCTION_TRACE(acpi_reset);
72
73 reset_reg = &acpi_gbl_FADT.reset_register;
74
75 /* Check if the reset register is supported */
76
Linus Torvalds19244ad2012-04-20 11:19:35 -070077 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) ||
78 !reset_reg->address) {
Bob Moored3fd9022008-12-30 11:11:57 +080079 return_ACPI_STATUS(AE_NOT_EXIST);
80 }
81
Bob Moore8a964232009-08-13 13:42:19 +080082 if (reset_reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
83 /*
Lv Zheng75c80442012-12-19 05:36:49 +000084 * For I/O space, write directly to the OSL. This bypasses the port
85 * validation mechanism, which may block a valid write to the reset
86 * register.
Bob Mooree07fcfd2013-10-29 09:29:45 +080087 *
88 * NOTE:
89 * The ACPI spec requires the reset register width to be 8, so we
90 * hardcode it here and ignore the FADT value. This maintains
91 * compatibility with other ACPI implementations that have allowed
92 * BIOS code with bad register width values to go unnoticed.
Bob Moore8a964232009-08-13 13:42:19 +080093 */
Lv Zhengf5c1e1c2016-05-05 12:57:53 +080094 status = acpi_os_write_port((acpi_io_address)reset_reg->address,
95 acpi_gbl_FADT.reset_value,
96 ACPI_RESET_REGISTER_WIDTH);
Bob Moore8a964232009-08-13 13:42:19 +080097 } else {
98 /* Write the reset value to the reset register */
Bob Moored3fd9022008-12-30 11:11:57 +080099
Bob Moore8a964232009-08-13 13:42:19 +0800100 status = acpi_hw_write(acpi_gbl_FADT.reset_value, reset_reg);
101 }
102
Bob Moored3fd9022008-12-30 11:11:57 +0800103 return_ACPI_STATUS(status);
104}
105
106ACPI_EXPORT_SYMBOL(acpi_reset)
107
108/******************************************************************************
109 *
Bob Moore7db5d822008-12-30 11:04:48 +0800110 * FUNCTION: acpi_read
111 *
Bob Mooreba494be2012-07-12 09:40:10 +0800112 * PARAMETERS: value - Where the value is returned
113 * reg - GAS register structure
Bob Moore7db5d822008-12-30 11:04:48 +0800114 *
115 * RETURN: Status
116 *
117 * DESCRIPTION: Read from either memory or IO space.
118 *
Bob Moorec6b57742009-06-24 09:44:06 +0800119 * LIMITATIONS: <These limitations also apply to acpi_write>
120 * bit_width must be exactly 8, 16, 32, or 64.
Bob Mooreba494be2012-07-12 09:40:10 +0800121 * space_ID must be system_memory or system_IO.
Bob Moorec6b57742009-06-24 09:44:06 +0800122 * bit_offset and access_width are currently ignored, as there has
123 * not been a need to implement these.
124 *
Bob Moore7db5d822008-12-30 11:04:48 +0800125 ******************************************************************************/
Bob Moorec6b57742009-06-24 09:44:06 +0800126acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg)
Bob Moore7db5d822008-12-30 11:04:48 +0800127{
Bob Moore7db5d822008-12-30 11:04:48 +0800128 acpi_status status;
129
130 ACPI_FUNCTION_NAME(acpi_read);
131
Lv Zheng8381c542017-09-20 10:00:11 +0800132 status = acpi_hw_read(return_value, reg);
133 return (status);
Bob Moore7db5d822008-12-30 11:04:48 +0800134}
135
136ACPI_EXPORT_SYMBOL(acpi_read)
137
138/******************************************************************************
139 *
140 * FUNCTION: acpi_write
141 *
Bob Mooreba494be2012-07-12 09:40:10 +0800142 * PARAMETERS: value - Value to be written
143 * reg - GAS register structure
Bob Moore7db5d822008-12-30 11:04:48 +0800144 *
145 * RETURN: Status
146 *
147 * DESCRIPTION: Write to either memory or IO space.
148 *
149 ******************************************************************************/
Bob Moorec6b57742009-06-24 09:44:06 +0800150acpi_status acpi_write(u64 value, struct acpi_generic_address *reg)
Bob Moore7db5d822008-12-30 11:04:48 +0800151{
Bob Moore7db5d822008-12-30 11:04:48 +0800152 acpi_status status;
153
154 ACPI_FUNCTION_NAME(acpi_write);
155
Lv Zheng8381c542017-09-20 10:00:11 +0800156 status = acpi_hw_write(value, reg);
Bob Moore7db5d822008-12-30 11:04:48 +0800157 return (status);
158}
159
160ACPI_EXPORT_SYMBOL(acpi_write)
161
Bob Moore33620c52012-02-14 18:14:27 +0800162#if (!ACPI_REDUCED_HARDWARE)
Bob Moore7db5d822008-12-30 11:04:48 +0800163/*******************************************************************************
164 *
Bob Moore50ffba12009-02-23 15:02:07 +0800165 * FUNCTION: acpi_read_bit_register
Bob Moore7db5d822008-12-30 11:04:48 +0800166 *
Bob Moore9892dd22009-02-18 15:10:07 +0800167 * PARAMETERS: register_id - ID of ACPI Bit Register to access
168 * return_value - Value that was read from the register,
169 * normalized to bit position zero.
Bob Moore7db5d822008-12-30 11:04:48 +0800170 *
Bob Moore9892dd22009-02-18 15:10:07 +0800171 * RETURN: Status and the value read from the specified Register. Value
Bob Moore7db5d822008-12-30 11:04:48 +0800172 * returned is normalized to bit0 (is shifted all the way right)
173 *
174 * DESCRIPTION: ACPI bit_register read function. Does not acquire the HW lock.
175 *
Bob Moore9892dd22009-02-18 15:10:07 +0800176 * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
177 * PM2 Control.
178 *
179 * Note: The hardware lock is not required when reading the ACPI bit registers
180 * since almost all of them are single bit and it does not matter that
181 * the parent hardware register can be split across two physical
182 * registers. The only multi-bit field is SLP_TYP in the PM1 control
183 * register, but this field does not cross an 8-bit boundary (nor does
184 * it make much sense to actually read this field.)
185 *
Bob Moore7db5d822008-12-30 11:04:48 +0800186 ******************************************************************************/
Bob Moore50ffba12009-02-23 15:02:07 +0800187acpi_status acpi_read_bit_register(u32 register_id, u32 *return_value)
Bob Moore7db5d822008-12-30 11:04:48 +0800188{
Bob Moore7db5d822008-12-30 11:04:48 +0800189 struct acpi_bit_register_info *bit_reg_info;
Bob Moore88dcb042009-02-18 16:01:04 +0800190 u32 register_value;
191 u32 value;
Bob Moore7db5d822008-12-30 11:04:48 +0800192 acpi_status status;
193
Bob Moore88dcb042009-02-18 16:01:04 +0800194 ACPI_FUNCTION_TRACE_U32(acpi_read_bit_register, register_id);
Bob Moore7db5d822008-12-30 11:04:48 +0800195
196 /* Get the info structure corresponding to the requested ACPI Register */
197
198 bit_reg_info = acpi_hw_get_bit_register_info(register_id);
199 if (!bit_reg_info) {
200 return_ACPI_STATUS(AE_BAD_PARAMETER);
201 }
202
Bob Moore9892dd22009-02-18 15:10:07 +0800203 /* Read the entire parent register */
Bob Moore7db5d822008-12-30 11:04:48 +0800204
205 status = acpi_hw_register_read(bit_reg_info->parent_register,
206 &register_value);
Bob Moore88dcb042009-02-18 16:01:04 +0800207 if (ACPI_FAILURE(status)) {
208 return_ACPI_STATUS(status);
Bob Moore7db5d822008-12-30 11:04:48 +0800209 }
210
Bob Moore88dcb042009-02-18 16:01:04 +0800211 /* Normalize the value that was read, mask off other bits */
212
213 value = ((register_value & bit_reg_info->access_bit_mask)
214 >> bit_reg_info->bit_position);
215
216 ACPI_DEBUG_PRINT((ACPI_DB_IO,
217 "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
218 register_id, bit_reg_info->parent_register,
219 register_value, value));
220
221 *return_value = value;
222 return_ACPI_STATUS(AE_OK);
Bob Moore7db5d822008-12-30 11:04:48 +0800223}
224
Bob Moore50ffba12009-02-23 15:02:07 +0800225ACPI_EXPORT_SYMBOL(acpi_read_bit_register)
Bob Moore7db5d822008-12-30 11:04:48 +0800226
227/*******************************************************************************
228 *
Bob Moore50ffba12009-02-23 15:02:07 +0800229 * FUNCTION: acpi_write_bit_register
Bob Moore7db5d822008-12-30 11:04:48 +0800230 *
Bob Moore9892dd22009-02-18 15:10:07 +0800231 * PARAMETERS: register_id - ID of ACPI Bit Register to access
Lv Zheng75c80442012-12-19 05:36:49 +0000232 * value - Value to write to the register, in bit
Justin P. Mattock42b2aa82011-11-28 20:31:00 -0800233 * position zero. The bit is automatically
Bob Moore9892dd22009-02-18 15:10:07 +0800234 * shifted to the correct position.
Bob Moore7db5d822008-12-30 11:04:48 +0800235 *
236 * RETURN: Status
237 *
Bob Moore9892dd22009-02-18 15:10:07 +0800238 * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock
239 * since most operations require a read/modify/write sequence.
240 *
241 * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
242 * PM2 Control.
Bob Moore7db5d822008-12-30 11:04:48 +0800243 *
Bob Moore88dcb042009-02-18 16:01:04 +0800244 * Note that at this level, the fact that there may be actually two
245 * hardware registers (A and B - and B may not exist) is abstracted.
246 *
Bob Moore7db5d822008-12-30 11:04:48 +0800247 ******************************************************************************/
Bob Moore50ffba12009-02-23 15:02:07 +0800248acpi_status acpi_write_bit_register(u32 register_id, u32 value)
Bob Moore7db5d822008-12-30 11:04:48 +0800249{
Bob Moore7db5d822008-12-30 11:04:48 +0800250 struct acpi_bit_register_info *bit_reg_info;
Bob Moore7db5d822008-12-30 11:04:48 +0800251 acpi_cpu_flags lock_flags;
Bob Moore88dcb042009-02-18 16:01:04 +0800252 u32 register_value;
253 acpi_status status = AE_OK;
Bob Moore7db5d822008-12-30 11:04:48 +0800254
Bob Moore50ffba12009-02-23 15:02:07 +0800255 ACPI_FUNCTION_TRACE_U32(acpi_write_bit_register, register_id);
Bob Moore7db5d822008-12-30 11:04:48 +0800256
257 /* Get the info structure corresponding to the requested ACPI Register */
258
259 bit_reg_info = acpi_hw_get_bit_register_info(register_id);
260 if (!bit_reg_info) {
Bob Moore7db5d822008-12-30 11:04:48 +0800261 return_ACPI_STATUS(AE_BAD_PARAMETER);
262 }
263
264 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
265
Bob Moore7db5d822008-12-30 11:04:48 +0800266 /*
Bob Moore88dcb042009-02-18 16:01:04 +0800267 * At this point, we know that the parent register is one of the
268 * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control
Bob Moore7db5d822008-12-30 11:04:48 +0800269 */
Bob Moore88dcb042009-02-18 16:01:04 +0800270 if (bit_reg_info->parent_register != ACPI_REGISTER_PM1_STATUS) {
Bob Moore7db5d822008-12-30 11:04:48 +0800271 /*
Bob Moore88dcb042009-02-18 16:01:04 +0800272 * 1) Case for PM1 Enable, PM1 Control, and PM2 Control
273 *
274 * Perform a register read to preserve the bits that we are not
275 * interested in
Bob Moore7db5d822008-12-30 11:04:48 +0800276 */
Bob Moore88dcb042009-02-18 16:01:04 +0800277 status = acpi_hw_register_read(bit_reg_info->parent_register,
Bob Moore7db5d822008-12-30 11:04:48 +0800278 &register_value);
279 if (ACPI_FAILURE(status)) {
280 goto unlock_and_exit;
281 }
282
Bob Moore88dcb042009-02-18 16:01:04 +0800283 /*
284 * Insert the input bit into the value that was just read
285 * and write the register
286 */
Bob Moore7db5d822008-12-30 11:04:48 +0800287 ACPI_REGISTER_INSERT_VALUE(register_value,
288 bit_reg_info->bit_position,
289 bit_reg_info->access_bit_mask,
290 value);
291
Bob Moore88dcb042009-02-18 16:01:04 +0800292 status = acpi_hw_register_write(bit_reg_info->parent_register,
293 register_value);
294 } else {
295 /*
296 * 2) Case for PM1 Status
297 *
298 * The Status register is different from the rest. Clear an event
299 * by writing 1, writing 0 has no effect. So, the only relevant
300 * information is the single bit we're interested in, all others
301 * should be written as 0 so they will be left unchanged.
302 */
303 register_value = ACPI_REGISTER_PREPARE_BITS(value,
304 bit_reg_info->
305 bit_position,
306 bit_reg_info->
307 access_bit_mask);
Bob Moore7db5d822008-12-30 11:04:48 +0800308
Bob Moore88dcb042009-02-18 16:01:04 +0800309 /* No need to write the register if value is all zeros */
Bob Moore7db5d822008-12-30 11:04:48 +0800310
Bob Moore88dcb042009-02-18 16:01:04 +0800311 if (register_value) {
312 status =
313 acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
314 register_value);
315 }
Bob Moore7db5d822008-12-30 11:04:48 +0800316 }
317
Bob Moore88dcb042009-02-18 16:01:04 +0800318 ACPI_DEBUG_PRINT((ACPI_DB_IO,
319 "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n",
320 register_id, bit_reg_info->parent_register, value,
321 register_value));
322
323unlock_and_exit:
Bob Moore7db5d822008-12-30 11:04:48 +0800324
325 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
Bob Moore7db5d822008-12-30 11:04:48 +0800326 return_ACPI_STATUS(status);
327}
328
Bob Moore50ffba12009-02-23 15:02:07 +0800329ACPI_EXPORT_SYMBOL(acpi_write_bit_register)
Bob Moore33620c52012-02-14 18:14:27 +0800330#endif /* !ACPI_REDUCED_HARDWARE */
Bob Moore7db5d822008-12-30 11:04:48 +0800331/*******************************************************************************
332 *
333 * FUNCTION: acpi_get_sleep_type_data
334 *
335 * PARAMETERS: sleep_state - Numeric sleep state
336 * *sleep_type_a - Where SLP_TYPa is returned
337 * *sleep_type_b - Where SLP_TYPb is returned
338 *
Bob Moore48ffb942013-01-25 05:41:00 +0000339 * RETURN: Status
Bob Moore7db5d822008-12-30 11:04:48 +0800340 *
Bob Moore48ffb942013-01-25 05:41:00 +0000341 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested
342 * sleep state via the appropriate \_Sx object.
343 *
344 * The sleep state package returned from the corresponding \_Sx_ object
345 * must contain at least one integer.
346 *
347 * March 2005:
348 * Added support for a package that contains two integers. This
349 * goes against the ACPI specification which defines this object as a
350 * package with one encoded DWORD integer. However, existing practice
351 * by many BIOS vendors is to return a package with 2 or more integer
352 * elements, at least one per sleep type (A/B).
353 *
354 * January 2013:
355 * Therefore, we must be prepared to accept a package with either a
356 * single integer or multiple integers.
357 *
358 * The single integer DWORD format is as follows:
359 * BYTE 0 - Value for the PM1A SLP_TYP register
360 * BYTE 1 - Value for the PM1B SLP_TYP register
361 * BYTE 2-3 - Reserved
362 *
363 * The dual integer format is as follows:
364 * Integer 0 - Value for the PM1A SLP_TYP register
365 * Integer 1 - Value for the PM1A SLP_TYP register
Bob Moore7db5d822008-12-30 11:04:48 +0800366 *
367 ******************************************************************************/
368acpi_status
369acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
370{
Bob Moore48ffb942013-01-25 05:41:00 +0000371 acpi_status status;
Bob Moore7db5d822008-12-30 11:04:48 +0800372 struct acpi_evaluate_info *info;
Bob Moore48ffb942013-01-25 05:41:00 +0000373 union acpi_operand_object **elements;
Bob Moore7db5d822008-12-30 11:04:48 +0800374
375 ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data);
376
377 /* Validate parameters */
378
379 if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) {
380 return_ACPI_STATUS(AE_BAD_PARAMETER);
381 }
382
383 /* Allocate the evaluation information block */
384
385 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
386 if (!info) {
387 return_ACPI_STATUS(AE_NO_MEMORY);
388 }
389
Bob Moore48ffb942013-01-25 05:41:00 +0000390 /*
391 * Evaluate the \_Sx namespace object containing the register values
392 * for this state
393 */
Bob Moore0dfaaa32016-03-24 09:40:40 +0800394 info->relative_pathname = acpi_gbl_sleep_state_names[sleep_state];
Prarit Bhargavaa59b6792015-12-29 13:52:41 +0800395
Bob Moore7db5d822008-12-30 11:04:48 +0800396 status = acpi_ns_evaluate(info);
397 if (ACPI_FAILURE(status)) {
Prarit Bhargavaa59b6792015-12-29 13:52:41 +0800398 if (status == AE_NOT_FOUND) {
399
400 /* The _Sx states are optional, ignore NOT_FOUND */
401
402 goto final_cleanup;
403 }
404
405 goto warning_cleanup;
Bob Moore7db5d822008-12-30 11:04:48 +0800406 }
407
408 /* Must have a return object */
409
410 if (!info->return_object) {
411 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]",
Bob Moore29a241c2013-05-30 10:00:01 +0800412 info->relative_pathname));
Bob Moore48ffb942013-01-25 05:41:00 +0000413 status = AE_AML_NO_RETURN_VALUE;
Prarit Bhargavaa59b6792015-12-29 13:52:41 +0800414 goto warning_cleanup;
Bob Moore7db5d822008-12-30 11:04:48 +0800415 }
416
Bob Moore48ffb942013-01-25 05:41:00 +0000417 /* Return object must be of type Package */
Bob Moore7db5d822008-12-30 11:04:48 +0800418
Bob Moore48ffb942013-01-25 05:41:00 +0000419 if (info->return_object->common.type != ACPI_TYPE_PACKAGE) {
Bob Moore7db5d822008-12-30 11:04:48 +0800420 ACPI_ERROR((AE_INFO,
421 "Sleep State return object is not a Package"));
422 status = AE_AML_OPERAND_TYPE;
Prarit Bhargavaa59b6792015-12-29 13:52:41 +0800423 goto return_value_cleanup;
Bob Moore7db5d822008-12-30 11:04:48 +0800424 }
425
426 /*
Bob Moore48ffb942013-01-25 05:41:00 +0000427 * Any warnings about the package length or the object types have
428 * already been issued by the predefined name module -- there is no
429 * need to repeat them here.
Bob Moore7db5d822008-12-30 11:04:48 +0800430 */
Bob Moore48ffb942013-01-25 05:41:00 +0000431 elements = info->return_object->package.elements;
432 switch (info->return_object->package.count) {
433 case 0:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000434
Bob Moore48ffb942013-01-25 05:41:00 +0000435 status = AE_AML_PACKAGE_LIMIT;
436 break;
437
438 case 1:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000439
Bob Moore48ffb942013-01-25 05:41:00 +0000440 if (elements[0]->common.type != ACPI_TYPE_INTEGER) {
441 status = AE_AML_OPERAND_TYPE;
442 break;
443 }
444
445 /* A valid _Sx_ package with one integer */
446
447 *sleep_type_a = (u8)elements[0]->integer.value;
448 *sleep_type_b = (u8)(elements[0]->integer.value >> 8);
449 break;
450
451 case 2:
452 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000453
Bob Moore48ffb942013-01-25 05:41:00 +0000454 if ((elements[0]->common.type != ACPI_TYPE_INTEGER) ||
455 (elements[1]->common.type != ACPI_TYPE_INTEGER)) {
456 status = AE_AML_OPERAND_TYPE;
457 break;
458 }
459
460 /* A valid _Sx_ package with two integers */
461
462 *sleep_type_a = (u8)elements[0]->integer.value;
463 *sleep_type_b = (u8)elements[1]->integer.value;
464 break;
Bob Moore7db5d822008-12-30 11:04:48 +0800465 }
466
Prarit Bhargavaa59b6792015-12-29 13:52:41 +0800467return_value_cleanup:
Bob Moore7db5d822008-12-30 11:04:48 +0800468 acpi_ut_remove_reference(info->return_object);
469
Prarit Bhargavaa59b6792015-12-29 13:52:41 +0800470warning_cleanup:
Bob Moore48ffb942013-01-25 05:41:00 +0000471 if (ACPI_FAILURE(status)) {
472 ACPI_EXCEPTION((AE_INFO, status,
473 "While evaluating Sleep State [%s]",
Bob Moore29a241c2013-05-30 10:00:01 +0800474 info->relative_pathname));
Bob Moore48ffb942013-01-25 05:41:00 +0000475 }
476
Prarit Bhargavaa59b6792015-12-29 13:52:41 +0800477final_cleanup:
Bob Moore7db5d822008-12-30 11:04:48 +0800478 ACPI_FREE(info);
479 return_ACPI_STATUS(status);
480}
481
482ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data)