acpi: Call acpi_gen_writeSTA by status from device tree
The device tree now supports 'hidden' and the status can be found in
`struct device.hidden`. A new acpi_device_status() will return the
expected setting of STA from a `struct device`.
BUG=b:72200466
BRANCH=eve
TEST=Builds and boots properly on device eve
Change-Id: I6dc62aff63cc3cb950739398a4dcac21836c9766
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://review.coreboot.org/28567
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c
index a5984da..48b7fee 100644
--- a/src/arch/x86/acpi_device.c
+++ b/src/arch/x86/acpi_device.c
@@ -166,6 +166,15 @@
return buf;
}
+int acpi_device_status(const struct device *dev)
+{
+ if (!dev->enabled)
+ return ACPI_STATUS_DEVICE_ALL_OFF;
+ if (dev->hidden)
+ return ACPI_STATUS_DEVICE_HIDDEN_ON;
+ return ACPI_STATUS_DEVICE_ALL_ON;
+}
+
/* ACPI 6.1 section 6.4.3.6: Extended Interrupt Descriptor */
void acpi_device_write_interrupt(const struct acpi_irq *irq)
{
diff --git a/src/arch/x86/include/arch/acpi_device.h b/src/arch/x86/include/arch/acpi_device.h
index 31b97bc..2711af5 100644
--- a/src/arch/x86/include/arch/acpi_device.h
+++ b/src/arch/x86/include/arch/acpi_device.h
@@ -66,6 +66,7 @@
const char *acpi_device_path(struct device *dev);
const char *acpi_device_scope(struct device *dev);
const char *acpi_device_path_join(struct device *dev, const char *name);
+int acpi_device_status(const struct device *dev);
/*
* ACPI Descriptor for extended Interrupt()
diff --git a/src/drivers/generic/adau7002/adau7002.c b/src/drivers/generic/adau7002/adau7002.c
index 0a94819..2ea1086 100644
--- a/src/drivers/generic/adau7002/adau7002.c
+++ b/src/drivers/generic/adau7002/adau7002.c
@@ -43,7 +43,7 @@
acpigen_write_name_string("_HID", ADAU7002_ACPI_HID);
acpigen_write_name_integer("_UID", 0);
acpigen_write_name_string("_DDN", dev->chip_ops->name);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
acpigen_pop_len(); /* Device */
acpigen_pop_len(); /* Scope */
diff --git a/src/drivers/generic/max98357a/max98357a.c b/src/drivers/generic/max98357a/max98357a.c
index 71ab1b9..f9b2d6c 100644
--- a/src/drivers/generic/max98357a/max98357a.c
+++ b/src/drivers/generic/max98357a/max98357a.c
@@ -43,7 +43,7 @@
acpigen_write_name_string("_HID", MAX98357A_ACPI_HID);
acpigen_write_name_integer("_UID", 0);
acpigen_write_name_string("_DDN", dev->chip_ops->name);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/i2c/da7219/da7219.c b/src/drivers/i2c/da7219/da7219.c
index 43e6076..d2a4b78 100644
--- a/src/drivers/i2c/da7219/da7219.c
+++ b/src/drivers/i2c/da7219/da7219.c
@@ -51,7 +51,7 @@
acpigen_write_name_integer("_UID", 1);
acpigen_write_name_string("_DDN", dev->chip_ops->name);
acpigen_write_name_integer("_S0W", 4);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/i2c/generic/generic.c b/src/drivers/i2c/generic/generic.c
index 1b12df5..df929b7 100644
--- a/src/drivers/i2c/generic/generic.c
+++ b/src/drivers/i2c/generic/generic.c
@@ -87,7 +87,7 @@
acpigen_write_name_string("_CID", config->cid);
acpigen_write_name_integer("_UID", config->uid);
acpigen_write_name_string("_DDN", config->desc);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/i2c/max98373/max98373.c b/src/drivers/i2c/max98373/max98373.c
index 558be8a..e019b70 100644
--- a/src/drivers/i2c/max98373/max98373.c
+++ b/src/drivers/i2c/max98373/max98373.c
@@ -51,7 +51,7 @@
acpigen_write_name_integer("_UID", config->uid);
if (config->desc)
acpigen_write_name_string("_DDN", config->desc);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/i2c/max98927/max98927.c b/src/drivers/i2c/max98927/max98927.c
index 12599fe..ec05034 100644
--- a/src/drivers/i2c/max98927/max98927.c
+++ b/src/drivers/i2c/max98927/max98927.c
@@ -49,7 +49,7 @@
acpigen_write_name_integer("_UID", config->uid);
if (config->desc)
acpigen_write_name_string("_DDN", config->desc);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/i2c/nau8825/nau8825.c b/src/drivers/i2c/nau8825/nau8825.c
index 3cf5edd..86d4306 100644
--- a/src/drivers/i2c/nau8825/nau8825.c
+++ b/src/drivers/i2c/nau8825/nau8825.c
@@ -55,7 +55,7 @@
acpigen_write_name_string("_HID", NAU8825_ACPI_HID);
acpigen_write_name_integer("_UID", 0);
acpigen_write_name_string("_DDN", dev->chip_ops->name);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/i2c/rt5663/rt5663.c b/src/drivers/i2c/rt5663/rt5663.c
index 16237d6..38b2a98 100644
--- a/src/drivers/i2c/rt5663/rt5663.c
+++ b/src/drivers/i2c/rt5663/rt5663.c
@@ -51,7 +51,7 @@
acpigen_write_name_string("_HID", RT5663_ACPI_HID);
acpigen_write_name_integer("_UID", config->uid);
acpigen_write_name_string("_DDN", dev->chip_ops->name);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/i2c/sx9310/sx9310.c b/src/drivers/i2c/sx9310/sx9310.c
index 3443f5c..0e98bcb 100644
--- a/src/drivers/i2c/sx9310/sx9310.c
+++ b/src/drivers/i2c/sx9310/sx9310.c
@@ -53,7 +53,7 @@
acpigen_write_name_string("_HID", I2C_SX9310_ACPI_ID);
acpigen_write_name_integer("_UID", config->uid);
acpigen_write_name_string("_DDN", config->desc);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/i2c/tpm/chip.c b/src/drivers/i2c/tpm/chip.c
index c2af071..3dbe811 100644
--- a/src/drivers/i2c/tpm/chip.c
+++ b/src/drivers/i2c/tpm/chip.c
@@ -49,7 +49,7 @@
acpigen_write_name_string("_HID", config->hid);
acpigen_write_name_integer("_UID", config->uid);
acpigen_write_name_string("_DDN", dev->chip_ops->name);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/intel/mipi_camera/camera.c b/src/drivers/intel/mipi_camera/camera.c
index 9def973..cdb9da3 100644
--- a/src/drivers/intel/mipi_camera/camera.c
+++ b/src/drivers/intel/mipi_camera/camera.c
@@ -43,7 +43,7 @@
acpigen_write_name_string("_HID", config->acpi_hid);
acpigen_write_name_integer("_UID", config->acpi_uid);
acpigen_write_name_string("_DDN", config->chip_name);
- acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");
diff --git a/src/drivers/spi/acpi/acpi.c b/src/drivers/spi/acpi/acpi.c
index 7af0460..cf75f9e 100644
--- a/src/drivers/spi/acpi/acpi.c
+++ b/src/drivers/spi/acpi/acpi.c
@@ -114,6 +114,7 @@
acpigen_write_name_integer("_UID", config->uid);
if (config->desc)
acpigen_write_name_string("_DDN", config->desc);
+ acpigen_write_STA(acpi_device_status(dev));
/* Resources */
acpigen_write_name("_CRS");