* [PATCH v6 1/5] dt-bindings: usb: ci-hdrc-usb2: add spacemit,k1-usb2 compatible
2026-11-19 13:41 [PATCH v6 0/5] Add SpacemiT K1 USB2.0 controllers support Junzhong Pan
@ 2026-11-19 13:41 ` Junzhong Pan
2026-11-19 14:08 ` Krzysztof Kozlowski
2026-11-19 13:41 ` [PATCH v6 2/5] usb: chipidea: usb2: use devm_clk_get_optional_enabled() Junzhong Pan
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Junzhong Pan @ 2026-11-19 13:41 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Peter Chen, Xu Yang, Peng Fan
Cc: linux-usb, devicetree, linux-kernel, Yixun Lan, Troy Mitchell,
spacemit, Junzhong Pan, Conor Dooley
The USB2.0 controller on the SpacemiT K1 SoC is dual-role capable but
has no internal OTG registers, this requires flags which disable
related features set in platform data. Add a compatible string to match
the platform data.
Chipidea USB2 Controller on SpacemiT K1 requires 1 clock and 1 reset to
work, add constraints for it.
Reviewed-by: Yixun Lan <dlan@kernel.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Junzhong Pan <panjunzhong@linux.spacemit.com>
---
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml
index 620b564914d4..5c2b7eb1a6ff 100644
--- a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml
+++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml
@@ -25,6 +25,7 @@ properties:
- nvidia,tegra124-udc
- nxp,s32g2-usb
- qcom,ci-hdrc
+ - spacemit,k1-usb2
- items:
- enum:
- nvidia,tegra114-ehci
@@ -113,6 +114,20 @@ allOf:
maxItems: 2
clock-names:
maxItems: 2
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: spacemit,k1-usb2
+ then:
+ properties:
+ clocks:
+ maxItems: 1
+ resets:
+ minItems: 1
+ required:
+ - clocks
+ - resets
unevaluatedProperties: false
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v6 1/5] dt-bindings: usb: ci-hdrc-usb2: add spacemit,k1-usb2 compatible
2026-11-19 13:41 ` [PATCH v6 1/5] dt-bindings: usb: ci-hdrc-usb2: add spacemit,k1-usb2 compatible Junzhong Pan
@ 2026-11-19 14:08 ` Krzysztof Kozlowski
0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-19 14:08 UTC (permalink / raw)
To: Junzhong Pan, Greg Kroah-Hartman, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Peter Chen, Xu Yang, Peng Fan
Cc: linux-usb, devicetree, linux-kernel, Yixun Lan, Troy Mitchell,
spacemit, Conor Dooley
On 19/11/2026 14:41, Junzhong Pan wrote:
> The USB2.0 controller on the SpacemiT K1 SoC is dual-role capable but
> has no internal OTG registers, this requires flags which disable
> related features set in platform data. Add a compatible string to match
> the platform data.
>
> Chipidea USB2 Controller on SpacemiT K1 requires 1 clock and 1 reset to
> work, add constraints for it.
>
> Reviewed-by: Yixun Lan <dlan@kernel.org>
Hm, I could not locate this tag. Where did it happen?
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> Signed-off-by: Junzhong Pan <panjunzhong@linux.spacemit.com>
> ---
> Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml
> index 620b564914d4..5c2b7eb1a6ff 100644
> --- a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml
> +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml
> @@ -25,6 +25,7 @@ properties:
> - nvidia,tegra124-udc
> - nxp,s32g2-usb
> - qcom,ci-hdrc
> + - spacemit,k1-usb2
> - items:
> - enum:
> - nvidia,tegra114-ehci
> @@ -113,6 +114,20 @@ allOf:
> maxItems: 2
> clock-names:
> maxItems: 2
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: spacemit,k1-usb2
> + then:
> + properties:
> + clocks:
> + maxItems: 1
Were are the clock-names constraints?
> + resets:
> + minItems: 1
This is odd. Why do you need minItems? What are the constraints?
This looks just wrong...
> + required:
> + - clocks
> + - resets
>
> unevaluatedProperties: false
>
>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v6 2/5] usb: chipidea: usb2: use devm_clk_get_optional_enabled()
2026-11-19 13:41 [PATCH v6 0/5] Add SpacemiT K1 USB2.0 controllers support Junzhong Pan
2026-11-19 13:41 ` [PATCH v6 1/5] dt-bindings: usb: ci-hdrc-usb2: add spacemit,k1-usb2 compatible Junzhong Pan
@ 2026-11-19 13:41 ` Junzhong Pan
2026-11-19 13:41 ` [PATCH v6 3/5] usb: chipidea: usb2: drop the ci_hdrc_usb2_priv wrapper struct Junzhong Pan
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Junzhong Pan @ 2026-11-19 13:41 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Peter Chen, Xu Yang, Peng Fan
Cc: linux-usb, devicetree, linux-kernel, Yixun Lan, Troy Mitchell,
spacemit, Junzhong Pan, Ze Huang
Convert devm_clk_get_optional() and clk_prepare_enable() into a single
call devm_clk_get_optional_enabled().
Reviewed-by: Yixun Lan <dlan@kernel.org>
Tested-by: Ze Huang <huang.ze@linux.dev>
Signed-off-by: Junzhong Pan <panjunzhong@linux.spacemit.com>
---
drivers/usb/chipidea/ci_hdrc_usb2.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
index b0200c5937cd..0032f9a9888e 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -20,7 +20,6 @@
struct ci_hdrc_usb2_priv {
struct platform_device *ci_pdev;
- struct clk *clk;
};
static const struct ci_hdrc_platform_data ci_default_pdata = {
@@ -52,6 +51,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
struct ci_hdrc_usb2_priv *priv;
struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
const struct ci_hdrc_platform_data *data;
+ struct clk *clk;
int ret;
if (!ci_pdata) {
@@ -70,15 +70,10 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
if (!priv)
return -ENOMEM;
- priv->clk = devm_clk_get_optional(dev, NULL);
- if (IS_ERR(priv->clk))
- return PTR_ERR(priv->clk);
-
- ret = clk_prepare_enable(priv->clk);
- if (ret) {
- dev_err(dev, "failed to enable the clock: %d\n", ret);
- return ret;
- }
+ clk = devm_clk_get_optional_enabled(dev, NULL);
+ if (IS_ERR(clk))
+ return dev_err_probe(dev, PTR_ERR(clk),
+ "failed to get or enable the clock\n");
ci_pdata->name = dev_name(dev);
@@ -90,7 +85,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
dev_err(dev,
"failed to register ci_hdrc platform device: %d\n",
ret);
- goto clk_err;
+ return ret;
}
platform_set_drvdata(pdev, priv);
@@ -99,10 +94,6 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
return 0;
-
-clk_err:
- clk_disable_unprepare(priv->clk);
- return ret;
}
static void ci_hdrc_usb2_remove(struct platform_device *pdev)
@@ -111,7 +102,6 @@ static void ci_hdrc_usb2_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
ci_hdrc_remove_device(priv->ci_pdev);
- clk_disable_unprepare(priv->clk);
}
static struct platform_driver ci_hdrc_usb2_driver = {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v6 3/5] usb: chipidea: usb2: drop the ci_hdrc_usb2_priv wrapper struct
2026-11-19 13:41 [PATCH v6 0/5] Add SpacemiT K1 USB2.0 controllers support Junzhong Pan
2026-11-19 13:41 ` [PATCH v6 1/5] dt-bindings: usb: ci-hdrc-usb2: add spacemit,k1-usb2 compatible Junzhong Pan
2026-11-19 13:41 ` [PATCH v6 2/5] usb: chipidea: usb2: use devm_clk_get_optional_enabled() Junzhong Pan
@ 2026-11-19 13:41 ` Junzhong Pan
2026-11-19 13:41 ` [PATCH v6 4/5] usb: chipidea: usb2: add optional reset support Junzhong Pan
2026-11-19 13:41 ` [PATCH v6 5/5] usb: chipidea: usb2: add SpacemiT K1 support Junzhong Pan
4 siblings, 0 replies; 7+ messages in thread
From: Junzhong Pan @ 2026-11-19 13:41 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Peter Chen, Xu Yang, Peng Fan
Cc: linux-usb, devicetree, linux-kernel, Yixun Lan, Troy Mitchell,
spacemit, Junzhong Pan
With the clock no longer stored in ci_hdrc_usb2_priv, the structure only
wraps the ci_hdrc platform device pointer. Store that pointer directly in
the driver data and drop the wrapper structure.
Signed-off-by: Junzhong Pan <panjunzhong@linux.spacemit.com>
---
drivers/usb/chipidea/ci_hdrc_usb2.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
index 0032f9a9888e..264546247a08 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -18,10 +18,6 @@
#include "ci.h"
-struct ci_hdrc_usb2_priv {
- struct platform_device *ci_pdev;
-};
-
static const struct ci_hdrc_platform_data ci_default_pdata = {
.capoffset = DEF_CAPOFFSET,
.flags = CI_HDRC_DISABLE_STREAMING,
@@ -48,7 +44,7 @@ MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
static int ci_hdrc_usb2_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- struct ci_hdrc_usb2_priv *priv;
+ struct platform_device *ci_pdev;
struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
const struct ci_hdrc_platform_data *data;
struct clk *clk;
@@ -66,10 +62,6 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
/* struct copy */
*ci_pdata = *data;
- priv = devm_kzalloc_obj(dev, *priv);
- if (!priv)
- return -ENOMEM;
-
clk = devm_clk_get_optional_enabled(dev, NULL);
if (IS_ERR(clk))
return dev_err_probe(dev, PTR_ERR(clk),
@@ -77,10 +69,10 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
ci_pdata->name = dev_name(dev);
- priv->ci_pdev = ci_hdrc_add_device(dev, pdev->resource,
- pdev->num_resources, ci_pdata);
- if (IS_ERR(priv->ci_pdev)) {
- ret = PTR_ERR(priv->ci_pdev);
+ ci_pdev = ci_hdrc_add_device(dev, pdev->resource,
+ pdev->num_resources, ci_pdata);
+ if (IS_ERR(ci_pdev)) {
+ ret = PTR_ERR(ci_pdev);
if (ret != -EPROBE_DEFER)
dev_err(dev,
"failed to register ci_hdrc platform device: %d\n",
@@ -88,7 +80,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
return ret;
}
- platform_set_drvdata(pdev, priv);
+ platform_set_drvdata(pdev, ci_pdev);
pm_runtime_no_callbacks(dev);
pm_runtime_enable(dev);
@@ -98,10 +90,10 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
static void ci_hdrc_usb2_remove(struct platform_device *pdev)
{
- struct ci_hdrc_usb2_priv *priv = platform_get_drvdata(pdev);
+ struct platform_device *ci_pdev = platform_get_drvdata(pdev);
pm_runtime_disable(&pdev->dev);
- ci_hdrc_remove_device(priv->ci_pdev);
+ ci_hdrc_remove_device(ci_pdev);
}
static struct platform_driver ci_hdrc_usb2_driver = {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v6 4/5] usb: chipidea: usb2: add optional reset support
2026-11-19 13:41 [PATCH v6 0/5] Add SpacemiT K1 USB2.0 controllers support Junzhong Pan
` (2 preceding siblings ...)
2026-11-19 13:41 ` [PATCH v6 3/5] usb: chipidea: usb2: drop the ci_hdrc_usb2_priv wrapper struct Junzhong Pan
@ 2026-11-19 13:41 ` Junzhong Pan
2026-11-19 13:41 ` [PATCH v6 5/5] usb: chipidea: usb2: add SpacemiT K1 support Junzhong Pan
4 siblings, 0 replies; 7+ messages in thread
From: Junzhong Pan @ 2026-11-19 13:41 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Peter Chen, Xu Yang, Peng Fan
Cc: linux-usb, devicetree, linux-kernel, Yixun Lan, Troy Mitchell,
spacemit, Junzhong Pan, Ze Huang
The USB2 controller of SpacemiT K1 SoC requires reset support, to keep
compatibility, add optional reset support.
Tested-by: Ze Huang <huang.ze@linux.dev>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Reviewed-by: Yixun Lan <dlan@kernel.org>
Acked-by: Peter Chen <peter.chen@kernel.org>
Signed-off-by: Junzhong Pan <panjunzhong@linux.spacemit.com>
---
drivers/usb/chipidea/ci_hdrc_usb2.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
index 264546247a08..226e3cab6ca0 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -12,6 +12,7 @@
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/property.h>
+#include <linux/reset.h>
#include <linux/usb/chipidea.h>
#include <linux/usb/hcd.h>
#include <linux/usb/ulpi.h>
@@ -48,6 +49,7 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
const struct ci_hdrc_platform_data *data;
struct clk *clk;
+ struct reset_control *reset;
int ret;
if (!ci_pdata) {
@@ -67,6 +69,11 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(clk),
"failed to get or enable the clock\n");
+ reset = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
+ if (IS_ERR(reset))
+ return dev_err_probe(dev, PTR_ERR(reset),
+ "failed to get or deassert the reset control\n");
+
ci_pdata->name = dev_name(dev);
ci_pdev = ci_hdrc_add_device(dev, pdev->resource,
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v6 5/5] usb: chipidea: usb2: add SpacemiT K1 support
2026-11-19 13:41 [PATCH v6 0/5] Add SpacemiT K1 USB2.0 controllers support Junzhong Pan
` (3 preceding siblings ...)
2026-11-19 13:41 ` [PATCH v6 4/5] usb: chipidea: usb2: add optional reset support Junzhong Pan
@ 2026-11-19 13:41 ` Junzhong Pan
4 siblings, 0 replies; 7+ messages in thread
From: Junzhong Pan @ 2026-11-19 13:41 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Peter Chen, Xu Yang, Peng Fan
Cc: linux-usb, devicetree, linux-kernel, Yixun Lan, Troy Mitchell,
spacemit, Junzhong Pan, Ze Huang
Add a compatible for SpacemiT K1, and add platform data with correct
flag since the hardware doesn't have internal otg register support.
Acked-by: Peter Chen <peter.chen@kernel.org>
Tested-by: Ze Huang <huang.ze@linux.dev>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Reviewed-by: Yixun Lan <dlan@kernel.org>
Signed-off-by: Junzhong Pan <panjunzhong@linux.spacemit.com>
---
drivers/usb/chipidea/ci_hdrc_usb2.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
index 226e3cab6ca0..b1d1c6df8b1d 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -34,10 +34,18 @@ static const struct ci_hdrc_platform_data ci_zevio_pdata = {
.flags = CI_HDRC_REGS_SHARED | CI_HDRC_FORCE_FULLSPEED,
};
+static const struct ci_hdrc_platform_data ci_k1_pdata = {
+ .capoffset = DEF_CAPOFFSET,
+ .flags = CI_HDRC_DISABLE_STREAMING |
+ CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS |
+ CI_HDRC_DUAL_ROLE_NOT_OTG,
+};
+
static const struct of_device_id ci_hdrc_usb2_of_match[] = {
{ .compatible = "chipidea,usb2" },
{ .compatible = "xlnx,zynq-usb-2.20a", .data = &ci_zynq_pdata },
{ .compatible = "lsi,zevio-usb", .data = &ci_zevio_pdata },
+ { .compatible = "spacemit,k1-usb2", .data = &ci_k1_pdata },
{ }
};
MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread