| 1 |
|
| 2 |
|
| 3 |
#include <boot/coreboot_tables.h> |
| 4 |
#include <bootmode.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <device/device.h> |
| 7 |
#include <ec/google/chromeec/ec.h> |
| 8 |
#include <gpio.h> |
| 9 |
#include <soc/pcie.h> |
| 10 |
#include <soc/qupv3_config_common.h> |
| 11 |
#include <soc/qup_se_handlers_common.h> |
| 12 |
#include "board.h" |
| 13 |
#include <soc/usb/usb.h> |
| 14 |
|
| 15 |
static void setup_usb(void) |
| 16 |
{ |
| 17 |
setup_usb_host0(); |
| 18 |
} |
| 19 |
|
| 20 |
void lb_add_boot_mode(struct lb_header *header) |
| 21 |
{ |
| 22 |
if (!CONFIG(EC_GOOGLE_CHROMEEC)) |
| 23 |
return; |
| 24 |
|
| 25 |
struct lb_boot_mode *mode = (struct lb_boot_mode *)lb_new_record(header); |
| 26 |
memset(mode, 0, sizeof(*mode)); |
| 27 |
|
| 28 |
mode->tag = LB_TAG_BOOT_MODE; |
| 29 |
mode->size = sizeof(*mode); |
| 30 |
mode->boot_mode = LB_BOOT_MODE_NORMAL; |
| 31 |
|
| 32 |
if (google_chromeec_is_below_critical_threshold()) |
| 33 |
mode->boot_mode = LB_BOOT_MODE_LOW_BATTERY; |
| 34 |
|
| 35 |
|
| 36 |
if (mode->boot_mode == LB_BOOT_MODE_NORMAL) |
| 37 |
disable_slow_battery_charging(); |
| 38 |
} |
| 39 |
|
| 40 |
bool mainboard_needs_pcie_init(void) |
| 41 |
{ |
| 42 |
return true; |
| 43 |
} |
| 44 |
|
| 45 |
static void display_startup(void) |
| 46 |
{ |
| 47 |
if (!display_init_required()) { |
| 48 |
printk(BIOS_INFO, "Skipping display init.\n"); |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
static void mainboard_init(struct device *dev) |
| 56 |
{ |
| 57 |
gpi_firmware_load(QUP_0_GSI_BASE); |
| 58 |
gpi_firmware_load(QUP_1_GSI_BASE); |
| 59 |
gpi_firmware_load(QUP_2_GSI_BASE); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
if (!CONFIG(CONSOLE_SERIAL)) |
| 66 |
qupv3_se_fw_load_and_init(QUPV3_2_SE5, SE_PROTOCOL_UART, FIFO); |
| 67 |
|
| 68 |
qupv3_se_fw_load_and_init(QUPV3_1_SE0, SE_PROTOCOL_I2C, MIXED); |
| 69 |
qupv3_se_fw_load_and_init(QUPV3_1_SE6, SE_PROTOCOL_UART, FIFO); |
| 70 |
qupv3_se_fw_load_and_init(QUPV3_0_SE0, SE_PROTOCOL_I2C, MIXED); |
| 71 |
qupv3_se_fw_load_and_init(QUPV3_0_SE1, SE_PROTOCOL_I2C, MIXED); |
| 72 |
if (CONFIG(MAINBOARD_HAS_FINGERPRINT_VIA_SPI)) |
| 73 |
qupv3_se_fw_load_and_init(QUPV3_2_SE2, SE_PROTOCOL_SPI, MIXED); |
| 74 |
|
| 75 |
|
| 76 |
if (CONFIG_MAINBOARD_GPIO_PIN_FOR_TOUCHPAD_POWER) |
| 77 |
gpio_output(GPIO_TP_POWER_EN, 1); |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
if (CONFIG(MAINBOARD_HAS_FINGERPRINT)) |
| 84 |
gpio_output(GPIO_FP_RST_L, 1); |
| 85 |
|
| 86 |
|
| 87 |
setup_usb(); |
| 88 |
|
| 89 |
display_startup(); |
| 90 |
} |
| 91 |
|
| 92 |
static void mainboard_enable(struct device *dev) |
| 93 |
{ |
| 94 |
dev->ops->init = &mainboard_init; |
| 95 |
} |
| 96 |
|
| 97 |
struct chip_operations mainboard_ops = { |
| 98 |
.enable_dev = mainboard_enable, |
| 99 |
}; |