blob: 9c8162128c2b943b2d970c6f13e699d367e9cdf3 [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 *
134 * FUNCTION: acpi_hw_register_read
135 *
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400136 * PARAMETERS: register_id - ACPI Register ID
Robert Moore44f6c012005-04-18 22:49:35 -0400137 * return_value - Where the register value is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 *
139 * RETURN: Status and the value read.
140 *
Bob Moore967440e32006-06-23 17:04:00 -0400141 * DESCRIPTION: Read from the specified ACPI register
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 *
143 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144acpi_status
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400145acpi_hw_register_read(u32 register_id, u32 * return_value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146{
Bob Moorec520aba2009-02-18 14:20:12 +0800147 u32 value = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400148 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Bob Mooreb229cf92006-04-21 17:15:00 -0400150 ACPI_FUNCTION_TRACE(hw_register_read);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 switch (register_id) {
Bob Moorec520aba2009-02-18 14:20:12 +0800153 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
Bob Moorec520aba2009-02-18 14:20:12 +0800155 status = acpi_hw_read_multiple(&value,
156 &acpi_gbl_xpm1a_status,
157 &acpi_gbl_xpm1b_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 break;
159
Bob Moorec520aba2009-02-18 14:20:12 +0800160 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Bob Moorec520aba2009-02-18 14:20:12 +0800162 status = acpi_hw_read_multiple(&value,
163 &acpi_gbl_xpm1a_enable,
164 &acpi_gbl_xpm1b_enable);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 break;
166
Bob Moorec520aba2009-02-18 14:20:12 +0800167 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
Bob Moorec520aba2009-02-18 14:20:12 +0800169 status = acpi_hw_read_multiple(&value,
170 &acpi_gbl_FADT.
171 xpm1a_control_block,
172 &acpi_gbl_FADT.
173 xpm1b_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 break;
175
Len Brown4be44fc2005-08-05 00:44:28 -0400176 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
Bob Moorec520aba2009-02-18 14:20:12 +0800178 status = acpi_read(&value, &acpi_gbl_FADT.xpm2_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 break;
180
Len Brown4be44fc2005-08-05 00:44:28 -0400181 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
Bob Moorec520aba2009-02-18 14:20:12 +0800183 status = acpi_read(&value, &acpi_gbl_FADT.xpm_timer_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 break;
185
Len Brown4be44fc2005-08-05 00:44:28 -0400186 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
Bob Mooref3d2e782007-02-02 19:48:18 +0300188 status =
Bob Moorec520aba2009-02-18 14:20:12 +0800189 acpi_os_read_port(acpi_gbl_FADT.smi_command, &value, 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 break;
191
192 default:
Bob Mooreb8e4d892006-01-27 16:43:00 -0500193 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 status = AE_BAD_PARAMETER;
195 break;
196 }
197
Len Brown4be44fc2005-08-05 00:44:28 -0400198 if (ACPI_SUCCESS(status)) {
Bob Moorec520aba2009-02-18 14:20:12 +0800199 *return_value = value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 }
201
Len Brown4be44fc2005-08-05 00:44:28 -0400202 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203}
204
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205/******************************************************************************
206 *
207 * FUNCTION: acpi_hw_register_write
208 *
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400209 * PARAMETERS: register_id - ACPI Register ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 * Value - The value to write
211 *
212 * RETURN: Status
213 *
Bob Moore967440e32006-06-23 17:04:00 -0400214 * DESCRIPTION: Write to the specified ACPI register
215 *
216 * NOTE: In accordance with the ACPI specification, this function automatically
217 * preserves the value of the following bits, meaning that these bits cannot be
218 * changed via this interface:
219 *
220 * PM1_CONTROL[0] = SCI_EN
221 * PM1_CONTROL[9]
222 * PM1_STATUS[11]
223 *
224 * ACPI References:
225 * 1) Hardware Ignored Bits: When software writes to a register with ignored
226 * bit fields, it preserves the ignored bit fields
227 * 2) SCI_EN: OSPM always preserves this bit position
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 *
229 ******************************************************************************/
230
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400231acpi_status acpi_hw_register_write(u32 register_id, u32 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232{
Len Brown4be44fc2005-08-05 00:44:28 -0400233 acpi_status status;
Bob Moore967440e32006-06-23 17:04:00 -0400234 u32 read_value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Bob Mooreb229cf92006-04-21 17:15:00 -0400236 ACPI_FUNCTION_TRACE(hw_register_write);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 switch (register_id) {
Bob Moorec520aba2009-02-18 14:20:12 +0800239 case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
Bob Moore967440e32006-06-23 17:04:00 -0400241 /* Perform a read first to preserve certain bits (per ACPI spec) */
242
Bob Moorec520aba2009-02-18 14:20:12 +0800243 status = acpi_hw_read_multiple(&read_value,
244 &acpi_gbl_xpm1a_status,
245 &acpi_gbl_xpm1b_status);
Bob Moore967440e32006-06-23 17:04:00 -0400246 if (ACPI_FAILURE(status)) {
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400247 goto exit;
Bob Moore967440e32006-06-23 17:04:00 -0400248 }
249
250 /* Insert the bits to be preserved */
251
252 ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
253 read_value);
254
255 /* Now we can write the data */
256
Bob Moorec520aba2009-02-18 14:20:12 +0800257 status = acpi_hw_write_multiple(value,
258 &acpi_gbl_xpm1a_status,
259 &acpi_gbl_xpm1b_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 break;
261
Bob Moorec520aba2009-02-18 14:20:12 +0800262 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
Bob Moorec520aba2009-02-18 14:20:12 +0800264 status = acpi_hw_write_multiple(value,
265 &acpi_gbl_xpm1a_enable,
266 &acpi_gbl_xpm1b_enable);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 break;
268
Bob Moorec520aba2009-02-18 14:20:12 +0800269 case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Bob Moore967440e32006-06-23 17:04:00 -0400271 /*
272 * Perform a read first to preserve certain bits (per ACPI spec)
Bob Moorec520aba2009-02-18 14:20:12 +0800273 * Note: This includes SCI_EN, we never want to change this bit
Bob Moore967440e32006-06-23 17:04:00 -0400274 */
Bob Moorec520aba2009-02-18 14:20:12 +0800275 status = acpi_hw_read_multiple(&read_value,
276 &acpi_gbl_FADT.
277 xpm1a_control_block,
278 &acpi_gbl_FADT.
279 xpm1b_control_block);
Bob Moore967440e32006-06-23 17:04:00 -0400280 if (ACPI_FAILURE(status)) {
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400281 goto exit;
Bob Moore967440e32006-06-23 17:04:00 -0400282 }
283
284 /* Insert the bits to be preserved */
285
286 ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
287 read_value);
288
289 /* Now we can write the data */
290
Bob Moorec520aba2009-02-18 14:20:12 +0800291 status = acpi_hw_write_multiple(value,
292 &acpi_gbl_FADT.
293 xpm1a_control_block,
294 &acpi_gbl_FADT.
295 xpm1b_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 break;
297
Len Brown4be44fc2005-08-05 00:44:28 -0400298 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
Bob Mooreecfbbc72008-12-31 02:55:32 +0800300 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 break;
302
Len Brown4be44fc2005-08-05 00:44:28 -0400303 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Bob Mooreecfbbc72008-12-31 02:55:32 +0800305 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 break;
307
Len Brown4be44fc2005-08-05 00:44:28 -0400308 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
Bob Mooreecfbbc72008-12-31 02:55:32 +0800310 status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 break;
312
Len Brown4be44fc2005-08-05 00:44:28 -0400313 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
Bob Mooreecfbbc72008-12-31 02:55:32 +0800315 status = acpi_write(value, &acpi_gbl_FADT.xpm_timer_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 break;
317
Len Brown4be44fc2005-08-05 00:44:28 -0400318 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
320 /* SMI_CMD is currently always in IO space */
321
Bob Mooref3d2e782007-02-02 19:48:18 +0300322 status =
323 acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 break;
325
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 default:
Bob Moorec520aba2009-02-18 14:20:12 +0800327 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 status = AE_BAD_PARAMETER;
329 break;
330 }
331
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400332 exit:
Len Brown4be44fc2005-08-05 00:44:28 -0400333 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334}
Bob Moorec520aba2009-02-18 14:20:12 +0800335
336/******************************************************************************
337 *
338 * FUNCTION: acpi_hw_read_multiple
339 *
340 * PARAMETERS: Value - Where the register value is returned
341 * register_a - First ACPI register (required)
342 * register_b - Second ACPI register (optional)
343 *
344 * RETURN: Status
345 *
346 * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B)
347 *
348 ******************************************************************************/
349
350static acpi_status
351acpi_hw_read_multiple(u32 *value,
352 struct acpi_generic_address *register_a,
353 struct acpi_generic_address *register_b)
354{
355 u32 value_a = 0;
356 u32 value_b = 0;
357 acpi_status status;
358
359 /* The first register is always required */
360
361 status = acpi_read(&value_a, register_a);
362 if (ACPI_FAILURE(status)) {
363 return (status);
364 }
365
366 /* Second register is optional */
367
368 if (register_b->address) {
369 status = acpi_read(&value_b, register_b);
370 if (ACPI_FAILURE(status)) {
371 return (status);
372 }
373 }
374
375 /* Shift the B bits above the A bits */
376
377 *value = value_a | (value_b << register_a->bit_width);
378 return (AE_OK);
379}
380
381/******************************************************************************
382 *
383 * FUNCTION: acpi_hw_write_multiple
384 *
385 * PARAMETERS: Value - The value to write
386 * register_a - First ACPI register (required)
387 * register_b - Second ACPI register (optional)
388 *
389 * RETURN: Status
390 *
391 * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B)
392 *
393 ******************************************************************************/
394
395static acpi_status
396acpi_hw_write_multiple(u32 value,
397 struct acpi_generic_address *register_a,
398 struct acpi_generic_address *register_b)
399{
400 acpi_status status;
401
402 /* The first register is always required */
403
404 status = acpi_write(value, register_a);
405 if (ACPI_FAILURE(status)) {
406 return (status);
407 }
408
409 /* Second register is optional */
410
411 if (register_b->address) {
412
413 /* Normalize the B bits before write */
414
415 status = acpi_write(value >> register_a->bit_width, register_b);
416 }
417
418 return (status);
419}