arm64: dts: mediatek: xaga: bring up USB peripheral and guarded OTG h… - #1
Open
2824799 wants to merge 1 commit into
Open
arm64: dts: mediatek: xaga: bring up USB peripheral and guarded OTG h…#12824799 wants to merge 1 commit into
2824799 wants to merge 1 commit into
Conversation
…ost support
This commit resolves USB device enumeration, Type-C PD negotiation,
charger BC1.2 handoff, and guarded OTG power sourcing on Xiaomi Redmi Note 11T
Pro / POCO X4 GT (xaga, MT6895):
1. MTU3 Dual-Role Controller & Peripheral Mode:
- Synchronize MTU3 internal VBUS state with external TCPM data role:
xaga lacks dedicated analog VBUS sensing routed to the MTU3 core.
Following the Xiaomi vendor MT6895 reference driver (mediatek,force-vbus):
when Type-C enters DEVICE mode, assert U3D_MISC_CTRL (VBUS_FRC_EN | VBUS_ON)
and clear SSUSB_U2_PORT_OTG_SEL to enable softconnect and D+ pullup,
allowing host computers to detect and enumerate the phone.
Safely clear force-vbus flags upon cable disconnect or host mode switch.
- Restrict role-switch userspace override on xaga to ensure only TCPM
drives role transitions without power role contention.
- Add role_lock mutex and runtime PM gating in mtu3_dr to serialize
dual-role work and unbound device recovery.
- Allow optional/missing local VBUS regulator in ssusb_set_vbus when
power is handled entirely by an external charger/TCPM supply.
2. Type-C TCPCI Controller & PD Robustness:
- In tcpci_set_polarity, use regmap_update_bits to modify the orientation
bit while preserving connection alert flags in TCPC_TCPC_CTRL.
- In tcpci_read_message, validate message byte count and header payload length
strictly. Discard malformed frames to prevent forwarding invalid zero-PDOs
to the TCPM state machine.
3. MT6375 Charger, PHY & Guarded OTG VBUS Power:
- Coordinate MT6375 BC1.2 charger detection with USB PHY switching to release
D+/D- data lines for USB transfer once detection concludes.
- Implement MT6375 OTG boost 5V supply managed strictly by TCPM, ensuring
power is sourced only after successful partner attach and role negotiation,
preventing dangerous VBUS backfeed into host ports.
- Restrict I2C bus regulator lookup in i2c-mt65xx to controller supplies.
4. Device Tree:
- Enable ssusb and usb_host in dr_mode = "otg" with peripheral default.
- Include mt6895-xaga-usb-tcpm.dtsi defining TCPC, connector, and VBUS supplies.
Tested-by: Silvia <2824799@users.noreply.github.com>
Signed-off-by: Silvia <2824799@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request resolves USB device/peripheral enumeration, Type-C PD negotiation, charger BC1.2 handoff, and safe OTG host power management on the Xiaomi Redmi Note 11T Pro / POCO X4 GT (
xaga, MT6895).Problem & Background
xaga, the MTU3 USB core does not have a dedicated analog VBUS sense line routed directly to the SoC. Without internal VBUS validity indication, MTU3 never initiates softconnect or pulls up the D+ line, making the device completely invisible to host PCs when plugged in via USB.tcpci_set_polaritypreviously overwroteTCPC_TCPC_CTRLviaregmap_write, unintentionally clearing the connection alert notification bit.tcpci_read_messagelacked strict header and byte count validation, which could forward corrupted packets or 0V PDOs to the TCPM state machine.Key Changes
MTU3 Dual-Role & Peripheral Mode (
drivers/usb/mtu3/):ssusb_set_device_vbus()referencing the Xiaomi MT6895 vendor BSP (mediatek,force-vbus). When TCPM signalsUSB_ROLE_DEVICE, the driver assertsU3D_MISC_CTRL (VBUS_FRC_EN | VBUS_ON)and clearsSSUSB_U2_PORT_OTG_SEL, successfully triggering high-speed device enumeration. Flags are cleanly cleared on cable disconnect or host mode.dr_workand recovery paths with arole_lockmutex and runtime PM references. Restricted userspace role overrides onxagato ensure only the hardware TCPM state machine drives transitions.ssusb_set_vbuswhen power is managed externally by the charger.TCPCI & PD Robustness (
drivers/usb/typec/tcpm/):tcpci_set_polarityto useregmap_update_bits, updating only the orientation bit while preserving connection alert flags.tcpci_read_messageto strictly validate message byte counts against PD header lengths and safely discard malformed packets.MT6375 Charger, PHY & Guarded OTG (
drivers/power/supply/mediatek/,drivers/phy/):i2c-mt65xxto controller supplies.Device Tree (
arch/arm64/boot/dts/mediatek/):ssusbandusb_hostindr_mode = "otg"withperipheraldefault.mt6895-xaga-usb-tcpm.dtsidefining the Type-C port, TCPC node, and power supplies.Hardware Validation
1d6b:0104) on PC host, stable IP communication (usb0), RDP and SSH over USB without packet drops.Tested-by: Silvia 2824799@users.noreply.github.com
Signed-off-by: Silvia 2824799@users.noreply.github.com