diff options
author | Aseda Aboagye <aaboagye@google.com> | 2017-10-16 14:55:00 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-10-23 04:28:25 -0700 |
commit | f45c06abc665d3114d67e5138531c81be0d43b59 (patch) | |
tree | e98e0467474d4201cf2a6bc65ae5729428acdd0f | |
parent | df3820165f8dd8bfb4b0a30ae1ac14372610cae8 (diff) | |
download | chrome-ec-f45c06abc665d3114d67e5138531c81be0d43b59.tar.gz |
zoombini: Add support for TI SN5S330 for Port 0.
BUG=b:67663166, b:67663124
BRANCH=None
TEST=Find a reworked zoombini with the SN5S330; Flash; verify that we
can charge at up to 20V on that port.
TEST=Plug in a USB-A to USB-C cable, verify that PD state machine still
transitions out of SNK_DISCONNECTED.
TEST=Plug in a weak power source to p0, plug in a stronger power source
to p1, verify that PP2 FET is turned off when stronger source is plugged
in. Verify that PP2 FET is turned on when strong power source is
removed.
Change-Id: I669494194f42d4fcc2b3d63ef1725132b6b8d9a8
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/722105
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | board/zoombini/board.c | 21 | ||||
-rw-r--r-- | board/zoombini/board.h | 1 |
2 files changed, 21 insertions, 1 deletions
diff --git a/board/zoombini/board.c b/board/zoombini/board.c index a9bd30e382..a0ed098658 100644 --- a/board/zoombini/board.c +++ b/board/zoombini/board.c @@ -12,6 +12,7 @@ #include "common.h" #include "console.h" #include "compile_time_macros.h" +#include "driver/ppc/sn5s330.h" #include "driver/tcpm/ps8xxx.h" #include "ec_commands.h" #ifdef CONFIG_ESPI_VW_SIGNALS @@ -102,6 +103,13 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); +/* TODO(aaboagye): Add the other ports. */ +const struct sn5s330_config sn5s330_chips[] = { + {I2C_PORT_TCPC0, SN5S330_ADDR0}, +}; +const unsigned int sn5s330_cnt = ARRAY_SIZE(sn5s330_chips); + + /* GPIO to enable/disable the USB Type-A port. */ const int usb_port_enable[CONFIG_USB_PORT_POWER_SMART_PORT_COUNT] = { GPIO_USB_A_5V_EN, @@ -217,6 +225,7 @@ int board_set_active_charge_port(int port) int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); static int initialized; + int i; if (!is_real_port && port != CHARGE_PORT_NONE) return EC_ERROR_INVAL; @@ -230,7 +239,7 @@ int board_set_active_charge_port(int port) port == CHARGE_PORT_NONE && charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) { CPRINTS("Bat critical, don't stop charging"); - return -1; + return EC_ERROR_BUSY; } CPRINTS("New chg p%d", port); @@ -258,6 +267,16 @@ int board_set_active_charge_port(int port) gpio_set_level(GPIO_USB_C2_CHARGE_EN_L, port != 2); initialized = 1; + /* + * Turn on the PP2 FET such that power actually flows and turn off the + * non-charge ports' PP2 FETs. + */ + for (i = 0; i < sn5s330_cnt; i++) { + if (sn5s330_pp_fet_enable(i, SN5S330_PP2, port == i)) + CPRINTF("%sabling C%d PP2 FET failed.", + port == i ? "En" : "Dis", port); + } + return EC_SUCCESS; } diff --git a/board/zoombini/board.h b/board/zoombini/board.h index 33a2f5c05b..dcfcb9c41c 100644 --- a/board/zoombini/board.h +++ b/board/zoombini/board.h @@ -78,6 +78,7 @@ #define CONFIG_USB_PD_TCPM_PS8805 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_TCPM_MUX +#define CONFIG_USBC_PPC_SN5S330 #define CONFIG_USBC_SS_MUX #define CONFIG_USBC_VCONN #define CONFIG_USBC_VCONN_SWAP |