2005-04-17 00:20:36 +02:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2015-02-05 08:20:45 +01:00
|
|
|
* Copyright (C) 2000 - 2015, Intel Corp.
|
2005-04-17 00:20:36 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
2009-01-09 06:30:03 +01:00
|
|
|
#include "accommon.h"
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_HARDWARE
|
2005-08-05 06:44:28 +02:00
|
|
|
ACPI_MODULE_NAME("hwacpi")
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-02-14 11:14:27 +01:00
|
|
|
#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
|
2005-04-17 00:20:36 +02:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_hw_set_mode
|
|
|
|
*
|
2012-07-12 03:40:10 +02:00
|
|
|
* PARAMETERS: mode - SYS_MODE_ACPI or SYS_MODE_LEGACY
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Transitions the system into the requested mode.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2005-08-05 06:44:28 +02:00
|
|
|
acpi_status acpi_hw_set_mode(u32 mode)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
|
2005-08-05 06:44:28 +02:00
|
|
|
acpi_status status;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-21 23:15:00 +02:00
|
|
|
ACPI_FUNCTION_TRACE(hw_set_mode);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2013-03-08 10:22:14 +01:00
|
|
|
/* If the Hardware Reduced flag is set, machine is always in acpi mode */
|
|
|
|
|
|
|
|
if (acpi_gbl_reduced_hardware) {
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
|
|
|
|
* system does not support mode transition.
|
|
|
|
*/
|
2007-02-02 17:48:18 +01:00
|
|
|
if (!acpi_gbl_FADT.smi_command) {
|
2006-01-27 22:43:00 +01:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"No SMI_CMD in FADT, mode transition failed"));
|
2005-08-05 06:44:28 +02:00
|
|
|
return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE
|
|
|
|
* in FADT: If it is zero, enabling or disabling is not supported.
|
|
|
|
* As old systems may have used zero for mode transition,
|
|
|
|
* we make sure both the numbers are zero to determine these
|
|
|
|
* transitions are not supported.
|
|
|
|
*/
|
2007-02-02 17:48:18 +01:00
|
|
|
if (!acpi_gbl_FADT.acpi_enable && !acpi_gbl_FADT.acpi_disable) {
|
2006-01-27 22:43:00 +01:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2009-03-06 03:05:18 +01:00
|
|
|
"No ACPI mode transition supported in this system "
|
|
|
|
"(enable/disable both zero)"));
|
2005-08-05 06:44:28 +02:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case ACPI_SYS_MODE_ACPI:
|
|
|
|
|
|
|
|
/* BIOS should have disabled ALL fixed and GP events */
|
|
|
|
|
2009-03-19 02:37:47 +01:00
|
|
|
status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
|
2007-02-02 17:48:18 +01:00
|
|
|
(u32) acpi_gbl_FADT.acpi_enable, 8);
|
2005-08-05 06:44:28 +02:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
|
|
"Attempting to enable ACPI mode\n"));
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_SYS_MODE_LEGACY:
|
|
|
|
/*
|
|
|
|
* BIOS should clear all fixed status bits and restore fixed event
|
|
|
|
* enable bits to default
|
|
|
|
*/
|
2009-03-19 02:37:47 +01:00
|
|
|
status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
|
2012-12-19 06:37:15 +01:00
|
|
|
(u32)acpi_gbl_FADT.acpi_disable, 8);
|
2005-08-05 06:44:28 +02:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
|
|
"Attempting to enable Legacy (non-ACPI) mode\n"));
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-06-08 02:58:14 +02:00
|
|
|
|
2005-08-05 06:44:28 +02:00
|
|
|
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-08-05 06:44:28 +02:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-27 22:43:00 +01:00
|
|
|
ACPI_EXCEPTION((AE_INFO, status,
|
|
|
|
"Could not write ACPI mode change"));
|
2005-08-05 06:44:28 +02:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
ACPICA: simplify SCI_EN workaround
acpi_hw_set_mode() double checks its effectiveness
by calling acpi_hw_get_mode() -- polling up to 3 seconds.
It would be more logical for its caller, acpi_enable()
acpi_enable() to do the double-checking. (lets assume
that acpi_disable() isn't interesting)
The ACPI specification is unclear on this point.
Some parts say that the BIOS sets SCI_EN and then returns to the OS,
but one part says "OSPM polls the SCI_EN bit until it is sampled SET".
The systems I have on hand do the former,
SCI_EN is observed to be set upon return from the BIOS.
So we move the check up out of acpi_hw_set_mode()
up into acpi_enable() where it makes logical sense.
Then we replace the 3-second polling loop
with a single check. If this check fails, we'll see:
"Hardware did not enter ACPI mode"
and the system will bail out of ACPI initialization
and likely fail to boot. If we see that in practice,
we can restore the polling, but put it into acpi_enable.
This patch is important if acpi_enable() is used in
the resume from S3 path. Many systems today are seen
coming back from S3 with SCI_EN off, and then failing
to set SCI_EN in response to acpi_enable(). Those systems
will take 3 seconds longer to resume due to this loop.
However, it is possible that we will not use acpi_enable()
in the S3 resume path, and bang SCI_EN directly, which
would make the loop harmless, as it would be invisible
to all systems except those that need it.
Signed-off-by: Len Brown <len.brown@intel.com>
2010-05-06 23:41:08 +02:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-04-19 04:49:35 +02:00
|
|
|
/*******************************************************************************
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
* FUNCTION: acpi_hw_get_mode
|
|
|
|
*
|
|
|
|
* PARAMETERS: none
|
|
|
|
*
|
|
|
|
* RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY
|
|
|
|
*
|
2012-10-31 03:26:55 +01:00
|
|
|
* DESCRIPTION: Return current operating state of system. Determined by
|
2005-04-17 00:20:36 +02:00
|
|
|
* querying the SCI_EN bit.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 06:44:28 +02:00
|
|
|
u32 acpi_hw_get_mode(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-08-05 06:44:28 +02:00
|
|
|
acpi_status status;
|
|
|
|
u32 value;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-21 23:15:00 +02:00
|
|
|
ACPI_FUNCTION_TRACE(hw_get_mode);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2013-03-08 10:22:14 +01:00
|
|
|
/* If the Hardware Reduced flag is set, machine is always in acpi mode */
|
|
|
|
|
|
|
|
if (acpi_gbl_reduced_hardware) {
|
2013-03-08 10:22:23 +01:00
|
|
|
return_UINT32(ACPI_SYS_MODE_ACPI);
|
2013-03-08 10:22:14 +01:00
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
|
|
|
|
* system does not support mode transition.
|
|
|
|
*/
|
2007-02-02 17:48:18 +01:00
|
|
|
if (!acpi_gbl_FADT.smi_command) {
|
2013-03-08 10:22:23 +01:00
|
|
|
return_UINT32(ACPI_SYS_MODE_ACPI);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2009-02-23 08:02:07 +01:00
|
|
|
status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value);
|
2005-08-05 06:44:28 +02:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2013-03-08 10:22:23 +01:00
|
|
|
return_UINT32(ACPI_SYS_MODE_LEGACY);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (value) {
|
2013-03-08 10:22:23 +01:00
|
|
|
return_UINT32(ACPI_SYS_MODE_ACPI);
|
2005-08-05 06:44:28 +02:00
|
|
|
} else {
|
2013-03-08 10:22:23 +01:00
|
|
|
return_UINT32(ACPI_SYS_MODE_LEGACY);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
2012-02-14 11:14:27 +01:00
|
|
|
|
|
|
|
#endif /* !ACPI_REDUCED_HARDWARE */
|