summaryrefslogtreecommitdiff
path: root/common/lightbar.c
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-12-17 13:22:36 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-03 02:26:21 +0000
commit2b0895179733852a7eb13051ad99a494af5cc3bd (patch)
tree557338d88ec7a20212bc8c4f457d7867073513a5 /common/lightbar.c
parenta3f3e38da09eb196a5773021a54832a553c206e3 (diff)
downloadchrome-ec-2b0895179733852a7eb13051ad99a494af5cc3bd.tar.gz
samus: when battery is full, and not in S0, stop charging
When battery is full and system is not in S0, then stop charging and allow battery to power the system. Once battery is no longer full and requests current, allow charging again. This is to work around power consumption issues in our AC input path. The charge override port is stored upon entering S3 and restored going back to S0 so that the charge override port is not affected by this. This also fixes lightbar so lightbar checks if battery is full instead of checking raw percentage. The lightbar is also changed to use the last tap direction if no charger is plugged in. And the lightbar tap for battery threshold for turning green is lowered to 95%. This also moves some samus_pd board code out of interrupt handlers and in to deferred functions to minimize time in interrupts. BUG=chrome-os-partner:34640, chrome-os-partner:34847 BRANCH=samus TEST=load onto samus. use battfake command from pd console to set battery percentage. when system is in G3, see that batt = 100% stops charging, and when batt < 100% it starts charging again. tested that we receive host command from EC with battery information every time battery changes SOC. Change-Id: Ia8e0721508e34ee3630f5e5b0c2f431a00329caf Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/236411 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/lightbar.c')
-rw-r--r--common/lightbar.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/common/lightbar.c b/common/lightbar.c
index bc43a6080e..ab9bfa8985 100644
--- a/common/lightbar.c
+++ b/common/lightbar.c
@@ -80,7 +80,7 @@ static const struct lightbar_params_v1 default_params = {
.tap_display_time = 3 * SECOND, /* total sequence time */
.tap_pct_red = 10, /* below this is red */
- .tap_pct_green = 97, /* above this is green */
+ .tap_pct_green = 94, /* above this is green */
.tap_seg_min_on = 35, /* min intensity (%) for "on" */
.tap_seg_max_on = 100, /* max intensity (%) for "on" */
.tap_seg_osc = 50, /* amplitude for charging osc */
@@ -876,8 +876,9 @@ static uint32_t sequence_TAP_inner(int dir)
f_mult = f_mult * gate[i] / FP_SCALE;
- /* Pulse when charging */
- if (st.battery_is_charging) {
+ /* Pulse when charging and not yet full */
+ if (st.battery_is_charging &&
+ st.battery_percent <= st.p.tap_pct_green) {
int scale = (FP_SCALE -
f_osc * cycle_010(w++) / FP_SCALE);
f_mult = f_mult * scale / FP_SCALE;
@@ -906,6 +907,7 @@ static int force_dir = -1;
/* Return 0 (left or none) or 1 (right) */
static int get_tap_direction(void)
{
+ static int last_dir;
int dir = 0;
if (force_dir >= 0)
@@ -914,10 +916,13 @@ static int get_tap_direction(void)
else
pd_exchange_status(&dir);
#endif
- if (dir != 1)
+ if (dir < 0)
+ dir = last_dir;
+ else if (dir != 1)
dir = 0;
CPRINTS("LB tap direction %d", dir);
+ last_dir = dir;
return dir;
}