summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSue Chen <sue.chen@quanta.corp-partner.google.com>2021-11-01 15:11:03 +0800
committerCommit Bot <commit-bot@chromium.org>2021-12-11 02:17:57 +0000
commitf9977e0929a99edc583109693fd2aa0d404cc8ec (patch)
treeede6844f29f2df75869b84edff14b8fa58b410a5
parent4c9dd75d74844ea1ba31c97ef146ec4875826209 (diff)
downloadchrome-ec-f9977e0929a99edc583109693fd2aa0d404cc8ec.tar.gz
quackingstick: support thermal charge policy
The charging limitation: While the DUT is enter OS, sample temperature as charger task Level | low T'C | high T'C | current | (Tsens > T) | (Tsens < T) | (mA) ------------------------------------------------ 0 | 0 | 50 | 3000 (Normal charge) 1 | 48 | 53 | 1500 2 | 51 | 56 | 1000 3 | 54 | 100 | 800 BUG=b:196997371 BRANCH=trogdor TEST=use console cmd chgstate to check requested_current is as expected. Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Change-Id: I1665f65d952cfd6bd292188b573997100384278f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3255091 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Bob Moragues <moragues@chromium.org>
-rw-r--r--board/quackingstick/usbc_config.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/board/quackingstick/usbc_config.c b/board/quackingstick/usbc_config.c
index 8f3fb02c30..b41eb2ecf1 100644
--- a/board/quackingstick/usbc_config.c
+++ b/board/quackingstick/usbc_config.c
@@ -8,7 +8,9 @@
#include "charger.h"
#include "charger/isl923x_public.h"
#include "charge_state.h"
+#include "temp_sensor.h"
#include "usb_pd.h"
+#include "util.h"
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
@@ -21,14 +23,50 @@ const struct charger_config_t chg_chips[] = {
},
};
+struct temp_chg_step {
+ int low; /* temp thershold ('C) to lower level*/
+ int high; /* temp thershold ('C) to higher level */
+ int current; /* charging limitation (mA) */
+};
+
+static const struct temp_chg_step temp_chg_table[] = {
+ {.low = 0, .high = 50, .current = 3000}, /* Lv0: normal charge */
+ {.low = 48, .high = 53, .current = 1500},
+ {.low = 51, .high = 56, .current = 1000},
+ {.low = 54, .high = 100, .current = 800},
+};
+#define NUM_TEMP_CHG_LEVELS ARRAY_SIZE(temp_chg_table)
+
int charger_profile_override(struct charge_state_data *curr)
{
+ static int current_level;
+ int charger_temp, charger_temp_c;
int usb_mv;
int port;
if (curr->state != ST_CHARGE)
return 0;
+ /* charge current control depends on temp if the system is on */
+ if (chipset_in_state(CHIPSET_STATE_ON)) {
+ temp_sensor_read(TEMP_SENSOR_SYS2, &charger_temp);
+ charger_temp_c = K_TO_C(charger_temp);
+
+ if (charger_temp_c <= temp_chg_table[current_level].low)
+ current_level--;
+ else if (charger_temp_c >= temp_chg_table[current_level].high)
+ current_level++;
+
+ if (current_level < 0)
+ current_level = 0;
+
+ if (current_level >= NUM_TEMP_CHG_LEVELS)
+ current_level = NUM_TEMP_CHG_LEVELS - 1;
+
+ curr->requested_current = MIN(curr->requested_current,
+ temp_chg_table[current_level].current);
+ }
+
/* Lower the max requested voltage to 5V when battery is full. */
if (chipset_in_state(CHIPSET_STATE_ANY_OFF) &&
!(curr->batt.flags & BATT_FLAG_BAD_STATUS) &&