summaryrefslogtreecommitdiff
path: root/drivers/usb/cdns3/host.c
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@nxp.com>2020-09-28 15:20:03 +0800
committerPeter Chen <peter.chen@nxp.com>2020-12-10 08:45:26 +0800
commit7cea9657756b2c83069a775c0671ff169bce456a (patch)
tree8c0368030230a7b210f9dd8561824509c212b426 /drivers/usb/cdns3/host.c
parent1cc6edd8a96fb3229d8309c49967713b5c79524f (diff)
usb: cdns3: add quirk for enable runtime pm by default
Some vendors (eg: NXP) may want to enable runtime pm by default for power saving, add one quirk for it. Reviewed-by: Jun Li <jun.li@nxp.com> Signed-off-by: Peter Chen <peter.chen@nxp.com>
Diffstat (limited to 'drivers/usb/cdns3/host.c')
-rw-r--r--drivers/usb/cdns3/host.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c
index b273ae2231d5..08103785a17a 100644
--- a/drivers/usb/cdns3/host.c
+++ b/drivers/usb/cdns3/host.c
@@ -52,15 +52,25 @@ static int __cdns3_host_init(struct cdns3 *cdns)
goto err1;
}
- ret = platform_device_add_data(xhci, &xhci_plat_cdns3_xhci,
+ cdns->xhci_plat_data = kmemdup(&xhci_plat_cdns3_xhci,
+ sizeof(struct xhci_plat_priv), GFP_KERNEL);
+ if (!cdns->xhci_plat_data) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ if (cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW)
+ cdns->xhci_plat_data->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
+
+ ret = platform_device_add_data(xhci, cdns->xhci_plat_data,
sizeof(struct xhci_plat_priv));
if (ret)
- goto err1;
+ goto free_memory;
ret = platform_device_add(xhci);
if (ret) {
dev_err(cdns->dev, "failed to register xHCI device\n");
- goto err1;
+ goto free_memory;
}
/* Glue needs to access xHCI region register for Power management */
@@ -69,6 +79,9 @@ static int __cdns3_host_init(struct cdns3 *cdns)
cdns->xhci_regs = hcd->regs;
return 0;
+
+free_memory:
+ kfree(cdns->xhci_plat_data);
err1:
platform_device_put(xhci);
return ret;
@@ -102,6 +115,7 @@ int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd)
static void cdns3_host_exit(struct cdns3 *cdns)
{
+ kfree(cdns->xhci_plat_data);
platform_device_unregister(cdns->host_dev);
cdns->host_dev = NULL;
cdns3_drd_host_off(cdns);