summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2021-04-19 20:45:32 -0700
committerCommit Bot <commit-bot@chromium.org>2021-04-21 02:22:18 +0000
commit07a2b0e11684be396edf1f421b9e4dc2b8b30683 (patch)
treeb4d2365a5812df30daeebe1e738eb5d8337c63b0 /include
parent0f69cef4c4871d70f959eff2e54761acc0e0921b (diff)
downloadchrome-ec-07a2b0e11684be396edf1f421b9e4dc2b8b30683.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>
Diffstat (limited to 'include')
-rw-r--r--include/driver/tcpm/tcpci.h4
-rw-r--r--include/driver/tcpm/tcpm.h23
-rw-r--r--include/usb_pd_tcpm.h10
3 files changed, 12 insertions, 25 deletions
diff --git a/include/driver/tcpm/tcpci.h b/include/driver/tcpm/tcpci.h
index 0dc5dadc6a..18cddd9b61 100644
--- a/include/driver/tcpm/tcpci.h
+++ b/include/driver/tcpm/tcpci.h
@@ -282,9 +282,9 @@ int tcpci_tcpm_mux_enter_low_power(const struct usb_mux *me);
int tcpci_get_chip_info(int port, int live,
struct ec_response_pd_chip_info_v1 *chip_info);
#ifdef CONFIG_USBC_PPC
-int tcpci_tcpm_get_snk_ctrl(int port, bool *sinking);
+bool tcpci_tcpm_get_snk_ctrl(int port);
int tcpci_tcpm_set_snk_ctrl(int port, int enable);
-int tcpci_tcpm_get_src_ctrl(int port, bool *sourcing);
+bool tcpci_tcpm_get_src_ctrl(int port);
int tcpci_tcpm_set_src_ctrl(int port, int enable);
#endif
diff --git a/include/driver/tcpm/tcpm.h b/include/driver/tcpm/tcpm.h
index 901f44a26a..df717dcb6a 100644
--- a/include/driver/tcpm/tcpm.h
+++ b/include/driver/tcpm/tcpm.h
@@ -255,16 +255,10 @@ static inline int tcpm_transmit(int port, enum tcpm_transmit_type type,
}
#ifdef CONFIG_USB_PD_PPC
-static inline int tcpm_get_snk_ctrl(int port, bool *sinking)
+static inline bool tcpm_get_snk_ctrl(int port)
{
- int rv = EC_ERROR_UNIMPLEMENTED;
-
- if (tcpc_config[port].drv->get_snk_ctrl != NULL)
- rv = tcpc_config[port].drv->get_snk_ctrl(port, sinking);
- else
- *sinking = false;
-
- return rv;
+ return tcpc_config[port].drv->get_snk_ctrl ?
+ tcpc_config[port].drv->get_snk_ctrl(port) : false;
}
static inline int tcpm_set_snk_ctrl(int port, int enable)
{
@@ -274,16 +268,11 @@ static inline int tcpm_set_snk_ctrl(int port, int enable)
return EC_ERROR_UNIMPLEMENTED;
}
-static inline int tcpm_get_src_ctrl(int port, bool *sourcing)
+static inline bool tcpm_get_src_ctrl(int port)
{
- int rv = EC_ERROR_UNIMPLEMENTED;
- if (tcpc_config[port].drv->get_src_ctrl != NULL)
- rv = tcpc_config[port].drv->get_src_ctrl(port, sourcing);
- else
- *sourcing = false;
-
- return rv;
+ return tcpc_config[port].drv->get_src_ctrl ?
+ tcpc_config[port].drv->get_src_ctrl(port) : false;
}
static inline int tcpm_set_src_ctrl(int port, int enable)
{
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index a814c2b7af..fddcb04c3a 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -373,11 +373,10 @@ struct tcpm_drv {
* NOTE: this is most useful for PPCs that can not tell on their own
*
* @param port Type-C port number
- * @param is_sinking true for sinking, false for not
*
- * @return EC_SUCCESS, EC_ERROR_UNIMPLEMENTED or error
+ * @return true if sinking else false
*/
- int (*get_snk_ctrl)(int port, bool *sinking);
+ bool (*get_snk_ctrl)(int port);
/**
* Send SinkVBUS or DisableSinkVBUS command
@@ -394,11 +393,10 @@ struct tcpm_drv {
* NOTE: this is most useful for PPCs that can not tell on their own
*
* @param port Type-C port number
- * @param is_sourcing true for sourcing, false for not
*
- * @return EC_SUCCESS, EC_ERROR_UNIMPLEMENTED or error
+ * @return true if sourcing else false
*/
- int (*get_src_ctrl)(int port, bool *sourcing);
+ bool (*get_src_ctrl)(int port);
/**
* Send SourceVBUS or DisableSourceVBUS command