From d2d5e44a67f6e7bb80a22822f34397b03426851b Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 1 Jul 2020 01:37:13 -0700 Subject: acpi_device: Replace polarity with active_low in acpi_gpio for GpioIo As per ACPI spec, GpioIo does not have any polarity associated with it. Linux kernel uses `active_low` argument within GPIO _DSD property to allow BIOS to indicate if the corresponding GPIO should be treated as active low. Thus, if GPIO has active high polarity or if it does not have any polarity associated with it, then the `active_low` argument is supposed to be set to 0. Having a `polarity` field in acpi_gpio seems confusing because GPIOs might not always have polarity associated with them. Example, in case of DMIC-select GPIO where 0 means select DMIC0 and 1 means select DMIC1, there is no polarity associated with the GPIO. Thus, it would be clearer for mainboard to use macros without having to specify a particular polarity. In order to enable mainboards to provide GPIO information without polarity for GpioIo usage, this change also adds `ACPI_GPIO_OUTPUT` and `ACPI_GPIO_INPUT` macros. BUG=b:157603026 Change-Id: I39d2a6ac8f149a74afeb915812fece86c9b9ad93 Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/c/coreboot/+/42968 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/acpi/acpigen.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/acpi') diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index efc5a16195..fc6da1beb9 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -1800,15 +1800,15 @@ int __weak acpigen_soc_clear_tx_gpio(unsigned int gpio_num) */ int acpigen_enable_tx_gpio(struct acpi_gpio *gpio) { - if (gpio->polarity == ACPI_GPIO_ACTIVE_HIGH) - return acpigen_soc_set_tx_gpio(gpio->pins[0]); - else + if (gpio->active_low) return acpigen_soc_clear_tx_gpio(gpio->pins[0]); + else + return acpigen_soc_set_tx_gpio(gpio->pins[0]); } int acpigen_disable_tx_gpio(struct acpi_gpio *gpio) { - if (gpio->polarity == ACPI_GPIO_ACTIVE_LOW) + if (gpio->active_low) return acpigen_soc_set_tx_gpio(gpio->pins[0]); else return acpigen_soc_clear_tx_gpio(gpio->pins[0]); @@ -1818,7 +1818,7 @@ void acpigen_get_rx_gpio(struct acpi_gpio *gpio) { acpigen_soc_read_rx_gpio(gpio->pins[0]); - if (gpio->polarity == ACPI_GPIO_ACTIVE_LOW) + if (gpio->active_low) acpigen_write_xor(LOCAL0_OP, 1, LOCAL0_OP); } @@ -1826,7 +1826,7 @@ void acpigen_get_tx_gpio(struct acpi_gpio *gpio) { acpigen_soc_get_tx_gpio(gpio->pins[0]); - if (gpio->polarity == ACPI_GPIO_ACTIVE_LOW) + if (gpio->active_low) acpigen_write_xor(LOCAL0_OP, 1, LOCAL0_OP); } -- cgit v1.2.3