Skip to contentSkip to conversation

usb: chipidea: Add support for s32g2 and s32g3

PATCH Superseded Dan Carpenter 3 participants 8 messages Jun 12, 2025 – Jun 13, 2025

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover usb: chipidea: Add support for s32g2 and s32g3

This patchset adds support for the s32g2 and s32g3 chips.

The changes since v1:
* Put the device tree lines in alphabetical order.
* Add [email protected] to the CC list.
* Use power_lost_check() instead of creating a new REINIT_DURING_RESUME flag.
* Change the Copyright date.
* Leave the .compatible = "nxp,s32g3-usb" out of the ci_hdrc_imx.c driver because people can just specify both in the devicetree since they are compatible.

Ghennadi Procopciuc (3):
dt-bindings: usb: Add compatible strings for s32g2/s32g3
usb: chipidea: s32g: Add usb support for s32g2
usb: chipidea: s32g: Add usb support for s32g3

 .../devicetree/bindings/usb/ci-hdrc-usb2.yaml |  2 +
 .../devicetree/bindings/usb/fsl,usbmisc.yaml  |  2 +
 drivers/usb/chipidea/ci_hdrc_imx.c            |  6 ++
 drivers/usb/chipidea/usbmisc_imx.c            | 89 +++++++++++++++++++
 4 files changed, 99 insertions(+)
Signature · 1 line
2.47.2
#1 lore raw

PATCH v2 1/3 dt-bindings: usb: Add compatible strings for s32g2/s32g3

From: Ghennadi Procopciuc <[email protected]>

Add the compatible strings for the NXP s32g2 and s32g3. These chips are mostly compatible. The one difference is that the s32g2-usbmisc device has an errata ERR050474 which requires a special flag to be set for handling packages that aren't 4 byte aligned.

---
Changes since v1:
1: Alphabetize
2: Update the commit message a bit.

 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml | 2 ++
 Documentation/devicetree/bindings/usb/fsl,usbmisc.yaml  | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml +2 -0
index cc5787a8cfa3..f6372b76ed5a 100644
@@ -23,6 +23,8 @@ properties:
           - nvidia,tegra30-udc
           - nvidia,tegra114-udc
           - nvidia,tegra124-udc
+          - nxp,s32g2-usb
+          - nxp,s32g3-usb
           - qcom,ci-hdrc
       - items:
           - enum:
Documentation/devicetree/bindings/usb/fsl,usbmisc.yaml +2 -0
index 019435540df0..ca677d1a8274 100644
@@ -21,6 +21,8 @@ properties:
           - fsl,imx53-usbmisc
           - fsl,imx6q-usbmisc
           - fsl,vf610-usbmisc
+          - nxp,s32g2-usbmisc
+          - nxp,s32g3-usbmisc
       - items:
           - enum:
               - fsl,imx6ul-usbmisc
Signature · 1 line
2.47.2
#2 lore raw

Re: [PATCH 1/3 v2] dt-bindings: usb: Add compatible strings for s32g2/s32g3

Quoted 11 lines · Ghennadi Procopciuc

From: Ghennadi Procopciuc <[email protected]>

Add the compatible strings for the NXP s32g2 and s32g3. These chips are mostly compatible. The one difference is that the s32g2-usbmisc device has an errata ERR050474 which requires a special flag to be set for handling packages that aren't 4 byte aligned.

This signoff chain is absolutely wrong, what were the contributions of Larisa, Ionut or Dan to this patch? If they were co-authors (surely not 4 people for a trivial 4 line diff) they need co-developed-by tags. You sent it, so your name should be last.

Quoted 38 lines

---
Changes since v1:
1: Alphabetize
2: Update the commit message a bit.

 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml | 2 ++
 Documentation/devicetree/bindings/usb/fsl,usbmisc.yaml  | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml +2 -0
index cc5787a8cfa3..f6372b76ed5a 100644
@@ -23,6 +23,8 @@ properties:
           - nvidia,tegra30-udc
           - nvidia,tegra114-udc
           - nvidia,tegra124-udc
+          - nxp,s32g2-usb
+          - nxp,s32g3-usb
           - qcom,ci-hdrc
       - items:
           - enum:
Documentation/devicetree/bindings/usb/fsl,usbmisc.yaml +2 -0
index 019435540df0..ca677d1a8274 100644
@@ -21,6 +21,8 @@ properties:
           - fsl,imx53-usbmisc
           - fsl,imx6q-usbmisc
           - fsl,vf610-usbmisc
+          - nxp,s32g2-usbmisc
+          - nxp,s32g3-usbmisc
       - items:
           - enum:
               - fsl,imx6ul-usbmisc
Signature · 1 line
2.47.2
maintainer
#3 lore raw

Re: [PATCH 1/3 v2] dt-bindings: usb: Add compatible strings for s32g2/s32g3

In reply to Ghennadi Procopciuc
Quoted 25 lines · Ghennadi Procopciuc

From: Ghennadi Procopciuc <[email protected]>

Add the compatible strings for the NXP s32g2 and s32g3. These chips are mostly compatible. The one difference is that the s32g2-usbmisc device has an errata ERR050474 which requires a special flag to be set for handling packages that aren't 4 byte aligned.

---
Changes since v1:
1: Alphabetize
2: Update the commit message a bit.

 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml | 2 ++
 Documentation/devicetree/bindings/usb/fsl,usbmisc.yaml  | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml +0 -0
index cc5787a8cfa3..f6372b76ed5a 100644

Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml properties: · line 27

Quoted 5 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml +2 -0
@@ -23,6 +23,8 @@ properties:
           - nvidia,tegra30-udc
           - nvidia,tegra114-udc
           - nvidia,tegra124-udc
+          - nxp,s32g2-usb
+          - nxp,s32g3-usb

You plan support nxp,s32g3-usb fallback to nxp,s32g2-usb in dts, your dts can't pass CHECK_DTB with this bindding.

Frank

Quoted 19 lines
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.yaml +0 -0
           - qcom,ci-hdrc
       - items:
           - enum:
Documentation/devicetree/bindings/usb/fsl,usbmisc.yaml +2 -1
index 019435540df0..ca677d1a8274 100644
@@ -21,6 +21,8 @@ properties:
           - fsl,imx53-usbmisc
           - fsl,imx6q-usbmisc
           - fsl,vf610-usbmisc
+          - nxp,s32g2-usbmisc
+          - nxp,s32g3-usbmisc
       - items:
           - enum:
               - fsl,imx6ul-usbmisc
--

2.47.2

#4 lore raw

PATCH v2 2/3 usb: chipidea: s32g: Add usb support for s32g2

In reply to Dan Carpenter

From: Ghennadi Procopciuc <[email protected]>

Enable USB driver for s32g2. This chip has an errata ERR050474, so we need to set S32G_UCMALLBE for it to handle packages which aren't 4 byte aligned correctly.

---
Changes since v1:
* Update the copyright
* Use the .power_lost_check callback.

 drivers/usb/chipidea/ci_hdrc_imx.c |  6 +++
 drivers/usb/chipidea/usbmisc_imx.c | 74 ++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)
drivers/usb/chipidea/ci_hdrc_imx.c +6 -0
index 780f4d151345..e8c847eab8e3 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2025 NXP
  * Copyright (C) 2012 Marek Vasut <[email protected]>
  * on behalf of DENX Software Engineering GmbH
  */
@@ -78,6 +79,10 @@ static const struct ci_hdrc_imx_platform_flag imx8ulp_usb_data = {
 		CI_HDRC_HAS_PORTSC_PEC_MISSED,
 };
 
+static const struct ci_hdrc_imx_platform_flag s32g_usb_data = {
+	.flags = CI_HDRC_DISABLE_HOST_STREAMING,
+};
+
 static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
 	{ .compatible = "fsl,imx23-usb", .data = &imx23_usb_data},
 	{ .compatible = "fsl,imx28-usb", .data = &imx28_usb_data},
@@ -89,6 +94,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
 	{ .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data},
 	{ .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data},
 	{ .compatible = "fsl,imx8ulp-usb", .data = &imx8ulp_usb_data},
+	{ .compatible = "nxp,s32g2-usb", .data = &s32g_usb_data},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, ci_hdrc_imx_dt_ids);
drivers/usb/chipidea/usbmisc_imx.c +74 -0

110 lines not on this page · raw message

Signature · 1 line
2.47.2
maintainer
#5 lore raw

Re: [PATCH 2/3 v2] usb: chipidea: s32g: Add usb support for s32g2

Quoted 3 lines · Dan Carpenter

From: Ghennadi Procopciuc <[email protected]>

Enable USB driver for s32g2. This chip has an errata ERR050474,

Can you provide errata link here?

Quoted 168 lines

so we need to set S32G_UCMALLBE for it to handle packages which aren't 4 byte aligned correctly.

---
Changes since v1:
* Update the copyright
* Use the .power_lost_check callback.

 drivers/usb/chipidea/ci_hdrc_imx.c |  6 +++
 drivers/usb/chipidea/usbmisc_imx.c | 74 ++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)
drivers/usb/chipidea/ci_hdrc_imx.c +6 -0
index 780f4d151345..e8c847eab8e3 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2025 NXP
  * Copyright (C) 2012 Marek Vasut <[email protected]>
  * on behalf of DENX Software Engineering GmbH
  */
@@ -78,6 +79,10 @@ static const struct ci_hdrc_imx_platform_flag imx8ulp_usb_data = {
 		CI_HDRC_HAS_PORTSC_PEC_MISSED,
 };
 
+static const struct ci_hdrc_imx_platform_flag s32g_usb_data = {
+	.flags = CI_HDRC_DISABLE_HOST_STREAMING,
+};
+
 static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
 	{ .compatible = "fsl,imx23-usb", .data = &imx23_usb_data},
 	{ .compatible = "fsl,imx28-usb", .data = &imx28_usb_data},
@@ -89,6 +94,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
 	{ .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data},
 	{ .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data},
 	{ .compatible = "fsl,imx8ulp-usb", .data = &imx8ulp_usb_data},
+	{ .compatible = "nxp,s32g2-usb", .data = &s32g_usb_data},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, ci_hdrc_imx_dt_ids);
drivers/usb/chipidea/usbmisc_imx.c +74 -1
index 118b9a68496b..67ff073ad806 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2025 NXP
  */
 
 #include <linux/module.h>
@@ -155,6 +156,18 @@
 					 BLKCTL_OTG_VBUS_WAKEUP_EN | \
 					 BLKCTL_OTG_DPDM_WAKEUP_EN)
 
+#define S32G_WAKEUP_IE		BIT(0)
+#define S32G_CORE_IE		BIT(1)
+#define S32G_PWRFLTEN		BIT(7)
+#define S32G_WAKEUPCTRL		BIT(10)
+#define S32G_WAKEUPEN		BIT(11)
+
+/* Workaround errata ERR050474 (handle packages that aren't 4 byte aligned) */
+#define S32G_UCMALLBE		BIT(15)
+
+#define S32G_WAKEUP_BITS (S32G_WAKEUP_IE | S32G_CORE_IE | S32G_WAKEUPEN | \
+			  S32G_WAKEUPCTRL)
+
 struct usbmisc_ops {
 	/* It's called once when probe a usb device */
 	int (*init)(struct imx_usbmisc_data *data);
@@ -614,6 +627,52 @@ static int usbmisc_vf610_init(struct imx_usbmisc_data *data)
 	return 0;
 }
 
+static int usbmisc_s32g_set_wakeup(struct imx_usbmisc_data *data, bool enabled)
+{
+	struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
+	unsigned long flags;
+	u32 reg;
+
+	spin_lock_irqsave(&usbmisc->lock, flags);
+
+	reg = readl(usbmisc->base);
+	if (enabled)
+		reg |= S32G_WAKEUP_BITS;
+	else
+		reg &= ~S32G_WAKEUP_BITS;
+
+	writel(reg, usbmisc->base);
+	spin_unlock_irqrestore(&usbmisc->lock, flags);
+
+	return 0;
+}
+
+static int usbmisc_s32g_init(struct imx_usbmisc_data *data, u32 extra_flags)
+{
+	struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
+	unsigned long flags;
+	u32 reg;
+
+	spin_lock_irqsave(&usbmisc->lock, flags);
+
+	reg = readl(usbmisc->base);
+
+	reg |= S32G_PWRFLTEN;
+	reg |= extra_flags;
+
+	writel(reg, usbmisc->base);
+
+	spin_unlock_irqrestore(&usbmisc->lock, flags);
+	usbmisc_s32g_set_wakeup(data, false);
+
+	return 0;
+}
+
+static int usbmisc_s32g2_init(struct imx_usbmisc_data *data)
+{
+	return usbmisc_s32g_init(data, S32G_UCMALLBE);
+}
+
 static int usbmisc_imx7d_set_wakeup
 	(struct imx_usbmisc_data *data, bool enabled)
 {
@@ -1033,6 +1092,11 @@ static int usbmisc_imx6sx_power_lost_check(struct imx_usbmisc_data *data)
 		return 0;
 }
 
+static int usbmisc_s32g_power_lost_check(struct imx_usbmisc_data *data)
+{
+	return 1;
+}
+
 static u32 usbmisc_blkctl_wakeup_setting(struct imx_usbmisc_data *data)
 {
 	u32 wakeup_setting = BLKCTL_WAKEUP_SOURCE;
@@ -1131,6 +1195,12 @@ static const struct usbmisc_ops imx95_usbmisc_ops = {
 	.vbus_comparator_on = usbmisc_imx7d_vbus_comparator_on,
 };
 
+static const struct usbmisc_ops s32g2_usbmisc_ops = {
+	.init = usbmisc_s32g2_init,
+	.set_wakeup = usbmisc_s32g_set_wakeup,
+	.power_lost_check = usbmisc_s32g_power_lost_check,
+};
+
 static inline bool is_imx53_usbmisc(struct imx_usbmisc_data *data)
 {
 	struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
@@ -1356,6 +1426,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
 		.compatible = "fsl,imx95-usbmisc",
 		.data = &imx95_usbmisc_ops,
 	},
+	{
+		.compatible = "nxp,s32g2-usbmisc",
+		.data = &s32g2_usbmisc_ops,
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
--

2.47.2

#6 lore raw

PATCH v2 3/3 usb: chipidea: s32g: Add usb support for s32g3

In reply to Dan Carpenter

From: Ghennadi Procopciuc <[email protected]>

Enable USB driver for the s32g3 USB device.

---
Changes since v1:
* Drop the changes to ci_hdrc_imx.c since that part is compatible with the s32g2 chip.
* Use the .power_lost_check() callback.

 drivers/usb/chipidea/usbmisc_imx.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/usb/chipidea/usbmisc_imx.c +15 -0
index 67ff073ad806..d5389156e157 100644
@@ -673,6 +673,11 @@ static int usbmisc_s32g2_init(struct imx_usbmisc_data *data)
 	return usbmisc_s32g_init(data, S32G_UCMALLBE);
 }
 
+static int usbmisc_s32g3_init(struct imx_usbmisc_data *data)
+{
+	return usbmisc_s32g_init(data, 0);
+}
+
 static int usbmisc_imx7d_set_wakeup
 	(struct imx_usbmisc_data *data, bool enabled)
 {
@@ -1201,6 +1206,12 @@ static const struct usbmisc_ops s32g2_usbmisc_ops = {
 	.power_lost_check = usbmisc_s32g_power_lost_check,
 };
 
+static const struct usbmisc_ops s32g3_usbmisc_ops = {
+	.init = usbmisc_s32g3_init,
+	.set_wakeup = usbmisc_s32g_set_wakeup,
+	.power_lost_check = usbmisc_s32g_power_lost_check,
+};
+
 static inline bool is_imx53_usbmisc(struct imx_usbmisc_data *data)
 {
 	struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
@@ -1430,6 +1441,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
 		.compatible = "nxp,s32g2-usbmisc",
 		.data = &s32g2_usbmisc_ops,
 	},
+	{
+		.compatible = "nxp,s32g3-usbmisc",
+		.data = &s32g3_usbmisc_ops,
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
Signature · 1 line
2.47.2
maintainer
#7 lore raw
In reply to Dan Carpenter
Quoted 11 lines · Dan Carpenter

This patchset adds support for the s32g2 and s32g3 chips.

The changes since v1:
* Put the device tree lines in alphabetical order.
* Add [email protected] to the CC list.
* Use power_lost_check() instead of creating a new REINIT_DURING_RESUME flag.
* Change the Copyright date.
* Leave the .compatible = "nxp,s32g3-usb" out of the ci_hdrc_imx.c driver because people can just specify both in the devicetree since they are compatible.

Suggest add dts patch also, make sure your dts file pass CHECK_DTBS

Frank

Quoted 15 lines

Ghennadi Procopciuc (3):
dt-bindings: usb: Add compatible strings for s32g2/s32g3
usb: chipidea: s32g: Add usb support for s32g2
usb: chipidea: s32g: Add usb support for s32g3

 .../devicetree/bindings/usb/ci-hdrc-usb2.yaml |  2 +
 .../devicetree/bindings/usb/fsl,usbmisc.yaml  |  2 +
 drivers/usb/chipidea/ci_hdrc_imx.c            |  6 ++
 drivers/usb/chipidea/usbmisc_imx.c            | 89 +++++++++++++++++++
 4 files changed, 99 insertions(+)

--
2.47.2