coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
chromeos.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <bootmode.h>
4 #include <boot/coreboot_tables.h>
7 #include <gpio.h>
8 
9 #include "board.h"
10 
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)
17 
19 {
25 }
26 
27 void fill_lb_gpios(struct lb_gpios *gpios)
28 {
29  struct lb_gpio chromeos_gpios[] = {
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"},
38  };
39  lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
40 }
41 
43 {
44  uint64_t ec_events;
45 
46  /* The GPIO is active low. */
47  if (!gpio_get(GPIO_RECOVERY))
48  return 1;
49 
50  ec_events = google_chromeec_get_events_b();
51  return !!(ec_events &
53 }
54 
56 {
57  return !gpio_get(GPIO_WP);
58 }
59 
61 {
62  /* EC is trusted if not in RW. */
63  return !gpio_get(GPIO_ECINRW);
64 }
void fill_lb_gpios(struct lb_gpios *gpios)
Definition: chromeos.c:9
int get_write_protect_state(void)
Only used if CONFIG(CHROMEOS) is set.
Definition: chromeos.c:15
#define ARRAY_SIZE(a)
Definition: helpers.h:12
uint64_t google_chromeec_get_events_b(void)
Definition: ec.c:272
@ EC_HOST_EVENT_KEYBOARD_RECOVERY
Definition: ec_commands.h:676
#define EC_HOST_EVENT_MASK(event_code)
Definition: ec_commands.h:738
int get_ec_is_trusted(void)
Definition: chromeos.c:25
void setup_chromeos_gpios(void)
Definition: chromeos.c:10
int get_recovery_mode_switch(void)
HACK: Use Fn-Key as recovery mode switch.
Definition: chromeos.c:29
#define ACTIVE_HIGH
Definition: chromeos.c:18
#define ACTIVE_LOW
Definition: chromeos.c:17
#define GPIO_BACKLIGHT
Definition: board.h:27
#define GPIO_POWER
Definition: chromeos.c:13
#define GPIO_RECOVERY
Definition: chromeos.c:14
#define GPIO_ECINRW
Definition: chromeos.c:15
#define GPIO_ECIRQ
Definition: chromeos.c:16
#define GPIO_LID
Definition: chromeos.c:12
#define GPIO_WP
Definition: chromeos.c:11
void lb_add_gpios(struct lb_gpios *gpios, const struct lb_gpio *gpio_table, size_t count)
int gpio_get(gpio_t gpio)
Definition: gpio.c:166
void gpio_input(gpio_t gpio)
Definition: gpio.c:189
void gpio_input_pullup(gpio_t gpio)
Definition: gpio.c:184
#define GPIO_RESET
Definition: gpio.h:16
unsigned long long uint64_t
Definition: stdint.h:17