diff options
author | Marc Zyngier <maz@kernel.org> | 2023-10-26 21:12:54 +0100 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2023-10-26 21:17:41 +0100 |
commit | d3d964d7690cb0c49af6ff911b6651b48440170f (patch) | |
tree | 9c2851ae922ff7c30a5f9e5bc1e498a8ebf768bb | |
parent | def63190f801a0025c6e6e12a3f332a667d594e1 (diff) | |
download | cs-sw-d3d964d7690cb0c49af6ff911b6651b48440170f.tar.gz |
Revert "Don't measure CC lines twice"
This reverts commit 248085cfe30a7dcf2ae819173604a0ae869c5612.
It appears that my M1 mini running some ancient firmware insist
on requiring the double checking, and displays the following
syndrome:
P0: S: DISCONNECTED
P0: Poll: cc1=2 cc2=0
P0: Connected: cc1=1 cc2=2
P0: Polarity: CC2 (flipped)
The first read of the CC lines reports something that is completely
wrong, while the second one behaves correctly.
My other machines don't behave like this at all. Until the problem
is undertood, let's go back to the original code.
Signed-off-by: Marc Zyngier <maz@kernel.org>
-rw-r--r-- | vdmtool.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -32,7 +32,6 @@ struct vdm_context { bool vdm_escape; bool cc_line; uint8_t serial_pin_set; - uint8_t version; }; static struct vdm_context vdm_contexts[CONFIG_USB_PD_PORT_COUNT]; @@ -88,16 +87,16 @@ void debug_poke(struct vdm_context *cxt) fusb302_tcpm_transmit(PORT(cxt), TCPC_TX_SOP_DEBUG_PRIME_PRIME, hdr, &x); } -static void evt_dfpconnect(struct vdm_context *cxt, int16_t cc1, int16_t cc2) +static void evt_dfpconnect(struct vdm_context *cxt) { - int ms = 200; - + int16_t cc1 = -1, cc2 = -1; + fusb302_tcpm_get_cc(PORT(cxt), &cc1, &cc2); cprintf(cxt, "Connected: cc1=%d cc2=%d\n", cc1, cc2); + if (cc1 < 2 && cc2 < 2) { + cprintf(cxt, "Nope.\n"); + return; + } - /* The original FUSB302 needs a bit longer... */ - if ((cxt->version & 0xf0) < 0x90) - ms += 300; - sleep_ms(ms); fusb302_tcpm_set_vconn(PORT(cxt), 0); fusb302_pd_reset(PORT(cxt)); @@ -579,7 +578,8 @@ static void state_machine(struct vdm_context *cxt) fusb302_tcpm_get_cc(PORT(cxt), &cc1, &cc2); dprintf(cxt, "Poll: cc1=%d cc2=%d\n", (int)cc1, (int)cc2); if (cc1 >= 2 || cc2 >= 2) { - evt_dfpconnect(cxt, cc1, cc2); + sleep_ms(500); + evt_dfpconnect(cxt); } else { vbus_off(cxt); } @@ -685,8 +685,6 @@ void m1_pd_bmc_fusb_setup(unsigned int port, cprintf(cxt, "Device ID: %c_rev%c (0x%x)\n", 'A' + ((reg >> 4) & 0x7), 'A' + (reg & 3), reg); - cxt->version = reg & 0xff; - cprintf(cxt, "Init\n"); fusb302_tcpm_init(PORT(cxt)); |