diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2021-04-19 20:45:32 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-27 19:26:33 +0000 |
commit | 450d88fb41b6d31f5cd57e50fc16139f9a277bbe (patch) | |
tree | 355df1b61528f08b4e2136fbbbd3cd972bf3c885 /driver | |
parent | f22a183b1cf3117d61527948740c39bb48744b20 (diff) | |
download | chrome-ec-450d88fb41b6d31f5cd57e50fc16139f9a277bbe.tar.gz |
TCPC: Cleanup: Get Sink & SRC state from PD or PPC
Added option to get the Sinking or Sourcing state from either
PD or PPC.
BUG=none
BRANCH=none
TEST=make buildall -j
Change-Id: Ibb21ef69b5825ea5722ceacd5d7ef6f535aad17c
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2838127
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2854420
Tested-by: Abe Levkoy <alevkoy@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/ppc/aoz1380.c | 9 | ||||
-rw-r--r-- | driver/tcpm/nct38xx.c | 15 | ||||
-rw-r--r-- | driver/tcpm/tcpci.c | 16 |
3 files changed, 11 insertions, 29 deletions
diff --git a/driver/ppc/aoz1380.c b/driver/ppc/aoz1380.c index 9ce5b442ac..4e2188c60d 100644 --- a/driver/ppc/aoz1380.c +++ b/driver/ppc/aoz1380.c @@ -37,17 +37,12 @@ static uint32_t flags[CONFIG_USB_PD_PORT_MAX_COUNT]; static int aoz1380_init(int port) { - int rv; - bool is_sinking, is_sourcing; - flags[port] = 0; - rv = tcpm_get_snk_ctrl(port, &is_sinking); - if (rv == EC_SUCCESS && is_sinking) + if (tcpm_get_snk_ctrl(port)) AOZ1380_SET_FLAG(port, AOZ1380_FLAGS_SINK_ENABLED); - rv = tcpm_get_src_ctrl(port, &is_sourcing); - if (rv == EC_SUCCESS && is_sourcing) + if (tcpm_get_src_ctrl(port)) AOZ1380_SET_FLAG(port, AOZ1380_FLAGS_SOURCE_ENABLED); return EC_SUCCESS; diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c index 5d2be3ad2f..f4e3382d3a 100644 --- a/driver/tcpm/nct38xx.c +++ b/driver/tcpm/nct38xx.c @@ -148,19 +148,10 @@ static int nct38xx_tcpm_set_cc(int port, int pull) * SNKEN will be re-enabled in nct38xx_init above (from tcpm_init), or * when CC lines are set again, or when sinking is disabled. */ - enum mask_update_action action = MASK_SET; int rv; - - if (pull == TYPEC_CC_OPEN) { - bool is_sinking; - - rv = tcpm_get_snk_ctrl(port, &is_sinking); - if (rv) - return rv; - - if (is_sinking) - action = MASK_CLR; - } + enum mask_update_action action = + pull == TYPEC_CC_OPEN && tcpm_get_snk_ctrl(port) ? + MASK_CLR : MASK_SET; rv = tcpc_update8(port, NCT38XX_REG_CTRL_OUT_EN, diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 64707c67df..56af65cc75 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -575,17 +575,15 @@ int tcpci_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) } #ifdef CONFIG_USB_PD_PPC -int tcpci_tcpm_get_snk_ctrl(int port, bool *sinking) +bool tcpci_tcpm_get_snk_ctrl(int port) { int rv; int pwr_sts; rv = tcpci_tcpm_get_power_status(port, &pwr_sts); - *sinking = (rv != EC_SUCCESS) - ? 0 - : pwr_sts & TCPC_REG_POWER_STATUS_SINKING_VBUS; - return rv; + return rv == EC_SUCCESS && + pwr_sts & TCPC_REG_POWER_STATUS_SINKING_VBUS; } int tcpci_tcpm_set_snk_ctrl(int port, int enable) @@ -596,17 +594,15 @@ int tcpci_tcpm_set_snk_ctrl(int port, int enable) return tcpc_write(port, TCPC_REG_COMMAND, cmd); } -int tcpci_tcpm_get_src_ctrl(int port, bool *sourcing) +bool tcpci_tcpm_get_src_ctrl(int port) { int rv; int pwr_sts; rv = tcpci_tcpm_get_power_status(port, &pwr_sts); - *sourcing = (rv != EC_SUCCESS) - ? 0 - : pwr_sts & TCPC_REG_POWER_STATUS_SOURCING_VBUS; - return rv; + return rv == EC_SUCCESS && + pwr_sts & TCPC_REG_POWER_STATUS_SOURCING_VBUS; } int tcpci_tcpm_set_src_ctrl(int port, int enable) |