usb: dwc3: core: Don't touch resets and clocks
authorBjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Tue, 15 Apr 2025 01:21:53 +0000 (20:21 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Apr 2025 12:29:19 +0000 (14:29 +0200)
When the core is integrated with glue, it's reasonable to assume that
the glue driver will have to touch the IP before/after the core takes
the hardware out and into reset. As such the glue must own these
resources and be allowed to turn them on/off outside the core's
handling.

Allow the platform or glue layer to indicate if the core logic for
clocks and resets should be skipped to deal with this.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-QRD
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250414-dwc3-refactor-v7-4-f015b358722d@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/core.c
drivers/usb/dwc3/glue.h

index 81324d586c0797a551b188685d7da2a504484e57..2bc775a747f200f6a7e5b7ba2771a9640dac5e98 100644 (file)
@@ -2211,15 +2211,17 @@ int dwc3_core_probe(const struct dwc3_probe_data *data)
        if (IS_ERR(dwc->usb_psy))
                return dev_err_probe(dev, PTR_ERR(dwc->usb_psy), "couldn't get usb power supply\n");
 
-       dwc->reset = devm_reset_control_array_get_optional_shared(dev);
-       if (IS_ERR(dwc->reset)) {
-               ret = PTR_ERR(dwc->reset);
-               goto err_put_psy;
-       }
+       if (!data->ignore_clocks_and_resets) {
+               dwc->reset = devm_reset_control_array_get_optional_shared(dev);
+               if (IS_ERR(dwc->reset)) {
+                       ret = PTR_ERR(dwc->reset);
+                       goto err_put_psy;
+               }
 
-       ret = dwc3_get_clocks(dwc);
-       if (ret)
-               goto err_put_psy;
+               ret = dwc3_get_clocks(dwc);
+               if (ret)
+                       goto err_put_psy;
+       }
 
        ret = reset_control_deassert(dwc->reset);
        if (ret)
@@ -2334,7 +2336,7 @@ EXPORT_SYMBOL_GPL(dwc3_core_probe);
 
 static int dwc3_probe(struct platform_device *pdev)
 {
-       struct dwc3_probe_data probe_data;
+       struct dwc3_probe_data probe_data = {};
        struct resource *res;
        struct dwc3 *dwc;
 
index bc446f92ec8b1b6feeb84ab2138516103833b259..2efd00e763be4fc51911f32d43054059e61fb43a 100644 (file)
  * dwc3_probe_data: Initialization parameters passed to dwc3_core_probe()
  * @dwc: Reference to dwc3 context structure
  * @res: resource for the DWC3 core mmio region
+ * @ignore_clocks_and_resets: clocks and resets defined for the device should
+ *             be ignored by the DWC3 core, as they are managed by the glue
  */
 struct dwc3_probe_data {
        struct dwc3 *dwc;
        struct resource *res;
+       bool ignore_clocks_and_resets;
 };
 
 int dwc3_core_probe(const struct dwc3_probe_data *data);