Duncan Laurie (dlaurie@chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15512
-gerrit
commit 332c7fdeecd5b877fad3de4a89ddcb059815ec44 Author: Duncan Laurie dlaurie@chromium.org Date: Wed Jun 29 10:47:22 2016 -0700
gpio: Add support for translating gpio_t into ACPI pin
Add a function for an SOC to define that will allow it to map the SOC-specific gpio_t value into an appropriate ACPI pin. The exact behavior depends on the GPIO implementation in the SOC, but it can be used to provide a pin number that is relative to the community or bank that a GPIO resides in.
Change-Id: Icb97ccf7d6a9034877614d49166bc9e4fe659bcf Signed-off-by: Duncan Laurie dlaurie@chromium.org --- src/arch/x86/acpi_device.c | 9 +++++++-- src/include/gpio.h | 10 ++++++++++ src/lib/gpio.c | 6 ++++++ 3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c index 69d44f3..940d871 100644 --- a/src/arch/x86/acpi_device.c +++ b/src/arch/x86/acpi_device.c @@ -314,8 +314,13 @@ void acpi_device_write_gpio(const struct acpi_gpio *gpio) acpi_device_fill_from_len(pin_table_offset, start);
/* Pin Table, one word for each pin */ - for (pin = 0; pin < gpio->pin_count; pin++) - acpigen_emit_word(gpio->pins[pin]); + for (pin = 0; pin < gpio->pin_count; pin++) { + uint16_t acpi_pin = gpio->pins[pin]; +#if IS_ENABLED(CONFIG_GENERIC_GPIO_LIB) + acpi_pin = gpio_acpi_pin(acpi_pin); +#endif + acpigen_emit_word(acpi_pin); + }
/* Fill in Resource Source Name Offset */ acpi_device_fill_from_len(resource_offset, start); diff --git a/src/include/gpio.h b/src/include/gpio.h index 3f462df..69a0828 100644 --- a/src/include/gpio.h +++ b/src/include/gpio.h @@ -41,6 +41,16 @@ int _gpio_base3_value(gpio_t gpio[], int num_gpio, int binary_first); const char *gpio_acpi_path(gpio_t gpio);
/* + * This function may be implemented by SoC/board code to provide + * a mapping from the internal representation of a GPIO to the 16bit + * value used in an ACPI GPIO pin table entry. + * + * If not implemented by the SOC the default handler will return 0 + * because the underlying type of gpio_t is unknown. + */ +uint16_t gpio_acpi_pin(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 b0a5f4d..81d6f6b 100644 --- a/src/lib/gpio.c +++ b/src/lib/gpio.c @@ -145,3 +145,9 @@ __attribute__((weak)) const char *gpio_acpi_path(gpio_t gpio) { return NULL; } + +/* Default handler returns 0 because type of gpio_t is unknown */ +__attribute__((weak)) uint16_t gpio_acpi_pin(gpio_t gpio) +{ + return 0; +}