libpayload: configs: Add new config.featuretest to broaden CI
[coreboot2.git] / src / vendorcode / google / chromeos / acpi.c
blobfb6d0a5e70dd7fd45e9b086be56dc50b7551abb4
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpigen.h>
4 #if CONFIG(GENERIC_GPIO_LIB)
5 #include <gpio.h>
6 #endif
7 #include "chromeos.h"
9 void chromeos_acpi_gpio_generate(void)
11 const struct cros_gpio *gpios;
12 size_t i, num;
13 int gpio_num;
15 num = variant_cros_gpio.count;
16 gpios = variant_cros_gpio.gpios;
17 if (num && !gpios)
18 return;
20 acpigen_write_scope("\\");
21 acpigen_write_name("OIPG");
23 acpigen_write_package(num);
24 for (i = 0; i < num; i++) {
25 acpigen_write_package(4);
26 acpigen_write_integer(gpios[i].type);
27 acpigen_write_integer(gpios[i].polarity);
28 gpio_num = gpios[i].gpio_num;
29 #if CONFIG(GENERIC_GPIO_LIB)
30 /* Get ACPI pin from GPIO library if available */
31 if (gpios[i].gpio_num != CROS_GPIO_VIRTUAL)
32 gpio_num = gpio_acpi_pin(gpio_num);
33 #endif
34 acpigen_write_integer(gpio_num);
35 acpigen_write_string(gpios[i].device);
36 acpigen_pop_len();
38 acpigen_pop_len();
40 acpigen_pop_len();