summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Herrmann <eherrmann@chromium.org>2020-07-07 13:11:07 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-17 02:22:06 +0000
commitc30291b716c54d94ef648e22df2c107ebfcb6139 (patch)
treefcbdb53636d3c848d1c0e5b736ee8e882846e9cd
parentc1284dc1da4aa6865d4375a67abf6b2f8d3d2219 (diff)
downloadchrome-ec-c30291b716c54d94ef648e22df2c107ebfcb6139.tar.gz
USB PD: Move board FRS configuration out of TCPCI
Board FRS configuration is more board-specific than TCPC-specific. Move the board FRS configuration from TCPCI to usb_common. Implementing the board-level frs configuration is optional for each project. BUG=b:148144711 TEST=Can build volteer image with CONFIG_USB_PD_TCPC set BRANCH=none Change-Id: I43d13ec0b23f71273807f58db35e7dd333089efa Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290838 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--baseboard/zork/baseboard.h4
-rw-r--r--baseboard/zork/variant_trembyle.c2
-rw-r--r--board/dalboz/board.c2
-rw-r--r--board/vilboz/board.c2
-rw-r--r--common/usb_common.c7
-rw-r--r--driver/tcpm/tcpci.c7
-rw-r--r--include/usb_pd.h9
7 files changed, 20 insertions, 13 deletions
diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h
index 95dd544af2..7cce28e6a6 100644
--- a/baseboard/zork/baseboard.h
+++ b/baseboard/zork/baseboard.h
@@ -333,10 +333,6 @@ void bc12_interrupt(enum gpio_signal signal);
void ppc_interrupt(enum gpio_signal signal);
#endif
-#ifdef CONFIG_USB_PD_FRS_TCPC
-int board_tcpc_fast_role_swap_enable(int port, int enable);
-#endif
-
void pi3hdx1204_retimer_power(void);
__override_proto int check_hdmi_hpd_status(void);
int board_get_temp(int idx, int *temp_k);
diff --git a/baseboard/zork/variant_trembyle.c b/baseboard/zork/variant_trembyle.c
index 1cae52cc2a..1464f65d3c 100644
--- a/baseboard/zork/variant_trembyle.c
+++ b/baseboard/zork/variant_trembyle.c
@@ -346,7 +346,7 @@ void tcpc_alert_event(enum gpio_signal signal)
}
-int board_tcpc_fast_role_swap_enable(int port, int enable)
+int board_pd_set_frs_enable(int port, int enable)
{
int rv = EC_SUCCESS;
diff --git a/board/dalboz/board.c b/board/dalboz/board.c
index b15f078f5a..462cd4bc4b 100644
--- a/board/dalboz/board.c
+++ b/board/dalboz/board.c
@@ -490,7 +490,7 @@ void bc12_interrupt(enum gpio_signal signal)
}
}
-int board_tcpc_fast_role_swap_enable(int port, int enable)
+int board_pd_set_frs_enable(int port, int enable)
{
int rv = EC_SUCCESS;
diff --git a/board/vilboz/board.c b/board/vilboz/board.c
index bbfbcc1e5f..23b5f65c22 100644
--- a/board/vilboz/board.c
+++ b/board/vilboz/board.c
@@ -358,7 +358,7 @@ void tcpc_alert_event(enum gpio_signal signal)
schedule_deferred_pd_interrupt(port);
}
-int board_tcpc_fast_role_swap_enable(int port, int enable)
+int board_pd_set_frs_enable(int port, int enable)
{
int rv = EC_SUCCESS;
diff --git a/common/usb_common.c b/common/usb_common.c
index c592deaafa..ea884193f8 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -738,6 +738,11 @@ int pd_is_vbus_present(int port)
}
#ifdef CONFIG_USB_PD_FRS
+__overridable int board_pd_set_frs_enable(int port, int enable)
+{
+ return EC_SUCCESS;
+}
+
int pd_set_frs_enable(int port, int enable)
{
int rv = EC_SUCCESS;
@@ -746,6 +751,8 @@ int pd_set_frs_enable(int port, int enable)
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);
+ if (rv == EC_SUCCESS)
+ rv = board_pd_set_frs_enable(port, enable);
return rv;
}
#endif /* defined(CONFIG_USB_PD_FRS) */
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 99860407a5..ae03f7e097 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -665,15 +665,10 @@ int tcpci_tcpm_set_rx_enable(int port, int enable)
#ifdef CONFIG_USB_PD_FRS_TCPC
int tcpci_tcpc_fast_role_swap_enable(int port, int enable)
{
- int rv;
- rv = tcpc_update8(port,
+ return tcpc_update8(port,
TCPC_REG_POWER_CTRL,
TCPC_REG_POWER_CTRL_FRS_ENABLE,
(enable) ? MASK_SET : MASK_CLR);
- if (rv)
- return rv;
- //TODO move this board FRS configuration call to usb_common
- return board_tcpc_fast_role_swap_enable(port, enable);
}
#endif
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 897517d57c..45732cb4be 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -2663,6 +2663,15 @@ int pd_is_vbus_present(int port);
int pd_set_frs_enable(int port, int enable);
/**
+ * Optional, board-specific configuration to enable the FRS trigger on port
+ *
+ * @param port USB-C port number
+ * @param enable 1 to enable the FRS trigger, 0 to disable
+ * @return EC_SUCCESS on success, or an error
+ */
+__override_proto int board_pd_set_frs_enable(int port, int enable);
+
+/**
* Get current DisplayPort pin mode on the specified port.
*
* @param port USB-C port number