* [PATCH 1/6] usb: cdns3: host: add .suspend_quirk for xhci-plat.c
@ 2020-10-22 1:39 Peter Chen
2020-10-22 1:39 ` [PATCH 2/6] usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT Peter Chen
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Peter Chen @ 2020-10-22 1:39 UTC (permalink / raw)
To: pawell, rogerq; +Cc: balbi, linux-usb, linux-imx, gregkh, jun.li, Peter Chen
cdns3 has some special PM sequence between xhci_bus_suspend and
xhci_suspend, add quirk to implement it.
Reviewed-by: Pawel Laszczak <pawell@cadence.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
drivers/usb/cdns3/host-export.h | 6 +++++
drivers/usb/cdns3/host.c | 43 +++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/drivers/usb/cdns3/host-export.h b/drivers/usb/cdns3/host-export.h
index ae11810f8826..26041718a086 100644
--- a/drivers/usb/cdns3/host-export.h
+++ b/drivers/usb/cdns3/host-export.h
@@ -9,9 +9,11 @@
#ifndef __LINUX_CDNS3_HOST_EXPORT
#define __LINUX_CDNS3_HOST_EXPORT
+struct usb_hcd;
#ifdef CONFIG_USB_CDNS3_HOST
int cdns3_host_init(struct cdns3 *cdns);
+int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd);
#else
@@ -21,6 +23,10 @@ static inline int cdns3_host_init(struct cdns3 *cdns)
}
static inline void cdns3_host_exit(struct cdns3 *cdns) { }
+static inline int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd)
+{
+ return 0;
+}
#endif /* CONFIG_USB_CDNS3_HOST */
diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c
index b3e2cb69762c..de8da737fa25 100644
--- a/drivers/usb/cdns3/host.c
+++ b/drivers/usb/cdns3/host.c
@@ -14,6 +14,18 @@
#include "drd.h"
#include "host-export.h"
#include <linux/usb/hcd.h>
+#include "../host/xhci.h"
+#include "../host/xhci-plat.h"
+
+#define XECP_PORT_CAP_REG 0x8000
+#define XECP_AUX_CTRL_REG1 0x8120
+
+#define CFG_RXDET_P3_EN BIT(15)
+#define LPM_2_STB_SWITCH_EN BIT(25)
+
+static const struct xhci_plat_priv xhci_plat_cdns3_xhci = {
+ .suspend_quirk = xhci_cdns3_suspend_quirk,
+};
static int __cdns3_host_init(struct cdns3 *cdns)
{
@@ -39,6 +51,11 @@ static int __cdns3_host_init(struct cdns3 *cdns)
goto err1;
}
+ ret = platform_device_add_data(xhci, &xhci_plat_cdns3_xhci,
+ sizeof(struct xhci_plat_priv));
+ if (ret)
+ goto err1;
+
ret = platform_device_add(xhci);
if (ret) {
dev_err(cdns->dev, "failed to register xHCI device\n");
@@ -56,6 +73,32 @@ static int __cdns3_host_init(struct cdns3 *cdns)
return ret;
}
+int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ u32 value;
+
+ if (pm_runtime_status_suspended(hcd->self.controller))
+ return 0;
+
+ /* set usbcmd.EU3S */
+ value = readl(&xhci->op_regs->command);
+ value |= CMD_PM_INDEX;
+ writel(value, &xhci->op_regs->command);
+
+ if (hcd->regs) {
+ value = readl(hcd->regs + XECP_AUX_CTRL_REG1);
+ value |= CFG_RXDET_P3_EN;
+ writel(value, hcd->regs + XECP_AUX_CTRL_REG1);
+
+ value = readl(hcd->regs + XECP_PORT_CAP_REG);
+ value |= LPM_2_STB_SWITCH_EN;
+ writel(value, hcd->regs + XECP_PORT_CAP_REG);
+ }
+
+ return 0;
+}
+
static void cdns3_host_exit(struct cdns3 *cdns)
{
platform_device_unregister(cdns->host_dev);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/6] usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT
2020-10-22 1:39 [PATCH 1/6] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Peter Chen
@ 2020-10-22 1:39 ` Peter Chen
2020-10-22 1:39 ` [PATCH 3/6] usb: cdns3: host: disable BEI support Peter Chen
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2020-10-22 1:39 UTC (permalink / raw)
To: pawell, rogerq; +Cc: balbi, linux-usb, linux-imx, gregkh, jun.li, Peter Chen
cdns3 manages PHY by own DRD driver, so skip the management by
HCD core.
Reviewed-by: Jun Li <jun.li@nxp.com>
Reviewed-by: Pawel Laszczak <pawell@cadence.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
drivers/usb/cdns3/host.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c
index de8da737fa25..f84739327a16 100644
--- a/drivers/usb/cdns3/host.c
+++ b/drivers/usb/cdns3/host.c
@@ -24,6 +24,7 @@
#define LPM_2_STB_SWITCH_EN BIT(25)
static const struct xhci_plat_priv xhci_plat_cdns3_xhci = {
+ .quirks = XHCI_SKIP_PHY_INIT,
.suspend_quirk = xhci_cdns3_suspend_quirk,
};
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/6] usb: cdns3: host: disable BEI support
2020-10-22 1:39 [PATCH 1/6] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Peter Chen
2020-10-22 1:39 ` [PATCH 2/6] usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT Peter Chen
@ 2020-10-22 1:39 ` Peter Chen
2020-10-22 1:39 ` [PATCH 4/6] usb: cdns3: add quirk for enable runtime pm by default Peter Chen
2020-10-22 1:39 ` [PATCH 5/6] usb: cdns3: imx: " Peter Chen
3 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2020-10-22 1:39 UTC (permalink / raw)
To: pawell, rogerq; +Cc: balbi, linux-usb, linux-imx, gregkh, jun.li, Peter Chen
The Cadence xHCI doesn't support BEI well, it causes the disconnection
of ISOC devices can't be detected, so we disable it.
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
drivers/usb/cdns3/host.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c
index f84739327a16..b273ae2231d5 100644
--- a/drivers/usb/cdns3/host.c
+++ b/drivers/usb/cdns3/host.c
@@ -24,7 +24,7 @@
#define LPM_2_STB_SWITCH_EN BIT(25)
static const struct xhci_plat_priv xhci_plat_cdns3_xhci = {
- .quirks = XHCI_SKIP_PHY_INIT,
+ .quirks = XHCI_SKIP_PHY_INIT | XHCI_AVOID_BEI,
.suspend_quirk = xhci_cdns3_suspend_quirk,
};
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/6] usb: cdns3: add quirk for enable runtime pm by default
2020-10-22 1:39 [PATCH 1/6] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Peter Chen
2020-10-22 1:39 ` [PATCH 2/6] usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT Peter Chen
2020-10-22 1:39 ` [PATCH 3/6] usb: cdns3: host: disable BEI support Peter Chen
@ 2020-10-22 1:39 ` Peter Chen
2020-10-22 1:39 ` [PATCH 5/6] usb: cdns3: imx: " Peter Chen
3 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2020-10-22 1:39 UTC (permalink / raw)
To: pawell, rogerq; +Cc: balbi, linux-usb, linux-imx, gregkh, jun.li, Peter Chen
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>
---
drivers/usb/cdns3/core.c | 3 ++-
drivers/usb/cdns3/core.h | 4 ++++
drivers/usb/cdns3/host.c | 20 +++++++++++++++++---
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index f2dedce3a40e..54d841aa626f 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -559,7 +559,8 @@ static int cdns3_probe(struct platform_device *pdev)
device_set_wakeup_capable(dev, true);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
- pm_runtime_forbid(dev);
+ if (!(cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW))
+ pm_runtime_forbid(dev);
/*
* The controller needs less time between bus and controller suspend,
diff --git a/drivers/usb/cdns3/core.h b/drivers/usb/cdns3/core.h
index 8a40d53d5ede..3176f924293a 100644
--- a/drivers/usb/cdns3/core.h
+++ b/drivers/usb/cdns3/core.h
@@ -42,6 +42,8 @@ struct cdns3_role_driver {
struct cdns3_platform_data {
int (*platform_suspend)(struct device *dev,
bool suspend, bool wakeup);
+ unsigned long quirks;
+#define CDNS3_DEFAULT_PM_RUNTIME_ALLOW BIT(0)
};
/**
@@ -73,6 +75,7 @@ struct cdns3_platform_data {
* @wakeup_pending: wakeup interrupt pending
* @pdata: platform data from glue layer
* @lock: spinlock structure
+ * @xhci_plat_data: xhci private data structure pointer
*/
struct cdns3 {
struct device *dev;
@@ -106,6 +109,7 @@ struct cdns3 {
bool wakeup_pending;
struct cdns3_platform_data *pdata;
spinlock_t lock;
+ struct xhci_plat_priv *xhci_plat_data;
};
int cdns3_hw_role_switch(struct cdns3 *cdns);
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);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5/6] usb: cdns3: imx: enable runtime pm by default
2020-10-22 1:39 [PATCH 1/6] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Peter Chen
` (2 preceding siblings ...)
2020-10-22 1:39 ` [PATCH 4/6] usb: cdns3: add quirk for enable runtime pm by default Peter Chen
@ 2020-10-22 1:39 ` Peter Chen
3 siblings, 0 replies; 5+ messages in thread
From: Peter Chen @ 2020-10-22 1:39 UTC (permalink / raw)
To: pawell, rogerq; +Cc: balbi, linux-usb, linux-imx, gregkh, jun.li, Peter Chen
Enable runtime pm by default
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
drivers/usb/cdns3/cdns3-imx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/cdns3/cdns3-imx.c b/drivers/usb/cdns3/cdns3-imx.c
index 54a2d70a9c73..22a56c4dce67 100644
--- a/drivers/usb/cdns3/cdns3-imx.c
+++ b/drivers/usb/cdns3/cdns3-imx.c
@@ -151,6 +151,7 @@ static int cdns_imx_platform_suspend(struct device *dev,
bool suspend, bool wakeup);
static struct cdns3_platform_data cdns_imx_pdata = {
.platform_suspend = cdns_imx_platform_suspend,
+ .quirks = CDNS3_DEFAULT_PM_RUNTIME_ALLOW,
};
static const struct of_dev_auxdata cdns_imx_auxdata[] = {
@@ -206,7 +207,6 @@ static int cdns_imx_probe(struct platform_device *pdev)
device_set_wakeup_capable(dev, true);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
- pm_runtime_forbid(dev);
return ret;
err:
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-10-22 1:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22 1:39 [PATCH 1/6] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Peter Chen
2020-10-22 1:39 ` [PATCH 2/6] usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT Peter Chen
2020-10-22 1:39 ` [PATCH 3/6] usb: cdns3: host: disable BEI support Peter Chen
2020-10-22 1:39 ` [PATCH 4/6] usb: cdns3: add quirk for enable runtime pm by default Peter Chen
2020-10-22 1:39 ` [PATCH 5/6] usb: cdns3: imx: " Peter Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).