Debian Codegraph @

src/mainboard/google/butterfly/chromeos.c

raw symbols SCIP
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 <southbridge/intel/bd82x6x/pch.h>
8 #include <ec/quanta/ene_kb3940q/ec.h>
9 #include <types.h>
10 #include <vendorcode/google/chromeos/chromeos.h>
11 #include "ec.h"
12 #include "onboard.h"
13
14 void fill_lb_gpios(struct lb_gpios *gpios)
15 {
16 struct lb_gpio chromeos_gpios[] = {
17 /* lid switch value from EC */
18 {-1, ACTIVE_HIGH, get_lid_switch(), "lid"},
19
20 /* Power Button - Hardcode Low as power button may still be
21 * pressed when read here.*/
22 {-1, ACTIVE_HIGH, 0, "power"},
23
24 /* Was VGA Option ROM loaded? */
25 /* -1 indicates that this is a pseudo GPIO */
26 {-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"},
27 };
28 lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
29 }
30
31 int get_write_protect_state(void)
32 {
33 return !gpio_get(WP_GPIO);
34 }
35
36 int get_lid_switch(void)
37 {
38 return (ec_mem_read(EC_HW_GPI_STATUS) >> EC_GPI_LID_STAT_BIT) & 1;
39 }
40
41 /* FIXME: VBOOT reads this in ENV_SEPARATE_ROMSTAGE. */
42 int get_recovery_mode_switch(void)
43 {
44 if (ENV_RAMSTAGE)
45 return (ec_mem_read(EC_CODE_STATE) == EC_COS_EC_RO);
46
47 return 0;
48 }
49
50 static const struct cros_gpio cros_gpios[] = {
51 CROS_GPIO_REC_AH(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
52 CROS_GPIO_WP_AL(WP_GPIO, CROS_GPIO_DEVICE_NAME),
53 };
54 DECLARE_CROS_GPIOS(cros_gpios);
55
56 int get_ec_is_trusted(void)
57 {
58 /* Do not have a Chrome EC involved in entering recovery mode;
59 Always return trusted. */
60 return 1;
61 }