Duncan Laurie merged this change.

View Change

Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, but someone else must approve Subrata Banik: Looks good to me, approved
vendorcode/google/chromeos: Use ACPI GPIO pin when possible

Have the generated Chrome OS ACPI GPIO table provide the ACPI GPIO
pin number instead of the raw GPIO number when possible.

This is necessary if the OS uses a different numbering for GPIOs
that are reported in ACPI than the actual underlying GPIO number.

For example, if the SOC OS driver declares more pins in an ACPI GPIO
bank than there are actual pins in the hardware it will have gaps in
the number space.

This is a reworked version of 6217e9beff16d805ca833e79a2931bcdb3d02a44
which does not try to convert CROS_GPIO_VIRTUAL.

BUG=b:120686247
TEST=pass firmware_WriteProtect test on Sarien

Signed-off-by: Duncan Laurie <dlaurie@google.com>
Change-Id: I3ad5099b7f2f871c7e516988f60a54eb2a75bef7
Reviewed-on: https://review.coreboot.org/c/31080
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Subrata Banik <subrata.banik@intel.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
---
M src/vendorcode/google/chromeos/acpi.c
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/vendorcode/google/chromeos/acpi.c b/src/vendorcode/google/chromeos/acpi.c
index 6605809..8fd47a6 100644
--- a/src/vendorcode/google/chromeos/acpi.c
+++ b/src/vendorcode/google/chromeos/acpi.c
@@ -14,11 +14,15 @@
*/

#include <arch/acpigen.h>
+#if IS_ENABLED(CONFIG_GENERIC_GPIO_LIB)
+#include <gpio.h>
+#endif
#include "chromeos.h"

void chromeos_acpi_gpio_generate(const struct cros_gpio *gpios, size_t num)
{
size_t i;
+ int gpio_num;

acpigen_write_scope("\\");
acpigen_write_name("OIPG");
@@ -28,7 +32,13 @@
acpigen_write_package(4);
acpigen_write_integer(gpios[i].type);
acpigen_write_integer(gpios[i].polarity);
- acpigen_write_integer(gpios[i].gpio_num);
+ gpio_num = gpios[i].gpio_num;
+#if IS_ENABLED(CONFIG_GENERIC_GPIO_LIB)
+ /* Get ACPI pin from GPIO library if available */
+ if (gpios[i].gpio_num != CROS_GPIO_VIRTUAL)
+ gpio_num = gpio_acpi_pin(gpio_num);
+#endif
+ acpigen_write_integer(gpio_num);
acpigen_write_string(gpios[i].device);
acpigen_pop_len();
}

To view, visit change 31080. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I3ad5099b7f2f871c7e516988f60a54eb2a75bef7
Gerrit-Change-Number: 31080
Gerrit-PatchSet: 3
Gerrit-Owner: Duncan Laurie <dlaurie@chromium.org>
Gerrit-Reviewer: Duncan Laurie <dlaurie@chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan@google.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Subrata Banik <subrata.banik@intel.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged