acpi: Call acpi_fill_ssdt() only for enabled devices
Individual drivers check whether the concerned device is enabled before
filling in the SSDT. Move the check before calling acpi_fill_ssdt() and
remove the check in the individual drivers.
BUG=None
TEST=util/abuild/abuild
Change-Id: Ib042bec7e8c68b38fafa60a8e965d781bddcd1f0
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/47148
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Sumeet R Pawnikar <sumeet.r.pawnikar@intel.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Christian Walter <christian.walter@9elements.com>
diff --git a/src/acpi/acpi.c b/src/acpi/acpi.c
index 89f2a46..259813b 100644
--- a/src/acpi/acpi.c
+++ b/src/acpi/acpi.c
@@ -468,7 +468,7 @@
{
struct device *dev;
for (dev = all_devices; dev; dev = dev->next)
- if (dev->ops && dev->ops->acpi_fill_ssdt)
+ if (dev->enabled && dev->ops && dev->ops->acpi_fill_ssdt)
dev->ops->acpi_fill_ssdt(dev);
current = (unsigned long) acpigen_get_current();
}
diff --git a/src/drivers/generic/adau7002/adau7002.c b/src/drivers/generic/adau7002/adau7002.c
index 88ee34d..26da09b 100644
--- a/src/drivers/generic/adau7002/adau7002.c
+++ b/src/drivers/generic/adau7002/adau7002.c
@@ -17,7 +17,7 @@
struct drivers_generic_adau7002_config *config;
struct acpi_dp *dp;
- if (!dev || !dev->enabled)
+ if (!dev)
return;
const char *scope = acpi_device_scope(dev);
diff --git a/src/drivers/generic/gpio_keys/gpio_keys.c b/src/drivers/generic/gpio_keys/gpio_keys.c
index 80ac407..3d273a0 100644
--- a/src/drivers/generic/gpio_keys/gpio_keys.c
+++ b/src/drivers/generic/gpio_keys/gpio_keys.c
@@ -57,7 +57,7 @@
const char *drv_string = config->is_polled ? "gpio-keys-polled"
: "gpio-keys";
- if (!dev->enabled || !scope || !path || !config->gpio.pin_count)
+ if (!scope || !path || !config->gpio.pin_count)
return;
/* Device */
diff --git a/src/drivers/generic/max98357a/max98357a.c b/src/drivers/generic/max98357a/max98357a.c
index 44f8802..9ae4bf4 100644
--- a/src/drivers/generic/max98357a/max98357a.c
+++ b/src/drivers/generic/max98357a/max98357a.c
@@ -18,7 +18,7 @@
const char *path;
struct acpi_dp *dp;
- if (!dev->enabled || !config)
+ if (!config)
return;
const char *scope = acpi_device_scope(dev);
diff --git a/src/drivers/gfx/generic/generic.c b/src/drivers/gfx/generic/generic.c
index 546f30b..d3a4518 100644
--- a/src/drivers/gfx/generic/generic.c
+++ b/src/drivers/gfx/generic/generic.c
@@ -106,7 +106,7 @@
const char *scope = acpi_device_scope(dev);
- if (!scope || !dev->enabled)
+ if (!scope)
return;
acpigen_write_scope(scope);
diff --git a/src/drivers/i2c/da7219/da7219.c b/src/drivers/i2c/da7219/da7219.c
index 1d98023..0423460 100644
--- a/src/drivers/i2c/da7219/da7219.c
+++ b/src/drivers/i2c/da7219/da7219.c
@@ -27,7 +27,7 @@
};
struct acpi_dp *dsd, *aad;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
/* Device */
diff --git a/src/drivers/i2c/designware/dw_i2c.c b/src/drivers/i2c/designware/dw_i2c.c
index e01b5a8..3181e7a 100644
--- a/src/drivers/i2c/designware/dw_i2c.c
+++ b/src/drivers/i2c/designware/dw_i2c.c
@@ -824,9 +824,6 @@
const char *path;
unsigned int speed;
- if (!dev->enabled)
- return;
-
bus = dw_i2c_soc_dev_to_bus(dev);
if (bus < 0)
diff --git a/src/drivers/i2c/generic/generic.c b/src/drivers/i2c/generic/generic.c
index 18fd55c..cd74068 100644
--- a/src/drivers/i2c/generic/generic.c
+++ b/src/drivers/i2c/generic/generic.c
@@ -57,7 +57,7 @@
int reset_gpio_index = -1, enable_gpio_index = -1, irq_gpio_index = -1;
const char *path = acpi_device_path(dev);
- if (!dev->enabled || !scope)
+ if (!scope)
return;
if (!config->hid) {
diff --git a/src/drivers/i2c/gpiomux/bus/bus.c b/src/drivers/i2c/gpiomux/bus/bus.c
index 66aef8e..0bcf36a 100644
--- a/src/drivers/i2c/gpiomux/bus/bus.c
+++ b/src/drivers/i2c/gpiomux/bus/bus.c
@@ -22,7 +22,7 @@
const char *scope = acpi_device_scope(dev);
const char *path = acpi_device_path(dev);
- if (!dev || !dev->enabled || !scope || !path)
+ if (!dev || !scope || !path)
return;
/* Device */
diff --git a/src/drivers/i2c/gpiomux/mux/mux.c b/src/drivers/i2c/gpiomux/mux/mux.c
index 66c8cc5..c1ae758 100644
--- a/src/drivers/i2c/gpiomux/mux/mux.c
+++ b/src/drivers/i2c/gpiomux/mux/mux.c
@@ -27,7 +27,7 @@
struct acpi_gpio_res_params param[MAX_NUM_MUX_GPIOS];
int i;
- if (!dev->enabled || !scope || !path)
+ if (!scope || !path)
return;
/* Device */
diff --git a/src/drivers/i2c/max98373/max98373.c b/src/drivers/i2c/max98373/max98373.c
index 1f8a4f3..b078674 100644
--- a/src/drivers/i2c/max98373/max98373.c
+++ b/src/drivers/i2c/max98373/max98373.c
@@ -24,7 +24,7 @@
};
struct acpi_dp *dp;
- if (!dev->enabled || !scope) {
+ if (!scope) {
printk(BIOS_ERR, "%s: dev not enabled\n", __func__);
return;
}
diff --git a/src/drivers/i2c/max98390/max98390.c b/src/drivers/i2c/max98390/max98390.c
index 24c500b..c216391 100644
--- a/src/drivers/i2c/max98390/max98390.c
+++ b/src/drivers/i2c/max98390/max98390.c
@@ -28,7 +28,7 @@
struct acpi_dp *dp;
uint64_t r0_value, temp_value;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
/* Device */
diff --git a/src/drivers/i2c/max98927/max98927.c b/src/drivers/i2c/max98927/max98927.c
index 9429e4a..642eccf 100644
--- a/src/drivers/i2c/max98927/max98927.c
+++ b/src/drivers/i2c/max98927/max98927.c
@@ -24,7 +24,7 @@
};
struct acpi_dp *dp;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
/* Device */
diff --git a/src/drivers/i2c/nau8825/nau8825.c b/src/drivers/i2c/nau8825/nau8825.c
index e995ebd..a0769d0 100644
--- a/src/drivers/i2c/nau8825/nau8825.c
+++ b/src/drivers/i2c/nau8825/nau8825.c
@@ -30,7 +30,7 @@
};
struct acpi_dp *dp = NULL;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
if (config->sar_threshold_num > NAU8825_MAX_BUTTONS)
return;
diff --git a/src/drivers/i2c/rt1011/rt1011.c b/src/drivers/i2c/rt1011/rt1011.c
index d1732f7..70f1881 100644
--- a/src/drivers/i2c/rt1011/rt1011.c
+++ b/src/drivers/i2c/rt1011/rt1011.c
@@ -28,7 +28,7 @@
struct acpi_dp *dp;
uint64_t r0_value, temp_value;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
/* Device */
diff --git a/src/drivers/i2c/rt5663/rt5663.c b/src/drivers/i2c/rt5663/rt5663.c
index 272cf78..565e3bb 100644
--- a/src/drivers/i2c/rt5663/rt5663.c
+++ b/src/drivers/i2c/rt5663/rt5663.c
@@ -27,7 +27,7 @@
};
struct acpi_dp *dp;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
/* Device */
diff --git a/src/drivers/i2c/sx9310/sx9310.c b/src/drivers/i2c/sx9310/sx9310.c
index c12e4ea..8dc57a2 100644
--- a/src/drivers/i2c/sx9310/sx9310.c
+++ b/src/drivers/i2c/sx9310/sx9310.c
@@ -28,7 +28,7 @@
};
struct acpi_dp *dsd;
- if (!dev->enabled || !scope || !config)
+ if (!scope || !config)
return;
if (config->speed)
diff --git a/src/drivers/i2c/tpm/chip.c b/src/drivers/i2c/tpm/chip.c
index 2baec42..07791c3 100644
--- a/src/drivers/i2c/tpm/chip.c
+++ b/src/drivers/i2c/tpm/chip.c
@@ -20,7 +20,7 @@
.resource = scope,
};
- if (!dev->enabled || !scope)
+ if (!scope)
return;
if (!config->hid) {
diff --git a/src/drivers/intel/ish/ish.c b/src/drivers/intel/ish/ish.c
index f82f7fc..19cbd82 100644
--- a/src/drivers/intel/ish/ish.c
+++ b/src/drivers/intel/ish/ish.c
@@ -13,7 +13,7 @@
struct device *root = dev->bus->dev;
struct acpi_dp *dsd;
- if (!dev->enabled || !config || !config->firmware_name)
+ if (!config || !config->firmware_name)
return;
acpigen_write_scope(acpi_device_path(root));
diff --git a/src/drivers/intel/mipi_camera/camera.c b/src/drivers/intel/mipi_camera/camera.c
index d4cf33d..7dfd650 100644
--- a/src/drivers/intel/mipi_camera/camera.c
+++ b/src/drivers/intel/mipi_camera/camera.c
@@ -909,9 +909,6 @@
const char *scope = NULL;
const struct device *pdev;
- if (!dev->enabled)
- return;
-
if (config->has_power_resource) {
pdev = dev->bus->dev;
if (!pdev || !pdev->enabled)
diff --git a/src/drivers/intel/pmc_mux/conn/conn.c b/src/drivers/intel/pmc_mux/conn/conn.c
index 16d113b..9fd8543 100644
--- a/src/drivers/intel/pmc_mux/conn/conn.c
+++ b/src/drivers/intel/pmc_mux/conn/conn.c
@@ -32,9 +32,6 @@
const char *scope;
const char *name;
- if (!dev->enabled)
- return;
-
/* Reference the existing scope and write CONx device */
scope = acpi_device_scope(dev);
name = acpi_device_name(dev);
diff --git a/src/drivers/intel/soundwire/soundwire.c b/src/drivers/intel/soundwire/soundwire.c
index 34ecd86..c7e84a5 100644
--- a/src/drivers/intel/soundwire/soundwire.c
+++ b/src/drivers/intel/soundwire/soundwire.c
@@ -50,7 +50,7 @@
struct intel_soundwire_controller *controller;
const char *scope = acpi_device_scope(dev);
- if (!dev->enabled || !scope)
+ if (!scope)
return;
if (soc_fill_soundwire_controller(&controller) < 0 || !controller)
diff --git a/src/drivers/intel/usb4/retimer/retimer.c b/src/drivers/intel/usb4/retimer/retimer.c
index be9ec35..7a693ff 100644
--- a/src/drivers/intel/usb4/retimer/retimer.c
+++ b/src/drivers/intel/usb4/retimer/retimer.c
@@ -101,7 +101,7 @@
const struct drivers_intel_usb4_retimer_config *config = dev->chip_info;
const char *scope = acpi_device_scope(dev);
- if (!dev->enabled || !scope || !config)
+ if (!scope || !config)
return;
if (!config->power_gpio.pin_count) {
diff --git a/src/drivers/soundwire/alc5682/alc5682.c b/src/drivers/soundwire/alc5682/alc5682.c
index 79ed610..e15ecd4 100644
--- a/src/drivers/soundwire/alc5682/alc5682.c
+++ b/src/drivers/soundwire/alc5682/alc5682.c
@@ -128,7 +128,7 @@
const char *scope = acpi_device_scope(dev);
struct acpi_dp *dsd;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
acpigen_write_scope(scope);
diff --git a/src/drivers/soundwire/alc711/alc711.c b/src/drivers/soundwire/alc711/alc711.c
index 8382fc9..44a9e98 100644
--- a/src/drivers/soundwire/alc711/alc711.c
+++ b/src/drivers/soundwire/alc711/alc711.c
@@ -105,7 +105,7 @@
const char *scope = acpi_device_scope(dev);
struct acpi_dp *dsd;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
acpigen_write_scope(scope);
diff --git a/src/drivers/soundwire/max98373/max98373.c b/src/drivers/soundwire/max98373/max98373.c
index 231385c..28796c0 100644
--- a/src/drivers/soundwire/max98373/max98373.c
+++ b/src/drivers/soundwire/max98373/max98373.c
@@ -114,7 +114,7 @@
const char *scope = acpi_device_scope(dev);
struct acpi_dp *dsd;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
acpigen_write_scope(scope);
diff --git a/src/drivers/spi/acpi/acpi.c b/src/drivers/spi/acpi/acpi.c
index c0e776e..b23bc9d 100644
--- a/src/drivers/spi/acpi/acpi.c
+++ b/src/drivers/spi/acpi/acpi.c
@@ -77,7 +77,7 @@
int reset_gpio_index = -1;
int enable_gpio_index = -1;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
if (spi_acpi_get_bus(dev) == -1) {
diff --git a/src/drivers/uart/acpi/acpi.c b/src/drivers/uart/acpi/acpi.c
index f9d9d8f..d4b14aac 100644
--- a/src/drivers/uart/acpi/acpi.c
+++ b/src/drivers/uart/acpi/acpi.c
@@ -46,7 +46,7 @@
int reset_gpio_index = -1;
int enable_gpio_index = -1;
- if (!dev->enabled || !scope)
+ if (!scope)
return;
if (!config->hid) {
diff --git a/src/drivers/usb/acpi/usb_acpi.c b/src/drivers/usb/acpi/usb_acpi.c
index d33b7de..55ef1d3 100644
--- a/src/drivers/usb/acpi/usb_acpi.c
+++ b/src/drivers/usb/acpi/usb_acpi.c
@@ -24,7 +24,7 @@
struct drivers_usb_acpi_config *config = dev->chip_info;
const char *path = acpi_device_path(dev);
- if (!dev->enabled || !path || !config)
+ if (!path || !config)
return;
/* Don't generate output for hubs, only ports */
diff --git a/src/drivers/wifi/generic/acpi.c b/src/drivers/wifi/generic/acpi.c
index ac2c5eb..1cc4bd0 100644
--- a/src/drivers/wifi/generic/acpi.c
+++ b/src/drivers/wifi/generic/acpi.c
@@ -222,9 +222,6 @@
{
const char *path;
- if (!is_dev_enabled(dev))
- return;
-
path = acpi_device_path(dev);
if (!path)
return;
@@ -247,9 +244,6 @@
{
const char *path;
- if (!is_dev_enabled(dev))
- return;
-
path = acpi_device_path(dev->bus->dev);
if (!path)
return;
diff --git a/src/ec/google/chromeec/audio_codec/audio_codec.c b/src/ec/google/chromeec/audio_codec/audio_codec.c
index 612b1f6..53037eb 100644
--- a/src/ec/google/chromeec/audio_codec/audio_codec.c
+++ b/src/ec/google/chromeec/audio_codec/audio_codec.c
@@ -15,7 +15,7 @@
const char *scope = acpi_device_scope(dev);
struct ec_google_chromeec_audio_codec_config *cfg = dev->chip_info;
- if (!dev->enabled || !scope || !cfg)
+ if (!scope || !cfg)
return;
acpigen_write_scope(scope);
diff --git a/src/ec/google/chromeec/ec_acpi.c b/src/ec/google/chromeec/ec_acpi.c
index 448ea4d..fff3954 100644
--- a/src/ec/google/chromeec/ec_acpi.c
+++ b/src/ec/google/chromeec/ec_acpi.c
@@ -223,9 +223,6 @@
struct device_path path;
struct device *ec;
- if (!dev->enabled)
- return;
-
/* Set up a minimal EC0 device to pass to the DPTF helpers */
path.type = DEVICE_PATH_GENERIC;
path.generic.id = 0;
diff --git a/src/ec/google/chromeec/i2c_tunnel/i2c_tunnel.c b/src/ec/google/chromeec/i2c_tunnel/i2c_tunnel.c
index ec8bdfc..e61ecfd8 100644
--- a/src/ec/google/chromeec/i2c_tunnel/i2c_tunnel.c
+++ b/src/ec/google/chromeec/i2c_tunnel/i2c_tunnel.c
@@ -17,7 +17,7 @@
struct ec_google_chromeec_i2c_tunnel_config *cfg = dev->chip_info;
struct acpi_dp *dsd;
- if (!dev->enabled || !scope || !cfg)
+ if (!scope || !cfg)
return;
acpigen_write_scope(scope);
diff --git a/src/ec/google/wilco/chip.c b/src/ec/google/wilco/chip.c
index dccaa23..911eb25 100644
--- a/src/ec/google/wilco/chip.c
+++ b/src/ec/google/wilco/chip.c
@@ -184,9 +184,6 @@
void *region_ptr;
size_t ucsi_alloc_region_len;
- if (!dev->enabled)
- return;
-
ucsi_alloc_region_len = ucsi_region_len < UCSI_MIN_ALLOC_REGION_LEN ?
UCSI_MIN_ALLOC_REGION_LEN : ucsi_region_len;
region_ptr = cbmem_add(CBMEM_ID_ACPI_UCSI, ucsi_alloc_region_len);
diff --git a/src/soc/intel/common/block/scs/sd.c b/src/soc/intel/common/block/scs/sd.c
index 04ebb13..be59a3d 100644
--- a/src/soc/intel/common/block/scs/sd.c
+++ b/src/soc/intel/common/block/scs/sd.c
@@ -12,9 +12,6 @@
struct acpi_gpio default_gpio = { 0 };
struct acpi_dp *dp;
- if (!dev->enabled)
- return;
-
if (sd_fill_soc_gpio_info(&default_gpio, dev) != 0)
return;
diff --git a/src/soc/intel/common/block/usb4/pcie.c b/src/soc/intel/common/block/usb4/pcie.c
index eae9027..81496ce 100644
--- a/src/soc/intel/common/block/usb4/pcie.c
+++ b/src/soc/intel/common/block/usb4/pcie.c
@@ -26,7 +26,7 @@
return;
}
- if (!dev->enabled || !parent->enabled)
+ if (!parent->enabled)
return;
config = config_of(dev);
diff --git a/src/soc/intel/common/block/usb4/usb4.c b/src/soc/intel/common/block/usb4/usb4.c
index df2dfdd..a8ab736 100644
--- a/src/soc/intel/common/block/usb4/usb4.c
+++ b/src/soc/intel/common/block/usb4/usb4.c
@@ -28,9 +28,6 @@
{
struct acpi_dp *dsd, *pkg;
- if (!dev->enabled)
- return;
-
acpigen_write_scope(acpi_device_path(dev));
dsd = acpi_dp_new_table("_DSD");