[PATCH v2] arm: dts: ls1021a: Add configure-gfladj property to USB3 node

2018-01-26 Thread yinbo.zhu
From: yinbo.zhu <yinbo@nxp.com>

Add "configure-gfladj" boolean property to USB3 node. This property
is used to determine whether frame length adjustent is required
or not

Signed-off-by: Ramneek Mehresh <ramneek.mehr...@freescale.com>
Signed-off-by: Honghua Yin <hong-hua@freescale.com>
Signed-off-by: yinbo zhu <yinbo@nxp.com>
---
Change in v2:
Remove the automatic generated tag from Gerrit.
Change "yinbo.zhu" to "yinbo zhu".
 arch/arm/boot/dts/ls1021a.dtsi |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index 9319e1f..ae8fc40 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -681,6 +681,7 @@
reg = <0x0 0x310 0x0 0x1>;
interrupts = ;
dr_mode = "host";
+   configure-gfladj;
snps,quirk-frame-length-adjustment = <0x20>;
snps,dis_rxdet_inp3_quirk;
};
-- 
1.7.1



[PATCH v2] arm: dts: ls1021a: Add configure-gfladj property to USB3 node

2018-01-26 Thread yinbo.zhu
From: yinbo.zhu 

Add "configure-gfladj" boolean property to USB3 node. This property
is used to determine whether frame length adjustent is required
or not

Signed-off-by: Ramneek Mehresh 
Signed-off-by: Honghua Yin 
Signed-off-by: yinbo zhu 
---
Change in v2:
Remove the automatic generated tag from Gerrit.
    Change "yinbo.zhu" to "yinbo zhu".
 arch/arm/boot/dts/ls1021a.dtsi |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index 9319e1f..ae8fc40 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -681,6 +681,7 @@
reg = <0x0 0x310 0x0 0x1>;
interrupts = ;
dr_mode = "host";
+   configure-gfladj;
snps,quirk-frame-length-adjustment = <0x20>;
snps,dis_rxdet_inp3_quirk;
};
-- 
1.7.1



[PATCH v1] arm: dts: ls1021a: Add configure-gfladj property to USB3 node

2018-01-22 Thread yinbo.zhu
From: yinbo.zhu <yinbo@nxp.com>

Add "configure-gfladj" boolean property to USB3 node. This property
is used to determine whether frame length adjustent is required
or not

Signed-off-by: Review Code-CDREVIEW <cdrev...@freescale.com>
Signed-off-by: Ramneek Mehresh <ramneek.mehr...@freescale.com>
Signed-off-by: Honghua Yin <hong-hua@freescale.com>
Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
 arch/arm/boot/dts/ls1021a.dtsi |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index f81fad2..a5ccf7a 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -707,6 +707,7 @@
reg = <0x0 0x310 0x0 0x1>;
interrupts = ;
dr_mode = "host";
+   configure-gfladj;
snps,quirk-frame-length-adjustment = <0x20>;
snps,dis_rxdet_inp3_quirk;
};
-- 
1.7.1



[PATCH v1] arm: dts: ls1021a: Add configure-gfladj property to USB3 node

2018-01-22 Thread yinbo.zhu
From: yinbo.zhu 

Add "configure-gfladj" boolean property to USB3 node. This property
is used to determine whether frame length adjustent is required
or not

Signed-off-by: Review Code-CDREVIEW 
Signed-off-by: Ramneek Mehresh 
Signed-off-by: Honghua Yin 
Signed-off-by: yinbo.zhu 
---
 arch/arm/boot/dts/ls1021a.dtsi |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index f81fad2..a5ccf7a 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -707,6 +707,7 @@
reg = <0x0 0x310 0x0 0x1>;
interrupts = ;
dr_mode = "host";
+   configure-gfladj;
snps,quirk-frame-length-adjustment = <0x20>;
snps,dis_rxdet_inp3_quirk;
};
-- 
1.7.1



[PATCH v5] arm64: dts: ls1088a: Add USB support

2017-12-22 Thread yinbo.zhu
From: yinbo.zhu <yinbo@nxp.com>

Add USB support on ls1088ardb

Signed-off-by: yinbo zhu <yinbo@nxp.com>
Signed-off-by: Ran Wang <ran.wan...@nxp.com>
---
Change in v5:
The usb node was sorted alphabetically in label name.
Remove the point in "yinbo.zhu".

 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi|   20 
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 0f6fcda..4f17601 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -125,3 +125,11 @@
  {
status = "okay";
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index bd80e9a..caf2bdd 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -394,6 +394,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
1.7.1



[PATCH v5] arm64: dts: ls1088a: Add USB support

2017-12-22 Thread yinbo.zhu
From: yinbo.zhu 

Add USB support on ls1088ardb

Signed-off-by: yinbo zhu 
Signed-off-by: Ran Wang 
---
Change in v5:
The usb node was sorted alphabetically in label name.
Remove the point in "yinbo.zhu".

 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi|   20 
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 0f6fcda..4f17601 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -125,3 +125,11 @@
  {
status = "okay";
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index bd80e9a..caf2bdd 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -394,6 +394,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
1.7.1



[PATCH v4 3/3] usb: host: Implement workaround for Erratum A-009668

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu <yinbo@nxp.com>

This issue is observed in USB 2.0 mode when the USB 3.0 host
controller is connected to a FS/LS device via a hub. The
host controller issues start-split (SSPLIT) and (CSPLIT)
tokens to accomplish a split-transaction. A
split-transaction consists of a SSPLIT token, token/data
consists of a SSPLIT token, token/data packets, CSPLIT token
and token/data/handshake packets. A SSPLIT token is issued
by the host controller to the hub followed by token/data/
handshake packets. The hub then relays the token/data/
handshake packets to the FS /LS device. Sometime later, the
host controller issues a CSPLIT token followed by the same
token/data/handshake packets to the hub to complete the
split-transaction. As an example scenario, when the xHCI
driver issues an Address device command with BSR=0, the
host controller sends SETUP(SET_ADDRESS) tokens on the USB
as part of splittransactions. If the host controller
receives a NYET response from the hub for the CSPLIT SETUP,
it means that the split-transaction has not yet been
completed or the hub is not able to handle the split
transaction. In such a case, the host controller keeps
retrying the splittransactions until such time an ACK
response is received from the hub for the CSPLIT SETUP token
. If the split-transactions do not complete in a time bound
manner, the xHCI driver may issue a Stop Endpoint Command.
The host controller does not service the Stop Endpoint
Command and eventually the xHCI driver times out waiting for
the Stop Endpoint Command to complete.

Impact: Stop Endpoint Command does not complete.
Workaround: Instead of issuing a Stop Endpoint Command,
issue a Disable Slot Command with the corresponding slot
ID. Alternately, you can issue an Address Device Command
with BSR=1.

Configs Affected:
LS1012A-R1.0, LS1012A-R2.0, LS1021-20-22A-R1.0,
LS1021-20-22A-R2.0, LS1043-23A-R1.0, LS1043-23A-R1.1,
LS1046-26A-R1.0, LS1088-48A-R1.0, LS2080-40A-R1.0,
LS2081A-R1.1, LS2085-45A-R1.0, LS2088-48A-R1.0,
LS2088-48A-R1.1, LX2160-2120-2080A-R1.0.

Signed-off-by: yinbo zhu <yinbo@nxp.com>
---
Change in v4:
Remove the point in "yinbo.zhu"
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |2 ++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |3 +++
 drivers/usb/host/xhci.c  |   12 
 drivers/usb/host/xhci.h  |1 +
 6 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 863f2c0..90b097c 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1059,6 +1059,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
"snps,quirk_reverse_in_out");
dwc->quirk_stop_transfer_in_block = device_property_read_bool(dev,
"snps,quirk_stop_transfer_in_block");
+   dwc->quirk_stop_ep_in_u1 = device_property_read_bool(dev,
+   "snps,quirk_stop_ep_in_u1");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6276678..b55a443 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -860,6 +860,7 @@ struct dwc3_scratchpad_array {
  * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
  * @quirk_stop_transfer_in_block: prevent block transmission from being
  *   interrupted
+ * @quirk_stop_ep_in_u1: replace stop commad with disable slot command
  * @imod_interval: set the interrupt moderation interval in 250ns
  * increments or 0 to disable.
  */
@@ -1014,6 +1015,7 @@ struct dwc3 {
unsignedtx_de_emphasis:2;
unsignedquirk_reverse_in_out:1;
unsignedquirk_stop_transfer_in_block:1;
+   unsignedquirk_stop_ep_in_u1:1;
 
u16 imod_interval;
 };
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index 78cb7bb..0a34274 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -96,6 +96,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->quirk_stop_transfer_in_block)
props[prop_idx++].name = "quirk-stop-transfer-in-block";
 
+   if (dwc->quirk_stop_ep_in_u1)
+   props[prop_idx++].name = "quirk-stop-ep-in-u1";
+
if (dwc->usb3_lpm_capable)
props[prop_idx++].name = "usb3-lpm-capable";
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 35e0fc8..49d6cb4 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -273,6 +273,9 @@ static int xhci_plat_probe(struct

[PATCH v4 3/3] usb: host: Implement workaround for Erratum A-009668

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu 

This issue is observed in USB 2.0 mode when the USB 3.0 host
controller is connected to a FS/LS device via a hub. The
host controller issues start-split (SSPLIT) and (CSPLIT)
tokens to accomplish a split-transaction. A
split-transaction consists of a SSPLIT token, token/data
consists of a SSPLIT token, token/data packets, CSPLIT token
and token/data/handshake packets. A SSPLIT token is issued
by the host controller to the hub followed by token/data/
handshake packets. The hub then relays the token/data/
handshake packets to the FS /LS device. Sometime later, the
host controller issues a CSPLIT token followed by the same
token/data/handshake packets to the hub to complete the
split-transaction. As an example scenario, when the xHCI
driver issues an Address device command with BSR=0, the
host controller sends SETUP(SET_ADDRESS) tokens on the USB
as part of splittransactions. If the host controller
receives a NYET response from the hub for the CSPLIT SETUP,
it means that the split-transaction has not yet been
completed or the hub is not able to handle the split
transaction. In such a case, the host controller keeps
retrying the splittransactions until such time an ACK
response is received from the hub for the CSPLIT SETUP token
. If the split-transactions do not complete in a time bound
manner, the xHCI driver may issue a Stop Endpoint Command.
The host controller does not service the Stop Endpoint
Command and eventually the xHCI driver times out waiting for
the Stop Endpoint Command to complete.

Impact: Stop Endpoint Command does not complete.
Workaround: Instead of issuing a Stop Endpoint Command,
issue a Disable Slot Command with the corresponding slot
ID. Alternately, you can issue an Address Device Command
with BSR=1.

Configs Affected:
LS1012A-R1.0, LS1012A-R2.0, LS1021-20-22A-R1.0,
LS1021-20-22A-R2.0, LS1043-23A-R1.0, LS1043-23A-R1.1,
LS1046-26A-R1.0, LS1088-48A-R1.0, LS2080-40A-R1.0,
LS2081A-R1.1, LS2085-45A-R1.0, LS2088-48A-R1.0,
LS2088-48A-R1.1, LX2160-2120-2080A-R1.0.

Signed-off-by: yinbo zhu 
---
Change in v4:
Remove the point in "yinbo.zhu"
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |2 ++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |3 +++
 drivers/usb/host/xhci.c  |   12 
 drivers/usb/host/xhci.h  |1 +
 6 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 863f2c0..90b097c 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1059,6 +1059,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
"snps,quirk_reverse_in_out");
dwc->quirk_stop_transfer_in_block = device_property_read_bool(dev,
"snps,quirk_stop_transfer_in_block");
+   dwc->quirk_stop_ep_in_u1 = device_property_read_bool(dev,
+   "snps,quirk_stop_ep_in_u1");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6276678..b55a443 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -860,6 +860,7 @@ struct dwc3_scratchpad_array {
  * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
  * @quirk_stop_transfer_in_block: prevent block transmission from being
  *   interrupted
+ * @quirk_stop_ep_in_u1: replace stop commad with disable slot command
  * @imod_interval: set the interrupt moderation interval in 250ns
  * increments or 0 to disable.
  */
@@ -1014,6 +1015,7 @@ struct dwc3 {
unsignedtx_de_emphasis:2;
unsignedquirk_reverse_in_out:1;
unsignedquirk_stop_transfer_in_block:1;
+   unsignedquirk_stop_ep_in_u1:1;
 
u16 imod_interval;
 };
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index 78cb7bb..0a34274 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -96,6 +96,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->quirk_stop_transfer_in_block)
props[prop_idx++].name = "quirk-stop-transfer-in-block";
 
+   if (dwc->quirk_stop_ep_in_u1)
+   props[prop_idx++].name = "quirk-stop-ep-in-u1";
+
if (dwc->usb3_lpm_capable)
props[prop_idx++].name = "usb3-lpm-capable";
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 35e0fc8..49d6cb4 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -273,6 +273,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
   

[PATCH v4 2/3] usb: host: Implement workaround for Erratum A-009611

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu <yinbo@nxp.com>

This is a occasional problem where the software issues an End
Transfer command while a USB transfer is in progress,
resulting in the TxFIFO  being flushed when the lower layer is
waiting for data, causing the super speed (ss) transmit to get
blocked. If the End Transfer command is issued on an IN
endpoint to flush out the pending transfers when the same IN
endpoint is doing transfers on the USB, then depending upon
the timing of the End Transfer (and the resulting internal
flush),the lower layer (U3PTL/U3MAC) could get stuck waiting
for data indefinitely. This blocks the transmission path on
the SS, and no DP/ACK/ERDY/DEVNOTIF packets can be sent from
the device. Impact: If this issue happens and the transmission
gets blocked, then the USB host aborts and
resets/re-enumerates the device. This unblocks the transmitt
engine and the device functions normally.

Workaround: Software must wait for all existing TRBs to
complete before issuing End transfer command.

Configs Affected:
LS1088-48A-R1.0, LS2081A-R1.1, LS2088-48A-R1.0,
LS2088-48A-R1.1, LX2160-2120-2080A-R1.

Signed-off-by: yinbo zhu <yinbo@nxp.com>
---
Change in v4:
Remove the point in "yinbo.zhu"
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |3 +++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |4 
 drivers/usb/host/xhci.c  |   25 +++--
 drivers/usb/host/xhci.h  |1 +
 6 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 6613bc0..863f2c0 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1057,6 +1057,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
"snps,tx_de_emphasis_quirk");
dwc->quirk_reverse_in_out = device_property_read_bool(dev,
"snps,quirk_reverse_in_out");
+   dwc->quirk_stop_transfer_in_block = device_property_read_bool(dev,
+   "snps,quirk_stop_transfer_in_block");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index a263fdc..6276678 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -858,6 +858,8 @@ struct dwc3_scratchpad_array {
  * 2   - No de-emphasis
  * 3   - Reserved
  * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
+ * @quirk_stop_transfer_in_block: prevent block transmission from being
+ *   interrupted
  * @imod_interval: set the interrupt moderation interval in 250ns
  * increments or 0 to disable.
  */
@@ -1011,6 +1013,7 @@ struct dwc3 {
unsignedtx_de_emphasis_quirk:1;
unsignedtx_de_emphasis:2;
unsignedquirk_reverse_in_out:1;
+   unsignedquirk_stop_transfer_in_block:1;
 
u16 imod_interval;
 };
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index dab5f49..78cb7bb 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -93,6 +93,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->quirk_reverse_in_out)
props[prop_idx++].name = "quirk-reverse-in-out";
 
+   if (dwc->quirk_stop_transfer_in_block)
+   props[prop_idx++].name = "quirk-stop-transfer-in-block";
+
if (dwc->usb3_lpm_capable)
props[prop_idx++].name = "usb3-lpm-capable";
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index fe71b92..35e0fc8 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -269,6 +269,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (device_property_read_bool(>dev, "quirk-reverse-in-out"))
xhci->quirks |= XHCI_REVERSE_IN_OUT;
 
+   if (device_property_read_bool(>dev,
+   "quirk-stop-transfer-in-block"))
+   xhci->quirks |= XHCI_STOP_TRANSFER_IN_BLOCK;
+
if (device_property_read_bool(>dev, "quirk-broken-port-ped"))
xhci->quirks |= XHCI_BROKEN_PORT_PED;
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 05104bd..5141856 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1501,13 +1501,26 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
ret = -ENOMEM;
goto done;
}
-   ep->ep_state |= EP_STOP_CMD_PENDING;
-   ep->stop_cmd_timer.expires = jiffies

[PATCH v4 1/3] usb: host: Implement workaround for Erratum A-007463

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu <yinbo@nxp.com>

When a transaction error (defined in Section 4.10.2.3, "USB
Transaction Error" of the xHCI Specification) occurs on the
USB, the host controller reports this through a transfer
event with the completion code "USB Transaction Error". When
this happens, the endpoint is placed in the Halted state. In
response, software must issue a Reset Endpoint command to
transition the endpoint to the Stopped state. In order to
restart the transfer, the driver can perform either of the
following:
a) Ring the doorbell again, which restarts the transfer from
   where it stopped, or
b) Issue a Set TR (Transfer Ring) Dequeue Pointer command
   for the endpoint to start the transfer form a different
   Transfer Ring pointer Consider the following
   scenario:
1. The xHCI driver prepares a control transfer read to one
   of the device's control endpoints;
2. During the IN data stage, a transaction error occurs on
   the USB, causing a transfer event with the completion
   code "USB Transaction Error";
3. The driver issues a Reset Endpoint command;
4. The driver rings the doorbell of the control endpoint to
   resume the transfer. In this scenario, the controller
   may reverse the direction of the data stage from IN to OUT.
   Instead of sending an ACK to the endpoint to poll for read
   data, it sends a Data Packet (DP) to the endpoint. It
   fetches the data from the data stage Transfer Request
   Block (TRB) that is being resumed, even though the data
   buffer is setup to receive data and not transmit it.
NOTE
This issue occurs only if the transaction error happens
during an IN data stage. There is no issue if the transaction
error happens during an OUT data stage.

Impact: When this issue occurs, the device likely responds in
one of the following ways:
a) The device responds with a STALL because the data stage
has unexpectedly changed directions. The controller then
generates a Stall Error transfer event, to which software
must issue a Reset Endpoint command followed by a Set TR
Dequeue Pointer command pointing to a new Setup TRB to clear
the STALL condition.
b) The device does not respond to the inverted data stage and
the transaction times out. The controller generates another
USB Transaction Error transfer event, to which software
likely performs a USB Reset to the device because it is
unresponsive. It is not expected that any of these recovery
steps will cause instability in the system because this
recovery is part of a standard xHCI driver and could happen
regardless of the defect. Another possible system-level
impact is that the controller attempts to read from the
memory location pointed at by the Data Stage TRB or a Normal
TRB chained to it. associated with this TRB is intended to be
written by the controller, but the controller reads from it
instead. Normally, this does not cause a problem. However, if
the system has some type of memory protection where this
unexpected read is treated as a bus error,
a problem. However, if the system has some type of memory
it may cause the system to become unstable or to crash.

Workaround: If a USB Transaction Error occurs during the IN
data phase of a control transfer, the driver must use the
Set TR Dequeue Pointer command to either restart the data
Phase or restart the entire control transfer from the
Setup phase.

Configs Affected:
LS1021-20-22A-R1.0, LS1021-20-22A-R2.007463

Signed-off-by: yinbo zhu <yinbo@nxp.com>
---
Change in v4:
Remove the point in "yinbo.zhu"
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |2 ++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |3 +++
 drivers/usb/host/xhci-ring.c |   28 +++-
 drivers/usb/host/xhci.h  |3 ++-
 6 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 0783250..6613bc0 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1055,6 +1055,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
"snps,tx_de_emphasis_quirk");
+   dwc->quirk_reverse_in_out = device_property_read_bool(dev,
+   "snps,quirk_reverse_in_out");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 4a4a4c9..a263fdc 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -857,6 +857,7 @@ struct dwc3_scratchpad_array {
  * 1   - -3.5dB de-emphasis
  * 2   - No de-emphasis
  * 3   - Reserved
+ * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
  * @imod_interval: set the inte

[PATCH v4 2/3] usb: host: Implement workaround for Erratum A-009611

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu 

This is a occasional problem where the software issues an End
Transfer command while a USB transfer is in progress,
resulting in the TxFIFO  being flushed when the lower layer is
waiting for data, causing the super speed (ss) transmit to get
blocked. If the End Transfer command is issued on an IN
endpoint to flush out the pending transfers when the same IN
endpoint is doing transfers on the USB, then depending upon
the timing of the End Transfer (and the resulting internal
flush),the lower layer (U3PTL/U3MAC) could get stuck waiting
for data indefinitely. This blocks the transmission path on
the SS, and no DP/ACK/ERDY/DEVNOTIF packets can be sent from
the device. Impact: If this issue happens and the transmission
gets blocked, then the USB host aborts and
resets/re-enumerates the device. This unblocks the transmitt
engine and the device functions normally.

Workaround: Software must wait for all existing TRBs to
complete before issuing End transfer command.

Configs Affected:
LS1088-48A-R1.0, LS2081A-R1.1, LS2088-48A-R1.0,
LS2088-48A-R1.1, LX2160-2120-2080A-R1.

Signed-off-by: yinbo zhu 
---
Change in v4:
Remove the point in "yinbo.zhu"
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |3 +++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |4 
 drivers/usb/host/xhci.c  |   25 +++--
 drivers/usb/host/xhci.h  |1 +
 6 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 6613bc0..863f2c0 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1057,6 +1057,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
"snps,tx_de_emphasis_quirk");
dwc->quirk_reverse_in_out = device_property_read_bool(dev,
"snps,quirk_reverse_in_out");
+   dwc->quirk_stop_transfer_in_block = device_property_read_bool(dev,
+   "snps,quirk_stop_transfer_in_block");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index a263fdc..6276678 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -858,6 +858,8 @@ struct dwc3_scratchpad_array {
  * 2   - No de-emphasis
  * 3   - Reserved
  * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
+ * @quirk_stop_transfer_in_block: prevent block transmission from being
+ *   interrupted
  * @imod_interval: set the interrupt moderation interval in 250ns
  * increments or 0 to disable.
  */
@@ -1011,6 +1013,7 @@ struct dwc3 {
unsignedtx_de_emphasis_quirk:1;
unsignedtx_de_emphasis:2;
unsignedquirk_reverse_in_out:1;
+   unsignedquirk_stop_transfer_in_block:1;
 
u16 imod_interval;
 };
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index dab5f49..78cb7bb 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -93,6 +93,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->quirk_reverse_in_out)
props[prop_idx++].name = "quirk-reverse-in-out";
 
+   if (dwc->quirk_stop_transfer_in_block)
+   props[prop_idx++].name = "quirk-stop-transfer-in-block";
+
if (dwc->usb3_lpm_capable)
props[prop_idx++].name = "usb3-lpm-capable";
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index fe71b92..35e0fc8 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -269,6 +269,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (device_property_read_bool(>dev, "quirk-reverse-in-out"))
xhci->quirks |= XHCI_REVERSE_IN_OUT;
 
+   if (device_property_read_bool(>dev,
+   "quirk-stop-transfer-in-block"))
+   xhci->quirks |= XHCI_STOP_TRANSFER_IN_BLOCK;
+
if (device_property_read_bool(>dev, "quirk-broken-port-ped"))
xhci->quirks |= XHCI_BROKEN_PORT_PED;
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 05104bd..5141856 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1501,13 +1501,26 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
ret = -ENOMEM;
goto done;
}
-   ep->ep_state |= EP_STOP_CMD_PENDING;
-   ep->stop_cmd_timer.expires = jiffies +
+   /*
+*erratum

[PATCH v4 1/3] usb: host: Implement workaround for Erratum A-007463

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu 

When a transaction error (defined in Section 4.10.2.3, "USB
Transaction Error" of the xHCI Specification) occurs on the
USB, the host controller reports this through a transfer
event with the completion code "USB Transaction Error". When
this happens, the endpoint is placed in the Halted state. In
response, software must issue a Reset Endpoint command to
transition the endpoint to the Stopped state. In order to
restart the transfer, the driver can perform either of the
following:
a) Ring the doorbell again, which restarts the transfer from
   where it stopped, or
b) Issue a Set TR (Transfer Ring) Dequeue Pointer command
   for the endpoint to start the transfer form a different
   Transfer Ring pointer Consider the following
   scenario:
1. The xHCI driver prepares a control transfer read to one
   of the device's control endpoints;
2. During the IN data stage, a transaction error occurs on
   the USB, causing a transfer event with the completion
   code "USB Transaction Error";
3. The driver issues a Reset Endpoint command;
4. The driver rings the doorbell of the control endpoint to
   resume the transfer. In this scenario, the controller
   may reverse the direction of the data stage from IN to OUT.
   Instead of sending an ACK to the endpoint to poll for read
   data, it sends a Data Packet (DP) to the endpoint. It
   fetches the data from the data stage Transfer Request
   Block (TRB) that is being resumed, even though the data
   buffer is setup to receive data and not transmit it.
NOTE
This issue occurs only if the transaction error happens
during an IN data stage. There is no issue if the transaction
error happens during an OUT data stage.

Impact: When this issue occurs, the device likely responds in
one of the following ways:
a) The device responds with a STALL because the data stage
has unexpectedly changed directions. The controller then
generates a Stall Error transfer event, to which software
must issue a Reset Endpoint command followed by a Set TR
Dequeue Pointer command pointing to a new Setup TRB to clear
the STALL condition.
b) The device does not respond to the inverted data stage and
the transaction times out. The controller generates another
USB Transaction Error transfer event, to which software
likely performs a USB Reset to the device because it is
unresponsive. It is not expected that any of these recovery
steps will cause instability in the system because this
recovery is part of a standard xHCI driver and could happen
regardless of the defect. Another possible system-level
impact is that the controller attempts to read from the
memory location pointed at by the Data Stage TRB or a Normal
TRB chained to it. associated with this TRB is intended to be
written by the controller, but the controller reads from it
instead. Normally, this does not cause a problem. However, if
the system has some type of memory protection where this
unexpected read is treated as a bus error,
a problem. However, if the system has some type of memory
it may cause the system to become unstable or to crash.

Workaround: If a USB Transaction Error occurs during the IN
data phase of a control transfer, the driver must use the
Set TR Dequeue Pointer command to either restart the data
Phase or restart the entire control transfer from the
Setup phase.

Configs Affected:
LS1021-20-22A-R1.0, LS1021-20-22A-R2.007463

Signed-off-by: yinbo zhu 
---
Change in v4:
    Remove the point in "yinbo.zhu"
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |2 ++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |3 +++
 drivers/usb/host/xhci-ring.c |   28 +++-
 drivers/usb/host/xhci.h  |3 ++-
 6 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 0783250..6613bc0 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1055,6 +1055,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
"snps,tx_de_emphasis_quirk");
+   dwc->quirk_reverse_in_out = device_property_read_bool(dev,
+   "snps,quirk_reverse_in_out");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 4a4a4c9..a263fdc 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -857,6 +857,7 @@ struct dwc3_scratchpad_array {
  * 1   - -3.5dB de-emphasis
  * 2   - No de-emphasis
  * 3   - Reserved
+ * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
  * @imod_interval: set the interrupt moderation interval in 250ns

[PATCH v3 3/3] usb: host: Implement workaround for Erratum A-009668

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu <yinbo@nxp.com>

This issue is observed in USB 2.0 mode when the USB 3.0 host
controller is connected to a FS/LS device via a hub. The
host controller issues start-split (SSPLIT) and (CSPLIT)
tokens to accomplish a split-transaction. A
split-transaction consists of a SSPLIT token, token/data
consists of a SSPLIT token, token/data packets, CSPLIT token
and token/data/handshake packets. A SSPLIT token is issued
by the host controller to the hub followed by token/data/
handshake packets. The hub then relays the token/data/
handshake packets to the FS /LS device. Sometime later, the
host controller issues a CSPLIT token followed by the same
token/data/handshake packets to the hub to complete the
split-transaction. As an example scenario, when the xHCI
driver issues an Address device command with BSR=0, the
host controller sends SETUP(SET_ADDRESS) tokens on the USB
as part of splittransactions. If the host controller
receives a NYET response from the hub for the CSPLIT SETUP,
it means that the split-transaction has not yet been
completed or the hub is not able to handle the split
transaction. In such a case, the host controller keeps
retrying the splittransactions until such time an ACK
response is received from the hub for the CSPLIT SETUP token
. If the split-transactions do not complete in a time bound
manner, the xHCI driver may issue a Stop Endpoint Command.
The host controller does not service the Stop Endpoint
Command and eventually the xHCI driver times out waiting for
the Stop Endpoint Command to complete.

Impact: Stop Endpoint Command does not complete.
Workaround: Instead of issuing a Stop Endpoint Command,
issue a Disable Slot Command with the corresponding slot
ID. Alternately, you can issue an Address Device Command
with BSR=1.

Configs Affected:
LS1012A-R1.0, LS1012A-R2.0, LS1021-20-22A-R1.0,
LS1021-20-22A-R2.0, LS1043-23A-R1.0, LS1043-23A-R1.1,
LS1046-26A-R1.0, LS1088-48A-R1.0, LS2080-40A-R1.0,
LS2081A-R1.1, LS2085-45A-R1.0, LS2088-48A-R1.0,
LS2088-48A-R1.1, LX2160-2120-2080A-R1.0.

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
Change in v3:
Adjust the commit information.
Replace "(1<<34)" with BIT(34).
Update the DT properity description.
Update erratum description in code comment.
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |2 ++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |3 +++
 drivers/usb/host/xhci.c  |   12 
 drivers/usb/host/xhci.h  |1 +
 6 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 863f2c0..90b097c 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1059,6 +1059,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
"snps,quirk_reverse_in_out");
dwc->quirk_stop_transfer_in_block = device_property_read_bool(dev,
"snps,quirk_stop_transfer_in_block");
+   dwc->quirk_stop_ep_in_u1 = device_property_read_bool(dev,
+   "snps,quirk_stop_ep_in_u1");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6276678..b55a443 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -860,6 +860,7 @@ struct dwc3_scratchpad_array {
  * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
  * @quirk_stop_transfer_in_block: prevent block transmission from being
  *   interrupted
+ * @quirk_stop_ep_in_u1: replace stop commad with disable slot command
  * @imod_interval: set the interrupt moderation interval in 250ns
  * increments or 0 to disable.
  */
@@ -1014,6 +1015,7 @@ struct dwc3 {
unsignedtx_de_emphasis:2;
unsignedquirk_reverse_in_out:1;
unsignedquirk_stop_transfer_in_block:1;
+   unsignedquirk_stop_ep_in_u1:1;
 
u16 imod_interval;
 };
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index 78cb7bb..0a34274 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -96,6 +96,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->quirk_stop_transfer_in_block)
props[prop_idx++].name = "quirk-stop-transfer-in-block";
 
+   if (dwc->quirk_stop_ep_in_u1)
+   props[prop_idx++].name = "quirk-stop-ep-in-u1";
+
if (dwc->usb3_lpm_capable)
props[prop_idx++].name = "usb3-lpm-capable";
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 3

[PATCH v3 2/3] usb: host: Implement workaround for Erratum A-009611

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu <yinbo@nxp.com>

This is a occasional problem where the software issues an End
Transfer command while a USB transfer is in progress,
resulting in the TxFIFO  being flushed when the lower layer is
waiting for data, causing the super speed (ss) transmit to get
blocked. If the End Transfer command is issued on an IN
endpoint to flush out the pending transfers when the same IN
endpoint is doing transfers on the USB, then depending upon
the timing of the End Transfer (and the resulting internal
flush),the lower layer (U3PTL/U3MAC) could get stuck waiting
for data indefinitely. This blocks the transmission path on
the SS, and no DP/ACK/ERDY/DEVNOTIF packets can be sent from
the device. Impact: If this issue happens and the transmission
gets blocked, then the USB host aborts and
resets/re-enumerates the device. This unblocks the transmitt
engine and the device functions normally.

Workaround: Software must wait for all existing TRBs to
complete before issuing End transfer command.

Configs Affected:
LS1088-48A-R1.0, LS2081A-R1.1, LS2088-48A-R1.0,
LS2088-48A-R1.1, LX2160-2120-2080A-R1.

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
Change in v3:
Adjust the commit information.
Replace "(1<<33)" with BIT(33).
Update the DT properity description.
Update erratum description in code comment. 
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |3 +++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |4 
 drivers/usb/host/xhci.c  |   25 +++--
 drivers/usb/host/xhci.h  |1 +
 6 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 6613bc0..863f2c0 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1057,6 +1057,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
"snps,tx_de_emphasis_quirk");
dwc->quirk_reverse_in_out = device_property_read_bool(dev,
"snps,quirk_reverse_in_out");
+   dwc->quirk_stop_transfer_in_block = device_property_read_bool(dev,
+   "snps,quirk_stop_transfer_in_block");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index a263fdc..6276678 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -858,6 +858,8 @@ struct dwc3_scratchpad_array {
  * 2   - No de-emphasis
  * 3   - Reserved
  * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
+ * @quirk_stop_transfer_in_block: prevent block transmission from being
+ *   interrupted
  * @imod_interval: set the interrupt moderation interval in 250ns
  * increments or 0 to disable.
  */
@@ -1011,6 +1013,7 @@ struct dwc3 {
unsignedtx_de_emphasis_quirk:1;
unsignedtx_de_emphasis:2;
unsignedquirk_reverse_in_out:1;
+   unsignedquirk_stop_transfer_in_block:1;
 
u16 imod_interval;
 };
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index dab5f49..78cb7bb 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -93,6 +93,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->quirk_reverse_in_out)
props[prop_idx++].name = "quirk-reverse-in-out";
 
+   if (dwc->quirk_stop_transfer_in_block)
+   props[prop_idx++].name = "quirk-stop-transfer-in-block";
+
if (dwc->usb3_lpm_capable)
props[prop_idx++].name = "usb3-lpm-capable";
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index fe71b92..35e0fc8 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -269,6 +269,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (device_property_read_bool(>dev, "quirk-reverse-in-out"))
xhci->quirks |= XHCI_REVERSE_IN_OUT;
 
+   if (device_property_read_bool(>dev,
+   "quirk-stop-transfer-in-block"))
+   xhci->quirks |= XHCI_STOP_TRANSFER_IN_BLOCK;
+
if (device_property_read_bool(>dev, "quirk-broken-port-ped"))
xhci->quirks |= XHCI_BROKEN_PORT_PED;
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 05104bd..5141856 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1501,13 +1501,26 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
re

[PATCH v3 3/3] usb: host: Implement workaround for Erratum A-009668

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu 

This issue is observed in USB 2.0 mode when the USB 3.0 host
controller is connected to a FS/LS device via a hub. The
host controller issues start-split (SSPLIT) and (CSPLIT)
tokens to accomplish a split-transaction. A
split-transaction consists of a SSPLIT token, token/data
consists of a SSPLIT token, token/data packets, CSPLIT token
and token/data/handshake packets. A SSPLIT token is issued
by the host controller to the hub followed by token/data/
handshake packets. The hub then relays the token/data/
handshake packets to the FS /LS device. Sometime later, the
host controller issues a CSPLIT token followed by the same
token/data/handshake packets to the hub to complete the
split-transaction. As an example scenario, when the xHCI
driver issues an Address device command with BSR=0, the
host controller sends SETUP(SET_ADDRESS) tokens on the USB
as part of splittransactions. If the host controller
receives a NYET response from the hub for the CSPLIT SETUP,
it means that the split-transaction has not yet been
completed or the hub is not able to handle the split
transaction. In such a case, the host controller keeps
retrying the splittransactions until such time an ACK
response is received from the hub for the CSPLIT SETUP token
. If the split-transactions do not complete in a time bound
manner, the xHCI driver may issue a Stop Endpoint Command.
The host controller does not service the Stop Endpoint
Command and eventually the xHCI driver times out waiting for
the Stop Endpoint Command to complete.

Impact: Stop Endpoint Command does not complete.
Workaround: Instead of issuing a Stop Endpoint Command,
issue a Disable Slot Command with the corresponding slot
ID. Alternately, you can issue an Address Device Command
with BSR=1.

Configs Affected:
LS1012A-R1.0, LS1012A-R2.0, LS1021-20-22A-R1.0,
LS1021-20-22A-R2.0, LS1043-23A-R1.0, LS1043-23A-R1.1,
LS1046-26A-R1.0, LS1088-48A-R1.0, LS2080-40A-R1.0,
LS2081A-R1.1, LS2085-45A-R1.0, LS2088-48A-R1.0,
LS2088-48A-R1.1, LX2160-2120-2080A-R1.0.

Signed-off-by: yinbo.zhu 
---
Change in v3:
Adjust the commit information.
Replace "(1<<34)" with BIT(34).
Update the DT properity description.
Update erratum description in code comment.
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |2 ++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |3 +++
 drivers/usb/host/xhci.c  |   12 
 drivers/usb/host/xhci.h  |1 +
 6 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 863f2c0..90b097c 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1059,6 +1059,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
"snps,quirk_reverse_in_out");
dwc->quirk_stop_transfer_in_block = device_property_read_bool(dev,
"snps,quirk_stop_transfer_in_block");
+   dwc->quirk_stop_ep_in_u1 = device_property_read_bool(dev,
+   "snps,quirk_stop_ep_in_u1");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6276678..b55a443 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -860,6 +860,7 @@ struct dwc3_scratchpad_array {
  * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
  * @quirk_stop_transfer_in_block: prevent block transmission from being
  *   interrupted
+ * @quirk_stop_ep_in_u1: replace stop commad with disable slot command
  * @imod_interval: set the interrupt moderation interval in 250ns
  * increments or 0 to disable.
  */
@@ -1014,6 +1015,7 @@ struct dwc3 {
unsignedtx_de_emphasis:2;
unsignedquirk_reverse_in_out:1;
unsignedquirk_stop_transfer_in_block:1;
+   unsignedquirk_stop_ep_in_u1:1;
 
u16 imod_interval;
 };
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index 78cb7bb..0a34274 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -96,6 +96,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->quirk_stop_transfer_in_block)
props[prop_idx++].name = "quirk-stop-transfer-in-block";
 
+   if (dwc->quirk_stop_ep_in_u1)
+   props[prop_idx++].name = "quirk-stop-ep-in-u1";
+
if (dwc->usb3_lpm_capable)
props[prop_idx++].name = "usb3-lpm-capable";
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 35e0fc8..49d6cb4 100644
--- a/drivers/usb/host/xhci-plat.c

[PATCH v3 2/3] usb: host: Implement workaround for Erratum A-009611

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu 

This is a occasional problem where the software issues an End
Transfer command while a USB transfer is in progress,
resulting in the TxFIFO  being flushed when the lower layer is
waiting for data, causing the super speed (ss) transmit to get
blocked. If the End Transfer command is issued on an IN
endpoint to flush out the pending transfers when the same IN
endpoint is doing transfers on the USB, then depending upon
the timing of the End Transfer (and the resulting internal
flush),the lower layer (U3PTL/U3MAC) could get stuck waiting
for data indefinitely. This blocks the transmission path on
the SS, and no DP/ACK/ERDY/DEVNOTIF packets can be sent from
the device. Impact: If this issue happens and the transmission
gets blocked, then the USB host aborts and
resets/re-enumerates the device. This unblocks the transmitt
engine and the device functions normally.

Workaround: Software must wait for all existing TRBs to
complete before issuing End transfer command.

Configs Affected:
LS1088-48A-R1.0, LS2081A-R1.1, LS2088-48A-R1.0,
LS2088-48A-R1.1, LX2160-2120-2080A-R1.

Signed-off-by: yinbo.zhu 
---
Change in v3:
Adjust the commit information.
Replace "(1<<33)" with BIT(33).
Update the DT properity description.
Update erratum description in code comment. 
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |3 +++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |4 
 drivers/usb/host/xhci.c  |   25 +++--
 drivers/usb/host/xhci.h  |1 +
 6 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 6613bc0..863f2c0 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1057,6 +1057,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
"snps,tx_de_emphasis_quirk");
dwc->quirk_reverse_in_out = device_property_read_bool(dev,
"snps,quirk_reverse_in_out");
+   dwc->quirk_stop_transfer_in_block = device_property_read_bool(dev,
+   "snps,quirk_stop_transfer_in_block");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index a263fdc..6276678 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -858,6 +858,8 @@ struct dwc3_scratchpad_array {
  * 2   - No de-emphasis
  * 3   - Reserved
  * @quirk_reverse_in_out: prevent tx fifo reverse the data direction
+ * @quirk_stop_transfer_in_block: prevent block transmission from being
+ *   interrupted
  * @imod_interval: set the interrupt moderation interval in 250ns
  * increments or 0 to disable.
  */
@@ -1011,6 +1013,7 @@ struct dwc3 {
unsignedtx_de_emphasis_quirk:1;
unsignedtx_de_emphasis:2;
unsignedquirk_reverse_in_out:1;
+   unsignedquirk_stop_transfer_in_block:1;
 
u16 imod_interval;
 };
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index dab5f49..78cb7bb 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -93,6 +93,9 @@ int dwc3_host_init(struct dwc3 *dwc)
if (dwc->quirk_reverse_in_out)
props[prop_idx++].name = "quirk-reverse-in-out";
 
+   if (dwc->quirk_stop_transfer_in_block)
+   props[prop_idx++].name = "quirk-stop-transfer-in-block";
+
if (dwc->usb3_lpm_capable)
props[prop_idx++].name = "usb3-lpm-capable";
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index fe71b92..35e0fc8 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -269,6 +269,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (device_property_read_bool(>dev, "quirk-reverse-in-out"))
xhci->quirks |= XHCI_REVERSE_IN_OUT;
 
+   if (device_property_read_bool(>dev,
+   "quirk-stop-transfer-in-block"))
+   xhci->quirks |= XHCI_STOP_TRANSFER_IN_BLOCK;
+
if (device_property_read_bool(>dev, "quirk-broken-port-ped"))
xhci->quirks |= XHCI_BROKEN_PORT_PED;
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 05104bd..5141856 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1501,13 +1501,26 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
ret = -ENOMEM;
goto done;
   

[PATCH v3 1/3] usb: host: Implement workaround for Erratum A-007463

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu <yinbo@nxp.com>

When a transaction error (defined in Section 4.10.2.3, "USB
Transaction Error" of the xHCI Specification) occurs on the
USB, the host controller reports this through a transfer
event with the completion code "USB Transaction Error". When
this happens, the endpoint is placed in the Halted state. In
response, software must issue a Reset Endpoint command to
transition the endpoint to the Stopped state. In order to
restart the transfer, the driver can perform either of the
following:
a) Ring the doorbell again, which restarts the transfer from
   where it stopped, or
b) Issue a Set TR (Transfer Ring) Dequeue Pointer command
   for the endpoint to start the transfer form a different
   Transfer Ring pointer Consider the following
   scenario:
1. The xHCI driver prepares a control transfer read to one
   of the device's control endpoints;
2. During the IN data stage, a transaction error occurs on
   the USB, causing a transfer event with the completion
   code "USB Transaction Error";
3. The driver issues a Reset Endpoint command;
4. The driver rings the doorbell of the control endpoint to
   resume the transfer. In this scenario, the controller
   may reverse the direction of the data stage from IN to OUT.
   Instead of sending an ACK to the endpoint to poll for read
   data, it sends a Data Packet (DP) to the endpoint. It
   fetches the data from the data stage Transfer Request
   Block (TRB) that is being resumed, even though the data
   buffer is setup to receive data and not transmit it.
NOTE
This issue occurs only if the transaction error happens
during an IN data stage. There is no issue if the transaction
error happens during an OUT data stage.

Impact: When this issue occurs, the device likely responds in
one of the following ways:
a) The device responds with a STALL because the data stage
has unexpectedly changed directions. The controller then
generates a Stall Error transfer event, to which software
must issue a Reset Endpoint command followed by a Set TR
Dequeue Pointer command pointing to a new Setup TRB to clear
the STALL condition.
b) The device does not respond to the inverted data stage and
the transaction times out. The controller generates another
USB Transaction Error transfer event, to which software
likely performs a USB Reset to the device because it is
unresponsive. It is not expected that any of these recovery
steps will cause instability in the system because this
recovery is part of a standard xHCI driver and could happen
regardless of the defect. Another possible system-level
impact is that the controller attempts to read from the
memory location pointed at by the Data Stage TRB or a Normal
TRB chained to it. associated with this TRB is intended to be
written by the controller, but the controller reads from it
instead. Normally, this does not cause a problem. However, if
the system has some type of memory protection where this
unexpected read is treated as a bus error,
a problem. However, if the system has some type of memory
it may cause the system to become unstable or to crash.

Workaround: If a USB Transaction Error occurs during the IN
data phase of a control transfer, the driver must use the
Set TR Dequeue Pointer command to either restart the data
Phase or restart the entire control transfer from the
Setup phase.

Configs Affected:
LS1021-20-22A-R1.0, LS1021-20-22A-R2.007463

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
Change in v3:
Adjust the commit information.
Replace "(1<<32)" with BIT(32).
Update the DT properity description. 
Update erratum description in code comment. 
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |2 ++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |3 +++
 drivers/usb/host/xhci-ring.c |   28 +++-
 drivers/usb/host/xhci.h  |3 ++-
 6 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 0783250..6613bc0 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1055,6 +1055,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
"snps,tx_de_emphasis_quirk");
+   dwc->quirk_reverse_in_out = device_property_read_bool(dev,
+   "snps,quirk_reverse_in_out");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 4a4a4c9..a263fdc 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -857,6 +857,7 @@ struct dwc3_scratchpad_array {
  * 1   - -3.5dB de

[PATCH v3 1/3] usb: host: Implement workaround for Erratum A-007463

2017-12-19 Thread yinbo.zhu
From: yinbo.zhu 

When a transaction error (defined in Section 4.10.2.3, "USB
Transaction Error" of the xHCI Specification) occurs on the
USB, the host controller reports this through a transfer
event with the completion code "USB Transaction Error". When
this happens, the endpoint is placed in the Halted state. In
response, software must issue a Reset Endpoint command to
transition the endpoint to the Stopped state. In order to
restart the transfer, the driver can perform either of the
following:
a) Ring the doorbell again, which restarts the transfer from
   where it stopped, or
b) Issue a Set TR (Transfer Ring) Dequeue Pointer command
   for the endpoint to start the transfer form a different
   Transfer Ring pointer Consider the following
   scenario:
1. The xHCI driver prepares a control transfer read to one
   of the device's control endpoints;
2. During the IN data stage, a transaction error occurs on
   the USB, causing a transfer event with the completion
   code "USB Transaction Error";
3. The driver issues a Reset Endpoint command;
4. The driver rings the doorbell of the control endpoint to
   resume the transfer. In this scenario, the controller
   may reverse the direction of the data stage from IN to OUT.
   Instead of sending an ACK to the endpoint to poll for read
   data, it sends a Data Packet (DP) to the endpoint. It
   fetches the data from the data stage Transfer Request
   Block (TRB) that is being resumed, even though the data
   buffer is setup to receive data and not transmit it.
NOTE
This issue occurs only if the transaction error happens
during an IN data stage. There is no issue if the transaction
error happens during an OUT data stage.

Impact: When this issue occurs, the device likely responds in
one of the following ways:
a) The device responds with a STALL because the data stage
has unexpectedly changed directions. The controller then
generates a Stall Error transfer event, to which software
must issue a Reset Endpoint command followed by a Set TR
Dequeue Pointer command pointing to a new Setup TRB to clear
the STALL condition.
b) The device does not respond to the inverted data stage and
the transaction times out. The controller generates another
USB Transaction Error transfer event, to which software
likely performs a USB Reset to the device because it is
unresponsive. It is not expected that any of these recovery
steps will cause instability in the system because this
recovery is part of a standard xHCI driver and could happen
regardless of the defect. Another possible system-level
impact is that the controller attempts to read from the
memory location pointed at by the Data Stage TRB or a Normal
TRB chained to it. associated with this TRB is intended to be
written by the controller, but the controller reads from it
instead. Normally, this does not cause a problem. However, if
the system has some type of memory protection where this
unexpected read is treated as a bus error,
a problem. However, if the system has some type of memory
it may cause the system to become unstable or to crash.

Workaround: If a USB Transaction Error occurs during the IN
data phase of a control transfer, the driver must use the
Set TR Dequeue Pointer command to either restart the data
Phase or restart the entire control transfer from the
Setup phase.

Configs Affected:
LS1021-20-22A-R1.0, LS1021-20-22A-R2.007463

Signed-off-by: yinbo.zhu 
---
Change in v3:
Adjust the commit information.
Replace "(1<<32)" with BIT(32).
Update the DT properity description. 
Update erratum description in code comment. 
 drivers/usb/dwc3/core.c  |2 ++
 drivers/usb/dwc3/core.h  |2 ++
 drivers/usb/dwc3/host.c  |3 +++
 drivers/usb/host/xhci-plat.c |3 +++
 drivers/usb/host/xhci-ring.c |   28 +++-
 drivers/usb/host/xhci.h  |3 ++-
 6 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 0783250..6613bc0 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1055,6 +1055,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 
dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
"snps,tx_de_emphasis_quirk");
+   dwc->quirk_reverse_in_out = device_property_read_bool(dev,
+   "snps,quirk_reverse_in_out");
device_property_read_u8(dev, "snps,tx_de_emphasis",
_de_emphasis);
device_property_read_string(dev, "snps,hsphy_interface",
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 4a4a4c9..a263fdc 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -857,6 +857,7 @@ struct dwc3_scratchpad_array {
  * 1   - -3.5dB de-emphasis
  * 2   - No de-emphasis
  * 

[PATCH v4] arm64: dts: ls1088a: Add USB support

2017-10-25 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

Add USB support on ls1088ardb

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
Signed-off-by: Ran Wang <ran.wan...@nxp.com>
---
Change in v4:
- Change status from "enable" to "disabled" then enable it on 
dts file.
- Add the version history.
- Update the subject.

 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 20 
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 0f6fcda36b9e..a84b49ec76ec 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -118,6 +118,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index 33797b373674..64968def0890 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -385,6 +385,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.14.1



[PATCH v4] arm64: dts: ls1088a: Add USB support

2017-10-25 Thread yinbo.zhu
From: "yinbo.zhu" 

Add USB support on ls1088ardb

Signed-off-by: yinbo.zhu 
Signed-off-by: Ran Wang 
---
Change in v4:
- Change status from "enable" to "disabled" then enable it on 
dts file.
- Add the version history.
- Update the subject.

 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 20 
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 0f6fcda36b9e..a84b49ec76ec 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -118,6 +118,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index 33797b373674..64968def0890 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -385,6 +385,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.14.1



[PATCH v3] arm64: dts: ls1088a: Add USB support

2017-10-24 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

Fix the issue that usb is not detected on ls1088ardb

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
Signed-off-by: Ran Wang <ran.wan...@nxp.com>
---

Change in v3:
- Change status from "enable" to "disabled" then enable it on 
dts file. 
- Add the version history.

 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 20 
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 213abb72de93..6c3c3bc4b681 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -118,6 +118,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index c144d06a6e33..c23fede8cf5d 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -359,6 +359,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.14.1



[PATCH v3] arm64: dts: ls1088a: Add USB support

2017-10-24 Thread yinbo.zhu
From: "yinbo.zhu" 

Fix the issue that usb is not detected on ls1088ardb

Signed-off-by: yinbo.zhu 
Signed-off-by: Ran Wang 
---

Change in v3:
- Change status from "enable" to "disabled" then enable it on 
dts file. 
- Add the version history.

 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 20 
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 213abb72de93..6c3c3bc4b681 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -118,6 +118,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index c144d06a6e33..c23fede8cf5d 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -359,6 +359,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.14.1



[PATCH v1] usb: host: Implement workaround for Erratum A-007463

2017-09-20 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

When a transaction error (defined in Section 4.10.2.3, "USB
Transaction Error" of the xHCI Specification) occurs on the
USB, the host controller reports this through a transfer
event with the completion code "USB Transaction Error". When
this happens, the endpoint is placed in the Halted state.
In response, software must issue a Reset Endpoint command to
transition the endpoint to the Stopped state. In order to
restart the transfer, the driver can perform either of the
following:
• Ring the doorbell again, which restarts the transfer from
  where it stopped, or
• Issue a Set TR (Transfer Ring) Dequeue Pointer command for
  the endpoint to start the transfer from a different
  Transfer Ring pointer Consider the following scenario:
1. The xHCI driver prepares a control transfer read to one
   of the device's control endpoints;
2. During the IN data stage, a transaction error occurs on
   the USB, causing a transfer event with the completion
   code "USB Transaction Error";
3. The driver issues a Reset Endpoint command;
4. The driver rings the doorbell of the control endpoint to
   resume the transfer. In this scenario, the controller
   may reverse the direction of the data stage from IN to OUT.
   Instead of sending an ACK to the endpoint to poll for read
   data, it sends a Data Packet (DP) to the endpoint. It
   fetches the data from the data stage Transfer Request Block
   (TRB) that is being resumed, even though the data buffer is
   setup to receive data and not transmit it.
NOTE
This issue occurs only if the transaction error happens during
an IN data stage. There is no issue if the transaction error
happens during an OUT data stage.

Impact: When this issue occurs, the device likely responds in
one of the following ways:
• The device responds with a STALL because the data stage has
unexpectedly changed directions. The controller then generates
a Stall Error transfer event, to which software must issue a
Reset Endpoint command followed by a Set TR Dequeue Pointer
command pointing to a new Setup TRB to clear the STALL condition.
• The device does not respond to the inverted data stage and the
transaction times out. The controller generates another USB
Transaction Error transfer event, to which software likely
performs a USB Reset to the device because it is unresponsive.
It is not expected that any of these recovery steps will cause
instability in the system because this recovery is part of a
standard xHCI driver and could happen regardless of the defect.
Another possible system-level impact is that the controller
attempts to read from the memory location pointed at by the Data
Stage TRB or a Normal TRB chained to it. associated with this
TRB is intended to be written by the controller, but the
controller reads from it instead. Normally, this does not cause
a problem. However, if the system has some type of memory
protection where this unexpected read is treated as a bus error,
it may cause the system to become unstable or to crash.

Workaround: If a USB Transaction Error occurs during the IN
data phase of a control transfer, the driver must use the
Set TR Dequeue Pointer command to either restart the data
phase or restart the entire control transfer from the
Setup phase.

Configs Affected:
LS1021-20-22A-R1.0, LS1021-20-22A-R2.007463

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
 arch/arm/boot/dts/ls1021a.dtsi |  1 +
 drivers/usb/dwc3/core.c|  2 ++
 drivers/usb/dwc3/core.h|  2 ++
 drivers/usb/dwc3/host.c|  2 ++
 drivers/usb/host/xhci-plat.c   |  3 +++
 drivers/usb/host/xhci-ring.c   | 28 +++-
 drivers/usb/host/xhci.h|  3 ++-
 7 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index 7bb9df2c1460..9f76b2b82dce 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -683,6 +683,7 @@
dr_mode = "host";
snps,quirk-frame-length-adjustment = <0x20>;
snps,dis_rxdet_inp3_quirk;
+   snps,quirk_reverse_in_out;
};
 
pcie@340 {
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 03474d3575ab..e6a3be9280b1 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1031,6 +1031,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
_threshold);
dwc->usb3_lpm_capable = device_property_read_bool(dev,
"snps,usb3_lpm_capable");
+   dwc->quirk_reverse_in_out = device_property_read_bool(dev,
+   "snps,quirk_reverse_in_out");
 
dwc->disable_scramble_quirk = device_property_read_bool(dev,
"snps,disable_scramble_quirk&quo

[PATCH v1] usb: host: Implement workaround for Erratum A-007463

2017-09-20 Thread yinbo.zhu
From: "yinbo.zhu" 

When a transaction error (defined in Section 4.10.2.3, "USB
Transaction Error" of the xHCI Specification) occurs on the
USB, the host controller reports this through a transfer
event with the completion code "USB Transaction Error". When
this happens, the endpoint is placed in the Halted state.
In response, software must issue a Reset Endpoint command to
transition the endpoint to the Stopped state. In order to
restart the transfer, the driver can perform either of the
following:
• Ring the doorbell again, which restarts the transfer from
  where it stopped, or
• Issue a Set TR (Transfer Ring) Dequeue Pointer command for
  the endpoint to start the transfer from a different
  Transfer Ring pointer Consider the following scenario:
1. The xHCI driver prepares a control transfer read to one
   of the device's control endpoints;
2. During the IN data stage, a transaction error occurs on
   the USB, causing a transfer event with the completion
   code "USB Transaction Error";
3. The driver issues a Reset Endpoint command;
4. The driver rings the doorbell of the control endpoint to
   resume the transfer. In this scenario, the controller
   may reverse the direction of the data stage from IN to OUT.
   Instead of sending an ACK to the endpoint to poll for read
   data, it sends a Data Packet (DP) to the endpoint. It
   fetches the data from the data stage Transfer Request Block
   (TRB) that is being resumed, even though the data buffer is
   setup to receive data and not transmit it.
NOTE
This issue occurs only if the transaction error happens during
an IN data stage. There is no issue if the transaction error
happens during an OUT data stage.

Impact: When this issue occurs, the device likely responds in
one of the following ways:
• The device responds with a STALL because the data stage has
unexpectedly changed directions. The controller then generates
a Stall Error transfer event, to which software must issue a
Reset Endpoint command followed by a Set TR Dequeue Pointer
command pointing to a new Setup TRB to clear the STALL condition.
• The device does not respond to the inverted data stage and the
transaction times out. The controller generates another USB
Transaction Error transfer event, to which software likely
performs a USB Reset to the device because it is unresponsive.
It is not expected that any of these recovery steps will cause
instability in the system because this recovery is part of a
standard xHCI driver and could happen regardless of the defect.
Another possible system-level impact is that the controller
attempts to read from the memory location pointed at by the Data
Stage TRB or a Normal TRB chained to it. associated with this
TRB is intended to be written by the controller, but the
controller reads from it instead. Normally, this does not cause
a problem. However, if the system has some type of memory
protection where this unexpected read is treated as a bus error,
it may cause the system to become unstable or to crash.

Workaround: If a USB Transaction Error occurs during the IN
data phase of a control transfer, the driver must use the
Set TR Dequeue Pointer command to either restart the data
phase or restart the entire control transfer from the
Setup phase.

Configs Affected:
LS1021-20-22A-R1.0, LS1021-20-22A-R2.007463

Signed-off-by: yinbo.zhu 
---
 arch/arm/boot/dts/ls1021a.dtsi |  1 +
 drivers/usb/dwc3/core.c|  2 ++
 drivers/usb/dwc3/core.h|  2 ++
 drivers/usb/dwc3/host.c|  2 ++
 drivers/usb/host/xhci-plat.c   |  3 +++
 drivers/usb/host/xhci-ring.c   | 28 +++-
 drivers/usb/host/xhci.h|  3 ++-
 7 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index 7bb9df2c1460..9f76b2b82dce 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -683,6 +683,7 @@
dr_mode = "host";
snps,quirk-frame-length-adjustment = <0x20>;
snps,dis_rxdet_inp3_quirk;
+   snps,quirk_reverse_in_out;
};
 
pcie@340 {
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 03474d3575ab..e6a3be9280b1 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1031,6 +1031,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
_threshold);
dwc->usb3_lpm_capable = device_property_read_bool(dev,
"snps,usb3_lpm_capable");
+   dwc->quirk_reverse_in_out = device_property_read_bool(dev,
+   "snps,quirk_reverse_in_out");
 
dwc->disable_scramble_quirk = device_property_read_bool(dev,
"snps,disable_scramble_quirk");
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/

[PATCH v2] arm64: dts: ls1088a: Add USB support

2017-09-13 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

Fix the issue that usb is not detected on ls1088ardb

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
Signed-off-by: Ran Wang <ran.wan...@nxp.com>
---
 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 20 
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 213abb72de93..6c3c3bc4b681 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -118,6 +118,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index c144d06a6e33..c23fede8cf5d 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -359,6 +359,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.14.1



[PATCH v2] arm64: dts: ls1088a: Add USB support

2017-09-13 Thread yinbo.zhu
From: "yinbo.zhu" 

Fix the issue that usb is not detected on ls1088ardb

Signed-off-by: yinbo.zhu 
Signed-off-by: Ran Wang 
---
 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 20 
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 213abb72de93..6c3c3bc4b681 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -118,6 +118,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index c144d06a6e33..c23fede8cf5d 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -359,6 +359,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.14.1



[PATCH 2/2] usb: host: Implement workaround for Erratum A-009668

2017-09-11 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

Description: This issue is observed in USB 2.0 mode
 when the USB 3.0 host controller is connected to a
FS/LS device via a hub.
The host controller issues start-split (SSPLIT) and
complete-split (CSPLIT) tokens to
accomplish a split-transaction. A split-transaction
consists of a SSPLIT token, token/data
packets, CSPLIT token and token/data/handshake packets.
A SSPLIT token is issued by the host controller to the
hub followed by token/data/handshake packets. The hub
then relays the token/data/handshake packets to the FS
/LS device. Sometime later, the host controller issues
a CSPLIT token followed by the same token/data/handshake
packets to the hub to complete the split-transaction.
As an example scenario, when the xHCI driver issues an
Address device command with BSR=0, the host controller
sends SETUP(SET_ADDRESS) tokens on the USB as part of
splittransactions.
If the host controller receives a NYET response from the
hub for the CSPLIT SETUP token, it means that the
split-transaction has not yet been completed or the hub
is not able to handle the split transaction. In such a
case, the host controller keeps retrying the
splittransactions
until such time an ACK response is received from the hub
for the CSPLIT SETUP token. If the split-transactions do
not complete in a time bound manner, the xHCI driver may
issue a Stop Endpoint Command. The host controller does
not service the Stop Endpoint Command and eventually the
xHCI driver times out waiting for the Stop Endpoint Command
to complete.

Impact: Stop Endpoint Command does not complete.
Workaround: Instead of issuing a Stop Endpoint Command,
issue a Disable Slot Command with the corresponding slot
ID. Alternately, you can issue an Address Device Command
with BSR=1.

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
 drivers/usb/host/xhci.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 35f7821bc8b2..62d6135ad428 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1517,6 +1517,18 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
urb->dev->slot_id, ep_index, 0);
xhci_ring_cmd_db(xhci);
}
+
+   /*
+*A-009668: Stop Endpoint Command does not complete.
+*Workaround: Instead of issuing a Stop Endpoint Command,
+*issue a Disable Slot Command with the corresponding slot ID.
+*Alternately, you can issue an Address Device Command with
+*BSR=1
+*/
+   if (urb->dev->speed <= USB_SPEED_HIGH) {
+   xhci_queue_slot_control(xhci, command, TRB_DISABLE_SLOT,
+   urb->dev->slot_id);
+   }
}
 done:
spin_unlock_irqrestore(>lock, flags);
-- 
2.14.1



[PATCH 2/2] usb: host: Implement workaround for Erratum A-009668

2017-09-11 Thread yinbo.zhu
From: "yinbo.zhu" 

Description: This issue is observed in USB 2.0 mode
 when the USB 3.0 host controller is connected to a
FS/LS device via a hub.
The host controller issues start-split (SSPLIT) and
complete-split (CSPLIT) tokens to
accomplish a split-transaction. A split-transaction
consists of a SSPLIT token, token/data
packets, CSPLIT token and token/data/handshake packets.
A SSPLIT token is issued by the host controller to the
hub followed by token/data/handshake packets. The hub
then relays the token/data/handshake packets to the FS
/LS device. Sometime later, the host controller issues
a CSPLIT token followed by the same token/data/handshake
packets to the hub to complete the split-transaction.
As an example scenario, when the xHCI driver issues an
Address device command with BSR=0, the host controller
sends SETUP(SET_ADDRESS) tokens on the USB as part of
splittransactions.
If the host controller receives a NYET response from the
hub for the CSPLIT SETUP token, it means that the
split-transaction has not yet been completed or the hub
is not able to handle the split transaction. In such a
case, the host controller keeps retrying the
splittransactions
until such time an ACK response is received from the hub
for the CSPLIT SETUP token. If the split-transactions do
not complete in a time bound manner, the xHCI driver may
issue a Stop Endpoint Command. The host controller does
not service the Stop Endpoint Command and eventually the
xHCI driver times out waiting for the Stop Endpoint Command
to complete.

Impact: Stop Endpoint Command does not complete.
Workaround: Instead of issuing a Stop Endpoint Command,
issue a Disable Slot Command with the corresponding slot
ID. Alternately, you can issue an Address Device Command
with BSR=1.

Signed-off-by: yinbo.zhu 
---
 drivers/usb/host/xhci.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 35f7821bc8b2..62d6135ad428 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1517,6 +1517,18 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
urb->dev->slot_id, ep_index, 0);
xhci_ring_cmd_db(xhci);
}
+
+   /*
+*A-009668: Stop Endpoint Command does not complete.
+*Workaround: Instead of issuing a Stop Endpoint Command,
+*issue a Disable Slot Command with the corresponding slot ID.
+*Alternately, you can issue an Address Device Command with
+*BSR=1
+*/
+   if (urb->dev->speed <= USB_SPEED_HIGH) {
+   xhci_queue_slot_control(xhci, command, TRB_DISABLE_SLOT,
+   urb->dev->slot_id);
+   }
}
 done:
spin_unlock_irqrestore(>lock, flags);
-- 
2.14.1



[PATCH 1/2] usb: host: Implement workaround for Erratum A-009611

2017-09-11 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

Description: This is a occasional problem where the software
issues an End Transfer command while a USB transfer is in progress,
resulting in the TxFIFO  being flushed when the lower layer is waiting
for data,causing the super speed (SS) transmit to get blocked.
If the End Transfer command is issued on an IN endpoint to
flush out the pending transfers when the same IN endpoint
is doing transfers on the USB, then depending upon the timing
of the End Transfer (and the resulting internal FIFO flush),the
lower layer (U3PTL/U3MAC) could get stuck waiting for data
indefinitely. This blocks the transmission path on the SS, and no
DP/ACK/ERDY/DEVNOTIF packets can be sent from the device.
Impact: If this issue happens and the transmission gets blocked,
then the USB host aborts and resets/re-enumerates the device.
This unblocks the transmitt engine and the device functions normally.

Workaround: Software must wait for all existing TRBs to complete before
issuing End transfer command.

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
 drivers/usb/host/xhci.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2d6a98c1dc12..35f7821bc8b2 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1501,13 +1501,22 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
ret = -ENOMEM;
goto done;
}
-   ep->ep_state |= EP_STOP_CMD_PENDING;
-   ep->stop_cmd_timer.expires = jiffies +
-   XHCI_STOP_EP_CMD_TIMEOUT * HZ;
-   add_timer(>stop_cmd_timer);
-   xhci_queue_stop_endpoint(xhci, command, urb->dev->slot_id,
-ep_index, 0);
-   xhci_ring_cmd_db(xhci);
+
+   /*
+*A-009611: Issuing an End Transfer command on an IN endpoint.
+*when a transfer is in progress on USB blocks the transmission
+*Workaround: Software must wait for all existing TRBs to
+*complete before issuing End transfer command.
+*/
+   if (ep_ring->enqueue == ep_ring->dequeue) {
+   ep->ep_state |= EP_STOP_CMD_PENDING;
+   ep->stop_cmd_timer.expires = jiffies +
+   XHCI_STOP_EP_CMD_TIMEOUT * HZ;
+   add_timer(>stop_cmd_timer);
+   xhci_queue_stop_endpoint(xhci, command,
+   urb->dev->slot_id, ep_index, 0);
+   xhci_ring_cmd_db(xhci);
+   }
}
 done:
spin_unlock_irqrestore(>lock, flags);
-- 
2.14.1



[PATCH 1/2] usb: host: Implement workaround for Erratum A-009611

2017-09-11 Thread yinbo.zhu
From: "yinbo.zhu" 

Description: This is a occasional problem where the software
issues an End Transfer command while a USB transfer is in progress,
resulting in the TxFIFO  being flushed when the lower layer is waiting
for data,causing the super speed (SS) transmit to get blocked.
If the End Transfer command is issued on an IN endpoint to
flush out the pending transfers when the same IN endpoint
is doing transfers on the USB, then depending upon the timing
of the End Transfer (and the resulting internal FIFO flush),the
lower layer (U3PTL/U3MAC) could get stuck waiting for data
indefinitely. This blocks the transmission path on the SS, and no
DP/ACK/ERDY/DEVNOTIF packets can be sent from the device.
Impact: If this issue happens and the transmission gets blocked,
then the USB host aborts and resets/re-enumerates the device.
This unblocks the transmitt engine and the device functions normally.

Workaround: Software must wait for all existing TRBs to complete before
issuing End transfer command.

Signed-off-by: yinbo.zhu 
---
 drivers/usb/host/xhci.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2d6a98c1dc12..35f7821bc8b2 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1501,13 +1501,22 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
ret = -ENOMEM;
goto done;
}
-   ep->ep_state |= EP_STOP_CMD_PENDING;
-   ep->stop_cmd_timer.expires = jiffies +
-   XHCI_STOP_EP_CMD_TIMEOUT * HZ;
-   add_timer(>stop_cmd_timer);
-   xhci_queue_stop_endpoint(xhci, command, urb->dev->slot_id,
-ep_index, 0);
-   xhci_ring_cmd_db(xhci);
+
+   /*
+*A-009611: Issuing an End Transfer command on an IN endpoint.
+*when a transfer is in progress on USB blocks the transmission
+*Workaround: Software must wait for all existing TRBs to
+*complete before issuing End transfer command.
+*/
+   if (ep_ring->enqueue == ep_ring->dequeue) {
+   ep->ep_state |= EP_STOP_CMD_PENDING;
+   ep->stop_cmd_timer.expires = jiffies +
+   XHCI_STOP_EP_CMD_TIMEOUT * HZ;
+   add_timer(>stop_cmd_timer);
+   xhci_queue_stop_endpoint(xhci, command,
+   urb->dev->slot_id, ep_index, 0);
+   xhci_ring_cmd_db(xhci);
+   }
}
 done:
spin_unlock_irqrestore(>lock, flags);
-- 
2.14.1



[PATCH] arm64: dts: ls1088a: Add USB support

2017-08-18 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

Fix the issue that usb is not detected on ls1088ardb

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
Signed-off-by: Ran Wang <ran.wan...@nxp.com>
---
 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 20 
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 213abb7..6c3c3bc 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -118,6 +118,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index c144d06..c23fede 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -359,6 +359,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.1.0.27.g96db324



[PATCH] arm64: dts: ls1088a: Add USB support

2017-08-18 Thread yinbo.zhu
From: "yinbo.zhu" 

Fix the issue that usb is not detected on ls1088ardb

Signed-off-by: yinbo.zhu 
Signed-off-by: Ran Wang 
---
 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 20 
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index 213abb7..6c3c3bc 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -118,6 +118,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index c144d06..c23fede 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -359,6 +359,26 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+   dr_mode = "host";
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,dis_rxdet_inp3_quirk;
+   status = "disabled";
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.1.0.27.g96db324



[PATCH] arm64: dts: ls1088a: Add USB support

2017-08-16 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

Fix the issue that usb is not detected on ls1088ardb

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
Signed-off-by: Ran Wang <ran.wan...@nxp.com>
---
 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 18 ++
 2 files changed, 26 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index e9276a5..949cd67 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -145,6 +145,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index 3a3be87..0dbff29 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -458,6 +458,24 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 0x4>; /* Level high type */
+   dr_mode = "host";
+   configure-gfladj;
+   snps,dis_rxdet_inp3_quirk;
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 0x4>; /* Level high type */
+   dr_mode = "host";
+   configure-gfladj;
+   snps,dis_rxdet_inp3_quirk;
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.1.0.27.g96db324



[PATCH] arm64: dts: ls1088a: Add USB support

2017-08-16 Thread yinbo.zhu
From: "yinbo.zhu" 

Fix the issue that usb is not detected on ls1088ardb

Signed-off-by: yinbo.zhu 
Signed-off-by: Ran Wang 
---
 arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts |  8 
 arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi| 18 ++
 2 files changed, 26 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
index e9276a5..949cd67 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a-rdb.dts
@@ -145,6 +145,14 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
index 3a3be87..0dbff29 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
@@ -458,6 +458,24 @@
status = "disabled";
};
 
+   usb0: usb3@310 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x310 0x0 0x1>;
+   interrupts = <0 80 0x4>; /* Level high type */
+   dr_mode = "host";
+   configure-gfladj;
+   snps,dis_rxdet_inp3_quirk;
+   };
+
+   usb1: usb3@311 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0x311 0x0 0x1>;
+   interrupts = <0 81 0x4>; /* Level high type */
+   dr_mode = "host";
+   configure-gfladj;
+   snps,dis_rxdet_inp3_quirk;
+   };
+
sata: sata@320 {
compatible = "fsl,ls1088a-ahci";
reg = <0x0 0x320 0x0 0x1>,
-- 
2.1.0.27.g96db324



[PATCH 3/3] core-arm: add a member about dma_map_ops in dev_archdata struct

2017-08-11 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
 arch/arm/include/asm/device.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/device.h b/arch/arm/include/asm/device.h
index 220ba20..c93d3df 100644
--- a/arch/arm/include/asm/device.h
+++ b/arch/arm/include/asm/device.h
@@ -7,6 +7,7 @@
 #define ASMARM_DEVICE_H
 
 struct dev_archdata {
+const struct dma_map_ops*dma_ops;
 #ifdef CONFIG_DMABOUNCE
struct dmabounce_device_info *dmabounce;
 #endif
-- 
2.1.0.27.g96db324



[PATCH 3/3] core-arm: add a member about dma_map_ops in dev_archdata struct

2017-08-11 Thread yinbo.zhu
From: "yinbo.zhu" 

Signed-off-by: yinbo.zhu 
---
 arch/arm/include/asm/device.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/device.h b/arch/arm/include/asm/device.h
index 220ba20..c93d3df 100644
--- a/arch/arm/include/asm/device.h
+++ b/arch/arm/include/asm/device.h
@@ -7,6 +7,7 @@
 #define ASMARM_DEVICE_H
 
 struct dev_archdata {
+const struct dma_map_ops*dma_ops;
 #ifdef CONFIG_DMABOUNCE
struct dmabounce_device_info *dmabounce;
 #endif
-- 
2.1.0.27.g96db324



[PATCH 2/3] usb: dwc3 : Add support for USB snooping

2017-08-11 Thread yinbo.zhu
From: Rajesh Bhagat <rajesh.bha...@freescale.com>

Add support for USB3 snooping by asserting bits
in register DWC3_GSBUSCFG0 for data and descriptor

Signed-off-by: Nikhil Badola <nikhil.bad...@freescale.com>
Signed-off-by: Rajesh Bhagat <rajesh.bha...@freescale.com>
Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
 drivers/usb/dwc3/core.c | 71 -
 drivers/usb/dwc3/core.h |  3 +++
 drivers/usb/dwc3/host.c |  8 +-
 3 files changed, 63 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 02a534a..b51b0d8 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -90,6 +90,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
 
if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
mode = USB_DR_MODE_HOST;
+
else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
mode = USB_DR_MODE_PERIPHERAL;
}
@@ -305,14 +306,27 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)
  */
 static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
 {
-   struct dwc3_event_buffer *evt;
+   int num;
+   int i;
+
+   num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
+   dwc->num_event_buffers = num;
+
+   dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num,
+   GFP_KERNEL);
+   if (!dwc->ev_buffs)
+   return -ENOMEM;
 
-   evt = dwc3_alloc_one_event_buffer(dwc, length);
-   if (IS_ERR(evt)) {
-   dev_err(dwc->dev, "can't allocate event buffer\n");
-   return PTR_ERR(evt);
+   for (i = 0; i < num; i++) {
+   struct dwc3_event_buffer*evt;
+
+   evt = dwc3_alloc_one_event_buffer(dwc, length);
+   if (IS_ERR(evt)) {
+   dev_err(dwc->dev, "can't allocate event buffer\n");
+   return PTR_ERR(evt);
+   }
+   dwc->ev_buffs[i] = evt;
}
-   dwc->ev_buf = evt;
 
return 0;
 }
@@ -325,17 +339,25 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, 
unsigned length)
  */
 static int dwc3_event_buffers_setup(struct dwc3 *dwc)
 {
-   struct dwc3_event_buffer*evt;
-
-   evt = dwc->ev_buf;
-   evt->lpos = 0;
-   dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0),
-   lower_32_bits(evt->dma));
-   dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0),
-   upper_32_bits(evt->dma));
-   dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0),
-   DWC3_GEVNTSIZ_SIZE(evt->length));
-   dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
+   struct dwc3_event_buffer*evt;
+   int n;
+
+   for (n = 0; n < dwc->num_event_buffers; n++) {
+   evt = dwc->ev_buffs[n];
+   dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n",
+   evt->buf, (unsigned long long) evt->dma,
+   evt->length);
+
+   evt->lpos = 0;
+
+   dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n),
+   lower_32_bits(evt->dma));
+   dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n),
+   upper_32_bits(evt->dma));
+   dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n),
+   DWC3_GEVNTSIZ_SIZE(evt->length));
+   dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
+   }
 
return 0;
 }
@@ -1181,6 +1203,7 @@ static void dwc3_check_params(struct dwc3 *dwc)
 static int dwc3_probe(struct platform_device *pdev)
 {
struct device   *dev = >dev;
+   struct device_node  *node = dev->of_node;
struct resource *res;
struct dwc3 *dwc;
 
@@ -1188,7 +1211,6 @@ static int dwc3_probe(struct platform_device *pdev)
 
void __iomem*regs;
 
-   struct device_node  *node = dev->of_node;
dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
if (!dwc)
return -ENOMEM;
@@ -1260,6 +1282,19 @@ static int dwc3_probe(struct platform_device *pdev)
goto err2;
}
 
+   /* Change burst beat and outstanding pipelined transfers requests */
+   dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
+   (dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) & ~0xff) | 0xf);
+   dwc3_writel(dwc->regs, DWC3_GSBUSCFG1,
+   dwc3_readl(dwc->regs, DWC3_GSBUSCFG1) | 0xf00);
+
+   /* Enable Snooping */
+   if (node && of_dma_is_coherent(node)) {
+   dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
+   dwc3_readl(dwc->regs, DWC3_GSBUS

[PATCH 2/3] usb: dwc3 : Add support for USB snooping

2017-08-11 Thread yinbo.zhu
From: Rajesh Bhagat 

Add support for USB3 snooping by asserting bits
in register DWC3_GSBUSCFG0 for data and descriptor

Signed-off-by: Nikhil Badola 
Signed-off-by: Rajesh Bhagat 
Signed-off-by: yinbo.zhu 
---
 drivers/usb/dwc3/core.c | 71 -
 drivers/usb/dwc3/core.h |  3 +++
 drivers/usb/dwc3/host.c |  8 +-
 3 files changed, 63 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 02a534a..b51b0d8 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -90,6 +90,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
 
if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
mode = USB_DR_MODE_HOST;
+
else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
mode = USB_DR_MODE_PERIPHERAL;
}
@@ -305,14 +306,27 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)
  */
 static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
 {
-   struct dwc3_event_buffer *evt;
+   int num;
+   int i;
+
+   num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
+   dwc->num_event_buffers = num;
+
+   dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num,
+   GFP_KERNEL);
+   if (!dwc->ev_buffs)
+   return -ENOMEM;
 
-   evt = dwc3_alloc_one_event_buffer(dwc, length);
-   if (IS_ERR(evt)) {
-   dev_err(dwc->dev, "can't allocate event buffer\n");
-   return PTR_ERR(evt);
+   for (i = 0; i < num; i++) {
+   struct dwc3_event_buffer*evt;
+
+   evt = dwc3_alloc_one_event_buffer(dwc, length);
+   if (IS_ERR(evt)) {
+   dev_err(dwc->dev, "can't allocate event buffer\n");
+   return PTR_ERR(evt);
+   }
+   dwc->ev_buffs[i] = evt;
}
-   dwc->ev_buf = evt;
 
return 0;
 }
@@ -325,17 +339,25 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, 
unsigned length)
  */
 static int dwc3_event_buffers_setup(struct dwc3 *dwc)
 {
-   struct dwc3_event_buffer*evt;
-
-   evt = dwc->ev_buf;
-   evt->lpos = 0;
-   dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0),
-   lower_32_bits(evt->dma));
-   dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0),
-   upper_32_bits(evt->dma));
-   dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0),
-   DWC3_GEVNTSIZ_SIZE(evt->length));
-   dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
+   struct dwc3_event_buffer*evt;
+   int n;
+
+   for (n = 0; n < dwc->num_event_buffers; n++) {
+   evt = dwc->ev_buffs[n];
+   dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n",
+   evt->buf, (unsigned long long) evt->dma,
+   evt->length);
+
+   evt->lpos = 0;
+
+   dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n),
+   lower_32_bits(evt->dma));
+   dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n),
+   upper_32_bits(evt->dma));
+   dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n),
+   DWC3_GEVNTSIZ_SIZE(evt->length));
+   dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
+   }
 
return 0;
 }
@@ -1181,6 +1203,7 @@ static void dwc3_check_params(struct dwc3 *dwc)
 static int dwc3_probe(struct platform_device *pdev)
 {
struct device   *dev = >dev;
+   struct device_node  *node = dev->of_node;
struct resource *res;
struct dwc3 *dwc;
 
@@ -1188,7 +1211,6 @@ static int dwc3_probe(struct platform_device *pdev)
 
void __iomem*regs;
 
-   struct device_node  *node = dev->of_node;
dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
if (!dwc)
return -ENOMEM;
@@ -1260,6 +1282,19 @@ static int dwc3_probe(struct platform_device *pdev)
goto err2;
}
 
+   /* Change burst beat and outstanding pipelined transfers requests */
+   dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
+   (dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) & ~0xff) | 0xf);
+   dwc3_writel(dwc->regs, DWC3_GSBUSCFG1,
+   dwc3_readl(dwc->regs, DWC3_GSBUSCFG1) | 0xf00);
+
+   /* Enable Snooping */
+   if (node && of_dma_is_coherent(node)) {
+   dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
+   dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) | 0x);
+   dev_dbg(dev, "enabled snooping for usb\n");
+   }
+
ret = dwc3_get_dr

[PATCH 1/3] dts: usb3: Add configure-gfladj property to USB3 nod

2017-08-11 Thread yinbo.zhu
From: "yinbo.zhu" <yinbo@nxp.com>

Signed-off-by: yinbo.zhu <yinbo@nxp.com>
---
 arch/arm/boot/dts/ls1021a.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index ffbf3cf..f525297 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -731,6 +731,8 @@
interrupts = ;
dr_mode = "host";
snps,quirk-frame-length-adjustment = <0x20>;
+   configure-gfladj;
+   dma-coherent;
snps,dis_rxdet_inp3_quirk;
};
 
-- 
2.1.0.27.g96db324



[PATCH 1/3] dts: usb3: Add configure-gfladj property to USB3 nod

2017-08-11 Thread yinbo.zhu
From: "yinbo.zhu" 

Signed-off-by: yinbo.zhu 
---
 arch/arm/boot/dts/ls1021a.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index ffbf3cf..f525297 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -731,6 +731,8 @@
interrupts = ;
dr_mode = "host";
snps,quirk-frame-length-adjustment = <0x20>;
+   configure-gfladj;
+   dma-coherent;
snps,dis_rxdet_inp3_quirk;
};
 
-- 
2.1.0.27.g96db324