Skip to content

Commit

Permalink
usb: xhci-plat: Add remote wakeup support for xilinx
Browse files Browse the repository at this point in the history
This patch adds support for enabling remote wakeup capability
to the host controller. If the device has wakeup capability,
then sets the wakeup flag and enable wakeup irq.

Added function registration and deregistration functionality,
to inform the dwc3 driver about the device wakeup capability.
This patch creates an interface between platform and dwc3-host.

Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
State: pending
  • Loading branch information
Piyush Mehta authored and Michal Simek committed Sep 22, 2021
1 parent e2af427 commit 4926040
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions drivers/usb/host/xhci-plat.c
Expand Up @@ -31,6 +31,8 @@ static struct hc_driver __read_mostly xhci_plat_hc_driver;
static int xhci_plat_setup(struct usb_hcd *hcd);
static int xhci_plat_start(struct usb_hcd *hcd);

static host_wakeup_t host_wakeup_fn;

static const struct xhci_driver_overrides xhci_plat_overrides __initconst = {
.extra_priv_size = sizeof(struct xhci_plat_priv),
.reset = xhci_plat_setup,
Expand Down Expand Up @@ -87,6 +89,17 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
xhci->quirks |= XHCI_PLAT | priv->quirks;
}

static void host_wakeup_register(host_wakeup_t func)
{
host_wakeup_fn = func;
}

static void host_wakeup_capable(struct device *dev, bool wakeup)
{
if (host_wakeup_fn)
host_wakeup_fn(dev, wakeup);
}

/* called during probe() after chip reset completes */
static int xhci_plat_setup(struct usb_hcd *hcd)
{
Expand Down Expand Up @@ -321,6 +334,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
}

device_set_wakeup_capable(&pdev->dev, true);
host_wakeup_register(dwc3_host_wakeup_capable);

xhci->main_hcd = hcd;
xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
Expand Down Expand Up @@ -433,6 +447,7 @@ static int xhci_plat_remove(struct platform_device *dev)
xhci->shared_hcd = NULL;
usb_phy_shutdown(hcd->usb_phy);

host_wakeup_register(NULL);
usb_otg_set_host(&dev->dev, hcd, false);

usb_remove_hcd(hcd);
Expand All @@ -458,6 +473,15 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
ret = xhci_priv_suspend_quirk(hcd);
if (ret)
return ret;

/* Inform dwc3 driver about the device wakeup capability */
if (device_may_wakeup(&hcd->self.root_hub->dev)) {
host_wakeup_capable(dev, true);
enable_irq_wake(hcd->irq);
} else {
host_wakeup_capable(dev, false);
}

/*
* xhci_suspend() needs `do_wakeup` to know whether host is allowed
* to do wakeup during suspend.
Expand Down
2 changes: 2 additions & 0 deletions drivers/usb/host/xhci.h
Expand Up @@ -2063,6 +2063,8 @@ void xhci_free_container_ctx(struct xhci_hcd *xhci,

/* xHCI host controller glue */
typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
typedef void (*host_wakeup_t)(struct device *dev, bool wakeup);
void dwc3_host_wakeup_capable(struct device *dev, bool wakeup);
int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec);
void xhci_quiesce(struct xhci_hcd *xhci);
int xhci_halt(struct xhci_hcd *xhci);
Expand Down

0 comments on commit 4926040

Please sign in to comment.