Hi, On 6/11/2020 7:58 PM, Sandeep Maheswaram wrote: > Avoiding phy powerdown in host mode so that it can be wake up by devices. > Set usb controller wakeup capable when wakeup capable devices are > connected to the host. > > Signed-off-by: Sandeep Maheswaram <sanm@xxxxxxxxxxxxxx> > --- > drivers/usb/dwc3/core.c | 47 ++++++++++++++++++++++++++----- > drivers/usb/dwc3/core.h | 1 + > drivers/usb/dwc3/dwc3-qcom.c | 66 +++++++++++++++++++++++++++++++++----------- > 3 files changed, 91 insertions(+), 23 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 25c686a7..8370350 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -31,15 +31,19 @@ > #include <linux/usb/gadget.h> > #include <linux/usb/of.h> > #include <linux/usb/otg.h> > +#include <linux/usb/hcd.h> > > #include "core.h" > #include "gadget.h" > #include "io.h" > > #include "debug.h" > +#include "../host/xhci.h" > > #define DWC3_DEFAULT_AUTOSUSPEND_DELAY 5000 /* ms */ > > +bool need_phy_for_wakeup; > + > /** > * dwc3_get_dr_mode - Validates and sets dr_mode > * @dwc: pointer to our context structure > @@ -1627,10 +1631,36 @@ static int dwc3_core_init_for_resume(struct dwc3 *dwc) > return ret; > } > > +static void dwc3_set_phy_speed_flags(struct dwc3 *dwc) > +{ > + > + int i, num_ports; > + u32 reg; > + struct usb_hcd *hcd = platform_get_drvdata(dwc->xhci); dwc->xhci could be NULL for DR_MODE = PERIPHERAL. > + struct xhci_hcd *xhci_hcd = hcd_to_xhci(hcd); > + > + dwc->hs_phy_flags &= ~(PHY_MODE_USB_HOST_HS | PHY_MODE_USB_HOST_LS); > + > + reg = readl(&xhci_hcd->cap_regs->hcs_params1); > + > + num_ports = HCS_MAX_PORTS(reg); > + for (i = 0; i < num_ports; i++) { > + reg = readl(&xhci_hcd->op_regs->port_status_base + i*0x10); > + if (reg & PORT_PE) { > + if (DEV_HIGHSPEED(reg) || DEV_FULLSPEED(reg)) > + dwc->hs_phy_flags |= PHY_MODE_USB_HOST_HS; > + else if (DEV_LOWSPEED(reg)) > + dwc->hs_phy_flags |= PHY_MODE_USB_HOST_LS; > + } > + } > + phy_set_mode(dwc->usb2_generic_phy, dwc->hs_phy_flags); Can we move this logic to xhci driver instead? > +} > + .. > @@ -240,6 +267,11 @@ 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); dwc->xhci could be NULL > + > + if (usb_wakeup_enabled_descendants(hcd->self.root_hub)) > + device_init_wakeup(qcom->dev, 1); > > if (qcom->is_suspended) > return 0; > @@ -262,6 +294,8 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom) > int ret; > int i; > > + device_init_wakeup(qcom->dev, 0); > + > if (!qcom->is_suspended) > return 0; > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project