Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2016 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #include <arch/acpigen.h> |
Duncan Laurie | 718d185 | 2018-12-10 11:29:36 -0800 | [diff] [blame] | 17 | #if IS_ENABLED(CONFIG_GENERIC_GPIO_LIB) |
| 18 | #include <gpio.h> |
| 19 | #endif |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 20 | #include "chromeos.h" |
| 21 | |
| 22 | void chromeos_acpi_gpio_generate(const struct cros_gpio *gpios, size_t num) |
| 23 | { |
| 24 | size_t i; |
Duncan Laurie | 718d185 | 2018-12-10 11:29:36 -0800 | [diff] [blame] | 25 | int gpio_num; |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 26 | |
| 27 | acpigen_write_scope("\\"); |
| 28 | acpigen_write_name("OIPG"); |
| 29 | |
| 30 | acpigen_write_package(num); |
| 31 | for (i = 0; i < num; i++) { |
| 32 | acpigen_write_package(4); |
| 33 | acpigen_write_integer(gpios[i].type); |
| 34 | acpigen_write_integer(gpios[i].polarity); |
Duncan Laurie | 718d185 | 2018-12-10 11:29:36 -0800 | [diff] [blame] | 35 | gpio_num = gpios[i].gpio_num; |
| 36 | #if IS_ENABLED(CONFIG_GENERIC_GPIO_LIB) |
| 37 | /* Get ACPI pin from GPIO library if available */ |
| 38 | if (gpios[i].gpio_num != CROS_GPIO_VIRTUAL) |
| 39 | gpio_num = gpio_acpi_pin(gpio_num); |
| 40 | #endif |
| 41 | acpigen_write_integer(gpio_num); |
Aaron Durbin | b0f8151 | 2016-07-25 21:31:41 -0500 | [diff] [blame] | 42 | acpigen_write_string(gpios[i].device); |
| 43 | acpigen_pop_len(); |
| 44 | } |
| 45 | acpigen_pop_len(); |
| 46 | |
| 47 | acpigen_pop_len(); |
| 48 | } |
| 49 | |
| 50 | void chromeos_dsdt_generator(struct device *dev) |
| 51 | { |
| 52 | mainboard_chromeos_acpi_generate(); |
| 53 | } |