summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2016-08-26 14:32:31 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-06 22:03:21 -0700
commit3392ad70d0d73788f1c24edbb08ddc30a93a0223 (patch)
treea52b5e1c0c6a663dc7be8e024bd0732bfb407392 /driver
parent107cb0df63efb527a470553b0a4e6f1f1ab17eb6 (diff)
downloadchrome-ec-3392ad70d0d73788f1c24edbb08ddc30a93a0223.tar.gz
Driver: BD99955: Enable trickle charging
Enabled the trickle charging mode by setting the VPRECHG_TH_SET register[0x18H] to board specific battery voltage minimum value. When the battery voltage drops below the battery voltage minimum value, trickle charging is enabled. BUG=chrome-os-partner:56684 BRANCH=none TEST=Manually verified on Reef. Drained the battery below battery voltage minimum value. On plugging in the charger, State Machine Status register CHGSTM_STATUS [0x00h] is 0x01 which indicates, current state of the charger state-machine is in Trickle-Charge condition. Change-Id: Ic4b985c71ff68ea4f5ab22e18feab03d776ec134 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/376939 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/charger/bd99955.c26
-rw-r--r--driver/charger/bd99955.h6
2 files changed, 20 insertions, 12 deletions
diff --git a/driver/charger/bd99955.c b/driver/charger/bd99955.c
index 68ebc0f77d..82457e732b 100644
--- a/driver/charger/bd99955.c
+++ b/driver/charger/bd99955.c
@@ -354,8 +354,7 @@ static void usb_charger_process(enum bd99955_charge_port port)
if (vbus_provided) {
/* Charger/sync attached */
bc12_detected_type[port] = bd99955_bc12_detect(port);
- } else if (bc12_detected_type[port] != CHARGE_SUPPLIER_NONE &&
- !vbus_provided) {
+ } else if (bc12_detected_type[port] != CHARGE_SUPPLIER_NONE) {
/* Charger/sync detached */
bd99955_bc12_detach(port, bc12_detected_type[port]);
bc12_detected_type[port] = CHARGE_SUPPLIER_NONE;
@@ -368,7 +367,7 @@ static int bd99955_set_vsysreg(int voltage)
/* VSYS Regulation voltage is in 64mV steps. */
voltage &= ~0x3F;
- return ch_raw_write16(BD99955_CMD_VSYSREG_SETa, voltage,
+ return ch_raw_write16(BD99955_CMD_VSYSREG_SET, voltage,
BD99955_EXTENDED_COMMAND);
}
@@ -528,13 +527,13 @@ int charger_set_mode(int mode)
int rv;
if (mode & CHARGE_FLAG_INHIBIT_CHARGE) {
- rv = bd99955_set_vsysreg(DISCHARGE_VSYSREG);
+ rv = bd99955_set_vsysreg(BD99955_DISCHARGE_VSYSREG);
msleep(50);
rv |= bd99955_charger_enable(0);
} else {
rv = bd99955_charger_enable(1);
msleep(1);
- rv |= bd99955_set_vsysreg(CHARGE_VSYSREG);
+ rv |= bd99955_set_vsysreg(BD99955_CHARGE_VSYSREG);
}
if (rv)
return rv;
@@ -684,6 +683,16 @@ static void bd99995_init(void)
/* Set charge termination current to 0 mA. */
ch_raw_write16(BD99955_CMD_ITERM_SET, 0,
BD99955_EXTENDED_COMMAND);
+
+ /* Set Pre-charge Voltage Threshold for trickle charging. */
+ ch_raw_write16(BD99955_CMD_VPRECHG_TH_SET,
+ bi->voltage_min & 0x7FC0,
+ BD99955_EXTENDED_COMMAND);
+
+ /* Trickle-charge Current Setting */
+ ch_raw_write16(BD99955_CMD_ITRICH_SET,
+ bi->precharge_current & 0x07C0,
+ BD99955_EXTENDED_COMMAND);
}
DECLARE_HOOK(HOOK_INIT, bd99995_init, HOOK_PRIO_INIT_EXTPOWER);
@@ -876,11 +885,10 @@ void usb_charger_task(void)
static int initialized;
int changed, port;
- for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++)
+ for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) {
bc12_detected_type[port] = CHARGE_SUPPLIER_NONE;
-
- bd99955_enable_vbus_detect_interrupts(BD99955_CHARGE_PORT_VBUS, 1);
- bd99955_enable_vbus_detect_interrupts(BD99955_CHARGE_PORT_VCC, 1);
+ bd99955_enable_vbus_detect_interrupts(port, 1);
+ }
while (1) {
changed = 0;
diff --git a/driver/charger/bd99955.h b/driver/charger/bd99955.h
index 41334ecb1c..2d67a8a389 100644
--- a/driver/charger/bd99955.h
+++ b/driver/charger/bd99955.h
@@ -43,8 +43,8 @@ enum bd99955_charge_port {
#define BD99955_NO_BATTERY_CHARGE_I_MIN 512
/* VSYSREG settings */
-#define DISCHARGE_VSYSREG 8960
-#define CHARGE_VSYSREG 6144
+#define BD99955_DISCHARGE_VSYSREG 8960
+#define BD99955_CHARGE_VSYSREG 6144
/*
* BC1.2 minimum voltage threshold.
@@ -112,7 +112,7 @@ enum bd99955_charge_port {
#define BD99955_CMD_VCCCLPS_TH_SET 0x0E
#define BD99955_CMD_CHGWDT_SET 0x0F
#define BD99955_CMD_BATTWDT_SET 0x10
-#define BD99955_CMD_VSYSREG_SETa 0x11
+#define BD99955_CMD_VSYSREG_SET 0x11
#define BD99955_CMD_VSYSVAL_THH_SET 0x12
#define BD99955_CMD_VSYSVAL_THL_SET 0x13
#define BD99955_CMD_ITRICH_SET 0x14