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.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
---
drivers/usb/dwc3/core.c | 19 +++++++++++--------
drivers/usb/dwc3/glue.h | 1 +
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index d9f0a6782d36..aecdde8dc999 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -2187,15 +2187,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)
@@ -2328,6 +2330,7 @@ static int dwc3_probe(struct platform_device *pdev)
probe_data.dwc = dwc;
probe_data.res = res;
+ probe_data.ignore_clocks_and_resets = false;
return dwc3_core_probe(&probe_data);
}
diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
index e73cfc466012..1ddb451bdbd0 100644
--- a/drivers/usb/dwc3/glue.h
+++ b/drivers/usb/dwc3/glue.h
@@ -17,6 +17,7 @@
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);
--
2.45.2
On Wed, Feb 26, 2025 at 04:17:50PM -0800, Bjorn Andersson wrote:
> 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.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/core.c | 19 +++++++++++--------
> drivers/usb/dwc3/glue.h | 1 +
> 2 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index d9f0a6782d36..aecdde8dc999 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -2187,15 +2187,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)
> @@ -2328,6 +2330,7 @@ static int dwc3_probe(struct platform_device *pdev)
>
> probe_data.dwc = dwc;
> probe_data.res = res;
> + probe_data.ignore_clocks_and_resets = false;
>
> return dwc3_core_probe(&probe_data);
> }
> diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
> index e73cfc466012..1ddb451bdbd0 100644
> --- a/drivers/usb/dwc3/glue.h
> +++ b/drivers/usb/dwc3/glue.h
> @@ -17,6 +17,7 @@
> struct dwc3_probe_data {
> struct dwc3 *dwc;
> struct resource *res;
> + bool ignore_clocks_and_resets;
Nit: suggest add kernel doc comments for each fields
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> };
>
> int dwc3_core_probe(const struct dwc3_probe_data *data);
>
> --
> 2.45.2
>
On Wed, Feb 26, 2025 at 04:17:50PM -0800, Bjorn Andersson wrote:
> 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.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/core.c | 19 +++++++++++--------
> drivers/usb/dwc3/glue.h | 1 +
> 2 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index d9f0a6782d36..aecdde8dc999 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -2328,6 +2330,7 @@ static int dwc3_probe(struct platform_device *pdev)
>
> probe_data.dwc = dwc;
> probe_data.res = res;
> + probe_data.ignore_clocks_and_resets = false;
Isn't it a default value?
>
> return dwc3_core_probe(&probe_data);
> }
> diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
> index e73cfc466012..1ddb451bdbd0 100644
> --- a/drivers/usb/dwc3/glue.h
> +++ b/drivers/usb/dwc3/glue.h
> @@ -17,6 +17,7 @@
> 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);
>
> --
> 2.45.2
>
--
With best wishes
Dmitry
On Thu, Feb 27, 2025 at 06:24:17AM +0200, Dmitry Baryshkov wrote:
> On Wed, Feb 26, 2025 at 04:17:50PM -0800, Bjorn Andersson wrote:
> > 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.
> >
> > Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
> > ---
> > drivers/usb/dwc3/core.c | 19 +++++++++++--------
> > drivers/usb/dwc3/glue.h | 1 +
> > 2 files changed, 12 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > index d9f0a6782d36..aecdde8dc999 100644
> > --- a/drivers/usb/dwc3/core.c
> > +++ b/drivers/usb/dwc3/core.c
> > @@ -2328,6 +2330,7 @@ static int dwc3_probe(struct platform_device *pdev)
> >
> > probe_data.dwc = dwc;
> > probe_data.res = res;
> > + probe_data.ignore_clocks_and_resets = false;
>
> Isn't it a default value?
>
I like the false because it's explicit, but I have no strong attachment
to it.
That said, it's not the default value, because probe_data isn't
zero-initialized. That would however make sense to do, in order to avoid
surprises in the future when probe_data grows.
Regards,
Bjorn
> >
> > return dwc3_core_probe(&probe_data);
> > }
> > diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
> > index e73cfc466012..1ddb451bdbd0 100644
> > --- a/drivers/usb/dwc3/glue.h
> > +++ b/drivers/usb/dwc3/glue.h
> > @@ -17,6 +17,7 @@
> > 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);
> >
> > --
> > 2.45.2
> >
>
> --
> With best wishes
> Dmitry
On Thu, Feb 27, 2025 at 09:55:29AM -0600, Bjorn Andersson wrote:
> On Thu, Feb 27, 2025 at 06:24:17AM +0200, Dmitry Baryshkov wrote:
> > On Wed, Feb 26, 2025 at 04:17:50PM -0800, Bjorn Andersson wrote:
> > > 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.
> > >
> > > Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
> > > ---
> > > drivers/usb/dwc3/core.c | 19 +++++++++++--------
> > > drivers/usb/dwc3/glue.h | 1 +
> > > 2 files changed, 12 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > > index d9f0a6782d36..aecdde8dc999 100644
> > > --- a/drivers/usb/dwc3/core.c
> > > +++ b/drivers/usb/dwc3/core.c
> > > @@ -2328,6 +2330,7 @@ static int dwc3_probe(struct platform_device *pdev)
> > >
> > > probe_data.dwc = dwc;
> > > probe_data.res = res;
> > > + probe_data.ignore_clocks_and_resets = false;
> >
> > Isn't it a default value?
> >
>
> I like the false because it's explicit, but I have no strong attachment
> to it.
I'm more biased to the 'make unusal cases stand out', which means the
defaults can go away to highlight non-default cases.
>
> That said, it's not the default value, because probe_data isn't
> zero-initialized. That would however make sense to do, in order to avoid
> surprises in the future when probe_data grows.
:-)
>
> Regards,
> Bjorn
>
> > >
> > > return dwc3_core_probe(&probe_data);
> > > }
> > > diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
> > > index e73cfc466012..1ddb451bdbd0 100644
> > > --- a/drivers/usb/dwc3/glue.h
> > > +++ b/drivers/usb/dwc3/glue.h
> > > @@ -17,6 +17,7 @@
> > > 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);
> > >
> > > --
> > > 2.45.2
> > >
> >
> > --
> > With best wishes
> > Dmitry
--
With best wishes
Dmitry
© 2016 - 2026 Red Hat, Inc.