summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2014-04-18 12:59:57 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-22 20:27:01 +0000
commit67698db7da22449314dc5c0b3f468674afe77092 (patch)
treed3c1addf6812a047eb89983884880c8b09abb547
parent4b530d9fce5f939e4470adc6fcb7e5ee833c509d (diff)
downloadchrome-ec-67698db7da22449314dc5c0b3f468674afe77092.tar.gz
nyan: add info_precharge for drained battery
Charger v2 assumes the battery_get_info() always returns non-NULL even if the battery is not detected, for example, in the over-drained situation. Thus, add a new struct so that we know what the conservative setting is to pre-charge the unknown battery. BUG=chrome-os-partner:28112 BRANCH=nyan,big,blaze TEST=See issue tracker for the test procedure. Change-Id: Ica4fe75d154e2f195eb1da19ba045346da383b6c Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/195596 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Devin Lu <Devin.Lu@quantatw.com> Tested-by: Devin Lu <Devin.Lu@quantatw.com>
-rw-r--r--board/big/battery.c33
-rw-r--r--board/blaze/battery.c34
-rw-r--r--board/nyan/battery.c43
-rw-r--r--common/charge_state_v2.c12
4 files changed, 107 insertions, 15 deletions
diff --git a/board/big/battery.c b/board/big/battery.c
index 1dacf4ec8b..1ac9991bef 100644
--- a/board/big/battery.c
+++ b/board/big/battery.c
@@ -30,6 +30,29 @@ struct battery_device {
int support_cut_off;
};
+/*
+ * Used for the case that battery cannot be detected, such as the pre-charge
+ * case. In this case, we need to provide the battery with the enough voltage
+ * (usually the highest voltage among batteries, but the smallest precharge
+ * current). This should be as conservative as possible.
+ */
+static struct battery_info info_precharge = {
+
+ .voltage_max = 12900, /* the max voltage among batteries */
+ .voltage_normal = 11400,
+ .voltage_min = 9000,
+
+ /* Pre-charge values. */
+ .precharge_current = 256, /* mA, the min current among batteries */
+
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 50,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = 0,
+ .discharging_max_c = 75,
+};
+
static struct battery_info info_2s = {
/*
* Design voltage
@@ -252,16 +275,16 @@ const struct battery_info *battery_get_info(void)
if (battery_manufacturer_name(manuf, sizeof(manuf))) {
CPRINTF("[%T Failed to get MANUF name]\n");
- return NULL;
+ return &info_precharge;
}
if (battery_device_name(device, sizeof(device))) {
CPRINTF("[%T Failed to get DEVICE name]\n");
- return NULL;
+ return &info_precharge;
}
if (battery_design_voltage((int *)&design_mv)) {
CPRINTF("[%T Failed to get DESIGN_VOLTAGE]\n");
- return NULL;
+ return &info_precharge;
}
for (i = 0; i < ARRAY_SIZE(support_batteries); ++i) {
@@ -276,7 +299,9 @@ const struct battery_info *battery_get_info(void)
}
}
- return NULL;
+ CPRINTF("[%T un-recognized battery Manuf:%s, Device:%s]\n",
+ manuf, device);
+ return &info_precharge;
}
int battery_command_cut_off(struct host_cmd_handler_args *args)
diff --git a/board/blaze/battery.c b/board/blaze/battery.c
index 569822a88a..7701aed74e 100644
--- a/board/blaze/battery.c
+++ b/board/blaze/battery.c
@@ -29,6 +29,30 @@ struct battery_device {
int support_cut_off;
};
+/*
+ * Used for the case that battery cannot be detected, such as the pre-charge
+ * case. In this case, we need to provide the battery with the enough voltage
+ * (usually the highest voltage among batteries, but the smallest precharge
+ * current). This should be as conservative as possible.
+ */
+static struct battery_info info_precharge = {
+
+ .voltage_max = 13050, /* the max voltage among batteries */
+ .voltage_normal = 11400,
+ .voltage_min = 9000,
+
+ /* Pre-charge values. */
+ .precharge_current = 392, /* mA, the min current among batteries */
+
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 60,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = 0,
+ .discharging_max_c = 60,
+};
+
+
static struct battery_info info_3s = {
.voltage_max = 13050,
@@ -176,16 +200,16 @@ const struct battery_info *battery_get_info(void)
if (battery_manufacturer_name(manuf, sizeof(manuf))) {
CPRINTF("[%T Failed to get MANUF name]\n");
- return NULL;
+ return &info_precharge;
}
if (battery_device_name(device, sizeof(device))) {
CPRINTF("[%T Failed to get DEVICE name]\n");
- return NULL;
+ return &info_precharge;
}
if (battery_design_voltage((int *)&design_mv)) {
CPRINTF("[%T Failed to get DESIGN_VOLTAGE]\n");
- return NULL;
+ return &info_precharge;
}
for (i = 0; i < ARRAY_SIZE(support_batteries); ++i) {
@@ -200,7 +224,9 @@ const struct battery_info *battery_get_info(void)
}
}
- return NULL;
+ CPRINTF("[%T un-recognized battery Manuf:%s, Device:%s]\n",
+ manuf, device);
+ return &info_precharge;
}
static int cutoff(void)
diff --git a/board/nyan/battery.c b/board/nyan/battery.c
index 6bd445fdf4..7ebfd594da 100644
--- a/board/nyan/battery.c
+++ b/board/nyan/battery.c
@@ -30,6 +30,39 @@ struct battery_device {
int support_cut_off;
};
+/*
+ * Used for the case that battery cannot be detected, such as the pre-charge
+ * case. In this case, we need to provide the battery with the enough voltage
+ * (usually the highest voltage among batteries, but the smallest precharge
+ * current). This should be as conservative as possible.
+ */
+static struct battery_info info_precharge = {
+ /*
+ * Design voltage
+ * max = 8.4V
+ * normal = 7.4V
+ * min = 6.0V
+ */
+ .voltage_max = 12600, /* the max voltage among batteries */
+ .voltage_normal = 11100,
+ .voltage_min = 9000,
+
+ /* Pre-charge current: I <= 0.01C */
+ .precharge_current = 64, /* mA, the min current among batteries */
+
+ /*
+ * Operational temperature range
+ * 0 <= T_charge <= 50 deg C
+ * -20 <= T_discharge <= 60 deg C
+ */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 50,
+ .charging_min_c = 0,
+ .charging_max_c = 50,
+ .discharging_min_c = 0,
+ .discharging_max_c = 60,
+};
+
static struct battery_info info_2s = {
/*
* Design voltage
@@ -204,16 +237,16 @@ const struct battery_info *battery_get_info(void)
if (battery_manufacturer_name(manuf, sizeof(manuf))) {
CPRINTF("[%T Failed to get MANUF name]\n");
- return NULL;
+ return &info_precharge;
}
if (battery_device_name(device, sizeof(device))) {
CPRINTF("[%T Failed to get DEVICE name]\n");
- return NULL;
+ return &info_precharge;
}
if (battery_design_voltage((int *)&design_mv)) {
CPRINTF("[%T Failed to get DESIGN_VOLTAGE]\n");
- return NULL;
+ return &info_precharge;
}
for (i = 0; i < ARRAY_SIZE(support_batteries); ++i) {
@@ -228,7 +261,9 @@ const struct battery_info *battery_get_info(void)
}
}
- return NULL;
+ CPRINTF("[%T un-recognized battery Manuf:%s, Device=%s]\n",
+ manuf, device);
+ return &info_precharge;
}
int battery_command_cut_off(struct host_cmd_handler_args *args)
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 25cde8eefc..a3f641d24a 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -284,12 +284,12 @@ static int charge_request(int voltage, int current)
CPRINTF("[%T %s(%dmV, %dmA)]\n", __func__, voltage, current);
- if (voltage > 0)
+ if (voltage >= 0)
r1 = charger_set_voltage(voltage);
if (r1 != EC_SUCCESS)
problem(PR_SET_VOLTAGE, r1);
- if (current > 0)
+ if (current >= 0)
r2 = charger_set_current(current);
if (r2 != EC_SUCCESS)
problem(PR_SET_CURRENT, r2);
@@ -538,8 +538,14 @@ void charger_task(void)
} else {
/* The battery is responding. Yay. Try to use it. */
if (curr.state == ST_PRECHARGE ||
- battery_seems_to_be_dead)
+ battery_seems_to_be_dead) {
ccprintf("[%T battery woke up]\n");
+
+ /* Update the battery-specific values */
+ batt_info = battery_get_info();
+ need_static = 1;
+ }
+
battery_seems_to_be_dead = 0;
curr.state = ST_CHARGE;
}