summaryrefslogtreecommitdiff
path: root/board/drawcia
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-08-19 15:19:16 -0600
committerCommit Bot <commit-bot@chromium.org>2020-08-26 21:42:44 +0000
commit9df40ef14c84e6575c3fecd2a5522b077b6f34ca (patch)
treeb271ccdc82834c75c02a73dc110e865665911601 /board/drawcia
parent4c97ac1c9053d26a0ca40f5cca1e461191be0d50 (diff)
downloadchrome-ec-9df40ef14c84e6575c3fecd2a5522b077b6f34ca.tar.gz
SM5803: Improve flow control setting
This change adds a new Vbus sink enable command which will be called on initial sink connection and detach. This will separate out most of the FLOW1 and FLOW2 register control from the set_mode() driver API which is regularly called from the charger task. This means that, if charging on a port fails, the charging will no longer be automatically re-enabled by the charger task. Additionally, this folds the verification that we aren't disabling sourcing into the sink enable so board files no longer need to verify this before calling the sink enable/disable API. It also allows the OTG disable to fully clear the FLOW1 mode since calls to OTG are more targeted than the sink enable/disable, which happens any time another charge port is set. BRANCH=None BUG=b:163511546,b:165677311 TEST=on waddledee and drawlat, confirm expected FLOW1 contents and Vbus level: - sinking C0 or C1 - sourcing C0 or C1 - sourcing both C0 and C1 - sinking C0 while sourcing C1 - sinking C1 while sourcing C0 - battery cutoff with charger in C0 or C1 - no battery boot with charger in C0 or C1 - power role swap with HooToo hub in C0 and C1 Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ifdc7786243bdf0a634d8db99b4deb53457232ad3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2372738 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/drawcia')
-rw-r--r--board/drawcia/board.c49
-rw-r--r--board/drawcia/usb_pd_policy.c4
2 files changed, 13 insertions, 40 deletions
diff --git a/board/drawcia/board.c b/board/drawcia/board.c
index 497bd9b7b7..0ba3b5c0b0 100644
--- a/board/drawcia/board.c
+++ b/board/drawcia/board.c
@@ -508,61 +508,34 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int board_set_active_charge_port(int port)
{
int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count());
- int p0_otg = 0, p1_otg = 0;
if (!is_valid_port && port != CHARGE_PORT_NONE)
return EC_ERROR_INVAL;
- /* TODO(b/147440290): charger functions should take chgnum */
- p0_otg = chg_chips[0].drv->is_sourcing_otg_power(0, 0);
-
- if (board_get_charger_chip_count() > 1)
- p1_otg = chg_chips[1].drv->is_sourcing_otg_power(1, 1);
-
if (port == CHARGE_PORT_NONE) {
CPRINTUSB("Disabling all charge ports");
- if (!p0_otg)
- chg_chips[0].drv->set_mode(0,
- CHARGE_FLAG_INHIBIT_CHARGE);
+ sm5803_vbus_sink_enable(CHARGER_PRIMARY, 0);
+
+ if (board_get_charger_chip_count() > 1)
+ sm5803_vbus_sink_enable(CHARGER_SECONDARY, 0);
- if (board_get_charger_chip_count() > 1) {
- if (!p1_otg)
- chg_chips[1].drv->set_mode(1,
- CHARGE_FLAG_INHIBIT_CHARGE);
- }
return EC_SUCCESS;
}
CPRINTUSB("New chg p%d", port);
/*
- * Charger task will take care of enabling charging on the new charge
- * port. Here, we ensure the other port is not charging by changing
- * CHG_EN
+ * Ensure other port is turned off, then enable new charge port
*/
if (port == 0) {
- if (p0_otg) {
- CPRINTUSB("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
- if (board_get_charger_chip_count() > 1) {
- if (!p1_otg) {
- chg_chips[1].drv->set_mode(1,
- CHARGE_FLAG_INHIBIT_CHARGE);
- }
- }
+ if (board_get_charger_chip_count() > 1)
+ sm5803_vbus_sink_enable(CHARGER_SECONDARY, 0);
+ sm5803_vbus_sink_enable(CHARGER_PRIMARY, 1);
+
} else {
- if (board_get_charger_chip_count() > 1) {
- if (p1_otg) {
- CPRINTUSB("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
- }
- if (!p0_otg) {
- chg_chips[0].drv->set_mode(0,
- CHARGE_FLAG_INHIBIT_CHARGE);
- }
+ sm5803_vbus_sink_enable(CHARGER_PRIMARY, 0);
+ sm5803_vbus_sink_enable(CHARGER_SECONDARY, 1);
}
return EC_SUCCESS;
diff --git a/board/drawcia/usb_pd_policy.c b/board/drawcia/usb_pd_policy.c
index f9ff88c26c..58b442a0ac 100644
--- a/board/drawcia/usb_pd_policy.c
+++ b/board/drawcia/usb_pd_policy.c
@@ -52,8 +52,8 @@ int pd_set_power_supply_ready(int port)
{
enum ec_error_list rv;
- /* Disable charging */
- rv = chg_chips[port].drv->set_mode(port, CHARGE_FLAG_INHIBIT_CHARGE);
+ /* Disable sinking */
+ rv = sm5803_vbus_sink_enable(port, 0);
if (rv)
return rv;