1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <boot/coreboot_tables.h>
7 #include <variant/gpio.h>
9 #include <vendorcode/google/chromeos/chromeos.h>
10 #include <security/tpm/tss.h>
11 #include <device/device.h>
12 #include <intelblocks/pmclib.h>
14 #include <soc/pci_devs.h>
17 REC_MODE_UNINITIALIZED
,
18 REC_MODE_NOT_REQUESTED
,
22 void fill_lb_gpios(struct lb_gpios
*gpios
)
24 struct lb_gpio chromeos_gpios
[] = {
25 {-1, ACTIVE_HIGH
, get_lid_switch(), "lid"},
26 {-1, ACTIVE_HIGH
, 0, "power"},
27 {-1, ACTIVE_HIGH
, gfx_get_init_done(), "oprom"},
28 {-1, ACTIVE_HIGH
, 0, "EC in RW"},
30 lb_add_gpios(gpios
, chromeos_gpios
, ARRAY_SIZE(chromeos_gpios
));
33 int get_write_protect_state(void)
35 return gpio_get(GPP_E15
);
38 static bool raw_get_recovery_mode_switch(void)
40 return !gpio_get(GPP_E8
);
44 int get_recovery_mode_switch(void)
46 static enum rec_mode_state saved_rec_mode
= REC_MODE_UNINITIALIZED
;
47 enum rec_mode_state state
= REC_MODE_NOT_REQUESTED
;
48 uint8_t cr50_state
= 0;
50 /* Check cached state, since TPM will only tell us the first time */
51 if (saved_rec_mode
!= REC_MODE_UNINITIALIZED
)
52 return saved_rec_mode
== REC_MODE_REQUESTED
;
55 * Read one-time recovery request from cr50 in verstage only since
56 * the TPM driver won't be set up in time for other stages like romstage
57 * and the value from the TPM would be wrong anyway since the verstage
58 * read would have cleared the value on the TPM.
60 * The TPM recovery request is passed between stages through vboot data
61 * or cbmem depending on stage.
63 if (ENV_SEPARATE_VERSTAGE
&&
64 tlcl_cr50_get_recovery_button(&cr50_state
) == TPM_SUCCESS
&&
66 state
= REC_MODE_REQUESTED
;
68 /* Read state from the GPIO controlled by servo. */
69 if (raw_get_recovery_mode_switch())
70 state
= REC_MODE_REQUESTED
;
72 /* Store the state in case this is called again in verstage. */
73 saved_rec_mode
= state
;
75 return state
== REC_MODE_REQUESTED
;
78 int get_lid_switch(void)
83 void mainboard_prepare_cr50_reset(void)
86 /* Ensure system powers up after CR50 reset */
87 pmc_soc_set_afterg3_en(true);
91 int get_ec_is_trusted(void)
93 /* Do not have a Chrome EC involved in entering recovery mode;
94 Always return trusted. */