summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2020-07-01 16:36:48 +1000
committerCommit Bot <commit-bot@chromium.org>2020-07-06 03:40:27 +0000
commit3f01ed23cae2dd07bc8d9ec69f5a15aa9afaefa3 (patch)
tree755252b65e1941fc3b335dc83faa1cacb9bb0c07
parent443d8cbb9e682302f665aef737bd746f19e5dcc1 (diff)
downloadchrome-ec-3f01ed23cae2dd07bc8d9ec69f5a15aa9afaefa3.tar.gz
usbc: only try to use ppc_set_frs_enable if it exists
The driver function to set FRS enable only exists if CONFIG_USB_PD_FRS_PPC is enabled, so we must also make its callers conditional in the same way. For consistency, also revise the TCPC FRS code paths to be conditional. BUG=b:146393213 BRANCH=None TEST=make buildall Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I3fb14c711dd2abdf6ef77d469b2103f37daac182 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276125 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--common/mock/tcpc_mock.c2
-rw-r--r--common/usb_common.c9
-rw-r--r--common/usbc_ppc.c4
-rw-r--r--driver/tcpm/tcpm.h2
-rw-r--r--include/usb_pd_tcpm.h2
5 files changed, 15 insertions, 4 deletions
diff --git a/common/mock/tcpc_mock.c b/common/mock/tcpc_mock.c
index 6dd5da7248..71be5ca281 100644
--- a/common/mock/tcpc_mock.c
+++ b/common/mock/tcpc_mock.c
@@ -197,5 +197,7 @@ const struct tcpm_drv mock_tcpc_driver = {
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
.enter_low_power_mode = &mock_enter_low_power_mode,
#endif
+#ifdef CONFIG_USB_PD_FRS_TCPC
.set_frs_enable = &mock_set_frs_enable,
+#endif
};
diff --git a/common/usb_common.c b/common/usb_common.c
index 9cf12ff6d2..b1920e3351 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -740,8 +740,13 @@ int pd_is_vbus_present(int port)
#ifdef CONFIG_USB_PD_FRS
int pd_set_frs_enable(int port, int enable)
{
- ppc_set_frs_enable(port, enable);
- return tcpm_set_frs_enable(port, enable);
+ int rv = EC_SUCCESS;
+
+ if (IS_ENABLED(CONFIG_USB_PD_FRS_PPC))
+ rv = ppc_set_frs_enable(port, enable);
+ if (rv == EC_SUCCESS && IS_ENABLED(CONFIG_USB_PD_FRS_TCPC))
+ rv = tcpm_set_frs_enable(port, enable);
+ return rv;
}
#endif /* defined(CONFIG_USB_PD_FRS) */
diff --git a/common/usbc_ppc.c b/common/usbc_ppc.c
index 765e028a65..c3710c0852 100644
--- a/common/usbc_ppc.c
+++ b/common/usbc_ppc.c
@@ -323,7 +323,7 @@ int ppc_vbus_source_enable(int port, int enable)
return rv;
}
-#ifdef CONFIG_USB_PD_FRS
+#ifdef CONFIG_USB_PD_FRS_PPC
int ppc_set_frs_enable(int port, int enable)
{
int rv = EC_ERROR_UNIMPLEMENTED;
@@ -341,7 +341,7 @@ int ppc_set_frs_enable(int port, int enable)
return rv;
}
-#endif /* defined(CONFIG_USB_PD_FRS) */
+#endif /* defined(CONFIG_USB_PD_FRS_PPC) */
#ifdef CONFIG_USB_PD_VBUS_DETECT_PPC
int ppc_is_vbus_present(int port)
diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h
index 9bb8362158..0c2f0417e9 100644
--- a/driver/tcpm/tcpm.h
+++ b/driver/tcpm/tcpm.h
@@ -461,6 +461,7 @@ int tcpm_has_pending_message(int port);
*/
void tcpm_clear_pending_messages(int port);
+#ifdef CONFIG_USB_PD_FRS_TCPC
/**
* Enable/Disable TCPC Fast Role Swap detection
*
@@ -482,6 +483,7 @@ static inline int tcpm_set_frs_enable(int port, int enable)
rv = tcpc->set_frs_enable(port, enable);
return rv;
}
+#endif /* defined(CONFIG_USB_PD_FRS_TCPC) */
#ifdef CONFIG_CMD_TCPC_DUMP
static inline void tcpm_dump_registers(int port)
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index fb46d055e7..26131214ba 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -387,6 +387,7 @@ struct tcpm_drv {
int (*enter_low_power_mode)(int port);
#endif
+#ifdef CONFIG_USB_PD_FRS_TCPC
/**
* Enable/Disable TCPC FRS detection
*
@@ -396,6 +397,7 @@ struct tcpm_drv {
* @return EC_SUCCESS or error
*/
int (*set_frs_enable)(int port, int enable);
+#endif
/**
* Handle TCPCI Faults