phy: Add USB3 PHY support to Google Tensor SoC USB PHY driver
Subsystems (3)
PATCH v2 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
--- drivers/phy/Kconfig | 2 +- drivers/phy/phy-google-usb.c | 379 +++++++++++++++++++++++++++++++---- 2 files changed, 346 insertions(+), 35 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 +345 -34
461 lines not on this page · raw message
base-commit: 2ace2e949979b82f82f12dd76d7c5a6145246ca3
Signature · 1 line
2.55.0.rc0.786.g65d90a0328-goog
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Critical] Unconditional acquisition of USB3 resources breaks backwards compatibility with existing…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] Unconditional acquisition of USB3 resources breaks backwards compatibility with existing device trees.
- [High] Missing .power_off callback prevents PHY state reset, breaking Type-C routing on resume.
- [High] Premature software state update breaks hardware programming retries on failure.
- [High] Missing PMGT_REF_CLK_REQ_N deassertion on error paths leaks the reference clock request. --
commit c027571e30437423b7f6c6808b9e70f2bc1b650a
Author: RD Babiera <[email protected]>
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.
Quoted 4 lines
drivers/phy/phy-google-usb.c +0
-0
[ ... ]
Quoted 3 lines
drivers/phy/phy-google-usb.c +2
-0@@ -161,6 +313,118 @@ static const struct phy_ops google_usb2_phy_ops = { +static int google_usb3_phy_init (struct phy *_phy) +{
[ ... ]
drivers/phy/phy-google-usb.c static const struct phy_ops google_usb2_phy_ops = { · line 353
Quoted 5 lines
drivers/phy/phy-google-usb.c +5
-0+set_pmgt_ref_clk_req_n (gphy, true); + + ret =clk_bulk_prepare_enable (inst->num_clks, inst->clks); +if (ret) +return ret;
[Severity: High]
Will this error path leak the reference clock request?
Since set_pmgt_ref_clk_req_n(gphy, true) was called earlier, if clk_bulk_prepare_enable() fails we return without deasserting the clock request.
The driver core doesn't invoke phy_exit() if phy_init() fails, so the request will remain permanently asserted.
Quoted 6 lines
drivers/phy/phy-google-usb.c +6
-0+ + ret =reset_control_bulk_deassert (inst->num_rsts, inst->rsts); +if (ret) { +clk_bulk_disable_unprepare (inst->num_clks, inst->clks); +return ret; + }
drivers/phy/phy-google-usb.c static const struct phy_ops google_usb2_phy_ops = { · line 369
Quoted 10 lines
drivers/phy/phy-google-usb.c +10
-0+ + ret =readl_poll_timeout (gphy->usb3_tca_base +TCA_PSTATE_0_OFFSET , + reg, !(reg &TCA_PSTATE_0_UPCS_LANE0_PHYSTATUS ), +GPHY_TCA_DELAY_US ,GPHY_TCA_TIMEOUT_US ); +if (ret) { +dev_err (gphy->dev,"wait for lane0 phystatus timed out" ); +reset_control_bulk_assert (inst->num_rsts, inst->rsts); +clk_bulk_disable_unprepare (inst->num_clks, inst->clks); +return ret; + }
[Severity: High]
Does this error path also leak the reference clock request?
It properly unwinds the clocks and resets, but it misses calling set_pmgt_ref_clk_req_n(gphy, false) before returning.
[ ... ]
Quoted 2 lines
drivers/phy/phy-google-usb.c +2
-0+static int google_usb3_phy_power_on (struct phy *_phy) +{
[ ... ]
Quoted 4 lines
drivers/phy/phy-google-usb.c +4
-0+if (gphy->phy_state ==COMBO_PHY_TCA_READY ) { +dev_warn (gphy->dev,"usb3 phy already powered on" ); +return 0 ; + }
[ ... ]
drivers/phy/phy-google-usb.c static const struct phy_ops google_usb2_phy_ops = { · line 420
Quoted 6 lines
drivers/phy/phy-google-usb.c +6
-0+ gphy->phy_state =COMBO_PHY_TCA_READY ; + + ret =program_tca_locked (gphy); + +return ret; +}
[Severity: High]
If program_tca_locked() fails, will hardware programming retries fail because the software state was prematurely updated?
If the USB subsystem retries powering on the PHY after an error, the early success check at the top of google_usb3_phy_power_on() will hit and return 0 without actually re-attempting the hardware configuration.
drivers/phy/phy-google-usb.c static const struct phy_ops google_usb2_phy_ops = { · line 426
Quoted 6 lines
drivers/phy/phy-google-usb.c +6
-0+ +static const struct phy_ops google_usb3_phy_ops = { + .init = google_usb3_phy_init, + .exit = google_usb3_phy_exit, + .power_on = google_usb3_phy_power_on, +};
[Severity: High]
Is the missing .power_off callback going to cause the state machine to desync on suspend and resume?
During suspend, without a power off hook, gphy->phy_state remains COMBO_PHY_TCA_READY. On resume, google_usb3_phy_power_on() checks this state and returns 0 without reprogramming the TCA hardware, which could permanently break the link.
[ ... ]
Quoted 3 lines
drivers/phy/phy-google-usb.c +2
-0@@ -173,14 +437,61 @@ static struct phy *google_usb_phy_xlate(struct device *dev, +static int google_usb_phy_parse_clocks (struct google_usb_phy *gphy) +{
[ ... ]
drivers/phy/phy-google-usb.c static struct phy *google_usb_phy_xlate(struct device *dev, · line 463
Quoted 7 lines
drivers/phy/phy-google-usb.c +7
-0+ ret =devm_clk_bulk_get (dev, inst->num_clks, inst->clks); +if (ret) +return dev_err_probe (dev, ret,"failed to get phy%d clks\n" , id); + } + +return 0 ; +}
[Severity: Critical]
Will unconditionally requesting the usb3 clocks break backwards compatibility on systems using older device trees?
If an older device tree only provides USB2 resources, devm_clk_bulk_get() will fail here and abort the entire probe sequence.
[ ... ]
Quoted 1 line
drivers/phy/phy-google-usb.c +0
-0@@ -212,39 +523,39 @@ static int google_usb_phy_probe(struct platform_device *pdev)
[ ... ]
drivers/phy/phy-google-usb.c static int google_usb_phy_probe(struct platform_device *pdev) · line 531
Quoted 6 lines
drivers/phy/phy-google-usb.c +6
-0+ gphy->usb3_tca_base =devm_platform_ioremap_resource_byname (pdev, +"usb3_tca" ); +if (IS_ERR (gphy->usb3_tca_base)) +return dev_err_probe (dev,PTR_ERR (gphy->usb3_tca_base), +"invalid usb3 tca\n" ); +
[Severity: Critical]
Similarly, will unconditionally requiring the usb3_tca resource break probe for older device trees that only define USB2 resources?
If the memory region is missing from the DT, this will return an error and prevent the USB2 PHY from working on those devices.
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 7 lines · On Mon, Jun 22, 2026 at 11:05 AM <[email protected]> wrote:
[Severity: High]
Will this error path leak the reference clock request?Since
set_pmgt_ref_clk_req_n(gphy, true)was called earlier, ifclk_bulk_prepare_enable()fails we return without deasserting the clock request.
Quoted 8 lines
The driver core doesn't invoke
phy_exit()ifphy_init()fails, so the request will remain permanently asserted.[Severity: High]
Does this error path also leak the reference clock request?It properly unwinds the clocks and resets, but it misses calling
set_pmgt_ref_clk_req_n(gphy, false)before returning.
I addressed this in V1 where a phy_init failure would likely result in the hardware powering off and on again and the request would clear, but I'll change it for the next version for correctness.
Quoted 7 lines
[Severity: High]
Ifprogram_tca_locked()fails, will hardware programming retries fail because the software state was prematurely updated?If the USB subsystem retries powering on the PHY after an error, the early success check at the top of
google_usb3_phy_power_on()will hit and return 0 without actually re-attempting the hardware configuration.
I'll change this so that COMBO_PHY_TCA_READY is set when the initial PoR => NC check passes, but subsequent power_on calls skip waiting for the PoR => NC request and allow the program_tca_locked() call to be made while the internal PHY state is COMBO_PHY_TCA_READY.
Quoted 8 lines
[Severity: High]
Is the missing .power_off callback going to cause the state machine to desync on suspend and resume?During suspend, without a power off hook,
gphy->phy_stateremainsCOMBO_PHY_TCA_READY. On resume,google_usb3_phy_power_on()checks this state and returns 0 without reprogramming the TCA hardware, which could permanently break the link.
The change above should cover this case.
Quoted 7 lines
[Severity: Critical]
Will unconditionally requesting the usb3 clocks break backwards compatibility on systems using older device trees?If an older device tree only provides USB2 resources,
devm_clk_bulk_get()will fail here and abort the entire probe sequence.
Quoted 6 lines
[Severity: Critical]
Similarly, will unconditionally requiring theusb3_tcaresource break probe for older device trees that only define USB2 resources?If the memory region is missing from the DT, this will return an error and prevent the USB2 PHY from working on those devices.
The PHY IP supports the USB3 resources by default, so it makes sense to bake in the requirements.
Best,
RD