1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <boot/coreboot_tables.h>
5 #include <device/device.h>
7 #include <ec/google/chromeec/ec.h>
9 #include <vendorcode/google/chromeos/chromeos.h>
14 void fill_lb_gpios(struct lb_gpios
*gpios
)
16 struct lb_gpio chromeos_gpios
[] = {
17 {-1, ACTIVE_HIGH
, get_lid_switch(), "lid"},
18 {-1, ACTIVE_HIGH
, 0, "power"},
19 {-1, ACTIVE_HIGH
, gfx_get_init_done(), "oprom"},
21 lb_add_gpios(gpios
, chromeos_gpios
, ARRAY_SIZE(chromeos_gpios
));
24 int get_lid_switch(void)
26 if (CONFIG(EC_GOOGLE_CHROMEEC
))
27 /* Read lid switch state from the EC. */
28 return !!(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN
);
34 int get_recovery_mode_switch(void)
36 if (CONFIG(EC_GOOGLE_CHROMEEC
)) {
37 /* Check for dedicated recovery switch first. */
38 if (google_chromeec_get_switches() &
39 EC_SWITCH_DEDICATED_RECOVERY
)
42 /* Otherwise check if the EC has posted the keyboard recovery
44 return !!(google_chromeec_get_events_b() &
45 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY
));
51 int get_write_protect_state(void)
53 /* No write protect */
57 static const struct cros_gpio cros_gpios
[] = {
58 CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL
, CROS_GPIO_DEVICE_NAME
),
59 CROS_GPIO_WP_AH(CROS_GPIO_VIRTUAL
, CROS_GPIO_DEVICE_NAME
),
61 DECLARE_CROS_GPIOS(cros_gpios
);
63 int get_ec_is_trusted(void)
65 /* Do not have a Chrome EC involved in entering recovery mode;
66 Always return trusted. */