From be2500881dfbc6ec77885599a01f4f31b32f6239 Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Fri, 20 Aug 2021 16:23:30 +0800 Subject: 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 Change-Id: I52a020b1288928eb9a0f3ada1364776cd8e78337 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3109709 Reviewed-by: Eric Yilun Lin Commit-Queue: Ting Shen Tested-by: Ting Shen --- driver/ppc/rt1718s.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'driver/ppc') 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 }; -- cgit v1.2.1