* [PATCH v2 3/3] usb: dwc3: Allow glue drivers to override all dwc3_properties
2026-12-04 17:52 [PATCH v2 0/3] usb: dwc3: Let glue drivers override all dwc3 properties Thinh Nguyen
@ 2026-12-04 17:53 ` Thinh Nguyen
0 siblings, 0 replies; 2+ messages in thread
From: Thinh Nguyen @ 2026-12-04 17:53 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,
Krishna Kurapati, André Draszik, Pengutronix Kernel Team,
Neal Gompa, Xu Yang, 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, ls1028a and qcom to the hook.
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Tested-by: Xu Yang <xu.yang_2@nxp.com> # dwc3-imx.c
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Acked-by: Sven Peter <sven@kernel.org>
Tested-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
Reviewed-by: André Draszik <andre.draszik@linaro.org>
---
Changes in v2:
- Convert dwc3-qcom skip_phy_init to the fixup_properties() hook
- Collect tags
drivers/usb/dwc3/core.c | 21 +++++----------------
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 | 9 +++++++--
drivers/usb/dwc3/glue.h | 10 ++++------
7 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 8901ca3a6d19..45f1d1737fd4 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1715,27 +1715,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;
-
- if (properties->skip_phy_init)
- dwc->skip_phy_init = 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.
@@ -2344,7 +2331,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;
@@ -2505,7 +2495,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 035aeeb05dd8..cfb1f6be0583 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 ad0906582505..9c7762be3899 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 850e377aaab6..d9f7bfcdc0cd 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -687,6 +687,12 @@ static struct dwc3_glue_ops dwc3_qcom_glue_ops = {
.pre_run_stop = dwc3_qcom_run_stop_notifier,
};
+static void dwc3_qcom_fixup_properties(struct dwc3 *dwc,
+ struct dwc3_properties *props)
+{
+ props->skip_phy_init = true;
+}
+
static int dwc3_qcom_probe(struct platform_device *pdev)
{
struct dwc3_probe_data probe_data = {};
@@ -796,8 +802,7 @@ 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;
- probe_data.properties.skip_phy_init = true;
+ probe_data.fixup_properties = dwc3_qcom_fixup_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