linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Add driver support for Eswin eic7700 SoC USB controller
@ 2025-07-30  7:39 zhangsenchuan
  2025-07-30  7:40 ` [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 " zhangsenchuan
  2025-07-30  7:41 ` [PATCH v2 2/2] usb: dwc3: eic7700: Add EIC7700 USB driver zhangsenchuan
  0 siblings, 2 replies; 7+ messages in thread
From: zhangsenchuan @ 2025-07-30  7:39 UTC (permalink / raw)
  To: gregkh, robh, krzk+dt, conor+dt, linux-usb, linux-kernel,
	devicetree, Thinh.Nguyen, p.zabel
  Cc: ningyu, linmin, yangwei1, pinkesh.vaghela, Senchuan Zhang

From: Senchuan Zhang <zhangsenchuan@eswincomputing.com>

Changes in v2:
- Updates: eswin,eic7700-usb.yaml
  - Drop the redundant descriptions.
  - Supplement the constraints of resets.
  - Replace "eswin,hsp_sp_csr" with "eswin,hsp-sp-csr"
    and add items description.
  - Drop numa-node-id, This is not necessary.
  - Add patternProperties and match the rules defined
    in the "snps,dwc3.yaml" file.
  - Add "#address-cells" "#size-cells".
  - Update the space indentation, remove the redundant labels,
    and sort the attributes according to the DTS encoding style.
  - Drop the "status = "disabled" attribute.
  - Update the common usb node names and fold the child
    nodes into the parent nodes.
  - The warning detected by the robot has been resolved.
- Link to V1: https://lore.kernel.org/lkml/20250516095237.1516-1-zhangsenchuan@eswincomputing.com/

- Updates: dwc3-eic7700.c
  - Remove dwc3_mode_show dwc3_mode_store dwc3_eswin_get_extcon_dev,
    dwc3_eswin_device_notifier and dwc3_eswin_host_notifier, usb role
    detection and switching are not supported.
  - Remove the hub-rst attribute, remove the dwc3_hub_rst_show and
    dwc3_hub_rst_store functions, this feature is not supported.
  - Use syscon_regmap_lookup_by_phandle_args instead of the
    syscon_regmap_lookup_by_phandle function.
  - Use dev_err_probe in probe function.
  - Drop mutex_lock, which is not required.
  - Remove clk_prepare_enable and of_clk_get, and manage multiple
    clocks using devm_clk_bulk_get_all_enabled.
  - Remove the device_init_wakeup related functions, which were
    used incorrectly.
  - Remove MODULE_ALIAS, which is used incorrectly.
  - The warning detected by the robot has been resolved.
- Link to V1: https://lore.kernel.org/lkml/20250516095237.1516-1-zhangsenchuan@eswincomputing.com/

Senchuan Zhang (2):
  dt-bindings: usb: Add Eswin EIC7700 USB controller
  usb: dwc3: eic7700: Add EIC7700 USB driver

 .../bindings/usb/eswin,eic7700-usb.yaml       | 123 +++++++++++
 drivers/usb/dwc3/Kconfig                      |  11 +
 drivers/usb/dwc3/Makefile                     |   1 +
 drivers/usb/dwc3/dwc3-eic7700.c               | 207 ++++++++++++++++++
 4 files changed, 342 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml
 create mode 100644 drivers/usb/dwc3/dwc3-eic7700.c

--
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 USB controller
  2025-07-30  7:39 [PATCH v2 0/2] Add driver support for Eswin eic7700 SoC USB controller zhangsenchuan
@ 2025-07-30  7:40 ` zhangsenchuan
  2025-07-30  7:46   ` Krzysztof Kozlowski
  2025-07-30  7:41 ` [PATCH v2 2/2] usb: dwc3: eic7700: Add EIC7700 USB driver zhangsenchuan
  1 sibling, 1 reply; 7+ messages in thread
From: zhangsenchuan @ 2025-07-30  7:40 UTC (permalink / raw)
  To: gregkh, robh, krzk+dt, conor+dt, linux-usb, linux-kernel,
	devicetree, Thinh.Nguyen, p.zabel
  Cc: ningyu, linmin, yangwei1, pinkesh.vaghela, Senchuan Zhang

From: Senchuan Zhang <zhangsenchuan@eswincomputing.com>

Add Device Tree binding documentation for the ESWIN EIC7700
USB controller module.

Co-developed-by: Wei Yang <yangwei1@eswincomputing.com>
Signed-off-by: Wei Yang <yangwei1@eswincomputing.com>
Signed-off-by: Senchuan Zhang <zhangsenchuan@eswincomputing.com>
---
 .../bindings/usb/eswin,eic7700-usb.yaml       | 123 ++++++++++++++++++
 1 file changed, 123 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml

diff --git a/Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml b/Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml
new file mode 100644
index 000000000000..c5a545d0ef49
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml
@@ -0,0 +1,123 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/eswin,eic7700-usb.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Eswin EIC7700 SoC Usb Controller
+
+maintainers:
+  - Wei Yang <yangwei1@eswincomputing.com>
+  - Senchuan Zhang <zhangsenchuan@eswincomputing.com>
+
+description:
+  The Usb controller on EIC7700 SoC.
+
+properties:
+  compatible:
+    const: eswin,eic7700-usb
+
+  reg:
+    maxItems: 1
+
+  '#address-cells':
+    const: 2
+
+  '#size-cells':
+    const: 2
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-names:
+    items:
+      - const: peripheral
+
+  clocks:
+    maxItems: 3
+
+  clock-names:
+    items:
+      - const: suspend
+      - const: aclk
+      - const: cfg
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    items:
+      - const: vaux
+
+  ranges: true
+
+  eswin,hsp-sp-csr:
+    description:
+      The phandle to HSP(High-Speed Peripheral) Register Controller hsp_sp_csr node
+      and the offset of HSP register for USB.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - items:
+          - description: phandle to HSP Register Controller hsp_sp_csr node.
+          - description: usb bus register offset.
+          - description: axi low power register offset.
+          - description: vbus frequency register offset.
+          - description: mpll register offset.
+
+patternProperties:
+  "^usb@[0-9a-f]+$":
+    $ref: snps,dwc3.yaml#
+    description: Required child node
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - interrupts
+  - interrupt-names
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - ranges
+  - eswin,hsp-sp-csr
+
+additionalProperties: false
+
+examples:
+  - |
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        usb {
+            compatible = "eswin,eic7700-dwc3";
+            clocks = <&fixed_factor_u_clk_1m_div24>,
+                     <&gate_clk_hsp_aclk>,
+                     <&gate_clk_hsp_cfgclk>;
+            clock-names = "suspend","aclk", "cfg";
+            eswin,hsp-sp-csr = <&hsp_sp_csr 0x800 0x808 0x83c 0x840>;
+            resets = <&reset 84>;
+            reset-names = "vaux";
+            ranges;
+            #address-cells = <2>;
+            #size-cells = <2>;
+
+            usb@50480000 {
+                compatible = "snps,dwc3";
+                reg = <0x0 0x50480000 0x0 0x10000>;
+                interrupt-parent = <&plic>;
+                interrupts = <85>;
+                interrupt-names = "peripheral";
+                dr_mode = "peripheral";
+                phy_type = "utmi";
+                maximum-speed = "high-speed";
+                snps,dis_enblslpm_quirk;
+                snps,dis-u2-freeclk-exists-quirk;
+                snps,dis_u2_susphy_quirk;
+                snps,dis-del-phy-power-chg-quirk;
+                snps,parkmode-disable-ss-quirk;
+            };
+        };
+    };
--
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] usb: dwc3: eic7700: Add EIC7700 USB driver
  2025-07-30  7:39 [PATCH v2 0/2] Add driver support for Eswin eic7700 SoC USB controller zhangsenchuan
  2025-07-30  7:40 ` [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 " zhangsenchuan
@ 2025-07-30  7:41 ` zhangsenchuan
  2025-08-06  0:17   ` Thinh Nguyen
  1 sibling, 1 reply; 7+ messages in thread
From: zhangsenchuan @ 2025-07-30  7:41 UTC (permalink / raw)
  To: gregkh, robh, krzk+dt, conor+dt, linux-usb, linux-kernel,
	devicetree, Thinh.Nguyen, p.zabel
  Cc: ningyu, linmin, yangwei1, pinkesh.vaghela, Senchuan Zhang

From: Senchuan Zhang <zhangsenchuan@eswincomputing.com>

Add the eic7700 usb driver, which is responsible for
identifying,configuring and connecting usb devices.

Co-developed-by: Wei Yang <yangwei1@eswincomputing.com>
Signed-off-by: Wei Yang <yangwei1@eswincomputing.com>
Signed-off-by: Senchuan Zhang <zhangsenchuan@eswincomputing.com>
---
 drivers/usb/dwc3/Kconfig        |  11 ++
 drivers/usb/dwc3/Makefile       |   1 +
 drivers/usb/dwc3/dwc3-eic7700.c | 207 ++++++++++++++++++++++++++++++++
 3 files changed, 219 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-eic7700.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 310d182e10b5..19657cfb5d08 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -189,4 +189,15 @@ config USB_DWC3_RTK
 	  or dual-role mode.
 	  Say 'Y' or 'M' if you have such device.
 
+config USB_DWC3_EIC7700
+	tristate "Eswin Platforms"
+	depends on OF
+	depends on USB=y || USB=USB_DWC3
+	default USB_DWC3
+	help
+	  The usb controller on eic7700 SoC.
+	  support of USB2/3 functionality
+	  in Eswin platforms.
+	  say 'Y' or 'M' if you have one such device.
+
 endif
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 830e6c9e5fe0..05f582103f8b 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -57,3 +57,4 @@ obj-$(CONFIG_USB_DWC3_IMX8MP)		+= dwc3-imx8mp.o
 obj-$(CONFIG_USB_DWC3_XILINX)		+= dwc3-xilinx.o
 obj-$(CONFIG_USB_DWC3_OCTEON)		+= dwc3-octeon.o
 obj-$(CONFIG_USB_DWC3_RTK)		+= dwc3-rtk.o
+obj-$(CONFIG_USB_DWC3_EIC7700)		+= dwc3-eic7700.o
diff --git a/drivers/usb/dwc3/dwc3-eic7700.c b/drivers/usb/dwc3/dwc3-eic7700.c
new file mode 100644
index 000000000000..337f6c1cbe66
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-eic7700.c
@@ -0,0 +1,207 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Eswin Specific Glue layer
+ *
+ * Copyright 2025, Beijing ESWIN Computing Technology Co., Ltd.
+ *
+ * Authors: Wei Yang <yangwei1@eswincomputing.com>
+ *          Senchuan Zhang <zhangsenchuan@eswincomputing.com>
+ */
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/reset.h>
+#include <linux/usb.h>
+#include <linux/pm.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
+
+#define HSP_USB_VBUS_FSEL 0x2a
+#define HSP_USB_MPLL_DEFAULT 0x0
+
+#define HSP_USB_BUS_FILTER_EN (0x1 << 0)
+#define HSP_USB_BUS_CLKEN_GM (0x1 << 9)
+#define HSP_USB_BUS_CLKEN_GS (0x1 << 16)
+#define HSP_USB_BUS_SW_RST (0x1 << 24)
+#define HSP_USB_BUS_CLK_EN (0x1 << 28)
+
+#define HSP_USB_AXI_LP_XM_CSYSREQ (0x1 << 0)
+#define HSP_USB_AXI_LP_XS_CSYSREQ (0x1 << 16)
+
+struct dwc3_eswin {
+	int num_clks;
+	struct device *dev;
+	struct clk_bulk_data *clks;
+	struct reset_control *vaux_rst;
+};
+
+static int dwc_usb_clk_init(struct device *dev)
+{
+	struct regmap *regmap;
+	u32 hsp_usb_bus;
+	u32 hsp_usb_axi_lp;
+	u32 hsp_usb_vbus_freq;
+	u32 hsp_usb_mpll;
+	u32 args[4];
+
+	regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node,
+						      "eswin,hsp-sp-csr", 4,
+						      args);
+	if (IS_ERR(regmap)) {
+		dev_err(dev, "No hsp-sp-csr phandle specified\n");
+		return PTR_ERR(regmap);
+	}
+
+	hsp_usb_bus       = args[0];
+	hsp_usb_axi_lp    = args[1];
+	hsp_usb_vbus_freq = args[2];
+	hsp_usb_mpll      = args[3];
+
+	/*
+	 * usb clock init
+	 * ref clock is 24M, below need to be set to satisfy
+	 * usb phy requirement(125M)
+	 */
+	regmap_write(regmap, hsp_usb_vbus_freq, HSP_USB_VBUS_FSEL);
+	regmap_write(regmap, hsp_usb_mpll, HSP_USB_MPLL_DEFAULT);
+	/*
+	 * reset usb core and usb phy
+	 */
+	regmap_write(regmap, hsp_usb_bus, HSP_USB_BUS_FILTER_EN |
+		     HSP_USB_BUS_CLKEN_GM | HSP_USB_BUS_CLKEN_GS |
+		     HSP_USB_BUS_SW_RST | HSP_USB_BUS_CLK_EN);
+	regmap_write(regmap, hsp_usb_axi_lp, HSP_USB_AXI_LP_XM_CSYSREQ |
+		     HSP_USB_AXI_LP_XS_CSYSREQ);
+
+	return 0;
+}
+
+static int dwc3_eswin_probe(struct platform_device *pdev)
+{
+	struct dwc3_eswin *eswin;
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	int ret;
+
+	eswin = devm_kzalloc(dev, sizeof(*eswin), GFP_KERNEL);
+	if (!eswin)
+		return -ENOMEM;
+
+	eswin->dev = dev;
+	platform_set_drvdata(pdev, eswin);
+
+	eswin->num_clks = devm_clk_bulk_get_all_enabled(dev, &eswin->clks);
+	if (eswin->num_clks < 0)
+		return dev_err_probe(dev, eswin->num_clks,
+				     "Failed to get usb clocks\n");
+
+	eswin->vaux_rst = devm_reset_control_get(dev, "vaux");
+	if (IS_ERR(eswin->vaux_rst))
+		return dev_err_probe(dev, PTR_ERR(eswin->vaux_rst),
+				     "Failed to get vaux reset\n");
+
+	ret = reset_control_deassert(eswin->vaux_rst);
+	if (ret)
+		return dev_err_probe(eswin->dev, ret,
+				     "Failed to deassert reset\n");
+
+	ret = dwc_usb_clk_init(dev);
+	if (ret) {
+		dev_err(eswin->dev, "Failed to clk init: %d\n", ret);
+		goto reset_assert;
+	}
+
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0) {
+		dev_err(dev, "get_sync failed with err %d\n", ret);
+		goto disable_pm;
+	}
+
+	/* Allocate and initialize the core */
+	ret = of_platform_populate(np, NULL, NULL, dev);
+	if (ret) {
+		dev_err(dev, "failed to create dwc3 core: %d\n", ret);
+		goto put_pm;
+	}
+
+	return ret;
+
+put_pm:
+	pm_runtime_put_sync(dev);
+disable_pm:
+	pm_runtime_disable(dev);
+reset_assert:
+	reset_control_assert(eswin->vaux_rst);
+
+	return ret;
+}
+
+static void dwc3_eswin_remove(struct platform_device *pdev)
+{
+	struct dwc3_eswin *eswin = platform_get_drvdata(pdev);
+	struct device *dev = &pdev->dev;
+
+	of_platform_depopulate(dev);
+
+	pm_runtime_put_sync(dev);
+	pm_runtime_disable(dev);
+	reset_control_assert(eswin->vaux_rst);
+}
+
+static int __maybe_unused dwc3_eswin_runtime_suspend(struct device *dev)
+{
+	struct dwc3_eswin *eswin = dev_get_drvdata(dev);
+
+	clk_bulk_disable_unprepare(eswin->num_clks, eswin->clks);
+
+	return 0;
+}
+
+static int __maybe_unused dwc3_eswin_runtime_resume(struct device *dev)
+{
+	struct dwc3_eswin *eswin = dev_get_drvdata(dev);
+	int ret;
+
+	ret = clk_bulk_prepare_enable(eswin->num_clks, eswin->clks);
+	if (ret) {
+		dev_err(dev, "failed to enable clocks: %d\n", ret);
+		return ret;
+	}
+
+	return ret;
+}
+
+static const struct dev_pm_ops dwc3_eswin_dev_pm_ops = {
+	SET_RUNTIME_PM_OPS(dwc3_eswin_runtime_suspend,
+			   dwc3_eswin_runtime_resume, NULL)
+};
+
+static const struct of_device_id eswin_dwc3_match[] = {
+	{ .compatible = "eswin,eic7700-dwc3" },
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, eswin_dwc3_match);
+
+static struct platform_driver dwc3_eswin_driver = {
+	.probe = dwc3_eswin_probe,
+	.remove = dwc3_eswin_remove,
+	.driver = {
+		.name = "eic7700-dwc3",
+		.pm	= &dwc3_eswin_dev_pm_ops,
+		.of_match_table = eswin_dwc3_match,
+	},
+};
+
+module_platform_driver(dwc3_eswin_driver);
+
+MODULE_AUTHOR("Wei Yang <yangwei1@eswincomputing.com");
+MODULE_AUTHOR("Senchuan Zhang <zhangsenchuan@eswincomputing.com");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("DesignWare USB3 ESWIN Glue Layer");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 USB controller
  2025-07-30  7:40 ` [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 " zhangsenchuan
@ 2025-07-30  7:46   ` Krzysztof Kozlowski
  2025-07-31  5:31     ` zhangsenchuan
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-30  7:46 UTC (permalink / raw)
  To: zhangsenchuan, gregkh, robh, krzk+dt, conor+dt, linux-usb,
	linux-kernel, devicetree, Thinh.Nguyen, p.zabel
  Cc: ningyu, linmin, yangwei1, pinkesh.vaghela

On 30/07/2025 09:40, zhangsenchuan@eswincomputing.com wrote:
> +
> +examples:
> +  - |
> +    soc {
> +        #address-cells = <2>;
> +        #size-cells = <2>;

This wasn't here. Drop.

> +
> +        usb {
> +            compatible = "eswin,eic7700-dwc3";
> +            clocks = <&fixed_factor_u_clk_1m_div24>,
> +                     <&gate_clk_hsp_aclk>,
> +                     <&gate_clk_hsp_cfgclk>;
> +            clock-names = "suspend","aclk", "cfg";
> +            eswin,hsp-sp-csr = <&hsp_sp_csr 0x800 0x808 0x83c 0x840>;
> +            resets = <&reset 84>;
> +            reset-names = "vaux";
> +            ranges;

Same comment: follow DTS coding style. Where should ranges or reg be placed?

> +            #address-cells = <2>;
> +            #size-cells = <2>;
> +
> +            usb@50480000 {
> +                compatible = "snps,dwc3";
> +                reg = <0x0 0x50480000 0x0 0x10000>;

Nothing improved and you did not respond to the feedback.


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Re: [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 USB controller
  2025-07-30  7:46   ` Krzysztof Kozlowski
@ 2025-07-31  5:31     ` zhangsenchuan
  2025-07-31  6:11       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: zhangsenchuan @ 2025-07-31  5:31 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: gregkh, robh, krzk+dt, conor+dt, linux-usb, linux-kernel,
	devicetree, Thinh.Nguyen, p.zabel, ningyu, linmin, yangwei1,
	pinkesh.vaghela




> -----原始邮件-----
> 发件人: "Krzysztof Kozlowski" <krzk@kernel.org>
> 发送时间:2025-07-30 15:46:02 (星期三)
> 收件人: zhangsenchuan@eswincomputing.com, gregkh@linuxfoundation.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Thinh.Nguyen@synopsys.com, p.zabel@pengutronix.de
> 抄送: ningyu@eswincomputing.com, linmin@eswincomputing.com, yangwei1@eswincomputing.com, pinkesh.vaghela@einfochips.com
> 主题: Re: [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 USB controller
> 
> On 30/07/2025 09:40, zhangsenchuan@eswincomputing.com wrote:
> > +
> > +examples:
> > +  - |
> > +    soc {
> > +        #address-cells = <2>;
> > +        #size-cells = <2>;
> 
> This wasn't here. Drop.
> 
> > +
> > +        usb {
> > +            compatible = "eswin,eic7700-dwc3";
> > +            clocks = <&fixed_factor_u_clk_1m_div24>,
> > +                     <&gate_clk_hsp_aclk>,
> > +                     <&gate_clk_hsp_cfgclk>;
> > +            clock-names = "suspend","aclk", "cfg";
> > +            eswin,hsp-sp-csr = <&hsp_sp_csr 0x800 0x808 0x83c 0x840>;
> > +            resets = <&reset 84>;
> > +            reset-names = "vaux";
> > +            ranges;
> 
> Same comment: follow DTS coding style. Where should ranges or reg be placed?

According to the "dts-coding-style.html", the order should be like below, is this correct?

compatible = "eswin,eic7700-dwc3";
ranges;
#address-cells = <1>;
#size-cells = <1>;

> 
> > +            #address-cells = <2>;
> > +            #size-cells = <2>;
> > +
> > +            usb@50480000 {
> > +                compatible = "snps,dwc3";
> > +                reg = <0x0 0x50480000 0x0 0x10000>;
> 
> Nothing improved and you did not respond to the feedback.

I'm very sorry that I haven't given you any feedback here. I'm not quite clear about what you mean by feedback.
In v1 patch, you mentioned "Fold the child node into the parent",could you please tell me what's the exact
meaning of this comment?
> 
> 
> Best regards,
> Senchuan Zhang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 USB controller
  2025-07-31  5:31     ` zhangsenchuan
@ 2025-07-31  6:11       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-31  6:11 UTC (permalink / raw)
  To: zhangsenchuan
  Cc: gregkh, robh, krzk+dt, conor+dt, linux-usb, linux-kernel,
	devicetree, Thinh.Nguyen, p.zabel, ningyu, linmin, yangwei1,
	pinkesh.vaghela

On 31/07/2025 07:31, zhangsenchuan wrote:
>>
>>> +            #address-cells = <2>;
>>> +            #size-cells = <2>;
>>> +
>>> +            usb@50480000 {
>>> +                compatible = "snps,dwc3";
>>> +                reg = <0x0 0x50480000 0x0 0x10000>;
>>
>> Nothing improved and you did not respond to the feedback.
> 
> I'm very sorry that I haven't given you any feedback here. I'm not quite clear about what you mean by feedback.
> In v1 patch, you mentioned "Fold the child node into the parent",could you please tell me what's the exact
> meaning of this comment?
It means you should not have separate child for dwc3, but only one node
in total.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] usb: dwc3: eic7700: Add EIC7700 USB driver
  2025-07-30  7:41 ` [PATCH v2 2/2] usb: dwc3: eic7700: Add EIC7700 USB driver zhangsenchuan
@ 2025-08-06  0:17   ` Thinh Nguyen
  0 siblings, 0 replies; 7+ messages in thread
From: Thinh Nguyen @ 2025-08-06  0:17 UTC (permalink / raw)
  To: zhangsenchuan@eswincomputing.com
  Cc: gregkh@linuxfoundation.org, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Thinh Nguyen, p.zabel@pengutronix.de, ningyu@eswincomputing.com,
	linmin@eswincomputing.com, yangwei1@eswincomputing.com,
	pinkesh.vaghela@einfochips.com

On Wed, Jul 30, 2025, zhangsenchuan@eswincomputing.com wrote:
> From: Senchuan Zhang <zhangsenchuan@eswincomputing.com>
> 
> Add the eic7700 usb driver, which is responsible for
> identifying,configuring and connecting usb devices.
> 
> Co-developed-by: Wei Yang <yangwei1@eswincomputing.com>
> Signed-off-by: Wei Yang <yangwei1@eswincomputing.com>
> Signed-off-by: Senchuan Zhang <zhangsenchuan@eswincomputing.com>
> ---
>  drivers/usb/dwc3/Kconfig        |  11 ++
>  drivers/usb/dwc3/Makefile       |   1 +
>  drivers/usb/dwc3/dwc3-eic7700.c | 207 ++++++++++++++++++++++++++++++++
>  3 files changed, 219 insertions(+)
>  create mode 100644 drivers/usb/dwc3/dwc3-eic7700.c
> 
> diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
> index 310d182e10b5..19657cfb5d08 100644
> --- a/drivers/usb/dwc3/Kconfig
> +++ b/drivers/usb/dwc3/Kconfig
> @@ -189,4 +189,15 @@ config USB_DWC3_RTK
>  	  or dual-role mode.
>  	  Say 'Y' or 'M' if you have such device.
>  
> +config USB_DWC3_EIC7700
> +	tristate "Eswin Platforms"
> +	depends on OF
> +	depends on USB=y || USB=USB_DWC3
> +	default USB_DWC3
> +	help
> +	  The usb controller on eic7700 SoC.
> +	  support of USB2/3 functionality
> +	  in Eswin platforms.
> +	  say 'Y' or 'M' if you have one such device.
> +
>  endif
> diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
> index 830e6c9e5fe0..05f582103f8b 100644
> --- a/drivers/usb/dwc3/Makefile
> +++ b/drivers/usb/dwc3/Makefile
> @@ -57,3 +57,4 @@ obj-$(CONFIG_USB_DWC3_IMX8MP)		+= dwc3-imx8mp.o
>  obj-$(CONFIG_USB_DWC3_XILINX)		+= dwc3-xilinx.o
>  obj-$(CONFIG_USB_DWC3_OCTEON)		+= dwc3-octeon.o
>  obj-$(CONFIG_USB_DWC3_RTK)		+= dwc3-rtk.o
> +obj-$(CONFIG_USB_DWC3_EIC7700)		+= dwc3-eic7700.o
> diff --git a/drivers/usb/dwc3/dwc3-eic7700.c b/drivers/usb/dwc3/dwc3-eic7700.c
> new file mode 100644
> index 000000000000..337f6c1cbe66
> --- /dev/null
> +++ b/drivers/usb/dwc3/dwc3-eic7700.c
> @@ -0,0 +1,207 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Eswin Specific Glue layer
> + *
> + * Copyright 2025, Beijing ESWIN Computing Technology Co., Ltd.
> + *
> + * Authors: Wei Yang <yangwei1@eswincomputing.com>
> + *          Senchuan Zhang <zhangsenchuan@eswincomputing.com>
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/platform_device.h>
> +#include <linux/clk.h>
> +#include <linux/of.h>
> +#include <linux/of_platform.h>
> +#include <linux/reset.h>
> +#include <linux/usb.h>
> +#include <linux/pm.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/regmap.h>
> +
> +#define HSP_USB_VBUS_FSEL 0x2a
> +#define HSP_USB_MPLL_DEFAULT 0x0
> +
> +#define HSP_USB_BUS_FILTER_EN (0x1 << 0)
> +#define HSP_USB_BUS_CLKEN_GM (0x1 << 9)
> +#define HSP_USB_BUS_CLKEN_GS (0x1 << 16)
> +#define HSP_USB_BUS_SW_RST (0x1 << 24)
> +#define HSP_USB_BUS_CLK_EN (0x1 << 28)
> +
> +#define HSP_USB_AXI_LP_XM_CSYSREQ (0x1 << 0)
> +#define HSP_USB_AXI_LP_XS_CSYSREQ (0x1 << 16)
> +
> +struct dwc3_eswin {
> +	int num_clks;
> +	struct device *dev;
> +	struct clk_bulk_data *clks;
> +	struct reset_control *vaux_rst;
> +};
> +
> +static int dwc_usb_clk_init(struct device *dev)
> +{
> +	struct regmap *regmap;
> +	u32 hsp_usb_bus;
> +	u32 hsp_usb_axi_lp;
> +	u32 hsp_usb_vbus_freq;
> +	u32 hsp_usb_mpll;
> +	u32 args[4];
> +
> +	regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node,
> +						      "eswin,hsp-sp-csr", 4,
> +						      args);
> +	if (IS_ERR(regmap)) {
> +		dev_err(dev, "No hsp-sp-csr phandle specified\n");
> +		return PTR_ERR(regmap);
> +	}
> +
> +	hsp_usb_bus       = args[0];
> +	hsp_usb_axi_lp    = args[1];
> +	hsp_usb_vbus_freq = args[2];
> +	hsp_usb_mpll      = args[3];
> +
> +	/*
> +	 * usb clock init
> +	 * ref clock is 24M, below need to be set to satisfy
> +	 * usb phy requirement(125M)
> +	 */
> +	regmap_write(regmap, hsp_usb_vbus_freq, HSP_USB_VBUS_FSEL);
> +	regmap_write(regmap, hsp_usb_mpll, HSP_USB_MPLL_DEFAULT);
> +	/*
> +	 * reset usb core and usb phy
> +	 */
> +	regmap_write(regmap, hsp_usb_bus, HSP_USB_BUS_FILTER_EN |
> +		     HSP_USB_BUS_CLKEN_GM | HSP_USB_BUS_CLKEN_GS |
> +		     HSP_USB_BUS_SW_RST | HSP_USB_BUS_CLK_EN);
> +	regmap_write(regmap, hsp_usb_axi_lp, HSP_USB_AXI_LP_XM_CSYSREQ |
> +		     HSP_USB_AXI_LP_XS_CSYSREQ);
> +
> +	return 0;
> +}
> +
> +static int dwc3_eswin_probe(struct platform_device *pdev)
> +{
> +	struct dwc3_eswin *eswin;
> +	struct device *dev = &pdev->dev;
> +	struct device_node *np = dev->of_node;
> +	int ret;
> +
> +	eswin = devm_kzalloc(dev, sizeof(*eswin), GFP_KERNEL);
> +	if (!eswin)
> +		return -ENOMEM;
> +
> +	eswin->dev = dev;
> +	platform_set_drvdata(pdev, eswin);
> +
> +	eswin->num_clks = devm_clk_bulk_get_all_enabled(dev, &eswin->clks);
> +	if (eswin->num_clks < 0)
> +		return dev_err_probe(dev, eswin->num_clks,
> +				     "Failed to get usb clocks\n");
> +
> +	eswin->vaux_rst = devm_reset_control_get(dev, "vaux");
> +	if (IS_ERR(eswin->vaux_rst))
> +		return dev_err_probe(dev, PTR_ERR(eswin->vaux_rst),
> +				     "Failed to get vaux reset\n");
> +
> +	ret = reset_control_deassert(eswin->vaux_rst);
> +	if (ret)
> +		return dev_err_probe(eswin->dev, ret,
> +				     "Failed to deassert reset\n");
> +
> +	ret = dwc_usb_clk_init(dev);
> +	if (ret) {
> +		dev_err(eswin->dev, "Failed to clk init: %d\n", ret);
> +		goto reset_assert;
> +	}
> +
> +	pm_runtime_set_active(dev);
> +	pm_runtime_enable(dev);
> +
> +	ret = pm_runtime_get_sync(dev);
> +	if (ret < 0) {
> +		dev_err(dev, "get_sync failed with err %d\n", ret);
> +		goto disable_pm;
> +	}
> +
> +	/* Allocate and initialize the core */
> +	ret = of_platform_populate(np, NULL, NULL, dev);

Can we use the dwc3 core as a library now instead of this as noted by
Krishna? Check dwc3-qcom for reference.

> +	if (ret) {
> +		dev_err(dev, "failed to create dwc3 core: %d\n", ret);
> +		goto put_pm;
> +	}
> +
> +	return ret;
> +
> +put_pm:
> +	pm_runtime_put_sync(dev);
> +disable_pm:
> +	pm_runtime_disable(dev);
> +reset_assert:
> +	reset_control_assert(eswin->vaux_rst);
> +
> +	return ret;
> +}
> +
> +static void dwc3_eswin_remove(struct platform_device *pdev)
> +{
> +	struct dwc3_eswin *eswin = platform_get_drvdata(pdev);
> +	struct device *dev = &pdev->dev;
> +
> +	of_platform_depopulate(dev);
> +
> +	pm_runtime_put_sync(dev);
> +	pm_runtime_disable(dev);
> +	reset_control_assert(eswin->vaux_rst);
> +}
> +
> +static int __maybe_unused dwc3_eswin_runtime_suspend(struct device *dev)
> +{
> +	struct dwc3_eswin *eswin = dev_get_drvdata(dev);
> +
> +	clk_bulk_disable_unprepare(eswin->num_clks, eswin->clks);
> +
> +	return 0;
> +}
> +
> +static int __maybe_unused dwc3_eswin_runtime_resume(struct device *dev)
> +{
> +	struct dwc3_eswin *eswin = dev_get_drvdata(dev);
> +	int ret;
> +
> +	ret = clk_bulk_prepare_enable(eswin->num_clks, eswin->clks);
> +	if (ret) {
> +		dev_err(dev, "failed to enable clocks: %d\n", ret);
> +		return ret;
> +	}
> +
> +	return ret;
> +}
> +
> +static const struct dev_pm_ops dwc3_eswin_dev_pm_ops = {
> +	SET_RUNTIME_PM_OPS(dwc3_eswin_runtime_suspend,
> +			   dwc3_eswin_runtime_resume, NULL)

You don't have system pm?

> +};
> +
> +static const struct of_device_id eswin_dwc3_match[] = {
> +	{ .compatible = "eswin,eic7700-dwc3" },
> +	{},
> +};
> +
> +MODULE_DEVICE_TABLE(of, eswin_dwc3_match);
> +
> +static struct platform_driver dwc3_eswin_driver = {
> +	.probe = dwc3_eswin_probe,
> +	.remove = dwc3_eswin_remove,
> +	.driver = {
> +		.name = "eic7700-dwc3",
> +		.pm	= &dwc3_eswin_dev_pm_ops,

Use pm_ptr() and remove the __maybe_unused tags.

> +		.of_match_table = eswin_dwc3_match,
> +	},
> +};
> +
> +module_platform_driver(dwc3_eswin_driver);
> +
> +MODULE_AUTHOR("Wei Yang <yangwei1@eswincomputing.com");
> +MODULE_AUTHOR("Senchuan Zhang <zhangsenchuan@eswincomputing.com");
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("DesignWare USB3 ESWIN Glue Layer");
> -- 
> 2.25.1
> 

BR,
Thinh

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-06  0:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-30  7:39 [PATCH v2 0/2] Add driver support for Eswin eic7700 SoC USB controller zhangsenchuan
2025-07-30  7:40 ` [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 " zhangsenchuan
2025-07-30  7:46   ` Krzysztof Kozlowski
2025-07-31  5:31     ` zhangsenchuan
2025-07-31  6:11       ` Krzysztof Kozlowski
2025-07-30  7:41 ` [PATCH v2 2/2] usb: dwc3: eic7700: Add EIC7700 USB driver zhangsenchuan
2025-08-06  0:17   ` Thinh Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).