Debian Codegraph @

src/mainboard/google/cherry/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 "gpio.h"
9
10 void setup_chromeos_gpios(void)
11 {
12 gpio_input(GPIO_WP);
13 gpio_input_pullup(GPIO_EC_AP_INT);
14 gpio_input_pullup(GPIO_SD_CD);
15 gpio_input_pullup(GPIO_EC_IN_RW);
16 gpio_input_pullup(GPIO_GSC_AP_INT);
17 gpio_output(GPIO_EN_SPK, 0);
18 gpio_output(GPIO_RESET, 0);
19 gpio_output(GPIO_XHCI_DONE, 0);
20 if (CONFIG(CHERRY_USE_RT1019))
21 gpio_output(GPIO_BEEP_ON, 0);
22 else if (CONFIG(CHERRY_USE_RT1011))
23 gpio_output(GPIO_RST_RT1011, 0);
24 }
25
26 void fill_lb_gpios(struct lb_gpios *gpios)
27 {
28 struct lb_gpio chromeos_gpios[] = {
29 {GPIO_EC_AP_INT.id, ACTIVE_LOW, -1, "EC interrupt"},
30 {GPIO_SD_CD.id, ACTIVE_LOW, -1, "SD card detect"},
31 {GPIO_EC_IN_RW.id, ACTIVE_LOW, -1, "EC in RW"},
32 /*
33 * The GPIO_GSC_AP_INT itself is active low, but the payloads will
34 * create the IRQ using its eint driver, which is active high.
35 */
36 {GPIO_GSC_AP_INT.id, ACTIVE_HIGH, -1, "TPM interrupt"},
37 };
38
39 struct lb_gpio rt1019_gpios[] = {
40 {GPIO_BEEP_ON.id, ACTIVE_HIGH, -1, "beep enable"},
41 {GPIO_EN_SPK.id, ACTIVE_HIGH, -1, "speaker enable"},
42 };
43
44 struct lb_gpio rt1011_gpios[] = {
45 {GPIO_RST_RT1011.id, ACTIVE_HIGH, -1, "rt1011 reset"},
46 {GPIO_EN_SPK.id, ACTIVE_HIGH, -1, "speaker enable"},
47 };
48
49 struct lb_gpio spk_gpios[] = {
50 {GPIO_EN_SPK.id, ACTIVE_HIGH, -1, "speaker enable"},
51 };
52
53 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
54
55 if (CONFIG(CHERRY_USE_RT1019))
56 lb_add_gpios(gpios, rt1019_gpios, ARRAY_SIZE(rt1019_gpios));
57 else if (CONFIG(CHERRY_USE_RT1011))
58 lb_add_gpios(gpios, rt1011_gpios, ARRAY_SIZE(rt1011_gpios));
59 else if (CONFIG(CHERRY_USE_MAX98390))
60 lb_add_gpios(gpios, spk_gpios, ARRAY_SIZE(spk_gpios));
61 }
62
63 int cr50_plat_irq_status(void)
64 {
65 return gpio_eint_poll(GPIO_GSC_AP_INT);
66 }
67
68 int get_ec_is_trusted(void)
69 {
70 /* EC is trusted if not in RW. This is active low. */
71 return !!gpio_get(GPIO_EC_IN_RW);
72 }