summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-01-20 12:17:35 -0700
committerCommit Bot <commit-bot@chromium.org>2020-01-28 20:22:25 +0000
commitf1e626bf81bc511d713fd306395d00e857764c09 (patch)
treea96a917a27d535757f3c79f95245f8c81cf2b935
parent4eb3a5fe699247a5767ae38c66c75872f4afc575 (diff)
downloadchrome-ec-f1e626bf81bc511d713fd306395d00e857764c09.tar.gz
Charger: Remove unused charger drivers
The driver/charger directory contains a number of charger drivers which are currently unused. As a part of the refactor of the charger drivers into a structure, remove these dead files which are no longer built. BRANCH=None BUG=b:147672225 TEST='make -j buildall' Change-Id: I89629c0cef3593954b5b6431bc29be5cc5ee6e45 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2008346 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/build.mk9
-rw-r--r--driver/charger/bq24192.c277
-rw-r--r--driver/charger/bq24192.h28
-rw-r--r--driver/charger/bq24707a.c178
-rw-r--r--driver/charger/bq24707a.h44
-rw-r--r--driver/charger/bq24725.c194
-rw-r--r--driver/charger/bq24725.h50
-rw-r--r--driver/charger/bq24735.c205
-rw-r--r--driver/charger/bq24735.h57
-rw-r--r--driver/charger/bq24738.c189
-rw-r--r--driver/charger/bq24738.h57
-rw-r--r--driver/charger/bq25703.c388
-rw-r--r--driver/charger/bq25703.h75
-rw-r--r--driver/charger/bq2589x.c394
-rw-r--r--driver/charger/bq2589x.h113
-rw-r--r--include/config.h31
16 files changed, 0 insertions, 2289 deletions
diff --git a/driver/build.mk b/driver/build.mk
index 7beb937268..6bd2689e8e 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -54,19 +54,10 @@ driver-$(CONFIG_BATTERY_MM8013)+=battery/mm8013.o
# Battery charger ICs
driver-$(CONFIG_CHARGER_BD9995X)+=charger/bd9995x.o
-driver-$(CONFIG_CHARGER_BQ24192)+=charger/bq24192.o
-driver-$(CONFIG_CHARGER_BQ24707A)+=charger/bq24707a.o
driver-$(CONFIG_CHARGER_BQ24715)+=charger/bq24715.o
-driver-$(CONFIG_CHARGER_BQ24725)+=charger/bq24725.o
-driver-$(CONFIG_CHARGER_BQ24735)+=charger/bq24735.o
-driver-$(CONFIG_CHARGER_BQ24738)+=charger/bq24738.o
driver-$(CONFIG_CHARGER_BQ24770)+=charger/bq24773.o
driver-$(CONFIG_CHARGER_BQ24773)+=charger/bq24773.o
-driver-$(CONFIG_CHARGER_BQ25703)+=charger/bq25703.o
driver-$(CONFIG_CHARGER_BQ25710)+=charger/bq25710.o
-driver-$(CONFIG_CHARGER_BQ25890)+=charger/bq2589x.o
-driver-$(CONFIG_CHARGER_BQ25892)+=charger/bq2589x.o
-driver-$(CONFIG_CHARGER_BQ25895)+=charger/bq2589x.o
driver-$(CONFIG_CHARGER_ISL9237)+=charger/isl923x.o
driver-$(CONFIG_CHARGER_ISL9238)+=charger/isl923x.o
driver-$(CONFIG_CHARGER_ISL9241)+=charger/isl9241.o
diff --git a/driver/charger/bq24192.c b/driver/charger/bq24192.c
deleted file mode 100644
index 3345bab093..0000000000
--- a/driver/charger/bq24192.c
+++ /dev/null
@@ -1,277 +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.
- *
- * TI bq24192 battery charger driver.
- */
-
-#include "bq24192.h"
-#include "charger.h"
-#include "common.h"
-#include "console.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "printf.h"
-#include "util.h"
-
-/* Console output macros */
-#define CPUTS(outstr) cputs(CC_CHARGER, outstr)
-#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
-
-/* Charger information */
-static const struct charger_info bq24192_charger_info = {
- .name = "bq24192",
- .voltage_max = 4400,
- .voltage_min = 3504,
- .voltage_step = 16,
- .current_max = 4544,
- .current_min = 512,
- .current_step = 64,
- .input_current_max = 3000,
- .input_current_min = 100,
- .input_current_step = -1,
-};
-
-static const int input_current_steps[] = {
- 100, 150, 500, 900, 1200, 1500, 2000, 3000};
-
-static int bq24192_read(int reg, int *value)
-{
- return i2c_read8(I2C_PORT_CHARGER, BQ24192_ADDR, reg, value);
-}
-
-static int bq24192_write(int reg, int value)
-{
- return i2c_write8(I2C_PORT_CHARGER, BQ24192_ADDR, reg, value);
-}
-
-static int bq24192_watchdog_reset(void)
-{
- int rv, val;
-
- rv = bq24192_read(BQ24192_REG_POWER_ON_CFG, &val);
- if (rv)
- return rv;
- val |= BIT(6);
- return bq24192_write(BQ24192_REG_POWER_ON_CFG, val) ||
- bq24192_write(BQ24192_REG_POWER_ON_CFG, val);
-}
-
-static int bq24192_set_terminate_current(int current)
-{
- int reg_val, rv;
- int val = (current - 128) / 128;
-
- rv = bq24192_read(BQ24192_REG_PRE_CHG_CURRENT, &reg_val);
- if (rv)
- return rv;
- reg_val = (reg_val & ~0xf) | (val & 0xf);
- return bq24192_write(BQ24192_REG_PRE_CHG_CURRENT, reg_val);
-}
-
-#ifdef CONFIG_CHARGER_OTG
-int charger_enable_otg_power(int enabled)
-{
- int val, rv;
-
- gpio_set_level(GPIO_BCHGR_OTG, enabled);
- rv = bq24192_read(BQ24192_REG_POWER_ON_CFG, &val);
- if (rv)
- return rv;
- val = (val & ~0x30) | (enabled ? 0x20 : 0x10);
- return bq24192_write(BQ24192_REG_POWER_ON_CFG, val);
-}
-#endif
-
-int charger_set_input_current(int input_current)
-{
- int i, value, rv;
-
- for (i = 1; i < ARRAY_SIZE(input_current_steps); ++i)
- if (input_current_steps[i] > input_current) {
- --i;
- break;
- }
- if (i == ARRAY_SIZE(input_current_steps))
- --i;
-
- rv = bq24192_read(BQ24192_REG_INPUT_CTRL, &value);
- if (rv)
- return rv;
- value = value & ~(0x7);
- value |= (i & 0x7);
- return bq24192_write(BQ24192_REG_INPUT_CTRL, value);
-}
-
-int charger_get_input_current(int *input_current)
-{
- int rv, value;
-
- rv = bq24192_read(BQ24192_REG_INPUT_CTRL, &value);
- if (rv)
- return rv;
- *input_current = input_current_steps[value & 0x7];
- return EC_SUCCESS;
-}
-
-int charger_manufacturer_id(int *id)
-{
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-int charger_device_id(int *id)
-{
- return bq24192_read(BQ24192_REG_ID, id);
-}
-
-int charger_get_option(int *option)
-{
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-int charger_set_option(int option)
-{
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-const struct charger_info *charger_get_info(void)
-{
- return &bq24192_charger_info;
-}
-
-int charger_get_status(int *status)
-{
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-int charger_set_mode(int mode)
-{
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-int charger_get_current(int *current)
-{
- int rv, val;
- const struct charger_info * const info = charger_get_info();
-
- rv = bq24192_read(BQ24192_REG_CHG_CURRENT, &val);
- if (rv)
- return rv;
- val = (val >> 2) & 0x3f;
- *current = val * info->current_step + info->current_min;
- return EC_SUCCESS;
-}
-
-int charger_set_current(int current)
-{
- int rv, val;
- const struct charger_info * const info = charger_get_info();
-
- current = charger_closest_current(current);
- rv = bq24192_read(BQ24192_REG_CHG_CURRENT, &val);
- if (rv)
- return rv;
- val = val & 0x3;
- val |= ((current - info->current_min) / info->current_step) << 2;
- return bq24192_write(BQ24192_REG_CHG_CURRENT, val);
-}
-
-int charger_get_voltage(int *voltage)
-{
- int rv, val;
- const struct charger_info * const info = charger_get_info();
-
- rv = bq24192_read(BQ24192_REG_CHG_VOLTAGE, &val);
- if (rv)
- return rv;
- val = (val >> 2) & 0x3f;
- *voltage = val * info->voltage_step + info->voltage_min;
- return EC_SUCCESS;
-}
-
-int charger_set_voltage(int voltage)
-{
- int rv, val;
- const struct charger_info * const info = charger_get_info();
-
- rv = bq24192_read(BQ24192_REG_CHG_VOLTAGE, &val);
- if (rv)
- return rv;
- val = val & 0x3;
- val |= ((voltage - info->voltage_min) / info->voltage_step) << 2;
- return bq24192_write(BQ24192_REG_CHG_VOLTAGE, val);
-}
-
-/* Charging power state initialization */
-int charger_post_init(void)
-{
- /* Input current controlled by extpower module. Do nothing here. */
- return EC_SUCCESS;
-}
-
-
-/*****************************************************************************/
-/* Hooks */
-
-static void bq24192_init(void)
-{
- int val;
-
- if (charger_device_id(&val) || val != BQ24192_DEVICE_ID) {
- CPRINTF("BQ24192 incorrent ID: 0x%02x\n", val);
- return;
- }
-
- /*
- * Disable I2C watchdog timer.
- *
- * TODO(crosbug.com/p/22238): Re-enable watchdog timer and kick it
- * periodically in charger task.
- */
- if (bq24192_read(BQ24192_REG_CHG_TERM_TMR, &val))
- return;
-
- val &= ~0x30;
-
- if (bq24192_write(BQ24192_REG_CHG_TERM_TMR, val))
- return;
-
- if (bq24192_set_terminate_current(128))
- return;
-
- if (bq24192_watchdog_reset())
- return;
-
- CPRINTF("BQ24192 initialized\n");
-}
-DECLARE_HOOK(HOOK_INIT, bq24192_init, HOOK_PRIO_LAST);
-
-/*****************************************************************************/
-/* Console commands */
-#ifdef CONFIG_CMD_CHARGER
-static int command_bq24192(int argc, char **argv)
-{
- int i;
- int value;
- int rv;
-
- ccprintf("REG:");
- for (i = 0; i <= 0xa; ++i)
- ccprintf(" %02x", i);
- ccprintf("\n");
-
- ccprintf("VAL:");
- for (i = 0; i <= 0xa; ++i) {
- rv = bq24192_read(i, &value);
- if (rv)
- return rv;
- ccprintf(" %02x", value);
- }
- ccprintf("\n");
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(bq24192, command_bq24192,
- NULL, NULL);
-#endif
diff --git a/driver/charger/bq24192.h b/driver/charger/bq24192.h
deleted file mode 100644
index b82fe93a02..0000000000
--- a/driver/charger/bq24192.h
+++ /dev/null
@@ -1,28 +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.
- *
- * TI bq24192 battery charger driver.
- */
-
-#ifndef __CROS_EC_BQ24192_H
-#define __CROS_EC_BQ24192_H
-
-#define BQ24192_ADDR_FLAGS 0x6b
-
-/* Registers */
-#define BQ24192_REG_INPUT_CTRL 0x0
-#define BQ24192_REG_POWER_ON_CFG 0x1
-#define BQ24192_REG_CHG_CURRENT 0x2
-#define BQ24192_REG_PRE_CHG_CURRENT 0x3
-#define BQ24192_REG_CHG_VOLTAGE 0x4
-#define BQ24192_REG_CHG_TERM_TMR 0x5
-#define BQ24192_REG_IR_COMP 0x6
-#define BQ24192_REG_MISC_OP 0x7
-#define BQ24192_REG_STATUS 0x8
-#define BQ24192_REG_FAULT 0x9
-#define BQ24192_REG_ID 0xa
-
-#define BQ24192_DEVICE_ID 0x2b
-
-#endif /* __CROS_EC_BQ24192_H */
diff --git a/driver/charger/bq24707a.c b/driver/charger/bq24707a.c
deleted file mode 100644
index 53e3f5b531..0000000000
--- a/driver/charger/bq24707a.c
+++ /dev/null
@@ -1,178 +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.
- *
- * TI bq24707A battery charger driver.
- */
-
-#include "battery_smart.h"
-#include "bq24707a.h"
-#include "charger.h"
-#include "console.h"
-#include "common.h"
-#include "i2c.h"
-#include "util.h"
-
-/* Sense resistor configurations and macros */
-#define DEFAULT_SENSE_RESISTOR 10
-#define R_SNS CONFIG_CHARGER_SENSE_RESISTOR
-#define R_AC CONFIG_CHARGER_SENSE_RESISTOR_AC
-#define REG_TO_CURRENT(REG, RS) ((REG) * DEFAULT_SENSE_RESISTOR / (RS))
-#define CURRENT_TO_REG(CUR, RS) ((CUR) * (RS) / DEFAULT_SENSE_RESISTOR)
-
-/*
- * charge voltage bitmask: 0111 1111 1111 0000
- * charge current bitmask: 0001 1111 1100 0000
- * input current bitmask : 0001 1111 1000 0000
- */
-static const struct charger_info bq24707a_charger_info = {
- .name = "bq24707A",
- .voltage_max = 19200,
- .voltage_min = 1024,
- .voltage_step = 16,
- .current_max = REG_TO_CURRENT(0x1fc0, R_SNS),
- .current_min = REG_TO_CURRENT(0x40, R_SNS),
- .current_step = REG_TO_CURRENT(0x40, R_SNS),
- .input_current_max = REG_TO_CURRENT(0x1F80, R_AC),
- .input_current_min = REG_TO_CURRENT(0x80, R_AC),
- .input_current_step = REG_TO_CURRENT(0x80, R_AC),
-};
-
-/* bq24707a specific interfaces */
-
-static inline int sbc_read(int cmd, int *param)
-{
- return i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, cmd, param);
-}
-
-static inline int sbc_write(int cmd, int param)
-{
- return i2c_write16(I2C_PORT_CHARGER, CHARGER_ADDR, cmd, param);
-}
-
-int charger_set_input_current(int input_current)
-{
- return sbc_write(BQ24707_INPUT_CURRENT,
- CURRENT_TO_REG(input_current, R_AC));
-}
-
-int charger_get_input_current(int *input_current)
-{
- int rv;
- int reg;
-
- rv = sbc_read(BQ24707_INPUT_CURRENT, &reg);
- if (rv)
- return rv;
-
- *input_current = REG_TO_CURRENT(reg, R_AC);
-
- return EC_SUCCESS;
-}
-
-int charger_manufacturer_id(int *id)
-{
- return sbc_read(BQ24707_MANUFACTURE_ID, id);
-}
-
-int charger_device_id(int *id)
-{
- return sbc_read(BQ24707_DEVICE_ID, id);
-}
-
-int charger_get_option(int *option)
-{
- return sbc_read(BQ24707_CHARGE_OPTION, option);
-}
-
-int charger_set_option(int option)
-{
- return sbc_write(BQ24707_CHARGE_OPTION, option);
-}
-
-/* Charger interfaces */
-
-const struct charger_info *charger_get_info(void)
-{
- return &bq24707a_charger_info;
-}
-
-int charger_get_status(int *status)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- /* Default status */
- *status = CHARGER_LEVEL_2;
-
- if (option & OPTION_CHARGE_INHIBIT)
- *status |= CHARGER_CHARGE_INHIBITED;
-
- return EC_SUCCESS;
-}
-
-int charger_set_mode(int mode)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- if (mode & CHARGE_FLAG_INHIBIT_CHARGE)
- option |= OPTION_CHARGE_INHIBIT;
- else
- option &= ~OPTION_CHARGE_INHIBIT;
- return charger_set_option(option);
-}
-
-int charger_get_current(int *current)
-{
- int rv;
- int reg;
-
- rv = sbc_read(SB_CHARGING_CURRENT, &reg);
- if (rv)
- return rv;
-
- *current = REG_TO_CURRENT(reg, R_SNS);
- return EC_SUCCESS;
-}
-
-int charger_set_current(int current)
-{
- current = charger_closest_current(current);
-
- return sbc_write(SB_CHARGING_CURRENT, CURRENT_TO_REG(current, R_SNS));
-}
-
-int charger_get_voltage(int *voltage)
-{
- return sbc_read(SB_CHARGING_VOLTAGE, voltage);
-}
-
-int charger_set_voltage(int voltage)
-{
- return sbc_write(SB_CHARGING_VOLTAGE, voltage);
-}
-
-/* Charging power state initialization */
-int charger_post_init(void)
-{
- /*
- * Note: bq24725 power on reset state is:
- * watch dog timer = 175 sec
- * input current limit = ~1/2 maximum setting
- * charging voltage = 0 mV
- * charging current = 0 mA
- * IOUT = 20x adapter current sense
- */
-
- /* Set charger input current limit */
- return charger_set_input_current(CONFIG_CHARGER_INPUT_CURRENT);
-}
diff --git a/driver/charger/bq24707a.h b/driver/charger/bq24707a.h
deleted file mode 100644
index c26a0eea35..0000000000
--- a/driver/charger/bq24707a.h
+++ /dev/null
@@ -1,44 +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.
- *
- * TI bq24707A battery charger driver.
- */
-
-#ifndef __CROS_EC_BQ24707A_H
-#define __CROS_EC_BQ24707A_H
-
-/* Chip specific commands */
-#define BQ24707_CHARGE_OPTION 0x12
-#define BQ24707_INPUT_CURRENT 0x3f
-#define BQ24707_MANUFACTURE_ID 0xfe
-#define BQ24707_DEVICE_ID 0xff
-
-/* ChargeOption 0x12 */
-#define OPTION_CHARGE_INHIBIT BIT(0)
-#define OPTION_ACOC_THRESHOLD (3 << 1)
-#define OPTION_COMPARATOR_THRESHOLD BIT(4)
-#define OPTION_IOUT_SELECTION BIT(5)
-#define OPTION_IFAULT_HI_THRESHOLD (3 << 7)
-#define OPTION_EMI_FREQ_ENABLE BIT(9)
-#define OPTION_EMI_FREQ_ADJ BIT(10)
-#define OPTION_WATCHDOG_TIMER (3 << 13)
-#define OPTION_AOC_DELITCH_TIME BIT(15)
-/* OPTION_ACOC_THRESHOLD */
-#define ACOC_THRESHOLD_DISABLE (0 << 1)
-#define ACOC_THRESHOLD_133X BIT(1)
-#define ACOC_THRESHOLD_166X_DEFAULT (2 << 1)
-#define ACOC_THRESHOLD_222X (3 << 1)
-/* OPTION_IFAULT_HI_THRESHOLD */
-#define IFAULT_THRESHOLD_300MV (0 << 7)
-#define IFAULT_THRESHOLD_500MV BIT(7)
-#define IFAULT_THRESHOLD_700MV_DEFAULT (2 << 7)
-#define IFAULT_THRESHOLD_900MV (3 << 7)
-/* OPTION_WATCHDOG_TIMER */
-#define CHARGE_WATCHDOG_DISABLE (0 << 13)
-#define CHARGE_WATCHDOG_44SEC BIT(13)
-#define CHARGE_WATCHDOG_88SEC (2 << 13)
-#define CHARGE_WATCHDOG_175SEC_DEFAULT (3 << 13)
-
-#endif /* __CROS_EC_BQ24707A_H */
-
diff --git a/driver/charger/bq24725.c b/driver/charger/bq24725.c
deleted file mode 100644
index 48f53a05c4..0000000000
--- a/driver/charger/bq24725.c
+++ /dev/null
@@ -1,194 +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.
- *
- * TI bq24725 battery charger driver.
- */
-
-#include "battery_smart.h"
-#include "bq24725.h"
-#include "charger.h"
-#include "console.h"
-#include "common.h"
-#include "util.h"
-
-/* Sense resistor configurations and macros */
-#define DEFAULT_SENSE_RESISTOR 10
-#define R_SNS CONFIG_CHARGER_SENSE_RESISTOR
-#define R_AC CONFIG_CHARGER_SENSE_RESISTOR_AC
-#define REG_TO_CURRENT(REG, RS) ((REG) * DEFAULT_SENSE_RESISTOR / (RS))
-#define CURRENT_TO_REG(CUR, RS) ((CUR) * (RS) / DEFAULT_SENSE_RESISTOR)
-
-/* Charger information
- * charge voltage bitmask: 0111 1111 1111 0000
- * charge current bitmask: 0001 1111 1000 0000
- * input current bitmask : 0000 0000 1000 0000
- */
-static const struct charger_info bq24725_charger_info = {
- .name = "bq24725",
- .voltage_max = 19200,
- .voltage_min = 1024,
- .voltage_step = 16,
- .current_max = REG_TO_CURRENT(8128, R_SNS),
- .current_min = REG_TO_CURRENT(128, R_SNS),
- .current_step = REG_TO_CURRENT(128, R_SNS),
- .input_current_max = REG_TO_CURRENT(8064, R_AC),
- .input_current_min = REG_TO_CURRENT(128, R_AC),
- .input_current_step = REG_TO_CURRENT(128, R_AC),
-};
-
-/* bq24725 specific interfaces */
-
-int charger_set_input_current(int input_current)
-{
- return sbc_write(BQ24725_INPUT_CURRENT,
- CURRENT_TO_REG(input_current, R_AC));
-}
-
-int charger_get_input_current(int *input_current)
-{
- int rv;
- int reg;
-
- rv = sbc_read(BQ24725_INPUT_CURRENT, &reg);
- if (rv)
- return rv;
-
- *input_current = REG_TO_CURRENT(reg, R_AC);
-
- return EC_SUCCESS;
-}
-
-int charger_manufacturer_id(int *id)
-{
- return sbc_read(BQ24725_MANUFACTURE_ID, id);
-}
-
-int charger_device_id(int *id)
-{
- return sbc_read(BQ24725_DEVICE_ID, id);
-}
-
-int charger_get_option(int *option)
-{
- return sbc_read(BQ24725_CHARGE_OPTION, option);
-}
-
-int charger_set_option(int option)
-{
- return sbc_write(BQ24725_CHARGE_OPTION, option);
-}
-
-/* Charger interfaces */
-
-const struct charger_info *charger_get_info(void)
-{
- return &bq24725_charger_info;
-}
-
-int charger_get_status(int *status)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- /* Default status */
- *status = CHARGER_LEVEL_2;
-
- if (option & OPTION_CHARGE_INHIBIT)
- *status |= CHARGER_CHARGE_INHIBITED;
-
- return EC_SUCCESS;
-}
-
-int charger_set_mode(int mode)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- if (mode & CHARGE_FLAG_INHIBIT_CHARGE)
- option |= OPTION_CHARGE_INHIBIT;
- else
- option &= ~OPTION_CHARGE_INHIBIT;
- return charger_set_option(option);
-}
-
-int charger_get_current(int *current)
-{
- int rv;
- int reg;
-
- rv = sbc_read(SB_CHARGING_CURRENT, &reg);
- if (rv)
- return rv;
-
- *current = REG_TO_CURRENT(reg, R_SNS);
- return EC_SUCCESS;
-}
-
-int charger_set_current(int current)
-{
- current = charger_closest_current(current);
-
- return sbc_write(SB_CHARGING_CURRENT, CURRENT_TO_REG(current, R_SNS));
-}
-
-int charger_get_voltage(int *voltage)
-{
- return sbc_read(SB_CHARGING_VOLTAGE, voltage);
-}
-
-int charger_set_voltage(int voltage)
-{
- return sbc_write(SB_CHARGING_VOLTAGE, voltage);
-}
-
-/* Charging power state initialization */
-int charger_post_init(void)
-{
- /*
- * Note: bq24725 power on reset state is:
- * watch dog timer = 175 sec
- * input current limit = ~1/2 maximum setting
- * charging voltage = 0 mV
- * charging current = 0 mA
- */
-
- int rv, option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- option &= ~OPTION_LEARN_ENABLE;
- rv = charger_set_option(option);
- if (rv)
- return rv;
-
- /* Set charger input current limit */
- return charger_set_input_current(CONFIG_CHARGER_INPUT_CURRENT);
-}
-
-int charger_discharge_on_ac(int enable)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- if (enable)
- rv = charger_set_option(option | OPTION_LEARN_ENABLE);
- else
- rv = charger_set_option(option & ~OPTION_LEARN_ENABLE);
-
- return rv;
-}
diff --git a/driver/charger/bq24725.h b/driver/charger/bq24725.h
deleted file mode 100644
index ad6c508a4f..0000000000
--- a/driver/charger/bq24725.h
+++ /dev/null
@@ -1,50 +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.
- *
- * TI bq24725 battery charger driver.
- */
-
-#ifndef __CROS_EC_BQ24725_H
-#define __CROS_EC_BQ24725_H
-
-/* Chip specific commands */
-#define BQ24725_CHARGE_OPTION 0x12
-#define BQ24725_INPUT_CURRENT 0x3f
-#define BQ24725_MANUFACTURE_ID 0xfe
-#define BQ24725_DEVICE_ID 0xff
-
-/* ChargeOption 0x12 */
-#define OPTION_CHARGE_INHIBIT BIT(0)
-#define OPTION_ACOC_THRESHOLD (3 << 1)
-#define OPTION_IOUT_SELECTION BIT(5)
-#define OPTION_LEARN_ENABLE BIT(6)
-#define OPTION_IFAULT_HI_THRESHOLD (3 << 7)
-#define OPTION_EMI_FREQ_ENABLE BIT(9)
-#define OPTION_EMI_FREQ_ADJ BIT(10)
-#define OPTION_BAT_DEPLETION_THRESHOLD (3 << 11)
-#define OPTION_WATCHDOG_TIMER (3 << 13)
-#define OPTION_AOC_DELITCH_TIME BIT(15)
-/* OPTION_ACOC_THRESHOLD */
-#define ACOC_THRESHOLD_DISABLE (0 << 1)
-#define ACOC_THRESHOLD_133X BIT(1)
-#define ACOC_THRESHOLD_166X_DEFAULT (2 << 1)
-#define ACOC_THRESHOLD_222X (3 << 1)
-/* OPTION_IFAULT_HI_THRESHOLD */
-#define IFAULT_THRESHOLD_300MV (0 << 7)
-#define IFAULT_THRESHOLD_500MV BIT(7)
-#define IFAULT_THRESHOLD_700MV_DEFAULT (2 << 7)
-#define IFAULT_THRESHOLD_900MV (3 << 7)
-/* OPTION_BAT_DEPLETION_THRESHOLD */
-#define FALLING_THRESHOLD_5919 (0 << 11)
-#define FALLING_THRESHOLD_6265 BIT(11)
-#define FALLING_THRESHOLD_6655 (2 << 11)
-#define FALLING_THRESHOLD_7097_DEFAULT (3 << 11)
-/* OPTION_WATCHDOG_TIMER */
-#define CHARGE_WATCHDOG_DISABLE (0 << 13)
-#define CHARGE_WATCHDOG_44SEC BIT(13)
-#define CHARGE_WATCHDOG_88SEC (2 << 13)
-#define CHARGE_WATCHDOG_175SEC_DEFAULT (3 << 13)
-
-#endif /* __CROS_EC_BQ24725_H */
-
diff --git a/driver/charger/bq24735.c b/driver/charger/bq24735.c
deleted file mode 100644
index 65fe353f9d..0000000000
--- a/driver/charger/bq24735.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* Copyright 2014 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.
- *
- * TI bq24735 battery charger driver.
- */
-
-#include "battery_smart.h"
-#include "bq24735.h"
-#include "charger.h"
-#include "console.h"
-#include "common.h"
-#include "i2c.h"
-#include "util.h"
-
-/* Sense resistor configurations and macros */
-#define DEFAULT_SENSE_RESISTOR 10
-#define R_SNS CONFIG_CHARGER_SENSE_RESISTOR
-#define R_AC CONFIG_CHARGER_SENSE_RESISTOR_AC
-#define REG_TO_CURRENT(REG, RS) ((REG) * DEFAULT_SENSE_RESISTOR / (RS))
-#define CURRENT_TO_REG(CUR, RS) ((CUR) * (RS) / DEFAULT_SENSE_RESISTOR)
-
-/* Charger information
- * charge voltage bitmask: 0111 1111 1111 0000
- * charge current bitmask: 0001 1111 1000 0000
- * input current bitmask : 0000 0000 1000 0000
- */
-static const struct charger_info bq24735_charger_info = {
- .name = "bq24735",
- .voltage_max = 19200,
- .voltage_min = 1024,
- .voltage_step = 16,
- .current_max = REG_TO_CURRENT(8128, R_SNS),
- .current_min = REG_TO_CURRENT(128, R_SNS),
- .current_step = REG_TO_CURRENT(128, R_SNS),
- .input_current_max = REG_TO_CURRENT(8064, R_AC),
- .input_current_min = REG_TO_CURRENT(128, R_AC),
- .input_current_step = REG_TO_CURRENT(128, R_AC),
-};
-
-/* bq24735 specific interfaces */
-
-static inline int sbc_read(int cmd, int *param)
-{
- return i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, cmd, param);
-}
-
-static inline int sbc_write(int cmd, int param)
-{
- return i2c_write16(I2C_PORT_CHARGER, CHARGER_ADDR, cmd, param);
-}
-
-int charger_set_input_current(int input_current)
-{
- return sbc_write(BQ24735_INPUT_CURRENT,
- CURRENT_TO_REG(input_current, R_AC));
-}
-
-int charger_get_input_current(int *input_current)
-{
- int rv;
- int reg;
-
- rv = sbc_read(BQ24735_INPUT_CURRENT, &reg);
- if (rv)
- return rv;
-
- *input_current = REG_TO_CURRENT(reg, R_AC);
-
- return EC_SUCCESS;
-}
-
-int charger_manufacturer_id(int *id)
-{
- return sbc_read(BQ24735_MANUFACTURE_ID, id);
-}
-
-int charger_device_id(int *id)
-{
- return sbc_read(BQ24735_DEVICE_ID, id);
-}
-
-int charger_get_option(int *option)
-{
- return sbc_read(BQ24735_CHARGE_OPTION, option);
-}
-
-int charger_set_option(int option)
-{
- return sbc_write(BQ24735_CHARGE_OPTION, option);
-}
-
-/* Charger interfaces */
-
-const struct charger_info *charger_get_info(void)
-{
- return &bq24735_charger_info;
-}
-
-int charger_get_status(int *status)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- /* Default status */
- *status = CHARGER_LEVEL_2;
-
- if (option & OPTION_CHARGE_INHIBIT)
- *status |= CHARGER_CHARGE_INHIBITED;
-
- return EC_SUCCESS;
-}
-
-int charger_set_mode(int mode)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- if (mode & CHARGE_FLAG_INHIBIT_CHARGE)
- option |= OPTION_CHARGE_INHIBIT;
- else
- option &= ~OPTION_CHARGE_INHIBIT;
- return charger_set_option(option);
-}
-
-int charger_get_current(int *current)
-{
- int rv;
- int reg;
-
- rv = sbc_read(SB_CHARGING_CURRENT, &reg);
- if (rv)
- return rv;
-
- *current = REG_TO_CURRENT(reg, R_SNS);
- return EC_SUCCESS;
-}
-
-int charger_set_current(int current)
-{
- current = charger_closest_current(current);
-
- return sbc_write(SB_CHARGING_CURRENT, CURRENT_TO_REG(current, R_SNS));
-}
-
-int charger_get_voltage(int *voltage)
-{
- return sbc_read(SB_CHARGING_VOLTAGE, voltage);
-}
-
-int charger_set_voltage(int voltage)
-{
- return sbc_write(SB_CHARGING_VOLTAGE, voltage);
-}
-
-/* Charging power state initialization */
-int charger_post_init(void)
-{
- /*
- * Note: bq24735 power on reset state is:
- * watch dog timer = 175 sec
- * input current limit = ~1/2 maximum setting
- * charging voltage = 0 mV
- * charging current = 0 mA
- */
-
- int rv, option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- option &= ~OPTION_LEARN_ENABLE;
- rv = charger_set_option(option);
- if (rv)
- return rv;
-
- /* Set charger input current limit */
- return charger_set_input_current(CONFIG_CHARGER_INPUT_CURRENT);
-}
-
-int charger_discharge_on_ac(int enable)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- if (enable)
- rv = charger_set_option(option | OPTION_LEARN_ENABLE);
- else
- rv = charger_set_option(option & ~OPTION_LEARN_ENABLE);
-
- return rv;
-}
diff --git a/driver/charger/bq24735.h b/driver/charger/bq24735.h
deleted file mode 100644
index 62d3365306..0000000000
--- a/driver/charger/bq24735.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright 2014 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.
- *
- * TI bq24735 battery charger driver.
- */
-
-#ifndef __CROS_EC_BQ24735_H
-#define __CROS_EC_BQ24735_H
-
-/* Chip specific commands */
-#define BQ24735_CHARGE_OPTION 0x12
-#define BQ24735_INPUT_CURRENT 0x3f
-#define BQ24735_MANUFACTURE_ID 0xfe
-#define BQ24735_DEVICE_ID 0xff
-
-/* ChargeOption 0x12 */
-#define OPTION_CHARGE_INHIBIT BIT(0)
-#define OPTION_ACOC_THRESHOLD BIT(1)
-#define OPTION_BOOST_MODE_STATE BIT(2)
-#define OPTION_BOOST_MODE_ENABLE BIT(3)
-#define OPTION_ACDET_STATE BIT(4)
-#define OPTION_IOUT_SELECTION BIT(5)
-#define OPTION_LEARN_ENABLE BIT(6)
-#define OPTION_IFAULT_LOW_THRESHOLD BIT(7)
-#define OPTION_IFAULT_HI_ENABLE BIT(8)
-#define OPTION_EMI_FREQ_ENABLE BIT(9)
-#define OPTION_EMI_FREQ_ADJ BIT(10)
-#define OPTION_BAT_DEPLETION_THRESHOLD (3 << 11)
-#define OPTION_WATCHDOG_TIMER (3 << 13)
-#define OPTION_ACPRES_DEGLITCH_TIME BIT(15)
-
-/* OPTION_ACOC_THRESHOLD */
-#define ACOC_THRESHOLD_DISABLE (0 << 1)
-#define ACOC_THRESHOLD_133X BIT(1)
-
-/* OPTION_IFAULT_LOW_THRESHOLD */
-#define IFAULT_LOW_135MV_DEFAULT (0 << 7)
-#define IFAULT_LOW_230MV BIT(7)
-
-/* OPTION_BAT_DEPLETION_THRESHOLD */
-#define FALLING_THRESHOLD_5919 (0 << 11)
-#define FALLING_THRESHOLD_6265 BIT(11)
-#define FALLING_THRESHOLD_6655 (2 << 11)
-#define FALLING_THRESHOLD_7097_DEFAULT (3 << 11)
-
-/* OPTION_WATCHDOG_TIMER */
-#define CHARGE_WATCHDOG_DISABLE (0 << 13)
-#define CHARGE_WATCHDOG_44SEC BIT(13)
-#define CHARGE_WATCHDOG_88SEC (2 << 13)
-#define CHARGE_WATCHDOG_175SEC_DEFAULT (3 << 13)
-
-/* OPTION_ACPRES_DEGLITCH_TIME */
-#define ACPRES_DEGLITCH_150MS (0 << 15)
-#define ACPRES_DEGLITCH_1300MS_DEFAULT BIT(15)
-
-#endif /* __CROS_EC_BQ24735_H */
diff --git a/driver/charger/bq24738.c b/driver/charger/bq24738.c
deleted file mode 100644
index 507ee3bf62..0000000000
--- a/driver/charger/bq24738.c
+++ /dev/null
@@ -1,189 +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.
- *
- * TI bq24738 battery charger driver.
- */
-
-#include "battery_smart.h"
-#include "bq24738.h"
-#include "charger.h"
-#include "console.h"
-#include "common.h"
-#include "util.h"
-
-/* Sense resistor configurations and macros */
-#define DEFAULT_SENSE_RESISTOR 10
-#define R_SNS CONFIG_CHARGER_SENSE_RESISTOR
-#define R_AC CONFIG_CHARGER_SENSE_RESISTOR_AC
-#define REG_TO_CURRENT(REG, RS) ((REG) * DEFAULT_SENSE_RESISTOR / (RS))
-#define CURRENT_TO_REG(CUR, RS) ((CUR) * (RS) / DEFAULT_SENSE_RESISTOR)
-
-/* Charger information
- * charge voltage bitmask: 0111 1111 1111 0000
- * charge current bitmask: 0001 1111 1100 0000
- * input current bitmask : 0000 0000 1000 0000
- */
-static const struct charger_info bq24738_charger_info = {
- .name = "bq24738",
- .voltage_max = 19200,
- .voltage_min = 1024,
- .voltage_step = 16,
- .current_max = REG_TO_CURRENT(8128, R_SNS),
- .current_min = REG_TO_CURRENT(128, R_SNS),
- .current_step = REG_TO_CURRENT(64, R_SNS),
- .input_current_max = REG_TO_CURRENT(8064, R_AC),
- .input_current_min = REG_TO_CURRENT(128, R_AC),
- .input_current_step = REG_TO_CURRENT(128, R_AC),
-};
-
-/* bq24738 specific interfaces */
-
-int charger_set_input_current(int input_current)
-{
- return sbc_write(BQ24738_INPUT_CURRENT,
- CURRENT_TO_REG(input_current, R_AC));
-}
-
-int charger_get_input_current(int *input_current)
-{
- int rv;
- int reg;
-
- rv = sbc_read(BQ24738_INPUT_CURRENT, &reg);
- if (rv)
- return rv;
-
- *input_current = REG_TO_CURRENT(reg, R_AC);
-
- return EC_SUCCESS;
-}
-
-int charger_manufacturer_id(int *id)
-{
- return sbc_read(BQ24738_MANUFACTURE_ID, id);
-}
-
-int charger_device_id(int *id)
-{
- return sbc_read(BQ24738_DEVICE_ID, id);
-}
-
-int charger_get_option(int *option)
-{
- return sbc_read(BQ24738_CHARGE_OPTION, option);
-}
-
-int charger_set_option(int option)
-{
- return sbc_write(BQ24738_CHARGE_OPTION, option);
-}
-
-/* Charger interfaces */
-
-const struct charger_info *charger_get_info(void)
-{
- return &bq24738_charger_info;
-}
-
-int charger_get_status(int *status)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- /* Default status */
- *status = CHARGER_LEVEL_2;
-
- if (option & OPTION_CHARGE_INHIBIT)
- *status |= CHARGER_CHARGE_INHIBITED;
-
- return EC_SUCCESS;
-}
-
-int charger_set_mode(int mode)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- if (mode & CHARGE_FLAG_INHIBIT_CHARGE)
- option |= OPTION_CHARGE_INHIBIT;
- else
- option &= ~OPTION_CHARGE_INHIBIT;
- return charger_set_option(option);
-}
-
-int charger_get_current(int *current)
-{
- int rv;
- int reg;
-
- rv = sbc_read(SB_CHARGING_CURRENT, &reg);
- if (rv)
- return rv;
-
- *current = REG_TO_CURRENT(reg, R_SNS);
- return EC_SUCCESS;
-}
-
-int charger_set_current(int current)
-{
- current = charger_closest_current(current);
-
- return sbc_write(SB_CHARGING_CURRENT, CURRENT_TO_REG(current, R_SNS));
-}
-
-int charger_get_voltage(int *voltage)
-{
- return sbc_read(SB_CHARGING_VOLTAGE, voltage);
-}
-
-int charger_set_voltage(int voltage)
-{
- return sbc_write(SB_CHARGING_VOLTAGE, voltage);
-}
-
-/* Charging power state initialization */
-int charger_post_init(void)
-{
- int rv;
- int val;
-
- /* Disable IFAULT_HI. See crosbug.com/p/19868 */
- rv = charger_get_option(&val);
- if (rv)
- return rv;
- val &= ~OPTION_IFAULT_HI_ENABLE;
- val &= ~OPTION_LEARN_ENABLE;
- rv = charger_set_option(val);
- if (rv)
- return rv;
-
- /* Set charger input current limit */
- rv = charger_set_input_current(CONFIG_CHARGER_INPUT_CURRENT);
- return rv;
-}
-
-int charger_discharge_on_ac(int enable)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- if (enable)
- rv = charger_set_option(option | OPTION_LEARN_ENABLE);
- else
- rv = charger_set_option(option & ~OPTION_LEARN_ENABLE);
-
- return rv;
-}
diff --git a/driver/charger/bq24738.h b/driver/charger/bq24738.h
deleted file mode 100644
index c06d1729b0..0000000000
--- a/driver/charger/bq24738.h
+++ /dev/null
@@ -1,57 +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.
- *
- * TI bq24738 battery charger driver.
- */
-
-#ifndef __CROS_EC_BQ24738_H
-#define __CROS_EC_BQ24738_H
-
-/* Chip specific commands */
-#define BQ24738_CHARGE_OPTION 0x12
-#define BQ24738_INPUT_CURRENT 0x3f
-#define BQ24738_MANUFACTURE_ID 0xfe
-#define BQ24738_DEVICE_ID 0xff
-
-/* ChargeOption 0x12 */
-#define OPTION_CHARGE_INHIBIT BIT(0)
-#define OPTION_ACOC_THRESHOLD BIT(1)
-#define OPTION_BOOST_MODE_STATE BIT(2)
-#define OPTION_BOOST_MODE_ENABLE BIT(3)
-#define OPTION_ACDET_STATE BIT(4)
-#define OPTION_IOUT_SELECTION BIT(5)
-#define OPTION_LEARN_ENABLE BIT(6)
-#define OPTION_IFAULT_LOW_THRESHOLD BIT(7)
-#define OPTION_IFAULT_HI_ENABLE BIT(8)
-#define OPTION_EMI_FREQ_ENABLE BIT(9)
-#define OPTION_EMI_FREQ_ADJ BIT(10)
-#define OPTION_BAT_DEPLETION_THRESHOLD (3 << 11)
-#define OPTION_WATCHDOG_TIMER (3 << 13)
-#define OPTION_ACPRES_DEGLITCH_TIME BIT(15)
-
-/* OPTION_ACOC_THRESHOLD */
-#define ACOC_THRESHOLD_DISABLE (0 << 1)
-#define ACOC_THRESHOLD_133X BIT(1)
-
-/* OPTION_IFAULT_LOW_THRESHOLD */
-#define IFAULT_LOW_135MV_DEFAULT (0 << 7)
-#define IFAULT_LOW_230MV BIT(7)
-
-/* OPTION_BAT_DEPLETION_THRESHOLD */
-#define FALLING_THRESHOLD_5919 (0 << 11)
-#define FALLING_THRESHOLD_6265 BIT(11)
-#define FALLING_THRESHOLD_6655 (2 << 11)
-#define FALLING_THRESHOLD_7097_DEFAULT (3 << 11)
-
-/* OPTION_WATCHDOG_TIMER */
-#define CHARGE_WATCHDOG_DISABLE (0 << 13)
-#define CHARGE_WATCHDOG_44SEC BIT(13)
-#define CHARGE_WATCHDOG_88SEC (2 << 13)
-#define CHARGE_WATCHDOG_175SEC_DEFAULT (3 << 13)
-
-/* OPTION_ACPRES_DEGLITCH_TIME */
-#define ACPRES_DEGLITCH_150MS (0 << 15)
-#define ACPRES_DEGLITCH_1300MS_DEFAULT BIT(15)
-
-#endif /* __CROS_EC_BQ24738_H */
diff --git a/driver/charger/bq25703.c b/driver/charger/bq25703.c
deleted file mode 100644
index 4d9fd2edcd..0000000000
--- a/driver/charger/bq25703.c
+++ /dev/null
@@ -1,388 +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.
- *
- * TI bq25703 battery charger driver.
- */
-
-#include "battery_smart.h"
-#include "bq25703.h"
-#include "charge_ramp.h"
-#include "charger.h"
-#include "common.h"
-#include "console.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "timer.h"
-
-/* Sense resistor configurations and macros */
-#define DEFAULT_SENSE_RESISTOR 10
-
-#define INPUT_RESISTOR_RATIO \
- ((CONFIG_CHARGER_SENSE_RESISTOR_AC) / DEFAULT_SENSE_RESISTOR)
-#define REG_TO_INPUT_CURRENT(REG) ((REG + 1) * 50 / INPUT_RESISTOR_RATIO)
-#define INPUT_CURRENT_TO_REG(CUR) (((CUR) * INPUT_RESISTOR_RATIO / 50) - 1)
-
-#define CHARGING_RESISTOR_RATIO \
- ((CONFIG_CHARGER_SENSE_RESISTOR) / DEFAULT_SENSE_RESISTOR)
-#define REG_TO_CHARGING_CURRENT(REG) ((REG) / CHARGING_RESISTOR_RATIO)
-#define CHARGING_CURRENT_TO_REG(CUR) ((CUR) * CHARGING_RESISTOR_RATIO)
-
-
-/* Console output macros */
-#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
-
-/* Charger parameters */
-static const struct charger_info bq25703_charger_info = {
- .name = "bq25703",
- .voltage_max = 19200,
- .voltage_min = 1024,
- .voltage_step = 16,
- .current_max = 8128 / CHARGING_RESISTOR_RATIO,
- .current_min = 64 / CHARGING_RESISTOR_RATIO,
- .current_step = 64 / CHARGING_RESISTOR_RATIO,
- .input_current_max = 6400 / INPUT_RESISTOR_RATIO,
- .input_current_min = 50 / INPUT_RESISTOR_RATIO,
- .input_current_step = 50 / INPUT_RESISTOR_RATIO,
-};
-
-static inline int raw_read8(int offset, int *value)
-{
- return i2c_read8(I2C_PORT_CHARGER, BQ25703_I2C_ADDR1, offset, value);
-}
-
-static inline int raw_write8(int offset, int value)
-{
- return i2c_write8(I2C_PORT_CHARGER, BQ25703_I2C_ADDR1, offset, value);
-}
-
-static inline int raw_read16(int offset, int *value)
-{
- return i2c_read16(I2C_PORT_CHARGER, BQ25703_I2C_ADDR1, offset, value);
-}
-
-static inline int raw_write16(int offset, int value)
-{
- return i2c_write16(I2C_PORT_CHARGER, BQ25703_I2C_ADDR1, offset, value);
-}
-
-#ifdef CONFIG_CHARGE_RAMP_HW
-static int bq25703_get_low_power_mode(int *mode)
-{
- int rv;
- int reg;
-
- rv = raw_read16(BQ25703_REG_CHARGE_OPTION_0, &reg);
- if (rv)
- return rv;
-
- *mode = !!(reg & BQ25703_CHARGE_OPTION_0_LOW_POWER_MODE);
-
- return EC_SUCCESS;
-}
-
-static int bq25703_set_low_power_mode(int enable)
-{
- int rv;
- int reg;
-
- rv = raw_read16(BQ25703_REG_CHARGE_OPTION_0, &reg);
- if (rv)
- return rv;
-
- if (enable)
- reg |= BQ25703_CHARGE_OPTION_0_LOW_POWER_MODE;
- else
- reg &= ~BQ25703_CHARGE_OPTION_0_LOW_POWER_MODE;
-
- rv = raw_write16(BQ25703_REG_CHARGE_OPTION_0, reg);
- if (rv)
- return rv;
-
- return EC_SUCCESS;
-}
-#endif
-
-/* Charger interfaces */
-
-const struct charger_info *charger_get_info(void)
-{
- return &bq25703_charger_info;
-}
-
-int charger_post_init(void)
-{
- /*
- * Note: bq25703 power on reset state is:
- * watch dog timer = 175 sec
- * input current limit = ~1/2 maximum setting
- * charging voltage = 0 mV
- * charging current = 0 mA
- * discharge on AC = disabled
- */
-
- /* Set charger input current limit */
- return charger_set_input_current(CONFIG_CHARGER_INPUT_CURRENT);
-}
-
-int charger_get_status(int *status)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- /* Default status */
- *status = CHARGER_LEVEL_2;
-
- if (option & BQ25703_CHARGE_OPTION_0_CHRG_INHIBIT)
- *status |= CHARGER_CHARGE_INHIBITED;
-
- return EC_SUCCESS;
-}
-
-int charger_set_mode(int mode)
-{
- int rv;
- int option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- if (mode & CHARGER_CHARGE_INHIBITED)
- option |= BQ25703_CHARGE_OPTION_0_CHRG_INHIBIT;
- else
- option &= ~BQ25703_CHARGE_OPTION_0_CHRG_INHIBIT;
-
- return charger_set_option(option);
-}
-
-int charger_enable_otg_power(int enabled)
-{
- /* This is controlled with the EN_OTG pin. Support not added yet. */
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-int charger_set_otg_current_voltage(int output_current, int output_voltage)
-{
- /* Add when needed. */
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-int charger_is_sourcing_otg_power(int port)
-{
- /* Add when needed. */
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-int charger_get_current(int *current)
-{
- int rv, reg;
-
- rv = raw_read16(BQ25703_REG_CHARGE_CURRENT, &reg);
- if (!rv)
- *current = REG_TO_CHARGING_CURRENT(reg);
-
- return rv;
-}
-
-int charger_set_current(int current)
-{
- return raw_write16(BQ25703_REG_CHARGE_CURRENT,
- CHARGING_CURRENT_TO_REG(current));
-}
-
-/* Get/set charge voltage limit in mV */
-int charger_get_voltage(int *voltage)
-{
- return raw_read16(BQ25703_REG_MAX_CHARGE_VOLTAGE, voltage);
-}
-int charger_set_voltage(int voltage)
-{
- return raw_write16(BQ25703_REG_MAX_CHARGE_VOLTAGE, voltage);
-}
-
-/* Discharge battery when on AC power. */
-int charger_discharge_on_ac(int enable)
-{
- int rv, option;
-
- rv = charger_get_option(&option);
- if (rv)
- return rv;
-
- if (enable)
- option |= BQ25703_CHARGE_OPTION_0_EN_LEARN;
- else
- option &= ~BQ25703_CHARGE_OPTION_0_EN_LEARN;
-
- return charger_set_option(option);
-}
-
-int charger_set_input_current(int input_current)
-{
- return raw_write8(BQ25703_REG_IIN_HOST,
- INPUT_CURRENT_TO_REG(input_current));
-}
-
-int charger_get_input_current(int *input_current)
-{
- int rv, reg;
-
- /*
- * IIN_DPM register reflects the actual input current limit programmed
- * in the register, either from host or from ICO. After ICO, the
- * current limit used by DPM regulation may differ from the IIN_HOST
- * register settings.
- */
- rv = raw_read8(BQ25703_REG_IIN_DPM, &reg);
- if (!rv)
- *input_current = REG_TO_INPUT_CURRENT(reg);
-
- return rv;
-}
-
-int charger_manufacturer_id(int *id)
-{
- return raw_read8(BQ25703_REG_MANUFACTURER_ID, id);
-}
-int charger_device_id(int *id)
-{
- return raw_read8(BQ25703_REG_DEVICE_ADDRESS, id);
-}
-
-int charger_get_option(int *option)
-{
- /* There are 4 option registers, but we only need the first for now. */
- return raw_read16(BQ25703_REG_CHARGE_OPTION_0, option);
-}
-
-int charger_set_option(int option)
-{
- /* There are 4 option registers, but we only need the first for now. */
- return raw_write16(BQ25703_REG_CHARGE_OPTION_0, option);
-}
-
-#ifdef CONFIG_CHARGE_RAMP_HW
-
-static void bq25703_chg_ramp_handle(void)
-{
- int ramp_curr;
-
- /*
- * Once the charge ramp is stable write back the stable ramp
- * current to input current register.
- */
- if (chg_ramp_is_stable()) {
- ramp_curr = chg_ramp_get_current_limit();
- if (ramp_curr && !charger_set_input_current(ramp_curr))
- CPRINTF("stable ramp current=%d\n", ramp_curr);
- }
-}
-DECLARE_DEFERRED(bq25703_chg_ramp_handle);
-
-int charger_set_hw_ramp(int enable)
-{
- int option3_reg, option2_reg, rv;
-
- rv = raw_read16(BQ25703_REG_CHARGE_OPTION_3, &option3_reg);
- if (rv)
- return rv;
- rv = raw_read16(BQ25703_REG_CHARGE_OPTION_2, &option2_reg);
- if (rv)
- return rv;
-
- if (enable) {
- /* Set InputVoltage register to BC1.2 minimum ramp voltage */
- rv = raw_write16(BQ25703_REG_INPUT_VOLTAGE,
- BQ25703_BC12_MIN_VOLTAGE_MV);
- if (rv)
- return rv;
-
- /* Enable ICO algorithm */
- option3_reg |= BQ25703_CHARGE_OPTION_3_EN_ICO_MODE;
-
- /* 0b: Input current limit is set by BQ25703_REG_IIN_HOST */
- option2_reg &= ~BQ25703_CHARGE_OPTION_2_EN_EXTILIM;
-
- /* Charge ramp may take up to 2s to settle down */
- hook_call_deferred(&bq25703_chg_ramp_handle_data, (4 * SECOND));
- } else {
- /* Disable ICO algorithm */
- option3_reg &= ~BQ25703_CHARGE_OPTION_3_EN_ICO_MODE;
-
- /*
- * 1b: Input current limit is set by the lower value of
- * ILIM_HIZ pin and BQ25703_REG_IIN_HOST
- */
- option2_reg |= BQ25703_CHARGE_OPTION_2_EN_EXTILIM;
- }
-
- rv = raw_write16(BQ25703_REG_CHARGE_OPTION_2, option2_reg);
- if (rv)
- return rv;
- return raw_write16(BQ25703_REG_CHARGE_OPTION_3, option3_reg);
-}
-
-int chg_ramp_is_stable(void)
-{
- int reg;
-
- if (raw_read16(BQ25703_REG_CHARGER_STATUS, &reg))
- return 0;
-
- return reg & BQ25703_CHARGE_STATUS_ICO_DONE;
-}
-
-int chg_ramp_get_current_limit(void)
-{
- int reg;
- int mode;
- int tries_left = 8;
-
- /* Save current mode to restore same state after ADC read */
- if (bq25703_get_low_power_mode(&mode))
- goto error;
-
- /* Exit low power mode so ADC conversion takes typical time */
- if (bq25703_set_low_power_mode(0))
- goto error;
-
- /* Turn on the ADC for one reading */
- reg = BQ25703_ADC_OPTION_ADC_START | BQ25703_ADC_OPTION_EN_ADC_IIN;
- if (raw_write16(BQ25703_REG_ADC_OPTION, reg))
- goto error;
-
- /*
- * Wait until the ADC operation completes. The spec says typical
- * conversion time is 10 msec. If low power mode isn't exited first,
- * then the conversion time jumps to ~60 msec.
- */
- do {
- msleep(2);
- raw_read16(BQ25703_REG_ADC_OPTION, &reg);
- } while (--tries_left && (reg & BQ25703_ADC_OPTION_ADC_START));
-
- /* ADC reading attempt complete, go back to low power mode */
- if (bq25703_set_low_power_mode(mode))
- goto error;
-
- /* Could not complete read */
- if (reg & BQ25703_ADC_OPTION_ADC_START)
- goto error;
-
- /* Read ADC value */
- if (raw_read8(BQ25703_REG_ADC_IIN, &reg))
- goto error;
-
- /* LSB => 50mA */
- return reg * BQ25703_ADC_IIN_STEP_MA;
-
-error:
- CPRINTF("Could not read input current limit ADC!\n");
- return 0;
-}
-#endif /* CONFIG_CHARGE_RAMP_HW */
diff --git a/driver/charger/bq25703.h b/driver/charger/bq25703.h
deleted file mode 100644
index f715824f63..0000000000
--- a/driver/charger/bq25703.h
+++ /dev/null
@@ -1,75 +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.
- *
- * TI bq25703 battery charger driver.
- */
-
-#ifndef __CROS_EC_BQ25703_H
-#define __CROS_EC_BQ25703_H
-
-/* I2C Interface */
-#define BQ25703_I2C_ADDR1_FLAGS 0x6B
-
-/*
- * BC1.2 minimum voltage threshold for BQ25703.
- * BC1.2 charging port output voltage range is 4.75V to 5.25V,
- * BQ25703 Input Voltage Accuracy is -2% to +2% (-95mV to +95mV)
- * 4750mV - 95mV => 4655mV - 3200 (offset reg 0x0A) => 1455mv
- * 1455mv & 0x1FC0 = 1408 (data for register 0x0A)
- */
-#define BQ25703_BC12_MIN_VOLTAGE_MV 1408
-
-/* Registers */
-
-/* ChargeOption0 Register */
-#define BQ25703_REG_CHARGE_OPTION_0 0x00
-#define BQ25703_CHARGE_OPTION_0_LOW_POWER_MODE BIT(15)
-#define BQ25703_CHARGE_OPTION_0_EN_LEARN BIT(5)
-#define BQ25703_CHARGE_OPTION_0_CHRG_INHIBIT BIT(0)
-
-#define BQ25703_REG_CHARGE_CURRENT 0x02
-#define BQ25703_REG_MAX_CHARGE_VOLTAGE 0x04
-#define BQ25703_REG_CHARGE_OPTION_1 0x30
-
-/* ChargeOption2 Register */
-#define BQ25703_REG_CHARGE_OPTION_2 0x32
-#define BQ25703_CHARGE_OPTION_2_EN_EXTILIM BIT(7)
-
-/* ChargeOption3 Register */
-#define BQ25703_REG_CHARGE_OPTION_3 0x34
-#define BQ25703_CHARGE_OPTION_3_EN_ICO_MODE BIT(11)
-
-#define BQ25703_REG_PROCHOT_OPTION_0 0x36
-#define BQ25703_REG_PROCHOT_OPTION_1 0x38
-
-/* ADCOption Register */
-#define BQ25703_REG_ADC_OPTION 0x3A
-#define BQ25703_ADC_OPTION_ADC_START BIT(14)
-#define BQ25703_ADC_OPTION_EN_ADC_IIN BIT(4)
-
-/* ChargeStatus Register */
-#define BQ25703_REG_CHARGER_STATUS 0x20
-#define BQ25703_CHARGE_STATUS_ICO_DONE BIT(14)
-
-#define BQ25703_REG_PROCHOT_STATUS 0x22
-#define BQ25703_REG_IIN_DPM 0x25
-#define BQ25703_REG_ADC_PSYS 0x26
-#define BQ25703_REG_ADC_VBUS 0x27
-#define BQ25703_REG_ADC_IBAT 0x28
-#define BQ25703_REG_ADC_CMPIN 0x2A
-
-/* ADCIIN Register */
-#define BQ25703_REG_ADC_IIN 0x2B
-#define BQ25703_ADC_IIN_STEP_MA 50
-
-#define BQ25703_REG_ADC_VSYS_VBAT 0x2C
-#define BQ25703_REG_OTG_VOLTAGE 0x06
-#define BQ25703_REG_OTG_CURRENT 0x08
-#define BQ25703_REG_INPUT_VOLTAGE 0x0A
-#define BQ25703_REG_MIN_SYSTEM_VOLTAGE 0x0C
-#define BQ25703_REG_IIN_HOST 0x0F
-#define BQ25703_REG_MANUFACTURER_ID 0x2E
-#define BQ25703_REG_DEVICE_ADDRESS 0x2F
-
-#endif /* __CROS_EC_BQ25703_H */
diff --git a/driver/charger/bq2589x.c b/driver/charger/bq2589x.c
deleted file mode 100644
index 966a0d0016..0000000000
--- a/driver/charger/bq2589x.c
+++ /dev/null
@@ -1,394 +0,0 @@
-/* Copyright 2015 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.
- *
- * TI bq25890/bq25892/bq25895 battery charger driver.
- */
-
-#include "config.h"
-#include "bq2589x.h"
-#include "charger.h"
-#include "common.h"
-#include "console.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "printf.h"
-#include "util.h"
-
-/* Console output macros */
-#define CPUTS(outstr) cputs(CC_CHARGER, outstr)
-#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
-
-/* 5V Boost settings */
-#ifndef CONFIG_CHARGER_BQ2589X_BOOST
-#define CONFIG_CHARGER_BQ2589X_BOOST BQ2589X_BOOST_DEFAULT
-#endif
-
-/* IR compensation settings */
-#ifndef CONFIG_CHARGER_BQ2589X_IR_COMP
-#define CONFIG_CHARGER_BQ2589X_IR_COMP BQ2589X_IR_COMP_DEFAULT
-#endif
-
-/* Termination current limit setting */
-#ifndef CONFIG_CHARGER_TERM_CURRENT_LIMIT
-#define CONFIG_CHARGER_TERM_CURRENT_LIMIT BQ2589X_TERM_CURRENT_LIMIT_DEFAULT
-#endif
-
-/* Charger information */
-static const struct charger_info bq2589x_charger_info = {
- .name = "bq2589x",
- .voltage_max = 4608,
- .voltage_min = 3840,
- .voltage_step = 16,
- .current_max = 5056,
- .current_min = 0,
- .current_step = 64,
- .input_current_max = 3250,
- .input_current_min = 100,
- .input_current_step = 50,
-};
-
-static int bq2589x_read(int reg, int *value)
-{
- return i2c_read8(I2C_PORT_CHARGER, BQ2589X_ADDR, reg, value);
-}
-
-static int bq2589x_write(int reg, int value)
-{
- return i2c_write8(I2C_PORT_CHARGER, BQ2589X_ADDR, reg, value);
-}
-
-static int bq2589x_watchdog_reset(void)
-{
- int rv, val;
-
- rv = bq2589x_read(BQ2589X_REG_CFG2, &val);
- if (rv)
- return rv;
- val |= BQ2589X_CFG2_WD_RST;
- return bq2589x_write(BQ2589X_REG_CFG2, val);
-}
-
-static int bq2589x_set_terminate_current(int current)
-{
- int reg_val, rv;
- int val = (current - 64) / 64;
-
- rv = bq2589x_read(BQ2589X_REG_PRE_CHG_CURR, &reg_val);
- if (rv)
- return rv;
- reg_val = (reg_val & ~0xf) | (val & 0xf);
- return bq2589x_write(BQ2589X_REG_PRE_CHG_CURR, reg_val);
-}
-
-#ifdef CONFIG_CHARGER_OTG
-int charger_enable_otg_power(int enabled)
-{
- int val, rv;
-
- rv = bq2589x_read(BQ2589X_REG_CFG2, &val);
- if (rv)
- return rv;
- val = (val & ~(BQ2589X_CFG2_CHG_CONFIG | BQ2589X_CFG2_OTG_CONFIG))
- | (enabled ? BQ2589X_CFG2_OTG_CONFIG : BQ2589X_CFG2_CHG_CONFIG);
- return bq2589x_write(BQ2589X_REG_CFG2, val);
-}
-#endif
-
-int charger_set_input_current(int input_current)
-{
- int value, rv;
- const struct charger_info * const info = charger_get_info();
-
- input_current -= info->input_current_min;
- if (input_current < 0)
- input_current = 0;
-
- rv = bq2589x_read(BQ2589X_REG_INPUT_CURR, &value);
- if (rv)
- return rv;
- value = value & ~(0x3f);
- value |= (input_current / info->input_current_step) & 0x3f;
- return bq2589x_write(BQ2589X_REG_INPUT_CURR, value);
-}
-
-int charger_get_input_current(int *input_current)
-{
- int rv, value;
- const struct charger_info * const info = charger_get_info();
-
- rv = bq2589x_read(BQ2589X_REG_INPUT_CURR, &value);
- if (rv)
- return rv;
-
- *input_current = (value & 0x3f) * info->input_current_step
- + info->input_current_min;
-
- return EC_SUCCESS;
-}
-
-int charger_manufacturer_id(int *id)
-{
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-int charger_device_id(int *id)
-{
- int res = bq2589x_read(BQ2589X_REG_ID, id);
-
- if (res == EC_SUCCESS)
- *id &= BQ2589X_DEVICE_ID_MASK;
-
- return res;
-}
-
-int charger_get_option(int *option)
-{
- /* Ignored: does not exist */
- *option = 0;
- return EC_SUCCESS;
-}
-
-int charger_set_option(int option)
-{
- /* Ignored: does not exist */
- return EC_SUCCESS;
-}
-
-const struct charger_info *charger_get_info(void)
-{
- return &bq2589x_charger_info;
-}
-
-int charger_get_status(int *status)
-{
- /* TODO(crosbug.com/p/38603) implement using REG0C value */
- *status = 0;
- return EC_SUCCESS;
-}
-
-int charger_set_mode(int mode)
-{
- return EC_SUCCESS;
-}
-
-int charger_get_current(int *current)
-{
- int rv, val;
- const struct charger_info * const info = charger_get_info();
-
- rv = bq2589x_read(BQ2589X_REG_CHG_CURR, &val);
- if (rv)
- return rv;
- *current = val * info->current_step + info->current_min;
- return EC_SUCCESS;
-}
-
-int charger_set_current(int current)
-{
- const struct charger_info * const info = charger_get_info();
-
- current = charger_closest_current(current);
-
- return bq2589x_write(BQ2589X_REG_CHG_CURR,
- current / info->current_step);
-}
-
-int charger_get_voltage(int *voltage)
-{
- int rv, val;
- const struct charger_info * const info = charger_get_info();
-
- rv = bq2589x_read(BQ2589X_REG_CHG_VOLT, &val);
- if (rv)
- return rv;
- val = (val >> 2) & 0x3f;
- *voltage = val * info->voltage_step + info->voltage_min;
- return EC_SUCCESS;
-}
-
-int charger_set_voltage(int voltage)
-{
- int rv, val;
- const struct charger_info * const info = charger_get_info();
-
- voltage = charger_closest_voltage(voltage);
-
- rv = bq2589x_read(BQ2589X_REG_CHG_VOLT, &val);
- if (rv)
- return rv;
- val = val & 0x3;
- val |= ((voltage - info->voltage_min) / info->voltage_step) << 2;
- return bq2589x_write(BQ2589X_REG_CHG_VOLT, val);
-}
-
-int charger_discharge_on_ac(int enable)
-{
- int rv, val;
-
- rv = bq2589x_read(BQ2589X_REG_INPUT_CURR, &val);
- if (rv)
- return rv;
-
- if (enable)
- val |= BQ2589X_INPUT_CURR_EN_HIZ;
- else
- val &= ~BQ2589X_INPUT_CURR_EN_HIZ;
-
- return bq2589x_write(BQ2589X_REG_INPUT_CURR, val);
-}
-
-/* Charging power state initialization */
-int charger_post_init(void)
-{
-#ifdef CONFIG_CHARGER_ILIM_PIN_DISABLED
- int val, rv;
- /* Ignore ILIM pin value */
- rv = bq2589x_read(BQ2589X_REG_INPUT_CURR, &val);
- if (rv)
- return rv;
- val &= ~BQ2589X_INPUT_CURR_EN_ILIM;
- rv = bq2589x_write(BQ2589X_REG_INPUT_CURR, val);
- if (rv)
- return rv;
-#endif /* CONFIG_CHARGER_ILIM_PIN_DISABLED */
-
- /* Input current controlled by extpower module. Do nothing here. */
- return EC_SUCCESS;
-}
-
-/*****************************************************************************/
-/* Hardware current ramping (aka ICO: Input Current Optimizer) */
-
-#ifdef CONFIG_CHARGE_RAMP_HW
-int charger_set_hw_ramp(int enable)
-{
- int val, rv;
-
- rv = i2c_read8(I2C_PORT_CHARGER, BQ2589X_ADDR, BQ2589X_REG_CFG1, &val);
- if (rv)
- return rv;
-
- if (enable)
- val |= BQ2589X_CFG1_ICO_EN;
- else
- val &= ~BQ2589X_CFG1_ICO_EN;
-
- return i2c_write8(I2C_PORT_CHARGER, BQ2589X_ADDR, BQ2589X_REG_CFG1,
- val);
-}
-
-int chg_ramp_is_stable(void)
-{
- int val, rv;
-
- rv = bq2589x_read(BQ2589X_REG_ID, &val);
- if (!rv && (val & BQ2589X_ID_ICO_OPTIMIZED))
- return 1;
- else
- return 0;
-}
-
-int chg_ramp_is_detected(void)
-{
- return 1;
-}
-
-int chg_ramp_get_current_limit(void)
-{
- int input_ma, rv;
-
- rv = bq2589x_read(BQ2589X_REG_ADC_INPUT_CURR, &input_ma);
-
- return rv ? -1 : 100 + (input_ma & 0x3f) * 50;
-}
-#endif /* CONFIG_CHARGE_RAMP_HW */
-
-/*****************************************************************************/
-/* Hooks */
-
-static void bq2589x_init(void)
-{
- int val;
-
- if (charger_device_id(&val) || val != BQ2589X_DEVICE_ID) {
- CPRINTF("BQ2589X incorrent ID: 0x%02x\n", val);
- return;
- }
-
- /*
- * Disable I2C watchdog timer.
- *
- * TODO(crosbug.com/p/38603): Re-enable watchdog timer and kick it
- * periodically in charger task.
- */
- if (bq2589x_read(BQ2589X_REG_TIMER, &val))
- return;
- val &= ~0x30;
- if (bq2589x_write(BQ2589X_REG_TIMER, val))
- return;
-
- if (bq2589x_set_terminate_current(CONFIG_CHARGER_TERM_CURRENT_LIMIT))
- return;
-
- if (bq2589x_watchdog_reset())
- return;
-
- if (bq2589x_write(BQ2589X_REG_IR_COMP, CONFIG_CHARGER_BQ2589X_IR_COMP))
- return;
-
- if (bq2589x_write(BQ2589X_REG_BOOST_MODE, CONFIG_CHARGER_BQ2589X_BOOST))
- return;
-
- CPRINTF("BQ2589%c initialized\n",
- BQ2589X_DEVICE_ID == BQ25890_DEVICE_ID ? '0' :
- (BQ2589X_DEVICE_ID == BQ25895_DEVICE_ID ? '5' : '2'));
-}
-DECLARE_HOOK(HOOK_INIT, bq2589x_init, HOOK_PRIO_LAST);
-
-/*****************************************************************************/
-/* Console commands */
-#ifdef CONFIG_CMD_CHARGER
-static int command_bq2589x(int argc, char **argv)
-{
- int i;
- int value;
- int rv;
- int batt_mv, sys_mv, vbus_mv, chg_ma, input_ma;
-
- /* Trigger one ADC conversion */
- bq2589x_read(BQ2589X_REG_CFG1, &value);
- bq2589x_write(BQ2589X_REG_CFG1, value | BQ2589X_CFG1_CONV_START);
- do {
- bq2589x_read(BQ2589X_REG_CFG1, &value);
- } while (value & BQ2589X_CFG1_CONV_START); /* Wait for End of Conv. */
-
- bq2589x_read(BQ2589X_REG_ADC_BATT_VOLT, &batt_mv);
- bq2589x_read(BQ2589X_REG_ADC_SYS_VOLT, &sys_mv);
- bq2589x_read(BQ2589X_REG_ADC_VBUS_VOLT, &vbus_mv);
- bq2589x_read(BQ2589X_REG_ADC_CHG_CURR, &chg_ma);
- bq2589x_read(BQ2589X_REG_ADC_INPUT_CURR, &input_ma);
- ccprintf("ADC Batt %dmV Sys %dmV VBUS %dmV Chg %dmA Input %dmA\n",
- 2304 + (batt_mv & 0x7f) * 20, 2304 + sys_mv * 20,
- 2600 + (vbus_mv & 0x7f) * 100,
- chg_ma * 50, 100 + (input_ma & 0x3f) * 50);
-
- ccprintf("REG:");
- for (i = 0; i <= 0x14; ++i)
- ccprintf(" %02x", i);
- ccprintf("\n");
-
- ccprintf("VAL:");
- for (i = 0; i <= 0x14; ++i) {
- rv = bq2589x_read(i, &value);
- if (rv)
- return rv;
- ccprintf(" %02x", value);
- }
- ccprintf("\n");
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(bq2589x, command_bq2589x,
- NULL, NULL);
-#endif
diff --git a/driver/charger/bq2589x.h b/driver/charger/bq2589x.h
deleted file mode 100644
index 95bbf4c226..0000000000
--- a/driver/charger/bq2589x.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Copyright 2015 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.
- *
- * TI bq25890/bq25892/bq25895 battery charger driver.
- */
-
-#ifndef __CROS_EC_BQ2589X_H
-#define __CROS_EC_BQ2589X_H
-
-/* Registers */
-#define BQ2589X_REG_INPUT_CURR 0x00
-#define BQ2589X_REG_VINDPM 0x01
-#define BQ2589X_REG_CFG1 0x02
-#define BQ2589X_REG_CFG2 0x03
-#define BQ2589X_REG_CHG_CURR 0x04
-#define BQ2589X_REG_PRE_CHG_CURR 0x05
-#define BQ2589X_REG_CHG_VOLT 0x06
-#define BQ2589X_REG_TIMER 0x07
-#define BQ2589X_REG_IR_COMP 0x08
-#define BQ2589X_REG_FORCE 0x09
-#define BQ2589X_REG_BOOST_MODE 0x0A
-#define BQ2589X_REG_STATUS 0x0B /* Read-only */
-#define BQ2589X_REG_FAULT 0x0C /* Read-only */
-#define BQ2589X_REG_VINDPM_THRESH 0x0D
-#define BQ2589X_REG_ADC_BATT_VOLT 0x0E /* Read-only */
-#define BQ2589X_REG_ADC_SYS_VOLT 0x0F /* Read-only */
-#define BQ2589X_REG_ADC_TS 0x10 /* Read-only */
-#define BQ2589X_REG_ADC_VBUS_VOLT 0x11 /* Read-only */
-#define BQ2589X_REG_ADC_CHG_CURR 0x12 /* Read-only */
-#define BQ2589X_REG_ADC_INPUT_CURR 0x13 /* Read-only */
-#define BQ2589X_REG_ID 0x14
-
-/* REG00 : input current register bit definitions */
-#define BQ2589X_INPUT_CURR_EN_HIZ (1<<7)
-#define BQ2589X_INPUT_CURR_EN_ILIM (1<<6)
-
-/* REG02 : first configuration register bit definitions */
-#define BQ2589X_CFG1_CONV_START (1<<7)
-#define BQ2589X_CFG1_ICO_EN (1<<4)
-#define BQ2589X_CFG1_AUTO_DPDM_EN (1<<0)
-
-/* REG03 : second configuration register bit definitions */
-#define BQ2589X_CFG2_CHG_CONFIG (1<<4)
-#define BQ2589X_CFG2_OTG_CONFIG (1<<5)
-#define BQ2589X_CFG2_WD_RST (1<<6)
-
-/* REG08 : IR compensation definitions */
-#define BQ2589X_IR_BAT_COMP_140MOHM (7 << 5)
-#define BQ2589X_IR_BAT_COMP_120MOHM (6 << 5)
-#define BQ2589X_IR_BAT_COMP_100MOHM (5 << 5)
-#define BQ2589X_IR_BAT_COMP_80MOHM (4 << 5)
-#define BQ2589X_IR_BAT_COMP_60MOHM (3 << 5)
-#define BQ2589X_IR_BAT_COMP_40MOHM (2 << 5)
-#define BQ2589X_IR_BAT_COMP_20MOHM BIT(5)
-#define BQ2589X_IR_BAT_COMP_0MOHM (0 << 5)
-#define BQ2589X_IR_VCLAMP_224MV (7 << 2)
-#define BQ2589X_IR_VCLAMP_192MV (6 << 2)
-#define BQ2589X_IR_VCLAMP_160MV (5 << 2)
-#define BQ2589X_IR_VCLAMP_128MV (4 << 2)
-#define BQ2589X_IR_VCLAMP_96MV (3 << 2)
-#define BQ2589X_IR_VCLAMP_64MV (2 << 2)
-#define BQ2589X_IR_VCLAMP_32MV BIT(2)
-#define BQ2589X_IR_VCLAMP_0MV (0 << 2)
-#define BQ2589X_IR_TREG_120C (3 << 0)
-#define BQ2589X_IR_TREG_100C (2 << 0)
-#define BQ2589X_IR_TREG_80C BIT(0)
-#define BQ2589X_IR_TREG_60C (0 << 0)
-
-#define BQ2589X_IR_COMP_DEFAULT (BQ2589X_IR_TREG_120C | BQ2589X_IR_VCLAMP_0MV |\
- BQ2589X_IR_BAT_COMP_0MOHM)
-
-#define BQ2589X_TERM_CURRENT_LIMIT_DEFAULT 256
-
-/* 5V VBUS Boost settings */
-#define BQ2589X_BOOSTV_MV(mv) (((((mv) - 4550)/64) & 0xF) << 4)
-#define BQ2589X_BOOSTV_DEFAULT BQ2589X_BOOSTV_MV(4998)
-#define BQ2589X_BOOST_LIM_500MA 0x00
-#define BQ2589X_BOOST_LIM_750MA 0x01
-#define BQ2589X_BOOST_LIM_1200MA 0x02
-#define BQ2589X_BOOST_LIM_1400MA 0x03
-#define BQ2589X_BOOST_LIM_1650MA 0x04
-#define BQ2589X_BOOST_LIM_1875MA 0x05
-#define BQ2589X_BOOST_LIM_2150MA 0x06
-#define BQ2589X_BOOST_LIM_2450MA 0x07
-#define BQ2589X_BOOST_LIM_DEFAULT BQ2589X_BOOST_LIM_1400MA
-#define BQ2589X_BOOST_DEFAULT (BQ2589X_BOOST_LIM_DEFAULT |\
- BQ2589X_BOOSTV_DEFAULT)
-
-/* REG14: Device ID, reset and ICO status */
-#define BQ2589X_DEVICE_ID_MASK 0x38
-#define BQ25890_DEVICE_ID 0x18
-#define BQ25892_DEVICE_ID 0x00
-#define BQ25895_DEVICE_ID 0x38
-
-#define BQ2589X_ID_ICO_OPTIMIZED 0x40
-
-
-/* Variant-specific configuration */
-#if defined(CONFIG_CHARGER_BQ25890)
-#define BQ2589X_DEVICE_ID BQ25890_DEVICE_ID
-#define BQ2589X_ADDR_FLAGS 0x6A
-#elif defined(CONFIG_CHARGER_BQ25895)
-#define BQ2589X_DEVICE_ID BQ25895_DEVICE_ID
-#define BQ2589X_ADDR_FLAGS 0x6A
-#elif defined(CONFIG_CHARGER_BQ25892)
-#define BQ2589X_DEVICE_ID BQ25892_DEVICE_ID
-#define BQ2589X_ADDR_FLAGS 0x6B
-#else
-#error BQ2589X unknown variant
-#endif
-
-#endif /* __CROS_EC_BQ2589X_H */
diff --git a/include/config.h b/include/config.h
index 5f3e4a0c4b..ae5318d311 100644
--- a/include/config.h
+++ b/include/config.h
@@ -777,18 +777,10 @@
/* Compile charger-specific code for these chargers (pick at most one) */
#undef CONFIG_CHARGER_BD9995X
-#undef CONFIG_CHARGER_BQ24707A
#undef CONFIG_CHARGER_BQ24715
-#undef CONFIG_CHARGER_BQ24725
-#undef CONFIG_CHARGER_BQ24735
-#undef CONFIG_CHARGER_BQ24738
#undef CONFIG_CHARGER_BQ24770
#undef CONFIG_CHARGER_BQ24773
-#undef CONFIG_CHARGER_BQ25703
#undef CONFIG_CHARGER_BQ25710
-#undef CONFIG_CHARGER_BQ25890
-#undef CONFIG_CHARGER_BQ25892
-#undef CONFIG_CHARGER_BQ25895
#undef CONFIG_CHARGER_ISL9237
#undef CONFIG_CHARGER_ISL9238
#undef CONFIG_CHARGER_ISL9241
@@ -829,19 +821,6 @@
#undef CONFIG_CHARGER_BATTERY_TSENSE
/*
- * BQ2589x IR Compensation settings.
- * Should be the combination of BQ2589X_IR_TREG_xxxC, BQ2589X_IR_VCLAMP_yyyMV
- * and BQ2589X_IR_BAT_COMP_zzzMOHM.
- */
-#undef CONFIG_CHARGER_BQ2589X_IR_COMP
-/*
- * BQ2589x 5V boost current limit and voltage.
- * Should be the combination of BQ2589X_BOOSTV_MV(voltage) and
- * BQ2589X_BOOST_LIM_xxxMA.
- */
-#undef CONFIG_CHARGER_BQ2589X_BOOST
-
-/*
* Board specific charging current limit, in mA. If defined, the charge state
* machine will not allow the battery to request more current than this.
*/
@@ -874,16 +853,6 @@
#undef CONFIG_CHARGER_PSYS_READ
/*
- * Board specific charging current termination limit, in mA. If defined and
- * charger supports setting termination current it should be set during charger
- * init.
- *
- * TODO(tbroch): Only valid for bq2589x currently. Configure defaults for other
- * charger ICs that support termination currents.
- */
-#undef CONFIG_CHARGER_TERM_CURRENT_LIMIT
-
-/*
* Board supports discharge mode. In this mode, the battery will discharge
* even if AC is present. Used for testing.
*/