1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <boot/coreboot_tables.h>
5 #include <drivers/tpm/cr50.h>
6 #include <ec/google/chromeec/ec.h>
12 void setup_chromeos_gpios(void)
14 /* Set up open-drain pins */
15 gpio_input(GPIO_SAR_INT_ODL
);
16 gpio_input(GPIO_BT_WAKE_AP_ODL
);
17 gpio_input(GPIO_WIFI_INT_ODL
);
18 gpio_input(GPIO_DPBRDG_INT_ODL
);
19 gpio_input(GPIO_EDPBRDG_INT_ODL
);
20 gpio_input(GPIO_EC_AP_HPD_OD
);
21 gpio_input(GPIO_TCHPAD_INT_ODL
);
22 gpio_input(GPIO_TCHSCR_INT_1V8_ODL
);
23 gpio_input(GPIO_EC_AP_INT_ODL
);
24 gpio_input(GPIO_EC_IN_RW_ODL
);
25 gpio_input(GPIO_GSC_AP_INT_ODL
);
26 gpio_input(GPIO_AP_WP_ODL
);
27 gpio_input(GPIO_HP_INT_ODL
);
28 gpio_input(GPIO_PEN_EJECT_OD
);
29 gpio_input(GPIO_UCAM_DET_ODL
);
32 gpio_output(GPIO_RESET
, 0);
33 gpio_output(GPIO_XHCI_DONE
, 0);
34 gpio_output(GPIO_EN_SPK
, 0);
37 void fill_lb_gpios(struct lb_gpios
*gpios
)
39 struct lb_gpio chromeos_gpios
[] = {
40 {GPIO_EC_AP_INT_ODL
.id
, ACTIVE_LOW
, -1, "EC interrupt"},
41 {GPIO_EC_IN_RW_ODL
.id
, ACTIVE_LOW
, -1, "EC in RW"},
42 {GPIO_GSC_AP_INT_ODL
.id
, ACTIVE_HIGH
, -1, "TPM interrupt"},
43 {GPIO_EN_SPK
.id
, ACTIVE_HIGH
, -1, "speaker enable"},
45 lb_add_gpios(gpios
, chromeos_gpios
, ARRAY_SIZE(chromeos_gpios
));
48 int get_ec_is_trusted(void)
51 bool has_cr50
= false;
54 * Kingler and Krabby's rev 0 boards both use Cr50 instead of Ti50. In order to share
55 * the same firmware with newer rev, get the board rev from CBI, and ignore
56 * TPM_GOOGLE_TI50 when rev is 0.
58 if (CONFIG(BOARD_GOOGLE_KINGLER
) || CONFIG(BOARD_GOOGLE_KRABBY
)) {
59 if (google_chromeec_cbi_get_board_version(&rev
) == 0 && rev
== 0)
63 /* With Ti50, VB2_CONTEXT_EC_TRUSTED should be set according to the boot mode. */
64 if (CONFIG(TPM_GOOGLE_TI50
) && !has_cr50
)
67 /* EC is trusted if not in RW. This is active low. */
68 return !!gpio_get(GPIO_EC_IN_RW_ODL
);
71 int cr50_plat_irq_status(void)
73 return gpio_eint_poll(GPIO_GSC_AP_INT_ODL
);