summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2019-02-28 21:22:56 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-04-19 01:14:33 -0700
commit38a77e88cdc844f8b8bd9639f8163e3da92663fe (patch)
tree954226bf324a75e9e29391b0381bee9d26ffb9f6
parentaf6a8f4ef6f7f187dd536879a432451ca096f162 (diff)
downloadchrome-ec-38a77e88cdc844f8b8bd9639f8163e3da92663fe.tar.gz
atlas: enable discharge-on-ac
enable a mode where we will switch from AC power to battery power when the battery is fully charged. then, when the battery is no longer considred fully charged (95%), switch back to AC and chrage the battery. BUG=b:128709632 BRANCH=none TEST=observed atlas hovers between 95% and 100% battery charge. no AC current drawn while going from 100% to 95%. Change-Id: I6e22189fa5be43dc31a5c3b93fda70a4fe5958a1 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1496755 Commit-Ready: Caveh Jalali <caveh@google.com> Tested-by: caveh jalali <caveh@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/atlas/battery.c41
-rw-r--r--board/atlas/board.h2
2 files changed, 43 insertions, 0 deletions
diff --git a/board/atlas/battery.c b/board/atlas/battery.c
index 806f042a70..fb2fba18be 100644
--- a/board/atlas/battery.c
+++ b/board/atlas/battery.c
@@ -155,11 +155,52 @@ int board_cut_off_battery(void)
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;
+ if (curr->batt.flags & BATT_FLAG_BAD_STATUS)
+ 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;
+
+ 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;
+ 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;
+ }
if (curr->batt.flags & BATT_FLAG_BAD_TEMPERATURE)
return 0;
diff --git a/board/atlas/board.h b/board/atlas/board.h
index aa94013c9d..63f5e5be93 100644
--- a/board/atlas/board.h
+++ b/board/atlas/board.h
@@ -66,6 +66,7 @@
/* Battery */
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION"
+#define CONFIG_BATTERY_LEVEL_NEAR_FULL 95
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_BATTERY_PRESENT_CUSTOM
#define CONFIG_BATTERY_SMART
@@ -93,6 +94,7 @@
#define CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD 30
#define CONFIG_POWER_S0IX
#define CONFIG_POWER_TRACK_HOST_SLEEP_STATE
+#define CONFIG_PWR_STATE_DISCHARGE_FULL
/* LEDs */
#define CONFIG_LED_COMMON