summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-12-21 17:04:52 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-15 03:56:11 +0000
commitff48c55fa23433a4beb5e057cab01ebfd60bbcea (patch)
tree6469686ed237f32eb8c3d174abf3f64228132fc7
parent17b94bd691f43a5fd305cde34657e9cc0e2b0cab (diff)
downloadchrome-ec-ff48c55fa23433a4beb5e057cab01ebfd60bbcea.tar.gz
Add information for battery charging
Copy this over from the EC code base so that volteer can build the charger task BUG=b:175248556 TEST=build and boot on volteer (no actual test) Cq-Depend: chromium:2600228 Change-Id: I42de66fc6023762eb6e0eb84d5b6e93bd41ca7d7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/zephyr-chrome/+/2599493 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2630164 Tested-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/projects/volteer/CMakeLists.txt1
-rw-r--r--zephyr/projects/volteer/include/i2c_map.h1
-rw-r--r--zephyr/projects/volteer/prj.conf1
-rw-r--r--zephyr/projects/volteer/src/battery.c78
4 files changed, 81 insertions, 0 deletions
diff --git a/zephyr/projects/volteer/CMakeLists.txt b/zephyr/projects/volteer/CMakeLists.txt
index fd5ed88bfe..20928eaea9 100644
--- a/zephyr/projects/volteer/CMakeLists.txt
+++ b/zephyr/projects/volteer/CMakeLists.txt
@@ -21,5 +21,6 @@ project(volteer)
# Include board specific header files
zephyr_include_directories(include)
+target_sources(app PRIVATE "src/battery.c")
target_sources(app PRIVATE "src/battery_presence.c")
target_sources(app PRIVATE "src/pwrok_signals.c")
diff --git a/zephyr/projects/volteer/include/i2c_map.h b/zephyr/projects/volteer/include/i2c_map.h
index 70a73fbb8c..4a0b131a70 100644
--- a/zephyr/projects/volteer/include/i2c_map.h
+++ b/zephyr/projects/volteer/include/i2c_map.h
@@ -23,5 +23,6 @@
#define I2C_ADDR_EEPROM_FLAGS 0x50
#define I2C_PORT_BATTERY I2C_PORT_POWER
+#define I2C_PORT_CHARGER I2C_PORT_EEPROM
#endif /* __ZEPHYR_CHROME_I2C_MAP_H */
diff --git a/zephyr/projects/volteer/prj.conf b/zephyr/projects/volteer/prj.conf
index 9055bd0da7..acfa0bdaad 100644
--- a/zephyr/projects/volteer/prj.conf
+++ b/zephyr/projects/volteer/prj.conf
@@ -20,6 +20,7 @@ CONFIG_PLATFORM_EC_CBI=y
# Battery
CONFIG_PLATFORM_EC_BATTERY=y
CONFIG_PLATFORM_EC_BATTERY_SMART=y
+CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
# Power Sequencing
CONFIG_PLATFORM_EC_POWERSEQ=y
diff --git a/zephyr/projects/volteer/src/battery.c b/zephyr/projects/volteer/src/battery.c
new file mode 100644
index 0000000000..d2530979fa
--- /dev/null
+++ b/zephyr/projects/volteer/src/battery.c
@@ -0,0 +1,78 @@
+/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Battery pack vendor provided charging profile
+ */
+
+#include "common.h"
+#include "battery_fuel_gauge.h"
+#include "charger.h"
+#include "util.h"
+#include "../driver/charger/isl9241.h"
+
+/*
+ * Battery info for all Volteer battery types. Note that the fields
+ * start_charging_min/max and charging_min/max are not used for the charger.
+ * The effective temperature limits are given by discharging_min/max_c.
+ *
+ * Fuel Gauge (FG) parameters which are used for determining if the battery
+ * is connected, the appropriate ship mode (battery cutoff) command, and the
+ * charge/discharge FETs status.
+ *
+ * Ship mode (battery cutoff) requires 2 writes to the appropriate smart battery
+ * register. For some batteries, the charge/discharge FET bits are set when
+ * charging/discharging is active, in other types, these bits set mean that
+ * charging/discharging is disabled. Therefore, in addition to the mask for
+ * these bits, a disconnect value must be specified. Note that for TI fuel
+ * gauge, the charge/discharge FET status is found in Operation Status (0x54),
+ * but a read of Manufacturer Access (0x00) will return the lower 16 bits of
+ * Operation status which contains the FET status bits.
+ *
+ * The assumption for battery types supported is that the charge/discharge FET
+ * status can be read with a sb_read() command and therefore, only the register
+ * address, mask, and disconnect value need to be provided.
+ */
+const struct board_batt_params board_battery_info[] = {
+ /* LGC\011 L17L3PB0 Battery Information */
+ /*
+ * Battery info provided by ODM on b/143477210, comment #11
+ */
+ [BATTERY_LGC011] = {
+ .fuel_gauge = {
+ .manuf_name = "LGC",
+ .ship_mode = {
+ .reg_addr = 0x00,
+ .reg_data = { 0x10, 0x10 },
+ },
+ .fet = {
+ .reg_addr = 0x0,
+ .reg_mask = 0x6000,
+ .disconnect_val = 0x6000,
+ }
+ },
+ .batt_info = {
+ .voltage_max = TARGET_WITH_MARGIN(13200, 5),
+ .voltage_normal = 11550, /* mV */
+ .voltage_min = 9000, /* mV */
+ .precharge_current = 256, /* mA */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 45,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = 0,
+ .discharging_max_c = 75,
+ },
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
+
+const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_LGC011;
+
+const struct charger_config_t chg_chips[] = {
+ {
+ .i2c_port = I2C_PORT_CHARGER,
+ .i2c_addr_flags = ISL9241_ADDR_FLAGS,
+ .drv = &isl9241_drv,
+ },
+};