eve: Updates from P1 build

- revert the change for issue 61431 as main build systems have
updated resistor values
- enable CONFIG_CHARGER_BD9995X_CHGEN, with the necessary changes
in battery.c to support the custom battery present functions
- enable CONFIG_CHARGER_MAINTAIN_VBAT
- enable CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT for testing
- set pre-charge current to 256mA to better wake up batteries
- set voltage-min to 6.1V to account for charger inaccuracies since
the battery expects >= 6V to wake up
- enable CONFIG_BACKLIGHT_LID to enforce backlight off with lid closed
- put all CONFIG_CMD enables in the same place
- make PCH_ACOK open drain (pull-up to be enabled on PCH)

BUG=chrome-os-partner:61431,chrome-os-partner:61676
BRANCH=none
TEST=manual testing on P1 boards at the factory

Change-Id: Ib20693c8200d253819873d03b54f91e12bda8270
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/428902
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Duncan Laurie
2017-01-17 10:27:29 -08:00
committed by chrome-bot
parent 268b510f0b
commit 383fea37f6
4 changed files with 69 additions and 10 deletions

View File

@@ -7,21 +7,25 @@
#include "battery.h"
#include "battery_smart.h"
#include "bd9995x.h"
#include "charge_state.h"
#include "console.h"
#include "ec_commands.h"
#include "extpower.h"
#include "gpio.h"
#include "util.h"
/* Shutdown mode parameter to write to manufacturer access register */
#define SB_SHUTDOWN_DATA 0x0010
static enum battery_present batt_pres_prev = BP_NOT_SURE;
/* Battery info for proto */
static const struct battery_info info = {
.voltage_max = 8800, /* mV */
.voltage_normal = 7700,
.voltage_min = 6000,
.precharge_current = 64, /* mA */
.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 = 0,
@@ -129,3 +133,54 @@ enum ec_status charger_profile_override_set_param(uint32_t param,
{
return EC_RES_INVALID_PARAM;
}
static inline 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);
}
/*
* Physical detection of battery.
*/
enum battery_present battery_is_present(void)
{
enum battery_present batt_pres;
/* 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_init()) {
batt_pres = BP_NO;
}
batt_pres_prev = batt_pres;
return batt_pres;
}
int board_battery_initialized(void)
{
return battery_hw_present() == batt_pres_prev;
}

View File

@@ -16,6 +16,7 @@
/* EC */
#define CONFIG_ADC
#define CONFIG_BACKLIGHT_LID
#define CONFIG_BOARD_HAS_BEFORE_RSMRST
#define CONFIG_BOARD_VERSION
#define CONFIG_BOARD_SPECIFIC_VERSION
@@ -46,6 +47,10 @@
/* 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_CMD_CHARGER_PSYS
#define CONFIG_CMD_PD_CONTROL
/* SOC */
#define CONFIG_CHIPSET_SKYLAKE
@@ -60,20 +65,23 @@
/* Battery */
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION"
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BATTERY_PRESENT_L
#define CONFIG_BATTERY_PRESENT_CUSTOM
#define CONFIG_BATTERY_REVIVE_DISCONNECT
#define CONFIG_BATTERY_SMART
/* Charger */
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT
#define CONFIG_CHARGE_RAMP
#define CONFIG_CHARGER
#define CONFIG_CHARGER_V2
#define CONFIG_CHARGER_BD99956
#define CONFIG_CHARGER_BD9995X_CHGEN
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000
#define CONFIG_CHARGER_MAINTAIN_VBAT
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
@@ -81,9 +89,6 @@
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_CMD_CHARGER_ADC_AMON_BMON
#define CONFIG_CMD_CHARGER_PSYS
#define CONFIG_CMD_PD_CONTROL
#define CONFIG_EXTPOWER_GPIO
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000

View File

@@ -31,7 +31,7 @@ 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_ODR_HIGH) /* CHARGER_RST_ODL */
GPIO(CPU_PROCHOT, PIN(8, 1), GPIO_OUT_HIGH) /* PROCHOT# to SOC */
GPIO(PCH_ACOK, PIN(5, 0), GPIO_OUT_LOW) /* ACOK 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 */

View File

@@ -35,7 +35,7 @@ const uint32_t pd_src_pdo[] = {
};
const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo);
const uint32_t pd_src_pdo_max[] = {
PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS),
PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS),
};
const int pd_src_pdo_max_cnt = ARRAY_SIZE(pd_src_pdo_max);
@@ -67,9 +67,8 @@ int board_vbus_source_enabled(int port)
static void board_vbus_update_source_current(int port)
{
enum gpio_signal gpio = port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN;
/* TODO(crosbug.com/p/61431): do not attempt to set 1.5A config */
int flags = (vbus_rp[port] == TYPEC_RP_1A5 && vbus_en[port]) ?
(GPIO_OUTPUT | GPIO_PULL_UP) : (GPIO_OUTPUT | GPIO_PULL_UP);
(GPIO_INPUT | GPIO_PULL_UP) : (GPIO_OUTPUT | GPIO_PULL_UP);
/*
* Driving USB_Cx_5V_EN high, actually put a 16.5k resistance