* [PATCH 3/3] usb: dwc3: Allow glue drivers to override all dwc3_properties
2026-11-24 22:59 [PATCH 0/3] usb: dwc3: Let glue drivers override all dwc3 properties Thinh Nguyen
@ 2026-11-24 22:59 ` Thinh Nguyen
0 siblings, 0 replies; 2+ messages in thread
From: Thinh Nguyen @ 2026-11-24 22:59 UTC (permalink / raw)
To: Greg Kroah-Hartman, Thinh Nguyen, Frank Li, Sven Peter,
Janne Grunau, Peter Griffin, Sascha Hauer
Cc: Tejas Narendra Joglekar, linux-usb@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
Tudor Ambarus, linux-arm-kernel@lists.infradead.org,
André Draszik, Pengutronix Kernel Team, Neal Gompa,
asahi@lists.linux.dev, imx@lists.linux.dev, Fabio Estevam
struct dwc3_properties holds all glue-overridable properties, but glue
drivers can only set needs_full_reinit and gsbuscfg0_reqinfo.
Replace the properties value in struct dwc3_probe_data with a
fixup_properties() hook. The core calls it after reading the DT
properties, so glue drivers can set properties that DT does not
provide, or override DT values, including clearing them, to correct
broken SoC settings. Convert imx and ls1028a to the hook.
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
drivers/usb/dwc3/core.c | 18 +++++-------------
drivers/usb/dwc3/dwc3-apple.c | 1 -
drivers/usb/dwc3/dwc3-generic-plat.c | 19 +++++++++++--------
drivers/usb/dwc3/dwc3-google.c | 1 -
drivers/usb/dwc3/dwc3-imx.c | 9 +++++++--
drivers/usb/dwc3/dwc3-qcom.c | 1 -
drivers/usb/dwc3/glue.h | 10 ++++------
7 files changed, 27 insertions(+), 32 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 3b2b5fcc627a..369c9ce9f1dc 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1684,24 +1684,14 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE, true);
}
-static void dwc3_get_software_properties(struct dwc3 *dwc,
- const struct dwc3_properties *properties)
+static void dwc3_get_software_properties(struct dwc3 *dwc)
{
struct device *tmpdev;
u16 gsbuscfg0_reqinfo;
int ret;
- if (properties->needs_full_reinit)
- dwc->needs_full_reinit = true;
-
dwc->gsbuscfg0_reqinfo = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED;
- if (properties->gsbuscfg0_reqinfo !=
- DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED) {
- dwc->gsbuscfg0_reqinfo = properties->gsbuscfg0_reqinfo;
- return;
- }
-
/*
* Iterate over all parent nodes for finding swnode properties
* and non-DT (non-ABI) properties.
@@ -2310,7 +2300,10 @@ int dwc3_core_probe(const struct dwc3_probe_data *data)
dwc->regs_size = resource_size(&dwc_res);
dwc3_get_properties(dwc);
- dwc3_get_software_properties(dwc, &data->properties);
+ dwc3_get_software_properties(dwc);
+
+ if (data->fixup_properties)
+ data->fixup_properties(dwc, &dwc->properties);
if (dwc->sysdev_is_parent)
dwc->sysdev = dwc->dev->parent;
@@ -2470,7 +2463,6 @@ static int dwc3_probe(struct platform_device *pdev)
probe_data.dwc = dwc;
probe_data.res = res;
- probe_data.properties = DWC3_DEFAULT_PROPERTIES;
return dwc3_core_probe(&probe_data);
}
diff --git a/drivers/usb/dwc3/dwc3-apple.c b/drivers/usb/dwc3/dwc3-apple.c
index 1f474a8bc59e..8289d22e5994 100644
--- a/drivers/usb/dwc3/dwc3-apple.c
+++ b/drivers/usb/dwc3/dwc3-apple.c
@@ -181,7 +181,6 @@ static int dwc3_apple_core_probe(struct dwc3_apple *appledwc)
probe_data.res = appledwc->mmio_resource;
probe_data.ignore_clocks_and_resets = true;
probe_data.skip_core_init_mode = true;
- probe_data.properties = DWC3_DEFAULT_PROPERTIES;
ret = dwc3_core_probe(&probe_data);
if (ret)
diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
index 3e90ddf25809..69a6acd84a0f 100644
--- a/drivers/usb/dwc3/dwc3-generic-plat.c
+++ b/drivers/usb/dwc3/dwc3-generic-plat.c
@@ -33,7 +33,8 @@ struct dwc3_generic {
struct dwc3_generic_config {
int (*init)(struct dwc3_generic *dwc3g);
- struct dwc3_properties properties;
+ void (*fixup_properties)(struct dwc3 *dwc,
+ struct dwc3_properties *props);
};
#define to_dwc3_generic(d) container_of((d), struct dwc3_generic, dwc)
@@ -137,12 +138,10 @@ static int dwc3_generic_probe(struct platform_device *pdev)
probe_data.ignore_clocks_and_resets = true;
plat_config = of_device_get_match_data(dev);
- if (!plat_config) {
- probe_data.properties = DWC3_DEFAULT_PROPERTIES;
+ if (!plat_config)
goto core_probe;
- }
- probe_data.properties = plat_config->properties;
+ probe_data.fixup_properties = plat_config->fixup_properties;
if (plat_config->init) {
ret = plat_config->init(dwc3g);
if (ret)
@@ -220,16 +219,20 @@ static const struct dev_pm_ops dwc3_generic_dev_pm_ops = {
static const struct dwc3_generic_config spacemit_k1_dwc3 = {
.init = dwc3_spacemit_k1_init,
- .properties = DWC3_DEFAULT_PROPERTIES,
};
+static void dwc3_ls1028a_fixup_properties(struct dwc3 *dwc,
+ struct dwc3_properties *props)
+{
+ props->gsbuscfg0_reqinfo = 0x2222;
+}
+
static const struct dwc3_generic_config fsl_ls1028_dwc3 = {
- .properties.gsbuscfg0_reqinfo = 0x2222,
+ .fixup_properties = dwc3_ls1028a_fixup_properties,
};
static const struct dwc3_generic_config eic7700_dwc3 = {
.init = dwc3_eic7700_init,
- .properties = DWC3_DEFAULT_PROPERTIES,
};
static const struct of_device_id dwc3_generic_of_match[] = {
diff --git a/drivers/usb/dwc3/dwc3-google.c b/drivers/usb/dwc3/dwc3-google.c
index 67eda7f0d528..213c03048aa0 100644
--- a/drivers/usb/dwc3/dwc3-google.c
+++ b/drivers/usb/dwc3/dwc3-google.c
@@ -440,7 +440,6 @@ static int dwc3_google_probe(struct platform_device *pdev)
probe_data.dwc = &google->dwc;
probe_data.res = res;
probe_data.ignore_clocks_and_resets = true;
- probe_data.properties = DWC3_DEFAULT_PROPERTIES;
ret = dwc3_core_probe(&probe_data);
if (ret) {
ret = dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
diff --git a/drivers/usb/dwc3/dwc3-imx.c b/drivers/usb/dwc3/dwc3-imx.c
index 64da121a8f76..396d76311120 100644
--- a/drivers/usb/dwc3/dwc3-imx.c
+++ b/drivers/usb/dwc3/dwc3-imx.c
@@ -192,6 +192,12 @@ static const struct software_node dwc3_imx_swnode = {
.properties = dwc3_imx_properties,
};
+static void dwc3_imx_fixup_properties(struct dwc3 *dwc,
+ struct dwc3_properties *props)
+{
+ props->needs_full_reinit = true;
+}
+
static int dwc3_imx_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -265,8 +271,7 @@ static int dwc3_imx_probe(struct platform_device *pdev)
probe_data.res = res;
probe_data.dwc = dwc;
- probe_data.properties = DWC3_DEFAULT_PROPERTIES;
- probe_data.properties.needs_full_reinit = true;
+ probe_data.fixup_properties = dwc3_imx_fixup_properties;
ret = dwc3_core_probe(&probe_data);
if (ret) {
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 5a68025ccea5..ef38308023aa 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -745,7 +745,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
probe_data.dwc = &qcom->dwc;
probe_data.res = &res;
probe_data.ignore_clocks_and_resets = true;
- probe_data.properties = DWC3_DEFAULT_PROPERTIES;
ret = dwc3_core_probe(&probe_data);
if (ret) {
ret = dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
index b7ce196e84ea..e56fee68e4bc 100644
--- a/drivers/usb/dwc3/glue.h
+++ b/drivers/usb/dwc3/glue.h
@@ -9,10 +9,6 @@
#include <linux/types.h>
#include "core.h"
-#define DWC3_DEFAULT_PROPERTIES ((struct dwc3_properties){ \
- .gsbuscfg0_reqinfo = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED, \
- })
-
/**
* dwc3_probe_data: Initialization parameters passed to dwc3_core_probe()
* @dwc: Reference to dwc3 context structure
@@ -21,14 +17,16 @@
* be ignored by the DWC3 core, as they are managed by the glue
* @skip_core_init_mode: Skip the final initialization of the target mode, as
* it must be managed by the glue
- * @properties: dwc3 software manage properties
+ * @fixup_properties: optional hook to set or override properties after
+ * the core reads them from DT
*/
struct dwc3_probe_data {
struct dwc3 *dwc;
struct resource *res;
bool ignore_clocks_and_resets;
bool skip_core_init_mode;
- struct dwc3_properties properties;
+ void (*fixup_properties)(struct dwc3 *dwc,
+ struct dwc3_properties *props);
};
/**
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread