summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2021-01-05 15:07:02 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-06 23:06:10 +0000
commitf81747eab60e0c329fc930b05c0c1d1edbbe32a4 (patch)
tree8e7929daf4193aff7c0b94f17d0ef1b53ca153aa
parentf5cfb505dc2f0123fdc053c100ce634b89036f8c (diff)
downloadchrome-ec-f81747eab60e0c329fc930b05c0c1d1edbbe32a4.tar.gz
coil: remove battery code
This code uses coil terms we're removing, but we don't use it in platform/cr50. Remove the code instead of replacing the terms. BUG=b:175244613 TEST=make buildall -j Change-Id: I15ffb2617d2dd4bedb809eeff858dcf0f6c8cf25 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2613140 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
-rw-r--r--common/battery.c626
-rw-r--r--common/battery_fuel_gauge.c218
-rw-r--r--common/build.mk2
-rw-r--r--common/i2c_master.c9
-rw-r--r--common/lightbar.c1
-rw-r--r--common/system.c10
-rw-r--r--include/battery.h448
-rw-r--r--include/battery_fuel_gauge.h87
8 files changed, 0 insertions, 1401 deletions
diff --git a/common/battery.c b/common/battery.c
deleted file mode 100644
index 67d08b4150..0000000000
--- a/common/battery.c
+++ /dev/null
@@ -1,626 +0,0 @@
-/* Copyright 2012 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.
- *
- * Common battery command.
- */
-
-#include "battery.h"
-#include "charge_state.h"
-#include "common.h"
-#include "console.h"
-#include "ec_ec_comm_master.h"
-#include "extpower.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "timer.h"
-#include "util.h"
-#include "watchdog.h"
-
-#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
-
-/* See config.h for details */
-const static int batt_full_factor = CONFIG_BATT_FULL_FACTOR;
-const static int batt_host_full_factor = CONFIG_BATT_HOST_FULL_FACTOR;
-const static int batt_host_shutdown_pct = CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE;
-
-#ifdef CONFIG_BATTERY_V2
-/*
- * Store battery information in these 2 structures. Main (lid) battery is always
- * at index 0, and secondary (base) battery at index 1.
- */
-struct ec_response_battery_static_info battery_static[CONFIG_BATTERY_COUNT];
-struct ec_response_battery_dynamic_info battery_dynamic[CONFIG_BATTERY_COUNT];
-#endif
-
-#ifdef CONFIG_BATTERY_CUT_OFF
-
-#ifndef CONFIG_BATTERY_CUTOFF_DELAY_US
-#define CONFIG_BATTERY_CUTOFF_DELAY_US (1 * SECOND)
-#endif
-
-static enum battery_cutoff_states battery_cutoff_state =
- BATTERY_CUTOFF_STATE_NORMAL;
-
-#endif
-
-#ifdef CONFIG_BATTERY_PRESENT_GPIO
-#ifdef CONFIG_BATTERY_PRESENT_CUSTOM
-#error "Don't define both CONFIG_BATTERY_PRESENT_CUSTOM and" \
- "CONFIG_BATTERY_PRESENT_GPIO"
-#endif
-/**
- * Physical detection of battery.
- */
-enum battery_present battery_is_present(void)
-{
- /* The GPIO is low when the battery is present */
- return gpio_get_level(CONFIG_BATTERY_PRESENT_GPIO) ? BP_NO : BP_YES;
-}
-#endif
-
-static const char *get_error_text(int rv)
-{
- if (rv == EC_ERROR_UNIMPLEMENTED)
- return "(unsupported)";
- else
- return "(error)";
-}
-
-static void print_item_name(const char *name)
-{
- ccprintf(" %-11s", name);
-}
-
-static int check_print_error(int rv)
-{
- if (rv != EC_SUCCESS)
- ccprintf("%s\n", get_error_text(rv));
- return rv == EC_SUCCESS;
-}
-
-static void print_battery_status(void)
-{
- static const char * const st[] = {"EMPTY", "FULL", "DCHG", "INIT",};
- static const char * const al[] = {"RT", "RC", "--", "TD",
- "OT", "--", "TC", "OC"};
-
- int value, i;
-
- print_item_name("Status:");
- if (check_print_error(battery_status(&value))) {
- ccprintf("0x%04x", value);
-
- /* bits 0-3 are only valid when the previous transaction
- * failed, so ignore them */
-
- /* bits 4-7 are status */
- for (i = 0; i < 4; i++)
- if (value & (1 << (i+4)))
- ccprintf(" %s", st[i]);
-
- /* bits 15-8 are alarms */
- for (i = 0; i < 8; i++)
- if (value & (1 << (i+8)))
- ccprintf(" %s", al[i]);
-
- ccprintf("\n");
- }
-}
-
-static void print_battery_strings(void)
-{
- char text[32];
-
- print_item_name("Manuf:");
- if (check_print_error(battery_manufacturer_name(text, sizeof(text))))
- ccprintf("%s\n", text);
-
- print_item_name("Device:");
- if (check_print_error(battery_device_name(text, sizeof(text))))
- ccprintf("%s\n", text);
-
- print_item_name("Chem:");
- if (check_print_error(battery_device_chemistry(text, sizeof(text))))
- ccprintf("%s\n", text);
-}
-
-static void print_battery_params(void)
-{
-#if defined(HAS_TASK_CHARGER)
- /* Ask charger so that we don't need to ask battery again. */
- const struct batt_params *batt = charger_current_battery_params();
-#else
- /* This is for test code, where doesn't have charger task. */
- struct batt_params _batt;
- const struct batt_params *batt = &_batt;
-
- battery_get_params(&_batt);
-#endif
-
- print_item_name("Param flags:");
- ccprintf("%08x\n", batt->flags);
-
- print_item_name("Temp:");
- ccprintf("0x%04x = %.1d K (%.1d C)\n",
- batt->temperature,
- batt->temperature,
- batt->temperature - 2731);
-
- print_item_name("V:");
- ccprintf("0x%04x = %d mV\n", batt->voltage, batt->voltage);
-
- print_item_name("V-desired:");
- ccprintf("0x%04x = %d mV\n", batt->desired_voltage,
- batt->desired_voltage);
-
- print_item_name("I:");
- ccprintf("0x%04x = %d mA", batt->current & 0xffff, batt->current);
- if (batt->current > 0)
- ccputs("(CHG)");
- else if (batt->current < 0)
- ccputs("(DISCHG)");
- ccputs("\n");
-
- print_item_name("I-desired:");
- ccprintf("0x%04x = %d mA\n", batt->desired_current,
- batt->desired_current);
-
- print_item_name("Charging:");
- ccprintf("%sAllowed\n",
- batt->flags & BATT_FLAG_WANT_CHARGE ? "" : "Not ");
-
- print_item_name("Charge:");
- ccprintf("%d %%\n", batt->state_of_charge);
-}
-
-static void print_battery_info(void)
-{
- int value;
- int hour, minute;
-
- print_item_name("Serial:");
- if (check_print_error(battery_serial_number(&value)))
- ccprintf("0x%04x\n", value);
-
- print_item_name("V-design:");
- if (check_print_error(battery_design_voltage(&value)))
- ccprintf("0x%04x = %d mV\n", value, value);
-
- print_item_name("Mode:");
- if (check_print_error(battery_get_mode(&value)))
- ccprintf("0x%04x\n", value);
-
- print_item_name("Abs charge:");
- if (check_print_error(battery_state_of_charge_abs(&value)))
- ccprintf("%d %%\n", value);
-
- print_item_name("Remaining:");
- if (check_print_error(battery_remaining_capacity(&value)))
- ccprintf("%d mAh\n", value);
-
- print_item_name("Cap-full:");
- if (check_print_error(battery_full_charge_capacity(&value)))
- ccprintf("%d mAh (%d mAh with %d %% compensation)\n",
- value, value*batt_full_factor/100, batt_full_factor);
-
-#ifdef CONFIG_CHARGER
- print_item_name("Display:");
- value = charge_get_display_charge();
- ccprintf("%d.%d %%\n", value / 10, value % 10);
-#endif
-
- print_item_name(" Design:");
- if (check_print_error(battery_design_capacity(&value)))
- ccprintf("%d mAh\n", value);
-
- print_item_name("Time-full:");
- if (check_print_error(battery_time_to_full(&value))) {
- if (value == 65535) {
- hour = 0;
- minute = 0;
- } else {
- hour = value / 60;
- minute = value % 60;
- }
- ccprintf("%dh:%d\n", hour, minute);
- }
-
- print_item_name(" Empty:");
- if (check_print_error(battery_time_to_empty(&value))) {
- if (value == 65535) {
- hour = 0;
- minute = 0;
- } else {
- hour = value / 60;
- minute = value % 60;
- }
- ccprintf("%dh:%d\n", hour, minute);
- }
-}
-
-void print_battery_debug(void)
-{
- print_battery_status();
- print_battery_params();
- print_battery_strings();
- print_battery_info();
-}
-
-static int command_battery(int argc, char **argv)
-{
- int repeat = 1;
- int loop;
- int sleep_ms = 0;
- char *e;
-
- if (argc > 1) {
- repeat = strtoi(argv[1], &e, 0);
- if (*e) {
- ccputs("Invalid repeat count\n");
- return EC_ERROR_INVAL;
- }
- }
-
- if (argc > 2) {
- sleep_ms = strtoi(argv[2], &e, 0);
- if (*e) {
- ccputs("Invalid sleep ms\n");
- return EC_ERROR_INVAL;
- }
- }
-
- for (loop = 0; loop < repeat; loop++) {
- print_battery_debug();
-
- /*
- * Running with a high repeat count will take so long the
- * watchdog timer fires. So reset the watchdog timer each
- * iteration.
- */
- watchdog_reload();
-
- if (sleep_ms)
- msleep(sleep_ms);
- }
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(battery, command_battery,
- "<repeat_count> <sleep_ms>",
- "Print battery info");
-
-#ifdef CONFIG_BATTERY_CUT_OFF
-int battery_is_cut_off(void)
-{
- return (battery_cutoff_state == BATTERY_CUTOFF_STATE_CUT_OFF);
-}
-
-static void pending_cutoff_deferred(void)
-{
- int rv;
-
- rv = board_cut_off_battery();
-
- if (rv == EC_RES_SUCCESS)
- CPRINTS("Battery cut off succeeded.");
- else
- CPRINTS("Battery cut off failed!");
-}
-DECLARE_DEFERRED(pending_cutoff_deferred);
-
-static void clear_pending_cutoff(void)
-{
- if (extpower_is_present()) {
- battery_cutoff_state = BATTERY_CUTOFF_STATE_NORMAL;
- hook_call_deferred(&pending_cutoff_deferred_data, -1);
- }
-}
-DECLARE_HOOK(HOOK_AC_CHANGE, clear_pending_cutoff, HOOK_PRIO_DEFAULT);
-
-static enum ec_status battery_command_cutoff(struct host_cmd_handler_args *args)
-{
- const struct ec_params_battery_cutoff *p;
- int rv;
-
- if (args->version == 1) {
- p = args->params;
- if (p->flags & EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN) {
- battery_cutoff_state = BATTERY_CUTOFF_STATE_PENDING;
- CPRINTS("Battery cut off at-shutdown is scheduled");
- return EC_RES_SUCCESS;
- }
- }
-
- rv = board_cut_off_battery();
- if (rv == EC_RES_SUCCESS) {
- CPRINTS("Battery cut off is successful.");
- battery_cutoff_state = BATTERY_CUTOFF_STATE_CUT_OFF;
- } else {
- CPRINTS("Battery cut off has failed.");
- }
-
- return rv;
-}
-DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cutoff,
- EC_VER_MASK(0) | EC_VER_MASK(1));
-
-static void check_pending_cutoff(void)
-{
- if (battery_cutoff_state == BATTERY_CUTOFF_STATE_PENDING) {
- CPRINTS("Cutting off battery in %d second(s)",
- CONFIG_BATTERY_CUTOFF_DELAY_US / SECOND);
- hook_call_deferred(&pending_cutoff_deferred_data,
- CONFIG_BATTERY_CUTOFF_DELAY_US);
- }
-}
-DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, check_pending_cutoff, HOOK_PRIO_LAST);
-
-static int command_cutoff(int argc, char **argv)
-{
- int rv;
-
- if (argc > 1) {
- if (!strcasecmp(argv[1], "at-shutdown")) {
- battery_cutoff_state = BATTERY_CUTOFF_STATE_PENDING;
- return EC_SUCCESS;
- } else {
- return EC_ERROR_INVAL;
- }
- }
-
- rv = board_cut_off_battery();
- if (rv == EC_RES_SUCCESS) {
- ccprints("Battery cut off");
- battery_cutoff_state = BATTERY_CUTOFF_STATE_CUT_OFF;
- return EC_SUCCESS;
- }
-
- return EC_ERROR_UNKNOWN;
-}
-DECLARE_CONSOLE_COMMAND(cutoff, command_cutoff,
- "[at-shutdown]",
- "Cut off the battery output");
-#else
-int battery_is_cut_off(void)
-{
- return 0; /* Always return NOT cut off */
-}
-#endif /* CONFIG_BATTERY_CUT_OFF */
-
-#ifdef CONFIG_BATTERY_VENDOR_PARAM
-static int console_command_battery_vendor_param(int argc, char **argv)
-{
- uint32_t param;
- uint32_t value;
- char *e;
- int rv;
-
- if (argc < 2)
- return EC_ERROR_INVAL;
-
- param = strtoi(argv[1], &e, 0);
- if (*e) {
- ccputs("Invalid param\n");
- return EC_ERROR_INVAL;
- }
-
- if (argc > 2) {
- value = strtoi(argv[2], &e, 0);
- if (*e) {
- ccputs("Invalid value\n");
- return EC_ERROR_INVAL;
- }
- rv = battery_set_vendor_param(param, value);
- if (rv != EC_SUCCESS)
- return rv;
- }
-
- rv = battery_get_vendor_param(param, &value);
- if (rv != EC_SUCCESS)
- return rv;
-
- ccprintf("0x%08x\n", value);
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(battparam, console_command_battery_vendor_param,
- "<param> [value]",
- "Get or set battery vendor parameters");
-
-static enum ec_status
-host_command_battery_vendor_param(struct host_cmd_handler_args *args)
-{
- int rv;
- const struct ec_params_battery_vendor_param *p = args->params;
- struct ec_response_battery_vendor_param *r = args->response;
-
- args->response_size = sizeof(*r);
-
- if (p->mode != BATTERY_VENDOR_PARAM_MODE_GET &&
- p->mode != BATTERY_VENDOR_PARAM_MODE_SET)
- return EC_RES_INVALID_PARAM;
-
- if (p->mode == BATTERY_VENDOR_PARAM_MODE_SET) {
- rv = battery_set_vendor_param(p->param, p->value);
- if (rv != EC_SUCCESS)
- return rv;
- }
-
- rv = battery_get_vendor_param(p->param, &r->value);
- return rv;
-}
-DECLARE_HOST_COMMAND(EC_CMD_BATTERY_VENDOR_PARAM,
- host_command_battery_vendor_param,
- EC_VER_MASK(0));
-#endif /* CONFIG_BATTERY_VENDOR_PARAM */
-
-#ifdef CONFIG_BATTERY_V2
-#ifdef CONFIG_HOSTCMD_BATTERY_V2
-static void battery_update(enum battery_index i);
-static enum ec_status
-host_command_battery_get_static(struct host_cmd_handler_args *args)
-{
- const struct ec_params_battery_static_info *p = args->params;
- struct ec_response_battery_static_info *r = args->response;
-
- if (p->index < 0 || p->index >= CONFIG_BATTERY_COUNT)
- return EC_RES_INVALID_PARAM;
- battery_update(p->index);
- args->response_size = sizeof(*r);
- memcpy(r, &battery_static[p->index], sizeof(*r));
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_BATTERY_GET_STATIC,
- host_command_battery_get_static,
- EC_VER_MASK(0));
-
-static enum ec_status
-host_command_battery_get_dynamic(struct host_cmd_handler_args *args)
-{
- const struct ec_params_battery_dynamic_info *p = args->params;
- struct ec_response_battery_dynamic_info *r = args->response;
-
- if (p->index < 0 || p->index >= CONFIG_BATTERY_COUNT)
- return EC_RES_INVALID_PARAM;
-
- args->response_size = sizeof(*r);
- memcpy(r, &battery_dynamic[p->index], sizeof(*r));
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_BATTERY_GET_DYNAMIC,
- host_command_battery_get_dynamic,
- EC_VER_MASK(0));
-#endif /* CONFIG_HOSTCMD_BATTERY_V2 */
-
-#ifdef HAS_TASK_HOSTCMD
-static void battery_update(enum battery_index i)
-{
- char *batt_str;
- int *memmap_dcap = (int *)host_get_memmap(EC_MEMMAP_BATT_DCAP);
- int *memmap_dvlt = (int *)host_get_memmap(EC_MEMMAP_BATT_DVLT);
- int *memmap_ccnt = (int *)host_get_memmap(EC_MEMMAP_BATT_CCNT);
- int *memmap_volt = (int *)host_get_memmap(EC_MEMMAP_BATT_VOLT);
- int *memmap_rate = (int *)host_get_memmap(EC_MEMMAP_BATT_RATE);
- int *memmap_cap = (int *)host_get_memmap(EC_MEMMAP_BATT_CAP);
- int *memmap_lfcc = (int *)host_get_memmap(EC_MEMMAP_BATT_LFCC);
- uint8_t *memmap_flags = host_get_memmap(EC_MEMMAP_BATT_FLAG);
-
- /* Smart battery serial number is 16 bits */
- batt_str = (char *)host_get_memmap(EC_MEMMAP_BATT_SERIAL);
- memcpy(batt_str, battery_static[i].serial, EC_MEMMAP_TEXT_MAX);
-
- /* Design Capacity of Full */
- *memmap_dcap = battery_static[i].design_capacity;
-
- /* Design Voltage */
- *memmap_dvlt = battery_static[i].design_voltage;
-
- /* Cycle Count */
- *memmap_ccnt = battery_static[i].cycle_count;
-
- /* Battery Manufacturer string */
- batt_str = (char *)host_get_memmap(EC_MEMMAP_BATT_MFGR);
- memcpy(batt_str, battery_static[i].manufacturer, EC_MEMMAP_TEXT_MAX);
-
- /* Battery Model string */
- batt_str = (char *)host_get_memmap(EC_MEMMAP_BATT_MODEL);
- memcpy(batt_str, battery_static[i].model, EC_MEMMAP_TEXT_MAX);
-
- /* Battery Type string */
- batt_str = (char *)host_get_memmap(EC_MEMMAP_BATT_TYPE);
- memcpy(batt_str, battery_static[i].type, EC_MEMMAP_TEXT_MAX);
-
- *memmap_volt = battery_dynamic[i].actual_voltage;
- *memmap_rate = battery_dynamic[i].actual_current;
- *memmap_cap = battery_dynamic[i].remaining_capacity;
- *memmap_lfcc = battery_dynamic[i].full_capacity;
- *memmap_flags = battery_dynamic[i].flags;
-}
-
-void battery_memmap_refresh(enum battery_index index)
-{
- if (*host_get_memmap(EC_MEMMAP_BATT_INDEX) == index)
- battery_update(index);
-}
-
-void battery_memmap_set_index(enum battery_index index)
-{
- if (*host_get_memmap(EC_MEMMAP_BATT_INDEX) == index)
- return;
-
- *host_get_memmap(EC_MEMMAP_BATT_INDEX) = BATT_IDX_INVALID;
- if (index < 0 || index >= CONFIG_BATTERY_COUNT)
- return;
-
- battery_update(index);
- *host_get_memmap(EC_MEMMAP_BATT_INDEX) = index;
-}
-
-static void battery_init(void)
-{
- *host_get_memmap(EC_MEMMAP_BATT_INDEX) = BATT_IDX_INVALID;
- *host_get_memmap(EC_MEMMAP_BATT_COUNT) = CONFIG_BATTERY_COUNT;
- *host_get_memmap(EC_MEMMAP_BATTERY_VERSION) = 2;
-
- battery_memmap_set_index(BATT_IDX_MAIN);
-}
-DECLARE_HOOK(HOOK_INIT, battery_init, HOOK_PRIO_DEFAULT);
-#endif /* HAS_TASK_HOSTCMD */
-#endif /* CONFIG_BATTERY_V2 */
-
-void battery_compensate_params(struct batt_params *batt)
-{
- int numer, denom;
- int remain = batt->remaining_capacity;
- int full = batt->full_capacity;
- int lfcc = *(int *)host_get_memmap(EC_MEMMAP_BATT_LFCC);
-
- if ((batt->flags & BATT_FLAG_BAD_FULL_CAPACITY) ||
- (batt->flags & BATT_FLAG_BAD_REMAINING_CAPACITY))
- return;
-
- if (remain <= 0 || full <= 0)
- return;
-
- /* full_factor != 100 isn't supported. EC and host are not able to
- * act on soc changes synchronously. */
- if (batt_host_full_factor != 100)
- return;
-
- /* full_factor is effectively disabled in powerd. */
- batt->full_capacity = full * batt_full_factor / 100;
- if (lfcc == 0)
- /* EC just reset. Assume host full is equal. */
- lfcc = batt->full_capacity;
- if (remain > lfcc) {
- batt->remaining_capacity = lfcc;
- remain = batt->remaining_capacity;
- }
-
- /*
- * Powerd uses the following equation to calculate display percentage:
- * charge = 100 * remain/full;
- * 100 * (charge - shutdown_pct) / (full_factor - shutdown_pct);
- */
- numer = (100 * remain - lfcc * batt_host_shutdown_pct) * 1000;
- denom = lfcc * (100 - batt_host_shutdown_pct);
- /* Rounding (instead of truncating) */
- batt->display_charge = (numer + denom / 2) / denom;
- if (batt->display_charge < 0)
- batt->display_charge = 0;
-}
-
-__attribute__((weak)) int get_battery_manufacturer_name(char *dest, int size)
-{
- strzcpy(dest, "<unkn>", size);
- return EC_SUCCESS;
-}
-
-int battery_manufacturer_name(char *dest, int size)
-{
- return get_battery_manufacturer_name(dest, size);
-}
diff --git a/common/battery_fuel_gauge.c b/common/battery_fuel_gauge.c
deleted file mode 100644
index a0dd250899..0000000000
--- a/common/battery_fuel_gauge.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/* Copyright 2018 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 fuel gauge parameters
- */
-
-#include "battery_fuel_gauge.h"
-#include "battery_smart.h"
-#include "console.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "util.h"
-
-#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
-
-
-/* Get type of the battery connected on the board */
-static int get_battery_type(void)
-{
- char manuf_name[32], device_name[32];
- int i;
- static enum battery_type battery_type = BATTERY_TYPE_COUNT;
-
- /*
- * If battery_type is not the default value, then can return here
- * as there is no need to query the fuel gauge.
- */
- if (battery_type != BATTERY_TYPE_COUNT)
- return battery_type;
-
- /* Get the manufacturer name. If can't read then just exit */
- if (battery_manufacturer_name(manuf_name, sizeof(manuf_name)))
- return battery_type;
-
- /*
- * Compare the manufacturer name read from the fuel gauge to the
- * manufacturer names defined in the board_battery_info table. If
- * a device name has been specified in the board_battery_info table,
- * then both the manufacturer and device name must match.
- */
- for (i = 0; i < BATTERY_TYPE_COUNT; i++) {
- const struct fuel_gauge_info * const fuel_gauge =
- &board_battery_info[i].fuel_gauge;
-
- if (strcasecmp(manuf_name, fuel_gauge->manuf_name))
- continue;
-
- if (fuel_gauge->device_name != NULL) {
-
- if (battery_device_name(device_name,
- sizeof(device_name)))
- continue;
-
- if (strcasecmp(device_name, fuel_gauge->device_name))
- continue;
- }
-
- CPRINTS("found batt:%s", fuel_gauge->manuf_name);
- battery_type = i;
- break;
- }
-
- return battery_type;
-}
-
-/*
- * Initialize the battery type for the board.
- *
- * The first call to battery_get_info() is when the charger task starts, so
- * initialize the battery type as soon as I2C is initialized.
- */
-static void init_battery_type(void)
-{
- if (get_battery_type() == BATTERY_TYPE_COUNT)
- CPRINTS("battery not found");
-}
-DECLARE_HOOK(HOOK_INIT, init_battery_type, HOOK_PRIO_INIT_I2C + 1);
-
-static inline const struct board_batt_params *get_batt_params(void)
-{
- int type = get_battery_type();
-
- return &board_battery_info[type == BATTERY_TYPE_COUNT ?
- DEFAULT_BATTERY_TYPE : type];
-}
-
-const struct battery_info *battery_get_info(void)
-{
- return &get_batt_params()->batt_info;
-}
-
-int cut_off_battery_block_write(const struct ship_mode_info *ship_mode)
-{
- int rv;
-
- uint8_t cutdata[3] = {
- 0x02,
- ship_mode->reg_data[0] & 0xFF,
- ship_mode->reg_data[0] >> 8,
- };
-
- /* SMBus protocols are block write, which include byte count
- * byte. Byte count segments are required to communicate
- * required action and the number of data bytes.
- * Due to ship mode command requires writing data values twice
- * to cutoff the battery, so byte count is 0x02.
- */
- rv = sb_write_block(ship_mode->reg_addr, cutdata, sizeof(cutdata));
- if (rv)
- return rv;
-
- /* Use the next set of values */
- cutdata[1] = ship_mode->reg_data[1] & 0xFF;
- cutdata[2] = ship_mode->reg_data[1] >> 8;
-
- return sb_write_block(ship_mode->reg_addr, cutdata, sizeof(cutdata));
-}
-
-int cut_off_battery_sb_write(const struct ship_mode_info *ship_mode)
-{
- int rv;
-
- /* Ship mode command requires writing 2 data values */
- rv = sb_write(ship_mode->reg_addr, ship_mode->reg_data[0]);
- if (rv)
- return rv;
-
- return sb_write(ship_mode->reg_addr, ship_mode->reg_data[1]);
-}
-
-int board_cut_off_battery(void)
-{
- int rv;
- int type = get_battery_type();
-
- /* If battery type is unknown can't send ship mode command */
- if (type == BATTERY_TYPE_COUNT)
- return EC_RES_ERROR;
-
- if (board_battery_info[type].fuel_gauge.ship_mode.wb_support)
- rv = cut_off_battery_block_write(
- &board_battery_info[type].fuel_gauge.ship_mode);
- else
- rv = cut_off_battery_sb_write(
- &board_battery_info[type].fuel_gauge.ship_mode);
-
- return rv ? EC_RES_ERROR : EC_RES_SUCCESS;
-}
-
-/*
- * This function checks the charge/discharge FET status bits. Each battery type
- * supported provides the register address, mask, and disconnect value for these
- * 2 FET status bits. If the FET status matches the disconnected value, then
- * BATTERY_DISCONNECTED is returned. This function is required to handle the
- * cases when the fuel gauge is awake and will return a non-zero state of
- * charge, but is not able yet to provide power (i.e. discharge FET is not
- * active). By returning BATTERY_DISCONNECTED the AP will not be powered up
- * until either the external charger is able to provided enough power, or
- * the battery is able to provide power and thus prevent a brownout when the
- * AP is powered on by the EC.
- */
-enum battery_disconnect_state battery_get_disconnect_state(void)
-{
- int rv;
- int reg;
- uint8_t data[6];
- int type = get_battery_type();
-
- /* If battery type is not known, can't check CHG/DCHG FETs */
- if (type == BATTERY_TYPE_COUNT) {
- /* Still don't know, so return here */
- return BATTERY_DISCONNECT_ERROR;
- }
-
- /* Read the status of charge/discharge FETs */
- if (board_battery_info[type].fuel_gauge.fet.mfgacc_support == 1) {
- rv = sb_read_mfgacc(PARAM_OPERATION_STATUS,
- SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data));
- /* Get the lowest 16bits of the OperationStatus() data */
- reg = data[2] | data[3] << 8;
- } else
- rv = sb_read(board_battery_info[type].fuel_gauge.fet.reg_addr,
- &reg);
-
- if (rv)
- return BATTERY_DISCONNECT_ERROR;
-
- if ((reg & board_battery_info[type].fuel_gauge.fet.reg_mask) ==
- board_battery_info[type].fuel_gauge.fet.disconnect_val) {
- CPRINTS("Batt disconnected: reg 0x%04x mask 0x%04x disc 0x%04x",
- reg,
- board_battery_info[type].fuel_gauge.fet.reg_mask,
- board_battery_info[type].fuel_gauge.fet.disconnect_val);
- return BATTERY_DISCONNECTED;
- }
-
- return BATTERY_NOT_DISCONNECTED;
-}
-
-#ifdef CONFIG_BATTERY_MEASURE_IMBALANCE
-int battery_imbalance_mv(void)
-{
- int type = get_battery_type();
-
- /*
- * If battery type is unknown, we cannot safely access non-standard
- * registers.
- */
- return (type == BATTERY_TYPE_COUNT) ? 0 :
- board_battery_info[type].fuel_gauge.imbalance_mv();
-}
-
-int battery_default_imbalance_mv(void)
-{
- return 0;
-}
-#endif /* CONFIG_BATTERY_MEASURE_IMBALANCE */
diff --git a/common/build.mk b/common/build.mk
index d099433290..8fb1d2c61a 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -37,8 +37,6 @@ common-$(CONFIG_AUDIO_CODEC_WOV)+=audio_codec_wov.o
common-$(CONFIG_BACKLIGHT_LID)+=backlight_lid.o
common-$(CONFIG_BASE32)+=base32.o
common-$(CONFIG_DETACHABLE_BASE)+=base_state.o
-common-$(CONFIG_BATTERY)+=battery.o
-common-$(CONFIG_BATTERY_FUEL_GAUGE)+=battery_fuel_gauge.o
common-$(CONFIG_CAPSENSE)+=capsense.o
common-$(CONFIG_CASE_CLOSED_DEBUG_V1)+=ccd_config.o
common-$(CONFIG_CEC)+=cec.o
diff --git a/common/i2c_master.c b/common/i2c_master.c
index 340c20bb7e..399303cc17 100644
--- a/common/i2c_master.c
+++ b/common/i2c_master.c
@@ -5,7 +5,6 @@
/* I2C cross-platform code for Chrome EC */
-#include "battery.h"
#include "clock.h"
#include "console.h"
#include "crc8.h"
@@ -959,14 +958,6 @@ static enum ec_status i2c_command_passthru(struct host_cmd_handler_args *args)
int ret, i;
int port_is_locked = 0;
-#ifdef CONFIG_BATTERY_CUT_OFF
- /*
- * Some batteries would wake up after cut-off if we talk to it.
- */
- if (battery_is_cut_off())
- return EC_RES_ACCESS_DENIED;
-#endif
-
i2c_port = get_i2c_port(params->port);
if (!i2c_port)
return EC_RES_INVALID_PARAM;
diff --git a/common/lightbar.c b/common/lightbar.c
index e535f5c20d..2ce15354b2 100644
--- a/common/lightbar.c
+++ b/common/lightbar.c
@@ -9,7 +9,6 @@
#ifdef LIGHTBAR_SIMULATION
#include "simulation.h"
#else
-#include "battery.h"
#include "common.h"
#include "console.h"
#include "ec_commands.h"
diff --git a/common/system.c b/common/system.c
index 62f7e6c40f..d9a40f8099 100644
--- a/common/system.c
+++ b/common/system.c
@@ -4,7 +4,6 @@
*/
/* System module for Chrome EC : common functions */
-#include "battery.h"
#include "chipset.h"
#include "clock.h"
#include "common.h"
@@ -1510,15 +1509,6 @@ DECLARE_HOST_COMMAND(EC_CMD_REBOOT_EC,
int system_can_boot_ap(void)
{
-#if defined(CONFIG_BATTERY) && \
- defined(CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
- /* Require a minimum battery level to power on. If battery isn't
- * present, battery_state_of_charge_abs returns false. */
- if (battery_state_of_charge_abs(&soc) == EC_SUCCESS &&
- soc >= CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
- return 1;
-#endif
-
/* For fixed AC system */
return 1;
}
diff --git a/include/battery.h b/include/battery.h
deleted file mode 100644
index 7052e2d663..0000000000
--- a/include/battery.h
+++ /dev/null
@@ -1,448 +0,0 @@
-/* Copyright 2013 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 charging parameters and constraints
- */
-
-#ifndef __CROS_EC_BATTERY_H
-#define __CROS_EC_BATTERY_H
-
-#include "common.h"
-#include "host_command.h"
-
-/* Battery index, only used with CONFIG_BATTERY_V2. */
-enum battery_index {
- BATT_IDX_INVALID = -1,
- BATT_IDX_MAIN = 0,
- BATT_IDX_BASE = 1,
-};
-
-#ifdef CONFIG_BATTERY_V2
-extern struct ec_response_battery_static_info
- battery_static[CONFIG_BATTERY_COUNT];
-extern struct ec_response_battery_dynamic_info
- battery_dynamic[CONFIG_BATTERY_COUNT];
-#endif
-
-/* Stop charge when charging and battery level >= this percentage */
-#define BATTERY_LEVEL_FULL 100
-
-/* Tell host we're charged when battery level >= this percentage */
-#ifdef CONFIG_BATTERY_LEVEL_NEAR_FULL
-#define BATTERY_LEVEL_NEAR_FULL CONFIG_BATTERY_LEVEL_NEAR_FULL
-#else
-#define BATTERY_LEVEL_NEAR_FULL 97
-#endif
-
-/*
- * Send battery-low host event when discharging and battery level <= this level
- */
-#define BATTERY_LEVEL_LOW 10
-
-/*
- * Send battery-critical host event when discharging and battery level <= this
- * level.
- */
-#define BATTERY_LEVEL_CRITICAL 5
-
-/*
- * Shut down main processor and/or hibernate EC when discharging and battery
- * level < this level.
- */
-#define BATTERY_LEVEL_SHUTDOWN 3
-
-/*
- * Sometimes we have hardware to detect battery present, sometimes we have to
- * wait until we've been able to talk to the battery.
- */
-enum battery_present {
- BP_NOT_INIT = -1,
- BP_NO = 0,
- BP_YES = 1,
- BP_NOT_SURE,
-};
-
-enum battery_cutoff_states {
- BATTERY_CUTOFF_STATE_NORMAL = 0,
- BATTERY_CUTOFF_STATE_CUT_OFF,
- BATTERY_CUTOFF_STATE_PENDING,
-};
-
-enum battery_disconnect_state {
- BATTERY_DISCONNECTED = 0,
- BATTERY_NOT_DISCONNECTED,
- BATTERY_DISCONNECT_ERROR,
-};
-
-/* Battery parameters */
-struct batt_params {
- int temperature; /* Temperature in 0.1 K */
- int state_of_charge; /* State of charge (percent, 0-100) */
- int voltage; /* Battery voltage (mV) */
- int current; /* Battery current (mA); negative=discharging */
- int desired_voltage; /* Charging voltage desired by battery (mV) */
- int desired_current; /* Charging current desired by battery (mA) */
- int remaining_capacity; /* Remaining capacity in mAh */
- int full_capacity; /* Capacity in mAh (might change occasionally) */
- int display_charge; /* Display charge in 10ths of a % (1000=100.0%) */
- int status; /* Battery status */
- enum battery_present is_present; /* Is the battery physically present */
- int flags; /* Flags */
-};
-
-/*
- * Provide a 1 minute average of the current and voltage on the battery.
- * Does not check for flags or whether those values are bad readings.
- * See driver/battery/[your_driver].h/c for details on implementation and
- * how the average is calculated.
- */
-
-int battery_get_avg_current(void); /* in mA */
-int battery_get_avg_voltage(void); /* in mV */
-
-/* Flags for batt_params */
-
-/* Battery wants to be charged */
-#define BATT_FLAG_WANT_CHARGE 0x00000001
-
-/* Battery is responsive (talking to us via I2C) */
-#define BATT_FLAG_RESPONSIVE 0x00000002
-
-/* Bits to indicate which parameter(s) could not be read */
-#define BATT_FLAG_BAD_TEMPERATURE 0x00000004
-#define BATT_FLAG_BAD_STATE_OF_CHARGE 0x00000008
-#define BATT_FLAG_BAD_VOLTAGE 0x00000010
-#define BATT_FLAG_BAD_CURRENT 0x00000020
-#define BATT_FLAG_BAD_DESIRED_VOLTAGE 0x00000040
-#define BATT_FLAG_BAD_DESIRED_CURRENT 0x00000080
-#define BATT_FLAG_BAD_REMAINING_CAPACITY 0x00000100
-#define BATT_FLAG_BAD_FULL_CAPACITY 0x00000200
-#define BATT_FLAG_BAD_STATUS 0x00000400
-#define BATT_FLAG_IMBALANCED_CELL 0x00000800
-/* All of the above BATT_FLAG_BAD_* bits */
-#define BATT_FLAG_BAD_ANY 0x000007fc
-
-/* Battery constants */
-struct battery_info {
- /* Operation voltage in mV */
- int voltage_max;
- int voltage_normal;
- int voltage_min;
- /* (TODO(chromium:756700): add desired_charging_current */
- /**
- * Pre-charge to fast charge threshold in mV,
- * default to voltage_min if not specified.
- * This option is only available on isl923x and rt946x.
- */
- int precharge_voltage;
- /* Pre-charge current in mA */
- int precharge_current;
- /* Working temperature ranges in degrees C */
- int8_t start_charging_min_c;
- int8_t start_charging_max_c;
- int8_t charging_min_c;
- int8_t charging_max_c;
- int8_t discharging_min_c;
- int8_t discharging_max_c;
-};
-
-/**
- * Return vendor-provided battery constants.
- */
-const struct battery_info *battery_get_info(void);
-
-/**
- * Get current battery parameters.
- *
- * Error conditions are reported via batt.flags.
- *
- * @param batt Destination for battery data
- */
-void battery_get_params(struct batt_params *batt);
-
-/**
- * Modify battery parameters to match vendor charging profile.
- *
- * @param batt Battery parameters to modify
- */
-void battery_override_params(struct batt_params *batt);
-
-/**
- * Check for presence of battery.
- *
- * @return Whether there is a battery attached or not, or if we can't tell.
- */
-enum battery_present battery_is_present(void);
-
-/**
- * Check for physical presence of battery.
- *
- * @return Whether there is a battery physically present, but possibly
- * in a disconnected or cut off state, or if we can't tell;
- */
-enum battery_present battery_hw_present(void);
-
-/**
- * Check for battery initialization status.
- *
- * @return zero if not initialized.
- */
-int board_battery_initialized(void);
-
-/**
- * Get battery mode.
- *
- * See MODE_* constants in battery_smart.h
- *
- * @param mode Destination for current mode.
- * @return non-zero if error.
- */
-int battery_get_mode(int *mode);
-
-/**
- * Read nominal voltage battery is designed to supply.
- *
- * @param voltage Destination for voltage in mW
- * @return non-zero if error.
- */
-int battery_design_voltage(int *voltage);
-
-/**
- * Read absolute state of charge.
- *
- * @param percent Destination for charge in percent
- * @return non-zero if error.
- */
-int battery_state_of_charge_abs(int *percent);
-
-/**
- * Read battery remaining capacity.
- *
- * @param capacity Destination for capacity in mAh
- * @return non-zero if error.
- */
-int battery_remaining_capacity(int *capacity);
-
-/**
- * Read battery full charge capacity.
- *
- * @param capacity Destination for capacity in mAh
- * @return non-zero if error.
- */
-int battery_full_charge_capacity(int *capacity);
-
-/**
- * Read the nominal capacity the battery is designed to supply when new.
- *
- * @param capacity Destination for capacity in mAh
- * @return non-zero if error.
- */
-int battery_design_capacity(int *capacity);
-
-/**
- * Read time in minutes left when discharging.
- *
- * @param capacity Destination for remaining time in minutes.
- * @return non-zero if error.
- */
-int battery_time_to_empty(int *minutes);
-
-/**
- * Read run time in minutes left when discharging.
- *
- * @param capacity Destination for remaining time in minutes.
- * @return non-zero if error.
- */
-int battery_run_time_to_empty(int *minutes);
-
-/**
- * Read time in minutes left to full capacity when charging.
- *
- * @param capacity Destination for remaining time in minutes.
- * @return non-zero if error.
- */
-int battery_time_to_full(int *minutes);
-
-/**
- * Calculate battery time in minutes, under an assumed current.
- *
- * @param rate Current to use for calculation, in mA.
- * If > 0, calculates charging time; if < 0, calculates
- * discharging time; 0 is invalid and sets minutes=0.
- * @param minutes Destination for calculated time in minutes.
- * @return non-zero if error.
- */
-int battery_time_at_rate(int rate, int *minutes);
-
-/**
- * Read battery status.
- *
- * @param status Destination for status; see STATUS_* in battery_smart.h.
- * @return non-zero if error.
- */
-int battery_status(int *status);
-
-/**
- * Read battery charge cycle count.
- *
- * @param count Destination for count.
- * @return non-zero if error.
- */
-int battery_cycle_count(int *count);
-
-/**
- * Read battery serial number.
- *
- * @param serial Destination for serial number.
- * @return non-zero if error.
- */
-int battery_serial_number(int *serial);
-
-/**
- * Read manufacturer name.
- *
- * @param dest Destination buffer.
- * @param size Length of destination buffer in chars.
- * @return non-zero if error.
- */
-int battery_manufacturer_name(char *dest, int size);
-
-/**
- * Read manufacturer name.
- *
- * This can be overridden to return a chip or board custom string.
- *
- * @param dest Destination buffer.
- * @param size Length of destination buffer in chars.
- * @return non-zero if error.
- */
-int get_battery_manufacturer_name(char *dest, int size);
-
-/**
- * Read device name.
- *
- * @param dest Destination buffer.
- * @param size Length of destination buffer in chars.
- * @return non-zero if error.
- */
-int battery_device_name(char *dest, int size);
-
-/**
- * Read battery type/chemistry.
- *
- * @param dest Destination buffer.
- * @param size Length of destination buffer in chars.
- * @return non-zero if error.
- */
-int battery_device_chemistry(char *dest, int size);
-
-/**
- * Read device manufacture date.
- *
- * @param year Destination for year
- * @param month Destination for month
- * @param day Destination for day
- * @return non-zero if error.
- */
-int battery_manufacturer_date(int *year, int *month, int *day);
-
-/**
- * Report the absolute difference between the highest and lowest cell voltage in
- * the battery pack, in millivolts. On error or unimplemented, returns '0'.
- */
-int battery_imbalance_mv(void);
-
-/**
- * Call board-specific cut-off function.
- *
- * @return EC_RES_INVALID_COMMAND if the battery doesn't support.
- */
-int board_cut_off_battery(void);
-
-/**
- * Return if the battery has been cut off.
- */
-int battery_is_cut_off(void);
-
-/**
- * Read battery vendor parameter.
- *
- * Vendor parameter handlers are implemented in a board-specific battery.c
- *
- * @param param Parameter identifier.
- * @param value Location to store retrieved value.
- * @return non-zero if error.
- */
-int battery_get_vendor_param(uint32_t param, uint32_t *value);
-
-/**
- * Write battery vendor parameter.
- *
- * Vendor parameter handlers are implemented in a board-specific battery.c
- *
- * @param param Parameter identifier.
- * @param value Value to write to the battery.
- * @return non-zero if error.
- */
-int battery_set_vendor_param(uint32_t param, uint32_t value);
-
-/**
- * Wait for battery stable.
- *
- * @return non-zero if error.
- */
-int battery_wait_for_stable(void);
-
-/**
- * Print all battery info for debugging purposes
- */
-void print_battery_debug(void);
-
-/**
- * Get the disconnect state of the battery.
- */
-enum battery_disconnect_state battery_get_disconnect_state(void);
-
-#ifdef CONFIG_BATTERY_V2
-/**
- * Refresh battery information in host memory mapped region, if index is
- * currently presented.
- */
-void battery_memmap_refresh(enum battery_index index);
-
-/**
- * Set which index to present in host memory mapped region.
- */
-void battery_memmap_set_index(enum battery_index index);
-#endif /* CONFIG_BATTERY_V2 */
-
-#ifdef CONFIG_CMD_I2C_STRESS_TEST_BATTERY
-extern struct i2c_stress_test_dev battery_i2c_stress_test_dev;
-#endif
-
-/*
- * If remaining charge is more than x% of the full capacity, the
- * remaining charge is raised to the full capacity before it's
- * reported to the rest of the system.
- *
- * Some batteries don't update full capacity timely or don't update it
- * at all. On such systems, compensation is required to guarantee
- * the remaining charge will be equal to the full capacity eventually.
- *
- * On some systems, Rohm charger generates audio noise when the battery
- * is fully charged and AC is plugged. A workaround is to do charge-
- * discharge cycles between 93 and 100%. On such systems, compensation
- * was also applied to mask this cycle from users.
- *
- * This used to be done in ACPI, thus, all software components except EC
- * was seeing the compensated charge. Now we do it in EC. It has more
- * knowledge on the charger and the battery. So, it can perform more
- * granular and precise compensation.
- *
- * TODO: Currently, this is applied only to smart battery. Apply it to other
- * battery drivers as needed.
- */
-void battery_compensate_params(struct batt_params *batt);
-
-#endif /* __CROS_EC_BATTERY_H */
diff --git a/include/battery_fuel_gauge.h b/include/battery_fuel_gauge.h
deleted file mode 100644
index d610b7e417..0000000000
--- a/include/battery_fuel_gauge.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Copyright 2018 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 fuel gauge parameters
- */
-
-#ifndef __CROS_EC_BATTERY_FUEL_GAUGE_H
-#define __CROS_EC_BATTERY_FUEL_GAUGE_H
-
-#include "battery.h"
-
-/* Number of writes needed to invoke battery cutoff command */
-#define SHIP_MODE_WRITES 2
-
-struct ship_mode_info {
- /*
- * Write Block Support. If wb_support is true, then we use a i2c write
- * block command instead of a 16-bit write. The effective difference is
- * that the i2c transaction will prefix the length (2) when wb_support
- * is enabled.
- */
- const uint8_t wb_support;
- const uint8_t reg_addr;
- const uint16_t reg_data[SHIP_MODE_WRITES];
-};
-
-struct fet_info {
- const int mfgacc_support;
- const uint8_t reg_addr;
- const uint16_t reg_mask;
- const uint16_t disconnect_val;
-};
-
-struct fuel_gauge_info {
- const char *manuf_name;
- const char *device_name;
- const uint8_t override_nil;
- const struct ship_mode_info ship_mode;
- const struct fet_info fet;
-
-#ifdef CONFIG_BATTERY_MEASURE_IMBALANCE
- /* See battery_*_imbalance_mv() for functions which are suitable. */
- int (*imbalance_mv)(void);
-#endif
-};
-
-struct board_batt_params {
- const struct fuel_gauge_info fuel_gauge;
- const struct battery_info batt_info;
-};
-
-/* Forward declare board specific data used by common code */
-extern const struct board_batt_params board_battery_info[];
-extern const enum battery_type DEFAULT_BATTERY_TYPE;
-
-
-#ifdef CONFIG_BATTERY_MEASURE_IMBALANCE
-/**
- * Report the absolute difference between the highest and lowest cell voltage in
- * the battery pack, in millivolts. On error or unimplemented, returns '0'.
- */
-int battery_default_imbalance_mv(void);
-
-#ifdef CONFIG_BATTERY_BQ4050
-int battery_bq4050_imbalance_mv(void);
-#endif
-
-#endif
-
-/**
- * Battery cut off command via SMBus write block.
- *
- * @param ship_mode Battery ship mode information
- * @return non-zero if error
- */
-int cut_off_battery_block_write(const struct ship_mode_info *ship_mode);
-
-/**
- * Battery cut off command via SMBus write word.
- *
- * @param ship_mode Battery ship mode information
- * @return non-zero if error
- */
-int cut_off_battery_sb_write(const struct ship_mode_info *ship_mode);
-
-#endif /* __CROS_EC_BATTERY_FUEL_GAUGE_H */