summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86/acpi_device.c10
-rw-r--r--src/arch/x86/acpigen.c23
-rw-r--r--src/arch/x86/include/arch/acpigen.h11
3 files changed, 39 insertions, 5 deletions
diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c
index 323d4f1eab..42305a6ab4 100644
--- a/src/arch/x86/acpi_device.c
+++ b/src/arch/x86/acpi_device.c
@@ -512,14 +512,14 @@ void acpi_device_add_power_res(
/* Method (_ON, 0, Serialized) */
acpigen_write_method_serialized("_ON", 0);
if (reset_gpio)
- acpigen_soc_set_tx_gpio(reset_gpio);
+ acpigen_enable_tx_gpio(reset);
if (enable_gpio) {
- acpigen_soc_set_tx_gpio(enable_gpio);
+ acpigen_enable_tx_gpio(enable);
if (enable_delay_ms)
acpigen_write_sleep(enable_delay_ms);
}
if (reset_gpio) {
- acpigen_soc_clear_tx_gpio(reset_gpio);
+ acpigen_disable_tx_gpio(reset);
if (reset_delay_ms)
acpigen_write_sleep(reset_delay_ms);
}
@@ -528,9 +528,9 @@ void acpi_device_add_power_res(
/* Method (_OFF, 0, Serialized) */
acpigen_write_method_serialized("_OFF", 0);
if (reset_gpio)
- acpigen_soc_set_tx_gpio(reset_gpio);
+ acpigen_enable_tx_gpio(reset);
if (enable_gpio)
- acpigen_soc_clear_tx_gpio(enable_gpio);
+ acpigen_disable_tx_gpio(enable);
acpigen_pop_len(); /* _OFF method */
acpigen_pop_len(); /* PowerResource PRIC */
diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c
index 8ebdd0982c..d3ec05fe3d 100644
--- a/src/arch/x86/acpigen.c
+++ b/src/arch/x86/acpigen.c
@@ -1299,3 +1299,26 @@ int __attribute__((weak)) acpigen_soc_clear_tx_gpio(unsigned int gpio_num)
acpigen_write_debug_string("clear_tx_gpio not available");
return -1;
}
+
+/*
+ * Helper functions for enabling/disabling Tx GPIOs based on the GPIO
+ * polarity. These functions end up calling acpigen_soc_{set,clear}_tx_gpio to
+ * make callbacks into SoC acpigen code.
+ *
+ * Returns 0 on success and -1 on error.
+ */
+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
+ return acpigen_soc_clear_tx_gpio(gpio->pins[0]);
+}
+
+int acpigen_disable_tx_gpio(struct acpi_gpio *gpio)
+{
+ if (gpio->polarity == ACPI_GPIO_ACTIVE_LOW)
+ return acpigen_soc_set_tx_gpio(gpio->pins[0]);
+ else
+ return acpigen_soc_clear_tx_gpio(gpio->pins[0]);
+}
diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h
index f76d85e9bc..c1c4d598c4 100644
--- a/src/arch/x86/include/arch/acpigen.h
+++ b/src/arch/x86/include/arch/acpigen.h
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <arch/acpi.h>
+#include <arch/acpi_device.h>
/* Values that can be returned for ACPI Device _STA method */
#define ACPI_STATUS_DEVICE_PRESENT (1 << 0)
@@ -289,4 +290,14 @@ int acpigen_soc_set_tx_gpio(unsigned int gpio_num);
/* Generate ACPI AML code to set Tx value of GPIO to 0. */
int acpigen_soc_clear_tx_gpio(unsigned int gpio_num);
+/*
+ * Helper functions for enabling/disabling Tx GPIOs based on the GPIO
+ * polarity. These functions end up calling acpigen_soc_{set,clear}_tx_gpio to
+ * make callbacks into SoC acpigen code.
+ *
+ * Returns 0 on success and -1 on error.
+ */
+int acpigen_enable_tx_gpio(struct acpi_gpio *gpio);
+int acpigen_disable_tx_gpio(struct acpi_gpio *gpio);
+
#endif