Debian Codegraph @

src/mainboard/google/gru/chromeos.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <bootmode.h>
4 #include <boot/coreboot_tables.h>
5 #include <drivers/tpm/cr50.h>
6 #include <gpio.h>
7
8 #include "board.h"
9
10 static const uint32_t wp_polarity = CONFIG(GRU_BASEBOARD_SCARLET) ?
11 ACTIVE_LOW : ACTIVE_HIGH;
12
13 int get_write_protect_state(void)
14 {
15 return gpio_get(GPIO_WP) ^ !wp_polarity;
16 }
17
18 void fill_lb_gpios(struct lb_gpios *gpios)
19 {
20 struct lb_gpio chromeos_gpios[] = {
21 #if CONFIG(GRU_BASEBOARD_SCARLET)
22 {GPIO_BACKLIGHT.raw, ACTIVE_HIGH, -1, "backlight"},
23 #endif
24 {GPIO_EC_IN_RW.raw, ACTIVE_HIGH, -1, "EC in RW"},
25 {GPIO_EC_IRQ.raw, ACTIVE_LOW, -1, "EC interrupt"},
26 {GPIO_RESET.raw, ACTIVE_HIGH, -1, "reset"},
27 {GPIO_SPK_PA_EN.raw, ACTIVE_HIGH, -1, "speaker enable"},
28 #if CONFIG(GRU_HAS_TPM2)
29 {GPIO_TPM_IRQ.raw, ACTIVE_HIGH, -1, "TPM interrupt"},
30 #endif
31 };
32
33 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
34 }
35
36 void setup_chromeos_gpios(void)
37 {
38 if (CONFIG(GRU_BASEBOARD_SCARLET))
39 gpio_input(GPIO_WP);
40 else
41 gpio_input_pullup(GPIO_WP);
42 gpio_input_pullup(GPIO_EC_IN_RW);
43 gpio_input_pullup(GPIO_EC_IRQ);
44 }
45
46 #if CONFIG(GRU_HAS_TPM2)
47 int cr50_plat_irq_status(void)
48 {
49 return gpio_irq_status(GPIO_TPM_IRQ);
50 }
51 #endif
52
53 int get_ec_is_trusted(void)
54 {
55 /* EC is trusted if not in RW. */
56 return !gpio_get(GPIO_EC_IN_RW);
57 }