Skip to content

Commit

Permalink
Implement DFP mode
Browse files Browse the repository at this point in the history
UFP mode does not work during early mode, DFP mode does
  • Loading branch information
marcan committed Jan 12, 2021
1 parent fd279c2 commit f5b4c0c
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 13 deletions.
59 changes: 52 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ USB-PD VDM documentation is [here](https://github.com/AsahiLinux/docs/wiki/Hardw
You can use a breakout board or a bare [FUSB302](https://www.onsemi.com/pub/Collateral/FUSB302-D.PDF). You need to wire it as follows:

* 1 CC2 → Type-C CC2 (B5) - ONLY wire this to a Type-C *socket* used with a cable. Otherwise leave open.
* 2 VBUS → Type-C VBUS (A4/A9/B4/B9)
* 2 VBUS → Arduino D4, Type-C VBUS (A4/A9/B4/B9)
* 3 VDD → Arduino 3.3V
* 4 VDD ↑
* 5 INT_N → Arduino D12
Expand All @@ -29,19 +29,64 @@ You can get away without decoupling and with only connecting one of the duplicat

By default the code will perform trivial (mostly hardcoded) USB-PD negotiation, then request to mux the debug UART over SBU1/SBU2. You can send custom VDMs using the Arduino serial terminal at 500000 baud.

Sample session:
Sample DFP mode session:

```
VBUS OFF
Device ID: 0x91
Init
STATUS0: 0x0
VBUS OFF
Disconnected
S: DISCONNECTED
Poll: cc1=0 cc2=0
Poll: cc1=2 cc2=0
Connected: cc1=2 cc2=0
Polarity: CC1 (normal)
VBUS ON
S: DFP_VBUS_ON
IRQ: VBUSOK (VBUS=ON)
>SOURCE_CAP
S: DFP_CONNECTED
IRQ: HARDRESET
VBUS OFF
Disconnected
S: DISCONNECTED
Poll: cc1=2 cc2=0
Connected: cc1=2 cc2=0
Polarity: CC1 (normal)
VBUS ON
S: DFP_VBUS_ON
IRQ: VBUSOK (VBUS=ON)
>SOURCE_CAP
S: DFP_CONNECTED
<REQUEST: 12000000
>ACCEPT
>PS_RDY
S: IDLE
<GET_SINK_CAP
>SINK_CAP
S: READY
>VDM SET ACTION serial -> SBU1/2
S: IDLE
<VDM RX SOP"DEBUG (5) [504F] 5AC8052 44740000 306 0 0
```

Sample UFP mode session:

```
VBUS OFF
Device ID: 0x91
Init
STATUS0: 0x0
Disconnected
IRQ: VBUSOK (VBUS=OFF)
State: DISCONNECTED
State: DISCONNECTED
S: DISCONNECTED
S: DISCONNECTED
IRQ: VBUSOK (VBUS=ON)
Connected: cc1=7 cc2=0
Polarity: CC1 (normal)
State: CONNECTED
S: CONNECTED
<SOURCE_CAP: 3F01912C
>REQUEST
<ACCEPT
Expand All @@ -54,9 +99,9 @@ State: CONNECTED
>SINK_CAP
<VDM DISCOVER_IDENTITY
>VDM DISCOVER_IDENTITY
State: READY
S: READY
>VDM SET ACTION serial -> SBU1/2
State: IDLE
S: IDLE
input: "5AC8010\n"
>VDM 5AC8010
<VDM RX SOP'DEBUG (7) [724F] 5AC8050 46060606 2060301 3060106 1050303 8030809 1030000
Expand Down
1 change: 1 addition & 0 deletions vdmtool/FUSB302.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static struct fusb302_chip_state {
void fusb302_pd_reset(int port)
{
tcpc_write(port, TCPC_REG_RESET, TCPC_REG_RESET_PD_RESET);
state[port].msgid = 0;
}

/*
Expand Down
Loading

0 comments on commit f5b4c0c

Please sign in to comment.