[PATCH]fsl/usb: Workarourd for USB erratum-A005697

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As per USB specification, in Suspend state the status bit does
not change until the port is suspended. However, there may be a delay
in suspending a port if there is a transaction currently in progress
on the bus.

In the USBDR controller, the PORTSCx[SUSP] bit changes immediately when
the application sets it and not when the port is actually suspended

Workaround for this issue involves waiting for a minimum of 10ms to
allow the controller to go into SUSPEND state before proceeding ahead

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@xxxxxxxxxxxxx>
---
 drivers/usb/host/ehci-fsl.c      |  2 ++
 drivers/usb/host/ehci-hub.c      |  2 ++
 drivers/usb/host/ehci.h          | 11 +++++++++
 drivers/usb/host/fsl-mph-dr-of.c | 52 ++++++++++++++++++++++++++++++++++++++++
 include/linux/fsl_devices.h      |  1 +
 5 files changed, 68 insertions(+)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 947b009..96e0b2b 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -306,6 +306,8 @@ static int ehci_fsl_usb_setup(struct ehci_hcd *ehci)
 		out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x80000000 | SNOOP_SIZE_2GB);
 	}
 
+	if (pdata->has_fsl_erratum_a005697 == 1)
+		ehci->has_fsl_susp_errata = 1;
 	if ((pdata->operating_mode == FSL_USB2_DR_HOST) ||
 			(pdata->operating_mode == FSL_USB2_DR_OTG))
 		if (ehci_fsl_setup_phy(hcd, pdata->phy_mode, 0))
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 835fc08..d9cb2c2 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -284,6 +284,8 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
 		else if ((t1 & PORT_PE) && !(t1 & PORT_SUSPEND)) {
 			t2 |= PORT_SUSPEND;
 			set_bit(port, &ehci->bus_suspended);
+			if (ehci_has_fsl_susp_errata(ehci))
+				usleep_range(10000, 20000);
 		}
 
 		/* enable remote wakeup on all ports, if told to do so */
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 291db7d..43f010c 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -193,6 +193,7 @@ struct ehci_hcd {			/* one per controller */
 	/* SILICON QUIRKS */
 	unsigned		no_selective_suspend:1;
 	unsigned		has_fsl_port_bug:1; /* FreeScale */
+	unsigned		has_fsl_susp_errata:1;	/*Freescale SUSP quirk*/
 	unsigned		big_endian_mmio:1;
 	unsigned		big_endian_desc:1;
 	unsigned		big_endian_capbase:1;
@@ -636,6 +637,16 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc)
 #define	ehci_has_fsl_portno_bug(e)		(0)
 #endif
 
+#if defined(CONFIG_PPC_85xx)
+/* Some Freescale processors have an erratum (USB A-005697) in which
+ * we need to wait for 10ms for bus to fo into suspend mode after
+ * setting SUSP bit
+ */
+#define ehci_has_fsl_susp_errata(e)	((e)->has_fsl_susp_errata)
+#else
+#define ehci_has_fsl_susp_errata(e)	(0)
+#endif
+
 /*
  * While most USB host controllers implement their registers in
  * little-endian format, a minority (celleb companion chip) implement
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 9e0020d..11258c4 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -17,6 +17,7 @@
 #include <linux/of_platform.h>
 #include <linux/clk.h>
 #include <linux/module.h>
+#include <asm/mpc85xx.h>
 
 struct fsl_usb2_dev_data {
 	char *dr_mode;		/* controller mode */
@@ -119,6 +120,52 @@ error:
 
 static const struct of_device_id fsl_usb2_mph_dr_of_match[];
 
+static bool has_erratum_a005697(void)
+{
+	unsigned int svr = mfspr(SPRN_SVR);
+	bool flag = false;
+
+	switch (SVR_SOC_VER(svr)) {
+	case SVR_P1010:
+	case SVR_P1014:
+	case SVR_T1040:
+		if (SVR_REV(svr) == 0x10)
+			flag = true;
+		break;
+	case SVR_9132:
+	if ((SVR_REV(svr) == 0x10) || (SVR_REV(svr) == 0x11))
+		flag = true;
+		break;
+	case SVR_P5040:
+	case SVR_P5021:
+		if ((SVR_REV(svr) == 0x10) || (SVR_REV(svr) == 0x20) ||
+			(SVR_REV(svr) == 0x21))
+			flag = true;
+		break;
+	case SVR_T4240:
+	case SVR_T4160:
+	case SVR_P5020:
+	case SVR_P5010:
+		if ((SVR_REV(svr) == 0x10) || (SVR_REV(svr) == 0x20))
+			flag = true;
+		break;
+	case SVR_P2040:
+	case SVR_P2041:
+	case SVR_P3041:
+		if ((SVR_REV(svr) == 0x10) || (SVR_REV(svr) == 0x11) ||
+			(SVR_REV(svr) == 0x20))
+			flag = true;
+		break;
+	case SVR_P4080:
+		if ((SVR_REV(svr) == 0x10) || (SVR_REV(svr) == 0x20) ||
+				(SVR_REV(svr) == 0x30))
+			flag = true;
+		break;
+	}
+
+	return flag;
+}
+
 static int usb_get_ver_info(struct device_node *np)
 {
 	int ver = -1;
@@ -213,6 +260,11 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
 		}
 	}
 
+	if (has_erratum_a005697())
+		pdata->has_fsl_erratum_a005697 = 1;
+	else
+		pdata->has_fsl_erratum_a005697 = 0;
+
 	for (i = 0; i < ARRAY_SIZE(dev_data->drivers); i++) {
 		if (!dev_data->drivers[i])
 			continue;
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index a82296a..62e76ca 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -92,6 +92,7 @@ struct fsl_usb2_platform_data {
 
 	unsigned	suspended:1;
 	unsigned	already_suspended:1;
+	unsigned	has_fsl_erratum_a005697:1;
 
 	/* register save area for suspend/resume */
 	u32		pm_command;
-- 
1.7.11.7



--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux