summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorLogan_Liao <Logan_Liao@compal.corp-partner.google.com>2023-03-13 09:23:49 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-15 01:51:38 +0000
commitb2c893485fc5017a4a440c4832e4a7fc17359af0 (patch)
tree94f3dba4e00f47a2faf9ce43822d0a4b3b594acf /driver
parentc49b07e12b1a69c7757b68b4000478418a3b321e (diff)
downloadchrome-ec-b2c893485fc5017a4a440c4832e4a7fc17359af0.tar.gz
frostflow: Modify charger frequence for power consumption.
To avoid charger enter CCM mode, modify isl9241 frequence to 600kHz from 1020kHz in S5. BUG=b:271704154 BRANCH=none TEST=power team test power consumption is lower than 1020kHz. Change-Id: I9906f2795582c2c8e4a63a674404c0e5a5dfbc96 Signed-off-by: Logan_Liao <Logan_Liao@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4333276 Reviewed-by: SamSP Liu <samsp_liu2@compal.corp-partner.google.com> Tested-by: Logan Liao <logan_liao@compal.corp-partner.google.com> Reviewed-by: Chao Gui <chaogui@google.com> Commit-Queue: Logan Liao <logan_liao@compal.corp-partner.google.com> Reviewed-by: Logan Liao <logan_liao@compal.corp-partner.google.com>
Diffstat (limited to 'driver')
-rw-r--r--driver/charger/isl9241.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/driver/charger/isl9241.c b/driver/charger/isl9241.c
index b419f1ccca..f1273fe43d 100644
--- a/driver/charger/isl9241.c
+++ b/driver/charger/isl9241.c
@@ -147,6 +147,53 @@ static enum ec_error_list isl9241_device_id(int chgnum, int *id)
return isl9241_read(chgnum, ISL9241_REG_DEVICE_ID, id);
}
+static enum ec_error_list isl9241_set_frequency(int chgnum, int freq_khz)
+{
+ int rv;
+ int reg;
+ int freq;
+
+ mutex_lock(&control1_mutex_isl9241);
+ rv = isl9241_read(chgnum, ISL9241_REG_CONTROL1, &reg);
+ if (rv) {
+ CPRINTS("Could not read CONTROL1. (rv=%d)", rv);
+ return rv;
+ }
+ /* 000 = 1420kHz */
+ /* 001 = 1180kHz */
+ /* 010 = 1020kHz */
+ /* 011 = 890kHz */
+ /* 100 = 808kHz */
+ /* 101 = 724kHz */
+ /* 110 = 656kHz */
+ /* 111 = 600kHz */
+ if (freq_khz >= 1300)
+ freq = ISL9241_CONTROL1_SWITCHING_FREQ_1420KHZ;
+ else if (freq_khz >= 1100)
+ freq = ISL9241_CONTROL1_SWITCHING_FREQ_1180KHZ;
+ else if (freq_khz >= 955)
+ freq = ISL9241_CONTROL1_SWITCHING_FREQ_1020KHZ;
+ else if (freq_khz >= 849)
+ freq = ISL9241_CONTROL1_SWITCHING_FREQ_890KHZ;
+ else if (freq_khz >= 766)
+ freq = ISL9241_CONTROL1_SWITCHING_FREQ_808KHZ;
+ else if (freq_khz >= 690)
+ freq = ISL9241_CONTROL1_SWITCHING_FREQ_724KHZ;
+ else if (freq_khz >= 678)
+ freq = ISL9241_CONTROL1_SWITCHING_FREQ_656KHZ;
+ else
+ freq = ISL9241_CONTROL1_SWITCHING_FREQ_600KHZ;
+
+ reg &= ~ISL9241_CONTROL1_SWITCHING_FREQ_MASK;
+ reg |= (freq << 7);
+ rv = isl9241_write(chgnum, ISL9241_REG_CONTROL1, reg);
+ if (rv)
+ return rv;
+
+ mutex_unlock(&control1_mutex_isl9241);
+ return EC_SUCCESS;
+}
+
static enum ec_error_list isl9241_get_option(int chgnum, int *option)
{
int rv;
@@ -1232,6 +1279,7 @@ const struct charger_drv isl9241_drv = {
.get_input_current_limit = &isl9241_get_input_current_limit,
.manufacturer_id = &isl9241_manufacturer_id,
.device_id = &isl9241_device_id,
+ .set_frequency = &isl9241_set_frequency,
.get_option = &isl9241_get_option,
.set_option = &isl9241_set_option,
#ifdef CONFIG_CHARGE_RAMP_HW