Hi Sandeep, On Thu, Jul 09, 2020 at 12:40:16AM +0530, Sandeep Maheswaram wrote: > configure interrupts based on hs_phy_flag. Set genpd active wakeup flag > for usb gdsc if wakeup capable devices are connected. as Stephen remarked, please describe why this patch is doing what it is doing. > Signed-off-by: Sandeep Maheswaram <sanm@xxxxxxxxxxxxxx> > --- > drivers/usb/dwc3/dwc3-qcom.c | 73 ++++++++++++++++++++++++++++++++++---------- > 1 file changed, 57 insertions(+), 16 deletions(-) > > diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c > index 1dfd024..8902670 100644 > --- a/drivers/usb/dwc3/dwc3-qcom.c > +++ b/drivers/usb/dwc3/dwc3-qcom.c > @@ -16,9 +16,11 @@ > #include <linux/of_platform.h> > #include <linux/platform_device.h> > #include <linux/phy/phy.h> > +#include <linux/pm_domain.h> > #include <linux/usb/of.h> > #include <linux/reset.h> > #include <linux/iopoll.h> > +#include <linux/usb/hcd.h> > > #include "core.h" > > @@ -192,21 +194,34 @@ static int dwc3_qcom_register_extcon(struct dwc3_qcom *qcom) > > static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) > { > + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); > + > if (qcom->hs_phy_irq) { > disable_irq_wake(qcom->hs_phy_irq); > disable_irq_nosync(qcom->hs_phy_irq); > } nit: add empty line > + if (dwc->hs_phy_flags & PHY_MODE_USB_HOST_LS) { > + if (qcom->dp_hs_phy_irq) { > + disable_irq_wake(qcom->dp_hs_phy_irq); > + disable_irq_nosync(qcom->dp_hs_phy_irq); > + } > + } else if (dwc->hs_phy_flags & PHY_MODE_USB_HOST_HS) { > + if (qcom->dm_hs_phy_irq) { > + disable_irq_wake(qcom->dm_hs_phy_irq); > + disable_irq_nosync(qcom->dm_hs_phy_irq); > + } > + } else { > delete empty line > - if (qcom->dp_hs_phy_irq) { > - disable_irq_wake(qcom->dp_hs_phy_irq); > - disable_irq_nosync(qcom->dp_hs_phy_irq); > - } > + if (qcom->dp_hs_phy_irq) { > + disable_irq_wake(qcom->dp_hs_phy_irq); > + disable_irq_nosync(qcom->dp_hs_phy_irq); > + } > > - if (qcom->dm_hs_phy_irq) { > - disable_irq_wake(qcom->dm_hs_phy_irq); > - disable_irq_nosync(qcom->dm_hs_phy_irq); > + if (qcom->dm_hs_phy_irq) { > + disable_irq_wake(qcom->dm_hs_phy_irq); > + disable_irq_nosync(qcom->dm_hs_phy_irq); > + } > } > - > if (qcom->ss_phy_irq) { > disable_irq_wake(qcom->ss_phy_irq); > disable_irq_nosync(qcom->ss_phy_irq); > @@ -215,21 +230,34 @@ static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) > > static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) > { > + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); > + > if (qcom->hs_phy_irq) { > enable_irq(qcom->hs_phy_irq); > enable_irq_wake(qcom->hs_phy_irq); > } nit: add empty line > + if (dwc->hs_phy_flags & PHY_MODE_USB_HOST_LS) { > + if (qcom->dp_hs_phy_irq) { > + enable_irq(qcom->dp_hs_phy_irq); > + enable_irq_wake(qcom->dp_hs_phy_irq); > + } > + } else if (dwc->hs_phy_flags & PHY_MODE_USB_HOST_HS) { > + if (qcom->dm_hs_phy_irq) { > + enable_irq(qcom->dm_hs_phy_irq); > + enable_irq_wake(qcom->dm_hs_phy_irq); > + } > + } else { > delete empty line > - if (qcom->dp_hs_phy_irq) { > - enable_irq(qcom->dp_hs_phy_irq); > - enable_irq_wake(qcom->dp_hs_phy_irq); > - } > + if (qcom->dp_hs_phy_irq) { > + enable_irq(qcom->dp_hs_phy_irq); > + enable_irq_wake(qcom->dp_hs_phy_irq); > + } > > - if (qcom->dm_hs_phy_irq) { > - enable_irq(qcom->dm_hs_phy_irq); > - enable_irq_wake(qcom->dm_hs_phy_irq); > + if (qcom->dm_hs_phy_irq) { > + enable_irq(qcom->dm_hs_phy_irq); > + enable_irq_wake(qcom->dm_hs_phy_irq); > + } > } > - > if (qcom->ss_phy_irq) { > enable_irq(qcom->ss_phy_irq); > enable_irq_wake(qcom->ss_phy_irq); > @@ -240,6 +268,14 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom) > { > u32 val; > int i; > + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); > + struct usb_hcd *hcd = platform_get_drvdata(dwc->xhci); > + struct generic_pm_domain *genpd; > + > + genpd = pd_to_genpd(qcom->dev->pm_domain); nit: assign in declaration? > + > + if (genpd && usb_wakeup_enabled_descendants(hcd->self.root_hub)) > + genpd->flags |= GENPD_FLAG_ACTIVE_WAKEUP; > > if (qcom->is_suspended) > return 0; > @@ -261,6 +297,11 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom) > { > int ret; > int i; > + struct generic_pm_domain *genpd; > + > + genpd = pd_to_genpd(qcom->dev->pm_domain); > + if (genpd) > + genpd->flags &= !GENPD_FLAG_ACTIVE_WAKEUP; ~GENPD_FLAG_ACTIVE_WAKEUP; ?