Skip to content

Commit e05d28b

Browse files
Hang Caogregkh
authored andcommitted
usb: dwc3: eic7700: Add EIC7700 USB driver
The EIC7700 instantiates two USB 3.0 DWC3 IPs, each of which is backward compatible with USB interfaces. It supports Super-speed (5Gb/s), DRD mode, and compatible with xHCI 1.1, etc. Each of instances supports 16 endpoints in device's mode and max 64 devices in host's mode. This module needs to interact with the NOC via the AXI master bus, thus requiring some HSP configuration operations to achieve this. Ops include bus filter, pm signal or status to usb bus and so on. Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Signed-off-by: Senchuan Zhang <zhangsenchuan@eswincomputing.com> Signed-off-by: Hang Cao <caohang@eswincomputing.com> Link: https://patch.msgid.link/20251112055346.1655-1-caohang@eswincomputing.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c640a42 commit e05d28b

1 file changed

Lines changed: 64 additions & 7 deletions

File tree

drivers/usb/dwc3/dwc3-generic-plat.c

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@
1010
#include <linux/clk.h>
1111
#include <linux/platform_device.h>
1212
#include <linux/reset.h>
13+
#include <linux/regmap.h>
14+
#include <linux/mfd/syscon.h>
1315
#include "glue.h"
1416

17+
#define EIC7700_HSP_BUS_FILTER_EN BIT(0)
18+
#define EIC7700_HSP_BUS_CLKEN_GM BIT(9)
19+
#define EIC7700_HSP_BUS_CLKEN_GS BIT(16)
20+
#define EIC7700_HSP_AXI_LP_XM_CSYSREQ BIT(0)
21+
#define EIC7700_HSP_AXI_LP_XS_CSYSREQ BIT(16)
22+
1523
struct dwc3_generic {
1624
struct device *dev;
1725
struct dwc3 dwc;
@@ -20,16 +28,50 @@ struct dwc3_generic {
2028
struct reset_control *resets;
2129
};
2230

31+
struct dwc3_generic_config {
32+
int (*init)(struct dwc3_generic *dwc3g);
33+
struct dwc3_properties properties;
34+
};
35+
2336
#define to_dwc3_generic(d) container_of((d), struct dwc3_generic, dwc)
2437

2538
static void dwc3_generic_reset_control_assert(void *data)
2639
{
2740
reset_control_assert(data);
2841
}
2942

43+
static int dwc3_eic7700_init(struct dwc3_generic *dwc3g)
44+
{
45+
struct device *dev = dwc3g->dev;
46+
struct regmap *regmap;
47+
u32 hsp_usb_axi_lp;
48+
u32 hsp_usb_bus;
49+
u32 args[2];
50+
u32 val;
51+
52+
regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node,
53+
"eswin,hsp-sp-csr",
54+
ARRAY_SIZE(args), args);
55+
if (IS_ERR(regmap)) {
56+
dev_err(dev, "No hsp-sp-csr phandle specified\n");
57+
return PTR_ERR(regmap);
58+
}
59+
60+
hsp_usb_bus = args[0];
61+
hsp_usb_axi_lp = args[1];
62+
63+
regmap_read(regmap, hsp_usb_bus, &val);
64+
regmap_write(regmap, hsp_usb_bus, val | EIC7700_HSP_BUS_FILTER_EN |
65+
EIC7700_HSP_BUS_CLKEN_GM | EIC7700_HSP_BUS_CLKEN_GS);
66+
67+
regmap_write(regmap, hsp_usb_axi_lp, EIC7700_HSP_AXI_LP_XM_CSYSREQ |
68+
EIC7700_HSP_AXI_LP_XS_CSYSREQ);
69+
return 0;
70+
}
71+
3072
static int dwc3_generic_probe(struct platform_device *pdev)
3173
{
32-
const struct dwc3_properties *properties;
74+
const struct dwc3_generic_config *plat_config;
3375
struct dwc3_probe_data probe_data = {};
3476
struct device *dev = &pdev->dev;
3577
struct dwc3_generic *dwc3g;
@@ -77,12 +119,21 @@ static int dwc3_generic_probe(struct platform_device *pdev)
77119
probe_data.res = res;
78120
probe_data.ignore_clocks_and_resets = true;
79121

80-
properties = of_device_get_match_data(dev);
81-
if (properties)
82-
probe_data.properties = *properties;
83-
else
122+
plat_config = of_device_get_match_data(dev);
123+
if (!plat_config) {
84124
probe_data.properties = DWC3_DEFAULT_PROPERTIES;
125+
goto core_probe;
126+
}
85127

128+
probe_data.properties = plat_config->properties;
129+
if (plat_config->init) {
130+
ret = plat_config->init(dwc3g);
131+
if (ret)
132+
return dev_err_probe(dev, ret,
133+
"failed to init platform\n");
134+
}
135+
136+
core_probe:
86137
ret = dwc3_core_probe(&probe_data);
87138
if (ret)
88139
return dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
@@ -150,13 +201,19 @@ static const struct dev_pm_ops dwc3_generic_dev_pm_ops = {
150201
dwc3_generic_runtime_idle)
151202
};
152203

153-
static const struct dwc3_properties fsl_ls1028_dwc3 = {
154-
.gsbuscfg0_reqinfo = 0x2222,
204+
static const struct dwc3_generic_config fsl_ls1028_dwc3 = {
205+
.properties.gsbuscfg0_reqinfo = 0x2222,
206+
};
207+
208+
static const struct dwc3_generic_config eic7700_dwc3 = {
209+
.init = dwc3_eic7700_init,
210+
.properties = DWC3_DEFAULT_PROPERTIES,
155211
};
156212

157213
static const struct of_device_id dwc3_generic_of_match[] = {
158214
{ .compatible = "spacemit,k1-dwc3", },
159215
{ .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3},
216+
{ .compatible = "eswin,eic7700-dwc3", &eic7700_dwc3},
160217
{ /* sentinel */ }
161218
};
162219
MODULE_DEVICE_TABLE(of, dwc3_generic_of_match);

0 commit comments

Comments
 (0)