[PATCH v5 2/2] usb: dwc3: eic7700: Add EIC7700 USB driver

caohang
2025-11-04T06:52:55Z

From: Hang Cao <caohang@eswincomputing.com>

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

Signed-off-by: Senchuan Zhang <zhangsenchuan@eswincomputing.com>
Signed-off-by: Hang Cao <caohang@eswincomputing.com>
---
drivers/usb/dwc3/dwc3-generic-plat.c | 43 ++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
index 770fedc16bb8..89ad952a4a4c 100644
--- a/drivers/usb/dwc3/dwc3-generic-plat.c
+++ b/drivers/usb/dwc3/dwc3-generic-plat.c
@@ -10,8 +10,16 @@
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
#include "glue.h"

+#define EIC7700_HSP_BUS_FILTER_EN BIT(0)
+#define EIC7700_HSP_BUS_CLKEN_GM BIT(9)
+#define EIC7700_HSP_BUS_CLKEN_GS BIT(16)
+#define EIC7700_HSP_AXI_LP_XM_CSYSREQ BIT(0)
+#define EIC7700_HSP_AXI_LP_XS_CSYSREQ BIT(16)
+
struct dwc3_generic {
struct device *dev;
struct dwc3 dwc;
@@ -27,6 +35,34 @@ static void dwc3_generic_reset_control_assert(void *data)
reset_control_assert(data);
}

+static int dwc3_eic7700_pre_init(struct device *dev)
+{
+ struct regmap *regmap;
+ u32 hsp_usb_axi_lp;
+ u32 hsp_usb_bus;
+ u32 args[2];
+ u32 val;
+
+ regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node,
+ "eswin,hsp-sp-csr",
+ ARRAY_SIZE(args), 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];
+
+ regmap_read(regmap, hsp_usb_bus, &val);
+ regmap_write(regmap, hsp_usb_bus, val | EIC7700_HSP_BUS_FILTER_EN |
+ EIC7700_HSP_BUS_CLKEN_GM | EIC7700_HSP_BUS_CLKEN_GS);
+
+ regmap_write(regmap, hsp_usb_axi_lp, EIC7700_HSP_AXI_LP_XM_CSYSREQ |
+ EIC7700_HSP_AXI_LP_XS_CSYSREQ);
+ return 0;
+}
+
static int dwc3_generic_probe(struct platform_device *pdev)
{
const struct dwc3_properties *properties;
@@ -83,6 +119,12 @@ static int dwc3_generic_probe(struct platform_device *pdev)
else
probe_data.properties = DWC3_DEFAULT_PROPERTIES;

+ if (of_device_is_compatible(dev->of_node, "eswin,eic7700-dwc3")) {
+ ret = dwc3_eic7700_pre_init(dev);
+ if (ret)
+ return dev_err_probe(dev, ret, "eic7700 init fail\n");
+ }
+
ret = dwc3_core_probe(&probe_data);
if (ret)
return dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
@@ -160,6 +202,7 @@ static const struct dwc3_properties fsl_ls1028_dwc3 = {
static const struct of_device_id dwc3_generic_of_match[] = {
{ .compatible = "spacemit,k1-dwc3", },
{ .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3},
+ { .compatible = "eswin,eic7700-dwc3",},
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, dwc3_generic_of_match);
--
2.34.1