Files
OpenCellular/include/charge_manager.h
Alec Berg 2b08951797 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>
2015-01-03 02:26:21 +00:00

54 lines
1.5 KiB
C

/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef __CHARGE_MANAGER_H
#define __CHARGE_MANAGER_H
/* Charge port that indicates no active port */
#define CHARGE_SUPPLIER_NONE -1
#define CHARGE_PORT_NONE -1
#define CHARGE_CEIL_NONE -1
/* Initial charge state */
#define CHARGE_CURRENT_UNINITIALIZED -1
#define CHARGE_VOLTAGE_UNINITIALIZED -1
/* Charge tasks report available current and voltage */
struct charge_port_info {
int current;
int voltage;
};
/* Called by charging tasks to update their available charge */
void charge_manager_update(int supplier,
int charge_port,
struct charge_port_info *charge);
/* Update charge ceiling for a given port */
void charge_manager_set_ceil(int port, int ceil);
/* Select an 'override port', which is always the preferred charge port */
int charge_manager_set_override(int port);
int charge_manager_get_override(void);
/* Returns the current active charge port, as determined by charge manager */
int charge_manager_get_active_charge_port(void);
/* Board-level callback functions */
/*
* Set the active charge port. Returns EC_SUCCESS if the charge port is
* accepted, returns ec_error_list status otherwise.
*/
int board_set_active_charge_port(int charge_port);
/* Set the charge current limit. */
void board_set_charge_limit(int charge_ma);
/* Called on delayed override timeout */
void board_charge_manager_override_timeout(void);
#endif /* __CHARGE_MANAGER_H */