mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
charger: bd99955: Disable BC1.2 detection
bd99955 enables BC1.2 detection by default and auto-sets current limit based upon the detection results. This is undesirable because it races against our external current limit settings (eg. USB-C / PD detection). BUG=chrome-os-partner:51766 BRANCH=None TEST=Manual on kevin. Plug zinger 10 times, verify that battery charges at ~1500mA on each plug, except for cases where Zinger falls into reset / OC loop (a separate issue). Change-Id: I787b2434c30b89fe78bbe50666075c694bf64503 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/336970 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
5aec786f4c
commit
a536bdb1cd
@@ -10,6 +10,7 @@
|
||||
#include "bd99955.h"
|
||||
#include "charger.h"
|
||||
#include "console.h"
|
||||
#include "hooks.h"
|
||||
#include "i2c.h"
|
||||
#include "task.h"
|
||||
#include "util.h"
|
||||
@@ -352,18 +353,46 @@ int charger_set_voltage(int voltage)
|
||||
BD99955_BAT_CHG_COMMAND);
|
||||
}
|
||||
|
||||
static void bd99995_init(void)
|
||||
{
|
||||
int reg;
|
||||
const struct battery_info *bi = battery_get_info();
|
||||
|
||||
/* Disable BC1.2 detection on VCC */
|
||||
if (ch_raw_read16(BD99955_CMD_VCC_UCD_SET, ®,
|
||||
BD99955_EXTENDED_COMMAND))
|
||||
return;
|
||||
reg &= ~BD99955_CMD_UCD_SET_USBDETEN;
|
||||
ch_raw_write16(BD99955_CMD_VCC_UCD_SET, reg,
|
||||
BD99955_EXTENDED_COMMAND);
|
||||
|
||||
/* Disable BC1.2 detection on VBUS */
|
||||
if (ch_raw_read16(BD99955_CMD_VBUS_UCD_SET, ®,
|
||||
BD99955_EXTENDED_COMMAND))
|
||||
return;
|
||||
reg &= ~BD99955_CMD_UCD_SET_USBDETEN;
|
||||
ch_raw_write16(BD99955_CMD_VBUS_UCD_SET, reg,
|
||||
BD99955_EXTENDED_COMMAND);
|
||||
|
||||
/* Disable BC1.2 charge enable trigger */
|
||||
if (ch_raw_read16(BD99955_CMD_CHGOP_SET1, ®,
|
||||
BD99955_EXTENDED_COMMAND))
|
||||
return;
|
||||
reg |= (BD99955_CMD_CHGOP_SET1_VCC_BC_DISEN |
|
||||
BD99955_CMD_CHGOP_SET1_VBUS_BC_DISEN);
|
||||
ch_raw_write16(BD99955_CMD_CHGOP_SET1, reg,
|
||||
BD99955_EXTENDED_COMMAND);
|
||||
|
||||
/* Set battery OVP to 500 + maximum battery voltage */
|
||||
ch_raw_write16(BD99955_CMD_VBATOVP_SET,
|
||||
(bi->voltage_max + 500) & 0x7ff0,
|
||||
BD99955_EXTENDED_COMMAND);
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, bd99995_init, HOOK_PRIO_DEFAULT);
|
||||
|
||||
int charger_post_init(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
/*
|
||||
* TODO: Disable charger & re-enable to initialize it.
|
||||
*/
|
||||
rv = charger_discharge_on_ac(1);
|
||||
if (rv)
|
||||
return rv;
|
||||
|
||||
return charger_discharge_on_ac(0);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
int charger_discharge_on_ac(int enable)
|
||||
@@ -472,28 +501,27 @@ static int console_command_bd99955(int argc, char **argv)
|
||||
char rw, *e;
|
||||
enum bd99955_command cmd;
|
||||
|
||||
rw = argv[1][0];
|
||||
if (rw == 'r') {
|
||||
if (argc < 4)
|
||||
return EC_ERROR_PARAM_COUNT;
|
||||
} else if (rw == 'w') {
|
||||
if (argc < 5)
|
||||
return EC_ERROR_PARAM_COUNT;
|
||||
} else
|
||||
if (argc < 4)
|
||||
return EC_ERROR_PARAM_COUNT;
|
||||
|
||||
rw = argv[1][0];
|
||||
if (rw == 'w' && argc < 5)
|
||||
return EC_ERROR_PARAM_COUNT;
|
||||
else if (rw != 'w' && rw != 'r')
|
||||
return EC_ERROR_PARAM1;
|
||||
|
||||
reg = strtoi(argv[2], &e, 16);
|
||||
if (*e || reg < 0)
|
||||
return EC_ERROR_PARAM2;
|
||||
|
||||
cmd = strtoi(argv[3], &e, 0);
|
||||
if (*e || cmd < 0)
|
||||
return EC_ERROR_INVAL;
|
||||
return EC_ERROR_PARAM3;
|
||||
|
||||
if (argc == 5) {
|
||||
val = strtoi(argv[4], &e, 16);
|
||||
if (*e || val < 0)
|
||||
return EC_ERROR_INVAL;
|
||||
return EC_ERROR_PARAM4;
|
||||
}
|
||||
|
||||
if (rw == 'r')
|
||||
|
||||
@@ -80,6 +80,8 @@ enum bd99955_charge_port {
|
||||
#define BD99955_CMD_VIN_CTRL_SET_VCC_EN (1 << 5)
|
||||
|
||||
#define BD99955_CMD_CHGOP_SET1 0x0B
|
||||
#define BD99955_CMD_CHGOP_SET1_VCC_BC_DISEN (1 << 11)
|
||||
#define BD99955_CMD_CHGOP_SET1_VBUS_BC_DISEN (1 << 10)
|
||||
#define BD99955_CMD_CHGOP_SET2 0x0C
|
||||
#define BD99955_CMD_CHGOP_SET2_BATT_LEARN (1 << 8)
|
||||
#define BD99955_CMD_CHGOP_SET2_CHG_EN (1 << 7)
|
||||
@@ -118,6 +120,9 @@ enum bd99955_charge_port {
|
||||
#define BD99955_CMD_PMON_DACIN_VAL 0x26
|
||||
#define BD99955_CMD_IOUT_DACIN_VAL 0x27
|
||||
#define BD99955_CMD_VCC_UCD_SET 0x28
|
||||
/* Bits for both VCC_UDC_SET and VBUS_UCD_SET regs */
|
||||
#define BD99955_CMD_UCD_SET_BCSRETRY (1 << 12)
|
||||
#define BD99955_CMD_UCD_SET_USBDETEN (1 << 7)
|
||||
#define BD99955_CMD_VCC_UCD_STATUS 0x29
|
||||
#define BD99955_CMD_VCC_IDD_STATUS 0x2A
|
||||
#define BD99955_CMD_VCC_UCD_FCTRL_SET 0x2B
|
||||
|
||||
Reference in New Issue
Block a user