phy: Add USB3 PHY support to Google Tensor SoC USB PHY driver
Subsystems (3)
PATCH v3 1/1 phy: Add USB3 PHY support to Google Tensor SoC USB PHY driver
Add USB3 PHY support for the Google Tensor G5 USB PHY driver. This patch adds functionality for the usb3_tca register, usb3 clock, and usb3 reset as defined in google,lga-usb-phy.yaml. Kconfig now lists USB SuperSpeed support.
Refactor the probe sequence to initialize the USB2 and USB3 PHYs, and then initialize clocks and resets for both PHYs afterwards.
Refactor set_vbus_valid to reduce duplicated code.
Implement USB3 phy_ops for phy_init, phy_exit, and phy_power_on. combo_phy_state enum is added to track PHY bringup state across PHY API calls.
---
Changes since v1:
* Removed mix of goto-based and scope-based cleanup from usb3 phy_init
* Removed unused usb3_core resource from probe
* Added combo_phy_state enum to interally track ComboPHY bringup state to allow google_usb_set_orientation() to change TCA orientation.
* Modify Kconfig documentation to reflect SuperSpeed support
Changes since v2:
* google_usb3_phy_init now sets USBDP_TOP_CFG_REG_PMGT_REF_CLK_REQ_N to false if phy_init fails elsewhere.
* google_usb3_phy_init errors are now handled via DEFINE_FREE structures. This affects set_pmgt_ref_clk_req_n, clk_bulk_prepare_enable, and reset_control_bulk_deassert.
* google_usb2_phy_init also handles undoing clk_bulk_prepare_enable via DEFINE_FREE structure.
* google_usb3_phy_power_on allows program_tca_locked in the COMBO_PHY_TCA_READY state. Waiting for PoR=>NC is only performed once.
* Note: there are checkpatch errors for the DEFINE_FREE macros resulting in "ERROR: trailing statements should be on next line". Other cases of DEFINE_FREE where the line limit would otherwise exceed 100 columns have the indentation done the same way.
--- drivers/phy/Kconfig | 2 +- drivers/phy/phy-google-usb.c | 404 +++++++++++++++++++++++++++++++---- 2 files changed, 368 insertions(+), 38 deletions(-)
drivers/phy/Kconfig +1 -1
@@ -100,7 +100,7 @@ config PHY_GOOGLE_USB the G5 generation (Laguna). This driver provides the PHY interfaces to interact with the SNPS eUSB2 and USB 3.2/DisplayPort Combo PHY, both of which are integrated with the DWC3 USB DRD controller. - This driver currently supports USB high-speed. + This driver currently supports USB high-speed and SuperSpeed. config USB_LGM_PHY tristate "INTEL Lightning Mountain USB PHY Driver"
drivers/phy/phy-google-usb.c +367 -37
500 lines not on this page · raw message
base-commit: 2ace2e949979b82f82f12dd76d7c5a6145246ca3
Signature · 1 line
2.55.0.rc0.799.gd6f94ed593-goog
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] The teardown sequence in google_usb3_phy_exit violates LIFO ordering, causing a hardware resource sequence mismatch.
- [High] Unconditional TCA programming in google_usb3_phy_power_on misconfigures the PHY for a disconnected port.
Pre-existing issues:
- [High] Time-of-Check to Time-of-Use (TOCTOU) race condition in google_usb_set_orientation leads to unclocked MMIO accesses. --
commit cefbad787f1b94bc99ee246cf94e5430283fce0c
Author: RD Babiera <[email protected]>
phy: Add USB3 PHY support to Google Tensor SoC USB PHY driver
This patch adds USB3 PHY support for the Google Tensor G5 USB PHY driver. It implements the USB3 phy_ops for phy_init, phy_exit, and phy_power_on, and adds a combo_phy_state enum to track the PHY bringup state across API calls.
drivers/phy/phy-google-usb.c +0 -0
[ ... ]
Review static int google_usb_set_orientation(struct typec_switch_dev *sw, · line 262
Quoted 3 lines
(quoted diff) +0
-0@@ -92,6 +261,9 @@ static int google_usb_set_orientation(struct typec_switch_dev *sw, set_vbus_valid(gphy);
[Severity: High]
This is a pre-existing issue, but does checking pm_runtime_suspended() earlier in this function without holding a PM reference introduce a race condition here?
If the PM core suspends the device immediately after that check returns false, the function will proceed to acquire the mutex and write to MMIO registers via set_vbus_valid() and program_tca_locked() after the power domain and clocks have been disabled.
Could this lead to a synchronous external abort when accessing the unclocked registers? Should this use pm_runtime_get_if_active() instead?
Quoted 5 lines
(quoted diff) +3
-0+ if (gphy->phy_state == COMBO_PHY_TCA_READY && orientation != TYPEC_ORIENTATION_NONE) + return program_tca_locked(gphy); + return 0; }
[ ... ]
Review
Quoted 12 lines
(quoted diff) +12
-0+static int google_usb3_phy_exit(struct phy *_phy) +{ + struct google_usb_phy_instance *inst = phy_get_drvdata(_phy); + struct google_usb_phy *gphy = inst->parent; + + dev_dbg(gphy->dev, "exiting usb3 phy\n"); + + guard(mutex)(&gphy->phy_mutex); + + set_pmgt_ref_clk_req_n(gphy, false); + reset_control_bulk_assert(inst->num_rsts, inst->rsts); + clk_bulk_disable_unprepare(inst->num_clks, inst->clks);
[Severity: High]
Is the manual teardown sequence here in the correct order?
In google_usb3_phy_init(), resources are acquired in this order:
1) set_pmgt_ref_clk_req_n(true)
2) clock enable
3) reset deassert
The __free blocks in the init function correctly establish the error cleanup sequence in reverse order (LIFO). However, here the upstream reference clock request is disabled before placing the hardware block into reset and disabling clocks.
Could disabling the clock request before asserting reset freeze the IP in an invalid state and prevent subsequent wakeups?
Quoted 17 lines
(quoted diff) +17
-0+ + gphy->phy_state = COMBO_PHY_IDLE; + + return 0; +} + +static int google_usb3_phy_power_on(struct phy *_phy) +{ + struct google_usb_phy_instance *inst = phy_get_drvdata(_phy); + struct google_usb_phy *gphy = inst->parent; + int ret; + + dev_dbg(gphy->dev, "power on usb3 phy\n"); + + guard(mutex)(&gphy->phy_mutex); + + if (gphy->phy_state != COMBO_PHY_TCA_READY) {
Review
Quoted 10 lines
(quoted diff) +10
-0+ /* Wait for PoR -> NC transitions*/ + ret = wait_tca_xa_ack(gphy); + if (ret) { + dev_err(gphy->dev, "PoR->NC transition timeout"); + return ret; + } + gphy->phy_state = COMBO_PHY_TCA_READY; + } + + return program_tca_locked(gphy);
[Severity: High]
Should this check if the Type-C port is actually connected before calling program_tca_locked()?
If the port is disconnected (gphy->orientation == TYPEC_ORIENTATION_NONE), program_tca_locked() falls through its else branch, configuring the registers for TYPEC_ORIENTATION_NORMAL and setting TCA_TCPC_VALID.
Since the Type-C switch callback google_usb_set_orientation() correctly skips TCA programming if the orientation is NONE, should a similar check be present here to prevent enabling the SuperSpeed data path for a phantom connection?
Quoted 1 line
+}
Signature · 6 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Quoted 21 lines · On Tue, Jun 30, 2026 at 7:40 PM <[email protected]> wrote:
Review
Quoted 12 lines
(quoted diff) +12
-0+static int google_usb3_phy_exit(struct phy *_phy) +{ + struct google_usb_phy_instance *inst = phy_get_drvdata(_phy); + struct google_usb_phy *gphy = inst->parent; + + dev_dbg(gphy->dev, "exiting usb3 phy\n"); + + guard(mutex)(&gphy->phy_mutex); + + set_pmgt_ref_clk_req_n(gphy, false); + reset_control_bulk_assert(inst->num_rsts, inst->rsts); + clk_bulk_disable_unprepare(inst->num_clks, inst->clks);[Severity: High]
Is the manual teardown sequence here in the correct order?In
google_usb3_phy_init(), resources are acquired in this order:
1)set_pmgt_ref_clk_req_n(true)
2) clock enable
3) reset deassert
Quoted 7 lines
The
__freeblocks in the init function correctly establish the error cleanup sequence in reverse order (LIFO). However, here the upstream reference clock request is disabled before placing the hardware block into reset and disabling clocks.Could disabling the clock request before asserting reset freeze the IP in an invalid state and prevent subsequent wakeups?
I've verified both orderings of set_pmgt_ref_clk_req_n in phy_exit, will change to be consistent with phy_init ordering though.
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + return program_tca_locked(gphy);[Severity: High]
Should this check if the Type-C port is actually connected before callingprogram_tca_locked()?
Quoted 7 lines
If the port is disconnected (
gphy->orientation==TYPEC_ORIENTATION_NONE),program_tca_locked()falls through its else branch, configuring the registers forTYPEC_ORIENTATION_NORMALand settingTCA_TCPC_VALID.Since the Type-C switch callback
google_usb_set_orientation()correctly skips TCA programming if the orientation is NONE, should a similar check be present here to prevent enabling the SuperSpeed data path for a phantom connection?
Will guard behind gphy->orientation in next version. If the port is disconnected the
PHY will be treated as being in normal orientation, but given USB mode is being programmed here and not NC, it's more correct to only program USB when a port partner is actually connected.
Best,
RD