summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-04-03 16:42:47 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-01 01:12:04 +0000
commit10fe09bf9aaf59213d141fc1d479ed259f786049 (patch)
tree1c2f9c76714af47bdb08b9cc388b0c0a56041e26
parent03e331ec95e732eab725073e6af22a09ad9c7616 (diff)
downloadchrome-ec-10fe09bf9aaf59213d141fc1d479ed259f786049.tar.gz
OCPC: Add concept of active charger IC
With OCPC, one charger IC per Type-C port, there are now multiple charger ICs present in the system. This commit adds the beginning of OCPC support by adding the notion of an active charger IC. Charge Manager will select the active charger IC based upon the charge port. Boards must define this mapping in a board specific function. Additionally, this commit adds chgnum as a parameter to charger_set_input_current_limit(). BUG=b:148981052 BRANCH=None TEST=With other patches, verify that the active charger IC is able to be saved and retrieved. Change-Id: Iba4a8958171ad6e1630b0ca3d07d128bc1f2c4dd Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2135963 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/atlas/board.c3
-rw-r--r--board/damu/board.c2
-rw-r--r--board/flapjack/board.c2
-rw-r--r--board/jacuzzi/board.c2
-rw-r--r--board/kakadu/board.c2
-rw-r--r--board/kappa/board.c2
-rw-r--r--board/kodama/board.c2
-rw-r--r--board/kukui/board.c2
-rw-r--r--board/scarlet/board.c2
-rw-r--r--common/charge_manager.c4
-rw-r--r--common/charge_state_v2.c58
-rw-r--r--common/charger.c98
-rw-r--r--driver/charger/bq25710.c7
-rw-r--r--include/charge_state_v2.h17
-rw-r--r--include/charger.h17
-rw-r--r--include/config.h10
-rw-r--r--include/ec_commands.h1
-rw-r--r--include/ocpc.h21
18 files changed, 188 insertions, 64 deletions
diff --git a/board/atlas/board.c b/board/atlas/board.c
index 82dc847623..8948207c24 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -531,7 +531,8 @@ static int charger_derate(int current)
static void board_charger_init(void)
{
- charger_set_input_current(charger_derate(PD_MAX_CURRENT_MA));
+ charger_set_input_current(CHARGER_SOLO, charger_derate
+ (PD_MAX_CURRENT_MA));
}
DECLARE_HOOK(HOOK_INIT, board_charger_init, HOOK_PRIO_DEFAULT);
diff --git a/board/damu/board.c b/board/damu/board.c
index 4f5ce743b4..dab8e8684a 100644
--- a/board/damu/board.c
+++ b/board/damu/board.c
@@ -209,7 +209,7 @@ int board_set_active_charge_port(int charge_port)
* even when battery is disconnected, keep VBAT rail on but
* set the charging current to minimum.
*/
- charger_set_current(0);
+ charger_set_current(CHARGER_SOLO, 0);
break;
default:
panic("Invalid charge port\n");
diff --git a/board/flapjack/board.c b/board/flapjack/board.c
index e0aed97417..f15f927840 100644
--- a/board/flapjack/board.c
+++ b/board/flapjack/board.c
@@ -347,7 +347,7 @@ int board_set_active_charge_port(int charge_port)
* even when battery is disconnected, keep VBAT rail on but
* set the charging current to minimum.
*/
- charger_set_current(0);
+ charger_set_current(CHARGER_SOLO, 0);
break;
default:
panic("Invalid charge port\n");
diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c
index 186b6ae934..101a80222b 100644
--- a/board/jacuzzi/board.c
+++ b/board/jacuzzi/board.c
@@ -211,7 +211,7 @@ int board_set_active_charge_port(int charge_port)
* even when battery is disconnected, keep VBAT rail on but
* set the charging current to minimum.
*/
- charger_set_current(0);
+ charger_set_current(CHARGER_SOLO, 0);
break;
default:
panic("Invalid charge port\n");
diff --git a/board/kakadu/board.c b/board/kakadu/board.c
index 5c1a7d0ad3..1e3b26cfdb 100644
--- a/board/kakadu/board.c
+++ b/board/kakadu/board.c
@@ -181,7 +181,7 @@ int board_set_active_charge_port(int charge_port)
*/
gpio_set_level(GPIO_EN_POGO_CHARGE_L, 1);
gpio_set_level(GPIO_EN_USBC_CHARGE_L, 1);
- charger_set_current(0);
+ charger_set_current(CHARGER_SOLO, 0);
break;
default:
panic("Invalid charge port\n");
diff --git a/board/kappa/board.c b/board/kappa/board.c
index 810b572a67..ea1821ee07 100644
--- a/board/kappa/board.c
+++ b/board/kappa/board.c
@@ -190,7 +190,7 @@ int board_set_active_charge_port(int charge_port)
* even when battery is disconnected, keep VBAT rail on but
* set the charging current to minimum.
*/
- charger_set_current(0);
+ charger_set_current(CHARGER_SOLO, 0);
break;
default:
panic("Invalid charge port\n");
diff --git a/board/kodama/board.c b/board/kodama/board.c
index 08a4eeeeae..8be6ba345d 100644
--- a/board/kodama/board.c
+++ b/board/kodama/board.c
@@ -171,7 +171,7 @@ int board_set_active_charge_port(int charge_port)
* even when battery is disconnected, keep VBAT rail on but
* set the charging current to minimum.
*/
- charger_set_current(0);
+ charger_set_current(CHARGER_SOLO, 0);
break;
default:
panic("Invalid charge port\n");
diff --git a/board/kukui/board.c b/board/kukui/board.c
index 2f71e46c89..422c60e123 100644
--- a/board/kukui/board.c
+++ b/board/kukui/board.c
@@ -195,7 +195,7 @@ int board_set_active_charge_port(int charge_port)
*/
gpio_set_level(GPIO_EN_POGO_CHARGE_L, 1);
gpio_set_level(GPIO_EN_USBC_CHARGE_L, 1);
- charger_set_current(0);
+ charger_set_current(CHARGER_SOLO, 0);
break;
default:
panic("Invalid charge port\n");
diff --git a/board/scarlet/board.c b/board/scarlet/board.c
index b84062153c..7638bee9cf 100644
--- a/board/scarlet/board.c
+++ b/board/scarlet/board.c
@@ -192,7 +192,7 @@ int board_set_active_charge_port(int charge_port)
* even when battery is disconnected, keep VBAT rail on but
* set the charging current to minimum.
*/
- charger_set_current(0);
+ charger_set_current(CHARGER_SOLO, 0);
break;
default:
panic("Invalid charge port\n");
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 8bf0267cc7..c12fc12318 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -705,6 +705,10 @@ static void charge_manager_refresh(void)
active_charge_port_initialized = 1;
+ /* Set the active charger chip based upon the selected charge port. */
+ if (IS_ENABLED(CONFIG_OCPC))
+ charge_set_active_chg_chip(new_port);
+
/*
* Clear override if it wasn't selected as the 'best' port -- it means
* that no charge is available on the port, or the port was rejected.
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index c5592cf5d1..6354cf0a40 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -380,6 +380,7 @@ static void set_base_lid_current(int current_base, int allow_charge_base,
int lid_first;
int ret;
+ int chgnum = 0;
/* TODO(b:71881017): This is still quite verbose during charging. */
if (prev_current_base != current_base ||
@@ -414,7 +415,7 @@ static void set_base_lid_current(int current_base, int allow_charge_base,
ret = charge_set_output_current_limit(0, 0);
if (ret)
return;
- ret = charger_set_input_current(current_lid);
+ ret = charger_set_input_current(chgnum, current_lid);
if (ret)
return;
if (allow_charge_lid)
@@ -1051,6 +1052,7 @@ static void dump_charge_state(void)
#define DUMP(FLD, FMT) ccprintf(#FLD " = " FMT "\n", curr.FLD)
#define DUMP_CHG(FLD, FMT) ccprintf("\t" #FLD " = " FMT "\n", curr.chg. FLD)
#define DUMP_BATT(FLD, FMT) ccprintf("\t" #FLD " = " FMT "\n", curr.batt. FLD)
+#define DUMP_OCPC(FLD, FMT) ccprintf("\t" #FLD " = " FMT "\n", curr.ocpc. FLD)
ccprintf("state = %s\n", state_list[curr.state]);
DUMP(ac, "%d");
DUMP(batt_is_charging, "%d");
@@ -1075,6 +1077,10 @@ static void dump_charge_state(void)
DUMP_BATT(full_capacity, "%dmAh");
ccprintf("\tis_present = %s\n", batt_pres[curr.batt.is_present]);
cflush();
+#ifdef CONFIG_OCPC
+ ccprintf("ocpc.*:\n");
+ DUMP_OCPC(active_chg_chip, "%d");
+#endif /* CONFIG_OCPC */
DUMP(requested_voltage, "%dmV");
DUMP(requested_current, "%dmA");
#ifdef CONFIG_CHARGER_OTG
@@ -1097,7 +1103,7 @@ static void dump_charge_state(void)
static void show_charging_progress(void)
{
- int rv = 0, minutes, to_full;
+ int rv = 0, minutes, to_full, chgnum = 0;
#ifdef CONFIG_BATTERY_SMART
/*
@@ -1155,7 +1161,9 @@ static void show_charging_progress(void)
ccprintf("battery:\n");
print_battery_debug();
ccprintf("charger:\n");
- print_charger_debug();
+ if (IS_ENABLED(CONFIG_OCPC))
+ chgnum = charge_get_active_chg_chip();
+ print_charger_debug(chgnum);
ccprintf("chg:\n");
dump_charge_state();
}
@@ -1223,12 +1231,12 @@ static int charge_request(int voltage, int current)
* battery.
*/
if (current >= 0)
- r2 = charger_set_current(current);
+ r2 = charger_set_current(0, current);
if (r2 != EC_SUCCESS)
problem(PR_SET_CURRENT, r2);
if (voltage >= 0)
- r1 = charger_set_voltage(voltage);
+ r1 = charger_set_voltage(0, voltage);
if (r1 != EC_SUCCESS)
problem(PR_SET_VOLTAGE, r1);
@@ -1607,6 +1615,7 @@ void charger_task(void *u)
int need_static = 1;
const struct charger_info * const info = charger_get_info();
int prev_plt_and_desired_mw;
+ int chgnum = 0;
/* Get the battery-specific values */
batt_info = battery_get_info();
@@ -1683,6 +1692,7 @@ void charger_task(void *u)
if (curr.desired_input_current !=
CHARGE_CURRENT_UNINITIALIZED)
rv = charger_set_input_current(
+ chgnum,
curr.desired_input_current);
if (rv != EC_SUCCESS)
problem(PR_SET_INPUT_CURR, rv);
@@ -1715,7 +1725,7 @@ void charger_task(void *u)
get_desired_input_current(prev_bp, info);
if (curr.desired_input_current !=
CHARGE_CURRENT_UNINITIALIZED)
- charger_set_input_current(
+ charger_set_input_current(chgnum,
curr.desired_input_current);
hook_notify(HOOK_BATTERY_SOC_CHANGE);
}
@@ -2366,6 +2376,10 @@ int charge_set_output_current_limit(int ma, int mv)
int charge_set_input_current_limit(int ma, int mv)
{
+ __maybe_unused int chgnum = 0;
+
+ if (IS_ENABLED(CONFIG_OCPC))
+ chgnum = charge_get_active_chg_chip();
#ifdef CONFIG_EC_EC_COMM_BATTERY_MASTER
curr.input_voltage = mv;
#endif
@@ -2407,7 +2421,29 @@ int charge_set_input_current_limit(int ma, int mv)
charge_wakeup();
return EC_SUCCESS;
#else
- return charger_set_input_current(ma);
+ return charger_set_input_current(chgnum, ma);
+#endif
+}
+
+#ifdef CONFIG_OCPC
+void charge_set_active_chg_chip(int idx)
+{
+ ASSERT(idx < (int)chg_cnt);
+
+ if (idx == curr.ocpc.active_chg_chip)
+ return;
+
+ CPRINTS("Act Chg: %d", idx);
+ curr.ocpc.active_chg_chip = idx;
+}
+#endif /* CONFIG_OCPC */
+
+int charge_get_active_chg_chip(void)
+{
+#ifdef CONFIG_OCPC
+ return curr.ocpc.active_chg_chip;
+#else
+ return 0;
#endif
}
@@ -2503,6 +2539,10 @@ charge_command_charge_state(struct host_cmd_handler_args *args)
struct ec_response_charge_state *out = args->response;
uint32_t val;
int rv = EC_RES_SUCCESS;
+ int chgnum = 0;
+
+ if (args->version > 0)
+ chgnum = in->chgnum;
switch (in->cmd) {
@@ -2597,7 +2637,7 @@ charge_command_charge_state(struct host_cmd_handler_args *args)
chgstate_set_manual_current(val);
break;
case CS_PARAM_CHG_INPUT_CURRENT:
- if (charger_set_input_current(val))
+ if (charger_set_input_current(chgnum, val))
rv = EC_RES_ERROR;
break;
case CS_PARAM_CHG_STATUS:
@@ -2624,7 +2664,7 @@ charge_command_charge_state(struct host_cmd_handler_args *args)
}
DECLARE_HOST_COMMAND(EC_CMD_CHARGE_STATE, charge_command_charge_state,
- EC_VER_MASK(0));
+ EC_VER_MASK(0) | EC_VER_MASK(1));
/*****************************************************************************/
/* Console commands */
diff --git a/common/charger.c b/common/charger.c
index eba9d621c6..21320fcd4d 100644
--- a/common/charger.c
+++ b/common/charger.c
@@ -86,12 +86,20 @@ int charger_closest_current(int current)
void charger_get_params(struct charger_params *chg)
{
int chgnum = 0;
+
+ if (IS_ENABLED(CONFIG_OCPC))
+ chgnum = charge_get_active_chg_chip();
+
memset(chg, 0, sizeof(*chg));
- if (charger_get_current(&chg->current))
+ /*
+ * Only the primary charger(0) can tightly regulate the current,
+ * therefore always query the primary charger.
+ */
+ if (charger_get_current(0, &chg->current))
chg->flags |= CHG_FLAG_BAD_CURRENT;
- if (charger_get_voltage(&chg->voltage))
+ if (charger_get_voltage(chgnum, &chg->voltage))
chg->flags |= CHG_FLAG_BAD_VOLTAGE;
if (charger_get_input_current(chgnum, &chg->input_current))
@@ -117,11 +125,10 @@ static int check_print_error(int rv)
return 0;
}
-void print_charger_debug(void)
+void print_charger_debug(int chgnum)
{
int d;
const struct charger_info *info = charger_get_info();
- int chgnum = 0;
/* info */
print_item_name("Name:");
@@ -144,13 +151,13 @@ void print_charger_debug(void)
/* charge voltage limit */
print_item_name("V_batt:");
- if (check_print_error(charger_get_voltage(&d)))
+ if (check_print_error(charger_get_voltage(chgnum, &d)))
ccprintf("%5d (%4d - %5d, %3d)\n", d, info->voltage_min,
info->voltage_max, info->voltage_step);
/* charge current limit */
print_item_name("I_batt:");
- if (check_print_error(charger_get_current(&d)))
+ if (check_print_error(charger_get_current(chgnum, &d)))
ccprintf("%5d (%4d - %5d, %3d)\n", d, info->current_min,
info->current_max, info->current_step);
@@ -172,41 +179,55 @@ static int command_charger(int argc, char **argv)
{
int d;
char *e;
+ int idx_provided = 0;
+ int chgnum;
- if (argc != 3) {
- print_charger_debug();
+ if (argc == 1) {
+ print_charger_debug(0);
return EC_SUCCESS;
}
- if (strcasecmp(argv[1], "input") == 0) {
- d = strtoi(argv[2], &e, 0);
+ idx_provided = isdigit(argv[1][0]);
+ if (idx_provided)
+ chgnum = atoi(argv[1]);
+ else
+ chgnum = 0;
+
+ if ((argc == 2) && idx_provided) {
+ print_charger_debug(chgnum);
+ return EC_SUCCESS;
+ }
+
+ if (strcasecmp(argv[1+idx_provided], "input") == 0) {
+ d = strtoi(argv[2+idx_provided], &e, 0);
if (*e)
- return EC_ERROR_PARAM2;
- return charger_set_input_current(d);
- } else if (strcasecmp(argv[1], "current") == 0) {
- d = strtoi(argv[2], &e, 0);
+ return EC_ERROR_PARAM2+idx_provided;
+ return charger_set_input_current(chgnum, d);
+ } else if (strcasecmp(argv[1+idx_provided], "current") == 0) {
+ d = strtoi(argv[2+idx_provided], &e, 0);
if (*e)
- return EC_ERROR_PARAM2;
+ return EC_ERROR_PARAM2+idx_provided;
chgstate_set_manual_current(d);
- return charger_set_current(d);
- } else if (strcasecmp(argv[1], "voltage") == 0) {
- d = strtoi(argv[2], &e, 0);
+ return charger_set_current(chgnum, d);
+ } else if (strcasecmp(argv[1+idx_provided], "voltage") == 0) {
+ d = strtoi(argv[2+idx_provided], &e, 0);
if (*e)
- return EC_ERROR_PARAM2;
+ return EC_ERROR_PARAM2+idx_provided;
chgstate_set_manual_voltage(d);
- return charger_set_voltage(d);
- } else if (strcasecmp(argv[1], "dptf") == 0) {
- d = strtoi(argv[2], &e, 0);
+ return charger_set_voltage(chgnum, d);
+ } else if (strcasecmp(argv[1+idx_provided], "dptf") == 0) {
+ d = strtoi(argv[2+idx_provided], &e, 0);
if (*e)
- return EC_ERROR_PARAM2;
+ return EC_ERROR_PARAM2+idx_provided;
dptf_limit_ma = d;
return EC_SUCCESS;
- } else
- return EC_ERROR_PARAM1;
+ } else {
+ return EC_ERROR_PARAM1+idx_provided;
+ }
}
DECLARE_CONSOLE_COMMAND(charger, command_charger,
- "[input | current | voltage | dptf] [newval]",
+ "[chgnum] [input | current | voltage | dptf] [newval]",
"Get or set charger param(s)");
/* Driver wrapper functions */
@@ -336,12 +357,14 @@ int charger_is_sourcing_otg_power(int port)
return rv;
}
-enum ec_error_list charger_get_current(int *current)
+enum ec_error_list charger_get_current(int chgnum, int *current)
{
- int chgnum = 0;
int rv = EC_ERROR_UNIMPLEMENTED;
- if ((chgnum < 0) || (chgnum >= chg_cnt)) {
+ if (chgnum < 0)
+ return EC_ERROR_INVAL;
+
+ if (chgnum >= chg_cnt) {
CPRINTS("%s(%d) Invalid charger!", __func__, chgnum);
return EC_ERROR_INVAL;
}
@@ -352,9 +375,8 @@ enum ec_error_list charger_get_current(int *current)
return rv;
}
-enum ec_error_list charger_set_current(int current)
+enum ec_error_list charger_set_current(int chgnum, int current)
{
- int chgnum = 0;
int rv = EC_ERROR_UNIMPLEMENTED;
if ((chgnum < 0) || (chgnum >= chg_cnt)) {
@@ -368,12 +390,14 @@ enum ec_error_list charger_set_current(int current)
return rv;
}
-enum ec_error_list charger_get_voltage(int *voltage)
+enum ec_error_list charger_get_voltage(int chgnum, int *voltage)
{
- int chgnum = 0;
int rv = EC_ERROR_UNIMPLEMENTED;
- if ((chgnum < 0) || (chgnum >= chg_cnt)) {
+ if (chgnum < 0)
+ return EC_ERROR_INVAL;
+
+ if (chgnum >= chg_cnt) {
CPRINTS("%s(%d) Invalid charger!", __func__, chgnum);
return EC_ERROR_INVAL;
}
@@ -384,9 +408,8 @@ enum ec_error_list charger_get_voltage(int *voltage)
return rv;
}
-enum ec_error_list charger_set_voltage(int voltage)
+enum ec_error_list charger_set_voltage(int chgnum, int voltage)
{
- int chgnum = 0;
int rv = EC_ERROR_UNIMPLEMENTED;
if ((chgnum < 0) || (chgnum >= chg_cnt)) {
@@ -433,9 +456,8 @@ enum ec_error_list charger_get_vbus_voltage(int port, int *voltage)
return rv;
}
-enum ec_error_list charger_set_input_current(int input_current)
+enum ec_error_list charger_set_input_current(int chgnum, int input_current)
{
- int chgnum = 0;
int rv = EC_ERROR_UNIMPLEMENTED;
if ((chgnum < 0) || (chgnum >= chg_cnt)) {
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c
index b9a897d843..72eaf20bdf 100644
--- a/driver/charger/bq25710.c
+++ b/driver/charger/bq25710.c
@@ -9,6 +9,7 @@
#include "battery_smart.h"
#include "bq25710.h"
#include "charge_ramp.h"
+#include "charge_state_v2.h"
#include "charger.h"
#include "common.h"
#include "console.h"
@@ -466,6 +467,10 @@ static enum ec_error_list bq25710_set_option(int chgnum, int option)
static void bq25710_chg_ramp_handle(void)
{
int ramp_curr;
+ int chgnum = 0;
+
+ if (IS_ENABLED(CONFIG_OCPC))
+ chgnum = charge_get_active_chg_chip();
/*
* Once the charge ramp is stable write back the stable ramp
@@ -473,7 +478,7 @@ static void bq25710_chg_ramp_handle(void)
*/
ramp_curr = chg_ramp_get_current_limit();
if (chg_ramp_is_stable()) {
- if (ramp_curr && !charger_set_input_current(ramp_curr))
+ if (ramp_curr && !charger_set_input_current(chgnum, ramp_curr))
CPRINTF("bq25710: stable ramp current=%d\n", ramp_curr);
} else {
CPRINTF("bq25710: ICO stall, ramp current=%d\n", ramp_curr);
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h
index ab9f54b46d..e26c53e2d5 100644
--- a/include/charge_state_v2.h
+++ b/include/charge_state_v2.h
@@ -8,6 +8,7 @@
#include "charger.h"
#include "chipset.h"
#include "ec_ec_comm_master.h"
+#include "ocpc.h"
#include "timer.h"
#ifndef __CROS_EC_CHARGE_STATE_V2_H
@@ -46,6 +47,9 @@ struct charge_state_data {
#ifdef CONFIG_EC_EC_COMM_BATTERY_MASTER
int input_voltage;
#endif
+#ifdef CONFIG_OCPC
+ struct ocpc_data ocpc;
+#endif
};
/**
@@ -147,6 +151,19 @@ int charge_get_plt_plus_bat_desired_mw(void);
int charge_get_stable_current(void);
/**
+ * Select which charger IC will actually be performing the charger switching.
+ *
+ * @param idx The index into the chg_chips table.
+ */
+void charge_set_active_chg_chip(int idx);
+
+/**
+ * Retrieve which charger IC is the active charger IC performing the charger
+ * switching.
+ */
+int charge_get_active_chg_chip(void);
+
+/**
* Set the stable current.
*
* @param ma: battery charging current in mA
diff --git a/include/charger.h b/include/charger.h
index 3baf9e93c9..310643017b 100644
--- a/include/charger.h
+++ b/include/charger.h
@@ -211,12 +211,12 @@ enum ec_error_list charger_set_otg_current_voltage(int output_current,
int charger_is_sourcing_otg_power(int port);
/* Get/set charge current limit in mA */
-enum ec_error_list charger_get_current(int *current);
-enum ec_error_list charger_set_current(int current);
+enum ec_error_list charger_get_current(int chgnum, int *current);
+enum ec_error_list charger_set_current(int chgnum, int current);
/* Get/set charge voltage limit in mV */
-enum ec_error_list charger_get_voltage(int *voltage);
-enum ec_error_list charger_set_voltage(int voltage);
+enum ec_error_list charger_get_voltage(int chgnum, int *voltage);
+enum ec_error_list charger_set_voltage(int chgnum, int voltage);
/* Discharge battery when on AC power. */
enum ec_error_list charger_discharge_on_ac(int enable);
@@ -236,7 +236,7 @@ int charger_get_system_power(void);
/* Other parameters that may be charger-specific, but are common so far. */
/* Set desired input current value */
-enum ec_error_list charger_set_input_current(int input_current);
+enum ec_error_list charger_set_input_current(int chgnum, int input_current);
/*
* Get actual input current value.
@@ -251,8 +251,11 @@ enum ec_error_list charger_get_option(int *option);
enum ec_error_list charger_set_option(int option);
enum ec_error_list charger_set_hw_ramp(int enable);
-/* Print all charger info for debugging purposes */
-void print_charger_debug(void);
+/*
+ * Print all charger info for debugging purposes
+ * @param chgnum: charger IC index.
+ */
+void print_charger_debug(int chgnum);
#endif /* __CROS_EC_CHARGER_H */
diff --git a/include/config.h b/include/config.h
index a0afe634e7..9c08c6901d 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1011,6 +1011,16 @@
/* Charger enable GPIO is active low */
#undef CONFIG_CHARGER_EN_ACTIVE_LOW
+/*
+ * OCPC - One Charger IC Per Type-C
+ *
+ * Define this if the board may have multiple charger ICs in the system. The
+ * assumption is that that primary charger is index 0 and is the charger IC
+ * connected to the battery FET. Additionally, `chgnum` is assumed to be the
+ * same as the charge port index.
+ */
+#undef CONFIG_OCPC
+
/* Enable trickle charging */
#undef CONFIG_TRICKLE_CHARGING
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 2685a0db22..a74360dc7a 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4445,6 +4445,7 @@ struct ec_params_charge_state {
uint32_t value; /* value to set */
} set_param;
};
+ uint8_t chgnum; /* Version 1 supports chgnum */
} __ec_todo_packed;
struct ec_response_charge_state {
diff --git a/include/ocpc.h b/include/ocpc.h
new file mode 100644
index 0000000000..c5c41470cb
--- /dev/null
+++ b/include/ocpc.h
@@ -0,0 +1,21 @@
+/* Copyright 2020 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.
+ */
+
+/*
+ * OCPC - One Charger IC per Type-C
+ */
+
+#ifndef __CROS_EC_OCPC_H_
+#define __CROS_EC_OCPC_H_
+
+#define PRIMARY_CHARGER 0
+#define SECONDARY_CHARGER 1
+
+struct ocpc_data {
+ /* Index into chg_chips[] table for the charger IC that is switching. */
+ int active_chg_chip;
+};
+
+#endif /* __CROS_EC_OCPC_H */