summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin Lu <Devin.Lu@quantatw.com>2021-12-03 17:26:01 +0800
committerCommit Bot <commit-bot@chromium.org>2022-01-12 06:23:47 +0000
commit7f78bbf28e9114423ed0b909df7f128014d905ec (patch)
treeb130895b3b389dc289dc3bfece39457895cbadc1
parentd0b23756668c0421831c70bd0850ef371f59c46c (diff)
downloadchrome-ec-7f78bbf28e9114423ed0b909df7f128014d905ec.tar.gz
redrix: Disable haptic pad LRA if battery is over current
This patch adds a protection method to turn off haptic pad LRA while battery overloading. Since the haptic pad LRA has around 20W while clicking. To prevent battery over current we are disabling the LRA temporarily. BUG=b:207459805 BRANCH=none TEST=Verify system is not brownout on heavy loading. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I5b82e8042e56a6f58241ff6cf629c4cf4d49c3c9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3353047 Reviewed-by: caveh jalali <caveh@chromium.org>
-rw-r--r--board/redrix/board.c28
-rw-r--r--board/redrix/board.h1
-rw-r--r--board/redrix/gpio.inc2
3 files changed, 30 insertions, 1 deletions
diff --git a/board/redrix/board.c b/board/redrix/board.c
index 3c0f48f2bd..5cf76b5447 100644
--- a/board/redrix/board.c
+++ b/board/redrix/board.c
@@ -6,6 +6,7 @@
#include "battery.h"
#include "button.h"
#include "charge_ramp.h"
+#include "charge_state.h"
#include "charger.h"
#include "common.h"
#include "compile_time_macros.h"
@@ -33,6 +34,9 @@
#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
+/* Battery discharging over-current limit is 8A */
+#define BATT_OC_LIMIT -8000
+
/* PCHG control */
#ifdef SECTION_IS_RW
extern struct pchg_drv ctn730_drv;
@@ -83,3 +87,27 @@ enum battery_present battery_hw_present(void)
/* The GPIO is low when the battery is physically present */
return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES;
}
+
+int charger_profile_override(struct charge_state_data *curr)
+{
+ /* Turn off haptic pad LRA if battery discharing current over 8A */
+ if (!(curr->batt.flags & BATT_FLAG_BAD_CURRENT) &&
+ curr->batt.current < BATT_OC_LIMIT)
+ gpio_set_level(GPIO_LRA_DIS_ODL, 0);
+ else
+ gpio_set_level(GPIO_LRA_DIS_ODL, 1);
+
+ 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/redrix/board.h b/board/redrix/board.h
index 8037a14d41..d1f0f34f72 100644
--- a/board/redrix/board.h
+++ b/board/redrix/board.h
@@ -196,6 +196,7 @@
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_PROFILE_OVERRIDE
/* Keyboard features */
#define CONFIG_KEYBOARD_FACTORY_TEST
diff --git a/board/redrix/gpio.inc b/board/redrix/gpio.inc
index a658ec5927..82dee549b0 100644
--- a/board/redrix/gpio.inc
+++ b/board/redrix/gpio.inc
@@ -82,7 +82,7 @@ GPIO(USB_C0_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW)
GPIO(USB_C1_TCPC_RST_ODL, PIN(A, 0), GPIO_ODR_LOW)
GPIO(VCCST_PWRGD_OD, PIN(A, 4), GPIO_ODR_LOW)
GPIO(PEN_RST_L, PIN(0, 2), GPIO_ODR_HIGH)
-GPIO(LRA_DIS_ODL, PIN(0, 4), GPIO_ODR_HIGH) /* Reserved for disable haptic pad LRA */
+GPIO(LRA_DIS_ODL, PIN(0, 4), GPIO_ODR_HIGH) /* Disable haptic pad LRA */
/* LED */
GPIO(C0_CHARGE_LED_AMBER_L, PIN(C, 4), GPIO_OUT_HIGH) /* Amber C0 port */