On Mon, Jan 13, 2025 at 09:11:41PM -0800, Bjorn Andersson wrote: > The DWC3 IP block is handled by three distinct device drivers: XHCI, > DWC3 core and a platform specific (optional) DWC3 glue driver. > > This has resulted in, at least in the case of the Qualcomm glue, the > presence of a number of layering violations, where the glue code either > can't handle, or has to work around, the fact that core might not probe > deterministically. > > An example of this is that the suspend path should operate slightly > different depending on the device operating in host or peripheral mode, > and the only way to determine the operating state is to peek into the > core's drvdata. > > The Qualcomm glue driver is expected to make updates in the qscratch > register region (the "glue" region) during role switch events, but with > the glue and core split using the driver model, there is no reasonable > way to introduce listeners for mode changes. > > Split the dwc3 core platform_driver callbacks and their implementation > and export the implementation, to make it possible to deterministically > instantiate the dwc3 core as part of the dwc3 glue drivers and to > allow flattening of the DeviceTree representation. > > Signed-off-by: Bjorn Andersson <bjorn.andersson@xxxxxxxxxxxxxxxx> > --- > drivers/usb/dwc3/core.c | 149 ++++++++++++++++++++++++++++++------------------ > drivers/usb/dwc3/glue.h | 22 +++++++ > 2 files changed, 117 insertions(+), 54 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index c22b8678e02e..930d812a9fbb 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -36,6 +36,7 @@ > > #include "core.h" > #include "gadget.h" > +#include "glue.h" > #include "io.h" > > #include "debug.h" > @@ -2129,27 +2130,14 @@ static int dwc3_get_num_ports(struct dwc3 *dwc) > return 0; > } > > -static int dwc3_probe(struct platform_device *pdev) > +int dwc3_init(struct dwc3 *dwc, struct resource *res) Maybe need data struct, which included res. It may need pass down more information in future. > { > - struct device *dev = &pdev->dev; > - struct resource *res, dwc_res; > + struct device *dev = dwc->dev; > + struct resource dwc_res; > unsigned int hw_mode; > void __iomem *regs; > - struct dwc3 *dwc; > int ret; > ... > +++ b/drivers/usb/dwc3/glue.h > @@ -0,0 +1,22 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * glue.h - DesignWare USB3 DRD glue header > + */ > + > +#ifndef __DRIVERS_USB_DWC3_GLUE_H > +#define __DRIVERS_USB_DWC3_GLUE_H > + > +#include <linux/types.h> > +#include "core.h" > + > +int dwc3_init(struct dwc3 *dwc, struct resource *res); > +void dwc3_uninit(struct dwc3 *dwc); > + > +int dwc3_runtime_suspend(struct dwc3 *dwc); > +int dwc3_runtime_resume(struct dwc3 *dwc); > +int dwc3_runtime_idle(struct dwc3 *dwc); > +int dwc3_suspend(struct dwc3 *dwc); > +int dwc3_resume(struct dwc3 *dwc); > +void dwc3_complete(struct dwc3 *dwc); dwc3_usb_*()? There may be name polution in future. There are many IPs created by dwc. Frank > + > +#endif > > -- > 2.45.2 >