2018-03-15 07:13:07 +08:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface
|
|
|
|
*
|
2019-01-15 01:55:25 +08:00
|
|
|
* Copyright (C) 2000 - 2019, Intel Corp.
|
2018-03-15 07:13:07 +08:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
2009-01-09 13:30:03 +08:00
|
|
|
#include "accommon.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_HARDWARE
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_MODULE_NAME("hwacpi")
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-14 18:14:27 +08:00
|
|
|
#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
|
2005-04-17 06:20:36 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_hw_set_mode
|
|
|
|
*
|
2012-07-12 09:40:10 +08:00
|
|
|
* PARAMETERS: mode - SYS_MODE_ACPI or SYS_MODE_LEGACY
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Transitions the system into the requested mode.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_hw_set_mode(u32 mode)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status;
|
2005-04-17 06:20:36 +08: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-22 05:15:00 +08:00
|
|
|
ACPI_FUNCTION_TRACE(hw_set_mode);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-03-08 17:22:14 +08: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 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
|
|
|
|
* system does not support mode transition.
|
|
|
|
*/
|
2007-02-03 00:48:18 +08:00
|
|
|
if (!acpi_gbl_FADT.smi_command) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"No SMI_CMD in FADT, mode transition failed"));
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
|
2005-04-17 06:20:36 +08: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-03 00:48:18 +08:00
|
|
|
if (!acpi_gbl_FADT.acpi_enable && !acpi_gbl_FADT.acpi_disable) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2009-03-06 10:05:18 +08:00
|
|
|
"No ACPI mode transition supported in this system "
|
|
|
|
"(enable/disable both zero)"));
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case ACPI_SYS_MODE_ACPI:
|
|
|
|
|
|
|
|
/* BIOS should have disabled ALL fixed and GP events */
|
|
|
|
|
2009-03-19 09:37:47 +08:00
|
|
|
status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
|
2007-02-03 00:48:18 +08:00
|
|
|
(u32) acpi_gbl_FADT.acpi_enable, 8);
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
|
|
"Attempting to enable ACPI mode\n"));
|
2005-04-17 06:20:36 +08: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 09:37:47 +08:00
|
|
|
status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
|
2012-12-19 13:37:15 +08:00
|
|
|
(u32)acpi_gbl_FADT.acpi_disable, 8);
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
|
|
"Attempting to enable Legacy (non-ACPI) mode\n"));
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-06-08 08:58:14 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_EXCEPTION((AE_INFO, status,
|
|
|
|
"Could not write ACPI mode change"));
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08: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-07 05:41:08 +08:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
/*******************************************************************************
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* FUNCTION: acpi_hw_get_mode
|
|
|
|
*
|
|
|
|
* PARAMETERS: none
|
|
|
|
*
|
|
|
|
* RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY
|
|
|
|
*
|
2012-10-31 10:26:55 +08:00
|
|
|
* DESCRIPTION: Return current operating state of system. Determined by
|
2005-04-17 06:20:36 +08:00
|
|
|
* querying the SCI_EN bit.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
u32 acpi_hw_get_mode(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status;
|
|
|
|
u32 value;
|
2005-04-17 06:20:36 +08: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-22 05:15:00 +08:00
|
|
|
ACPI_FUNCTION_TRACE(hw_get_mode);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-03-08 17:22:14 +08:00
|
|
|
/* If the Hardware Reduced flag is set, machine is always in acpi mode */
|
|
|
|
|
|
|
|
if (acpi_gbl_reduced_hardware) {
|
2013-03-08 17:22:23 +08:00
|
|
|
return_UINT32(ACPI_SYS_MODE_ACPI);
|
2013-03-08 17:22:14 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
|
|
|
|
* system does not support mode transition.
|
|
|
|
*/
|
2007-02-03 00:48:18 +08:00
|
|
|
if (!acpi_gbl_FADT.smi_command) {
|
2013-03-08 17:22:23 +08:00
|
|
|
return_UINT32(ACPI_SYS_MODE_ACPI);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-02-23 15:02:07 +08:00
|
|
|
status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value);
|
2005-08-05 12:44:28 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2013-03-08 17:22:23 +08:00
|
|
|
return_UINT32(ACPI_SYS_MODE_LEGACY);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (value) {
|
2013-03-08 17:22:23 +08:00
|
|
|
return_UINT32(ACPI_SYS_MODE_ACPI);
|
2005-08-05 12:44:28 +08:00
|
|
|
} else {
|
2013-03-08 17:22:23 +08:00
|
|
|
return_UINT32(ACPI_SYS_MODE_LEGACY);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2012-02-14 18:14:27 +08:00
|
|
|
|
|
|
|
#endif /* !ACPI_REDUCED_HARDWARE */
|