Mathew King | 44948a7 | 2021-02-10 16:05:38 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
Mathew King | 5d47887 | 2021-02-16 14:05:15 -0700 | [diff] [blame] | 3 | #include <baseboard/gpio.h> |
Hsuan-ting Chen | 642508a | 2021-10-27 10:59:41 +0000 | [diff] [blame] | 4 | #include <boardid.h> |
Kyösti Mälkki | be7692a | 2021-11-03 17:54:14 +0200 | [diff] [blame] | 5 | #include <bootmode.h> |
Mathew King | 44948a7 | 2021-02-10 16:05:38 -0700 | [diff] [blame] | 6 | #include <boot/coreboot_tables.h> |
| 7 | #include <gpio.h> |
Kyösti Mälkki | 9a3bde0 | 2021-11-06 16:13:15 +0200 | [diff] [blame] | 8 | #include <types.h> |
Mathew King | 44948a7 | 2021-02-10 16:05:38 -0700 | [diff] [blame] | 9 | #include <vendorcode/google/chromeos/chromeos.h> |
| 10 | |
| 11 | void fill_lb_gpios(struct lb_gpios *gpios) |
| 12 | { |
| 13 | struct lb_gpio chromeos_gpios[] = { |
Karthikeyan Ramasubramanian | 1b7dac1 | 2021-07-21 14:54:16 -0600 | [diff] [blame] | 14 | {GPIO_EC_IN_RW, ACTIVE_HIGH, gpio_get(GPIO_EC_IN_RW), "EC in RW"}, |
Mathew King | 44948a7 | 2021-02-10 16:05:38 -0700 | [diff] [blame] | 15 | }; |
| 16 | lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); |
| 17 | } |
Mathew King | 5d47887 | 2021-02-16 14:05:15 -0700 | [diff] [blame] | 18 | |
| 19 | static const struct cros_gpio cros_gpios[] = { |
| 20 | CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, GPIO_DEVICE_NAME), |
| 21 | CROS_GPIO_WP_AL(CROS_WP_GPIO, GPIO_DEVICE_NAME), |
| 22 | }; |
Kyösti Mälkki | 4ff218a | 2021-11-02 13:03:06 +0200 | [diff] [blame] | 23 | DECLARE_CROS_GPIOS(cros_gpios); |
Hsuan-ting Chen | 642508a | 2021-10-27 10:59:41 +0000 | [diff] [blame] | 24 | |
| 25 | int get_ec_is_trusted(void) |
| 26 | { |
| 27 | /* Board versions 1 & 2 support H1 DB, but the EC_IN_RW signal is not |
| 28 | routed. So emulate EC is trusted. */ |
| 29 | if (CONFIG(BOARD_GOOGLE_GUYBRUSH) && |
| 30 | (board_id() == UNDEFINED_STRAPPING_ID || board_id() < 3)) |
| 31 | return 1; |
| 32 | /* EC is trusted if not in RW. */ |
| 33 | return !gpio_get(GPIO_EC_IN_RW); |
| 34 | } |