[coreboot-gerrit] New patch to review for coreboot: gpio: Add a function to map GPIO to ACPI path

Duncan Laurie (dlaurie@google.com) gerrit at coreboot.org
Mon May 16 22:50:43 CEST 2016


Duncan Laurie (dlaurie at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14842

-gerrit

commit 413a85decbe9edc5640934354b9b573a512419f2
Author: Duncan Laurie <dlaurie at chromium.org>
Date:   Mon May 9 16:09:25 2016 -0700

    gpio: Add a function to map GPIO to ACPI path
    
    Add a new function "gpio_acpi_path()" that can be implemented by SoC/board
    code to provide a mapping from a "gpio_t" pin to a controller by returning
    the ACPI path for the controller that owns this GPIO.
    
    This is implemented separately from the "acpi_name" handler as many SOCs do
    not have a specific device that handles GPIOs (or may have many devices and
    the only way to know which is the opaque gpio_t) and the current GPIO library
    does not have any association with the device tree.
    
    If not implemented (many SoCs do not implement the GPIO library abstraction
    at all in coreboot) then the default handler will return NULL and the caller
    knows it cannot determine this reliably.
    
    Change-Id: Iaa0ff6c8c058f00cddf0909c4b7405a0660d4cfb
    Signed-off-by: Duncan Laurie <dlaurie at chromium.org>
---
 src/include/gpio.h | 9 +++++++++
 src/lib/gpio.c     | 6 ++++++
 2 files changed, 15 insertions(+)

diff --git a/src/include/gpio.h b/src/include/gpio.h
index 4627e44..3f462df 100644
--- a/src/include/gpio.h
+++ b/src/include/gpio.h
@@ -32,6 +32,15 @@ void gpio_output(gpio_t gpio, int value);
 int _gpio_base3_value(gpio_t gpio[], int num_gpio, int binary_first);
 
 /*
+ * This function may be implemented by SoC/board code to provide
+ * a mapping from a GPIO pin to controller by returning the ACPI
+ * path for the controller that owns this GPIO.
+ *
+ * If not implemented the default handler will return NULL.
+ */
+const char *gpio_acpi_path(gpio_t gpio);
+
+/*
  * Read the value presented by the set of GPIOs, when each pin is interpreted
  * as a base-2 digit (LOW = 0, HIGH = 1).
  *
diff --git a/src/lib/gpio.c b/src/lib/gpio.c
index 2e34595..b0a5f4d 100644
--- a/src/lib/gpio.c
+++ b/src/lib/gpio.c
@@ -139,3 +139,9 @@ int _gpio_base3_value(gpio_t gpio[], int num_gpio, int binary_first)
 
 	return result;
 }
+
+/* Default handler for ACPI path is to return NULL */
+__attribute__((weak)) const char *gpio_acpi_path(gpio_t gpio)
+{
+	return NULL;
+}



More information about the coreboot-gerrit mailing list