summaryrefslogtreecommitdiff
path: root/board/eve
diff options
context:
space:
mode:
Diffstat (limited to 'board/eve')
-rw-r--r--board/eve/battery.c656
-rw-r--r--board/eve/board.c981
-rw-r--r--board/eve/board.h316
-rw-r--r--board/eve/build.mk14
-rw-r--r--board/eve/ec.tasklist26
-rw-r--r--board/eve/gpio.inc126
-rw-r--r--board/eve/led.c676
-rw-r--r--board/eve/usb_pd_policy.c134
-rw-r--r--board/eve/vif_override.xml3
9 files changed, 0 insertions, 2932 deletions
diff --git a/board/eve/battery.c b/board/eve/battery.c
deleted file mode 100644
index b5fb949ffe..0000000000
--- a/board/eve/battery.c
+++ /dev/null
@@ -1,656 +0,0 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Placeholder values for temporary battery pack.
- */
-
-#include "battery.h"
-#include "battery_smart.h"
-#include "bd9995x.h"
-#include "charge_ramp.h"
-#include "charge_state.h"
-#include "console.h"
-#include "ec_commands.h"
-#include "extpower.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "util.h"
-
-#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
-
-/* Shutdown mode parameter to write to manufacturer access register */
-#define SB_SHUTDOWN_DATA 0x0010
-
-/* Vendor CTO command parameter */
-#define SB_VENDOR_PARAM_CTO_DISABLE 0
-/* Flash address of Enabled Protections C Regsiter */
-#define SB_VENDOR_ENABLED_PROTECT_C 0x482C
-/* Expected CTO disable value */
-#define EXPECTED_CTO_DISABLE_VALUE 0x05
-
-/* Vendor OTD Recovery Temperature command parameter */
-#define SB_VENDOR_PARAM_OTD_RECOVERY_TEMP 1
-/* Flash address of OTD Recovery Temperature Register */
-#define SB_VENDOR_OTD_RECOVERY_TEMP 0x486F
-/* Expected OTD recovery temperature in 0.1C */
-#define EXPECTED_OTD_RECOVERY_TEMP 400
-
-enum battery_type {
- BATTERY_LG,
- BATTERY_LISHEN,
- BATTERY_SIMPLO,
- BATTERY_TYPE_COUNT,
-};
-
-struct board_batt_params {
- const char *manuf_name;
- const struct battery_info *batt_info;
-};
-
-/*
- * Set LISHEN as default since the LG precharge current level could cause the
- * LISHEN battery to not accept charge when it's recovering from a fully
- * discharged state.
- */
-#define DEFAULT_BATTERY_TYPE BATTERY_LISHEN
-static enum battery_present batt_pres_prev = BP_NOT_SURE;
-static enum battery_type board_battery_type = BATTERY_TYPE_COUNT;
-
-/* Battery may delay reporting battery present */
-static int battery_report_present = 1;
-
-/*
- * Battery protect_c register value.
- * Because this value can only be read when the battery is unsealed, the read of
- * this register is only done if the value is changed.
- */
-static int protect_c_reg = -1;
-
-/*
- * Battery OTD recovery temperature register value.
- * Because this value can only be read when the battery is unsealed, the read of
- * this register is only done if the value is changed.
- */
-static int otd_recovery_temp_reg = -1;
-
-/*
- * Battery info for LG A50. Note that the fields start_charging_min/max and
- * charging_min/max are not used for the Eve charger. The effective temperature
- * limits are given by discharging_min/max_c.
- */
-static const struct battery_info batt_info_lg = {
- .voltage_max = TARGET_WITH_MARGIN(8800, 5), /* mV */
- .voltage_normal = 7700,
- .voltage_min = 6100, /* Add 100mV for charger accuracy */
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 46,
- .charging_min_c = 10,
- .charging_max_c = 50,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
-};
-
-/*
- * Battery info for LISHEN. Note that the fields start_charging_min/max and
- * charging_min/max are not used for the Eve charger. The effective temperature
- * limits are given by discharging_min/max_c.
- */
-static const struct battery_info batt_info_lishen = {
- .voltage_max = TARGET_WITH_MARGIN(8800, 5), /* mV */
- .voltage_normal = 7700,
- .voltage_min = 6100, /* Add 100mV for charger accuracy */
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 46,
- .charging_min_c = 10,
- .charging_max_c = 50,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
-};
-
-static const struct board_batt_params info[] = {
- [BATTERY_LG] = {
- .manuf_name = "LG A50",
- .batt_info = &batt_info_lg,
- },
-
- [BATTERY_LISHEN] = {
- .manuf_name = "Lishen A50",
- .batt_info = &batt_info_lishen,
- },
-
- [BATTERY_SIMPLO] = {
- .manuf_name = "Simplo A50",
- .batt_info = &batt_info_lishen,
- },
-
-};
-BUILD_ASSERT(ARRAY_SIZE(info) == BATTERY_TYPE_COUNT);
-
-/* Get type of the battery connected on the board */
-static int board_get_battery_type(void)
-{
- char name[3];
- int i;
-
- if (!battery_manufacturer_name(name, sizeof(name))) {
- for (i = 0; i < BATTERY_TYPE_COUNT; i++) {
- if (!strncasecmp(name, info[i].manuf_name,
- ARRAY_SIZE(name)-1)) {
- board_battery_type = i;
- break;
- }
- }
- }
-
- return board_battery_type;
-}
-
-/*
- * Initialize the battery type for the board.
- *
- * Very first battery info is called by the charger driver to initialize
- * the charger parameters hence initialize the battery type for the board
- * as soon as the I2C is initialized.
- */
-static void board_init_battery_type(void)
-{
- if (board_get_battery_type() != BATTERY_TYPE_COUNT)
- CPRINTS("found batt: %s", info[board_battery_type].manuf_name);
- else
- CPRINTS("battery not found");
-}
-DECLARE_HOOK(HOOK_INIT, board_init_battery_type, HOOK_PRIO_INIT_I2C + 1);
-
-const struct battery_info *battery_get_info(void)
-{
- return info[board_battery_type == BATTERY_TYPE_COUNT ?
- DEFAULT_BATTERY_TYPE : board_battery_type].batt_info;
-}
-
-int board_cut_off_battery(void)
-{
- int rv;
-
- /* Ship mode command must be sent twice to take effect */
- rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
- if (rv != EC_SUCCESS)
- return EC_RES_ERROR;
-
- rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
- return rv ? EC_RES_ERROR : EC_RES_SUCCESS;
-}
-
-static int charger_should_discharge_on_ac(struct charge_state_data *curr)
-{
- /* Can not discharge on AC without battery */
- if (curr->batt.is_present != BP_YES)
- return 0;
-
- /* Do not discharge on AC if the battery is still waking up */
- if (!(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
- !(curr->batt.status & STATUS_FULLY_CHARGED))
- return 0;
-
- /*
- * In light load (<450mA being withdrawn from VSYS) the DCDC of the
- * charger operates intermittently i.e. DCDC switches continuously
- * and then stops to regulate the output voltage and current, and
- * sometimes to prevent reverse current from flowing to the input.
- * This causes a slight voltage ripple on VSYS that falls in the
- * audible noise frequency (single digit kHz range). This small
- * ripple generates audible noise in the output ceramic capacitors
- * (caps on VSYS and any input of DCDC under VSYS).
- *
- * To overcome this issue enable the battery learning operation
- * and suspend USB charging and DC/DC converter.
- */
- if (!battery_is_cut_off() &&
- !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
- (curr->batt.status & STATUS_FULLY_CHARGED))
- return 1;
-
- /*
- * To avoid inrush current from the external charger, enable
- * discharge on AC 2till the new charger is detected and charge
- * detect delay has passed.
- */
- if (!chg_ramp_is_detected() && curr->batt.state_of_charge > 2)
- return 1;
-
- return 0;
-}
-
-int charger_profile_override(struct charge_state_data *curr)
-{
- const struct battery_info *batt_info;
- /* battery temp in 0.1 deg C */
- int bat_temp_c = curr->batt.temperature - 2731;
- int disch_on_ac = charger_should_discharge_on_ac(curr);
-
- charger_discharge_on_ac(disch_on_ac);
-
- if (disch_on_ac) {
- curr->state = ST_DISCHARGE;
- return 0;
- }
-
- batt_info = battery_get_info();
- /* Don't charge if outside of allowable temperature range */
- if (bat_temp_c >= batt_info->charging_max_c * 10 ||
- bat_temp_c < batt_info->charging_min_c * 10) {
- curr->requested_current = 0;
- curr->requested_voltage = 0;
- curr->batt.flags &= ~BATT_FLAG_WANT_CHARGE;
- curr->state = ST_IDLE;
- }
- return 0;
-}
-
-/* Customs options controllable by host command. */
-#define PARAM_FASTCHARGE (CS_PARAM_CUSTOM_PROFILE_MIN + 0)
-
-enum ec_status charger_profile_override_get_param(uint32_t param,
- uint32_t *value)
-{
- return EC_RES_INVALID_PARAM;
-}
-
-enum ec_status charger_profile_override_set_param(uint32_t param,
- uint32_t value)
-{
- return EC_RES_INVALID_PARAM;
-}
-
-enum battery_present battery_hw_present(void)
-{
- /* The GPIO is low when the battery is physically present */
- return gpio_get_level(GPIO_BATTERY_PRESENT_L) ? BP_NO : BP_YES;
-}
-
-static int battery_init(void)
-{
- int batt_status;
-
- return battery_status(&batt_status) ? 0 :
- !!(batt_status & STATUS_INITIALIZED);
-}
-
-/* Allow booting now that the battery has woke up */
-static void battery_now_present(void)
-{
- CPRINTS("battery will now report present");
- battery_report_present = 1;
-}
-DECLARE_DEFERRED(battery_now_present);
-
-/*
- * Check for case where XDSG bit is set indicating that even
- * though the FG can be read from the battery, the battery is not able to be
- * charged or discharged. This situation will happen if a battery disconnect was
- * intiaited via H1 setting the DISCONN signal to the battery. This will put the
- * battery pack into a sleep state and when power is reconnected, the FG can be
- * read, but the battery is still not able to provide power to the system. The
- * calling function returns batt_pres = BP_NO, which instructs the charging
- * state machine to prevent powering up the AP on battery alone which could lead
- * to a brownout event when the battery isn't able yet to provide power to the
- * system. .
- */
-static int battery_check_disconnect(void)
-{
- int rv;
- uint8_t data[6];
-
- /* Check if battery discharging is disabled. */
- rv = sb_read_mfgacc(PARAM_OPERATION_STATUS,
- SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data));
- if (rv)
- return BATTERY_DISCONNECT_ERROR;
-
- if (data[3] & BATTERY_DISCHARGING_DISABLED)
- return BATTERY_DISCONNECTED;
-
- return BATTERY_NOT_DISCONNECTED;
-}
-
-/*
- * Physical detection of battery.
- */
-enum battery_present battery_is_present(void)
-{
- enum battery_present batt_pres;
- static int battery_report_present_timer_started;
-
- /* Get the physical hardware status */
- batt_pres = battery_hw_present();
-
- /*
- * Make sure battery status is implemented, I2C transactions are
- * success & the battery status is Initialized to find out if it
- * is a working battery and it is not in the cut-off mode.
- *
- * If battery I2C fails but VBATT is high, battery is booting from
- * cut-off mode.
- *
- * FETs are turned off after Power Shutdown time.
- * The device will wake up when a voltage is applied to PACK.
- * Battery status will be inactive until it is initialized.
- */
- if (batt_pres == BP_YES && batt_pres_prev != batt_pres &&
- (battery_is_cut_off() != BATTERY_CUTOFF_STATE_NORMAL ||
- battery_check_disconnect() != BATTERY_NOT_DISCONNECTED ||
- battery_init() == 0)) {
- battery_report_present = 0;
- } else if (batt_pres == BP_YES && batt_pres_prev == BP_NO &&
- !battery_report_present_timer_started) {
- /*
- * Wait 1 second before reporting present if it was
- * previously reported as not present
- */
- battery_report_present_timer_started = 1;
- battery_report_present = 0;
- hook_call_deferred(&battery_now_present_data, SECOND);
- }
-
- if (!battery_report_present)
- batt_pres = BP_NO;
-
- batt_pres_prev = batt_pres;
-
- return batt_pres;
-}
-
-int board_battery_initialized(void)
-{
- return battery_hw_present() == batt_pres_prev;
-}
-
-static int board_battery_sb_write(uint8_t access, int cmd)
-{
- int rv;
- uint8_t buf[1 + sizeof(uint16_t)];
-
- /*
- * Note, the i2c_lock must be handled by the calling function. The
- * battery unseal operation requires two writes without any other access
- * taking place. Therefore the calling function handles when to
- * grab/release the lock.
- */
-
- buf[0] = access;
- buf[1] = cmd & 0xff;
- buf[2] = (cmd >> 8) & 0xff;
-
- rv = i2c_xfer(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS,
- buf, 1 + sizeof(uint16_t), NULL, 0);
-
- return rv;
-}
-
-int board_battery_read_mfgacc(int offset, int access,
- uint8_t *buf, int len)
-{
- int rv;
- uint8_t block_len, reg;
-
- /* start read */
- i2c_lock(I2C_PORT_BATTERY, 1);
-
- /* Send write block */
- rv = board_battery_sb_write(SB_MANUFACTURER_ACCESS, offset);
- if (rv) {
- i2c_lock(I2C_PORT_BATTERY, 0);
- return rv;
- }
-
- reg = access;
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, &reg, 1,
- &block_len, 1, I2C_XFER_START);
- if (rv) {
- i2c_lock(I2C_PORT_BATTERY, 0);
- return rv;
- }
-
- /* Compare block length to desired read length */
- if (len && (block_len > len))
- block_len = len;
-
- rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, NULL, 0,
- buf, block_len, I2C_XFER_STOP);
- i2c_lock(I2C_PORT_BATTERY, 0);
-
- return rv;
-}
-
-static int board_battery_unseal(uint32_t param)
-{
- int rv;
- uint8_t data[6];
-
- /* Get Operation Status */
- rv = board_battery_read_mfgacc(PARAM_OPERATION_STATUS,
- SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data));
-
- if (rv)
- return EC_ERROR_UNKNOWN;
-
- if ((data[3] & 0x3) == 0x3) {
- /*
- * Hold the lock for both writes to ensure that no other
- * manufactuer access opertion can take place.
- */
- i2c_lock(I2C_PORT_BATTERY, 1);
- rv = board_battery_sb_write(SB_MANUFACTURER_ACCESS,
- param & 0xffff);
- if (rv)
- goto unseal_fail;
-
- rv = board_battery_sb_write(SB_MANUFACTURER_ACCESS,
- (param >> 16) & 0xffff);
- if (rv)
- goto unseal_fail;
-
- i2c_lock(I2C_PORT_BATTERY, 0);
-
- /* Verify that battery is unsealed */
- rv = board_battery_read_mfgacc(PARAM_OPERATION_STATUS,
- SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data));
- if (rv || ((data[3] & 0x3) != 0x2))
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-
-unseal_fail:
- i2c_lock(I2C_PORT_BATTERY, 0);
- return EC_RES_ERROR;
-}
-
-static int board_battery_seal(void)
-{
- int rv;
-
- i2c_lock(I2C_PORT_BATTERY, 1);
- rv = board_battery_sb_write(SB_MANUFACTURER_ACCESS, 0x0030);
- i2c_lock(I2C_PORT_BATTERY, 0);
-
- if (rv != EC_SUCCESS)
- return EC_RES_ERROR;
-
- return EC_SUCCESS;
-}
-
-static int board_battery_write_flash(int addr, uint32_t data, int len)
-{
- int rv;
- uint8_t buf[sizeof(uint32_t) + 4];
-
- if (len > 4)
- return EC_ERROR_INVAL;
-
- buf[0] = SB_ALT_MANUFACTURER_ACCESS;
- /* Number of bytes to write, including the address */
- buf[1] = len + 2;
- /* Put in the flash address */
- buf[2] = addr & 0xff;
- buf[3] = (addr >> 8) & 0xff;
-
- /* Add data to be written */
- buf[4] = data & 0xff;
- buf[5] = (data >> 8) & 0xff;
- buf[6] = (data >> 16) & 0xff;
- buf[7] = (data >> 24) & 0xff;
- /* Account for command, length, and address */
- len += 4;
-
- i2c_lock(I2C_PORT_BATTERY, 1);
- rv = i2c_xfer(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, buf,
- len, NULL, 0);
- i2c_lock(I2C_PORT_BATTERY, 0);
-
- return rv;
-}
-
-static int board_battery_read_flash(int block, int len, uint8_t *buf)
-{
- uint8_t data[6];
- int rv;
- int i;
-
- if (len > 4)
- len = 4;
- rv = board_battery_read_mfgacc(block,
- SB_ALT_MANUFACTURER_ACCESS, data, len + 2);
- if (rv)
- return EC_RES_ERROR;
-
- for (i = 0; i < len; i++)
- buf[i] = data[i+2];
-
- return EC_SUCCESS;
-}
-
-static int board_battery_disable_cto(uint32_t value)
-{
- uint8_t protect_c;
-
- if (board_battery_unseal(value))
- return EC_RES_ERROR;
-
- /* Check CTO enable */
- if (board_battery_read_flash(SB_VENDOR_ENABLED_PROTECT_C, 1,
- &protect_c)) {
- board_battery_seal();
- return EC_RES_ERROR;
- }
-
- if (protect_c != EXPECTED_CTO_DISABLE_VALUE) {
- board_battery_write_flash(SB_VENDOR_ENABLED_PROTECT_C,
- EXPECTED_CTO_DISABLE_VALUE, 1);
- /* After flash write, allow time for it to complete */
- msleep(100);
- /* Read the current protect_c register value */
- if (board_battery_read_flash(SB_VENDOR_ENABLED_PROTECT_C, 1,
- &protect_c) == EC_SUCCESS)
- protect_c_reg = protect_c;
- } else {
- protect_c_reg = protect_c;
- }
-
- if (board_battery_seal()) {
- /* If failed, then wait one more time and seal again */
- msleep(100);
- if (board_battery_seal())
- return EC_RES_ERROR;
- }
-
- return EC_SUCCESS;
-}
-
-static int board_battery_fix_otd_recovery_temp(uint32_t value)
-{
- int16_t otd_recovery_temp;
-
- if (board_battery_unseal(value))
- return EC_RES_ERROR;
-
- /* Check current OTD recovery temp */
- if (board_battery_read_flash(SB_VENDOR_OTD_RECOVERY_TEMP, 2,
- (uint8_t *)&otd_recovery_temp)) {
- board_battery_seal();
- return EC_RES_ERROR;
- }
-
- if (otd_recovery_temp != EXPECTED_OTD_RECOVERY_TEMP) {
- board_battery_write_flash(SB_VENDOR_OTD_RECOVERY_TEMP,
- EXPECTED_OTD_RECOVERY_TEMP, 2);
- /* After flash write, allow time for it to complete */
- msleep(100);
- /* Read the current OTD recovery temperature */
- if (!board_battery_read_flash(SB_VENDOR_OTD_RECOVERY_TEMP, 2,
- (uint8_t *)&otd_recovery_temp))
- otd_recovery_temp_reg = otd_recovery_temp;
- } else {
- otd_recovery_temp_reg = otd_recovery_temp;
- }
-
- if (board_battery_seal()) {
- /* If failed, then wait one more time and seal again */
- msleep(100);
- if (board_battery_seal())
- return EC_RES_ERROR;
- }
-
- return EC_SUCCESS;
-}
-
-int battery_get_vendor_param(uint32_t param, uint32_t *value)
-{
- /*
- * These registers can't be read directly because the flash area
- * of the battery is protected, unless it's been
- * unsealed. The key is only able to be passed in the set
- * function. The get function is always called following the set
- * function. Therefore when the set function is called, this
- * register value is read and saved to protect_c_reg. If this
- * value is < 0, then the set function wasn't called and
- * therefore the value can't be known.
- */
- switch (param) {
- case SB_VENDOR_PARAM_CTO_DISABLE:
- if (protect_c_reg >= 0) {
- *value = protect_c_reg;
- return EC_SUCCESS;
- }
- break;
- case SB_VENDOR_PARAM_OTD_RECOVERY_TEMP:
- if (otd_recovery_temp_reg >= 0) {
- *value = otd_recovery_temp_reg;
- return EC_SUCCESS;
- }
- break;
- default:
- return EC_ERROR_UNIMPLEMENTED;
- }
- return EC_RES_ERROR;
-}
-
-int battery_set_vendor_param(uint32_t param, uint32_t value)
-{
- switch (param) {
- case SB_VENDOR_PARAM_CTO_DISABLE:
- if (board_battery_disable_cto(value))
- return EC_ERROR_UNKNOWN;
- break;
- case SB_VENDOR_PARAM_OTD_RECOVERY_TEMP:
- if (board_battery_fix_otd_recovery_temp(value))
- return EC_ERROR_UNKNOWN;
- break;
- default:
- return EC_ERROR_INVAL;
- }
- return EC_SUCCESS;
-}
diff --git a/board/eve/board.c b/board/eve/board.c
deleted file mode 100644
index f73118e8f2..0000000000
--- a/board/eve/board.c
+++ /dev/null
@@ -1,981 +0,0 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Eve board-specific configuration */
-
-#include "acpi.h"
-#include "bd99992gw.h"
-#include "board_config.h"
-#include "button.h"
-#include "charge_manager.h"
-#include "charge_state.h"
-#include "charge_ramp.h"
-#include "charger.h"
-#include "chipset.h"
-#include "console.h"
-#include "device_event.h"
-#include "driver/accel_kionix.h"
-#include "driver/accel_kxcj9.h"
-#include "driver/accelgyro_bmi_common.h"
-#include "driver/als_si114x.h"
-#include "driver/charger/bd9995x.h"
-#include "driver/tcpm/anx74xx.h"
-#include "driver/tcpm/tcpci.h"
-#include "driver/tcpm/tcpm.h"
-#include "driver/temp_sensor/bd99992gw.h"
-#include "extpower.h"
-#include "gesture.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "i2c.h"
-#include "keyboard_scan.h"
-#include "keyboard_8042_sharedlib.h"
-#include "lid_angle.h"
-#include "lid_switch.h"
-#include "math_util.h"
-#include "motion_lid.h"
-#include "motion_sense.h"
-#include "power.h"
-#include "power_button.h"
-#include "pwm.h"
-#include "pwm_chip.h"
-#include "spi.h"
-#include "switch.h"
-#include "system.h"
-#include "tablet_mode.h"
-#include "task.h"
-#include "temp_sensor.h"
-#include "timer.h"
-#include "uart.h"
-#include "usb_charge.h"
-#include "usb_mux.h"
-#include "usb_pd.h"
-#include "usb_pd_tcpm.h"
-#include "util.h"
-#include "espi.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-
-static void tcpc_alert_event(enum gpio_signal signal)
-{
- int port = -1;
-
- switch (signal) {
- case GPIO_USB_C0_PD_INT_ODL:
- port = 0;
- break;
- case GPIO_USB_C1_PD_INT_ODL:
- port = 1;
- break;
- default:
- return;
- }
-
- schedule_deferred_pd_interrupt(port);
-}
-
-/*
- * enable_input_devices() is called by the tablet_mode ISR, but changes the
- * state of GPIOs, so its definition must reside after including gpio_list.
- */
-static void enable_input_devices(void);
-DECLARE_DEFERRED(enable_input_devices);
-
-#define LID_DEBOUNCE_US (30 * MSEC)
-void tablet_mode_interrupt(enum gpio_signal signal)
-{
- hook_call_deferred(&enable_input_devices_data, LID_DEBOUNCE_US);
-}
-
-/* Send event to wake AP based on trackpad input */
-void trackpad_interrupt(enum gpio_signal signal)
-{
- device_set_single_event(EC_DEVICE_EVENT_TRACKPAD);
-}
-
-/* Send event to wake AP based on DSP interrupt */
-void dsp_interrupt(enum gpio_signal signal)
-{
- device_set_single_event(EC_DEVICE_EVENT_DSP);
-}
-
-#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
-static void anx74xx_c0_cable_det_handler(void)
-{
- int cable_det = gpio_get_level(GPIO_USB_C0_CABLE_DET);
- int reset_n = gpio_get_level(GPIO_USB_C0_PD_RST_L);
-
- /*
- * A cable_det low->high transition was detected. If following the
- * debounce time, cable_det is high, and reset_n is low, then ANX3429 is
- * currently in standby mode and needs to be woken up. Set the
- * TCPC_RESET event which will bring the ANX3429 out of standby
- * mode. Setting this event is gated on reset_n being low because the
- * ANX3429 will always set cable_det when transitioning to normal mode
- * and if in normal mode, then there is no need to trigger a tcpc reset.
- */
- if (cable_det && !reset_n)
- task_set_event(TASK_ID_PD_C0, PD_EVENT_TCPC_RESET);
-}
-DECLARE_DEFERRED(anx74xx_c0_cable_det_handler);
-
-static void anx74xx_c1_cable_det_handler(void)
-{
- int cable_det = gpio_get_level(GPIO_USB_C1_CABLE_DET);
- int reset_n = gpio_get_level(GPIO_USB_C1_PD_RST_L);
-
- /*
- * A cable_det low->high transition was detected. If following the
- * debounce time, cable_det is high, and reset_n is low, then ANX3429 is
- * currently in standby mode and needs to be woken up. Set the
- * TCPC_RESET event which will bring the ANX3429 out of standby
- * mode. Setting this event is gated on reset_n being low because the
- * ANX3429 will always set cable_det when transitioning to normal mode
- * and if in normal mode, then there is no need to trigger a tcpc reset.
- */
- if (cable_det && !reset_n)
- task_set_event(TASK_ID_PD_C1, PD_EVENT_TCPC_RESET);
-}
-DECLARE_DEFERRED(anx74xx_c1_cable_det_handler);
-
-void anx74xx_cable_det_interrupt(enum gpio_signal signal)
-{
- /* Check if it is port 0 or 1, and debounce for 2 msec. */
- if (signal == GPIO_USB_C0_CABLE_DET)
- hook_call_deferred(&anx74xx_c0_cable_det_handler_data,
- (2 * MSEC));
- else
- hook_call_deferred(&anx74xx_c1_cable_det_handler_data,
- (2 * MSEC));
-}
-#endif
-
-#include "gpio_list.h"
-
-/* Keyboard scan. Increase output_settle_us to 80us from default 50us. */
-__override struct keyboard_scan_config keyscan_config = {
- .output_settle_us = 80,
- .debounce_down_us = 9 * MSEC,
- .debounce_up_us = 30 * MSEC,
- .scan_period_us = 3 * MSEC,
- .min_post_scan_delay_us = 1000,
- .poll_timeout_us = 100 * MSEC,
- .actual_key_mask = {
- 0x3c, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff,
- 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */
- },
-};
-
-/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
-const struct pwm_t pwm_channels[] = {
- [PWM_CH_KBLIGHT] = { 5, 0, 10000 },
- [PWM_CH_LED_L_RED] = { 2, PWM_CONFIG_DSLEEP, 100 },
- [PWM_CH_LED_L_GREEN] = { 3, PWM_CONFIG_DSLEEP, 100 },
- [PWM_CH_LED_L_BLUE] = { 4, PWM_CONFIG_DSLEEP, 100 },
- [PWM_CH_LED_R_RED] = { 1, PWM_CONFIG_DSLEEP, 100 },
- [PWM_CH_LED_R_GREEN] = { 0, PWM_CONFIG_DSLEEP, 100 },
- [PWM_CH_LED_R_BLUE] = { 6, PWM_CONFIG_DSLEEP, 100 },
-};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-
-/* Hibernate wake configuration */
-const enum gpio_signal hibernate_wake_pins[] = {
- GPIO_AC_PRESENT,
- GPIO_LID_OPEN,
- GPIO_POWER_BUTTON_L,
-};
-const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
-
-/* I2C port map */
-const struct i2c_port_t i2c_ports[] = {
- {"tcpc0", I2C_PORT_TCPC0, 400, GPIO_I2C0_0_SCL, GPIO_I2C0_0_SDA},
- {"tcpc1", I2C_PORT_TCPC1, 400, GPIO_I2C0_1_SCL, GPIO_I2C0_1_SDA},
- {"accelgyro", I2C_PORT_GYRO, 400, GPIO_I2C1_SCL, GPIO_I2C1_SDA},
- {"sensors", I2C_PORT_LID_ACCEL, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA},
- {"batt", I2C_PORT_BATTERY, 100, GPIO_I2C3_SCL, GPIO_I2C3_SDA},
-};
-const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-
-/* TCPC mux configuration */
-const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_TCPC0,
- .addr_flags = ANX74XX_I2C_ADDR1_FLAGS,
- },
- .drv = &anx74xx_tcpm_drv,
- },
- {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_TCPC1,
- .addr_flags = ANX74XX_I2C_ADDR1_FLAGS,
- },
- .drv = &anx74xx_tcpm_drv,
- },
-};
-
-const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .usb_port = 0,
- .driver = &anx74xx_tcpm_usb_mux_driver,
- .hpd_update = &anx74xx_tcpc_update_hpd_status,
- },
- {
- .usb_port = 1,
- .driver = &anx74xx_tcpm_usb_mux_driver,
- .hpd_update = &anx74xx_tcpc_update_hpd_status,
- },
-};
-
-const struct charger_config_t chg_chips[] = {
- {
- .i2c_port = I2C_PORT_CHARGER,
- .i2c_addr_flags = BD9995X_ADDR_FLAGS,
- .drv = &bd9995x_drv,
- },
-};
-
-/**
- * Power on (or off) a single TCPC.
- * minimum on/off delays are included.
- *
- * @param port Port number of TCPC.
- * @param mode 0: power off, 1: power on.
- */
-void board_set_tcpc_power_mode(int port, int mode)
-{
- switch (port) {
- case 0:
- if (mode) {
- gpio_set_level(GPIO_USB_C0_TCPC_PWR, 1);
- msleep(ANX74XX_PWR_H_RST_H_DELAY_MS);
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 1);
- } else {
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 0);
- msleep(ANX74XX_RST_L_PWR_L_DELAY_MS);
- gpio_set_level(GPIO_USB_C0_TCPC_PWR, 0);
- msleep(ANX74XX_PWR_L_PWR_H_DELAY_MS);
- }
- break;
- case 1:
- if (mode) {
- gpio_set_level(GPIO_USB_C1_TCPC_PWR, 1);
- msleep(ANX74XX_PWR_H_RST_H_DELAY_MS);
- gpio_set_level(GPIO_USB_C1_PD_RST_L, 1);
- } else {
- gpio_set_level(GPIO_USB_C1_PD_RST_L, 0);
- msleep(ANX74XX_RST_L_PWR_L_DELAY_MS);
- gpio_set_level(GPIO_USB_C1_TCPC_PWR, 0);
- msleep(ANX74XX_PWR_L_PWR_H_DELAY_MS);
- }
- break;
- }
-}
-
-void board_reset_pd_mcu(void)
-{
- /* Assert reset */
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 0);
- gpio_set_level(GPIO_USB_C1_PD_RST_L, 0);
- msleep(ANX74XX_RST_L_PWR_L_DELAY_MS);
- /* Disable power */
- gpio_set_level(GPIO_USB_C0_TCPC_PWR, 0);
- gpio_set_level(GPIO_USB_C1_TCPC_PWR, 0);
- msleep(ANX74XX_PWR_L_PWR_H_DELAY_MS);
- /* Enable power */
- gpio_set_level(GPIO_USB_C0_TCPC_PWR, 1);
- gpio_set_level(GPIO_USB_C1_TCPC_PWR, 1);
- msleep(ANX74XX_PWR_H_RST_H_DELAY_MS);
- /* Deassert reset */
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 1);
- gpio_set_level(GPIO_USB_C1_PD_RST_L, 1);
-}
-
-void board_tcpc_init(void)
-{
- int count = 0;
- int port;
-
- /* Wait for disconnected battery to wake up */
- while (battery_hw_present() == BP_YES &&
- battery_is_present() == BP_NO) {
- usleep(100 * MSEC);
- /* Give up waiting after 2 seconds */
- if (++count > 20)
- break;
- }
-
- /* Only reset TCPC if not sysjump */
- if (!system_jumped_late())
- board_reset_pd_mcu();
-
- /* Enable TCPC interrupts */
- gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
- gpio_enable_interrupt(GPIO_USB_C1_PD_INT_ODL);
-
-#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
- /* Enable CABLE_DET interrupt for ANX3429 wake from standby */
- gpio_enable_interrupt(GPIO_USB_C0_CABLE_DET);
- gpio_enable_interrupt(GPIO_USB_C1_CABLE_DET);
-#endif
-
- /*
- * Initialize HPD to low; after sysjump SOC needs to see
- * HPD pulse to enable video path
- */
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
-
- if (!gpio_get_level(GPIO_USB_C0_PD_INT_ODL)) {
- if (gpio_get_level(GPIO_USB_C0_PD_RST_L))
- status |= PD_STATUS_TCPC_ALERT_0;
- }
-
- if (!gpio_get_level(GPIO_USB_C1_PD_INT_ODL)) {
- if (gpio_get_level(GPIO_USB_C1_PD_RST_L))
- status |= PD_STATUS_TCPC_ALERT_1;
- }
-
- return status;
-}
-
-const struct temp_sensor_t temp_sensors[] = {
- {"Battery", TEMP_SENSOR_TYPE_BATTERY, charge_get_battery_temp, 0},
-
- /* These BD99992GW temp sensors are only readable in S0 */
- {"Ambient", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
- BD99992GW_ADC_CHANNEL_SYSTHERM0},
- {"Charger", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
- BD99992GW_ADC_CHANNEL_SYSTHERM1},
- {"DRAM", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
- BD99992GW_ADC_CHANNEL_SYSTHERM2},
- {"eMMC", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
- BD99992GW_ADC_CHANNEL_SYSTHERM3},
- {"Gyro", TEMP_SENSOR_TYPE_BOARD, bmi160_get_sensor_temp, BASE_GYRO},
-};
-BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-
-/*
- * Check if PMIC fault registers indicate VR fault. If yes, print out fault
- * register info to console. Additionally, set panic reason so that the OS can
- * check for fault register info by looking at offset 0x14(PWRSTAT1) and
- * 0x15(PWRSTAT2) in cros ec panicinfo.
- */
-static void board_report_pmic_fault(const char *str)
-{
- int vrfault, pwrstat1 = 0, pwrstat2 = 0;
- uint32_t info;
-
- /* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x8, &vrfault)
- != EC_SUCCESS)
- return;
-
- if (!(vrfault & BIT(4)))
- return;
-
- /* VRFAULT has occurred, print VRFAULT status bits. */
-
- /* PWRSTAT1 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x16, &pwrstat1);
-
- /* PWRSTAT2 */
- i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x17, &pwrstat2);
-
- CPRINTS("PMIC VRFAULT: %s", str);
- CPRINTS("PMIC VRFAULT: PWRSTAT1=0x%02x PWRSTAT2=0x%02x", pwrstat1,
- pwrstat2);
-
- /* Clear all faults -- Write 1 to clear. */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x8, BIT(4));
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x16, pwrstat1);
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x17, pwrstat2);
-
- /*
- * Status of the fault registers can be checked in the OS by looking at
- * offset 0x14(PWRSTAT1) and 0x15(PWRSTAT2) in cros ec panicinfo.
- */
- info = ((pwrstat2 & 0xFF) << 8) | (pwrstat1 & 0xFF);
- panic_set_reason(PANIC_SW_PMIC_FAULT, info, 0);
-}
-
-static void board_pmic_init(void)
-{
- board_report_pmic_fault("SYSJUMP");
-
- /* Clear power source events */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x04, 0xff);
-
- /* Disable power button shutdown timer */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x14, 0x00);
-
- /* Disable VCCIO in ALL_SYS_PWRGD for early boards */
- if (board_get_version() <= BOARD_VERSION_DVTB)
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x18, 0x80);
-
- if (system_jumped_late())
- return;
-
- /* DISCHGCNT2 - enable 100 ohm discharge on V3.3A and V1.8A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x3d, 0x05);
-
- /* DISCHGCNT3 - enable 100 ohm discharge on V1.00A */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x3e, 0x04);
-
- /* Set CSDECAYEN / VCCIO decays to 0V at assertion of SLP_S0# */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x30, 0x7a);
-
- /*
- * Set V100ACNT / V1.00A Control Register:
- * Nominal output = 1.0V.
- */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x37, 0x1a);
-
- /*
- * Set V085ACNT / V0.85A Control Register:
- * Lower power mode = 0.7V.
- * Nominal output = 1.0V.
- */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x38, 0x7a);
-
- /* VRMODECTRL - disable low-power mode for all rails */
- i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x3b, 0x1f);
-}
-DECLARE_DEFERRED(board_pmic_init);
-
-static void board_set_tablet_mode(void)
-{
- int flipped_360_mode = !gpio_get_level(GPIO_TABLET_MODE_L);
-
- tablet_set_mode(flipped_360_mode, TABLET_TRIGGER_LID);
-
- /* Update DPTF profile based on mode */
- if (flipped_360_mode)
- acpi_dptf_set_profile_num(DPTF_PROFILE_FLIPPED_360_MODE);
- else
- acpi_dptf_set_profile_num(DPTF_PROFILE_CLAMSHELL);
-}
-
-int board_has_working_reset_flags(void)
-{
- int version = board_get_version();
-
- /* board version P1b to EVTb will lose reset flags on power cycle */
- if (version >= BOARD_VERSION_P1B && version <= BOARD_VERSION_EVTB)
- return 0;
-
- /* All other board versions should have working reset flags */
- return 1;
-}
-
-/* Initialize board. */
-static void board_init(void)
-{
- /* Enabure tablet mode is initialized */
- board_set_tablet_mode();
-
- /* Enable tablet mode interrupt for input device enable */
- gpio_enable_interrupt(GPIO_TABLET_MODE_L);
-
- /* Enable charger interrupts */
- gpio_enable_interrupt(GPIO_CHARGER_INT_L);
-
- /* Enable interrupts from BMI160 sensor. */
- gpio_enable_interrupt(GPIO_ACCELGYRO3_INT_L);
-
- /* Provide AC status to the PCH */
- gpio_set_level(GPIO_PCH_ACOK, extpower_is_present());
-
-#ifndef TEST_BUILD
- if (board_get_version() == BOARD_VERSION_EVT) {
- /* Set F13 to new defined key on EVT */
- CPRINTS("Overriding F13 scan code");
- set_scancode_set2(3, 9, 0xe007);
-#ifdef CONFIG_KEYBOARD_DEBUG
- set_keycap_label(3, 9, KLLI_F13);
-#endif
- }
-#endif
-
- /* Initialize PMIC */
- hook_call_deferred(&board_pmic_init_data, 0);
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-
-__override enum pd_dual_role_states pd_get_drp_state_in_suspend(void)
-{
- /*
- * If board is not connected to charger it will disable VBUS
- * on all ports that acts as source when going to suspend.
- * Change DRP state to force sink, to inform TCPM about that.
- */
- if (!extpower_is_present())
- return PD_DRP_FORCE_SINK;
-
- return PD_DRP_TOGGLE_OFF;
-}
-
-/**
- * Buffer the AC present GPIO to the PCH.
- * Set appropriate DRP state when chipset in suspend
- */
-static void board_extpower(void)
-{
- enum pd_dual_role_states drp_state;
- int port;
-
- gpio_set_level(GPIO_PCH_ACOK, extpower_is_present());
-
- if (chipset_in_or_transitioning_to_state(CHIPSET_STATE_SUSPEND)) {
- drp_state = pd_get_drp_state_in_suspend();
- for (port = 0; port < board_get_usb_pd_port_count(); port++)
- if (pd_get_dual_role(port) != drp_state)
- pd_set_dual_role(port, drp_state);
- }
-}
-DECLARE_HOOK(HOOK_AC_CHANGE, board_extpower, HOOK_PRIO_DEFAULT);
-
-int pd_snk_is_vbus_provided(int port)
-{
- if (port != 0 && port != 1)
- panic("Invalid charge port\n");
-
- return bd9995x_is_vbus_provided(port);
-}
-
-/**
- * Set active charge port -- only one port can be active at a time.
- *
- * @param charge_port Charge port to enable.
- *
- * Returns EC_SUCCESS if charge port is accepted and made active,
- * EC_ERROR_* otherwise.
- */
-int board_set_active_charge_port(int charge_port)
-{
- enum bd9995x_charge_port bd9995x_port;
- int bd9995x_port_select = 1;
-
- switch (charge_port) {
- case 0:
- case 1:
- /* Don't charge from a source port */
- if (board_vbus_source_enabled(charge_port))
- return -1;
-
- bd9995x_port = charge_port;
- break;
- case CHARGE_PORT_NONE:
- bd9995x_port_select = 0;
- bd9995x_port = BD9995X_CHARGE_PORT_BOTH;
-
- /*
- * To avoid inrush current from the external charger,
- * enable discharge on AC until the new charger is detected
- * and charge detect delay has passed.
- */
- if (charge_get_percent() > 2)
- charger_discharge_on_ac(1);
- break;
- default:
- panic("Invalid charge port\n");
- break;
- }
-
- CPRINTS("New chg p%d", charge_port);
-
- return bd9995x_select_input_port(bd9995x_port, bd9995x_port_select);
-}
-
-/**
- * Set the charge limit based upon desired maximum.
- *
- * @param port Port number.
- * @param supplier Charge supplier type.
- * @param charge_ma Desired charge limit (mA).
- * @param charge_mv Negotiated charge voltage (mV).
- */
-void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- /* Enable charging trigger by BC1.2 detection */
- int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP ||
- supplier == CHARGE_SUPPLIER_BC12_DCP ||
- supplier == CHARGE_SUPPLIER_BC12_SDP ||
- supplier == CHARGE_SUPPLIER_OTHER);
-
- if (bd9995x_bc12_enable_charging(port, bc12_enable))
- return;
-
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(MAX(charge_ma,
- CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
-/**
- * Return if VBUS is sagging too low
- */
-int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
-{
- int voltage;
-
- if (charger_get_vbus_voltage(port, &voltage))
- voltage = 0;
-
- return voltage < BD9995X_BC12_MIN_VOLTAGE;
-}
-
-/* Clear pending interrupts and enable DSP for wake */
-static void dsp_wake_enable(int enable)
-{
- if (enable) {
- gpio_clear_pending_interrupt(GPIO_MIC_DSP_IRQ_1V8_L);
- gpio_enable_interrupt(GPIO_MIC_DSP_IRQ_1V8_L);
- } else {
- gpio_disable_interrupt(GPIO_MIC_DSP_IRQ_1V8_L);
- }
-}
-
-/* Clear pending interrupts and enable trackpad for wake */
-static void trackpad_wake_enable(int enable)
-{
- static int prev_enable = -1;
-
- if (prev_enable == enable)
- return;
- prev_enable = enable;
-
- if (enable) {
- gpio_clear_pending_interrupt(GPIO_TRACKPAD_INT_L);
- gpio_enable_interrupt(GPIO_TRACKPAD_INT_L);
- } else {
- gpio_disable_interrupt(GPIO_TRACKPAD_INT_L);
- }
-}
-
-/* Enable or disable input devices, based upon chipset state and tablet mode */
-static void enable_input_devices(void)
-{
- /* We need to turn on tablet mode for motion sense */
- board_set_tablet_mode();
-
- /*
- * Then, we disable peripherals only when the lid reaches 360 position.
- * (It's probably already disabled by motion_sense_task.)
- * We deliberately do not enable peripherals when the lid is leaving
- * 360 position. Instead, we let motion_sense_task enable it once it
- * reaches laptop zone (180 or less).
- */
- if (tablet_get_mode())
- lid_angle_peripheral_enable(0);
-}
-
-/* Enable or disable input devices, based on chipset state and tablet mode */
-__override void lid_angle_peripheral_enable(int enable)
-{
- /*
- * If suspended and the lid is in 360 position, ignore the lid angle,
- * which might be faulty. Disable keyboard and trackpad wake.
- */
- if (chipset_in_state(CHIPSET_STATE_ANY_OFF) ||
- (tablet_get_mode() && chipset_in_state(CHIPSET_STATE_SUSPEND)))
- enable = 0;
- keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE);
-
- /* Also disable trackpad wake if not in suspend */
- if (!chipset_in_state(CHIPSET_STATE_SUSPEND))
- enable = 0;
- trackpad_wake_enable(enable);
-}
-
-/* Called on AP S5 -> S3 transition */
-static void board_chipset_startup(void)
-{
- /* Enable Trackpad */
- gpio_set_level(GPIO_TRACKPAD_SHDN_L, 1);
- hook_call_deferred(&enable_input_devices_data, 0);
-}
-DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT);
-
-/* Called on AP S3 -> S5 transition */
-static void board_chipset_shutdown(void)
-{
- /* Disable Trackpad and DSP wake in S5 */
- trackpad_wake_enable(0);
- dsp_wake_enable(0);
- gpio_set_level(GPIO_TRACKPAD_SHDN_L, 0);
- hook_call_deferred(&enable_input_devices_data, 0);
-}
-DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
-
-/* Called on AP S0 -> S3 transition */
-static void board_chipset_suspend(void)
-{
- gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0);
- if (lid_is_open()) {
- /* Enable DSP wake if suspended with lid open */
- dsp_wake_enable(1);
-
- /* Enable trackpad wake if suspended and not in tablet mode */
- if (!tablet_get_mode())
- trackpad_wake_enable(1);
- }
-}
-DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
-
-/* Called on AP S3 -> S0 transition */
-static void board_chipset_resume(void)
-{
- gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);
- dsp_wake_enable(0);
- trackpad_wake_enable(0);
-}
-DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
-
-static void board_chipset_reset(void)
-{
- board_report_pmic_fault("CHIPSET RESET");
-}
-DECLARE_HOOK(HOOK_CHIPSET_RESET, board_chipset_reset, HOOK_PRIO_DEFAULT);
-
-/* Called on lid change */
-static void board_lid_change(void)
-{
- /* Disable trackpad and DSP wake if lid is closed */
- if (!lid_is_open()) {
- trackpad_wake_enable(0);
- dsp_wake_enable(0);
- }
-}
-DECLARE_HOOK(HOOK_LID_CHANGE, board_lid_change, HOOK_PRIO_DEFAULT);
-
-void board_hibernate(void)
-{
- /* Enable both the VBUS & VCC ports before entering PG3 */
- bd9995x_select_input_port(BD9995X_CHARGE_PORT_BOTH, 1);
-
- /* Turn BGATE OFF for power saving */
- bd9995x_set_power_save_mode(BD9995X_PWR_SAVE_MAX);
-
- /* Shut down PMIC */
- CPRINTS("Triggering PMIC shutdown");
- uart_flush_output();
- if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x49, 0x01)) {
- /*
- * If we can't tell the PMIC to shutdown, instead reset
- * and don't start the AP. Hopefully we'll be able to
- * communicate with the PMIC next time.
- */
- CPRINTS("PMIC I2C failed");
- uart_flush_output();
- system_reset(SYSTEM_RESET_LEAVE_AP_OFF);
- }
- while (1)
- ;
-}
-
-int board_get_version(void)
-{
- static int ver;
-
- if (!ver) {
- /*
- * Read the board EC ID on the tristate strappings
- * using ternary encoding: 0 = 0, 1 = 1, Hi-Z = 2
- */
- uint8_t id0, id1, id2;
-
- id0 = gpio_get_ternary(GPIO_BOARD_VERSION1);
- id1 = gpio_get_ternary(GPIO_BOARD_VERSION2);
- id2 = gpio_get_ternary(GPIO_BOARD_VERSION3);
-
- ver = (id2 * 9) + (id1 * 3) + id0;
- CPRINTS("Board ID = %d", ver);
- }
-
- return ver;
-}
-
-void sensor_board_proc_double_tap(void)
-{
- led_register_double_tap();
-}
-
-/* Base Sensor mutex */
-static struct mutex g_base_mutex;
-
-/* Lid Sensor mutex */
-static struct mutex g_lid_mutex;
-
-static struct kionix_accel_data g_kxcj9_data;
-static struct bmi_drv_data_t g_bmi160_data;
-
-static struct si114x_drv_data_t g_si114x_data = {
- .state = SI114X_NOT_READY,
- .covered = 0,
- .type_data = {
- /* Proximity - unused */
- {
- },
- /* light */
- {
- .base_data_reg = SI114X_ALS_VIS_DATA0,
- .irq_flags = SI114X_IRQ_ENABLE_ALS_IE_INT0 |
- SI114X_IRQ_ENABLE_ALS_IE_INT1,
- .scale = 1,
- .offset = -256,
- }
- }
-};
-
-/* Matrix to rotate accelrator into standard reference frame */
-const mat33_fp_t mag_standard_ref = {
- { FLOAT_TO_FP(-1), 0, 0},
- { 0, FLOAT_TO_FP(1), 0},
- { 0, 0, FLOAT_TO_FP(-1)}
-};
-
-const mat33_fp_t lid_standard_ref = {
- {FLOAT_TO_FP(-1), 0, 0},
- { 0, FLOAT_TO_FP(-1), 0},
- { 0, 0, FLOAT_TO_FP(1)}
-};
-
-struct motion_sensor_t motion_sensors[] = {
- [LID_ACCEL] = {
- .name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_KXCJ9,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &kionix_accel_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_kxcj9_data,
- .port = I2C_PORT_LID_ACCEL,
- .i2c_spi_addr_flags = KXCJ9_ADDR0_FLAGS,
- .rot_standard_ref = &lid_standard_ref,
- .default_range = 2, /* g, enough for lid angle calculation. */
- .min_frequency = KXCJ9_ACCEL_MIN_FREQ,
- .max_frequency = KXCJ9_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- },
- /* Sensor on for lid angle detection */
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 10000 | ROUND_UP_FLAG,
- },
- },
- },
-
- [BASE_ACCEL] = {
- .name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3_S5,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = I2C_PORT_GYRO,
- .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
- .rot_standard_ref = NULL,
- .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs */
- .min_frequency = BMI_ACCEL_MIN_FREQ,
- .max_frequency = BMI_ACCEL_MAX_FREQ,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = TAP_ODR,
- .ec_rate = 100 * MSEC,
- },
- /* Sensor on for lid angle detection */
- [SENSOR_CONFIG_EC_S3] = {
- .odr = TAP_ODR,
- .ec_rate = 100 * MSEC,
- },
- /* Sensor on in S5 for battery detection */
- [SENSOR_CONFIG_EC_S5] = {
- .odr = TAP_ODR,
- .ec_rate = 100 * MSEC,
- },
- },
- },
-
- [BASE_GYRO] = {
- .name = "Base Gyro",
- .active_mask = SENSOR_ACTIVE_S0_S3_S5,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_GYRO,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = I2C_PORT_GYRO,
- .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
- .default_range = 1000, /* dps */
- .rot_standard_ref = NULL,
- .min_frequency = BMI_GYRO_MIN_FREQ,
- .max_frequency = BMI_GYRO_MAX_FREQ,
- },
-
- [BASE_MAG] = {
- .name = "Base Mag",
- .active_mask = SENSOR_ACTIVE_S0_S3_S5,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_MAG,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = I2C_PORT_GYRO,
- .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
- .default_range = BIT(11), /* 16LSB / uT, fixed */
- .rot_standard_ref = &mag_standard_ref,
- .min_frequency = BMM150_MAG_MIN_FREQ,
- .max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL),
- },
-
- [LID_LIGHT] = {
- .name = "Light",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_SI1141,
- .type = MOTIONSENSE_TYPE_LIGHT,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &si114x_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_si114x_data,
- .port = I2C_PORT_ALS,
- .i2c_spi_addr_flags = SI114X_ADDR_FLAGS,
- .rot_standard_ref = NULL,
- .default_range = 6000, /* 60.00%: int = 0 - frac = 6000/10000 */
- .min_frequency = SI114X_LIGHT_MIN_FREQ,
- .max_frequency = SI114X_LIGHT_MAX_FREQ,
- .config = {
- /* Run ALS sensor in S0 */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 1000,
- },
- },
- },
-};
-const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-
-/* ALS instances when LPC mapping is needed. Each entry directs to a sensor. */
-const struct motion_sensor_t *motion_als_sensors[] = {
- &motion_sensors[LID_LIGHT],
-};
-BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT);
diff --git a/board/eve/board.h b/board/eve/board.h
deleted file mode 100644
index df80e4dccf..0000000000
--- a/board/eve/board.h
+++ /dev/null
@@ -1,316 +0,0 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Eve board configuration */
-
-#ifndef __CROS_EC_BOARD_H
-#define __CROS_EC_BOARD_H
-
-/*
- * By default, enable all console messages excepted HC, ACPI and event:
- * The sensor stack is generating a lot of activity.
- */
-#define CC_DEFAULT (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC)))
-#undef CONFIG_HOSTCMD_DEBUG_MODE
-#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF
-
-/* EC */
-#define CONFIG_ADC
-#define CONFIG_BACKLIGHT_LID
-#define CONFIG_BOARD_FORCE_RESET_PIN
-#define CONFIG_DEVICE_EVENT
-#define CONFIG_DPTF
-#define CONFIG_DPTF_MULTI_PROFILE
-#define CONFIG_FLASH_SIZE_BYTES 0x80000
-#define CONFIG_FPU
-/* 7 day delay before hibernate */
-#undef CONFIG_HIBERNATE_DELAY_SEC
-#define CONFIG_HIBERNATE_DELAY_SEC (3600 * 24 * 7)
-/* 1 day delay before hibernate if battery is less than 10% */
-#define CONFIG_HIBERNATE_BATT_PCT 10
-#define CONFIG_HIBERNATE_BATT_SEC (3600 * 24)
-#define CONFIG_I2C
-#define CONFIG_I2C_CONTROLLER
-#define CONFIG_LED_COMMON
-#define CONFIG_LID_SWITCH
-#define CONFIG_LOW_POWER_IDLE
-#define CONFIG_LTO
-#define CONFIG_CHIP_PANIC_BACKUP
-#define CONFIG_SOFTWARE_PANIC
-#define CONFIG_PWM
-#define CONFIG_PWM_KBLIGHT
-#define CONFIG_SHA256_UNROLLED
-#define CONFIG_SPI_FLASH_REGS
-#define CONFIG_SPI_FLASH_W25X40
-#define CONFIG_VBOOT_HASH
-#define CONFIG_VOLUME_BUTTONS
-#define CONFIG_VSTORE
-#define CONFIG_VSTORE_SLOT_COUNT 1
-#define CONFIG_WATCHDOG_HELP
-#define CONFIG_WIRELESS
-#define CONFIG_WIRELESS_SUSPEND \
- (EC_WIRELESS_SWITCH_WLAN | EC_WIRELESS_SWITCH_WLAN_POWER)
-#define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L
-#define WIRELESS_GPIO_WLAN_POWER GPIO_PP3300_DX_WLAN
-#undef CONFIG_UART_TX_BUF_SIZE
-#define CONFIG_UART_TX_BUF_SIZE 256
-
-/* EC console commands */
-#define CONFIG_CMD_ACCELS
-#define CONFIG_CMD_ACCEL_INFO
-#define CONFIG_CMD_BATT_MFG_ACCESS
-#define CONFIG_CMD_CHARGER_ADC_AMON_BMON
-#define CONFIG_HOSTCMD_PD_CONTROL
-
-/* EC console history configuration */
-#undef CONFIG_CONSOLE_HISTORY
-#define CONFIG_CONSOLE_HISTORY 1
-
-/* SOC */
-#define CONFIG_CHIPSET_SKYLAKE
-#define CONFIG_CHIPSET_HAS_PLATFORM_PMIC_RESET
-#define CONFIG_CHIPSET_RESET_HOOK
-#define CONFIG_HOSTCMD_ESPI
-#define CONFIG_HOSTCMD_ESPI_VW_SLP_S3
-#define CONFIG_HOSTCMD_ESPI_VW_SLP_S4
-
-#define CONFIG_KEYBOARD_COL2_INVERTED
-#undef CONFIG_KEYBOARD_VIVALDI
-#define CONFIG_KEYBOARD_PROTOCOL_8042
-#define CONFIG_KEYBOARD_REFRESH_ROW3
-#define CONFIG_TABLET_MODE
-
-/* Battery */
-#define CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF
-#define CONFIG_BATTERY_CUT_OFF
-#define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION"
-#define CONFIG_BATTERY_LEVEL_NEAR_FULL 94
-#define CONFIG_BATTERY_PRESENT_CUSTOM
-#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
-#define CONFIG_BATTERY_SMART
-#define CONFIG_BATTERY_VENDOR_PARAM
-
-/* Charger */
-#define CONFIG_CHARGE_MANAGER
-#define CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT
-#define CONFIG_CHARGE_RAMP_SW
-#define CONFIG_CHARGER
-#define CONFIG_CHARGER_BD9995X
-#define CONFIG_CHARGER_BD9995X_CHGEN
-#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_MAINTAIN_VBAT
-#define CONFIG_CHARGER_PROFILE_OVERRIDE
-#define CONFIG_CHARGER_PSYS_READ
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
-#define BD9995X_IOUT_GAIN_SELECT \
- BD9995X_CMD_PMON_IOUT_CTRL_SET_IOUT_GAIN_SET_20V
-#define BD9995X_PSYS_GAIN_SELECT \
- BD9995X_CMD_PMON_IOUT_CTRL_SET_PMON_GAIN_SET_02UAW
-#define CONFIG_EXTPOWER_GPIO
-#undef CONFIG_EXTPOWER_DEBOUNCE_MS
-#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
-#define CONFIG_POWER_BUTTON
-#define CONFIG_POWER_BUTTON_X86
-#define CONFIG_POWER_COMMON
-#define CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD 30
-#define CONFIG_PWR_STATE_DISCHARGE_FULL
-
-/* Sensor */
-#define CONFIG_MKBP_EVENT
-/* Don't wake up from suspend on any MKBP event. */
-#define CONFIG_MKBP_EVENT_WAKEUP_MASK 0
-#define CONFIG_MKBP_USE_HOST_EVENT
-#define CONFIG_ACCEL_KXCJ9
-#define CONFIG_ALS_SI114X 0x40
-#define CONFIG_ALS_SI114X_INT_EVENT \
- TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_LIGHT)
-#define CONFIG_ALS_SI114X_POLLING
-#define CONFIG_TEMP_SENSOR
-#define CONFIG_TEMP_SENSOR_BD99992GW
-#define CONFIG_THERMISTOR_NCP15WB
-#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_MAG_BMI_BMM150
-#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
- TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
-#define CONFIG_ACCELGYRO_SEC_ADDR_FLAGS BMM150_ADDR0_FLAGS
-#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT /* Unused */
-#define CONFIG_MAG_CALIBRATE
-#define CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_INVALID_CHECK
-#define CONFIG_LID_ANGLE_TABLET_MODE
-#define CONFIG_LID_ANGLE_UPDATE
-#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
-#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
-
-/* Enable sensor fifo, must also define the _SIZE and _THRES */
-#define CONFIG_ACCEL_FIFO
-/* FIFO size is in power of 2. */
-#define CONFIG_ACCEL_FIFO_SIZE 256
-/* Depends on how fast the AP boots and typical ODRs */
-#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3)
-
-/* Enable double tap detection */
-#define CONFIG_GESTURE_DETECTION
-#define CONFIG_GESTURE_HOST_DETECTION
-#define CONFIG_GESTURE_SENSOR_DOUBLE_TAP
-#define CONFIG_GESTURE_SAMPLING_INTERVAL_MS 5
-#define CONFIG_GESTURE_TAP_THRES_MG 100
-#define CONFIG_GESTURE_TAP_MAX_INTERSTICE_T 500
-#define CONFIG_GESTURE_DETECTION_MASK BIT(CONFIG_GESTURE_TAP_SENSOR)
-#define CONFIG_GESTURE_TAP_SENSOR 1
-
-/* USB */
-#define CONFIG_USB_PID 0x504B
-
-#define CONFIG_USB_CHARGER
-#define CONFIG_USB_DRP_ACC_TRYSRC
-#define CONFIG_USB_PD_ALT_MODE
-#define CONFIG_USB_PD_ALT_MODE_DFP
-#define CONFIG_USB_PD_COMM_LOCKED
-#define CONFIG_USB_PD_DECODE_SOP
-#define CONFIG_USB_PD_DISCHARGE_TCPC
-#define CONFIG_USB_PD_DUAL_ROLE
-#define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
-#define CONFIG_BD9995X_DELAY_INPUT_PORT_SELECT
-#define CONFIG_USB_PD_LOGGING
-#define CONFIG_USB_PD_PORT_MAX_COUNT 2
-#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
-#define CONFIG_USB_PD_TCPC_BOARD_INIT
-#define CONFIG_USB_PD_TCPC_LOW_POWER
-#define CONFIG_USB_PD_TCPM_MUX
-#define CONFIG_USB_PD_TCPM_ANX3429
-#define CONFIG_USB_PD_TCPM_TCPCI
-#define CONFIG_USB_PD_TRY_SRC
-#undef CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC
-#define CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC 2
-#define CONFIG_USB_POWER_DELIVERY
-#define CONFIG_USB_PD_TCPMV2
-#define CONFIG_USBC_SS_MUX
-#define CONFIG_USBC_VCONN
-#define CONFIG_USBC_VCONN_SWAP
-
-/* Optional feature to configure npcx chip */
-#define NPCX_UART_MODULE2 1 /* 1:GPIO64/65 as UART */
-#define NPCX_JTAG_MODULE2 0 /* 0:GPIO21/17/16/20 as JTAG */
-#define NPCX_TACH_SEL2 0 /* 0:GPIO40/73 as TACH */
-
-/* I2C ports */
-#define I2C_PORT_TCPC0 NPCX_I2C_PORT0_0
-#define I2C_PORT_TCPC1 NPCX_I2C_PORT0_1
-#define I2C_PORT_GYRO NPCX_I2C_PORT1
-#define I2C_PORT_ACCEL I2C_PORT_GYRO
-#define I2C_PORT_LID_ACCEL NPCX_I2C_PORT2
-#define I2C_PORT_ALS NPCX_I2C_PORT2
-#define I2C_PORT_PMIC NPCX_I2C_PORT3
-#define I2C_PORT_BATTERY NPCX_I2C_PORT3
-#define I2C_PORT_CHARGER NPCX_I2C_PORT3
-#define I2C_PORT_THERMAL I2C_PORT_PMIC
-#define I2C_PORT_MP2949 NPCX_I2C_PORT3
-
-/* I2C addresses */
-#define I2C_ADDR_BD99992_FLAGS 0x30
-#define I2C_ADDR_MP2949_FLAGS 0x20
-
-#ifndef __ASSEMBLER__
-
-#include "gpio_signal.h"
-#include "registers.h"
-
-enum board_version_list {
- BOARD_VERSION_P0,
- BOARD_VERSION_P0B,
- BOARD_VERSION_P1,
- BOARD_VERSION_P1B,
- BOARD_VERSION_EVT,
- BOARD_VERSION_EVTB,
- BOARD_VERSION_DVT,
- BOARD_VERSION_DVTB,
- BOARD_VERSION_PVT,
-};
-
-enum temp_sensor_id {
- TEMP_SENSOR_BATTERY, /* BD99956GW TSENSE */
- TEMP_SENSOR_AMBIENT, /* BD99992GW SYSTHERM0 */
- TEMP_SENSOR_CHARGER, /* BD99992GW SYSTHERM1 */
- TEMP_SENSOR_DRAM, /* BD99992GW SYSTHERM2 */
- TEMP_SENSOR_EMMC, /* BD99992GW SYSTHERM3 */
- TEMP_SENSOR_GYRO,
- TEMP_SENSOR_COUNT
-};
-
-/*
- * The PWM channel enums for the LEDs need to be in Red, Green, Blue order as
- * the 'set_color()' function assumes this order. The left vs right order
- * doesn't matter as long as each side follows RGB order.
- */
-enum pwm_channel {
- PWM_CH_KBLIGHT,
- PWM_CH_LED_L_RED,
- PWM_CH_LED_L_GREEN,
- PWM_CH_LED_L_BLUE,
- PWM_CH_LED_R_RED,
- PWM_CH_LED_R_GREEN,
- PWM_CH_LED_R_BLUE,
- PWM_CH_COUNT
-};
-
-/*
- * For backward compatibility, to report ALS via ACPI,
- * Define the number of ALS sensors: motion_sensor copy the data to the ALS
- * memmap region.
- */
-#define CONFIG_ALS
-#define ALS_COUNT 1
-
-/*
- * Motion sensors:
- * When reading through IO memory is set up for sensors (LPC is used),
- * the first 2 entries must be accelerometers, then gyroscope.
- * For BMI160, accel, gyro and compass sensors must be next to each other.
- */
-enum sensor_id {
- LID_ACCEL = 0,
- BASE_ACCEL,
- BASE_GYRO,
- BASE_MAG,
- LID_LIGHT,
- SENSOR_COUNT,
-};
-
-enum adc_channel {
- ADC_CH_COUNT
-};
-
-/*
- * delay to turn on the power supply max is ~16ms.
- * delay to turn off the power supply max is about ~180ms.
- */
-#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
-#define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */
-
-/* delay to turn on/off vconn */
-
-/* Define typical operating power and max power */
-#define PD_OPERATING_POWER_MW 15000
-#define PD_MAX_POWER_MW 45000
-#define PD_MAX_CURRENT_MA 3000
-#define PD_MAX_VOLTAGE_MV 20000
-
-/* Board specific handlers */
-int board_get_version(void);
-void board_reset_pd_mcu(void);
-void board_set_tcpc_power_mode(int port, int mode);
-void board_tcpc_init(void);
-void led_register_double_tap(void);
-
-/* Sensors without hardware FIFO are in forced mode */
-#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL) | BIT(LID_LIGHT))
-
-#endif /* !__ASSEMBLER__ */
-
-#endif /* __CROS_EC_BOARD_H */
diff --git a/board/eve/build.mk b/board/eve/build.mk
deleted file mode 100644
index f47b5d9caf..0000000000
--- a/board/eve/build.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- makefile -*-
-# Copyright 2016 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-# Board specific files build
-#
-
-CHIP:=npcx
-CHIP_VARIANT:=npcx5m6g
-
-board-y=board.o led.o
-board-$(CONFIG_BATTERY_SMART)+=battery.o
-board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o
diff --git a/board/eve/ec.tasklist b/board/eve/ec.tasklist
deleted file mode 100644
index 99de365243..0000000000
--- a/board/eve/ec.tasklist
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/*
- * See CONFIG_TASK_LIST in config.h for details.
- */
-
-#define CONFIG_TASK_LIST \
- TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_ALWAYS(LED, led_task, NULL, TASK_STACK_SIZE) \
- TASK_ALWAYS(CHG_RAMP, chg_ramp_task, NULL, TASK_STACK_SIZE) \
- TASK_ALWAYS(USB_CHG, usb_charger_task, NULL, TASK_STACK_SIZE) \
- TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \
- TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \
- TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_ALWAYS(POWERBTN, power_button_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) \
- TASK_ALWAYS(PD_C0, pd_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_ALWAYS(PD_C1, pd_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, TASK_STACK_SIZE) \
- TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, TASK_STACK_SIZE)
diff --git a/board/eve/gpio.inc b/board/eve/gpio.inc
deleted file mode 100644
index f9b0c3cfc4..0000000000
--- a/board/eve/gpio.inc
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- mode:c -*-
- *
- * Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Declare symbolic names for all the GPIOs that we care about.
- * Note: Those with interrupt handlers must be declared first. */
-
-GPIO_INT(CHARGER_INT_L, PIN(3, 3), GPIO_INT_FALLING, bd9995x_vbus_interrupt)
-GPIO_INT(USB_C0_PD_INT_ODL, PIN(3, 7), GPIO_INT_FALLING, tcpc_alert_event)
-GPIO_INT(USB_C1_PD_INT_ODL, PIN(C, 5), GPIO_INT_FALLING, tcpc_alert_event)
-GPIO_INT(PCH_SLP_S0_L, PIN(7, 5), GPIO_INT_BOTH, power_signal_interrupt)
-GPIO_INT(PCH_SLP_SUS_L, PIN(6, 2), GPIO_INT_BOTH, power_signal_interrupt)
-GPIO_INT(RSMRST_L_PGOOD, PIN(B, 0), GPIO_INT_BOTH, power_signal_interrupt)
-GPIO_INT(PMIC_DPWROK, PIN(9, 7), GPIO_INT_BOTH, power_signal_interrupt)
-GPIO_INT(POWER_BUTTON_L, PIN(0, 4), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt)
-GPIO_INT(LID_OPEN, PIN(6, 7), GPIO_INT_BOTH, lid_interrupt)
-GPIO_INT(TABLET_MODE_L, PIN(3, 6), GPIO_INT_BOTH, tablet_mode_interrupt)
-/* Volume buttons are swapped in the schematic */
-GPIO_INT(VOLUME_DOWN_L, PIN(8, 2), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
-GPIO_INT(VOLUME_UP_L, PIN(8, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
-GPIO_INT(WP_L, PIN(4, 0), GPIO_INT_BOTH, switch_interrupt)
-GPIO_INT(AC_PRESENT, PIN(C, 1), GPIO_INT_BOTH, extpower_interrupt)
-GPIO_INT(ACCELGYRO3_INT_L, PIN(9, 3), GPIO_INT_FALLING, bmi160_interrupt)
-GPIO_INT(TRACKPAD_INT_L, PIN(7, 1), GPIO_INT_FALLING, trackpad_interrupt)
-/* DSP IRQ is active low in schematic but DSP treats as active high */
-GPIO_INT(MIC_DSP_IRQ_1V8_L, PIN(C, 6), GPIO_INT_RISING | GPIO_SEL_1P8V, dsp_interrupt)
-#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
-GPIO_INT(USB_C0_CABLE_DET, PIN(D, 2), GPIO_INT_RISING, anx74xx_cable_det_interrupt)
-GPIO_INT(USB_C1_CABLE_DET, PIN(D, 3), GPIO_INT_RISING, anx74xx_cable_det_interrupt)
-#else
-GPIO(USB_C0_CABLE_DET, PIN(D, 2), GPIO_INPUT)
-GPIO(USB_C1_CABLE_DET, PIN(D, 3), GPIO_INPUT)
-#endif
-
-/* Lid KCJX9 accelerometer sensor interrupt */
-GPIO(ACCEL1_INT_L, PIN(C, 7), GPIO_INPUT | GPIO_PULL_UP)
-
-GPIO(PCH_RTCRST, PIN(E, 7), GPIO_OUT_LOW) /* RTCRST# to SOC */
-GPIO(ENABLE_BACKLIGHT, PIN(5, 6), GPIO_OUT_LOW) /* Enable Backlight */
-GPIO(TRACKPAD_SHDN_L, PIN(3, 2), GPIO_OUT_LOW) /* Enable Trackpad */
-GPIO(WLAN_OFF_L, PIN(7, 2), GPIO_OUT_LOW) /* Disable WLAN */
-GPIO(PP3300_DX_WLAN, PIN(A, 7), GPIO_OUT_LOW) /* Enable WLAN 3.3V Power */
-GPIO(CHARGER_RST_ODL, PIN(0, 1), GPIO_INPUT | GPIO_PULL_UP) /* CHARGER_RST_ODL, no-connect */
-GPIO(CPU_PROCHOT, PIN(8, 1), GPIO_OUT_LOW) /* PROCHOT to SOC */
-GPIO(PCH_ACOK, PIN(5, 0), GPIO_ODR_LOW) /* ACOK to SOC */
-GPIO(PCH_WAKE_L, PIN(A, 3), GPIO_ODR_HIGH) /* Wake SOC */
-GPIO(PCH_RSMRST_L, PIN(7, 0), GPIO_OUT_LOW) /* RSMRST# to SOC */
-GPIO(PCH_PWRBTN_L, PIN(4, 1), GPIO_ODR_HIGH) /* Power Button to SOC */
-GPIO(EC_PLATFORM_RST, PIN(A, 6), GPIO_OUT_LOW) /* EC Reset to LDO_EN */
-GPIO(SYS_RESET_L, PIN(6, 1), GPIO_ODR_HIGH) /* Cold Reset to SOC */
-GPIO(PMIC_SLP_SUS_L, PIN(8, 5), GPIO_OUT_LOW) /* SLP_SUS# to PMIC */
-GPIO(BATTERY_PRESENT_L, PIN(3, 4), GPIO_INPUT) /* Battery Present */
-GPIO(CCD_MODE_ODL, PIN(6, 3), GPIO_INPUT) /* Case Closed Debug Mode */
-GPIO(EC_HAVEN_RESET_ODL, PIN(0, 2), GPIO_INPUT | GPIO_PULL_UP) /* H1 Reset, no-connect */
-GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUTPUT) /* EC Entering RW */
-GPIO(PMIC_INT_L, PIN(6, 0), GPIO_INPUT) /* PMIC interrupt */
-
-/* I2C pins - these will be reconfigured for alternate function below */
-GPIO(I2C0_0_SCL, PIN(B, 5), GPIO_INPUT) /* EC_I2C00_USB_C0_SCL */
-GPIO(I2C0_0_SDA, PIN(B, 4), GPIO_INPUT) /* EC_I2C00_USB_C0_SDA */
-GPIO(I2C0_1_SCL, PIN(B, 3), GPIO_INPUT) /* EC_I2C01_USB_C1_SCL */
-GPIO(I2C0_1_SDA, PIN(B, 2), GPIO_INPUT) /* EC_I2C01_USB_C1_SDA */
-GPIO(I2C1_SCL, PIN(9, 0), GPIO_INPUT) /* EC_I2C1_GYRO_SCL */
-GPIO(I2C1_SDA, PIN(8, 7), GPIO_INPUT) /* EC_I2C1_GYRO_SDA */
-GPIO(I2C2_SCL, PIN(9, 2), GPIO_INPUT) /* EC_I2C2_SENSOR_3V3_SCL */
-GPIO(I2C2_SDA, PIN(9, 1), GPIO_INPUT) /* EC_I2C2_SENSOR_3V3_SDA */
-GPIO(I2C3_SCL, PIN(D, 1), GPIO_INPUT) /* EC_I2C3_POWER_SCL */
-GPIO(I2C3_SDA, PIN(D, 0), GPIO_INPUT) /* EC_I2C3_POWER_SDA */
-
-/*
- * For P1 and prior: 5V enables: INPUT=1.5A, OUT_LOW=OFF, OUT_HIGH=3A
- * For P1B and later: 5V enables: OUT_LOW=VBUS Off, OUT_HIGH=VBUS On
- */
-GPIO(USB_C0_5V_EN, PIN(4, 2), GPIO_OUT_LOW | GPIO_PULL_UP) /* C0 5V Enable */
-GPIO(USB_C1_5V_EN, PIN(B, 1), GPIO_OUT_LOW | GPIO_PULL_UP) /* C1 5V Enable */
-GPIO(EN_USB_C0_3A, PIN(6, 6), GPIO_OUT_LOW) /* 1.5/3.0 C0 current limit selection */
-GPIO(EN_USB_C1_3A, PIN(3, 5), GPIO_OUT_LOW) /* 1.5/3.0 C1 current limit selection */
-GPIO(USB_C0_PD_RST_L, PIN(0, 3), GPIO_OUT_LOW) /* C0 PD Reset */
-GPIO(USB_C1_PD_RST_L, PIN(7, 4), GPIO_OUT_LOW) /* C1 PD Reset */
-GPIO(USB_C0_DP_HPD, PIN(9, 4), GPIO_INPUT) /* C0 DP Hotplug Detect */
-GPIO(USB_C1_DP_HPD, PIN(A, 5), GPIO_INPUT) /* C1 DP Hotplug Detect */
-GPIO(USB_C0_TCPC_PWR, PIN(8, 4), GPIO_OUT_LOW) /* Enable C0 TCPC Power */
-GPIO(USB_C1_TCPC_PWR, PIN(0, 0), GPIO_OUT_LOW) /* Enable C1 TCPC Power */
-GPIO(USB2_OTG_ID, PIN(A, 1), GPIO_OUT_LOW) /* OTG ID */
-GPIO(USB2_OTG_VBUSSENSE, PIN(9, 5), GPIO_OUT_LOW) /* OTG VBUS Sense */
-
-/* Board ID */
-GPIO(BOARD_VERSION1, PIN(4, 3), GPIO_INPUT | GPIO_PULL_UP) /* Board ID bit0 */
-GPIO(BOARD_VERSION2, PIN(4, 4), GPIO_INPUT | GPIO_PULL_UP) /* Board ID bit1 */
-GPIO(BOARD_VERSION3, PIN(4, 5), GPIO_INPUT | GPIO_PULL_UP) /* Board ID bit2 */
-
-/* Alternate functions GPIO definitions */
-ALTERNATE(PIN_MASK(6, 0x30), 1, MODULE_UART, 0) /* GPIO64-65 */ /* UART from EC to Servo */
-ALTERNATE(PIN_MASK(8, 0x80), 1, MODULE_I2C, 0) /* GPIO87 */ /* EC_I2C1_GYRO_SDA */
-ALTERNATE(PIN_MASK(9, 0x01), 1, MODULE_I2C, 0) /* GPIO90 */ /* EC_I2C1_GYRO_SCL */
-ALTERNATE(PIN_MASK(9, 0x06), 1, MODULE_I2C, 0) /* GPIO91-92 */ /* EC_I2C2_SENSOR_3V3_SDA/SCL */
-ALTERNATE(PIN_MASK(B, 0x30), 1, MODULE_I2C, 0) /* GPIOB4-B5 */ /* EC_I2C00_USB_C0_SDA/SCL */
-ALTERNATE(PIN_MASK(B, 0x0C), 1, MODULE_I2C, 0) /* GPOPB2-B3 */ /* EC_I2C01_USB_C1_SDA/SCL */
-ALTERNATE(PIN_MASK(D, 0x03), 1, MODULE_I2C, 0) /* GPIOD0-D1 */ /* EC_I2C3_POWER_SDA/SCL */
-ALTERNATE(PIN_MASK(B, 0x80), 1, MODULE_PWM, 0) /* GPIOB7 */ /* KBD_BL_PWM */
-/* Left LED PWM Channels */
-ALTERNATE(PIN_MASK(C, 0x10), 1, MODULE_PWM, 0) /* GPIOC4 PWM2 Red*/
-ALTERNATE(PIN_MASK(B, 0x40), 1, MODULE_PWM, 0) /* GPOB6 PWM3 Green*/
-ALTERNATE(PIN_MASK(8, 0x01), 1, MODULE_PWM, 0) /* GPIO80 PWM4 Blue*/
-/* Right LED PWM Channels */
-ALTERNATE(PIN_MASK(C, 0x04), 1, MODULE_PWM, 0) /* GPIOC2 PWM1 Red*/
-ALTERNATE(PIN_MASK(C, 0x08), 1, MODULE_PWM, 0) /* GPIOC3 PWM0 Green */
-ALTERNATE(PIN_MASK(C, 0x01), 1, MODULE_PWM, 0) /* GPIOC0 PWM6 Blue */
-
-/* Set unused pins as Input+PU */
-GPIO(TP_EC_GPIO_57, PIN(5, 7), GPIO_INPUT | GPIO_PULL_UP)
-
-/* Keyboard pins */
-#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP)
-#define GPIO_KB_OUTPUT (GPIO_ODR_HIGH)
-#define GPIO_KB_OUTPUT_COL2 (GPIO_OUT_LOW)
-
-ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_INPUT)
-ALTERNATE(PIN_MASK(2, 0xfc), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_INPUT)
-ALTERNATE(PIN_MASK(2, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_OUTPUT)
-ALTERNATE(PIN_MASK(0, 0xe0), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_OUTPUT)
-ALTERNATE(PIN_MASK(1, 0x7f), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_OUTPUT)
-GPIO(KBD_KSO2, PIN(1, 7), GPIO_KB_OUTPUT_COL2)
diff --git a/board/eve/led.c b/board/eve/led.c
deleted file mode 100644
index 91a7b24a2b..0000000000
--- a/board/eve/led.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/* Copyright 2017 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Power/Battery LED control for Eve
- */
-
-#include "charge_manager.h"
-#include "charge_state.h"
-#include "chipset.h"
-#include "console.h"
-#include "extpower.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "led_common.h"
-#include "pwm.h"
-#include "math_util.h"
-#include "registers.h"
-#include "task.h"
-#include "util.h"
-
-#define CPRINTF(format, args...) cprintf(CC_PWM, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_PWM, format, ## args)
-
-#define LED_TICK_TIME (500 * MSEC)
-#define LED_TICKS_PER_BEAT 1
-#define NUM_PHASE 2
-#define DOUBLE_TAP_TICK_LEN (LED_TICKS_PER_BEAT * 8)
-#define LED_FRAC_BITS 4
-#define LED_STEP_MSEC 45
-
-/*
- * The PWM % on levels to transition from intensity 0 (black) to intensity 1.0
- * (white) in the HSI color space converted back to RGB space (0 - 255) and
- * converted to a % for PWM. This table is used for Red <--> White and Green
- * <--> Transitions. In HSI space white = (0, 0, 1), red = (0, .5, .33), green =
- * (120, .5, .33). For the transitions of interest only S and I are changed and
- * they are changed linearly in HSI space.
- */
-static const uint8_t trans_steps[] = {0, 4, 9, 16, 24, 33, 44, 56, 69, 84, 100};
-
-/* List of LED colors used */
-enum led_color {
- LED_OFF = 0,
- LED_RED,
- LED_GREEN,
- LED_BLUE,
- LED_WHITE,
- LED_RED_HALF,
-
- /* Number of colors, not a color itself */
- LED_COLOR_COUNT
-};
-
-/* List of supported LED patterns */
-enum led_pattern {
- OFF = 0,
- SOLID_GREEN,
- WHITE_GREEN,
- SOLID_WHITE,
- WHITE_RED,
- SOLID_RED,
- PULSE_RED,
- BLINK_RED,
- LED_NUM_PATTERNS,
-};
-
-enum led_side {
- LED_LEFT = 0,
- LED_RIGHT,
- LED_BOTH
-};
-
-struct led_info {
- /* LED pattern manage variables */
- int ticks;
- int pattern_sel;
- int tap_tick_count;
- enum led_color color;
- /* Color transition variables */
- int state;
- int step;
- uint8_t rgb_current[3];
- const uint8_t *rgb_target;
- uint8_t trans[ARRAY_SIZE(trans_steps)];
-};
-
-/*
- * LED patterns are described as two phases. Each phase has an associated LED
- * color and length in beats. The length of each beat is defined by the macro
- * LED_TICKS_PER_BEAT.
- */
-struct led_phase {
- uint8_t color[NUM_PHASE];
- uint8_t len[NUM_PHASE];
- uint8_t tap_len;
-};
-
-static int led_debug;
-static int double_tap;
-static int led_charge_side;
-static struct led_info led[LED_BOTH];
-
-const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_LEFT_LED, EC_LED_ID_RIGHT_LED};
-const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-
-/*
- * Pattern table. The len field is beats per color. 0 for len indicates that a
- * particular pattern never changes from the first phase.
- */
-static const struct led_phase pattern[LED_NUM_PATTERNS] = {
- { {LED_OFF, LED_OFF}, {0, 0}, DOUBLE_TAP_TICK_LEN },
- { {LED_GREEN, LED_GREEN}, {0, 0}, DOUBLE_TAP_TICK_LEN },
- { {LED_WHITE, LED_GREEN}, {2, 4}, DOUBLE_TAP_TICK_LEN },
- { {LED_WHITE, LED_WHITE}, {0, 0}, DOUBLE_TAP_TICK_LEN },
- { {LED_WHITE, LED_RED}, {2, 4}, DOUBLE_TAP_TICK_LEN },
- { {LED_RED, LED_RED}, {0, 0}, DOUBLE_TAP_TICK_LEN},
- { {LED_RED, LED_RED_HALF}, {4, 4}, DOUBLE_TAP_TICK_LEN * 2 +
- DOUBLE_TAP_TICK_LEN / 2},
- { {LED_RED, LED_OFF}, {1, 5}, DOUBLE_TAP_TICK_LEN * 3 +
- DOUBLE_TAP_TICK_LEN / 2},
-};
-
-/*
- * Brightness vs. color, in the order of off, red, green and blue. Values are
- * for % on PWM duty cycle time.
- */
-#define PWM_CHAN_PER_LED 3
-static const uint8_t color_brightness[LED_COLOR_COUNT][PWM_CHAN_PER_LED] = {
- /* {Red, Green, Blue}, */
- [LED_OFF] = {0, 0, 0},
- [LED_RED] = {80, 0, 0},
- [LED_GREEN] = {0, 80, 0},
- [LED_BLUE] = {0, 0, 80},
- [LED_WHITE] = {100, 100, 100},
- [LED_RED_HALF] = {40, 0, 0},
-};
-
-/*
- * When a double tap event occurs, a LED pattern is displayed based on the
- * current battery charge level. The LED patterns used for double tap under low
- * battery conditions are same patterns displayed when the battery is not
- * charging. The table below shows what battery charge level displays which
- * pattern.
- */
-struct range_map {
- uint8_t max;
- uint8_t pattern;
-};
-
-#if (CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC >= 3)
-#error "LED: PULSE_RED battery level <= BLINK_RED level"
-#endif
-static const struct range_map pattern_tbl[] = {
- {CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC - 1, BLINK_RED},
- {5, PULSE_RED},
- {15, SOLID_RED},
- {25, WHITE_RED},
- {75, SOLID_WHITE},
- {95, WHITE_GREEN},
- {100, SOLID_GREEN},
-};
-
-enum led_state_change {
- LED_STATE_INTENSITY_DOWN,
- LED_STATE_INTENSITY_UP,
- LED_STATE_DONE,
-};
-
-/**
- * Set LED color
- *
- * @param pwm Pointer to 3 element RGB color level (0 -> 100)
- * @param side Left LED, Right LED, or both LEDs
- */
-static void set_color(const uint8_t *pwm, enum led_side side)
-{
- int i;
- static uint8_t saved_duty[LED_BOTH][PWM_CHAN_PER_LED];
-
- /* Set color for left LED */
- if (side == LED_LEFT || side == LED_BOTH) {
- for (i = 0; i < PWM_CHAN_PER_LED; i++) {
- if (saved_duty[LED_LEFT][i] != pwm[i]) {
- pwm_set_duty(PWM_CH_LED_L_RED + i,
- 100 - pwm[i]);
- saved_duty[LED_LEFT][i] = pwm[i];
- }
- }
- }
-
- /* Set color for right LED */
- if (side == LED_RIGHT || side == LED_BOTH) {
- for (i = 0; i < PWM_CHAN_PER_LED; i++) {
- if (saved_duty[LED_RIGHT][i] != pwm[i]) {
- pwm_set_duty(PWM_CH_LED_R_RED + i,
- 100 - pwm[i]);
- saved_duty[LED_RIGHT][i] = pwm[i];
- }
- }
- }
-}
-
-void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
-{
- brightness_range[EC_LED_COLOR_RED] = 100;
- brightness_range[EC_LED_COLOR_BLUE] = 100;
- brightness_range[EC_LED_COLOR_GREEN] = 100;
-}
-
-int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
-{
- switch (led_id) {
- case EC_LED_ID_LEFT_LED:
- /* Set brightness for left LED */
- pwm_set_duty(PWM_CH_LED_L_RED,
- 100 - brightness[EC_LED_COLOR_RED]);
- pwm_set_duty(PWM_CH_LED_L_BLUE,
- 100 - brightness[EC_LED_COLOR_BLUE]);
- pwm_set_duty(PWM_CH_LED_L_GREEN,
- 100 - brightness[EC_LED_COLOR_GREEN]);
- break;
- case EC_LED_ID_RIGHT_LED:
- /* Set brightness for right LED */
- pwm_set_duty(PWM_CH_LED_R_RED,
- 100 - brightness[EC_LED_COLOR_RED]);
- pwm_set_duty(PWM_CH_LED_R_BLUE,
- 100 - brightness[EC_LED_COLOR_BLUE]);
- pwm_set_duty(PWM_CH_LED_R_GREEN,
- 100 - brightness[EC_LED_COLOR_GREEN]);
- break;
- default:
- return EC_ERROR_UNKNOWN;
- }
- return EC_SUCCESS;
-}
-
-void led_register_double_tap(void)
-{
- double_tap = 1;
-}
-
-static void led_setup_color_change(int old_idx, int new_idx, enum led_side side)
-{
- int i;
- int increase = 0;
- /*
- * Using the color indices, poplulate the current and target R, G, B
- * arrays. The arrays are indexed R = 0, G = 1, B = 2. If the target of
- * any of the 3 is greater than the current, then this color change is
- * an increase in intensity. Otherwise, it's a decrease.
- */
- led[side].rgb_target = color_brightness[new_idx];
- for (i = 0; i < PWM_CHAN_PER_LED; i++) {
- led[side].rgb_current[i] = color_brightness[old_idx][i];
- if (led[side].rgb_current[i] < led[side].rgb_target[i]) {
- /* increase in color */
- increase = 1;
- }
- }
- /* Check to see if increasing or decreasing color */
- if (increase) {
- led[side].state = LED_STATE_INTENSITY_UP;
- /* First entry of transition table == current level */
- led[side].step = 1;
- } else {
- /* Last entry of transition table == current level */
- led[side].step = ARRAY_SIZE(trans_steps) - 2;
- led[side].state = LED_STATE_INTENSITY_DOWN;
- }
-
- /*
- * Populate transition table based on the number of R, G, B components
- * changing. If only 1 componenet is changing, then can just do linear
- * steps over the range. If more than 1 component is changing, then
- * this is a white <--> color transition and will use
- * the precomputed steps which are derived by converting to HSI space
- * and then linearly transitioning S and I to go from the starting color
- * to white and vice versa.
- */
- if (old_idx == LED_WHITE || new_idx == LED_WHITE) {
- for (i = 0; i < ARRAY_SIZE(trans_steps); i++)
- led[side].trans[i] = trans_steps[i];
- } else {
- int delta_per_step;
- int step_value;
- int start_lvl;
- int total_change;
- /* Assume that the R component (index = 0) is changing */
- int rgb_index = 0;
-
- /*
- * Since the new or old color is not white, then this change
- * must involve only either red or green. There are no red <-->
- * green transitions. So only 1 color is being changed in this
- * case. Assume it's red (index = 0), but check if it's green
- * (index = 1).
- */
-
- if (old_idx == LED_GREEN || new_idx == LED_GREEN)
- rgb_index = 1;
-
- /*
- * Determine the total change assuming current level is higher
- * than target level. The transitions steps are always ordered
- * lower to higher. The starting index is adjusted if intensity
- * is decreasing.
- */
- start_lvl = led[side].rgb_target[rgb_index];
-
- if (led[side].state == LED_STATE_INTENSITY_UP)
- /*
- * Increasing in intensity, current level or R/G is
- * the starting level.
- */
- start_lvl = led[side].rgb_current[rgb_index];
-
- /*
- * Compute change per step using fractional bits. The step
- * change accumulates fractional bits and is truncated after
- * rounding before being added to the starting value.
- */
- total_change = ABS(led[side].rgb_current[rgb_index] -
- led[side].rgb_target[rgb_index]);
- delta_per_step = (total_change << LED_FRAC_BITS)
- / (ARRAY_SIZE(trans_steps) - 1);
- step_value = 0;
- for (i = 0; i < ARRAY_SIZE(trans_steps); i++) {
- led[side].trans[i] = start_lvl +
- ((step_value +
- (1 << (LED_FRAC_BITS - 1)))
- >> LED_FRAC_BITS);
- step_value += delta_per_step;
- }
- }
-
-}
-
-static void led_adjust_color_step(int side)
-{
- int i;
- int change = 0;
- uint8_t lvl = led[side].trans[led[side].step];
- uint8_t *rgb_c = led[side].rgb_current;
- const uint8_t *rgb_t = led[side].rgb_target;
-
- if (led[side].state == LED_STATE_INTENSITY_DOWN) {
- /*
- * Colors are going from higher to lower level. If the current
- * level of R, G, or B is higher than both the next step in the
- * transition table and and the target level, then move to
- * the larger of the two. The MAX is used to make sure that it
- * doens't drop below the target level.
- */
- for (i = 0; i < PWM_CHAN_PER_LED; i++) {
- if ((rgb_c[i] > rgb_t[i]) && (rgb_c[i] >= lvl)) {
- rgb_c[i] = MAX(lvl, rgb_t[i]);
- change = 1;
- }
- }
- /*
- * If nothing changed this iteration, or if lowest table entry
- * has been used, then the change is complete.
- */
- if (!change || --led[side].step < 0)
- led[side].state = LED_STATE_DONE;
-
- } else if (led[side].state == LED_STATE_INTENSITY_UP) {
- /*
- * Colors are going from lower to higher level. If the current
- * level of R, G, B is lower than both the target level and the
- * transition table entry for a given color, then move up to
- * the MIN of next transition step and target level.
- */
- for (i = 0; i < PWM_CHAN_PER_LED; i++) {
- if ((rgb_c[i] < rgb_t[i]) && (rgb_c[i] <= lvl)) {
- rgb_c[i] = MIN(lvl, rgb_t[i]);
- change = 1;
- }
- }
- /*
- * If nothing changed this iteration, or if highest table entry
- * has been used, then the change is complete.
- */
- if (!change || ++led[side].step >= ARRAY_SIZE(trans_steps))
- led[side].state = LED_STATE_DONE;
- }
- /* Apply current R, G, B levels */
- set_color(rgb_c, side);
-}
-
-static void led_change_color(void)
-{
- int i;
-
- /* Will loop here until the color change is complete. */
- while (led[LED_LEFT].state != LED_STATE_DONE ||
- led[LED_RIGHT].state != LED_STATE_DONE) {
-
- for (i = 0; i < LED_BOTH; i++) {
- if (led[i].state != LED_STATE_DONE)
- /* Move one step in the transition table */
- led_adjust_color_step(i);
-
- }
- msleep(LED_STEP_MSEC);
- }
-}
-
-static void led_manage_patterns(enum led_pattern *pattern_desired, int tap)
-{
- int color;
- int phase;
- int i;
- int color_change = 0;
-
- for (i = 0; i < LED_BOTH; i++) {
- /* For each led check if the pattern needs to change */
- if (pattern_desired[i] != led[i].pattern_sel) {
- /*
- * Pattern needs to change, but if double tap sequence
- * is active, then need to wait until that
- * completes. Unless the pattern change is due to
- * external charger state change, make that happen
- * immediately.
- */
- if (i == led_charge_side || !led[i].tap_tick_count) {
- led[i].ticks = 0;
- led[i].tap_tick_count = tap ?
- pattern[pattern_desired[i]].tap_len : 0;
- led[i].pattern_sel = pattern_desired[i];
- }
- }
- /* Determine pattern phase and color for current phase */
- phase = led[i].ticks < LED_TICKS_PER_BEAT *
- pattern[led[i].pattern_sel].len[0] ? 0 : 1;
- color = pattern[led[i].pattern_sel].color[phase];
- /* If color is changing, then setup the transition. */
- if (led[i].color != color) {
- led_setup_color_change(led[i].color, color, i);
- led[i].color = color;
- color_change = 1;
- }
- }
-
- if (color_change)
- /* Change color is done for both LEDs simultaneously */
- led_change_color();
-
- for (i = 0; i < LED_BOTH; i++) {
- /* Set color for the current phase */
- set_color(color_brightness[led[i].color], i);
-
- /*
- * Update led_ticks. If the len field is 0, then the pattern
- * being used is just one color so no need to increase the tick
- * count.
- */
- if (pattern[led[i].pattern_sel].len[0])
- if (++led[i].ticks == LED_TICKS_PER_BEAT *
- (pattern[led[i].pattern_sel].len[0] +
- pattern[led[i].pattern_sel].len[1]))
- led[i].ticks = 0;
-
- /* If double tap display is active, decrement its counter */
- if (led[i].tap_tick_count)
- led[i].tap_tick_count--;
- }
-}
-
-static enum led_pattern led_get_double_tap_pattern(int percent_chg)
-{
- int i;
- enum led_pattern pattern = OFF;
-
- for (i = 0; i < ARRAY_SIZE(pattern_tbl); i++) {
- if (percent_chg <= pattern_tbl[i].max) {
- pattern = pattern_tbl[i].pattern;
- break;
- }
- }
-
- return pattern;
-}
-
-static void led_select_pattern(enum led_pattern *pattern_desired, int tap)
-{
- enum charge_state chg_state = charge_get_state();
- int side;
- int percent_chg;
- enum led_pattern new_pattern;
-
- /* Get active charge port which maps directly to left/right LED */
- side = charge_manager_get_active_charge_port();
- /*
- * Maintain a copy of the side associated with charging. If there is no
- * active charging port, then charge_side = -1. This value is used to
- * manage the double_tap tick counts on a per LED basis.
- */
- led_charge_side = side;
- /* Ensure that side can be safely used as an index */
- if (side < 0 || side >= CONFIG_USB_PD_PORT_MAX_COUNT)
- side = LED_BOTH;
-
- /* Get percent charge */
- percent_chg = charge_get_percent();
-
- if (side == LED_BOTH) {
- /*
- * External charger is not connected. Find the pattern that
- * would be used for double tap event.
- */
- new_pattern = led_get_double_tap_pattern(percent_chg);
-
- /*
- * The patterns used for double tap and for not charging
- * state are the same for low battery cases. But, if
- * battery charge is high enough to be above SOLID_RED,
- * then only display LED pattern if double tap has
- * occurred.
- */
- if (!tap && new_pattern <= WHITE_RED)
- new_pattern = OFF;
- /*
- * When external charger is not connected, always apply pattern
- * to both LEDs.
- */
- pattern_desired[LED_LEFT] = new_pattern;
- pattern_desired[LED_RIGHT] = new_pattern;
-
- } else {
- /*
- * External charger is connected. First determine pattern for
- * charging side LED.
- */
- if (chg_state == PWR_STATE_CHARGE_NEAR_FULL ||
- ((chg_state == PWR_STATE_DISCHARGE_FULL)
- && extpower_is_present())) {
- new_pattern = SOLID_GREEN;
- } else if (chg_state == PWR_STATE_CHARGE) {
- new_pattern = SOLID_WHITE;
- } else {
- new_pattern = OFF;
- }
- pattern_desired[side] = new_pattern;
-
- /* Check for double tap for side not associated with charger */
- new_pattern = led_get_double_tap_pattern(percent_chg);
- if (!tap && new_pattern != BLINK_RED)
- new_pattern = OFF;
- /* Apply this pattern to the non-charging side LED */
- pattern_desired[side ^ 1] = new_pattern;
- }
-}
-
-static void led_init(void)
-{
- int i;
-
- /*
- * Enable PWMs and set to 0% duty cycle. If they're disabled,
- * seems to ground the pins instead of letting them float.
- */
- /* Initialize PWM channels for left LED */
- pwm_enable(PWM_CH_LED_L_RED, 1);
- pwm_enable(PWM_CH_LED_L_GREEN, 1);
- pwm_enable(PWM_CH_LED_L_BLUE, 1);
-
- /* Initialize PWM channels for right LED */
- pwm_enable(PWM_CH_LED_R_RED, 1);
- pwm_enable(PWM_CH_LED_R_GREEN, 1);
- pwm_enable(PWM_CH_LED_R_BLUE, 1);
-
- set_color(color_brightness[LED_OFF], LED_BOTH);
-
- /*
- * Initialize LED descriptors. The members that are used for changing
- * colors don't neet to be initialized as they are always computed
- * when a color change is required.
- */
- for (i = 0; i < LED_BOTH; i++) {
- led[i].pattern_sel = OFF;
- led[i].color = LED_OFF;
- led[i].ticks = 0;
- led[i].tap_tick_count = 0;
- led[i].state = LED_STATE_DONE;
- }
-
-}
-
-void led_task(void *u)
-{
- uint32_t start_time;
- uint32_t task_duration;
-
- led_init();
-
- usleep(SECOND);
-
- while (1) {
- enum led_pattern pattern_desired[LED_BOTH];
- int tap = 0;
-
- start_time = get_time().le.lo;
-
- if (double_tap) {
- /* Clear double tap indication */
- if (!chipset_in_state(CHIPSET_STATE_ON))
- /* If not in S0, then set tap on */
- tap = 1;
- double_tap = 0;
- }
-
- if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED) &&
- led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED) &&
- led_debug != 1) {
- /* Determine desired LED patterns for both LEDS */
- led_select_pattern(pattern_desired, tap);
- /* Update LED patterns/colors (if necessary) */
- led_manage_patterns(pattern_desired, tap);
- }
- /* Compute time for this iteration */
- task_duration = get_time().le.lo - start_time;
- /*
- * Compute wait time required to for next desired LED tick. If
- * the duration exceeds the tick time, then don't sleep.
- */
- if (task_duration < LED_TICK_TIME)
- usleep(LED_TICK_TIME - task_duration);
- }
-}
-
-/******************************************************************/
-/* Console commands */
-static int command_led(int argc, char **argv)
-{
- int side = LED_BOTH;
- char *e;
- enum led_color color;
-
- if (argc > 1) {
- if (argc > 2) {
- side = strtoi(argv[2], &e, 10);
- if (*e)
- return EC_ERROR_PARAM2;
- if (side > 1)
- return EC_ERROR_PARAM2;
- }
-
- if (!strcasecmp(argv[1], "debug")) {
- led_debug ^= 1;
- CPRINTF("led_debug = %d\n", led_debug);
- return EC_SUCCESS;
- }
-
- if (!strcasecmp(argv[1], "off"))
- color = LED_OFF;
- else if (!strcasecmp(argv[1], "red"))
- color = LED_RED;
- else if (!strcasecmp(argv[1], "green"))
- color = LED_GREEN;
- else if (!strcasecmp(argv[1], "blue"))
- color = LED_BLUE;
- else if (!strcasecmp(argv[1], "white"))
- color = LED_WHITE;
- else
- return EC_ERROR_PARAM1;
-
- set_color(color_brightness[color], side);
- }
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(led, command_led,
- "[debug|red|green|blue|white|amber|off <0|1>]",
- "Change LED color");
diff --git a/board/eve/usb_pd_policy.c b/board/eve/usb_pd_policy.c
deleted file mode 100644
index d6dd5ad1be..0000000000
--- a/board/eve/usb_pd_policy.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "atomic.h"
-#include "extpower.h"
-#include "charge_manager.h"
-#include "common.h"
-#include "console.h"
-#include "driver/charger/bd9995x.h"
-#include "driver/tcpm/anx74xx.h"
-#include "driver/tcpm/ps8xxx.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "registers.h"
-#include "system.h"
-#include "task.h"
-#include "timer.h"
-#include "util.h"
-#include "usb_mux.h"
-#include "usb_pd.h"
-#include "usb_pd_tcpm.h"
-
-#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args)
-
-static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT];
-static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5,
- TYPEC_RP_1A5};
-
-int board_vbus_source_enabled(int port)
-{
- return vbus_en[port];
-}
-
-static void board_vbus_update_source_current(int port)
-{
- enum gpio_signal gpio_5v_en = port ? GPIO_USB_C1_5V_EN :
- GPIO_USB_C0_5V_EN;
- enum gpio_signal gpio_3a_en = port ? GPIO_EN_USB_C1_3A :
- GPIO_EN_USB_C0_3A;
- int flags;
-
- if (system_get_board_version() >= BOARD_VERSION_P1B) {
- /*
- * For P1B and beyond, 1.5 vs 3.0 A limit is controlled by a
- * dedicated gpio where high = 3.0A and low = 1.5A. VBUS on/off
- * is controlled by GPIO_USB_C0/1_5V_EN. Both of these signals
- * can remain outputs.
- */
- gpio_set_level(gpio_3a_en, vbus_rp[port] == TYPEC_RP_3A0 ?
- 1 : 0);
- gpio_set_level(gpio_5v_en, vbus_en[port]);
- } else {
- /*
- * For P1 and earlier board revs, a single gpio signal is
- * used to both enable VBUS and set the current limit.
- * Driving USB_Cx_5V_EN high, actually put a 16.5k resistance
- * (2x 33k in parallel) on the NX5P3290 load switch ILIM pin,
- * setting a minimum OCP current of 3186 mA.
- * Putting an internal pull-up on USB_Cx_5V_EN, effectively put
- * a 33k resistor on ILIM, setting a minimum OCP current of
- * 1505 mA.
- */
- flags = (vbus_rp[port] == TYPEC_RP_1A5 && vbus_en[port]) ?
- (GPIO_INPUT | GPIO_PULL_UP) :
- (GPIO_OUTPUT | GPIO_PULL_UP);
- gpio_set_level(gpio_5v_en, vbus_en[port]);
- gpio_set_flags(gpio_5v_en, flags);
- }
-}
-
-void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- vbus_rp[port] = rp;
-
- /* change the GPIO driving the load switch if needed */
- board_vbus_update_source_current(port);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- /* Ensure we're not charging from this port */
- bd9995x_select_input_port(port, 0);
-
- pd_set_vbus_discharge(port, 0);
- /* Provide VBUS */
- vbus_en[port] = 1;
- board_vbus_update_source_current(port);
-
- /* notify host of power info change */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS; /* we are ready */
-}
-
-void pd_power_supply_reset(int port)
-{
- int prev_en;
-
- prev_en = vbus_en[port];
-
- /* Disable VBUS */
- vbus_en[port] = 0;
- board_vbus_update_source_current(port);
-
- /* Enable discharge if we were previously sourcing 5V */
- if (prev_en)
- pd_set_vbus_discharge(port, 1);
-
- /* notify host of power info change */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_check_vconn_swap(int port)
-{
- /* in G3, do not allow vconn swap since pp5000_A rail is off */
- return gpio_get_level(GPIO_PMIC_SLP_SUS_L);
-}
-
-void pd_execute_data_swap(int port,
- enum pd_data_role data_role)
-{
- /* Only port 0 supports device mode. */
- if (port != 0)
- return;
-
- gpio_set_level(GPIO_USB2_OTG_ID,
- (data_role == PD_ROLE_UFP) ? 1 : 0);
- gpio_set_level(GPIO_USB2_OTG_VBUSSENSE,
- (data_role == PD_ROLE_UFP) ? 1 : 0);
-}
diff --git a/board/eve/vif_override.xml b/board/eve/vif_override.xml
deleted file mode 100644
index 32736caf64..0000000000
--- a/board/eve/vif_override.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<!-- Add VIF field overrides here. See genvif.c and the Vendor Info File
- Definition from the USB-IF.
--->