diff options
author | Boris Mittelberg <bmbm@google.com> | 2023-04-07 14:06:41 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-17 22:21:39 +0000 |
commit | 187f87afaa39ed24c0a6fa30782b6379ed05fed1 (patch) | |
tree | fe08f963f88ca1b3f36c522f13025926e43353b5 /driver | |
parent | 020eba3677f31a4ccb51bf37bf70927a92ef6bf1 (diff) | |
download | chrome-ec-187f87afaa39ed24c0a6fa30782b6379ed05fed1.tar.gz |
ktu1125: fix polarity and vconn sourcing
Set polarity to be used when enabling vconn
BUG=b:207178886
BRANCH=none
TEST=manual test on rex sku2
Change-Id: I82efeeb7d01f7b8baa6493753c0a96471116b1a9
Signed-off-by: Boris Mittelberg <bmbm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4409006
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/ppc/ktu1125.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/driver/ppc/ktu1125.c b/driver/ppc/ktu1125.c index c6ced41f85..698c4f6cb1 100644 --- a/driver/ppc/ktu1125.c +++ b/driver/ppc/ktu1125.c @@ -96,11 +96,10 @@ static int ktu1125_dump(int port) /* helper */ static int ktu1125_power_path_control(int port, int enable) { - int status = enable ? set_flags(port, KTU1125_CTRL_SW_CFG, - KTU1125_SW_AB_EN) : - clr_flags(port, KTU1125_CTRL_SW_CFG, - KTU1125_SW_AB_EN | KTU1125_CC1S_VCONN | - KTU1125_CC2S_VCONN); + int status = + enable ? + set_flags(port, KTU1125_CTRL_SW_CFG, KTU1125_SW_AB_EN) : + clr_flags(port, KTU1125_CTRL_SW_CFG, KTU1125_SW_AB_EN); if (status) { CPRINTS("ppc p%d: Failed to %s power path", port, @@ -345,11 +344,19 @@ static int ktu1125_discharge_vbus(int port, int enable) #ifdef CONFIG_USBC_PPC_VCONN static int ktu1125_set_vconn(int port, int enable) { - int status = enable ? set_flags(port, KTU1125_CTRL_SW_CFG, - KTU1125_VCONN_EN) : - clr_flags(port, KTU1125_CTRL_SW_CFG, - KTU1125_VCONN_EN | KTU1125_CC1S_VCONN | - KTU1125_CC2S_VCONN); + int polarity; + int status; + int flags = KTU1125_VCONN_EN; + + polarity = polarity_rm_dts(pd_get_polarity(port)); + + if (enable) { + flags |= polarity ? KTU1125_CC2S_VCONN : KTU1125_CC1S_VCONN; + status = set_flags(port, KTU1125_SET_SW_CFG, flags); + } else { + flags |= KTU1125_CC1S_VCONN | KTU1125_CC2S_VCONN; + status = clr_flags(port, KTU1125_SET_SW_CFG, flags); + } return status; } |