| 1 |
|
| 2 |
|
| 3 |
#include <bootmode.h> |
| 4 |
#include <boot/coreboot_tables.h> |
| 5 |
#include <ec/google/chromeec/ec.h> |
| 6 |
#include <ec/google/chromeec/ec_commands.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 |
|
| 18 |
void setup_chromeos_gpios(void) |
| 19 |
{ |
| 20 |
gpio_input(GPIO_WP); |
| 21 |
gpio_input_pullup(GPIO_LID); |
| 22 |
gpio_input(GPIO_POWER); |
| 23 |
gpio_input_pullup(GPIO_RECOVERY); |
| 24 |
gpio_input(GPIO_ECIRQ); |
| 25 |
} |
| 26 |
|
| 27 |
void fill_lb_gpios(struct lb_gpios *gpios) |
| 28 |
{ |
| 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"}, |
| 38 |
}; |
| 39 |
lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); |
| 40 |
} |
| 41 |
|
| 42 |
int get_recovery_mode_switch(void) |
| 43 |
{ |
| 44 |
uint64_t ec_events; |
| 45 |
|
| 46 |
|
| 47 |
if (!gpio_get(GPIO_RECOVERY)) |
| 48 |
return 1; |
| 49 |
|
| 50 |
ec_events = google_chromeec_get_events_b(); |
| 51 |
return !!(ec_events & |
| 52 |
EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY)); |
| 53 |
} |
| 54 |
|
| 55 |
int get_write_protect_state(void) |
| 56 |
{ |
| 57 |
return !gpio_get(GPIO_WP); |
| 58 |
} |
| 59 |
|
| 60 |
int get_ec_is_trusted(void) |
| 61 |
{ |
| 62 |
|
| 63 |
return !gpio_get(GPIO_ECINRW); |
| 64 |
} |