soc/amd: correctly report I2C controller state in ACPI
Instead of reporting all I2C controllers in the system as enabled in the
corresponding ACPI device's _STA method, report the I2C devices that are
disabled in the devicetree as disabled in the corresponding _STA method
too. This is done by returning the contents of the STAT variable inside
each device's scope in the DSDT that have a default value of 0 (device
not present/disabled). For all enabled and hidden I2C devices
i2c_acpi_fill_ssdt gets called which then writes 0xf (device enabled and
visible) or 0xb (device enabled, but hidden) to the STAT name inside the
same scope, but in the SSDT. This object in the SSDT will then override
the default in the DSDT resulting in the _STA method returning the
correct status of each device. The code was inspired by
commit 7cf9c74518
("soc/amd/*: Fix UART ACPI device status").
TEST=On Mandolin all I2C controllers are disabled and with this patch
none shows up in the Windows 10 device manager. When enabling an I2C
controller in the devicetree for testing, it shows up again in the
Windows device manager.
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I4cd9f447ded3a7f0b092218410c89767ec517417
Reviewed-on: https://review.coreboot.org/c/coreboot/+/77643
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
parent
feb683d1b9
commit
bfd85218a7
|
@ -161,9 +161,10 @@ Device (I2C0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C0, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C0, 0)
|
||||||
|
@ -197,9 +198,10 @@ Device (I2C1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C1, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C1, 0)
|
||||||
|
@ -233,9 +235,10 @@ Device (I2C2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
||||||
|
@ -273,9 +276,11 @@ Device (I2C3)
|
||||||
Return (Local0)
|
Return (Local0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this device is shared with PSP, then PSP takes care of power management */
|
/* If this device is shared with PSP, then PSP takes care of power management */
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
|
||||||
|
#include <acpi/acpigen.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <amdblocks/acpimmio.h>
|
#include <amdblocks/acpimmio.h>
|
||||||
#include <amdblocks/gpio.h>
|
#include <amdblocks/gpio.h>
|
||||||
|
@ -62,6 +63,15 @@ static const char *i2c_acpi_name(const struct device *dev)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void i2c_acpi_fill_ssdt(const struct device *dev)
|
||||||
|
{
|
||||||
|
dw_i2c_acpi_fill_ssdt(dev);
|
||||||
|
|
||||||
|
acpigen_write_scope(acpi_device_path(dev));
|
||||||
|
acpigen_write_store_int_to_namestr(acpi_device_status(dev), "STAT");
|
||||||
|
acpigen_pop_len(); /* Scope */
|
||||||
|
}
|
||||||
|
|
||||||
int dw_i2c_soc_dev_to_bus(const struct device *dev)
|
int dw_i2c_soc_dev_to_bus(const struct device *dev)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -129,7 +139,7 @@ struct device_operations soc_amd_i2c_mmio_ops = {
|
||||||
.set_resources = noop_set_resources,
|
.set_resources = noop_set_resources,
|
||||||
.scan_bus = scan_smbus,
|
.scan_bus = scan_smbus,
|
||||||
.acpi_name = i2c_acpi_name,
|
.acpi_name = i2c_acpi_name,
|
||||||
.acpi_fill_ssdt = dw_i2c_acpi_fill_ssdt,
|
.acpi_fill_ssdt = i2c_acpi_fill_ssdt,
|
||||||
.ops_i2c_bus = &dw_i2c_bus_ops,
|
.ops_i2c_bus = &dw_i2c_bus_ops,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -274,9 +274,10 @@ Device (I2C0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C0, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C0, 0)
|
||||||
|
@ -310,9 +311,10 @@ Device (I2C1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C1, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C1, 0)
|
||||||
|
@ -346,9 +348,10 @@ Device (I2C2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
||||||
|
@ -386,9 +389,10 @@ Device (I2C3)
|
||||||
Return (Local0)
|
Return (Local0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this device is shared with PSP, then PSP takes care of power management */
|
/* If this device is shared with PSP, then PSP takes care of power management */
|
||||||
|
|
|
@ -274,9 +274,10 @@ Device (I2C0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C0, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C0, 0)
|
||||||
|
@ -310,9 +311,10 @@ Device (I2C1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C1, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C1, 0)
|
||||||
|
@ -346,9 +348,10 @@ Device (I2C2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
||||||
|
@ -386,9 +389,11 @@ Device (I2C3)
|
||||||
Return (Local0)
|
Return (Local0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this device is shared with PSP, then PSP takes care of power management */
|
/* If this device is shared with PSP, then PSP takes care of power management */
|
||||||
|
|
|
@ -274,9 +274,10 @@ Device (I2C0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C0, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C0, 0)
|
||||||
|
@ -310,9 +311,10 @@ Device (I2C1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C1, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C1, 0)
|
||||||
|
@ -346,9 +348,10 @@ Device (I2C2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
||||||
|
@ -386,9 +389,11 @@ Device (I2C3)
|
||||||
Return (Local0)
|
Return (Local0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this device is shared with PSP, then PSP takes care of power management */
|
/* If this device is shared with PSP, then PSP takes care of power management */
|
||||||
|
|
|
@ -279,9 +279,10 @@ Device (I2C0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(5, 0)
|
AOAC_DEVICE(5, 0)
|
||||||
|
@ -315,9 +316,10 @@ Device (I2C1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(6, 0)
|
AOAC_DEVICE(6, 0)
|
||||||
|
@ -352,9 +354,10 @@ Device (I2C2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C2, 0)
|
||||||
|
@ -388,9 +391,11 @@ Device (I2C3)
|
||||||
Return (Local0)
|
Return (Local0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAC_DEVICE(FCH_AOAC_DEV_I2C3, 0)
|
AOAC_DEVICE(FCH_AOAC_DEV_I2C3, 0)
|
||||||
|
|
|
@ -78,9 +78,10 @@ Device (I2CA) {
|
||||||
Memory32Fixed (ReadWrite, APU_I2C0_BASE, 0x1000)
|
Memory32Fixed (ReadWrite, APU_I2C0_BASE, 0x1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +94,11 @@ Device (I2CB)
|
||||||
IRQ (Edge, ActiveHigh, Exclusive) { 15 }
|
IRQ (Edge, ActiveHigh, Exclusive) { 15 }
|
||||||
Memory32Fixed (ReadWrite, APU_I2C1_BASE, 0x1000)
|
Memory32Fixed (ReadWrite, APU_I2C1_BASE, 0x1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,9 +111,10 @@ Device (I2CC) {
|
||||||
Memory32Fixed (ReadWrite, APU_I2C2_BASE, 0x1000)
|
Memory32Fixed (ReadWrite, APU_I2C2_BASE, 0x1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,9 +126,11 @@ Device (I2CD)
|
||||||
IRQ (Edge, ActiveHigh, Exclusive) { 14 }
|
IRQ (Edge, ActiveHigh, Exclusive) { 14 }
|
||||||
Memory32Fixed(ReadWrite, APU_I2C3_BASE, 0x1000)
|
Memory32Fixed(ReadWrite, APU_I2C3_BASE, 0x1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Name (STAT, 0x0)
|
||||||
Method (_STA, 0x0, NotSerialized)
|
Method (_STA, 0x0, NotSerialized)
|
||||||
{
|
{
|
||||||
Return (0x0F)
|
Return (STAT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue