summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-09-17 18:25:33 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-05 12:09:41 +0000
commitaf43e1d434c0335b18f05878dc568cf1a3dcb5b0 (patch)
tree1079c2426afd68fd054e7f9d871ef14a679e49d9 /board
parentc7f698412abf87988d8b18ecc455a6f2ea061da1 (diff)
downloadchrome-ec-af43e1d434c0335b18f05878dc568cf1a3dcb5b0.tar.gz
CHERRY-PICK: nocturne: Enable CONFIG_CHARGER_PROFILE_OVERRIDE.
We need to stop charging the battery when the DRAM temperature exceeds 47 C. This commit uses charge_profile_override() to start discharging the pack when this happens and resume charging when the temperature cools down. BUG=b:115924459, b:112550414 BRANCH=firmware-nocturne-10984.B TEST=Cool device down, verify that once temp sensor crosses threshold, charging is stopped. TEST=Verify charging is resumed when device shuts down. TEST=Verify charging is resumed when device cools down. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1231476 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Change-Id: I5feb132ec915894b7c391ffdf49a3f150912f554 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2157061 Tested-by: Patryk Duda <pdk@semihalf.com> Commit-Queue: Patryk Duda <pdk@semihalf.com>
Diffstat (limited to 'board')
-rw-r--r--board/nocturne/battery.c60
-rw-r--r--board/nocturne/board.h1
2 files changed, 61 insertions, 0 deletions
diff --git a/board/nocturne/battery.c b/board/nocturne/battery.c
index 3db5fede33..67c5346063 100644
--- a/board/nocturne/battery.c
+++ b/board/nocturne/battery.c
@@ -8,17 +8,26 @@
#include "battery.h"
#include "battery_smart.h"
#include "charge_manager.h"
+#include "charger.h"
#include "chipset.h"
+#include "charge_state_v2.h"
#include "common.h"
#include "console.h"
#include "ec_commands.h"
#include "extpower.h"
#include "hooks.h"
+#include "temp_sensor.h"
#include "usb_pd.h"
/* Shutdown mode parameter to write to manufacturer access register */
#define SB_SHUTDOWN_DATA 0x0010
+/*
+ * We need to stop charging the battery when the DRAM temperature sensor gets
+ * over 47 C (320 K), and resume charging once it cools back down.
+ */
+#define DRAM_STOPCHARGE_TEMP_K 320
+
/* Battery info */
static const struct battery_info info = {
.voltage_max = 8880,
@@ -115,3 +124,54 @@ static void reduce_input_voltage_when_full(void)
}
}
DECLARE_HOOK(HOOK_SECOND, reduce_input_voltage_when_full, HOOK_PRIO_DEFAULT);
+
+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;
+}
+
+static int should_stopcharge(void)
+{
+ int t_dram;
+
+ /* We can only stop charging on AC, if AC is plugged in. */
+ if (!gpio_get_level(GPIO_AC_PRESENT))
+ return 0;
+
+ /*
+ * The DRAM temperature sensor is only available when the AP is on,
+ * therefore only inhibit charging when we can actually read a
+ * temperature.
+ */
+ if (chipset_in_state(CHIPSET_STATE_ON) &&
+ !temp_sensor_read(TEMP_SENSOR_DRAM, &t_dram) &&
+ (t_dram >= DRAM_STOPCHARGE_TEMP_K))
+ return 1;
+ else
+ return 0;
+}
+
+int charger_profile_override(struct charge_state_data *curr)
+{
+ static uint8_t stopcharge_on_ac;
+ int enable_stopcharge;
+
+ enable_stopcharge = should_stopcharge();
+ if (enable_stopcharge != stopcharge_on_ac) {
+ stopcharge_on_ac = enable_stopcharge;
+ if (enable_stopcharge) {
+ chgstate_set_manual_current(0);
+ } else {
+ chgstate_set_manual_current(-1);
+ }
+ }
+
+ return 0;
+}
diff --git a/board/nocturne/board.h b/board/nocturne/board.h
index 82d511ed01..868dde09ad 100644
--- a/board/nocturne/board.h
+++ b/board/nocturne/board.h
@@ -71,6 +71,7 @@
#define CONFIG_CHARGER_INPUT_CURRENT 128
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
+#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
#define CONFIG_EXTPOWER_GPIO