blob: edc627c9fc0d5e3340e3a61d762c2b59471f6999 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001
2/*******************************************************************************
3 *
4 * Module Name: hwregs - Read/write access functions for the various ACPI
5 * control and status registers.
6 *
7 ******************************************************************************/
8
9/*
Len Brown75a44ce2008-04-23 23:00:13 -040010 * Copyright (C) 2000 - 2008, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050047#include "accommon.h"
48#include "acnamesp.h"
49#include "acevents.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51#define _COMPONENT ACPI_HARDWARE
Len Brown4be44fc2005-08-05 00:44:28 -040052ACPI_MODULE_NAME("hwregs")
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Bob Moorec520aba2009-02-18 14:20:12 +080054/* Local Prototypes */
55static acpi_status
56acpi_hw_read_multiple(u32 *value,
57 struct acpi_generic_address *register_a,
58 struct acpi_generic_address *register_b);
59
60static acpi_status
61acpi_hw_write_multiple(u32 value,
62 struct acpi_generic_address *register_a,
63 struct acpi_generic_address *register_b);
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065/*******************************************************************************
66 *
67 * FUNCTION: acpi_hw_clear_acpi_status
68 *
Bob Moored8c71b62007-02-02 19:48:21 +030069 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 *
Bob Moore7db5d822008-12-30 11:04:48 +080071 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 *
73 * DESCRIPTION: Clears all fixed and general purpose status bits
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 *
75 ******************************************************************************/
Bob Moorec520aba2009-02-18 14:20:12 +080076
Bob Moored8c71b62007-02-02 19:48:21 +030077acpi_status acpi_hw_clear_acpi_status(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
Len Brown4be44fc2005-08-05 00:44:28 -040079 acpi_status status;
Bob Moore4c90ece2006-06-08 16:29:00 -040080 acpi_cpu_flags lock_flags = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Bob Mooreb229cf92006-04-21 17:15:00 -040082 ACPI_FUNCTION_TRACE(hw_clear_acpi_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Bob Moore227243a2009-02-18 14:24:50 +080084 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %0llX\n",
Len Brown4be44fc2005-08-05 00:44:28 -040085 ACPI_BITMASK_ALL_FIXED_STATUS,
Bob Moore227243a2009-02-18 14:24:50 +080086 acpi_gbl_xpm1a_status.address));
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Bob Moore4c90ece2006-06-08 16:29:00 -040088 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Bob Moore227243a2009-02-18 14:24:50 +080090 /* Clear the fixed events in PM1 A/B */
Bob Moore531c6332009-02-18 14:06:12 +080091
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +040092 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
Len Brown4be44fc2005-08-05 00:44:28 -040093 ACPI_BITMASK_ALL_FIXED_STATUS);
94 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 goto unlock_and_exit;
96 }
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
99
Bob Mooree97d6bf2008-12-30 09:45:17 +0800100 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
Len Brown4be44fc2005-08-05 00:44:28 -0400102 unlock_and_exit:
Bob Moore4c90ece2006-06-08 16:29:00 -0400103 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
Len Brown4be44fc2005-08-05 00:44:28 -0400104 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105}
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107/*******************************************************************************
108 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 * FUNCTION: acpi_hw_get_register_bit_mask
110 *
111 * PARAMETERS: register_id - Index of ACPI Register to access
112 *
Robert Moore44f6c012005-04-18 22:49:35 -0400113 * RETURN: The bitmask to be used when accessing the register
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 *
Robert Moore44f6c012005-04-18 22:49:35 -0400115 * DESCRIPTION: Map register_id into a register bitmask.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 *
117 ******************************************************************************/
Bob Moore7db5d822008-12-30 11:04:48 +0800118
Len Brown4be44fc2005-08-05 00:44:28 -0400119struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120{
Bob Moore4a90c7e2006-01-13 16:22:00 -0500121 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123 if (register_id > ACPI_BITREG_MAX) {
Bob Mooreb229cf92006-04-21 17:15:00 -0400124 ACPI_ERROR((AE_INFO, "Invalid BitRegister ID: %X",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500125 register_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 return (NULL);
127 }
128
129 return (&acpi_gbl_bit_register_info[register_id]);
130}
131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132/******************************************************************************
133 *
Bob Moore32c9ef92009-02-18 14:36:05 +0800134 * FUNCTION: acpi_hw_write_pm1_control
135 *
136 * PARAMETERS: pm1a_control - Value to be written to PM1A control
137 * pm1b_control - Value to be written to PM1B control
138 *
139 * RETURN: Status
140 *
141 * DESCRIPTION: Write the PM1 A/B control registers. These registers are
142 * different than than the PM1 A/B status and enable registers
143 * in that different values can be written to the A/B registers.
144 * Most notably, the SLP_TYP bits can be different, as per the
145 * values returned from the _Sx predefined methods.
146 *
147 ******************************************************************************/
148
149acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control)
150{
151 acpi_status status;
152
153 ACPI_FUNCTION_TRACE(hw_write_pm1_control);
154
155 status = acpi_write(pm1a_control, &acpi_gbl_FADT.xpm1a_control_block);
156 if (ACPI_FAILURE(status)) {
157 return_ACPI_STATUS(status);
158 }
159
160 if (acpi_gbl_FADT.xpm1b_control_block.address) {
161 status =
162 acpi_write(pm1b_control,
163 &acpi_gbl_FADT.xpm1b_control_block);
164 }
165 return_ACPI_STATUS(status);
166}
167
168/******************************************************************************
169 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 * FUNCTION: acpi_hw_register_read
171 *
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400172 * PARAMETERS: register_id - ACPI Register ID
Robert Moore44f6c012005-04-18 22:49:35 -0400173 * return_value - Where the register value is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 *
175 * RETURN: Status and the value read.
176 *
Bob Moore967440e2006-06-23 17:04:00 -0400177 * DESCRIPTION: Read from the specified ACPI register
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 *
179 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180acpi_status
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400181acpi_hw_register_read(u32 register_id, u32 * return_value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182{
Bob Moorec520aba2009-02-18 14:20:12 +0800183 u32 value = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400184 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
Bob Mooreb229cf92006-04-21 17:15:00 -0400186 ACPI_FUNCTION_TRACE(hw_register_read);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 switch (register_id) {
Bob Moorec520aba2009-02-18 14:20:12 +0800189 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
Bob Moorec520aba2009-02-18 14:20:12 +0800191 status = acpi_hw_read_multiple(&value,
192 &acpi_gbl_xpm1a_status,
193 &acpi_gbl_xpm1b_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 break;
195
Bob Moorec520aba2009-02-18 14:20:12 +0800196 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Bob Moorec520aba2009-02-18 14:20:12 +0800198 status = acpi_hw_read_multiple(&value,
199 &acpi_gbl_xpm1a_enable,
200 &acpi_gbl_xpm1b_enable);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 break;
202
Bob Moorec520aba2009-02-18 14:20:12 +0800203 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Bob Moorec520aba2009-02-18 14:20:12 +0800205 status = acpi_hw_read_multiple(&value,
206 &acpi_gbl_FADT.
207 xpm1a_control_block,
208 &acpi_gbl_FADT.
209 xpm1b_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 break;
211
Len Brown4be44fc2005-08-05 00:44:28 -0400212 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
Bob Moorec520aba2009-02-18 14:20:12 +0800214 status = acpi_read(&value, &acpi_gbl_FADT.xpm2_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 break;
216
Len Brown4be44fc2005-08-05 00:44:28 -0400217 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
Bob Moorec520aba2009-02-18 14:20:12 +0800219 status = acpi_read(&value, &acpi_gbl_FADT.xpm_timer_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 break;
221
Len Brown4be44fc2005-08-05 00:44:28 -0400222 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Bob Mooref3d2e782007-02-02 19:48:18 +0300224 status =
Bob Moorec520aba2009-02-18 14:20:12 +0800225 acpi_os_read_port(acpi_gbl_FADT.smi_command, &value, 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 break;
227
228 default:
Bob Mooreb8e4d892006-01-27 16:43:00 -0500229 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 status = AE_BAD_PARAMETER;
231 break;
232 }
233
Len Brown4be44fc2005-08-05 00:44:28 -0400234 if (ACPI_SUCCESS(status)) {
Bob Moorec520aba2009-02-18 14:20:12 +0800235 *return_value = value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 }
237
Len Brown4be44fc2005-08-05 00:44:28 -0400238 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239}
240
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241/******************************************************************************
242 *
243 * FUNCTION: acpi_hw_register_write
244 *
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400245 * PARAMETERS: register_id - ACPI Register ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 * Value - The value to write
247 *
248 * RETURN: Status
249 *
Bob Moore967440e2006-06-23 17:04:00 -0400250 * DESCRIPTION: Write to the specified ACPI register
251 *
252 * NOTE: In accordance with the ACPI specification, this function automatically
253 * preserves the value of the following bits, meaning that these bits cannot be
254 * changed via this interface:
255 *
256 * PM1_CONTROL[0] = SCI_EN
257 * PM1_CONTROL[9]
258 * PM1_STATUS[11]
259 *
260 * ACPI References:
261 * 1) Hardware Ignored Bits: When software writes to a register with ignored
262 * bit fields, it preserves the ignored bit fields
263 * 2) SCI_EN: OSPM always preserves this bit position
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 *
265 ******************************************************************************/
266
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400267acpi_status acpi_hw_register_write(u32 register_id, u32 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268{
Len Brown4be44fc2005-08-05 00:44:28 -0400269 acpi_status status;
Bob Moore967440e2006-06-23 17:04:00 -0400270 u32 read_value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Bob Mooreb229cf92006-04-21 17:15:00 -0400272 ACPI_FUNCTION_TRACE(hw_register_write);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 switch (register_id) {
Bob Moorec520aba2009-02-18 14:20:12 +0800275 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Bob Moore967440e2006-06-23 17:04:00 -0400277 /* Perform a read first to preserve certain bits (per ACPI spec) */
278
Bob Moorec520aba2009-02-18 14:20:12 +0800279 status = acpi_hw_read_multiple(&read_value,
280 &acpi_gbl_xpm1a_status,
281 &acpi_gbl_xpm1b_status);
Bob Moore967440e2006-06-23 17:04:00 -0400282 if (ACPI_FAILURE(status)) {
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400283 goto exit;
Bob Moore967440e2006-06-23 17:04:00 -0400284 }
285
286 /* Insert the bits to be preserved */
287
288 ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
289 read_value);
290
291 /* Now we can write the data */
292
Bob Moorec520aba2009-02-18 14:20:12 +0800293 status = acpi_hw_write_multiple(value,
294 &acpi_gbl_xpm1a_status,
295 &acpi_gbl_xpm1b_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 break;
297
Bob Moorec520aba2009-02-18 14:20:12 +0800298 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
Bob Moorec520aba2009-02-18 14:20:12 +0800300 status = acpi_hw_write_multiple(value,
301 &acpi_gbl_xpm1a_enable,
302 &acpi_gbl_xpm1b_enable);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 break;
304
Bob Moorec520aba2009-02-18 14:20:12 +0800305 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
Bob Moore967440e2006-06-23 17:04:00 -0400307 /*
308 * Perform a read first to preserve certain bits (per ACPI spec)
Bob Moorec520aba2009-02-18 14:20:12 +0800309 * Note: This includes SCI_EN, we never want to change this bit
Bob Moore967440e2006-06-23 17:04:00 -0400310 */
Bob Moorec520aba2009-02-18 14:20:12 +0800311 status = acpi_hw_read_multiple(&read_value,
312 &acpi_gbl_FADT.
313 xpm1a_control_block,
314 &acpi_gbl_FADT.
315 xpm1b_control_block);
Bob Moore967440e2006-06-23 17:04:00 -0400316 if (ACPI_FAILURE(status)) {
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400317 goto exit;
Bob Moore967440e2006-06-23 17:04:00 -0400318 }
319
320 /* Insert the bits to be preserved */
321
322 ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
323 read_value);
324
325 /* Now we can write the data */
326
Bob Moorec520aba2009-02-18 14:20:12 +0800327 status = acpi_hw_write_multiple(value,
328 &acpi_gbl_FADT.
329 xpm1a_control_block,
330 &acpi_gbl_FADT.
331 xpm1b_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 break;
333
Len Brown4be44fc2005-08-05 00:44:28 -0400334 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
Bob Mooreecfbbc72008-12-31 02:55:32 +0800336 status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 break;
338
Len Brown4be44fc2005-08-05 00:44:28 -0400339 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
Bob Mooreecfbbc72008-12-31 02:55:32 +0800341 status = acpi_write(value, &acpi_gbl_FADT.xpm_timer_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 break;
343
Len Brown4be44fc2005-08-05 00:44:28 -0400344 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
346 /* SMI_CMD is currently always in IO space */
347
Bob Mooref3d2e782007-02-02 19:48:18 +0300348 status =
349 acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 break;
351
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 default:
Bob Moorec520aba2009-02-18 14:20:12 +0800353 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 status = AE_BAD_PARAMETER;
355 break;
356 }
357
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400358 exit:
Len Brown4be44fc2005-08-05 00:44:28 -0400359 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360}
Bob Moorec520aba2009-02-18 14:20:12 +0800361
362/******************************************************************************
363 *
364 * FUNCTION: acpi_hw_read_multiple
365 *
366 * PARAMETERS: Value - Where the register value is returned
367 * register_a - First ACPI register (required)
368 * register_b - Second ACPI register (optional)
369 *
370 * RETURN: Status
371 *
372 * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B)
373 *
374 ******************************************************************************/
375
376static acpi_status
377acpi_hw_read_multiple(u32 *value,
378 struct acpi_generic_address *register_a,
379 struct acpi_generic_address *register_b)
380{
381 u32 value_a = 0;
382 u32 value_b = 0;
383 acpi_status status;
384
385 /* The first register is always required */
386
387 status = acpi_read(&value_a, register_a);
388 if (ACPI_FAILURE(status)) {
389 return (status);
390 }
391
392 /* Second register is optional */
393
394 if (register_b->address) {
395 status = acpi_read(&value_b, register_b);
396 if (ACPI_FAILURE(status)) {
397 return (status);
398 }
399 }
400
Bob Mooreaefc7f92009-02-18 14:26:02 +0800401 /*
402 * OR the two return values together. No shifting or masking is necessary,
403 * because of how the PM1 registers are defined in the ACPI specification:
404 *
405 * "Although the bits can be split between the two register blocks (each
406 * register block has a unique pointer within the FADT), the bit positions
407 * are maintained. The register block with unimplemented bits (that is,
408 * those implemented in the other register block) always returns zeros,
409 * and writes have no side effects"
410 */
411 *value = (value_a | value_b);
Bob Moorec520aba2009-02-18 14:20:12 +0800412 return (AE_OK);
413}
414
415/******************************************************************************
416 *
417 * FUNCTION: acpi_hw_write_multiple
418 *
419 * PARAMETERS: Value - The value to write
420 * register_a - First ACPI register (required)
421 * register_b - Second ACPI register (optional)
422 *
423 * RETURN: Status
424 *
425 * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B)
426 *
427 ******************************************************************************/
428
429static acpi_status
430acpi_hw_write_multiple(u32 value,
431 struct acpi_generic_address *register_a,
432 struct acpi_generic_address *register_b)
433{
434 acpi_status status;
435
436 /* The first register is always required */
437
438 status = acpi_write(value, register_a);
439 if (ACPI_FAILURE(status)) {
440 return (status);
441 }
442
Bob Mooreaefc7f92009-02-18 14:26:02 +0800443 /*
444 * Second register is optional
445 *
446 * No bit shifting or clearing is necessary, because of how the PM1
447 * registers are defined in the ACPI specification:
448 *
449 * "Although the bits can be split between the two register blocks (each
450 * register block has a unique pointer within the FADT), the bit positions
451 * are maintained. The register block with unimplemented bits (that is,
452 * those implemented in the other register block) always returns zeros,
453 * and writes have no side effects"
454 */
Bob Moorec520aba2009-02-18 14:20:12 +0800455 if (register_b->address) {
Bob Mooreaefc7f92009-02-18 14:26:02 +0800456 status = acpi_write(value, register_b);
Bob Moorec520aba2009-02-18 14:20:12 +0800457 }
458
459 return (status);
460}