Add driver support for Eswin eic7700 SoC USB controller
Subsystems (3)
v2 cover Add driver support for Eswin eic7700 SoC USB controller
From: Senchuan Zhang <[email protected]>
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/[email protected]/
- 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/[email protected]/
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
PATCH v2 1/2 dt-bindings: usb: Add Eswin EIC7700 USB controller
From: Senchuan Zhang <[email protected]>
Add Device Tree binding documentation for the ESWIN EIC7700 USB controller module.
--- .../bindings/usb/eswin,eic7700-usb.yaml | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml new file +123 -0
@@ -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 <[email protected]> + - Senchuan Zhang <[email protected]> + +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
Re: [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 USB controller
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml line 92
Quoted 6 lines · On 30/07/2025 09:40, [email protected] wrote:
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml new file +6
-0+ +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>;
This wasn't here. Drop.
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml line 103
Quoted 11 lines
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml new file +11
-0+ + 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?
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml line 109
Quoted 6 lines
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml new file +6
-0+ #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
Re: Re: [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 USB controller
Quoted 32 lines
-----原始邮件-----
发件人: "Krzysztof Kozlowski" <[email protected]>
发送时间:2025-07-30 15:46:02 (星期三)
收件人: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] 抄送: [email protected], [email protected], [email protected], [email protected]
主题: Re: [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 USB controllerDocumentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml line 92
Quoted 6 lines · On 30/07/2025 09:40, [email protected] wrote:
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml new file +6
-0+ +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>;This wasn't here. Drop.
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml line 103
Quoted 11 lines
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml new file +11
-0+ + 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;
Quoted 1 line
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>;
Quoted 9 lines
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml line 109
Quoted 7 lines
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml new file +6
-0+ #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?
Quoted 4 lines
Best regards,
Senchuan Zhang
Re: [PATCH v2 1/2] dt-bindings: usb: Add Eswin EIC7700 USB controller
Quoted 8 lines · zhangsenchuan
Quoted 8 lines
Quoted 7 lines
Documentation/devicetree/bindings/usb/eswin,eic7700-usb.yaml new file +6
-0+ #address-cells = <2>; + #size-cells = <2>; + + usb@50480000 { + compatible = "snps,dwc3"; + reg = <0x0 0x50480000 0x0 0x10000>;
Quoted 5 lines
Quoted 1 line
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
PATCH v2 2/2 usb: dwc3: eic7700: Add EIC7700 USB driver
In reply to [email protected]From: Senchuan Zhang <[email protected]>
Add the eic7700 usb driver, which is responsible for identifying,configuring and connecting usb devices.
--- 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
drivers/usb/dwc3/Kconfig +11 -0
@@ -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
drivers/usb/dwc3/Makefile +1 -0
@@ -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
drivers/usb/dwc3/dwc3-eic7700.c new file +207 -0
207 lines not on this page · raw message
Signature · 1 line
2.25.1
Thinh Nguyen
maintainerRe: [PATCH v2 2/2] usb: dwc3: eic7700: Add EIC7700 USB driver
Quoted 167 lines · On Wed, Jul 30, 2025, [email protected] wrote:
From: Senchuan Zhang <[email protected]>
Add the eic7700 usb driver, which is responsible for identifying,configuring and connecting usb devices.
Co-developed-by Wei Yang <[email protected]>Signed-off-by Wei Yang <[email protected]>Signed-off-by Senchuan Zhang <[email protected]>--- 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.cdrivers/usb/dwc3/Kconfig +11
-0@@ -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. + endifdrivers/usb/dwc3/Makefile +1
-0@@ -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.odrivers/usb/dwc3/dwc3-eic7700.c new file +117
-0@@ -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 <[email protected]> +* Senchuan Zhang <[email protected]> +*/ + +#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);
drivers/usb/dwc3/dwc3-eic7700.c line 127
Quoted 10 lines
drivers/usb/dwc3/dwc3-eic7700.c new file +10
-0+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.
Quoted 45 lines
drivers/usb/dwc3/dwc3-eic7700.c new file +45
-0+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) {
drivers/usb/dwc3/dwc3-eic7700.c line 182
Quoted 10 lines
drivers/usb/dwc3/dwc3-eic7700.c new file +10
-0+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?
Quoted 5 lines
drivers/usb/dwc3/dwc3-eic7700.c new file +5
-0+}; + +static const struct of_device_id eswin_dwc3_match[] = { + { .compatible ="eswin,eic7700-dwc3" }, + {},
drivers/usb/dwc3/dwc3-eic7700.c line 197
Quoted 10 lines
drivers/usb/dwc3/dwc3-eic7700.c new file +10
-0+}; + +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.
Quoted 13 lines
drivers/usb/dwc3/dwc3-eic7700.c new file +10
-0+ .of_match_table = eswin_dwc3_match, + }, +}; + +module_platform_driver (dwc3_eswin_driver); + +MODULE_AUTHOR ("Wei Yang <[email protected]" ); +MODULE_AUTHOR ("Senchuan Zhang <[email protected]" ); +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("DesignWare USB3 ESWIN Glue Layer" );Signature · 1 line
2.25.1
BR,
Thinh