1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <boot/coreboot_tables.h>
5 #include <ec/google/chromeec/ec.h>
6 #include <ec/google/chromeec/ec_commands.h>
11 #define GPIO_WP GPIO(7, A, 6)
12 #define GPIO_LID GPIO(0, A, 6)
13 #define GPIO_POWER GPIO(0, A, 5)
14 #define GPIO_RECOVERY GPIO(0, B, 1)
15 #define GPIO_ECINRW GPIO(0, A, 7)
16 #define GPIO_ECIRQ GPIO(7, A, 7)
18 void setup_chromeos_gpios(void)
21 gpio_input_pullup(GPIO_LID
);
22 gpio_input(GPIO_POWER
);
23 gpio_input_pullup(GPIO_RECOVERY
);
24 gpio_input(GPIO_ECIRQ
);
27 void fill_lb_gpios(struct lb_gpios
*gpios
)
29 struct lb_gpio chromeos_gpios
[] = {
30 {GPIO_RECOVERY
.raw
, ACTIVE_LOW
,
31 !get_recovery_mode_switch(), "presence"},
32 {GPIO_LID
.raw
, ACTIVE_HIGH
, -1, "lid"},
33 {GPIO_POWER
.raw
, ACTIVE_LOW
, -1, "power"},
34 {GPIO_ECINRW
.raw
, ACTIVE_HIGH
, -1, "EC in RW"},
35 {GPIO_ECIRQ
.raw
, ACTIVE_LOW
, -1, "EC interrupt"},
36 {GPIO_RESET
.raw
, ACTIVE_HIGH
, -1, "reset"},
37 {GPIO_BACKLIGHT
.raw
, ACTIVE_HIGH
, -1, "backlight"},
39 lb_add_gpios(gpios
, chromeos_gpios
, ARRAY_SIZE(chromeos_gpios
));
42 int get_recovery_mode_switch(void)
46 /* The GPIO is active low. */
47 if (!gpio_get(GPIO_RECOVERY
))
50 ec_events
= google_chromeec_get_events_b();
52 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY
));
55 int get_write_protect_state(void)
57 return !gpio_get(GPIO_WP
);
60 int get_ec_is_trusted(void)
62 /* EC is trusted if not in RW. */
63 return !gpio_get(GPIO_ECINRW
);