[PATCH v10 0/3] usb: dwc3: support two connectors sharing one HS data bus

From: Qianhui Xu

Date: Fri Nov 20 2026 - 21:22:05 EST


Two USB Type-C receptacles can share one High Speed D+/D- pair if a
multiplexer selects which of them drives the controller. This series
describes that in the DWC3 binding, adds the endpoint-scoped role-switch
lookup the connectors need, and drives the shared data path from the DWC3
mode worker through the mux controller API.

No runtime testing is claimed for this version: the mux path has not been
exercised on hardware. The series was reviewed statically and through the
gates listed below.

*** AI-assistance disclosure ***
This series was prepared with the help of an LLM coding assistant. The
author reviewed every line, checked every quoted claim against the tree,
and ran the gates quoted below; the design decisions and any errors are the
author's. Each patch repeats this disclosure in its own commit message.

Changes since v9

1) Review of 2026-11-18 on 1/3 ("??" plus four inline comments):

- "??" was on the DRAFT note that v9 left in the mail body after the
'---' separator (it said the driver and the board DTS were still to be
ported, while 3/3 of the same posting already called
devm_mux_control_get() / mux_control_select()). The note is gone; what
follows the separator is now only the per-version changelog. v9's 1/3
patch body also carried no "diff --git" header (only ---/+++); the
series is produced with "git format-patch" again.

- "You don't need to use $defs here." The High Speed endpoint schema is
inlined under "port@0"; there is no local "$defs" section any more. The
only "$defs" left in the patch are dtschema's own
graph.yaml#/$defs/{port-base,endpoint-base} references.

- "These can be: patternProperties '^endpoint@[01]$'". Done: both
endpoints are matched by patternProperties under "port@0", and the
opposite-mux-state rule sits in port@0's own if/then.

- "Don't put driver specifics in bindings." The comment that explained
what dwc3_get_dr_mode(), dwc3_get_extcon() and dwc3_drd_init() do is
removed. The "mux-controls" branch now states only what the device
tree must contain: dr_mode = "otg", "port@0" with '#address-cells',
'#size-cells', endpoint@0 and endpoint@1, and both "usb-role-switch"
and "mux-state" on each endpoint.

- "This $ref can be dropped. You already have the schema for 'port@0'
below." Dropped: the then-branch only adds "required" to port@0, whose
schema is defined once, under "properties".

2) Review of 2026-11-18 on 3/3 (commit message):

- "What changed in this version isn't really applicable for the commit
message ... The commit msg should answer 'why' ... goes here after the
'---'." 3/3's message is rewritten: it now says why a mux controller is
needed (a board level GPIO cannot follow the USB mode, so the
controller can drive the data lines of the connector that is not in
use, and an instance cannot be torn down while its own lines are still
selected), why the first mode request claims state 0 (a mux cannot be
read back, so the connector in use at boot is unknowable), and why
mux_control_select()/mux_control_deselect() are only called from the
mode worker and from dwc3_drd_exit() after cancel_work_sync(). The
v9-to-v10 changelog moved below the separator. 1/3 got the same
treatment: it now describes the binding relative to the baseline tree,
and the v8-to-v9 changelog (which referred to a "port@2" and a
"port-select-gpios" that never existed upstream) is gone.

3) Fixes carried over from the static review of v9:

- [High] unbalanced mux_control_deselect(): only a mux that is actually
selected is deselected, and a failed mux_control_select() records
active_port = -1 instead of a stale index.
- [High] missing deselect on teardown: dwc3_drd_exit() deselects the mux
after cancel_work_sync(&dwc->drd_work), because devm_mux_control_get()
only puts the controller on release.
- [Medium] the two endpoints and the opposite-mux-state rule are required
only when "mux-controls" is present, so single-connector controllers
such as qcom/sm8250.dtsi are not rejected.
- [Low] both endpoints must carry "usb-role-switch" and "mux-state"; a
tree that sets them on endpoint@0 only is rejected.

4) Unchanged: 2/3 (usb: roles: look up role switches attached to a graph
endpoint). It got no comment and the code is identical to v9 apart from
the series numbering.

Known gaps (stated so that nobody has to guess)

- Which physical receptacle corresponds to mux state 0 and which to 1 is not
proven on hardware yet; the board DTS therefore names them "Receptacle A"
and "Receptacle B" and does not claim long/short edge.
- "gpio-mux" drives the select lines low in probe
(devm_gpiod_get_array(dev, "mux", GPIOD_OUT_LOW)), so the level left by
the firmware is not preserved. "idle-state" is deliberately omitted: a
non-AS_IS idle state would drive the wrong state between
mux_control_deselect() and the following mux_control_select(). Making the
probe keep the pin as is (GPIOD_ASIS) is a change to drivers/mux/gpio.c and
affects the ~70 existing gpio-mux users, so it does not belong in this
series; it needs a separate discussion with the mux maintainer.
- dtbs_check cannot see "idle-state" values: gpio-mux.yaml declares it
without a type or bounds, so an out-of-range value is only rejected at
probe time. The gate below therefore does not claim coverage for it.
- The board DTS is not part of this posting: the Lenovo Legion Y700 Gen 4
file is not upstream yet and is posted with its own board series.

Gate results (base: v7.4-rc3 = aebb7274476403040d582c61478df8f4a7bf9cd3)

G1 apply git am --3way 3/3 clean, rc=0, no offset/fuzz
on a pristine check-out of the base above
G2 checkpatch perl scripts/checkpatch.pl --strict --no-signoff --no-tree
1/3 0E/0W/0C (146 lines) · 2/3 0E/0W/0C (63 lines)
3/3 0E/0W/0C (618 lines)
G3 build make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- W=1
drivers/usb/dwc3/ drivers/usb/roles/
(CONFIG_MULTIPLEXER=y, CONFIG_USB_ROLE_SWITCH=y)
rc=0, 0 warnings, 22 objects (21 dwc3 + 1 roles), all
aarch64 relocatables
G4 binding make ARCH=arm64 dt_binding_check (no DT_SCHEMA_FILES)
rc=0, no diagnostics; every example DTC [C]
G5 dtbs_check make ARCH=arm64 CHECK_DTBS=1 qcom/sm8250-mtp.dtb
qcom/sm8650-mtp.dtb qcom/sm8750-mtp.dtb qcom/sm8750-qrd.dtb
(no DT_SCHEMA_FILES)
patched: 4/4 DTC [C], 0 diagnostics
base: 4/4 DTC [C], 0 diagnostics => 0 new
G6 samples dt-validate on the rebuilt schema bundle
positive (two endpoints, opposite mux-state) 0 complaints
negatives, all rejected:
same mux-state on both endpoints
endpoint@1 missing
endpoint@1 without usb-role-switch/mux-state
legacy pre-v10 shape (nested single endpoint)
G7 hardware not run

On the command shapes: DT_SCHEMA_FILES is intentionally not used for
dtbs_check. It is passed to dt-validate as "-l", which only keeps schemas
whose $id matches and that still select a node themselves;
snps,dwc3-common.yaml is a fragment without "select:", so the run reports
nothing and looks green. The dtbs_check rule also ends with "|| true", so
the result is read from the diagnostics in the output, not from the exit
status.

Qianhui Xu (3):
dt-bindings: usb: snps,dwc3: describe two connectors on one HS data
bus
usb: roles: look up role switches attached to a graph endpoint
usb: dwc3: select the shared HS data bus with a mux controller

.../bindings/usb/snps,dwc3-common.yaml | 124 ++++++-
drivers/usb/dwc3/core.c | 116 ++++++-
drivers/usb/dwc3/core.h | 43 +++
drivers/usb/dwc3/debugfs.c | 4 +
drivers/usb/dwc3/drd.c | 323 +++++++++++++++++-
drivers/usb/roles/class.c | 45 +++
6 files changed, 650 insertions(+), 5 deletions(-)

--
2.53.0