diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/acpi/device.c | 17 | ||||
-rw-r--r-- | src/drivers/i2c/generic/generic.c | 20 | ||||
-rw-r--r-- | src/include/acpi/acpi_device.h | 3 |
3 files changed, 23 insertions, 17 deletions
diff --git a/src/acpi/device.c b/src/acpi/device.c index 95316b0861..091a0865a1 100644 --- a/src/acpi/device.c +++ b/src/acpi/device.c @@ -39,6 +39,23 @@ #define ACPI_DSD_STORAGE_D3_UUID "5025030F-842F-4AB4-A561-99A5189762D0" #define ACPI_DSD_STORAGE_D3_NAME "StorageD3Enable" +/* Write GPIO descriptor of DSD property */ +int acpi_device_write_dsd_gpio(struct acpi_gpio *gpio, int *curr_index) +{ + int ret = -1; + + if (!gpio || !curr_index) + return ret; + + if (gpio->pin_count == 0) + return ret; + + acpi_device_write_gpio(gpio); + ret = *curr_index++; + + return ret; +} + /* Write empty word value and return pointer to it */ static void *acpi_device_write_zero_len(void) { diff --git a/src/drivers/i2c/generic/generic.c b/src/drivers/i2c/generic/generic.c index afff978065..a2d510bcf2 100644 --- a/src/drivers/i2c/generic/generic.c +++ b/src/drivers/i2c/generic/generic.c @@ -27,20 +27,6 @@ static bool i2c_generic_add_gpios_to_crs(struct drivers_i2c_generic_config *cfg) return true; } -static int i2c_generic_write_gpio(struct acpi_gpio *gpio, int *curr_index) -{ - int ret = -1; - - if (gpio->pin_count == 0) - return ret; - - acpi_device_write_gpio(gpio); - ret = *curr_index; - (*curr_index)++; - - return ret; -} - void i2c_generic_fill_ssdt(const struct device *dev, void (*callback)(const struct device *dev), struct drivers_i2c_generic_config *config) @@ -96,15 +82,15 @@ void i2c_generic_fill_ssdt(const struct device *dev, /* Use either Interrupt() or GpioInt() */ if (config->irq_gpio.pin_count) - irq_gpio_index = i2c_generic_write_gpio(&config->irq_gpio, + irq_gpio_index = acpi_device_write_dsd_gpio(&config->irq_gpio, &curr_index); else acpi_device_write_interrupt(&config->irq); if (i2c_generic_add_gpios_to_crs(config) == true) { - reset_gpio_index = i2c_generic_write_gpio(&config->reset_gpio, + reset_gpio_index = acpi_device_write_dsd_gpio(&config->reset_gpio, &curr_index); - enable_gpio_index = i2c_generic_write_gpio(&config->enable_gpio, + enable_gpio_index = acpi_device_write_dsd_gpio(&config->enable_gpio, &curr_index); } acpigen_write_resourcetemplate_footer(); diff --git a/src/include/acpi/acpi_device.h b/src/include/acpi/acpi_device.h index 9ce5e0a3b1..3b66989030 100644 --- a/src/include/acpi/acpi_device.h +++ b/src/include/acpi/acpi_device.h @@ -313,6 +313,9 @@ struct acpi_i2c { /* Write I2cSerialBus() descriptor to SSDT AML output */ void acpi_device_write_i2c(const struct acpi_i2c *i2c); +/* Write GPIO descriptor of DSD property */ +int acpi_device_write_dsd_gpio(struct acpi_gpio *gpio, int *curr_index); + /* * ACPI SPI Bus */ |