* [PATCH 0/3] phy: spacemit: Add USB2 PHY support for K3 SoC
@ 2026-02-12 1:38 Yixun Lan
2026-02-12 1:38 ` [PATCH 1/3] dt-bindings: phy: spacemit: k3: add USB2 PHY support Yixun Lan
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Yixun Lan @ 2026-02-12 1:38 UTC (permalink / raw)
To: Vinod Koul, Neil Armstrong, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Ze Huang
Cc: Junzhong Pan, linux-phy, devicetree, linux-riscv, spacemit,
linux-kernel, Yixun Lan
The series trys to add USB2 PHY support for SpacemiT K3 SoC,
while patch [2/3] implement a disconnect function which is
needed during next connection.
No DTS part has been inclueded in this series, instead I plan
to submit while adding USB host support.
Signed-off-by: Yixun Lan <dlan@kernel.org>
---
Yixun Lan (3):
dt-bindings: phy: spacemit: k3: add USB2 PHY support
phy: k1-usb: add disconnect function support
phy: k1-usb: k3: add USB2 PHY support
.../devicetree/bindings/phy/spacemit,usb2-phy.yaml | 6 ++-
drivers/phy/spacemit/phy-k1-usb2.c | 52 +++++++++++++++++++++-
2 files changed, 55 insertions(+), 3 deletions(-)
---
base-commit: dd39930f3d9c1d74a40b79d368e1f3d1555e919c
change-id: 20260124-11-k3-usb2-phy-c4630b990b1f
Best regards,
--
Yixun Lan <dlan@kernel.org>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 1/3] dt-bindings: phy: spacemit: k3: add USB2 PHY support 2026-02-12 1:38 [PATCH 0/3] phy: spacemit: Add USB2 PHY support for K3 SoC Yixun Lan @ 2026-02-12 1:38 ` Yixun Lan 2026-02-12 12:03 ` Krzysztof Kozlowski 2026-02-12 1:38 ` [PATCH 2/3] phy: k1-usb: add disconnect function support Yixun Lan 2026-02-12 1:38 ` [PATCH 3/3] phy: k1-usb: k3: add USB2 PHY support Yixun Lan 2 siblings, 1 reply; 9+ messages in thread From: Yixun Lan @ 2026-02-12 1:38 UTC (permalink / raw) To: Vinod Koul, Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ze Huang Cc: Junzhong Pan, linux-phy, devicetree, linux-riscv, spacemit, linux-kernel, Yixun Lan Introduce a compatible string for the USB2 PHY in SpacemiT K3 SoC. The IP of USB2 PHY mostly shares the same functionalities with K1 SoC, while has some register layout changes. Signed-off-by: Yixun Lan <dlan@kernel.org> --- Documentation/devicetree/bindings/phy/spacemit,usb2-phy.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/spacemit,usb2-phy.yaml b/Documentation/devicetree/bindings/phy/spacemit,usb2-phy.yaml index 43eaca90d88c..18025e5f60d6 100644 --- a/Documentation/devicetree/bindings/phy/spacemit,usb2-phy.yaml +++ b/Documentation/devicetree/bindings/phy/spacemit,usb2-phy.yaml @@ -4,14 +4,16 @@ $id: http://devicetree.org/schemas/phy/spacemit,usb2-phy.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: SpacemiT K1 SoC USB 2.0 PHY +title: SpacemiT K1/K3 SoC USB 2.0 PHY maintainers: - Ze Huang <huang.ze@linux.dev> properties: compatible: - const: spacemit,k1-usb2-phy + enum: + - spacemit,k1-usb2-phy + - spacemit,k3-usb2-phy reg: maxItems: 1 -- 2.52.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] dt-bindings: phy: spacemit: k3: add USB2 PHY support 2026-02-12 1:38 ` [PATCH 1/3] dt-bindings: phy: spacemit: k3: add USB2 PHY support Yixun Lan @ 2026-02-12 12:03 ` Krzysztof Kozlowski 0 siblings, 0 replies; 9+ messages in thread From: Krzysztof Kozlowski @ 2026-02-12 12:03 UTC (permalink / raw) To: Yixun Lan Cc: Vinod Koul, Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ze Huang, Junzhong Pan, linux-phy, devicetree, linux-riscv, spacemit, linux-kernel On Thu, Feb 12, 2026 at 09:38:54AM +0800, Yixun Lan wrote: > Introduce a compatible string for the USB2 PHY in SpacemiT K3 SoC. The IP > of USB2 PHY mostly shares the same functionalities with K1 SoC, while has > some register layout changes. > > Signed-off-by: Yixun Lan <dlan@kernel.org> > --- > Documentation/devicetree/bindings/phy/spacemit,usb2-phy.yaml | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Best regards, Krzysztof ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/3] phy: k1-usb: add disconnect function support 2026-02-12 1:38 [PATCH 0/3] phy: spacemit: Add USB2 PHY support for K3 SoC Yixun Lan 2026-02-12 1:38 ` [PATCH 1/3] dt-bindings: phy: spacemit: k3: add USB2 PHY support Yixun Lan @ 2026-02-12 1:38 ` Yixun Lan 2026-02-12 11:24 ` Yao Zi 2026-02-12 1:38 ` [PATCH 3/3] phy: k1-usb: k3: add USB2 PHY support Yixun Lan 2 siblings, 1 reply; 9+ messages in thread From: Yixun Lan @ 2026-02-12 1:38 UTC (permalink / raw) To: Vinod Koul, Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ze Huang Cc: Junzhong Pan, linux-phy, devicetree, linux-riscv, spacemit, linux-kernel, Yixun Lan A disconnect status BIT of USB2 PHY need to be cleared, otherwise it will fail to work properly during next connection when devices connect to roothub directly. Signed-off-by: Yixun Lan <dlan@kernel.org> --- drivers/phy/spacemit/phy-k1-usb2.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/phy/spacemit/phy-k1-usb2.c b/drivers/phy/spacemit/phy-k1-usb2.c index 342061380012..959bf79c7a72 100644 --- a/drivers/phy/spacemit/phy-k1-usb2.c +++ b/drivers/phy/spacemit/phy-k1-usb2.c @@ -48,6 +48,9 @@ #define PHY_CLK_HSTXP_EN BIT(3) /* clock hstxp enable */ #define PHY_HSTXP_MODE BIT(4) /* 0: force en_txp to be 1; 1: no force */ +#define PHY_K1_HS_HOST_DISC 0x40 +#define PHY_K1_HS_HOST_DISC_CLR BIT(0) + #define PHY_PLL_DIV_CFG 0x98 #define PHY_FDIV_FRACT_8_15 GENMASK(7, 0) #define PHY_FDIV_FRACT_16_19 GENMASK(11, 8) @@ -142,9 +145,20 @@ static int spacemit_usb2phy_exit(struct phy *phy) return 0; } +static int spacemit_usb2phy_disconnect(struct phy *phy, int port) +{ + struct spacemit_usb2phy *sphy = phy_get_drvdata(phy); + + regmap_update_bits(sphy->regmap_base, PHY_K1_HS_HOST_DISC, + PHY_K1_HS_HOST_DISC_CLR, PHY_K1_HS_HOST_DISC_CLR); + + return 0; +} + static const struct phy_ops spacemit_usb2phy_ops = { .init = spacemit_usb2phy_init, .exit = spacemit_usb2phy_exit, + .disconnect = spacemit_usb2phy_disconnect, .owner = THIS_MODULE, }; -- 2.52.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] phy: k1-usb: add disconnect function support 2026-02-12 1:38 ` [PATCH 2/3] phy: k1-usb: add disconnect function support Yixun Lan @ 2026-02-12 11:24 ` Yao Zi 2026-02-12 14:43 ` Yixun Lan 0 siblings, 1 reply; 9+ messages in thread From: Yao Zi @ 2026-02-12 11:24 UTC (permalink / raw) To: Yixun Lan, Vinod Koul, Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ze Huang Cc: Junzhong Pan, linux-phy, devicetree, linux-riscv, spacemit, linux-kernel On Thu, Feb 12, 2026 at 09:38:55AM +0800, Yixun Lan wrote: > A disconnect status BIT of USB2 PHY need to be cleared, otherwise > it will fail to work properly during next connection when devices > connect to roothub directly. This sounds like a bug. Does it affect K1 SoC as well? If so, I think it deserves a Fixes tag and backporting. > Signed-off-by: Yixun Lan <dlan@kernel.org> Best regards, Yao Zi ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] phy: k1-usb: add disconnect function support 2026-02-12 11:24 ` Yao Zi @ 2026-02-12 14:43 ` Yixun Lan 0 siblings, 0 replies; 9+ messages in thread From: Yixun Lan @ 2026-02-12 14:43 UTC (permalink / raw) To: Yao Zi Cc: Yixun Lan, Vinod Koul, Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ze Huang, Junzhong Pan, linux-phy, devicetree, linux-riscv, spacemit, linux-kernel Hi Yao, On 11:24 Thu 12 Feb , Yao Zi wrote: > On Thu, Feb 12, 2026 at 09:38:55AM +0800, Yixun Lan wrote: > > A disconnect status BIT of USB2 PHY need to be cleared, otherwise > > it will fail to work properly during next connection when devices > > connect to roothub directly. > > This sounds like a bug. Does it affect K1 SoC as well? If so, I think > it deserves a Fixes tag and backporting. > yes, but I haven't checked if it will affect real case since the problem exist with devices connected to roothub directly only.. anyway, I think it deserves to add a Fixes tag, so will do in next version -- Yixun Lan (dlan) ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] phy: k1-usb: k3: add USB2 PHY support 2026-02-12 1:38 [PATCH 0/3] phy: spacemit: Add USB2 PHY support for K3 SoC Yixun Lan 2026-02-12 1:38 ` [PATCH 1/3] dt-bindings: phy: spacemit: k3: add USB2 PHY support Yixun Lan 2026-02-12 1:38 ` [PATCH 2/3] phy: k1-usb: add disconnect function support Yixun Lan @ 2026-02-12 1:38 ` Yixun Lan 2026-02-12 11:30 ` Yao Zi 2 siblings, 1 reply; 9+ messages in thread From: Yixun Lan @ 2026-02-12 1:38 UTC (permalink / raw) To: Vinod Koul, Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ze Huang Cc: Junzhong Pan, linux-phy, devicetree, linux-riscv, spacemit, linux-kernel, Yixun Lan Add USB2 PHY support for SpacemiT K3 SoC. Register layout of handling USB disconnect operation has been changed, So introducing a platform data to distinguish the different SoCs. Signed-off-by: Yixun Lan <dlan@kernel.org> --- drivers/phy/spacemit/phy-k1-usb2.c | 40 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/phy/spacemit/phy-k1-usb2.c b/drivers/phy/spacemit/phy-k1-usb2.c index 959bf79c7a72..b0ce0a92861e 100644 --- a/drivers/phy/spacemit/phy-k1-usb2.c +++ b/drivers/phy/spacemit/phy-k1-usb2.c @@ -51,6 +51,9 @@ #define PHY_K1_HS_HOST_DISC 0x40 #define PHY_K1_HS_HOST_DISC_CLR BIT(0) +#define PHY_K3_HS_HOST_DISC 0x20 +#define PHY_K3_HS_HOST_DISC_CLR BIT(8) + #define PHY_PLL_DIV_CFG 0x98 #define PHY_FDIV_FRACT_8_15 GENMASK(7, 0) #define PHY_FDIV_FRACT_16_19 GENMASK(11, 8) @@ -74,10 +77,15 @@ #define K1_USB2PHY_RESET_TIME_MS 50 +struct spacemit_usb2phy_data { + int (*disconnect)(struct phy *phy, int port); +}; + struct spacemit_usb2phy { struct phy *phy; struct clk *clk; struct regmap *regmap_base; + const struct spacemit_usb2phy_data *data; }; static const struct regmap_config phy_regmap_config = { @@ -145,7 +153,7 @@ static int spacemit_usb2phy_exit(struct phy *phy) return 0; } -static int spacemit_usb2phy_disconnect(struct phy *phy, int port) +static int spacemit_k1_usb2phy_disconnect(struct phy *phy, int port) { struct spacemit_usb2phy *sphy = phy_get_drvdata(phy); @@ -155,6 +163,23 @@ static int spacemit_usb2phy_disconnect(struct phy *phy, int port) return 0; } +static int spacemit_k3_usb2phy_disconnect(struct phy *phy, int port) +{ + struct spacemit_usb2phy *sphy = phy_get_drvdata(phy); + + regmap_update_bits(sphy->regmap_base, PHY_K3_HS_HOST_DISC, + PHY_K3_HS_HOST_DISC_CLR, PHY_K3_HS_HOST_DISC_CLR); + + return 0; +} + +static int spacemit_usb2phy_disconnect(struct phy *phy, int port) +{ + struct spacemit_usb2phy *sphy = phy_get_drvdata(phy); + + return sphy->data->disconnect(phy, port); +} + static const struct phy_ops spacemit_usb2phy_ops = { .init = spacemit_usb2phy_init, .exit = spacemit_usb2phy_exit, @@ -173,6 +198,8 @@ static int spacemit_usb2phy_probe(struct platform_device *pdev) if (!sphy) return -ENOMEM; + sphy->data = device_get_match_data(dev); + sphy->clk = devm_clk_get_prepared(&pdev->dev, NULL); if (IS_ERR(sphy->clk)) return dev_err_probe(dev, PTR_ERR(sphy->clk), "Failed to get clock\n"); @@ -195,8 +222,17 @@ static int spacemit_usb2phy_probe(struct platform_device *pdev) return PTR_ERR_OR_ZERO(phy_provider); } +static const struct spacemit_usb2phy_data k1_usb2phy_data = { + .disconnect = spacemit_k1_usb2phy_disconnect, +}; + +static const struct spacemit_usb2phy_data k3_usb2phy_data = { + .disconnect = spacemit_k3_usb2phy_disconnect, +}; + static const struct of_device_id spacemit_usb2phy_dt_match[] = { - { .compatible = "spacemit,k1-usb2-phy", }, + { .compatible = "spacemit,k1-usb2-phy", .data = &k1_usb2phy_data }, + { .compatible = "spacemit,k3-usb2-phy", .data = &k3_usb2phy_data }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, spacemit_usb2phy_dt_match); -- 2.52.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] phy: k1-usb: k3: add USB2 PHY support 2026-02-12 1:38 ` [PATCH 3/3] phy: k1-usb: k3: add USB2 PHY support Yixun Lan @ 2026-02-12 11:30 ` Yao Zi 2026-02-12 14:35 ` Yixun Lan 0 siblings, 1 reply; 9+ messages in thread From: Yao Zi @ 2026-02-12 11:30 UTC (permalink / raw) To: Yixun Lan, Vinod Koul, Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ze Huang Cc: Junzhong Pan, linux-phy, devicetree, linux-riscv, spacemit, linux-kernel On Thu, Feb 12, 2026 at 09:38:56AM +0800, Yixun Lan wrote: > Add USB2 PHY support for SpacemiT K3 SoC. > > Register layout of handling USB disconnect operation has been changed, > So introducing a platform data to distinguish the different SoCs. Would it be clearer and simpler if you define separate phy_ops for k1 and k3, and point of_device_id.data directly to the corresponding phy_ops? Then there's no need to introduce either spacemit_usb2phy_data structure, or spacemit_usb2phy_disconnect wrapper. Best regards, Yao Zi > Signed-off-by: Yixun Lan <dlan@kernel.org> > --- > drivers/phy/spacemit/phy-k1-usb2.c | 40 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 38 insertions(+), 2 deletions(-) > > diff --git a/drivers/phy/spacemit/phy-k1-usb2.c b/drivers/phy/spacemit/phy-k1-usb2.c > index 959bf79c7a72..b0ce0a92861e 100644 > --- a/drivers/phy/spacemit/phy-k1-usb2.c > +++ b/drivers/phy/spacemit/phy-k1-usb2.c > @@ -51,6 +51,9 @@ > #define PHY_K1_HS_HOST_DISC 0x40 > #define PHY_K1_HS_HOST_DISC_CLR BIT(0) > > +#define PHY_K3_HS_HOST_DISC 0x20 > +#define PHY_K3_HS_HOST_DISC_CLR BIT(8) > + > #define PHY_PLL_DIV_CFG 0x98 > #define PHY_FDIV_FRACT_8_15 GENMASK(7, 0) > #define PHY_FDIV_FRACT_16_19 GENMASK(11, 8) > @@ -74,10 +77,15 @@ > > #define K1_USB2PHY_RESET_TIME_MS 50 > > +struct spacemit_usb2phy_data { > + int (*disconnect)(struct phy *phy, int port); > +}; > + > struct spacemit_usb2phy { > struct phy *phy; > struct clk *clk; > struct regmap *regmap_base; > + const struct spacemit_usb2phy_data *data; > }; > > static const struct regmap_config phy_regmap_config = { > @@ -145,7 +153,7 @@ static int spacemit_usb2phy_exit(struct phy *phy) > return 0; > } > > -static int spacemit_usb2phy_disconnect(struct phy *phy, int port) > +static int spacemit_k1_usb2phy_disconnect(struct phy *phy, int port) > { > struct spacemit_usb2phy *sphy = phy_get_drvdata(phy); > > @@ -155,6 +163,23 @@ static int spacemit_usb2phy_disconnect(struct phy *phy, int port) > return 0; > } > > +static int spacemit_k3_usb2phy_disconnect(struct phy *phy, int port) > +{ > + struct spacemit_usb2phy *sphy = phy_get_drvdata(phy); > + > + regmap_update_bits(sphy->regmap_base, PHY_K3_HS_HOST_DISC, > + PHY_K3_HS_HOST_DISC_CLR, PHY_K3_HS_HOST_DISC_CLR); > + > + return 0; > +} > + > +static int spacemit_usb2phy_disconnect(struct phy *phy, int port) > +{ > + struct spacemit_usb2phy *sphy = phy_get_drvdata(phy); > + > + return sphy->data->disconnect(phy, port); > +} > + > static const struct phy_ops spacemit_usb2phy_ops = { > .init = spacemit_usb2phy_init, > .exit = spacemit_usb2phy_exit, > @@ -173,6 +198,8 @@ static int spacemit_usb2phy_probe(struct platform_device *pdev) > if (!sphy) > return -ENOMEM; > > + sphy->data = device_get_match_data(dev); > + > sphy->clk = devm_clk_get_prepared(&pdev->dev, NULL); > if (IS_ERR(sphy->clk)) > return dev_err_probe(dev, PTR_ERR(sphy->clk), "Failed to get clock\n"); > @@ -195,8 +222,17 @@ static int spacemit_usb2phy_probe(struct platform_device *pdev) > return PTR_ERR_OR_ZERO(phy_provider); > } > > +static const struct spacemit_usb2phy_data k1_usb2phy_data = { > + .disconnect = spacemit_k1_usb2phy_disconnect, > +}; > + > +static const struct spacemit_usb2phy_data k3_usb2phy_data = { > + .disconnect = spacemit_k3_usb2phy_disconnect, > +}; > + > static const struct of_device_id spacemit_usb2phy_dt_match[] = { > - { .compatible = "spacemit,k1-usb2-phy", }, > + { .compatible = "spacemit,k1-usb2-phy", .data = &k1_usb2phy_data }, > + { .compatible = "spacemit,k3-usb2-phy", .data = &k3_usb2phy_data }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(of, spacemit_usb2phy_dt_match); > > -- > 2.52.0 > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] phy: k1-usb: k3: add USB2 PHY support 2026-02-12 11:30 ` Yao Zi @ 2026-02-12 14:35 ` Yixun Lan 0 siblings, 0 replies; 9+ messages in thread From: Yixun Lan @ 2026-02-12 14:35 UTC (permalink / raw) To: Yao Zi Cc: Yixun Lan, Vinod Koul, Neil Armstrong, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Ze Huang, Junzhong Pan, linux-phy, devicetree, linux-riscv, spacemit, linux-kernel Hi Yao, On 11:30 Thu 12 Feb , Yao Zi wrote: > On Thu, Feb 12, 2026 at 09:38:56AM +0800, Yixun Lan wrote: > > Add USB2 PHY support for SpacemiT K3 SoC. > > > > Register layout of handling USB disconnect operation has been changed, > > So introducing a platform data to distinguish the different SoCs. > > Would it be clearer and simpler if you define separate phy_ops for > k1 and k3, and point of_device_id.data directly to the corresponding > phy_ops? Then there's no need to introduce either spacemit_usb2phy_data > structure, or spacemit_usb2phy_disconnect wrapper. > Yes, I agree, thanks for the suggestion -- Yixun Lan (dlan) ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-02-12 14:43 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-02-12 1:38 [PATCH 0/3] phy: spacemit: Add USB2 PHY support for K3 SoC Yixun Lan 2026-02-12 1:38 ` [PATCH 1/3] dt-bindings: phy: spacemit: k3: add USB2 PHY support Yixun Lan 2026-02-12 12:03 ` Krzysztof Kozlowski 2026-02-12 1:38 ` [PATCH 2/3] phy: k1-usb: add disconnect function support Yixun Lan 2026-02-12 11:24 ` Yao Zi 2026-02-12 14:43 ` Yixun Lan 2026-02-12 1:38 ` [PATCH 3/3] phy: k1-usb: k3: add USB2 PHY support Yixun Lan 2026-02-12 11:30 ` Yao Zi 2026-02-12 14:35 ` Yixun Lan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox