Add AST2700 USB3.2 PHY driver
Ryan Chen
reviewerv2 cover Add AST2700 USB3.2 PHY driver
Add AST2700 USB3.2 PHY support.
- Supports Super Speed Plus Gen2x1 (10 Gbps), Super Speed (5 Gbps), High Speed (480 Mbps), Full Speed (12Mbps), and Low Speed (1.5 Mbps).
---
Changes in v2:
- aspeed,ast2700-usb3-phy.yaml
- Drop clocks, resets descripton.
- Kconfig
- add COMPILE_TEST, remove default n
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Ryan Chen (3):
dt-bindings: phy: aspeed: Document AST2700 USB3.0 PHY
phy: add AST2700 usb3.2 phy driver
MAINTAINERS: Add ASPEED USB3 PHY driver
.../bindings/phy/aspeed,ast2700-usb3-phy.yaml | 48 +++++ MAINTAINERS | 8 + drivers/phy/aspeed/Kconfig | 12 ++ drivers/phy/aspeed/Makefile | 2 + drivers/phy/aspeed/phy-aspeed-usb3.c | 236 +++++++++++++++++++++ 5 files changed, 306 insertions(+)
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20260112-upstream_usb3phy-7116f8dfe779
Best regards,
Signature · 1 line
Ryan Chen <[email protected]>
Ryan Chen
reviewerPATCH v2 1/3 dt-bindings: phy: aspeed: Document AST2700 USB3.0 PHY
Document AST2700 USB3.2 PHY. This IP is connected between USB3 controller and PHY module.
--- .../bindings/phy/aspeed,ast2700-usb3-phy.yaml | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+)
Documentation/devicetree/bindings/phy/aspeed,ast2700-usb3-phy.yaml new file +48 -0
@@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/aspeed,ast2700-usb3-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ASPEED AST2700 USB 3.2 PHY + +maintainers: + - Ryan Chen <[email protected]> + +properties: + compatible: + const: aspeed,ast2700-usb3-phy + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + '#phy-cells': + const: 0 + +required: + - compatible + - reg + - clocks + - resets + - '#phy-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/aspeed,ast2700-scu.h> + #include <dt-bindings/reset/aspeed,ast2700-scu.h> + + usb-phy@12010000 { + compatible = "aspeed,ast2700-usb3-phy"; + reg = <0x12010000 0xc0>; + clocks = <&syscon0 SCU0_CLK_GATE_PORTAUSB2CLK>; + resets = <&syscon0 SCU0_RESET_PORTA_PHY3>; + #phy-cells = <0>; + };
Signature · 1 line
2.34.1
Ryan Chen
reviewerPATCH v2 2/3 phy: add AST2700 usb3.2 phy driver
In reply to Ryan ChenAdd AST2700 USB3.2 PHY driver support.
--- drivers/phy/aspeed/Kconfig | 12 ++ drivers/phy/aspeed/Makefile | 2 + drivers/phy/aspeed/phy-aspeed-usb3.c | 236 +++++++++++++++++++++++++++++++++++ 3 files changed, 250 insertions(+)
drivers/phy/aspeed/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only + +# +# PHY drivers for ASPEED +# + +config PHY_ASPEED_USB3 + tristate "ASPEED USB3 PHY driver" + select GENERIC_PHY + depends on (ARCH_ASPEED || COMPILE_TEST) + help + Enable driver support for Aspeed AST2700 USB3 PHY.
drivers/phy/aspeed/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_ASPEED_USB3_PHY) += phy-aspeed-usb3.o
drivers/phy/aspeed/phy-aspeed-usb3.c new file +236 -0
236 lines not on this page · raw message
Signature · 1 line
2.34.1
Andrew Jeffery
maintainerRe: [PATCH v2 2/3] phy: add AST2700 usb3.2 phy driver
Hi Ryan,
On Fri, 2026-01-16 at 10:53 +0800, Ryan Chen wrote:
...
Quoted 26 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +19
-0@@ -0,0 +1,236 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright 2026 Aspeed Technology Inc. +*/ + +#include <linux/bitfield.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/reset.h> + +#define PHY3S00 0x00 +#define PHY3S00_INIT_DONE BIT(15) +#define PHY3S00_SRAM_BYPASS BIT(7) +#define PHY3S00_SRAM_EXT_LOAD BIT(6)
...
Quoted 7 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +7
-0+ +static int aspeed_usb3_phy_init (struct phy *phy) +{ +struct aspeed_usb3_phy *aspeed_phy =phy_get_drvdata (phy); +u32 val; +int ret; +
drivers/phy/aspeed/phy-aspeed-usb3.c line 135
Quoted 10 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +10
-0+ ret =clk_prepare_enable (aspeed_phy->clk); +if (ret) { +dev_err (aspeed_phy->dev,"Failed to enable clock %d\n" , ret); +return ret; + } + + ret =reset_control_deassert (aspeed_phy->rst); +if (ret) { +clk_disable_unprepare (aspeed_phy->clk); +return ret;
Nit: Given we have to do this below if the reset_control_deassert() succeeds, perhaps add a label below and use goto here?
Quoted 4 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +4
-0+ } + +/* Wait for USB3 PHY internal SRAM initialization done */ + ret = readl_poll_timeout(aspeed_phy->regs + PHY3S00, val,
drivers/phy/aspeed/phy-aspeed-usb3.c line 149
Quoted 10 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +10
-0+ val &PHY3S00_INIT_DONE , + USEC_PER_MSEC, 10 * USEC_PER_MSEC); +if (ret) { +dev_err (aspeed_phy->dev,"SRAM init timeout\n" ); + goto err_assert_reset; + } + + val =readl (aspeed_phy->regs +PHY3S00 ); + val |=PHY3S00_SRAM_BYPASS ; +writel (val, aspeed_phy->regs +PHY3S00 );
According to the datasheet PHY3S00[15] (PHY3S00_INIT_DONE above) indicates that the PHY internal SRAM initialisation is complete. The datasheet reports the SRAM is used for configuration of calibration among other things. PHY3S00[6] instructs the PHY that software has completed loading the configuration data into SRAM, however PHY3S00_SRAM_BYPASS (PHY3S00[7]) tells the PHY to load configuration from "hard wired" values.
Is it necessary to wait for SRAM initialisation to complete if we're bypassing it? Or are there other side-effects involved in the setting of PHY3S00[15]?
Quoted 17 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +16
-0+ +/* Set protocol1_ext signals as default PHY3 settings based on SNPS documents. +* Including PCFGI[54]: protocol1_ext_rx_los_lfps_en for better compatibility +*/ +writel (PHY3P00_DEFAULT , aspeed_phy->regs +PHY3P00 ); +writel (PHY3P04_DEFAULT , aspeed_phy->regs +PHY3P04 ); +writel (PHY3P08_DEFAULT , aspeed_phy->regs +PHY3P08 ); +writel (PHY3P0C_DEFAULT , aspeed_phy->regs +PHY3P0C ); + +return 0 ; + +err_assert_reset: +reset_control_assert (aspeed_phy->rst); +clk_disable_unprepare (aspeed_phy->clk); +return ret; +}
...
drivers/phy/aspeed/phy-aspeed-usb3.c line 236
Quoted 12 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +11
-0+static struct platform_driver aspeed_usb3_phy_driver = { + .probe = aspeed_usb3_phy_probe, + .driver = { + .name =KBUILD_MODNAME , + .of_match_table = aspeed_usb3_phy_match_table, + }, +}; +module_platform_driver (aspeed_usb3_phy_driver); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("ASPEED USB3.0 PHY Driver" );
MODULE_AUTHOR()?
Andrew
Ryan Chen
reviewerRE: [PATCH v2 2/3] phy: add AST2700 usb3.2 phy driver
Quoted 50 lines
Subject: Re: [PATCH v2 2/3] phy: add AST2700 usb3.2 phy driver
Hi Ryan,
On Fri, 2026-01-16 at 10:53 +0800, Ryan Chen wrote:
...
Quoted 27 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +19
-0@@ -0,0 +1,236 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright 2026 Aspeed Technology Inc. +*/ + +#include <linux/bitfield.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/reset.h> + +#define PHY3S00 0x00 +#define PHY3S00_INIT_DONE BIT(15) +#define PHY3S00_SRAM_BYPASS BIT(7) +#define PHY3S00_SRAM_EXT_LOAD BIT(6)...
Quoted 11 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +11
-0+ +static int aspeed_usb3_phy_init (struct phy *phy) { +struct aspeed_usb3_phy *aspeed_phy =phy_get_drvdata (phy); +u32 val; +int ret; + + ret =clk_prepare_enable (aspeed_phy->clk); +if (ret) { +dev_err (aspeed_phy->dev,"Failed to enable clock %d\n" , ret); +return ret; + }
Quoted 8 lines
drivers/phy/aspeed/phy-aspeed-usb3.c line 135
Quoted 5 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +5
-0+ + ret =reset_control_deassert (aspeed_phy->rst); +if (ret) { +clk_disable_unprepare (aspeed_phy->clk); +return ret;Nit: Given we have to do this below if the
reset_control_deassert()succeeds, perhaps add a label below and use goto here?
Will update
ret = reset_control_deassert(aspeed_phy->rst);
if (ret)
goto err_disable_clk;
...
if (ret) {
dev_err(aspeed_phy->dev, "SRAM init timeout\n");
goto err_assert_reset;
}
...
return 0;err_assert_reset:
reset_control_assert(aspeed_phy->rst); err_disable_clk: clk_disable_unprepare(aspeed_phy->clk); return ret;
Quoted 23 lines
Quoted 5 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +4
-0+ } + +/* Wait for USB3 PHY internal SRAM initialization done */ + ret = readl_poll_timeout(aspeed_phy->regs + PHY3S00, val,drivers/phy/aspeed/phy-aspeed-usb3.c line 149
Quoted 10 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +10
-0+ val &PHY3S00_INIT_DONE , + USEC_PER_MSEC, 10 * USEC_PER_MSEC); +if (ret) { +dev_err (aspeed_phy->dev,"SRAM init timeout\n" ); + goto err_assert_reset; + } + + val =readl (aspeed_phy->regs +PHY3S00 ); + val |=PHY3S00_SRAM_BYPASS ; +writel (val, aspeed_phy->regs +PHY3S00 );According to the datasheet PHY3S00[15] (
PHY3S00_INIT_DONEabove) indicates that the PHY internal SRAM initialisation is complete. The datasheet reports the SRAM is used for configuration of calibration among other things. PHY3S00[6] instructs the PHY that software has completed loading the configuration data into SRAM, howeverPHY3S00_SRAM_BYPASS(PHY3S00[7]) tells the PHY to load configuration from "hard wired" values.
Quoted 2 lines
Is it necessary to wait for SRAM initialisation to complete if we're bypassing it? Or are there other side-effects involved in the setting of PHY3S00[15]?
Yes, it is necessary to wait SRAM initial, the driver polls PHY3S00[15]. It reports that the boot loader in the PCS has finished initialising the SRAM (loading the contents into the PCS), and that initialisation has to complete before sram_bypass (PHY3S00[7]) may be asserted.
Quoted 24 lines
drivers/phy/aspeed/phy-aspeed-usb3.c
Quoted 3 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +2
-0+ +/* Set protocol1_ext signals as default PHY3 settings based on SNPS documents.
drivers/phy/aspeed/phy-aspeed-usb3.c
Quoted 1 line
drivers/phy/aspeed/phy-aspeed-usb3.c new file +1
-0+* Including PCFGI[54]: protocol1_ext_rx_los_lfps_en for better compatibility
Quoted 14 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +13
-0+*/ +writel (PHY3P00_DEFAULT , aspeed_phy->regs +PHY3P00 ); +writel (PHY3P04_DEFAULT , aspeed_phy->regs +PHY3P04 ); +writel (PHY3P08_DEFAULT , aspeed_phy->regs +PHY3P08 ); +writel (PHY3P0C_DEFAULT , aspeed_phy->regs +PHY3P0C ); + +return 0 ; + +err_assert_reset: +reset_control_assert (aspeed_phy->rst); +clk_disable_unprepare (aspeed_phy->clk); +return ret; +}...
Quoted 1 line
Quoted 13 lines
drivers/phy/aspeed/phy-aspeed-usb3.c line 236
Quoted 11 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +11
-0+static struct platform_driver aspeed_usb3_phy_driver = { + .probe = aspeed_usb3_phy_probe, + .driver = { + .name =KBUILD_MODNAME , + .of_match_table = aspeed_usb3_phy_match_table, + }, +}; +module_platform_driver (aspeed_usb3_phy_driver); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("ASPEED USB3.0 PHY Driver" );
MODULE_AUTHOR()?
Will updateMODULE_AUTHOR("Ryan Chen <[email protected]>");
Andrew Jeffery
maintainerRe: [PATCH v2 2/3] phy: add AST2700 usb3.2 phy driver
Quoted 24 lines · Ryan Chen
Quoted 24 lines
Quoted 6 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +4
-0+ } + +/* Wait for USB3 PHY internal SRAM initialization done */ + ret = readl_poll_timeout(aspeed_phy->regs + PHY3S00, val,drivers/phy/aspeed/phy-aspeed-usb3.c line 149
Quoted 10 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +10
-0+ val &PHY3S00_INIT_DONE , + USEC_PER_MSEC, 10 * USEC_PER_MSEC); +if (ret) { +dev_err (aspeed_phy->dev,"SRAM init timeout\n" ); + goto err_assert_reset; + } + + val =readl (aspeed_phy->regs +PHY3S00 ); + val |=PHY3S00_SRAM_BYPASS ; +writel (val, aspeed_phy->regs +PHY3S00 );According to the datasheet PHY3S00[15] (
PHY3S00_INIT_DONEabove) indicates that the PHY internal SRAM initialisation is complete. The datasheet reports the SRAM is used for configuration of calibration among other things. PHY3S00[6] instructs the PHY that software has completed loading the configuration data into SRAM, howeverPHY3S00_SRAM_BYPASS(PHY3S00[7]) tells the PHY to load configuration from "hard wired" values.
Quoted 8 lines
Quoted 2 lines
Is it necessary to wait for SRAM initialisation to complete if we're bypassing it? Or are there other side-effects involved in the setting of PHY3S00[15]?
Yes, it is necessary to wait SRAM initial, the driver polls PHY3S00[15]. It reports that the boot loader in the PCS has finished initialising the SRAM (loading the contents into the PCS), and that initialisation has to complete before
sram_bypass(PHY3S00[7]) may be asserted.
Can you improve the comment then to make it clear that the wait is necessary despite the bypass?
Andrew
Ryan Chen
reviewerRE: [PATCH v2 2/3] phy: add AST2700 usb3.2 phy driver
Quoted 33 lines
Subject: Re: [PATCH v2 2/3] phy: add AST2700 usb3.2 phy driver
Quoted 12 lines · Ryan Chen
Quoted 12 lines
Quoted 12 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +10
-0+ } + +/* Wait for USB3 PHY internal SRAM initialization done */ + ret =readl_poll_timeout (aspeed_phy->regs +PHY3S00 , val, + val &PHY3S00_INIT_DONE , +USEC_PER_MSEC ,10 *USEC_PER_MSEC ); +if (ret) { +dev_err (aspeed_phy->dev,"SRAM init timeout\n" ); + goto err_assert_reset; + }Quoted 8 lines
Quoted 8 lines
drivers/phy/aspeed/phy-aspeed-usb3.c line 149
Quoted 4 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +4
-0+ + val =readl (aspeed_phy->regs +PHY3S00 ); + val |=PHY3S00_SRAM_BYPASS ; +writel (val, aspeed_phy->regs +PHY3S00 );According to the datasheet PHY3S00[15] (
PHY3S00_INIT_DONEabove) indicates that the PHY internal SRAM initialisation is complete. The datasheet reports the SRAM is used for configuration of calibration amongother things.
Quoted 5 lines
Quoted 5 lines
PHY3S00[6] instructs the PHY that software has completed loading the configuration data into SRAM, however
PHY3S00_SRAM_BYPASS(PHY3S00[7]) tells the PHY to load configuration from "hard wired" values.Is it necessary to wait for SRAM initialisation to complete if we're
bypassing it?
Quoted 2 lines
Quoted 1 line
Or are there other side-effects involved in the setting of PHY3S00[15]?
Quoted 9 lines
Quoted 5 lines
Yes, it is necessary to wait SRAM initial, the driver polls PHY3S00[15]. It reports that the boot loader in the PCS has finished initialising the SRAM (loading the contents into the PCS), and that initialisation has to complete before
sram_bypass(PHY3S00[7]) may be asserted.Can you improve the comment then to make it clear that the wait is necessary despite the bypass?
Thanks, will update.
Ryan Chen
reviewerRE: [PATCH v2 2/3] phy: add AST2700 usb3.2 phy driver
Quoted 34 lines
Subject: RE: [PATCH v2 2/3] phy: add AST2700 usb3.2 phy driver
Quoted 31 lines
Subject: Re: [PATCH v2 2/3] phy: add AST2700 usb3.2 phy driver
Quoted 13 lines · Ryan Chen
Quoted 13 lines
Quoted 13 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +11
-0+ } + +/* Wait for USB3 PHY internal SRAM initialization done */ + ret =readl_poll_timeout (aspeed_phy->regs +PHY3S00 , val, + val &PHY3S00_INIT_DONE , +USEC_PER_MSEC ,10 *USEC_PER_MSEC ); +if (ret) { +dev_err (aspeed_phy->dev,"SRAM init timeout\n" ); + goto err_assert_reset; + } +Quoted 8 lines
Quoted 8 lines
drivers/phy/aspeed/phy-aspeed-usb3.c line 149
Quoted 3 lines
drivers/phy/aspeed/phy-aspeed-usb3.c new file +3
-0+ val =readl (aspeed_phy->regs +PHY3S00 ); + val |=PHY3S00_SRAM_BYPASS ; +writel (val, aspeed_phy->regs +PHY3S00 );According to the datasheet PHY3S00[15] (
PHY3S00_INIT_DONEabove) indicates that the PHY internal SRAM initialisation is complete. The datasheet reports the SRAM is used for configuration of calibration amongother things.
Quoted 6 lines
Quoted 6 lines
PHY3S00[6] instructs the PHY that software has completed loading the configuration data into SRAM, however
PHY3S00_SRAM_BYPASS(PHY3S00[7]) tells the PHY to load configuration from "hard wired" values.Is it necessary to wait for SRAM initialisation to complete if we're
Quoted 12 lines
Quoted 7 lines
bypassing it?
Quoted 6 lines
Quoted 1 line
Or are there other side-effects involved in the setting of PHY3S00[15]?
Yes, it is necessary to wait SRAM initial, the driver polls PHY3S00[15]. It reports that the boot loader in the PCS has finished initialising the SRAM (loading the contents into the PCS), and that initialisation has to complete before
sram_bypass(PHY3S00[7]) may beasserted.
Quoted 4 lines
Quoted 1 line
Can you improve the comment then to make it clear that the wait is necessary despite the bypass?
Hello Andrew,
Sorry for late response, it takes times commentate with our designer. The PHY takes its configuration from the internal SRAM in both modes, so the wait is necessary either way. PHY3S00[15] reports that the PCS boot loader has finished initialising that SRAM, and the loading controls - PHY3S00[7] and PHY3S00[6] - may only be driven once it has.
What the two controls select is which configuration is used:
PHY3S00_SRAM_BYPASS (bit 7) the default design configuration
PHY3S00_SRAM_EXT_LOAD (bit 6) the ROM code configuration
After confirm with designer I will modify at v4 patch from SRAM_BYPASS to EXT_LOAD, Due to that will be more precise configuration.
And I will update commit message with following.
phy: aspeed: Add AST2700 USB3.2 PHY driver
Add a driver for the USB3.2 PHY on the Aspeed AST2700, which is paired with the DWC3 controller.
The PHY draws its configuration from an internal SRAM in both of the available modes, so the driver must wait for PHY3S00_INIT_DONE before selecting one. PHY3S00_SRAM_BYPASS selects the default design configuration and PHY3S00_SRAM_EXT_LOAD the ROM code configuration; the driver uses the latter.
Ryan Chen
reviewerPATCH v2 3/3 MAINTAINERS: Add ASPEED USB3 PHY driver
In reply to Ryan ChenAdd maintainer entry for ASPEED USB3 PHY driver.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -3894,6 +3894,14 @@ S: Maintained F: Documentation/devicetree/bindings/usb/aspeed,ast2600-udc.yaml F: drivers/usb/gadget/udc/aspeed_udc.c +ASPEED USB3 PHY DRIVER +M: Ryan Chen <[email protected]> +L: [email protected] (moderated for non-subscribers) +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/phy/aspeed,ast2700-usb3-phy.yaml +F: drivers/phy/aspeed/phy-aspeed-usb3.c + ASPEED VIDEO ENGINE DRIVER M: Eddie James <[email protected]> L: [email protected]
Signature · 1 line
2.34.1