summaryrefslogtreecommitdiff
path: root/driver/ppc/rt1718s.c
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2021-08-20 16:23:30 +0800
committerCommit Bot <commit-bot@chromium.org>2021-08-25 08:13:24 +0000
commitbe2500881dfbc6ec77885599a01f4f31b32f6239 (patch)
treedf5e978a121aa33909c2769af24a1b87c0dbc827 /driver/ppc/rt1718s.c
parent7373dc974cd6b29babaf36895ab763defb9cf820 (diff)
downloadchrome-ec-be2500881dfbc6ec77885599a01f4f31b32f6239.tar.gz
rt1718s: enable FRS
BUG=b:190348051 TEST=Combined with other CLs in the chain, verify FRS workable on Tomato BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I52a020b1288928eb9a0f3ada1364776cd8e78337 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3109709 Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'driver/ppc/rt1718s.c')
-rw-r--r--driver/ppc/rt1718s.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/driver/ppc/rt1718s.c b/driver/ppc/rt1718s.c
index 8fb9200cb1..96cb789cd0 100644
--- a/driver/ppc/rt1718s.c
+++ b/driver/ppc/rt1718s.c
@@ -173,6 +173,12 @@ static int rt1718s_init(int port)
{
atomic_clear(&flags[port]);
+ if (IS_ENABLED(CONFIG_USB_PD_FRS_PPC))
+ /* Set Rx frs unmasked */
+ RETURN_ERROR(update_bits(port, RT1718S_RT_MASK1,
+ RT1718S_RT_MASK1_M_RX_FRS,
+ 0xFF));
+
return EC_SUCCESS;
}
@@ -183,6 +189,29 @@ static int rt1718s_set_polarity(int port, int polarity)
}
#endif
+#ifdef CONFIG_USB_PD_FRS_PPC
+static int rt1718s_set_frs_enable(int port, int enable)
+{
+ /*
+ * Use write instead of update to save 2 i2c read.
+ * Assume other bits are at their reset value.
+ */
+ int frs_ctrl2 = 0x10, vbus_ctrl_en = 0x3F;
+
+ if (enable) {
+ frs_ctrl2 |= RT1718S_FRS_CTRL2_RX_FRS_EN;
+ frs_ctrl2 |= RT1718S_FRS_CTRL2_VBUS_FRS_EN;
+
+ vbus_ctrl_en |= RT1718S_VBUS_CTRL_EN_GPIO2_VBUS_PATH_EN;
+ vbus_ctrl_en |= RT1718S_VBUS_CTRL_EN_GPIO1_VBUS_PATH_EN;
+ }
+
+ RETURN_ERROR(write_reg(port, RT1718S_FRS_CTRL2, frs_ctrl2));
+ RETURN_ERROR(write_reg(port, RT1718S_VBUS_CTRL_EN, vbus_ctrl_en));
+ return EC_SUCCESS;
+}
+#endif
+
const struct ppc_drv rt1718s_ppc_drv = {
.init = &rt1718s_init,
.is_sourcing_vbus = &rt1718s_is_sourcing_vbus,
@@ -202,4 +231,7 @@ const struct ppc_drv rt1718s_ppc_drv = {
#ifdef CONFIG_USBC_PPC_VCONN
.set_vconn = &tcpci_tcpm_set_vconn,
#endif
+#ifdef CONFIG_USB_PD_FRS_PPC
+ .set_frs_enable = rt1718s_set_frs_enable,
+#endif
};