summaryrefslogtreecommitdiff
path: root/board/gumboz
diff options
context:
space:
mode:
authorZick Wei <zick.wei@quanta.corp-partner.google.com>2021-03-16 09:04:20 +0800
committerCommit Bot <commit-bot@chromium.org>2021-03-29 03:15:08 +0000
commita68f4691e240a46fed4b8b9f6977382036f93c7d (patch)
treee6c651e10246ea08d0922a417c8631a74f40b56f /board/gumboz
parentc5dbd10a02a907e7c2c0ada341feae7c0c741906 (diff)
downloadchrome-ec-a68f4691e240a46fed4b8b9f6977382036f93c7d.tar.gz
gumboz: add thermal protect parameter
This patch add thermal protect parameter for gumboz(same as dirinboz): All trigger/release by charger thermistor, Charging current 0.5A: Trigger > 58’C ; Release < 57’C CPU PROCHOT: Trigger > 63’C ; Release < 62’C Set USB-C0 port to 1.5A: Trigger > 63’C ; Release < 62’C BUG=b:181803301 BRANCH=zork TEST=verify EC behavior intended when trigger/ release thermal protection. Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: Ia2d840536b6e96474de293c7a014ae76816eb607 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2780818 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'board/gumboz')
-rw-r--r--board/gumboz/board.c100
-rw-r--r--board/gumboz/board.h2
2 files changed, 102 insertions, 0 deletions
diff --git a/board/gumboz/board.c b/board/gumboz/board.c
index 825b206500..60a8d9c9b3 100644
--- a/board/gumboz/board.c
+++ b/board/gumboz/board.c
@@ -6,6 +6,7 @@
#include "battery_smart.h"
#include "button.h"
#include "cros_board_info.h"
+#include "charge_state.h"
#include "driver/accel_kionix.h"
#include "driver/accelgyro_lsm6dsm.h"
#include "driver/bc12/pi3usb9201.h"
@@ -29,6 +30,8 @@
#include "system.h"
#include "tablet_mode.h"
#include "task.h"
+#include "temp_sensor.h"
+#include "thermal.h"
#include "usb_charge.h"
#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
@@ -538,3 +541,100 @@ const int keyboard_factory_scan_pins[][2] = {
const int keyboard_factory_scan_pins_used =
ARRAY_SIZE(keyboard_factory_scan_pins);
#endif
+
+#define CHARGING_CURRENT_500MA 500
+
+int charger_profile_override(struct charge_state_data *curr)
+{
+ int rv;
+ static int thermal_sensor_temp;
+ static int prev_thermal_sensor_temp;
+ static int limit_charge;
+ static int limit_usbc_power;
+ static int limit_usbc_power_backup;
+ enum tcpc_rp_value rp;
+
+ rv = temp_sensor_read(TEMP_SENSOR_CHARGER, &thermal_sensor_temp);
+
+ if (rv != EC_SUCCESS)
+ return 0;
+
+ if (thermal_sensor_temp > prev_thermal_sensor_temp) {
+ if (thermal_sensor_temp > C_TO_K(63))
+ limit_usbc_power = 1;
+
+ else if (thermal_sensor_temp > C_TO_K(58)) {
+ if (curr->state == ST_CHARGE)
+ limit_charge = 1;
+ }
+ } else if (thermal_sensor_temp < prev_thermal_sensor_temp) {
+ if (thermal_sensor_temp < C_TO_K(57)) {
+ if (curr->state == ST_CHARGE)
+ limit_charge = 0;
+
+ } else if (thermal_sensor_temp < C_TO_K(62))
+ limit_usbc_power = 0;
+ }
+
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ return 0;
+
+ curr->requested_current = (limit_charge) ? CHARGING_CURRENT_500MA
+ : curr->batt.desired_current;
+
+ if (limit_usbc_power != limit_usbc_power_backup) {
+ rp = (limit_usbc_power) ? TYPEC_RP_1A5
+ : TYPEC_RP_3A0;
+
+ ppc_set_vbus_source_current_limit(0, rp);
+ tcpm_select_rp_value(0, rp);
+ pd_update_contract(0);
+ limit_usbc_power_backup = limit_usbc_power;
+ }
+
+ prev_thermal_sensor_temp = thermal_sensor_temp;
+
+ 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;
+}
+
+__override struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT] = {
+ [TEMP_SENSOR_CHARGER] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(63),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(92),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(62),
+ }
+ },
+ [TEMP_SENSOR_SOC] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(85),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(77),
+ }
+ },
+ [TEMP_SENSOR_CPU] = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(85),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(90),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(83),
+ }
+ },
+};
diff --git a/board/gumboz/board.h b/board/gumboz/board.h
index 73b8b741fe..004c4e60fe 100644
--- a/board/gumboz/board.h
+++ b/board/gumboz/board.h
@@ -23,6 +23,8 @@
#define CONFIG_USB_PD_PORT_MAX_COUNT 2
#define CONFIG_USB_PORT_ENABLE_DYNAMIC
+#define CONFIG_CHARGER_PROFILE_OVERRIDE
+
#define CONFIG_KEYBOARD_FACTORY_TEST
/* USB-A config */