summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-12-14 11:59:49 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-17 22:53:31 +0000
commit53af9d188fb7e714623d4ebd4e78e83090c09e74 (patch)
treee32623bdf34488ae14f26991247004f0c6550d46
parentb5d83cde1dea30d19d3416f6c0e9ba703cffdbf9 (diff)
downloadchrome-ec-53af9d188fb7e714623d4ebd4e78e83090c09e74.tar.gz
zephyr: Enable isl9241 for Volteer
Add configs and build rules to enable this driver. A few issues are left to clean up later. BUG=b:175248556 BRANCH=none TEST=build for volteer Change-Id: If2c5427d016ae8cddcc25926668011aa11673091 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2589562 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--driver/charger/isl9241.c8
-rw-r--r--zephyr/CMakeLists.txt2
-rw-r--r--zephyr/shim/include/config_chip.h7
3 files changed, 16 insertions, 1 deletions
diff --git a/driver/charger/isl9241.c b/driver/charger/isl9241.c
index d0a8127b21..ae2867a139 100644
--- a/driver/charger/isl9241.c
+++ b/driver/charger/isl9241.c
@@ -5,7 +5,10 @@
* Renesas (Intersil) ISL-9241 battery charger driver.
*/
+/* TODO(b/175881324) */
+#ifndef CONFIG_ZEPHYR
#include "adc.h"
+#endif
#include "battery.h"
#include "battery_smart.h"
#include "charger.h"
@@ -42,7 +45,7 @@
static int learn_mode;
/* Mutex for CONTROL1 register, that can be updated from multiple tasks. */
-static struct mutex control1_mutex;
+static mutex_t control1_mutex;
/* Charger parameters */
static const struct charger_info isl9241_charger_info = {
@@ -371,6 +374,9 @@ static void isl9241_init(int chgnum)
{
const struct battery_info *bi = battery_get_info();
+ /* Init the mutex for ZephyrOS (nop for non-Zephyr builds) */
+ (void)k_mutex_init(&control1_mutex);
+
/*
* Set the MaxSystemVoltage to battery maximum,
* 0x00=disables switching charger states
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 79efbdf6b5..0c0ecb5284 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -46,6 +46,8 @@ zephyr_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c"
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY "${PLATFORM_EC}/common/battery.c")
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY_SMART
"${PLATFORM_EC}/driver/battery/smart.c")
+zephyr_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_ISL9241
+ "${PLATFORM_EC}/driver/charger/isl9241.c")
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_CBI "${PLATFORM_EC}/common/cbi.c")
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 61ddefedaf..84f0af9b77 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -39,6 +39,13 @@
#define CONFIG_CHARGER_ISL9241
/* Hardware based charge ramp is broken in the ISL9241 (b/169350714) */
#define CONFIG_CHARGE_RAMP_SW
+
+/* TODO(b/175881762): Move to devicetree? */
+#define CONFIG_CHARGER_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+
+#define CONFIG_CHARGER_DISCHARGE_ON_AC
+#define CONFIG_CHARGER_INPUT_CURRENT 512
#endif
#undef CONFIG_BATTERY_SMART