xref: /onnv-gate/usr/src/uts/intel/io/acpica/hardware/hwregs.c (revision 11225:eb6056029d84)
13446Smrj 
23446Smrj /*******************************************************************************
33446Smrj  *
43446Smrj  * Module Name: hwregs - Read/write access functions for the various ACPI
53446Smrj  *                       control and status registers.
63446Smrj  *
73446Smrj  ******************************************************************************/
83446Smrj 
93446Smrj /******************************************************************************
103446Smrj  *
113446Smrj  * 1. Copyright Notice
123446Smrj  *
139980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
143446Smrj  * All rights reserved.
153446Smrj  *
163446Smrj  * 2. License
173446Smrj  *
183446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
193446Smrj  * rights.  You may have additional license terms from the party that provided
203446Smrj  * you this software, covering your right to use that party's intellectual
213446Smrj  * property rights.
223446Smrj  *
233446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
243446Smrj  * copy of the source code appearing in this file ("Covered Code") an
253446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
263446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
273446Smrj  * make derivatives, distribute, use and display any portion of the Covered
283446Smrj  * Code in any form, with the right to sublicense such rights; and
293446Smrj  *
303446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
313446Smrj  * license (with the right to sublicense), under only those claims of Intel
323446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
333446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
343446Smrj  * solely to the minimum extent necessary to exercise the above copyright
353446Smrj  * license, and in no event shall the patent license extend to any additions
363446Smrj  * to or modifications of the Original Intel Code.  No other license or right
373446Smrj  * is granted directly or by implication, estoppel or otherwise;
383446Smrj  *
393446Smrj  * The above copyright and patent license is granted only if the following
403446Smrj  * conditions are met:
413446Smrj  *
423446Smrj  * 3. Conditions
433446Smrj  *
443446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
453446Smrj  * Redistribution of source code of any substantial portion of the Covered
463446Smrj  * Code or modification with rights to further distribute source must include
473446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
483446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
493446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
503446Smrj  * contain a file documenting the changes Licensee made to create that Covered
513446Smrj  * Code and the date of any change.  Licensee must include in that file the
523446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
533446Smrj  * must include a prominent statement that the modification is derived,
543446Smrj  * directly or indirectly, from Original Intel Code.
553446Smrj  *
563446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
573446Smrj  * Redistribution of source code of any substantial portion of the Covered
583446Smrj  * Code or modification without rights to further distribute source must
593446Smrj  * include the following Disclaimer and Export Compliance provision in the
603446Smrj  * documentation and/or other materials provided with distribution.  In
613446Smrj  * addition, Licensee may not authorize further sublicense of source of any
623446Smrj  * portion of the Covered Code, and must include terms to the effect that the
633446Smrj  * license from Licensee to its licensee is limited to the intellectual
643446Smrj  * property embodied in the software Licensee provides to its licensee, and
653446Smrj  * not to intellectual property embodied in modifications its licensee may
663446Smrj  * make.
673446Smrj  *
683446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
693446Smrj  * substantial portion of the Covered Code or modification must reproduce the
703446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
713446Smrj  * provision in the documentation and/or other materials provided with the
723446Smrj  * distribution.
733446Smrj  *
743446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
753446Smrj  * Intel Code.
763446Smrj  *
773446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
783446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
793446Smrj  * other dealings in products derived from or relating to the Covered Code
803446Smrj  * without prior written authorization from Intel.
813446Smrj  *
823446Smrj  * 4. Disclaimer and Export Compliance
833446Smrj  *
843446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
853446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
863446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
873446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
883446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
893446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
903446Smrj  * PARTICULAR PURPOSE.
913446Smrj  *
923446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
933446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
943446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
953446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
963446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
973446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
983446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
993446Smrj  * LIMITED REMEDY.
1003446Smrj  *
1013446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1023446Smrj  * software or system incorporating such software without first obtaining any
1033446Smrj  * required license or other approval from the U. S. Department of Commerce or
1043446Smrj  * any other agency or department of the United States Government.  In the
1053446Smrj  * event Licensee exports any such software from the United States or
1063446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1073446Smrj  * ensure that the distribution and export/re-export of the software is in
1083446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1093446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1103446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1113446Smrj  * software, or service, directly or indirectly, to any country for which the
1123446Smrj  * United States government or any agency thereof requires an export license,
1133446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1143446Smrj  * such license, approval or letter.
1153446Smrj  *
1163446Smrj  *****************************************************************************/
1173446Smrj 
1183446Smrj #define __HWREGS_C__
1193446Smrj 
1203446Smrj #include "acpi.h"
1219980SDana.Myers@Sun.COM #include "accommon.h"
1223446Smrj #include "acevents.h"
1233446Smrj 
1243446Smrj #define _COMPONENT          ACPI_HARDWARE
1253446Smrj         ACPI_MODULE_NAME    ("hwregs")
1263446Smrj 
1273446Smrj 
1289980SDana.Myers@Sun.COM /* Local Prototypes */
1299980SDana.Myers@Sun.COM 
1309980SDana.Myers@Sun.COM static ACPI_STATUS
1319980SDana.Myers@Sun.COM AcpiHwReadMultiple (
1329980SDana.Myers@Sun.COM     UINT32                  *Value,
1339980SDana.Myers@Sun.COM     ACPI_GENERIC_ADDRESS    *RegisterA,
1349980SDana.Myers@Sun.COM     ACPI_GENERIC_ADDRESS    *RegisterB);
1359980SDana.Myers@Sun.COM 
1369980SDana.Myers@Sun.COM static ACPI_STATUS
1379980SDana.Myers@Sun.COM AcpiHwWriteMultiple (
1389980SDana.Myers@Sun.COM     UINT32                  Value,
1399980SDana.Myers@Sun.COM     ACPI_GENERIC_ADDRESS    *RegisterA,
1409980SDana.Myers@Sun.COM     ACPI_GENERIC_ADDRESS    *RegisterB);
1419980SDana.Myers@Sun.COM 
1429980SDana.Myers@Sun.COM 
14310457SSaurabh.Mishra@Sun.COM /******************************************************************************
14410457SSaurabh.Mishra@Sun.COM  *
14510457SSaurabh.Mishra@Sun.COM  * FUNCTION:    AcpiHwValidateRegister
14610457SSaurabh.Mishra@Sun.COM  *
14710457SSaurabh.Mishra@Sun.COM  * PARAMETERS:  Reg                 - GAS register structure
14810457SSaurabh.Mishra@Sun.COM  *              MaxBitWidth         - Max BitWidth supported (32 or 64)
14910457SSaurabh.Mishra@Sun.COM  *              Address             - Pointer to where the gas->address
15010457SSaurabh.Mishra@Sun.COM  *                                    is returned
15110457SSaurabh.Mishra@Sun.COM  *
15210457SSaurabh.Mishra@Sun.COM  * RETURN:      Status
15310457SSaurabh.Mishra@Sun.COM  *
15410457SSaurabh.Mishra@Sun.COM  * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS
15510457SSaurabh.Mishra@Sun.COM  *              pointer, Address, SpaceId, BitWidth, and BitOffset.
15610457SSaurabh.Mishra@Sun.COM  *
15710457SSaurabh.Mishra@Sun.COM  ******************************************************************************/
15810457SSaurabh.Mishra@Sun.COM 
15910457SSaurabh.Mishra@Sun.COM ACPI_STATUS
AcpiHwValidateRegister(ACPI_GENERIC_ADDRESS * Reg,UINT8 MaxBitWidth,UINT64 * Address)16010457SSaurabh.Mishra@Sun.COM AcpiHwValidateRegister (
16110457SSaurabh.Mishra@Sun.COM     ACPI_GENERIC_ADDRESS    *Reg,
16210457SSaurabh.Mishra@Sun.COM     UINT8                   MaxBitWidth,
16310457SSaurabh.Mishra@Sun.COM     UINT64                  *Address)
16410457SSaurabh.Mishra@Sun.COM {
16510457SSaurabh.Mishra@Sun.COM 
16610457SSaurabh.Mishra@Sun.COM     /* Must have a valid pointer to a GAS structure */
16710457SSaurabh.Mishra@Sun.COM 
16810457SSaurabh.Mishra@Sun.COM     if (!Reg)
16910457SSaurabh.Mishra@Sun.COM     {
170*11225SDana.Myers@Sun.COM         return (AE_BAD_PARAMETER);
17110457SSaurabh.Mishra@Sun.COM     }
17210457SSaurabh.Mishra@Sun.COM 
17310457SSaurabh.Mishra@Sun.COM     /*
17410457SSaurabh.Mishra@Sun.COM      * Copy the target address. This handles possible alignment issues.
17510457SSaurabh.Mishra@Sun.COM      * Address must not be null. A null address also indicates an optional
17610457SSaurabh.Mishra@Sun.COM      * ACPI register that is not supported, so no error message.
17710457SSaurabh.Mishra@Sun.COM      */
17810457SSaurabh.Mishra@Sun.COM     ACPI_MOVE_64_TO_64 (Address, &Reg->Address);
17910457SSaurabh.Mishra@Sun.COM     if (!(*Address))
18010457SSaurabh.Mishra@Sun.COM     {
181*11225SDana.Myers@Sun.COM         return (AE_BAD_ADDRESS);
18210457SSaurabh.Mishra@Sun.COM     }
18310457SSaurabh.Mishra@Sun.COM 
18410457SSaurabh.Mishra@Sun.COM     /* Validate the SpaceID */
18510457SSaurabh.Mishra@Sun.COM 
18610457SSaurabh.Mishra@Sun.COM     if ((Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
187*11225SDana.Myers@Sun.COM         (Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
18810457SSaurabh.Mishra@Sun.COM     {
189*11225SDana.Myers@Sun.COM         ACPI_ERROR ((AE_INFO,
19010457SSaurabh.Mishra@Sun.COM             "Unsupported address space: 0x%X", Reg->SpaceId));
191*11225SDana.Myers@Sun.COM         return (AE_SUPPORT);
19210457SSaurabh.Mishra@Sun.COM     }
19310457SSaurabh.Mishra@Sun.COM 
19410457SSaurabh.Mishra@Sun.COM     /* Validate the BitWidth */
19510457SSaurabh.Mishra@Sun.COM 
19610457SSaurabh.Mishra@Sun.COM     if ((Reg->BitWidth != 8) &&
197*11225SDana.Myers@Sun.COM         (Reg->BitWidth != 16) &&
198*11225SDana.Myers@Sun.COM         (Reg->BitWidth != 32) &&
199*11225SDana.Myers@Sun.COM         (Reg->BitWidth != MaxBitWidth))
20010457SSaurabh.Mishra@Sun.COM     {
201*11225SDana.Myers@Sun.COM         ACPI_ERROR ((AE_INFO,
20210457SSaurabh.Mishra@Sun.COM             "Unsupported register bit width: 0x%X", Reg->BitWidth));
203*11225SDana.Myers@Sun.COM         return (AE_SUPPORT);
20410457SSaurabh.Mishra@Sun.COM     }
20510457SSaurabh.Mishra@Sun.COM 
20610457SSaurabh.Mishra@Sun.COM     /* Validate the BitOffset. Just a warning for now. */
20710457SSaurabh.Mishra@Sun.COM 
20810457SSaurabh.Mishra@Sun.COM     if (Reg->BitOffset != 0)
20910457SSaurabh.Mishra@Sun.COM     {
210*11225SDana.Myers@Sun.COM         ACPI_WARNING ((AE_INFO,
21110457SSaurabh.Mishra@Sun.COM             "Unsupported register bit offset: 0x%X", Reg->BitOffset));
21210457SSaurabh.Mishra@Sun.COM     }
21310457SSaurabh.Mishra@Sun.COM 
21410457SSaurabh.Mishra@Sun.COM     return (AE_OK);
21510457SSaurabh.Mishra@Sun.COM }
21610457SSaurabh.Mishra@Sun.COM 
21710457SSaurabh.Mishra@Sun.COM 
21810457SSaurabh.Mishra@Sun.COM /******************************************************************************
21910457SSaurabh.Mishra@Sun.COM  *
220*11225SDana.Myers@Sun.COM  * FUNCTION:    AcpiHwRead
221*11225SDana.Myers@Sun.COM  *
222*11225SDana.Myers@Sun.COM  * PARAMETERS:  Value               - Where the value is returned
223*11225SDana.Myers@Sun.COM  *              Reg                 - GAS register structure
224*11225SDana.Myers@Sun.COM  *
225*11225SDana.Myers@Sun.COM  * RETURN:      Status
226*11225SDana.Myers@Sun.COM  *
227*11225SDana.Myers@Sun.COM  * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max
228*11225SDana.Myers@Sun.COM  *              version of AcpiRead, used internally since the overhead of
229*11225SDana.Myers@Sun.COM  *              64-bit values is not needed.
230*11225SDana.Myers@Sun.COM  *
231*11225SDana.Myers@Sun.COM  * LIMITATIONS: <These limitations also apply to AcpiHwWrite>
232*11225SDana.Myers@Sun.COM  *      BitWidth must be exactly 8, 16, or 32.
233*11225SDana.Myers@Sun.COM  *      SpaceID must be SystemMemory or SystemIO.
234*11225SDana.Myers@Sun.COM  *      BitOffset and AccessWidth are currently ignored, as there has
235*11225SDana.Myers@Sun.COM  *          not been a need to implement these.
236*11225SDana.Myers@Sun.COM  *
237*11225SDana.Myers@Sun.COM  ******************************************************************************/
238*11225SDana.Myers@Sun.COM 
239*11225SDana.Myers@Sun.COM ACPI_STATUS
AcpiHwRead(UINT32 * Value,ACPI_GENERIC_ADDRESS * Reg)240*11225SDana.Myers@Sun.COM AcpiHwRead (
241*11225SDana.Myers@Sun.COM     UINT32                  *Value,
242*11225SDana.Myers@Sun.COM     ACPI_GENERIC_ADDRESS    *Reg)
243*11225SDana.Myers@Sun.COM {
244*11225SDana.Myers@Sun.COM     UINT64                  Address;
245*11225SDana.Myers@Sun.COM     ACPI_STATUS             Status;
246*11225SDana.Myers@Sun.COM 
247*11225SDana.Myers@Sun.COM 
248*11225SDana.Myers@Sun.COM     ACPI_FUNCTION_NAME (HwRead);
249*11225SDana.Myers@Sun.COM 
250*11225SDana.Myers@Sun.COM 
251*11225SDana.Myers@Sun.COM     /* Validate contents of the GAS register */
252*11225SDana.Myers@Sun.COM 
253*11225SDana.Myers@Sun.COM     Status = AcpiHwValidateRegister (Reg, 32, &Address);
254*11225SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
255*11225SDana.Myers@Sun.COM     {
256*11225SDana.Myers@Sun.COM         return (Status);
257*11225SDana.Myers@Sun.COM     }
258*11225SDana.Myers@Sun.COM 
259*11225SDana.Myers@Sun.COM     /* Initialize entire 32-bit return value to zero */
260*11225SDana.Myers@Sun.COM 
261*11225SDana.Myers@Sun.COM     *Value = 0;
262*11225SDana.Myers@Sun.COM 
263*11225SDana.Myers@Sun.COM     /*
264*11225SDana.Myers@Sun.COM      * Two address spaces supported: Memory or IO. PCI_Config is
265*11225SDana.Myers@Sun.COM      * not supported here because the GAS structure is insufficient
266*11225SDana.Myers@Sun.COM      */
267*11225SDana.Myers@Sun.COM     if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
268*11225SDana.Myers@Sun.COM     {
269*11225SDana.Myers@Sun.COM         Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
270*11225SDana.Myers@Sun.COM                     Address, Value, Reg->BitWidth);
271*11225SDana.Myers@Sun.COM     }
272*11225SDana.Myers@Sun.COM     else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
273*11225SDana.Myers@Sun.COM     {
274*11225SDana.Myers@Sun.COM         Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
275*11225SDana.Myers@Sun.COM                     Address, Value, Reg->BitWidth);
276*11225SDana.Myers@Sun.COM     }
277*11225SDana.Myers@Sun.COM 
278*11225SDana.Myers@Sun.COM     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
279*11225SDana.Myers@Sun.COM         "Read:  %8.8X width %2d from %8.8X%8.8X (%s)\n",
280*11225SDana.Myers@Sun.COM         *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
281*11225SDana.Myers@Sun.COM         AcpiUtGetRegionName (Reg->SpaceId)));
282*11225SDana.Myers@Sun.COM 
283*11225SDana.Myers@Sun.COM     return (Status);
284*11225SDana.Myers@Sun.COM }
285*11225SDana.Myers@Sun.COM 
286*11225SDana.Myers@Sun.COM 
287*11225SDana.Myers@Sun.COM /******************************************************************************
288*11225SDana.Myers@Sun.COM  *
28910457SSaurabh.Mishra@Sun.COM  * FUNCTION:    AcpiHwWrite
29010457SSaurabh.Mishra@Sun.COM  *
29110457SSaurabh.Mishra@Sun.COM  * PARAMETERS:  Value               - Value to be written
29210457SSaurabh.Mishra@Sun.COM  *              Reg                 - GAS register structure
29310457SSaurabh.Mishra@Sun.COM  *
29410457SSaurabh.Mishra@Sun.COM  * RETURN:      Status
29510457SSaurabh.Mishra@Sun.COM  *
29610457SSaurabh.Mishra@Sun.COM  * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max
29710457SSaurabh.Mishra@Sun.COM  *              version of AcpiWrite, used internally since the overhead of
29810457SSaurabh.Mishra@Sun.COM  *              64-bit values is not needed.
29910457SSaurabh.Mishra@Sun.COM  *
30010457SSaurabh.Mishra@Sun.COM  ******************************************************************************/
30110457SSaurabh.Mishra@Sun.COM 
30210457SSaurabh.Mishra@Sun.COM ACPI_STATUS
AcpiHwWrite(UINT32 Value,ACPI_GENERIC_ADDRESS * Reg)30310457SSaurabh.Mishra@Sun.COM AcpiHwWrite (
30410457SSaurabh.Mishra@Sun.COM     UINT32                  Value,
30510457SSaurabh.Mishra@Sun.COM     ACPI_GENERIC_ADDRESS    *Reg)
30610457SSaurabh.Mishra@Sun.COM {
30710457SSaurabh.Mishra@Sun.COM     UINT64                  Address;
30810457SSaurabh.Mishra@Sun.COM     ACPI_STATUS             Status;
30910457SSaurabh.Mishra@Sun.COM 
31010457SSaurabh.Mishra@Sun.COM 
31110457SSaurabh.Mishra@Sun.COM     ACPI_FUNCTION_NAME (HwWrite);
31210457SSaurabh.Mishra@Sun.COM 
31310457SSaurabh.Mishra@Sun.COM 
31410457SSaurabh.Mishra@Sun.COM     /* Validate contents of the GAS register */
31510457SSaurabh.Mishra@Sun.COM 
31610457SSaurabh.Mishra@Sun.COM     Status = AcpiHwValidateRegister (Reg, 32, &Address);
31710457SSaurabh.Mishra@Sun.COM     if (ACPI_FAILURE (Status))
31810457SSaurabh.Mishra@Sun.COM     {
31910457SSaurabh.Mishra@Sun.COM         return (Status);
32010457SSaurabh.Mishra@Sun.COM     }
32110457SSaurabh.Mishra@Sun.COM 
32210457SSaurabh.Mishra@Sun.COM     /*
32310457SSaurabh.Mishra@Sun.COM      * Two address spaces supported: Memory or IO. PCI_Config is
32410457SSaurabh.Mishra@Sun.COM      * not supported here because the GAS structure is insufficient
32510457SSaurabh.Mishra@Sun.COM      */
32610457SSaurabh.Mishra@Sun.COM     if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
32710457SSaurabh.Mishra@Sun.COM     {
32810457SSaurabh.Mishra@Sun.COM         Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
32910457SSaurabh.Mishra@Sun.COM                     Address, Value, Reg->BitWidth);
33010457SSaurabh.Mishra@Sun.COM     }
33110457SSaurabh.Mishra@Sun.COM     else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
33210457SSaurabh.Mishra@Sun.COM     {
333*11225SDana.Myers@Sun.COM         Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
33410457SSaurabh.Mishra@Sun.COM                     Address, Value, Reg->BitWidth);
33510457SSaurabh.Mishra@Sun.COM     }
33610457SSaurabh.Mishra@Sun.COM 
33710457SSaurabh.Mishra@Sun.COM     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
338*11225SDana.Myers@Sun.COM         "Wrote: %8.8X width %2d   to %8.8X%8.8X (%s)\n",
339*11225SDana.Myers@Sun.COM         Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
340*11225SDana.Myers@Sun.COM         AcpiUtGetRegionName (Reg->SpaceId)));
34110457SSaurabh.Mishra@Sun.COM 
34210457SSaurabh.Mishra@Sun.COM     return (Status);
34310457SSaurabh.Mishra@Sun.COM }
34410457SSaurabh.Mishra@Sun.COM 
34510457SSaurabh.Mishra@Sun.COM 
3463446Smrj /*******************************************************************************
3473446Smrj  *
3483446Smrj  * FUNCTION:    AcpiHwClearAcpiStatus
3493446Smrj  *
3507851SDana.Myers@Sun.COM  * PARAMETERS:  None
3513446Smrj  *
3529980SDana.Myers@Sun.COM  * RETURN:      Status
3533446Smrj  *
3543446Smrj  * DESCRIPTION: Clears all fixed and general purpose status bits
3553446Smrj  *
3563446Smrj  ******************************************************************************/
3573446Smrj 
3583446Smrj ACPI_STATUS
AcpiHwClearAcpiStatus(void)3593446Smrj AcpiHwClearAcpiStatus (
3607851SDana.Myers@Sun.COM     void)
3613446Smrj {
3623446Smrj     ACPI_STATUS             Status;
3633446Smrj     ACPI_CPU_FLAGS          LockFlags = 0;
3643446Smrj 
3653446Smrj 
3663446Smrj     ACPI_FUNCTION_TRACE (HwClearAcpiStatus);
3673446Smrj 
3683446Smrj 
3699980SDana.Myers@Sun.COM     ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n",
3703446Smrj         ACPI_BITMASK_ALL_FIXED_STATUS,
3719980SDana.Myers@Sun.COM         ACPI_FORMAT_UINT64 (AcpiGbl_XPm1aStatus.Address)));
3723446Smrj 
3733446Smrj     LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
3743446Smrj 
3759980SDana.Myers@Sun.COM     /* Clear the fixed events in PM1 A/B */
3769980SDana.Myers@Sun.COM 
3777851SDana.Myers@Sun.COM     Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS,
3783446Smrj                 ACPI_BITMASK_ALL_FIXED_STATUS);
3793446Smrj     if (ACPI_FAILURE (Status))
3803446Smrj     {
3813446Smrj         goto UnlockAndExit;
3823446Smrj     }
3833446Smrj 
3843446Smrj     /* Clear the GPE Bits in all GPE registers in all GPE blocks */
3853446Smrj 
3869980SDana.Myers@Sun.COM     Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
3873446Smrj 
3883446Smrj UnlockAndExit:
3893446Smrj     AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
3903446Smrj     return_ACPI_STATUS (Status);
3913446Smrj }
3923446Smrj 
3933446Smrj 
3943446Smrj /*******************************************************************************
3953446Smrj  *
3963446Smrj  * FUNCTION:    AcpiHwGetRegisterBitMask
3973446Smrj  *
3983446Smrj  * PARAMETERS:  RegisterId          - Index of ACPI Register to access
3993446Smrj  *
4003446Smrj  * RETURN:      The bitmask to be used when accessing the register
4013446Smrj  *
4023446Smrj  * DESCRIPTION: Map RegisterId into a register bitmask.
4033446Smrj  *
4043446Smrj  ******************************************************************************/
4053446Smrj 
4063446Smrj ACPI_BIT_REGISTER_INFO *
AcpiHwGetBitRegisterInfo(UINT32 RegisterId)4073446Smrj AcpiHwGetBitRegisterInfo (
4083446Smrj     UINT32                  RegisterId)
4093446Smrj {
4103446Smrj     ACPI_FUNCTION_ENTRY ();
4113446Smrj 
4123446Smrj 
4133446Smrj     if (RegisterId > ACPI_BITREG_MAX)
4143446Smrj     {
4153446Smrj         ACPI_ERROR ((AE_INFO, "Invalid BitRegister ID: %X", RegisterId));
4163446Smrj         return (NULL);
4173446Smrj     }
4183446Smrj 
4193446Smrj     return (&AcpiGbl_BitRegisterInfo[RegisterId]);
4203446Smrj }
4213446Smrj 
4223446Smrj 
4239980SDana.Myers@Sun.COM /******************************************************************************
4243446Smrj  *
4259980SDana.Myers@Sun.COM  * FUNCTION:    AcpiHwWritePm1Control
4267851SDana.Myers@Sun.COM  *
4279980SDana.Myers@Sun.COM  * PARAMETERS:  Pm1aControl         - Value to be written to PM1A control
4289980SDana.Myers@Sun.COM  *              Pm1bControl         - Value to be written to PM1B control
4293446Smrj  *
4303446Smrj  * RETURN:      Status
4313446Smrj  *
4329980SDana.Myers@Sun.COM  * DESCRIPTION: Write the PM1 A/B control registers. These registers are
4339980SDana.Myers@Sun.COM  *              different than than the PM1 A/B status and enable registers
4349980SDana.Myers@Sun.COM  *              in that different values can be written to the A/B registers.
4359980SDana.Myers@Sun.COM  *              Most notably, the SLP_TYP bits can be different, as per the
4369980SDana.Myers@Sun.COM  *              values returned from the _Sx predefined methods.
4373446Smrj  *
4383446Smrj  ******************************************************************************/
4393446Smrj 
4403446Smrj ACPI_STATUS
AcpiHwWritePm1Control(UINT32 Pm1aControl,UINT32 Pm1bControl)4419980SDana.Myers@Sun.COM AcpiHwWritePm1Control (
4429980SDana.Myers@Sun.COM     UINT32                  Pm1aControl,
4439980SDana.Myers@Sun.COM     UINT32                  Pm1bControl)
4443446Smrj {
4453446Smrj     ACPI_STATUS             Status;
4463446Smrj 
4473446Smrj 
4489980SDana.Myers@Sun.COM     ACPI_FUNCTION_TRACE (HwWritePm1Control);
4493446Smrj 
4503446Smrj 
451*11225SDana.Myers@Sun.COM     Status = AcpiHwWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock);
4529980SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
4539980SDana.Myers@Sun.COM     {
4549980SDana.Myers@Sun.COM         return_ACPI_STATUS (Status);
4553446Smrj     }
4563446Smrj 
4579980SDana.Myers@Sun.COM     if (AcpiGbl_FADT.XPm1bControlBlock.Address)
4589980SDana.Myers@Sun.COM     {
459*11225SDana.Myers@Sun.COM         Status = AcpiHwWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock);
4609980SDana.Myers@Sun.COM     }
4613446Smrj     return_ACPI_STATUS (Status);
4623446Smrj }
4633446Smrj 
4643446Smrj 
4653446Smrj /******************************************************************************
4663446Smrj  *
4673446Smrj  * FUNCTION:    AcpiHwRegisterRead
4683446Smrj  *
4697851SDana.Myers@Sun.COM  * PARAMETERS:  RegisterId          - ACPI Register ID
4703446Smrj  *              ReturnValue         - Where the register value is returned
4713446Smrj  *
4723446Smrj  * RETURN:      Status and the value read.
4733446Smrj  *
4743446Smrj  * DESCRIPTION: Read from the specified ACPI register
4753446Smrj  *
4763446Smrj  ******************************************************************************/
4773446Smrj 
4783446Smrj ACPI_STATUS
AcpiHwRegisterRead(UINT32 RegisterId,UINT32 * ReturnValue)4793446Smrj AcpiHwRegisterRead (
4803446Smrj     UINT32                  RegisterId,
4813446Smrj     UINT32                  *ReturnValue)
4823446Smrj {
4839980SDana.Myers@Sun.COM     UINT32                  Value = 0;
4843446Smrj     ACPI_STATUS             Status;
4853446Smrj 
4863446Smrj 
4873446Smrj     ACPI_FUNCTION_TRACE (HwRegisterRead);
4883446Smrj 
4893446Smrj 
4903446Smrj     switch (RegisterId)
4913446Smrj     {
4929980SDana.Myers@Sun.COM     case ACPI_REGISTER_PM1_STATUS:           /* PM1 A/B: 16-bit access each */
4933446Smrj 
4949980SDana.Myers@Sun.COM         Status = AcpiHwReadMultiple (&Value,
4959980SDana.Myers@Sun.COM                     &AcpiGbl_XPm1aStatus,
4969980SDana.Myers@Sun.COM                     &AcpiGbl_XPm1bStatus);
4973446Smrj         break;
4983446Smrj 
4993446Smrj 
5009980SDana.Myers@Sun.COM     case ACPI_REGISTER_PM1_ENABLE:           /* PM1 A/B: 16-bit access each */
5013446Smrj 
5029980SDana.Myers@Sun.COM         Status = AcpiHwReadMultiple (&Value,
5039980SDana.Myers@Sun.COM                     &AcpiGbl_XPm1aEnable,
5049980SDana.Myers@Sun.COM                     &AcpiGbl_XPm1bEnable);
5053446Smrj         break;
5063446Smrj 
5073446Smrj 
5089980SDana.Myers@Sun.COM     case ACPI_REGISTER_PM1_CONTROL:          /* PM1 A/B: 16-bit access each */
5099980SDana.Myers@Sun.COM 
5109980SDana.Myers@Sun.COM         Status = AcpiHwReadMultiple (&Value,
5119980SDana.Myers@Sun.COM                     &AcpiGbl_FADT.XPm1aControlBlock,
5129980SDana.Myers@Sun.COM                     &AcpiGbl_FADT.XPm1bControlBlock);
5133446Smrj 
5149980SDana.Myers@Sun.COM         /*
5159980SDana.Myers@Sun.COM          * Zero the write-only bits. From the ACPI specification, "Hardware
5169980SDana.Myers@Sun.COM          * Write-Only Bits": "Upon reads to registers with write-only bits,
5179980SDana.Myers@Sun.COM          * software masks out all write-only bits."
5189980SDana.Myers@Sun.COM          */
5199980SDana.Myers@Sun.COM         Value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS;
5203446Smrj         break;
5213446Smrj 
5223446Smrj 
5233446Smrj     case ACPI_REGISTER_PM2_CONTROL:          /* 8-bit access */
5243446Smrj 
525*11225SDana.Myers@Sun.COM         Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock);
5263446Smrj         break;
5273446Smrj 
5283446Smrj 
5293446Smrj     case ACPI_REGISTER_PM_TIMER:             /* 32-bit access */
5303446Smrj 
531*11225SDana.Myers@Sun.COM         Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock);
5323446Smrj         break;
5333446Smrj 
5349980SDana.Myers@Sun.COM 
5353446Smrj     case ACPI_REGISTER_SMI_COMMAND_BLOCK:    /* 8-bit access */
5363446Smrj 
5379980SDana.Myers@Sun.COM         Status = AcpiHwReadPort (AcpiGbl_FADT.SmiCommand, &Value, 8);
5383446Smrj         break;
5393446Smrj 
5409980SDana.Myers@Sun.COM 
5413446Smrj     default:
5423446Smrj         ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X",
5433446Smrj             RegisterId));
5443446Smrj         Status = AE_BAD_PARAMETER;
5453446Smrj         break;
5463446Smrj     }
5473446Smrj 
5483446Smrj     if (ACPI_SUCCESS (Status))
5493446Smrj     {
5509980SDana.Myers@Sun.COM         *ReturnValue = Value;
5513446Smrj     }
5523446Smrj 
5533446Smrj     return_ACPI_STATUS (Status);
5543446Smrj }
5553446Smrj 
5563446Smrj 
5573446Smrj /******************************************************************************
5583446Smrj  *
5593446Smrj  * FUNCTION:    AcpiHwRegisterWrite
5603446Smrj  *
5617851SDana.Myers@Sun.COM  * PARAMETERS:  RegisterId          - ACPI Register ID
5623446Smrj  *              Value               - The value to write
5633446Smrj  *
5643446Smrj  * RETURN:      Status
5653446Smrj  *
5663446Smrj  * DESCRIPTION: Write to the specified ACPI register
5673446Smrj  *
5683446Smrj  * NOTE: In accordance with the ACPI specification, this function automatically
5693446Smrj  * preserves the value of the following bits, meaning that these bits cannot be
5703446Smrj  * changed via this interface:
5713446Smrj  *
5723446Smrj  * PM1_CONTROL[0] = SCI_EN
5733446Smrj  * PM1_CONTROL[9]
5743446Smrj  * PM1_STATUS[11]
5753446Smrj  *
5763446Smrj  * ACPI References:
5773446Smrj  * 1) Hardware Ignored Bits: When software writes to a register with ignored
5783446Smrj  *      bit fields, it preserves the ignored bit fields
5793446Smrj  * 2) SCI_EN: OSPM always preserves this bit position
5803446Smrj  *
5813446Smrj  ******************************************************************************/
5823446Smrj 
5833446Smrj ACPI_STATUS
AcpiHwRegisterWrite(UINT32 RegisterId,UINT32 Value)5843446Smrj AcpiHwRegisterWrite (
5853446Smrj     UINT32                  RegisterId,
5863446Smrj     UINT32                  Value)
5873446Smrj {
5883446Smrj     ACPI_STATUS             Status;
5893446Smrj     UINT32                  ReadValue;
5903446Smrj 
5913446Smrj 
5923446Smrj     ACPI_FUNCTION_TRACE (HwRegisterWrite);
5933446Smrj 
5943446Smrj 
5953446Smrj     switch (RegisterId)
5963446Smrj     {
5979980SDana.Myers@Sun.COM     case ACPI_REGISTER_PM1_STATUS:           /* PM1 A/B: 16-bit access each */
5989980SDana.Myers@Sun.COM         /*
5999980SDana.Myers@Sun.COM          * Handle the "ignored" bit in PM1 Status. According to the ACPI
6009980SDana.Myers@Sun.COM          * specification, ignored bits are to be preserved when writing.
6019980SDana.Myers@Sun.COM          * Normally, this would mean a read/modify/write sequence. However,
6029980SDana.Myers@Sun.COM          * preserving a bit in the status register is different. Writing a
6039980SDana.Myers@Sun.COM          * one clears the status, and writing a zero preserves the status.
6049980SDana.Myers@Sun.COM          * Therefore, we must always write zero to the ignored bit.
6059980SDana.Myers@Sun.COM          *
6069980SDana.Myers@Sun.COM          * This behavior is clarified in the ACPI 4.0 specification.
6079980SDana.Myers@Sun.COM          */
6089980SDana.Myers@Sun.COM         Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS;
6093446Smrj 
6109980SDana.Myers@Sun.COM         Status = AcpiHwWriteMultiple (Value,
6119980SDana.Myers@Sun.COM                     &AcpiGbl_XPm1aStatus,
6129980SDana.Myers@Sun.COM                     &AcpiGbl_XPm1bStatus);
6133446Smrj         break;
6143446Smrj 
6153446Smrj 
6169980SDana.Myers@Sun.COM     case ACPI_REGISTER_PM1_ENABLE:           /* PM1 A/B: 16-bit access each */
6173446Smrj 
6189980SDana.Myers@Sun.COM         Status = AcpiHwWriteMultiple (Value,
6199980SDana.Myers@Sun.COM                     &AcpiGbl_XPm1aEnable,
6209980SDana.Myers@Sun.COM                     &AcpiGbl_XPm1bEnable);
6213446Smrj         break;
6223446Smrj 
6233446Smrj 
6249980SDana.Myers@Sun.COM     case ACPI_REGISTER_PM1_CONTROL:          /* PM1 A/B: 16-bit access each */
6253446Smrj 
6263446Smrj         /*
6273446Smrj          * Perform a read first to preserve certain bits (per ACPI spec)
6283446Smrj          * Note: This includes SCI_EN, we never want to change this bit
6293446Smrj          */
6309980SDana.Myers@Sun.COM         Status = AcpiHwReadMultiple (&ReadValue,
6319980SDana.Myers@Sun.COM                     &AcpiGbl_FADT.XPm1aControlBlock,
6329980SDana.Myers@Sun.COM                     &AcpiGbl_FADT.XPm1bControlBlock);
6333446Smrj         if (ACPI_FAILURE (Status))
6343446Smrj         {
6357851SDana.Myers@Sun.COM             goto Exit;
6363446Smrj         }
6373446Smrj 
6383446Smrj         /* Insert the bits to be preserved */
6393446Smrj 
6403446Smrj         ACPI_INSERT_BITS (Value, ACPI_PM1_CONTROL_PRESERVED_BITS, ReadValue);
6413446Smrj 
6423446Smrj         /* Now we can write the data */
6433446Smrj 
6449980SDana.Myers@Sun.COM         Status = AcpiHwWriteMultiple (Value,
6459980SDana.Myers@Sun.COM                     &AcpiGbl_FADT.XPm1aControlBlock,
6469980SDana.Myers@Sun.COM                     &AcpiGbl_FADT.XPm1bControlBlock);
6479980SDana.Myers@Sun.COM         break;
6489980SDana.Myers@Sun.COM 
6499980SDana.Myers@Sun.COM 
6509980SDana.Myers@Sun.COM     case ACPI_REGISTER_PM2_CONTROL:          /* 8-bit access */
6519980SDana.Myers@Sun.COM 
6529980SDana.Myers@Sun.COM         /*
6539980SDana.Myers@Sun.COM          * For control registers, all reserved bits must be preserved,
6549980SDana.Myers@Sun.COM          * as per the ACPI spec.
6559980SDana.Myers@Sun.COM          */
656*11225SDana.Myers@Sun.COM         Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock);
6573446Smrj         if (ACPI_FAILURE (Status))
6583446Smrj         {
6597851SDana.Myers@Sun.COM             goto Exit;
6603446Smrj         }
6613446Smrj 
6629980SDana.Myers@Sun.COM         /* Insert the bits to be preserved */
6633446Smrj 
6649980SDana.Myers@Sun.COM         ACPI_INSERT_BITS (Value, ACPI_PM2_CONTROL_PRESERVED_BITS, ReadValue);
6653446Smrj 
666*11225SDana.Myers@Sun.COM         Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock);
6673446Smrj         break;
6683446Smrj 
6693446Smrj 
6703446Smrj     case ACPI_REGISTER_PM_TIMER:             /* 32-bit access */
6713446Smrj 
672*11225SDana.Myers@Sun.COM         Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock);
6733446Smrj         break;
6743446Smrj 
6753446Smrj 
6763446Smrj     case ACPI_REGISTER_SMI_COMMAND_BLOCK:    /* 8-bit access */
6773446Smrj 
6783446Smrj         /* SMI_CMD is currently always in IO space */
6793446Smrj 
6809980SDana.Myers@Sun.COM         Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, Value, 8);
6813446Smrj         break;
6823446Smrj 
6833446Smrj 
6843446Smrj     default:
6859980SDana.Myers@Sun.COM         ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X",
6869980SDana.Myers@Sun.COM             RegisterId));
6873446Smrj         Status = AE_BAD_PARAMETER;
6883446Smrj         break;
6893446Smrj     }
6903446Smrj 
6917851SDana.Myers@Sun.COM Exit:
6923446Smrj     return_ACPI_STATUS (Status);
6933446Smrj }
6943446Smrj 
6953446Smrj 
6963446Smrj /******************************************************************************
6973446Smrj  *
6989980SDana.Myers@Sun.COM  * FUNCTION:    AcpiHwReadMultiple
6993446Smrj  *
7009980SDana.Myers@Sun.COM  * PARAMETERS:  Value               - Where the register value is returned
7019980SDana.Myers@Sun.COM  *              RegisterA           - First ACPI register (required)
7029980SDana.Myers@Sun.COM  *              RegisterB           - Second ACPI register (optional)
7033446Smrj  *
7043446Smrj  * RETURN:      Status
7053446Smrj  *
7069980SDana.Myers@Sun.COM  * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B)
7073446Smrj  *
7083446Smrj  ******************************************************************************/
7093446Smrj 
7109980SDana.Myers@Sun.COM static ACPI_STATUS
AcpiHwReadMultiple(UINT32 * Value,ACPI_GENERIC_ADDRESS * RegisterA,ACPI_GENERIC_ADDRESS * RegisterB)7119980SDana.Myers@Sun.COM AcpiHwReadMultiple (
7123446Smrj     UINT32                  *Value,
7139980SDana.Myers@Sun.COM     ACPI_GENERIC_ADDRESS    *RegisterA,
7149980SDana.Myers@Sun.COM     ACPI_GENERIC_ADDRESS    *RegisterB)
7153446Smrj {
7169980SDana.Myers@Sun.COM     UINT32                  ValueA = 0;
7179980SDana.Myers@Sun.COM     UINT32                  ValueB = 0;
7183446Smrj     ACPI_STATUS             Status;
7193446Smrj 
7203446Smrj 
7219980SDana.Myers@Sun.COM     /* The first register is always required */
7223446Smrj 
723*11225SDana.Myers@Sun.COM     Status = AcpiHwRead (&ValueA, RegisterA);
7249980SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
7253446Smrj     {
7269980SDana.Myers@Sun.COM         return (Status);
7273446Smrj     }
7283446Smrj 
7299980SDana.Myers@Sun.COM     /* Second register is optional */
7303446Smrj 
7319980SDana.Myers@Sun.COM     if (RegisterB->Address)
7323446Smrj     {
733*11225SDana.Myers@Sun.COM         Status = AcpiHwRead (&ValueB, RegisterB);
7349980SDana.Myers@Sun.COM         if (ACPI_FAILURE (Status))
7359980SDana.Myers@Sun.COM         {
7369980SDana.Myers@Sun.COM             return (Status);
7379980SDana.Myers@Sun.COM         }
7383446Smrj     }
7393446Smrj 
7403446Smrj     /*
7419980SDana.Myers@Sun.COM      * OR the two return values together. No shifting or masking is necessary,
7429980SDana.Myers@Sun.COM      * because of how the PM1 registers are defined in the ACPI specification:
7439980SDana.Myers@Sun.COM      *
7449980SDana.Myers@Sun.COM      * "Although the bits can be split between the two register blocks (each
7459980SDana.Myers@Sun.COM      * register block has a unique pointer within the FADT), the bit positions
7469980SDana.Myers@Sun.COM      * are maintained. The register block with unimplemented bits (that is,
7479980SDana.Myers@Sun.COM      * those implemented in the other register block) always returns zeros,
7489980SDana.Myers@Sun.COM      * and writes have no side effects"
7493446Smrj      */
7509980SDana.Myers@Sun.COM     *Value = (ValueA | ValueB);
7519980SDana.Myers@Sun.COM     return (AE_OK);
7523446Smrj }
7533446Smrj 
7543446Smrj 
7553446Smrj /******************************************************************************
7563446Smrj  *
7579980SDana.Myers@Sun.COM  * FUNCTION:    AcpiHwWriteMultiple
7583446Smrj  *
7599980SDana.Myers@Sun.COM  * PARAMETERS:  Value               - The value to write
7609980SDana.Myers@Sun.COM  *              RegisterA           - First ACPI register (required)
7619980SDana.Myers@Sun.COM  *              RegisterB           - Second ACPI register (optional)
7623446Smrj  *
7633446Smrj  * RETURN:      Status
7643446Smrj  *
7659980SDana.Myers@Sun.COM  * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B)
7663446Smrj  *
7673446Smrj  ******************************************************************************/
7683446Smrj 
7699980SDana.Myers@Sun.COM static ACPI_STATUS
AcpiHwWriteMultiple(UINT32 Value,ACPI_GENERIC_ADDRESS * RegisterA,ACPI_GENERIC_ADDRESS * RegisterB)7709980SDana.Myers@Sun.COM AcpiHwWriteMultiple (
7713446Smrj     UINT32                  Value,
7729980SDana.Myers@Sun.COM     ACPI_GENERIC_ADDRESS    *RegisterA,
7739980SDana.Myers@Sun.COM     ACPI_GENERIC_ADDRESS    *RegisterB)
7743446Smrj {
7753446Smrj     ACPI_STATUS             Status;
7763446Smrj 
7773446Smrj 
7789980SDana.Myers@Sun.COM     /* The first register is always required */
7793446Smrj 
780*11225SDana.Myers@Sun.COM     Status = AcpiHwWrite (Value, RegisterA);
7819980SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
7823446Smrj     {
7839980SDana.Myers@Sun.COM         return (Status);
7843446Smrj     }
7853446Smrj 
7863446Smrj     /*
7879980SDana.Myers@Sun.COM      * Second register is optional
7889980SDana.Myers@Sun.COM      *
7899980SDana.Myers@Sun.COM      * No bit shifting or clearing is necessary, because of how the PM1
7909980SDana.Myers@Sun.COM      * registers are defined in the ACPI specification:
7919980SDana.Myers@Sun.COM      *
7929980SDana.Myers@Sun.COM      * "Although the bits can be split between the two register blocks (each
7939980SDana.Myers@Sun.COM      * register block has a unique pointer within the FADT), the bit positions
7949980SDana.Myers@Sun.COM      * are maintained. The register block with unimplemented bits (that is,
7959980SDana.Myers@Sun.COM      * those implemented in the other register block) always returns zeros,
7969980SDana.Myers@Sun.COM      * and writes have no side effects"
7973446Smrj      */
7989980SDana.Myers@Sun.COM     if (RegisterB->Address)
7993446Smrj     {
800*11225SDana.Myers@Sun.COM         Status = AcpiHwWrite (Value, RegisterB);
8013446Smrj     }
8023446Smrj 
8033446Smrj     return (Status);
8043446Smrj }
8059980SDana.Myers@Sun.COM 
806