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-only */
2 
3 #include <bootmode.h>
4 #include <boot/coreboot_tables.h>
5 #include <device/device.h>
6 #include <gpio.h>
7 #include <soc/gpio.h>
9 #include <types.h>
10 #include <vendorcode/google/chromeos/chromeos.h>
11 
12 #include "gpio.h"
13 #include "ec.h"
14 
15 void fill_lb_gpios(struct lb_gpios *gpios)
16 {
17  struct lb_gpio chromeos_gpios[] = {
18  {-1, ACTIVE_HIGH, get_lid_switch(), "lid"},
19  {-1, ACTIVE_HIGH, 0, "power"},
20  {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"},
21  };
22  lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
23 }
24 
25 int get_lid_switch(void)
26 {
27  if (CONFIG(EC_GOOGLE_CHROMEEC))
28  /* Read lid switch state from the EC. */
30 
31  /* Lid always open */
32  return 1;
33 }
34 
36 {
37  if (CONFIG(EC_GOOGLE_CHROMEEC)) {
38  /* Check for dedicated recovery switch first. */
41  return 1;
42 
43  /* Otherwise check if the EC has posted the keyboard recovery
44  * event. */
45  return !!(google_chromeec_get_events_b() &
47  }
48 
49  return 0;
50 }
51 
53 {
54  /* No write protect */
55  return 0;
56 }
57 
58 static const struct cros_gpio cros_gpios[] = {
59  CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
60  CROS_GPIO_WP_AH(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
61 };
63 
65 {
66  /* Do not have a Chrome EC involved in entering recovery mode;
67  Always return trusted. */
68  return 1;
69 }
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
@ CONFIG
Definition: dsi_common.h:201
uint64_t google_chromeec_get_events_b(void)
Definition: ec.c:272
uint8_t google_chromeec_get_switches(void)
Definition: ec_lpc.c:359
#define EC_SWITCH_LID_OPEN
Definition: ec_commands.h:227
@ EC_HOST_EVENT_KEYBOARD_RECOVERY
Definition: ec_commands.h:676
#define EC_HOST_EVENT_MASK(event_code)
Definition: ec_commands.h:738
#define EC_SWITCH_DEDICATED_RECOVERY
Definition: ec_commands.h:233
DECLARE_CROS_GPIOS(cros_gpios)
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
int get_lid_switch(void)
Definition: chromeos.c:37
#define ACTIVE_HIGH
Definition: chromeos.c:18
void lb_add_gpios(struct lb_gpios *gpios, const struct lb_gpio *gpio_table, size_t count)
static const struct cros_gpio cros_gpios[]
Definition: chromeos.c:58
#define CROS_GPIO_DEVICE_NAME
Definition: gpio.h:14