summaryrefslogtreecommitdiff
path: root/board/pdeval-stm32f072/usb_pd_policy.c
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/pdeval-stm32f072/usb_pd_policy.c
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/pdeval-stm32f072/usb_pd_policy.c')
-rw-r--r--board/pdeval-stm32f072/usb_pd_policy.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/board/pdeval-stm32f072/usb_pd_policy.c b/board/pdeval-stm32f072/usb_pd_policy.c
index 2f0022d211..775f8b8876 100644
--- a/board/pdeval-stm32f072/usb_pd_policy.c
+++ b/board/pdeval-stm32f072/usb_pd_policy.c
@@ -36,8 +36,9 @@ const uint32_t pd_snk_pdo[] = {
const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo);
#if defined(CONFIG_USB_PD_TCPM_MUX) && defined(CONFIG_USB_PD_TCPM_ANX7447)
-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 = &anx7447_usb_mux_driver,
},
};
@@ -200,6 +201,9 @@ __override int svdm_dp_config(int port, uint32_t *payload)
{
int opos = pd_alt_mode(port, USB_SID_DISPLAYPORT);
int pin_mode = pd_dfp_dp_get_pin_mode(port, dp_status[port]);
+#if defined(CONFIG_USB_PD_TCPM_MUX) && defined(CONFIG_USB_PD_TCPM_ANX7447)
+ const struct usb_mux *mux = &usb_muxes[port];
+#endif
#ifdef CONFIG_USB_PD_TCPM_ANX7447
mux_state_t mux_state = USB_PD_MUX_NONE;
@@ -217,13 +221,13 @@ __override int svdm_dp_config(int port, uint32_t *payload)
case MODE_DP_PIN_C:
case MODE_DP_PIN_E:
mux_state |= USB_PD_MUX_DP_ENABLED;
- usb_muxes[port].driver->set(port, mux_state);
+ mux->driver->set(mux, mux_state);
break;
case MODE_DP_PIN_B:
case MODE_DP_PIN_D:
case MODE_DP_PIN_F:
mux_state |= USB_PD_MUX_DOCK;
- usb_muxes[port].driver->set(port, mux_state);
+ mux->driver->set(mux, mux_state);
break;
}
#endif
@@ -242,13 +246,14 @@ __override int svdm_dp_config(int port, uint32_t *payload)
__override void svdm_dp_post_config(int port)
{
+ const struct usb_mux *mux = &usb_muxes[port];
+
dp_flags[port] |= DP_FLAGS_DP_ON;
if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING))
return;
-#ifdef CONFIG_USB_PD_TCPM_ANX7447
- anx7447_tcpc_update_hpd_status(port, 1, 0);
-#endif
+ if (IS_ENABLED(CONFIG_USB_PD_TCPM_ANX7447))
+ anx7447_tcpc_update_hpd_status(mux, 1, 0);
}
__override int svdm_dp_attention(int port, uint32_t *payload)
@@ -256,9 +261,10 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
#ifdef CONFIG_USB_PD_TCPM_ANX7447
int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
+ const struct usb_mux *mux = &usb_muxes[port];
CPRINTS("Attention: 0x%x", payload[1]);
- anx7447_tcpc_update_hpd_status(port, lvl, irq);
+ anx7447_tcpc_update_hpd_status(mux, lvl, irq);
#endif
dp_status[port] = payload[1];