mb/ocp/tiogapass: Fix GPIOs
[coreboot2.git] / src / mainboard / intel / kblrvp / chromeos.c
blob59d1a345d9605af7e3641d8020f55463195c4dc4
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <bootmode.h>
4 #include <boot/coreboot_tables.h>
5 #include <device/device.h>
6 #include <gpio.h>
7 #include <ec/google/chromeec/ec.h>
8 #include <types.h>
9 #include <vendorcode/google/chromeos/chromeos.h>
11 #include "gpio.h"
12 #include "ec.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);
30 /* Lid always open */
31 return 1;
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)
40 return 1;
42 /* Otherwise check if the EC has posted the keyboard recovery
43 * event. */
44 return !!(google_chromeec_get_events_b() &
45 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY));
48 return 0;
51 int get_write_protect_state(void)
53 /* No write protect */
54 return 0;
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. */
67 return 1;