summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-01-22 17:46:05 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-01 18:08:36 -0800
commite127855f27ace32faa948ee8ab052ccb98e42dd6 (patch)
tree45d3fc814a6b41cec5fac0f24230bc672d245143 /driver
parent1b87ee65ac8f3cd895da6ef2e219670d2f9779ec (diff)
downloadchrome-ec-e127855f27ace32faa948ee8ab052ccb98e42dd6.tar.gz
ppc: Add Vconn and CC polarity settings.
BUG=b:72292985 BRANCH=None TEST=Flash meowth; Verify with twinkie that Vconn is provided for a sink that requires it. Change-Id: I8168d2e4c46e04810dcf5c2898b2c337424eefec Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/888224 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/ppc/sn5s330.c36
-rw-r--r--driver/ppc/sn5s330.h3
2 files changed, 39 insertions, 0 deletions
diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c
index bdc9d3af7d..90f90528ef 100644
--- a/driver/ppc/sn5s330.c
+++ b/driver/ppc/sn5s330.c
@@ -455,6 +455,23 @@ static int sn5s330_is_sourcing_vbus(int port)
return is_sourcing_vbus;
}
+static int sn5s330_set_polarity(int port, int polarity)
+{
+ int regval;
+ int status;
+
+ status = read_reg(port, SN5S330_FUNC_SET4, &regval);
+ if (status)
+ return status;
+
+ if (polarity)
+ regval |= SN5S330_CC_POLARITY; /* CC2 active. */
+ else
+ regval &= ~SN5S330_CC_POLARITY; /* CC1 active. */
+
+ return write_reg(port, SN5S330_FUNC_SET4, regval);
+}
+
static int sn5s330_set_vbus_source_current_limit(int port,
enum tcpc_rp_value rp)
{
@@ -515,6 +532,23 @@ static int sn5s330_discharge_vbus(int port, int enable)
return EC_SUCCESS;
}
+static int sn5s330_set_vconn(int port, int enable)
+{
+ int regval;
+ int status;
+
+ status = read_reg(port, SN5S330_FUNC_SET4, &regval);
+ if (status)
+ return status;
+
+ if (enable)
+ regval |= SN5S330_VCONN_EN;
+ else
+ regval &= ~SN5S330_VCONN_EN;
+
+ return write_reg(port, SN5S330_FUNC_SET4, regval);
+}
+
static int sn5s330_vbus_sink_enable(int port, int enable)
{
return sn5s330_pp_fet_enable(port, SN5S330_PP2, !!enable);
@@ -588,6 +622,8 @@ const struct ppc_drv sn5s330_drv = {
#ifdef CONFIG_USB_PD_VBUS_DETECT_PPC
.is_vbus_present = &sn5s330_is_vbus_present,
#endif /* defined(CONFIG_USB_PD_VBUS_DETECT_PPC) */
+ .set_polarity = &sn5s330_set_polarity,
.set_vbus_source_current_limit = &sn5s330_set_vbus_source_current_limit,
.discharge_vbus = &sn5s330_discharge_vbus,
+ .set_vconn = &sn5s330_set_vconn,
};
diff --git a/driver/ppc/sn5s330.h b/driver/ppc/sn5s330.h
index e8850faf57..2e4b36cbca 100644
--- a/driver/ppc/sn5s330.h
+++ b/driver/ppc/sn5s330.h
@@ -95,6 +95,9 @@ enum sn5s330_pp_idx {
#define SN5S330_SET_RCP_MODE_PP1 (1 << 5)
#define SN5S330_SET_RCP_MODE_PP2 (1 << 6)
+/* FUNC_SET_4 */
+#define SN5S330_VCONN_EN (1 << 0)
+#define SN5S330_CC_POLARITY (1 << 1)
#define SN5S330_CC_EN (1 << 4)
/* FUNC_SET_9 */