summaryrefslogtreecommitdiff
path: root/board/sasukette
diff options
context:
space:
mode:
authorMike Lee <mike5@huaqin.corp-partner.google.com>2021-05-10 20:16:24 +0800
committerCommit Bot <commit-bot@chromium.org>2021-06-23 08:35:57 +0000
commit610c6877bbbe5a0b0c7f3625102413f833fa6e39 (patch)
tree8825f988a64cb372ccdad051f6c4ca46c9360a7b /board/sasukette
parent1f3acc718c874f207fae4a4f97e88802288ca430 (diff)
downloadchrome-ec-610c6877bbbe5a0b0c7f3625102413f833fa6e39.tar.gz
Sasukette: add battery swelling function
According to OEM request, add battery swelling function. 1. modify voltage_max 8800mV according to battery spec 2. modify charging_max_c = 50 according to swelling request 3. add battery swelling function BUG=b:187441287 BRANCH=dedede TEST=make -j BOARD=sasukette TEST=test department test swelling function pass Signed-off-by: Mike Lee <mike5@huaqin.corp-partner.google.com> Change-Id: Ie6dedff3df071e5abbece4a00133f1c5663acbf1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2883379 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/sasukette')
-rw-r--r--board/sasukette/battery.c177
-rw-r--r--board/sasukette/board.h1
2 files changed, 175 insertions, 3 deletions
diff --git a/board/sasukette/battery.c b/board/sasukette/battery.c
index 9e85906b9b..10d4187c15 100644
--- a/board/sasukette/battery.c
+++ b/board/sasukette/battery.c
@@ -51,14 +51,14 @@ const struct board_batt_params board_battery_info[] = {
}
},
.batt_info = {
- .voltage_max = 8860,
+ .voltage_max = 8800,
.voltage_normal = 7700, /* mV */
.voltage_min = 6000, /* mV */
.precharge_current = 200, /* mA */
.start_charging_min_c = 0,
.start_charging_max_c = 45,
.charging_min_c = 0,
- .charging_max_c = 60,
+ .charging_max_c = 50,
.discharging_min_c = -20,
.discharging_max_c = 70,
},
@@ -68,9 +68,180 @@ BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_SDI;
+static int swelling_flag = -1;
+static int prev_ac = -1;
+static int charger_flag = -1;
+
+enum swelling_data {
+ SWELLING_TRIGGER_5 = 1,
+ SWELLING_TRIGGER_15,
+ SWELLING_TRIGGER_45,
+ SWELLING_TRIGGER_50,
+ SWELLING_RECOVERY_10,
+ SWELLING_RECOVERY_20,
+ SWELLING_RECOVERY_50,
+ SWELLING_DATA_COUNT
+};
+
int charger_profile_override(struct charge_state_data *curr)
{
- curr->requested_voltage += 100;
+ static timestamp_t chargeCnt;
+ int bat_temp_c = (curr->batt.temperature - 2731) / 10;
+
+ /*
+ * start charge temp control
+ *
+ * if bat_temp >= 45 or bat_temp <= 0 when adapter plugging in,
+ * stop charge
+ * if 0 < bat_temp < 45 when adapter plugging in, charge normal
+ */
+ if (curr->ac != prev_ac) {
+ if (curr->ac) {
+ if ((bat_temp_c <= 0) || (bat_temp_c >= 45))
+ charger_flag = 1;
+ }
+ prev_ac = curr->ac;
+ }
+
+ if (charger_flag) {
+ curr->requested_current = 0;
+ curr->requested_voltage = 0;
+ curr->batt.flags &= ~BATT_FLAG_WANT_CHARGE;
+ curr->state = ST_IDLE;
+ }
+
+ if ((bat_temp_c > 0) && (bat_temp_c < 45))
+ charger_flag = 0;
+
+/*
+ * battery swelling control
+ *
+ * trigger condition | recovery condition
+ * 1. bat_temp < 5 && | 1.batt_temp >= 10
+ * bat_cell_voltage < 4.15 |
+ * | cv = (cell CV-50mv)*series
+ * cv = 4150mv*series = 8300mv | = 8700mv
+ * cc = FCC*C_rate*0.4 | cc = FCC*C_rate*0.4 = 1464ma
+ * |
+ * 2. bat_temp < 15 && | 2.batt_temp >= 20,
+ * bat_cell_voltage < 4.15 |
+ * | cv = (cell CV-50mv)*series
+ * cv = 4150mv*series = 8300mv | = 8700mv
+ * cc = FCC*C_rate*0.4= 1464ma | cc = FCC*C_rate*0.9 = 3294ma
+ * |
+ * 3. bat_temp >= 45 && | 3. batt_temp < 43
+ * bat_cell_voltage < 4.15 |
+ * | cv = (cell CV-50mv)*series
+ * cv = 4150mv*series = 8300mv | = 8700mv
+ * cc = FCC*C_rate*0.45= 1647ma | cc = FCC*C_rate*0.9 = 3294ma
+ * |
+ * 4. bat_temp >= 50 | 4.batt_temp < 45,
+ * stop charge | recovery charge
+ */
+ if (curr->ac && !charger_flag) {
+
+ /*
+ * battery swelling trigger condition
+ */
+ if (curr->batt.voltage < 8300) {
+ if (bat_temp_c < 5)
+ swelling_flag = SWELLING_TRIGGER_5;
+ else if (bat_temp_c < 15)
+ swelling_flag = SWELLING_TRIGGER_15;
+
+ if (bat_temp_c >= 50)
+ swelling_flag = SWELLING_TRIGGER_50;
+ else if (bat_temp_c >= 45) {
+ if (!(swelling_flag & SWELLING_TRIGGER_50))
+ swelling_flag = SWELLING_TRIGGER_45;
+ }
+ }
+
+ /*
+ * battery swelling recovery condition
+ */
+ if (swelling_flag) {
+ if ((bat_temp_c >= 10) && (bat_temp_c < 20))
+ swelling_flag = SWELLING_RECOVERY_10;
+ else if ((bat_temp_c >= 20) && (bat_temp_c < 43))
+ swelling_flag = SWELLING_RECOVERY_20;
+ else if ((bat_temp_c >= 43) && (bat_temp_c < 45))
+ swelling_flag = SWELLING_RECOVERY_50;
+ }
+
+ switch (swelling_flag) {
+ case SWELLING_TRIGGER_5:
+ curr->requested_voltage = 4150 * 2;
+ curr->requested_current = 5230 * 0.7 * 0.4;
+
+ if ((curr->batt.current < 300)) {
+ if (chargeCnt.val == 0) {
+ chargeCnt.val = get_time().val
+ + 30 * SECOND;
+ } else if (timestamp_expired(chargeCnt, NULL)) {
+ curr->requested_current = 0;
+ curr->requested_voltage = 0;
+ curr->batt.flags &=
+ ~BATT_FLAG_WANT_CHARGE;
+ curr->state = ST_IDLE;
+ }
+ } else {
+ chargeCnt.val = 0;
+ }
+ break;
+
+ case SWELLING_TRIGGER_15:
+ curr->requested_current = 5230 * 0.7 * 0.4;
+ chargeCnt.val = 0;
+ break;
+
+ case SWELLING_TRIGGER_45:
+ curr->requested_voltage = 4150 * 2;
+ curr->requested_current = 5230 * 0.7 * 0.45;
+
+ if ((curr->batt.current < 300)) {
+ if (chargeCnt.val == 0) {
+ chargeCnt.val = get_time().val
+ + 30 * SECOND;
+ } else if (timestamp_expired(chargeCnt, NULL)) {
+ curr->requested_current = 0;
+ curr->requested_voltage = 0;
+ curr->batt.flags &=
+ ~BATT_FLAG_WANT_CHARGE;
+ curr->state = ST_IDLE;
+ }
+ } else {
+ chargeCnt.val = 0;
+ }
+ break;
+
+ case SWELLING_TRIGGER_50:
+ curr->requested_current = 0;
+ curr->requested_voltage = 0;
+ curr->batt.flags &= ~BATT_FLAG_WANT_CHARGE;
+ curr->state = ST_IDLE;
+ chargeCnt.val = 0;
+ break;
+
+ case SWELLING_RECOVERY_10:
+ curr->requested_current = 5230 * 0.7 * 0.4;
+ chargeCnt.val = 0;
+ break;
+
+ case SWELLING_RECOVERY_20:
+ case SWELLING_RECOVERY_50:
+ curr->requested_current = 5230 * 0.7 * 0.9;
+ chargeCnt.val = 0;
+ break;
+
+ default:
+ curr->requested_voltage += 100;
+ break;
+ }
+ } else {
+ swelling_flag = 0;
+ chargeCnt.val = 0;
+ }
return 0;
}
diff --git a/board/sasukette/board.h b/board/sasukette/board.h
index 6cc0d0009b..8c57fa9528 100644
--- a/board/sasukette/board.h
+++ b/board/sasukette/board.h
@@ -22,6 +22,7 @@
/* Battery */
#define CONFIG_BATTERY_FUEL_GAUGE
+#define CONFIG_BATTERY_CHECK_CHARGE_TEMP_LIMITS
/* BC 1.2 */
#define CONFIG_BC12_DETECT_PI3USB9201