summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2023-04-07 15:28:13 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-12 23:07:17 +0000
commitd14883b6fd881ff821d88e670d1c4ead4479f983 (patch)
tree832567862b28cd178866997003d530883cfe0b7f
parent7bc2e12e1ee125bd124ef4de463cb2764e91e14c (diff)
downloadchrome-ec-d14883b6fd881ff821d88e670d1c4ead4479f983.tar.gz
RAA489110: Add RAA489110 driver
RAA489110 is an EPR capable version of ISL9241. BUG=b:277280318 BRANCH=None TEST=make BOARD=hades TEST=./twister --toolchain host -T zephyr/test/drivers -s drivers.isl9241 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I15eb1f652027f157ccb6b3a2d509531bef0c7c6c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4409986 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
-rw-r--r--driver/build.mk1
-rw-r--r--driver/charger/isl9241.c39
-rw-r--r--driver/charger/isl9241.h12
-rw-r--r--include/config.h13
-rw-r--r--include/driver/charger/isl9241_public.h4
-rw-r--r--zephyr/Kconfig.charger10
-rw-r--r--zephyr/shim/include/config_chip.h5
7 files changed, 63 insertions, 21 deletions
diff --git a/driver/build.mk b/driver/build.mk
index da10cf3cbe..ba8078b11e 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -76,6 +76,7 @@ driver-$(CONFIG_CHARGER_ISL9238C)+=charger/isl923x.o
driver-$(CONFIG_CHARGER_ISL9241)+=charger/isl9241.o
driver-$(CONFIG_CHARGER_MT6370)+=charger/rt946x.o
driver-$(CONFIG_CHARGER_RAA489000)+=charger/isl923x.o
+driver-$(CONFIG_CHARGER_RAA489110)+=charger/isl9241.o
driver-$(CONFIG_CHARGER_RT9466)+=charger/rt946x.o
driver-$(CONFIG_CHARGER_RT9467)+=charger/rt946x.o
driver-$(CONFIG_CHARGER_RT9490)+=charger/rt9490.o
diff --git a/driver/charger/isl9241.c b/driver/charger/isl9241.c
index 266150f2eb..2bb3d75f28 100644
--- a/driver/charger/isl9241.c
+++ b/driver/charger/isl9241.c
@@ -2,7 +2,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
- * Renesas (Intersil) ISL-9241 battery charger driver.
+ * Renesas (Intersil) ISL-9241 (and RAA489110) battery charger driver.
*/
/* TODO(b/175881324) */
@@ -474,9 +474,9 @@ int isl9241_set_ac_prochot(int chgnum, int ma)
uint16_t reg;
/*
- * The register reserves bits [6:0] and bits [15:13].
- * This routine should ensure these bits are not set
- * before writing the register.
+ * The register reserves bits [6:0] ([4:0] for rsa489110) and bits
+ * [15:13]. This routine should ensure these bits are not set before
+ * writing the register.
*/
if (ma > ISL9241_AC_PROCHOT_CURRENT_MAX)
reg = AC_CURRENT_TO_REG(ISL9241_AC_PROCHOT_CURRENT_MAX);
@@ -497,9 +497,9 @@ int isl9241_set_dc_prochot(int chgnum, int ma)
int rv;
/*
- * The register reserves bits [7:0] and bits [15:14].
- * This routine should ensure these bits are not set
- * before writing the register.
+ * The register reserves bits [7:0] ([5:0] for RAA489110) and bits
+ * [15:14]. This routine should ensure these bits are not set before
+ * writing the register.
*/
if (ma > ISL9241_DC_PROCHOT_CURRENT_MAX)
ma = ISL9241_DC_PROCHOT_CURRENT_MAX;
@@ -725,6 +725,19 @@ static bool isl9241_is_in_chrg(int chgnum)
return trickle_charge_enabled || fast_charge_enabled;
}
+static enum ec_error_list
+isl9241_update_force_buck_mode(int chgnum, enum mask_update_action action)
+{
+ if (IS_ENABLED(CONFIG_CHARGER_ISL9241))
+ return isl9241_update(chgnum, ISL9241_REG_CONTROL4,
+ ISL9241_CONTROL4_FORCE_BUCK_MODE, action);
+ else
+ /* CONFIG_CHARGER_RAA489110 */
+ return isl9241_update(chgnum, ISL9241_REG_CONTROL0,
+ RAA489110_CONTROL0_EN_FORCE_BUCK_MODE,
+ action);
+}
+
/*
* Transition from Bypass to BAT.
*/
@@ -736,8 +749,7 @@ static enum ec_error_list isl9241_bypass_to_bat(int chgnum)
mutex_lock(&control3_mutex_isl9241);
/* 1: Disable force forward buck/reverse boost. */
- isl9241_update(chgnum, ISL9241_REG_CONTROL4,
- ISL9241_CONTROL4_FORCE_BUCK_MODE, MASK_CLR);
+ isl9241_update_force_buck_mode(chgnum, MASK_CLR);
/*
* 2: Turn off BYPSG, turn on NGATE, disable charge pump 100%, disable
@@ -774,8 +786,7 @@ static enum ec_error_list isl9241_bypass_chrg_to_bat(int chgnum)
mutex_lock(&control3_mutex_isl9241);
/* 1: Disable force forward buck/reverse boost. */
- isl9241_update(chgnum, ISL9241_REG_CONTROL4,
- ISL9241_CONTROL4_FORCE_BUCK_MODE, MASK_CLR);
+ isl9241_update_force_buck_mode(chgnum, MASK_CLR);
/* 2: Disable fast charge. */
isl9241_write(chgnum, ISL9241_REG_CHG_CURRENT_LIMIT, 0);
/* 3: Disable trickle charge. */
@@ -915,8 +926,7 @@ static enum ec_error_list isl9241_nvdc_to_bypass(int chgnum)
/* 17: Read diode emulation active bit. */
/* 18: Disable 10mA discharge on CSOP. */
/* 19*: Force forward buck/reverse boost mode. */
- isl9241_update(chgnum, ISL9241_REG_CONTROL4,
- ISL9241_CONTROL4_FORCE_BUCK_MODE, MASK_SET);
+ isl9241_update_force_buck_mode(chgnum, MASK_SET);
if (!isl9241_is_ac_present(chgnum)) {
/*
@@ -972,8 +982,7 @@ static enum ec_error_list isl9241_bypass_to_nvdc(int chgnum)
/* 1*: Reduce system load below ACLIM. */
/* 3*: Disable force forward buck/reverse boost. */
- rv = isl9241_update(chgnum, ISL9241_REG_CONTROL4,
- ISL9241_CONTROL4_FORCE_BUCK_MODE, MASK_CLR);
+ rv = isl9241_update_force_buck_mode(chgnum, MASK_CLR);
if (rv)
return rv;
diff --git a/driver/charger/isl9241.h b/driver/charger/isl9241.h
index b068d48faa..4e766a9886 100644
--- a/driver/charger/isl9241.h
+++ b/driver/charger/isl9241.h
@@ -2,7 +2,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
- * Renesas (Intersil) ISL-9241 battery charger driver header.
+ * Renesas (Intersil) ISL-9241 (and RAA489110) battery charger driver header.
*/
#ifndef __CROS_EC_ISL9241_H
@@ -45,6 +45,7 @@
#define ISL9241_CONTROL0_INPUT_VTG_REGULATION BIT(2)
#define ISL9241_CONTROL0_EN_VIN_VOUT_COMP BIT(5)
#define ISL9241_CONTROL0_EN_CHARGE_PUMPS BIT(6)
+#define RAA489110_CONTROL0_EN_FORCE_BUCK_MODE BIT(10)
#define ISL9241_CONTROL0_EN_BYPASS_GATE BIT(11)
#define ISL9241_CONTROL0_NGATE_OFF BIT(12)
@@ -105,7 +106,11 @@
#define ISL9241_REG_OTG_VOLTAGE 0x49
#define ISL9241_REG_OTG_CURRENT 0x4A
+#ifdef CONFIG_CHARGER_RAA489110
+#define ISL9241_MV_TO_ACOK_REFERENCE(mv) (((mv) / 144) << 6)
+#else /* CONFIG_CHARGER_ISL9241 */
#define ISL9241_MV_TO_ACOK_REFERENCE(mv) (((mv) / 96) << 6)
+#endif
/* VIN Voltage (ADP Min Voltage) (default 4.096V) */
#define ISL9241_REG_VIN_VOLTAGE 0x4B
@@ -129,6 +134,7 @@
#define ISL9241_INFORMATION2_ACOK_PIN BIT(14)
#define ISL9241_REG_CONTROL4 0x4E
+/* ISL9241 only */
#define ISL9241_CONTROL4_FORCE_BUCK_MODE BIT(10)
/* 11: Rsense (Rs1:Rs2) ratio for PSYS (0 - 2:1, 1 - 1:1) */
#define ISL9241_CONTROL4_PSYS_RSENSE_RATIO BIT(11)
@@ -153,7 +159,11 @@
#define ISL9241_REG_DEVICE_ID 0xFF
#define ISL9241_VIN_ADC_BIT_OFFSET 6
+#ifdef CONFIG_CHARGER_RAA489110
+#define ISL9241_VIN_ADC_STEP_MV 144
+#else /* CONFIG_CHARGER_ISL9241 */
#define ISL9241_VIN_ADC_STEP_MV 96
+#endif
#define ISL9241_ADC_POLLING_TIME_US 400
diff --git a/include/config.h b/include/config.h
index 96c79a2d93..b0a809af7f 100644
--- a/include/config.h
+++ b/include/config.h
@@ -950,6 +950,7 @@
#undef CONFIG_CHARGER_ISL9241
#undef CONFIG_CHARGER_MT6370
#undef CONFIG_CHARGER_RAA489000
+#undef CONFIG_CHARGER_RAA489110
#undef CONFIG_CHARGER_RT9466
#undef CONFIG_CHARGER_RT9467
#undef CONFIG_CHARGER_RT9490
@@ -6308,10 +6309,11 @@
* Define CONFIG_USB_PD_VBUS_MEASURE_CHARGER if the charger on the board
* supports VBUS measurement.
*/
-#if defined(CONFIG_CHARGER_BD9995X) || defined(CONFIG_CHARGER_RT9466) || \
- defined(CONFIG_CHARGER_RT9467) || defined(CONFIG_CHARGER_RT9490) || \
- defined(CONFIG_CHARGER_MT6370) || defined(CONFIG_CHARGER_BQ25710) || \
- defined(CONFIG_CHARGER_BQ25720) || defined(CONFIG_CHARGER_ISL9241)
+#if defined(CONFIG_CHARGER_BD9995X) || defined(CONFIG_CHARGER_RT9466) || \
+ defined(CONFIG_CHARGER_RT9467) || defined(CONFIG_CHARGER_RT9490) || \
+ defined(CONFIG_CHARGER_MT6370) || defined(CONFIG_CHARGER_BQ25710) || \
+ defined(CONFIG_CHARGER_BQ25720) || defined(CONFIG_CHARGER_ISL9241) || \
+ defined(CONFIG_CHARGER_RAA489110)
#define CONFIG_USB_PD_VBUS_MEASURE_CHARGER
#ifdef CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
@@ -6353,7 +6355,8 @@
#if defined(CONFIG_CHARGER_ISL9237) || defined(CONFIG_CHARGER_ISL9238) || \
defined(CONFIG_CHARGER_ISL9238C) || defined(CONFIG_CHARGER_ISL9241) || \
defined(CONFIG_CHARGER_RAA489000) || defined(CONFIG_CHARGER_SM5803) || \
- defined(CONFIG_CHARGER_BQ25710) || defined(CONFIG_CHARGER_BQ25720)
+ defined(CONFIG_CHARGER_BQ25710) || defined(CONFIG_CHARGER_BQ25720) || \
+ defined(CONFIG_CHARGER_RAA489110)
#define CONFIG_CHARGER_NARROW_VDC
#endif
diff --git a/include/driver/charger/isl9241_public.h b/include/driver/charger/isl9241_public.h
index be586f39c3..cccce15bd7 100644
--- a/include/driver/charger/isl9241_public.h
+++ b/include/driver/charger/isl9241_public.h
@@ -33,7 +33,11 @@ int isl9241_set_ac_prochot(int chgnum, int ma);
*/
int isl9241_set_dc_prochot(int chgnum, int ma);
+#ifdef CONFIG_CHARGER_RAA489110
+#define ISL9241_AC_PROCHOT_CURRENT_MIN 32 /* mA */
+#else /* CONFIG_CHARGER_ISL9241 */
#define ISL9241_AC_PROCHOT_CURRENT_MIN 128 /* mA */
+#endif
#define ISL9241_AC_PROCHOT_CURRENT_MAX 6400 /* mA */
#define ISL9241_DC_PROCHOT_CURRENT_MIN 256 /* mA */
#define ISL9241_DC_PROCHOT_CURRENT_MAX 12800 /* mA */
diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger
index b340bd7da2..7c50f9fe31 100644
--- a/zephyr/Kconfig.charger
+++ b/zephyr/Kconfig.charger
@@ -137,6 +137,16 @@ config PLATFORM_EC_CHARGER_ISL9241
control. It supports an input voltage range of 3.9-23.4V and output
of 3.9-18.3V. It provides an I2C interface for configuration.
+config PLATFORM_EC_CHARGER_RAA489110
+ bool "Use the RAA489110 charger"
+ depends on PLATFORM_EC_I2C
+ # Hardware based charge ramp is broken in the ISL9241 (b/169350714)
+ # Probably also broken for RAA489110.
+ select PLATFORM_EC_CHARGER_CHGRAMP_BROKEN
+ help
+ Enables a driver for the RAA489110 VCD Battery Charger. This is a
+ EPR capable version of ISL9241.
+
if PLATFORM_EC_CHARGER_ISL9241
config PLATFORM_EC_ISL9241_SWITCHING_FREQ
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 567e42a715..0ea6bcd187 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -312,6 +312,11 @@
#define CONFIG_CHARGER_ISL9241
#endif
+#undef CONFIG_CHARGER_RAA489110
+#ifdef CONFIG_PLATFORM_EC_CHARGER_RAA489110
+#define CONFIG_CHARGER_RAA489110
+#endif
+
#undef CONFIG_OCPC
#ifdef CONFIG_PLATFORM_EC_OCPC
#define CONFIG_OCPC