mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
ec_ec_comm_slave: Define extpower_is_present
On dual-battery slave, we use the charging allowed signal from
master to indicate whether external power is present.
In most cases, this actually matches the external power status
of the master (slave battery charging when AC is connected, or
discharging when slave battery still has enough capacity), with
one exception: when we do master to slave battery charging (in
this case the "external" power is the master).
BRANCH=none
BUG=b:65697962
TEST=Deplete wand battery to 5%, see that lux still provides power
to it but the battery does not charge.
Change-Id: I8bd9f52c386a0a9edfae3837ba33725b3101a008
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
6040852eb7
commit
7eacce9720
@@ -270,11 +270,3 @@ int board_write_serial(const char *serialno)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef BOARD_WAND
|
||||
/* TODO(b:66575472): This assumes external power is always present. */
|
||||
int extpower_is_present(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1071,6 +1071,14 @@ wait_for_it:
|
||||
curr.requested_voltage = charger_closest_voltage(
|
||||
curr.batt.voltage + info->voltage_step);
|
||||
curr.requested_current = -1;
|
||||
#endif
|
||||
#ifdef CONFIG_EC_EC_COMM_BATTERY_SLAVE
|
||||
/*
|
||||
* On EC-EC slave, do not charge if curr.ac is 0: there
|
||||
* might still be some external power available but we
|
||||
* do not want to use it for charging.
|
||||
*/
|
||||
curr.requested_current = 0;
|
||||
#endif
|
||||
}
|
||||
charge_request(curr.requested_voltage, curr.requested_current);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "crc8.h"
|
||||
#include "ec_commands.h"
|
||||
#include "ec_ec_comm_slave.h"
|
||||
#include "extpower.h"
|
||||
#include "hwtimer.h"
|
||||
#include "queue.h"
|
||||
#include "queue_policies.h"
|
||||
@@ -31,6 +32,9 @@
|
||||
struct ec_response_battery_static_info base_battery_static;
|
||||
struct ec_response_battery_dynamic_info base_battery_dynamic;
|
||||
|
||||
/* Set if the master allows the slave to charge the battery. */
|
||||
static int charging_allowed;
|
||||
|
||||
/*
|
||||
* Our command parameter buffer must be big enough to fit any command
|
||||
* parameter, and crc byte.
|
||||
@@ -140,6 +144,7 @@ static void handle_cmd_charger_control(
|
||||
charger_enable_otg_power(0);
|
||||
charge_set_input_current_limit(
|
||||
MIN(MAX_CURRENT_MA, params->max_current), 0);
|
||||
charging_allowed = params->allow_charging;
|
||||
} else {
|
||||
if (-params->max_current > MAX_OTG_CURRENT_MA ||
|
||||
params->otg_voltage > MAX_OTG_VOLTAGE_MV) {
|
||||
@@ -153,11 +158,26 @@ static void handle_cmd_charger_control(
|
||||
charger_set_otg_current_voltage(-params->max_current,
|
||||
params->otg_voltage);
|
||||
charger_enable_otg_power(1);
|
||||
charging_allowed = 0;
|
||||
}
|
||||
|
||||
out:
|
||||
write_response(ret, seq, NULL, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* On dual-battery slave, we use the charging allowed signal from master to
|
||||
* indicate whether external power is present.
|
||||
*
|
||||
* In most cases, this actually matches the external power status of the master
|
||||
* (slave battery charging when AC is connected, or discharging when slave
|
||||
* battery still has enough capacity), with one exception: when we do master to
|
||||
* slave battery charging (in this case the "external" power is the master).
|
||||
*/
|
||||
int extpower_is_present(void)
|
||||
{
|
||||
return charging_allowed;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ec_ec_comm_slave_task(void *u)
|
||||
|
||||
Reference in New Issue
Block a user