summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Mittelberg <bmbm@google.com>2023-04-07 14:06:41 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-17 22:21:39 +0000
commit187f87afaa39ed24c0a6fa30782b6379ed05fed1 (patch)
treefe08f963f88ca1b3f36c522f13025926e43353b5
parent020eba3677f31a4ccb51bf37bf70927a92ef6bf1 (diff)
downloadchrome-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>
-rw-r--r--driver/ppc/ktu1125.c27
-rw-r--r--zephyr/Kconfig.ppc5
2 files changed, 22 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;
}
diff --git a/zephyr/Kconfig.ppc b/zephyr/Kconfig.ppc
index c7108e62a8..7893e0ae08 100644
--- a/zephyr/Kconfig.ppc
+++ b/zephyr/Kconfig.ppc
@@ -80,7 +80,12 @@ config PLATFORM_EC_USBC_PPC_RT1718S
config PLATFORM_EC_USBC_PPC_KTU1125
bool "Kinetic KTU1125 Power Path Controller"
+ default y
+ depends on DT_HAS_KINETIC_KTU1125_ENABLED
select PLATFORM_EC_USBC_OCP
+ select PLATFORM_EC_USBC_PPC_POLARITY
+ select PLATFORM_EC_USBC_PPC_SBU
+ select PLATFORM_EC_USBC_PPC_VCONN if PLATFORM_EC_USBC_VCONN
help
KTU1125 integrates power switches to provide a compact protection
solution to USB Type-C applications by eliminating the dependence