summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlschyi <lschyi@google.com>2022-05-31 16:58:50 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-08 09:47:12 +0000
commit15e11018d2c71a7424382837af65f1a309b38373 (patch)
tree608671ef96d24bd4e7149dc7a2147129b646acb0
parentfe0ba746225d89db6b4a6f1c011632748cff0b72 (diff)
downloadchrome-ec-15e11018d2c71a7424382837af65f1a309b38373.tar.gz
rt1718s: Implement set_sbu
The rt1718s can enable the SBU protection and control in the SBU_CTRL register. Implement the set_sbu function to make projects set the SBU line protection and function within the application. BUG=b:208372205 TEST=manually test with inserting a type c display, then check the SBU register is set enabled and external display is functioning. BRANCH=none Change-Id: I13f3881ddbb3b70f04e8ea88fcb51b1cf37fd517 Signed-off-by: lschyi <lschyi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3682600 Commit-Queue: Sung-Chi Li <lschyi@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com> Tested-by: Sung-Chi Li <lschyi@chromium.org>
-rw-r--r--driver/tcpm/rt1718s.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/driver/tcpm/rt1718s.c b/driver/tcpm/rt1718s.c
index d90e09805d..2dd28646b3 100644
--- a/driver/tcpm/rt1718s.c
+++ b/driver/tcpm/rt1718s.c
@@ -722,6 +722,22 @@ static int command_rt1718s_gpio(int argc, char **argv)
}
DECLARE_CONSOLE_COMMAND(rt1718s_gpio, command_rt1718s_gpio, "", "RT1718S GPIO");
+#ifdef CONFIG_USB_PD_TCPM_SBU
+static int rt1718s_set_sbu(int port, bool enable)
+{
+ /*
+ * The `enable` here means to enable the SBU line (set 1)
+ * - true: connect SBU lines from outer to the host
+ * - false: isolate the SBU lines
+ */
+ return rt1718s_update_bits8(port, RT1718S_RT2_SBU_CTRL_01,
+ RT1718S_RT2_SBU_CTRL_01_SBU_VIEN |
+ RT1718S_RT2_SBU_CTRL_01_SBU1_SWEN |
+ RT1718S_RT2_SBU_CTRL_01_SBU2_SWEN,
+ enable ? 0xFF : 0);
+}
+#endif
+
/* RT1718S is a TCPCI compatible port controller */
const struct tcpm_drv rt1718s_tcpm_drv = {
.init = &rt1718s_init,
@@ -758,6 +774,9 @@ const struct tcpm_drv rt1718s_tcpm_drv = {
.set_frs_enable = &rt1718s_set_frs_enable,
#endif
.set_bist_test_mode = &tcpci_set_bist_test_mode,
+#ifdef CONFIG_USB_PD_TCPM_SBU
+ .set_sbu = &rt1718s_set_sbu,
+#endif
};
const struct bc12_drv rt1718s_bc12_drv = {