summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2016-10-20 07:12:49 -0700
committerFurquan Shaikh <furquan@google.com>2016-10-24 17:44:15 +0200
commit0a48aee795942538e006bba42c188ee95afb49bb (patch)
treec6e55cf05a67e19fa6bb8afa5ac8ee5ef6197ad1 /src
parentfcc7a04cc8d222bf74b1d541566aacc32fd7285d (diff)
downloadcoreboot-0a48aee795942538e006bba42c188ee95afb49bb.tar.xz
arch/x86/acpigen: Add support for interacting with GPIOs
Since reading/toggling of GPIOs is platform-dependent task, provide an interface with common functions to generate ACPI AML code for manipulating GPIOs: 1. acpigen_soc_read_rx_gpio 2. acpigen_soc_get_tx_gpio 3. acpigen_soc_set_tx_gpio 4. acpigen_soc_clear_tx_gpio Provide weak implementations of above functions. These functions are expected to be implemented by every SoC that uses ACPI. This allows drivers to easily generate ACPI AML code to interact GPIOs. BUG=chrome-os-partner:55988 Change-Id: I3564f15a1cb50e6ca6132638447529648589aa0e Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/17080 Tested-by: build bot (Jenkins) Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/acpigen.c29
-rw-r--r--src/arch/x86/include/arch/acpigen.h22
2 files changed, 51 insertions, 0 deletions
diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c
index e0e957a9df..0a572630a1 100644
--- a/src/arch/x86/acpigen.c
+++ b/src/arch/x86/acpigen.c
@@ -992,3 +992,32 @@ void acpigen_write_else(void)
acpigen_emit_byte(ELSE_OP);
acpigen_write_len_f();
}
+
+/* Soc-implemented functions -- weak definitions. */
+int __attribute__((weak)) acpigen_soc_read_rx_gpio(unsigned int gpio_num)
+{
+ printk(BIOS_ERR, "ERROR: %s not implemented\n", __func__);
+ acpigen_write_debug_string("read_rx_gpio not available");
+ return -1;
+}
+
+int __attribute__((weak)) acpigen_soc_get_tx_gpio(unsigned int gpio_num)
+{
+ printk(BIOS_ERR, "ERROR: %s not implemented\n", __func__);
+ acpigen_write_debug_string("get_tx_gpio not available");
+ return -1;
+}
+
+int __attribute__((weak)) acpigen_soc_set_tx_gpio(unsigned int gpio_num)
+{
+ printk(BIOS_ERR, "ERROR: %s not implemented\n", __func__);
+ acpigen_write_debug_string("set_tx_gpio not available");
+ return -1;
+}
+
+int __attribute__((weak)) acpigen_soc_clear_tx_gpio(unsigned int gpio_num)
+{
+ printk(BIOS_ERR, "ERROR: %s not implemented\n", __func__);
+ acpigen_write_debug_string("clear_tx_gpio not available");
+ return -1;
+}
diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h
index c2936e2aa9..0c515da242 100644
--- a/src/arch/x86/include/arch/acpigen.h
+++ b/src/arch/x86/include/arch/acpigen.h
@@ -160,4 +160,26 @@ void acpigen_write_else(void);
int get_cst_entries(acpi_cstate_t **);
+/*
+ * Soc-implemented functions for generating ACPI AML code for GPIO handling. All
+ * these functions are expected to use only Local5, Local6 and Local7
+ * variables. If the functions call into another ACPI method, then there is no
+ * restriction on the use of Local variables. In case of get/read functions,
+ * return value is expected to be stored in Local0 variable.
+ *
+ * All functions return 0 on success and -1 on error.
+ */
+
+/* Generate ACPI AML code to return Rx value of GPIO in Local0. */
+int acpigen_soc_read_rx_gpio(unsigned int gpio_num);
+
+/* Generate ACPI AML code to return Tx value of GPIO in Local0. */
+int acpigen_soc_get_tx_gpio(unsigned int gpio_num);
+
+/* Generate ACPI AML code to set Tx value of GPIO to 1. */
+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);
+
#endif