• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <boot/coreboot_tables.h>
4 #include <ec/google/chromeec/ec.h>
5 #include <ec/google/chromeec/ec_commands.h>
6 #include <soc/cpu.h>
7 #include <soc/gpio.h>
8 #include <types.h>
9 #include <vendorcode/google/chromeos/chromeos.h>
10 #include <bootmode.h>
11 
fill_lb_gpios(struct lb_gpios * gpios)12 void fill_lb_gpios(struct lb_gpios *gpios)
13 {
14 	struct lb_gpio chromeos_gpios[] = {
15 		/* Lid: active high (LID_GPIO) */
16 		{EXYNOS5_GPX3, ACTIVE_HIGH, gpio_get_value(GPIO_X35), "lid"},
17 
18 		/* Power: virtual GPIO active low (POWER_GPIO) */
19 		{EXYNOS5_GPX1, ACTIVE_LOW, gpio_get_value(GPIO_X13), "power"},
20 	};
21 	lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
22 }
23 
get_recovery_mode_switch(void)24 int get_recovery_mode_switch(void)
25 {
26 	uint64_t ec_events;
27 
28 	/* The GPIO is active low. */
29 	if (!gpio_get_value(GPIO_Y10)) // RECMODE_GPIO
30 		return 1;
31 
32 	ec_events = google_chromeec_get_events_b();
33 	return !!(ec_events &
34 		  EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY));
35 }
36 
get_write_protect_state(void)37 int get_write_protect_state(void)
38 {
39 	return !gpio_get_value(GPIO_D16);
40 }
41 
get_ec_is_trusted(void)42 int get_ec_is_trusted(void)
43 {
44 	/* EC is trusted if not in RW. */
45 	return !gpio_get_value(GPIO_D17);
46 }
47