coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
chromeos.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <baseboard/gpio.h>
4 #include <bootmode.h>
5 #include <boot/coreboot_tables.h>
6 #include <gpio.h>
7 #include <soc/gpio.h>
8 #include <variant/gpio.h>
9 #include <types.h>
10 #include <vendorcode/google/chromeos/chromeos.h>
11 #include <security/tpm/tss.h>
12 #include <device/device.h>
13 #include <intelblocks/pmclib.h>
14 #include <soc/pmc.h>
15 #include <soc/pci_devs.h>
16 
21 };
22 
23 void fill_lb_gpios(struct lb_gpios *gpios)
24 {
25  struct lb_gpio chromeos_gpios[] = {
26  {-1, ACTIVE_HIGH, get_lid_switch(), "lid"},
27  {-1, ACTIVE_HIGH, 0, "power"},
28  {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"},
29  {-1, ACTIVE_HIGH, 0, "EC in RW"},
30  };
31  lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
32 }
33 
35 {
36  return gpio_get(GPIO_PCH_WP);
37 }
38 
40 {
41  return !gpio_get(GPIO_REC_MODE);
42 }
43 
44 
46 {
47  static enum rec_mode_state saved_rec_mode = REC_MODE_UNINITIALIZED;
49  uint8_t cr50_state = 0;
50 
51  /* Check cached state, since TPM will only tell us the first time */
52  if (saved_rec_mode != REC_MODE_UNINITIALIZED)
53  return saved_rec_mode == REC_MODE_REQUESTED;
54 
55  /*
56  * Read one-time recovery request from cr50 in verstage only since
57  * the TPM driver won't be set up in time for other stages like romstage
58  * and the value from the TPM would be wrong anyway since the verstage
59  * read would have cleared the value on the TPM.
60  *
61  * The TPM recovery request is passed between stages through vboot data
62  * or cbmem depending on stage.
63  */
66  cr50_state)
68 
69  /* Read state from the GPIO controlled by servo. */
72 
73  /* Store the state in case this is called again in verstage. */
74  saved_rec_mode = state;
75 
76  return state == REC_MODE_REQUESTED;
77 }
78 
79 int get_lid_switch(void)
80 {
81  return 1;
82 }
83 
85 {
86  /* Ensure system powers up after CR50 reset */
87  if (ENV_RAMSTAGE)
89 }
90 
92 {
93  /* Do not have a Chrome EC involved in entering recovery mode;
94  Always return trusted. */
95  return 1;
96 }
void fill_lb_gpios(struct lb_gpios *gpios)
Definition: chromeos.c:9
int get_write_protect_state(void)
Only used if CONFIG(CHROMEOS) is set.
Definition: chromeos.c:15
int gfx_get_init_done(void)
Definition: bootmode.c:10
#define ARRAY_SIZE(a)
Definition: helpers.h:12
int get_ec_is_trusted(void)
Definition: chromeos.c:25
int get_recovery_mode_switch(void)
HACK: Use Fn-Key as recovery mode switch.
Definition: chromeos.c:29
#define GPIO_REC_MODE
Definition: onboard.h:20
int get_lid_switch(void)
Definition: chromeos.c:37
#define ACTIVE_HIGH
Definition: chromeos.c:18
static bool raw_get_recovery_mode_switch(void)
Definition: chromeos.c:39
void mainboard_prepare_cr50_reset(void)
Definition: chromeos.c:84
rec_mode_state
Definition: chromeos.c:17
@ REC_MODE_REQUESTED
Definition: chromeos.c:20
@ REC_MODE_UNINITIALIZED
Definition: chromeos.c:18
@ REC_MODE_NOT_REQUESTED
Definition: chromeos.c:19
void lb_add_gpios(struct lb_gpios *gpios, const struct lb_gpio *gpio_table, size_t count)
int gpio_get(gpio_t gpio)
Definition: gpio.c:166
#define GPIO_PCH_WP
Definition: gpio.h:14
state
Definition: raminit.c:1787
#define ENV_RAMSTAGE
Definition: rules.h:150
#define ENV_SEPARATE_VERSTAGE
Definition: rules.h:152
uint32_t tlcl_cr50_get_recovery_button(uint8_t *recovery_button_state)
CR50 specific tpm command to get the latched state of the recovery button.
Definition: cr50.c:51
void pmc_soc_set_afterg3_en(const bool on)
Definition: pmutil.c:263
unsigned char uint8_t
Definition: stdint.h:8
#define TPM_SUCCESS
Definition: tss_common.h:9