diff options
author | Tommy Chung <tommy.chung@quanta.corp-partner.google.com> | 2022-02-17 10:24:56 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-03-14 11:33:18 +0000 |
commit | ec41126f8a8030540612937b081c02feddac97f0 (patch) | |
tree | 39df2cac807801f14c79325138322911d016b054 /board/dojo | |
parent | c7c7d9aa13fde83d8dab0df618f3e47407b4a371 (diff) | |
download | chrome-ec-ec41126f8a8030540612937b081c02feddac97f0.tar.gz |
dojo: Control charging current with temperature charging table
Set a temperature charging table to control charging current to meet
thermal request.
BUG=b:219834480
BRANCH=cherry
TEST=make sure that charging current can be controlled by temperature
measured with thermistor according to the temperature charging table.
Signed-off-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com>
Change-Id: I6b31e5d9f06c60b1490d6ca6e5c74f970dac2173
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3468921
Reviewed-by: Devin Lu <Devin.Lu@quantatw.com>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'board/dojo')
-rw-r--r-- | board/dojo/battery.c | 45 | ||||
-rw-r--r-- | board/dojo/board.c | 20 | ||||
-rw-r--r-- | board/dojo/board.h | 21 |
3 files changed, 86 insertions, 0 deletions
diff --git a/board/dojo/battery.c b/board/dojo/battery.c index 7e9b30079b..12e6b6aba0 100644 --- a/board/dojo/battery.c +++ b/board/dojo/battery.c @@ -6,6 +6,10 @@ #include "battery.h" #include "battery_fuel_gauge.h" #include "battery_smart.h" +#include "charge_state.h" +#include "console.h" +#include "temp_sensor.h" +#include "util.h" const struct board_batt_params board_battery_info[] = { /* DynaPack CosMX Battery Information */ @@ -161,3 +165,44 @@ const struct board_batt_params board_battery_info[] = { BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_DYNAPACK_COS; + +int charger_profile_override(struct charge_state_data *curr) +{ + int chg_temp; + int prev_chg_lvl; + static int chg_lvl; + + if (chipset_in_state(CHIPSET_STATE_ON)) { + temp_sensor_read(TEMP_SENSOR_CHARGER, &chg_temp); + chg_temp = K_TO_C(chg_temp); + + prev_chg_lvl = chg_lvl; + if (chg_temp <= temp_chg_table[chg_lvl].lo_thre && + chg_lvl > 0) + chg_lvl--; + else if (chg_temp >= temp_chg_table[chg_lvl].hi_thre && + chg_lvl < CHG_LEVEL_COUNT - 1) + chg_lvl++; + + curr->requested_current = MIN(curr->requested_current, + temp_chg_table[chg_lvl].chg_curr); + + if(chg_lvl != prev_chg_lvl) + ccprints("Override chg curr to %dmA by chg LEVEL_%d", + curr->requested_current, chg_lvl); + } + + return 0; +} + +enum ec_status charger_profile_override_get_param(uint32_t param, + uint32_t *value) +{ + return EC_RES_INVALID_PARAM; +} + +enum ec_status charger_profile_override_set_param(uint32_t param, + uint32_t value) +{ + return EC_RES_INVALID_PARAM; +} diff --git a/board/dojo/board.c b/board/dojo/board.c index ae8e67b8f2..c3c57bd978 100644 --- a/board/dojo/board.c +++ b/board/dojo/board.c @@ -36,6 +36,26 @@ __override struct keyboard_scan_config keyscan_config = { }, }; +/* Temperature charging table */ +const struct temp_chg_struct temp_chg_table[] = { + [LEVEL_0] = { + .lo_thre = 0, + .hi_thre = 68, + .chg_curr = 3000, + }, + [LEVEL_1] = { + .lo_thre = 63, + .hi_thre = 74, + .chg_curr = 1500, + }, + [LEVEL_2] = { + .lo_thre = 69, + .hi_thre = 100, + .chg_curr = 500, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(temp_chg_table) == CHG_LEVEL_COUNT); + /* Sensor */ static struct mutex g_base_mutex; static struct mutex g_lid_mutex; diff --git a/board/dojo/board.h b/board/dojo/board.h index ad1a251d92..6e00e3c009 100644 --- a/board/dojo/board.h +++ b/board/dojo/board.h @@ -31,6 +31,9 @@ /* BC12 */ +/* Charger */ +#define CONFIG_CHARGER_PROFILE_OVERRIDE + /* PD / USB-C / PPC */ #undef CONFIG_USB_PD_DEBUG_LEVEL /* default to 1, configurable in ec console */ @@ -110,6 +113,24 @@ enum pwm_channel { PWM_CH_COUNT, }; +/* Temperature charging level */ +enum temp_chg_lvl { + LEVEL_0 = 0, + LEVEL_1, + LEVEL_2, + CHG_LEVEL_COUNT, +}; + +/* Temperature charging struct */ +struct temp_chg_struct { + int lo_thre; + int hi_thre; + int chg_curr; +}; + +/* Forward declaration of temperature charging table */ +extern const struct temp_chg_struct temp_chg_table[]; + int board_accel_force_mode_mask(void); #endif /* !__ASSEMBLER__ */ |