| 1 |
|
| 2 |
|
| 3 |
#include <bootmode.h> |
| 4 |
#include <boot/coreboot_tables.h> |
| 5 |
#include <device/pci_ops.h> |
| 6 |
#include <console/console.h> |
| 7 |
#include <device/device.h> |
| 8 |
#include <gpio.h> |
| 9 |
#include <southbridge/intel/bd82x6x/pch.h> |
| 10 |
#include <types.h> |
| 11 |
#include <vendorcode/google/chromeos/chromeos.h> |
| 12 |
#include "ec.h" |
| 13 |
#include <ec/quanta/it8518/ec.h> |
| 14 |
#include "onboard.h" |
| 15 |
|
| 16 |
void fill_lb_gpios(struct lb_gpios *gpios) |
| 17 |
{ |
| 18 |
struct lb_gpio chromeos_gpios[] = { |
| 19 |
|
| 20 |
{-1, ACTIVE_HIGH, get_lid_switch(), "lid"}, |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
{-1, ACTIVE_HIGH, 0, "power"}, |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
{-1, ACTIVE_HIGH, gfx_get_init_done(), "oprom"}, |
| 29 |
|
| 30 |
|
| 31 |
{-1, ACTIVE_HIGH, !get_recovery_mode_switch(), "ec_in_rw"} |
| 32 |
}; |
| 33 |
lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); |
| 34 |
} |
| 35 |
|
| 36 |
int get_write_protect_state(void) |
| 37 |
{ |
| 38 |
return !gpio_get(GPIO_SPI_WP); |
| 39 |
} |
| 40 |
|
| 41 |
int get_lid_switch(void) |
| 42 |
{ |
| 43 |
|
| 44 |
return 1; |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
int get_recovery_mode_switch(void) |
| 55 |
{ |
| 56 |
static int ec_in_rec_mode; |
| 57 |
static int ec_rec_flag_good; |
| 58 |
|
| 59 |
if (ec_rec_flag_good) |
| 60 |
return ec_in_rec_mode; |
| 61 |
|
| 62 |
const pci_devfn_t dev = PCI_DEV(0, 0x1f, 0); |
| 63 |
u8 reg8 = pci_s_read_config8(dev, GEN_PMCON_3); |
| 64 |
|
| 65 |
u8 ec_status = ec_read(EC_STATUS_REG); |
| 66 |
|
| 67 |
printk(BIOS_SPEW,"%s: EC status:%#x RTC_BAT: %x\n", |
| 68 |
__func__, ec_status, reg8 & RTC_BATTERY_DEAD); |
| 69 |
|
| 70 |
ec_in_rec_mode = (((reg8 & RTC_BATTERY_DEAD) != 0) && |
| 71 |
((ec_status & 0x3) == EC_IN_RECOVERY_MODE)); |
| 72 |
ec_rec_flag_good = 1; |
| 73 |
return ec_in_rec_mode; |
| 74 |
} |
| 75 |
|
| 76 |
static const struct cros_gpio cros_gpios[] = { |
| 77 |
CROS_GPIO_REC_AH(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME), |
| 78 |
CROS_GPIO_WP_AL(GPIO_SPI_WP, CROS_GPIO_DEVICE_NAME), |
| 79 |
}; |
| 80 |
|
| 81 |
DECLARE_CROS_GPIOS(cros_gpios); |