summaryrefslogtreecommitdiff
path: root/board/cheza
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2020-02-21 14:21:05 -0700
committerCommit Bot <commit-bot@chromium.org>2020-02-28 22:47:11 +0000
commit9c194fd057558a1dfadee419e92aca31953a86fc (patch)
tree001ae7c162a4152312a180574ae58e19a3763eb8 /board/cheza
parentab35b456ad8c52f336ea793b17155cfc796c4e44 (diff)
downloadchrome-ec-9c194fd057558a1dfadee419e92aca31953a86fc.tar.gz
usb_mux: retimer: mux as chained mux and retimer
This makes retimers appear as generic muxes. By allowing a chain of muxes they can be stacked up to the new configurations that zork requires and will continue to work as they did before on configurations that only have a single mux. The code used to have two different arrays, 1) muxes and 2) retimers. On one of the zork configurations the processor MUX stopped being the primary mux and the retimer took its place. In a different configuration of that same platform it left the primary and secondary alone but the mux_set FLIP operation had to be ignored. Since the same interfaces needed to be available for both it stopped making sense to have two different structures and two different methods of handling them. This consolodates the two into one. The platforms that do not have retimers, this change will not make any difference. For platforms like zork, it will remove the retimers and make them chained muxes. So testing on trembyle makes sense to verify, BUG=b:147593660 BRANCH=none TEST=verify USB still works on trembyle Change-Id: I286cf1e302f9bd3dd7e81098ec08514a2a009fe3 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2066794 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'board/cheza')
-rw-r--r--board/cheza/board.c45
-rw-r--r--board/cheza/usb_pd_policy.c3
2 files changed, 22 insertions, 26 deletions
diff --git a/board/cheza/board.c b/board/cheza/board.c
index 232f6cfc3d..855451049d 100644
--- a/board/cheza/board.c
+++ b/board/cheza/board.c
@@ -294,23 +294,23 @@ const unsigned int chg_cnt = ARRAY_SIZE(chg_chips);
* Redirect to anx74xx_tcpm_usb_mux_driver but override the get() function
* to check the HPD_IRQ mask from virtual_usb_mux_driver.
*/
-static int port0_usb_mux_init(int port)
+static int port0_usb_mux_init(const struct usb_mux *me)
{
- return anx74xx_tcpm_usb_mux_driver.init(port);
+ return anx74xx_tcpm_usb_mux_driver.init(me);
}
-static int port0_usb_mux_set(int i2c_addr, mux_state_t mux_state)
+static int port0_usb_mux_set(const struct usb_mux *me, mux_state_t mux_state)
{
- return anx74xx_tcpm_usb_mux_driver.set(i2c_addr, mux_state);
+ return anx74xx_tcpm_usb_mux_driver.set(me, mux_state);
}
-static int port0_usb_mux_get(int port, mux_state_t *mux_state)
+static int port0_usb_mux_get(const struct usb_mux *me, mux_state_t *mux_state)
{
int rv;
mux_state_t virtual_mux_state;
- rv = anx74xx_tcpm_usb_mux_driver.get(port, mux_state);
- rv |= virtual_usb_mux_driver.get(port, &virtual_mux_state);
+ rv = anx74xx_tcpm_usb_mux_driver.get(me, mux_state);
+ rv |= virtual_usb_mux_driver.get(me, &virtual_mux_state);
if (virtual_mux_state & USB_PD_MUX_HPD_IRQ)
*mux_state |= USB_PD_MUX_HPD_IRQ;
@@ -330,32 +330,32 @@ const struct usb_mux_driver port0_usb_mux_driver = {
* Redirect to tcpci_tcpm_usb_mux_driver but override the get() function
* to check the HPD_IRQ mask from virtual_usb_mux_driver.
*/
-static int port1_usb_mux_init(int port)
+static int port1_usb_mux_init(const struct usb_mux *me)
{
- return tcpci_tcpm_usb_mux_driver.init(port);
+ return tcpci_tcpm_usb_mux_driver.init(me);
}
-static int port1_usb_mux_set(int i2c_addr, mux_state_t mux_state)
+static int port1_usb_mux_set(const struct usb_mux *me, mux_state_t mux_state)
{
- return tcpci_tcpm_usb_mux_driver.set(i2c_addr, mux_state);
+ return tcpci_tcpm_usb_mux_driver.set(me, mux_state);
}
-static int port1_usb_mux_get(int port, mux_state_t *mux_state)
+static int port1_usb_mux_get(const struct usb_mux *me, mux_state_t *mux_state)
{
int rv;
mux_state_t virtual_mux_state;
- rv = tcpci_tcpm_usb_mux_driver.get(port, mux_state);
- rv |= virtual_usb_mux_driver.get(port, &virtual_mux_state);
+ rv = tcpci_tcpm_usb_mux_driver.get(me, mux_state);
+ rv |= virtual_usb_mux_driver.get(me, &virtual_mux_state);
if (virtual_mux_state & USB_PD_MUX_HPD_IRQ)
*mux_state |= USB_PD_MUX_HPD_IRQ;
return rv;
}
-static int port1_usb_mux_enter_low_power(int port)
+static int port1_usb_mux_enter_low_power(const struct usb_mux *me)
{
- return tcpci_tcpm_usb_mux_driver.enter_low_power_mode(port);
+ return tcpci_tcpm_usb_mux_driver.enter_low_power_mode(me);
}
const struct usb_mux_driver port1_usb_mux_driver = {
@@ -365,12 +365,14 @@ const struct usb_mux_driver port1_usb_mux_driver = {
.enter_low_power_mode = &port1_usb_mux_enter_low_power,
};
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
+ .usb_port = 0,
.driver = &port0_usb_mux_driver,
.hpd_update = &virtual_hpd_update,
},
{
+ .usb_port = 1,
.driver = &port1_usb_mux_driver,
.hpd_update = &virtual_hpd_update,
}
@@ -406,8 +408,6 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
void board_tcpc_init(void)
{
- int port;
-
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image()) {
/* TODO(crosbug.com/p/61098): How long do we need to wait? */
@@ -428,11 +428,8 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, 0, 0);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
diff --git a/board/cheza/usb_pd_policy.c b/board/cheza/usb_pd_policy.c
index 17f75136f9..694899ab79 100644
--- a/board/cheza/usb_pd_policy.c
+++ b/board/cheza/usb_pd_policy.c
@@ -177,11 +177,10 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
int mf_pref = PD_VDO_DPSTS_MF_PREF(payload[1]);
- const struct usb_mux *mux = &usb_muxes[port];
dp_status[port] = payload[1];
- mux->hpd_update(port, lvl, irq);
+ usb_mux_hpd_update(port, lvl, irq);
if (lvl && is_dp_muxable(port)) {
/*