summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-09-25 18:27:19 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-03-26 04:42:42 -0700
commit901dfa10e5204bb6e45f5f70d068aeefa3ad452b (patch)
tree3635f4a4ee73de30d6b8568cd1c8864ef011b94d
parenta4c7cc8ab45d47fff3ab4c45d6a93ea449208e4d (diff)
downloadchrome-ec-901dfa10e5204bb6e45f5f70d068aeefa3ad452b.tar.gz
sn5s330: Add support for SBU FET control.
The SN5S330 has FETs for the SBU lines which need to be controlled by the TCPM. This commit adds a function to control the SBU FETs and enables them when configuring the USB mux. This commit also fixes a bug with the external VBUS current limit setting by setting it appropriately to a min of ~3A. BUG=b:114340064 BRANCH=firmware-nocturne-10984.B TEST=Flash nocturne; plug in hoho; verify that external display is shown. Bounce thru S5, verify that external display still works. TEST=Repeat above with superspeed hub instead. Change-Id: I931f7a47d4eb28e8d9e3cb188601ce0889a44f8d Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1244382 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1530125 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--common/usbc_ppc.c10
-rw-r--r--driver/ppc/sn5s330.c19
-rw-r--r--driver/usb_mux.c9
-rw-r--r--include/config.h4
-rw-r--r--include/usbc_ppc.h18
5 files changed, 59 insertions, 1 deletions
diff --git a/common/usbc_ppc.c b/common/usbc_ppc.c
index 9ec33a3ec1..54da1f22b4 100644
--- a/common/usbc_ppc.c
+++ b/common/usbc_ppc.c
@@ -140,6 +140,16 @@ int ppc_is_port_latched_off(int port)
return oc_event_cnt_tbl[port] >= PPC_OC_CNT_THRESH;
}
+#ifdef CONFIG_USBC_PPC_SBU
+int ppc_set_sbu(int port, int enable)
+{
+ if ((port < 0) || (port >= ppc_cnt))
+ return EC_ERROR_INVAL;
+
+ return ppc_chips[port].drv->set_sbu(port, enable);
+}
+#endif /* defined(CONFIG_USBC_PPC_SBU) */
+
#ifdef CONFIG_USBC_PPC_VCONN
int ppc_set_vconn(int port, int enable)
{
diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c
index 6b48c8650b..c73182ca81 100644
--- a/driver/ppc/sn5s330.c
+++ b/driver/ppc/sn5s330.c
@@ -246,7 +246,7 @@ static int sn5s330_init(int port)
}
/* Enable SBU Fets and set PP2 current limit to ~3A. */
- regval = SN5S330_SBU_EN | 0xf;
+ regval = SN5S330_SBU_EN | 0x8;
status = i2c_write8(i2c_port, i2c_addr, SN5S330_FUNC_SET2, regval);
if (status) {
CPRINTS("ppc p%d: Failed to set FUNC_SET2!", port);
@@ -667,6 +667,20 @@ static void sn5s330_handle_interrupt(int port)
}
}
+#ifdef CONFIG_USBC_PPC_SBU
+static int sn5s330_set_sbu(int port, int enable)
+{
+ int rv;
+
+ if (enable)
+ rv = set_flags(port, SN5S330_FUNC_SET2, SN5S330_SBU_EN);
+ else
+ rv = clr_flags(port, SN5S330_FUNC_SET2, SN5S330_SBU_EN);
+
+ return rv;
+}
+#endif /* CONFIG_USBC_PPC_SBU */
+
static void sn5s330_irq_deferred(void)
{
int i;
@@ -701,6 +715,9 @@ const struct ppc_drv sn5s330_drv = {
#ifdef CONFIG_USBC_PPC_POLARITY
.set_polarity = &sn5s330_set_polarity,
#endif
+#ifdef CONFIG_USBC_PPC_SBU
+ .set_sbu = &sn5s330_set_sbu,
+#endif /* defined(CONFIG_USBC_PPC_SBU) */
#ifdef CONFIG_USBC_PPC_VCONN
.set_vconn = &sn5s330_set_vconn,
#endif
diff --git a/driver/usb_mux.c b/driver/usb_mux.c
index 5ef11d7ac1..2b94dede60 100644
--- a/driver/usb_mux.c
+++ b/driver/usb_mux.c
@@ -9,6 +9,7 @@
#include "console.h"
#include "host_command.h"
#include "usb_mux.h"
+#include "usbc_ppc.h"
#include "util.h"
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
@@ -97,6 +98,14 @@ void usb_mux_set(int port, enum typec_mux mux_mode,
usb_charger_set_switches(port, usb_mode);
#endif
+#ifdef CONFIG_USBC_PPC_SBU
+ /* Make sure to disable/enable the SBU FETs if needed. */
+ if (mux_mode == TYPEC_MUX_NONE)
+ ppc_set_sbu(port, 0);
+ else
+ ppc_set_sbu(port, 1);
+#endif /* CONFIG_USBC_PPC_SBU */
+
/*
* Don't wake device up just to put it back to sleep. Low power mode
* flag is only set if the mux set() operation succeeded previously for
diff --git a/include/config.h b/include/config.h
index b53c48cfc1..5607fecde2 100644
--- a/include/config.h
+++ b/include/config.h
@@ -3463,6 +3463,9 @@
#undef CONFIG_USBC_PPC_SN5S330
#undef CONFIG_USBC_PPC_SYV682X
+/* PPC is capable of gating the SBU lines. */
+#undef CONFIG_USBC_PPC_SBU
+
/* PPC is capable of providing VCONN */
#undef CONFIG_USBC_PPC_VCONN
@@ -4028,6 +4031,7 @@
/* The TI SN5S330 supports VCONN and needs to be informed of CC polarity */
#if defined(CONFIG_USBC_PPC_SN5S330)
#define CONFIG_USBC_PPC_POLARITY
+#define CONFIG_USBC_PPC_SBU
#define CONFIG_USBC_PPC_VCONN
#endif
diff --git a/include/usbc_ppc.h b/include/usbc_ppc.h
index a502ebe91e..fbd4385afc 100644
--- a/include/usbc_ppc.h
+++ b/include/usbc_ppc.h
@@ -89,6 +89,16 @@ struct ppc_drv {
*/
int (*discharge_vbus)(int port, int enable);
+#ifdef CONFIG_USBC_PPC_SBU
+ /**
+ * Turn on/off the SBU FETs.
+ *
+ * @param port: The Type-C port number.
+ * @param enable: 1: enable SBU FETs 0: disable SBU FETs.
+ */
+ int (*set_sbu)(int port, int enable);
+#endif /* CONFIG_USBC_PPC_SBU */
+
#ifdef CONFIG_USBC_PPC_VCONN
/**
* Turn on/off the VCONN FET.
@@ -225,6 +235,14 @@ int ppc_set_polarity(int port, int polarity);
int ppc_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp);
/**
+ * Turn on/off the SBU FETs.
+ *
+ * @param port: The Type-C port number.
+ * @param enable: 1: enable SBU FETs 0: disable SBU FETs.
+ */
+int ppc_set_sbu(int port, int enable);
+
+/**
* Turn on/off the VCONN FET.
*
* @param port: The Type-C port number.