Skip to contentSkip to conversation

usb: dwc3: add support for AMD NL SoC

PATCH Superseded Huang Rui 4 participants 51 messages Oct 17, 2014 – Oct 27, 2014

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Huang Rui

author
#0 lore raw

v2 cover usb: dwc3: add support for AMD NL SoC

Hi,

The series of patches add AMD NL SoC support for DesignWare USB3 OTG IP with PCI bus glue layer. This controller supported hibernation, LPM erratum and used the 2.80a IP version and amd own phy. Current implementation support both simulation and SoC platform. And already tested with gadget zero and msc tool. It works well on file storage gadget.

These patches are generated on balbi/testing/next

Changes from v1 -> v2
- remove dual role function temporarily
- add pci quirk to avoid to bind with xhci driver
- distinguish between simulation board and soc
- break down all the special quirks

Patch 1:
- add PCI device id into pci bus glue

Patch 2:
- add PCI quirk to avoid to bind with xhci

Patch 3:
- enable hibernation

Patch 4:
- distinguish between simulation board and soc

Patch 5:
- add quirks flag to be compatible for kinds of soc

Patch 6 - 16:
- as felipe's suggestion, break down all the special quirks of amd nl

Patch set already passed all the MSC testing, detailed result is below:

root@hr-ub:/home/ray/felipe/usb-tools# ./msc.sh -o /dev/sdb1
Starting test suite: 2014年 10月 09日 星期四 18:02:41 CST
test 0a: simple 4k read/write
test  0: sent       3.91 MB read       0.03 MB/s write       0.03 MB/s ... success
test 0b: simple 8k read/write
test  0: sent       7.81 MB read       6.15 MB/s write       5.96 MB/s ... success
test 0c: simple 16k read/write
test  0: sent      15.62 MB read      14.30 MB/s write      12.97 MB/s ... success
test 0d: simple 32k read/write
test  0: sent      31.25 MB read      18.26 MB/s write      17.10 MB/s ... success
test 0e: simple 64k read/write
test  0: sent      62.50 MB read      22.00 MB/s write      16.33 MB/s ... success
test 1: simple 1-sector read/write
test  1: sent     500.00 kB read       1.05 MB/s write       0.93 MB/s ... success
test 2: simple 8-sectors read/write
test  2: sent       3.91 MB read       6.52 MB/s write       6.10 MB/s ... success
test 3: simple 32-sectors read/write
test  3: sent      15.62 MB read      14.33 MB/s write      13.14 MB/s ... success
test 4: simple 64-sectors read/write
test  4: sent      31.25 MB read      17.79 MB/s write      16.38 MB/s ... success
test 5a: scatter/gather for 2-sectors buflen 4k
test  5: sent    1000.00 kB read       1.85 MB/s write       1.56 MB/s ... success
test 5b: scatter/gather for 2-sectors buflen 8k
test  5: sent    1000.00 kB read       1.91 MB/s write       1.63 MB/s ... success
test 5c: scatter/gather for 2-sectors buflen 16k
test  5: sent    1000.00 kB read       1.94 MB/s write       1.62 MB/s ... success
test 5d: scatter/gather for 2-sectors buflen 32k
test  5: sent    1000.00 kB read       1.93 MB/s write       1.64 MB/s ... success
test 5e: scatter/gather for 2-sectors buflen 64k
test  5: sent    1000.00 kB read       1.96 MB/s write       1.68 MB/s ... success
test 6a: scatter/gather for 8-sectors buflen 4k
test  6: sent       3.91 MB read       6.53 MB/s write       6.05 MB/s ... success
test 6b: scatter/gather for 8-sectors buflen 8k
test  6: sent       3.91 MB read       6.56 MB/s write       5.98 MB/s ... success
test 6c: scatter/gather for 8-sectors buflen 16k
test  6: sent       3.91 MB read       6.55 MB/s write       6.15 MB/s ... success
test 6d: scatter/gather for 8-sectors buflen 32k
test  6: sent       3.91 MB read       6.51 MB/s write       6.06 MB/s ... success
test 6e: scatter/gather for 8-sectors buflen 64k
test  6: sent       3.91 MB read       6.50 MB/s write       6.06 MB/s ... success
test 7a: scatter/gather for 32-sectors buflen 16k
test  7: sent      15.62 MB read      14.23 MB/s write      12.99 MB/s ... success
test 7b: scatter/gather for 32-sectors buflen 32k
test  7: sent      15.62 MB read      14.27 MB/s write      12.91 MB/s ... success
test 7c: scatter/gather for 32-sectors buflen 64k
test  7: sent      15.62 MB read      14.73 MB/s write      13.00 MB/s ... success
test 8a: scatter/gather for 64-sectors buflen 32k
test  8: sent      31.25 MB read      18.42 MB/s write      16.65 MB/s ... success
test 8b: scatter/gather for 64-sectors buflen 64k
test  8: sent      31.25 MB read      17.70 MB/s write      16.39 MB/s ... success
test 9: scatter/gather for 128-sectors buflen 64k
test  9: sent      62.50 MB read      21.14 MB/s write      16.07 MB/s ... success
test 10: read over the end of the block device
test 10: sent      62.01 MB read       0.00 MB/s write       0.00 MB/s ... success
test 11: lseek past the end of the block device
test 11: sent       0.00 B read       0.00 MB/s write       0.00 MB/s ... success
test 12: write over the end of the block device
test 12: sent       0.00 B read       0.00 MB/s write       0.00 MB/s ... success
test 13: write 1 sg, read 8 random size sgs
test 13: sent      62.50 MB read      21.61 MB/s write      16.21 MB/s ... success
test 14: write 8 random size sgs, read 1 sg
test 14: sent      62.50 MB read      22.52 MB/s write      18.61 MB/s ... success
test 15: write and read 8 random size sgs
test 15: sent      62.50 MB read      22.31 MB/s write      19.28 MB/s ... success
test 16a: read with heap allocated buffer
test 16: sent      62.50 MB read      21.69 MB/s write       0.00 MB/s ... success
test 16b: read with stack allocated buffer
test 16: sent      62.50 MB read      21.42 MB/s write       0.00 MB/s ... success
test 17a: write with heap allocated buffer
test 17: sent       0.00 B read       0.00 MB/s write      19.94 MB/s ... success
test 17b: write with stack allocated buffer
test 17: sent       0.00 B read       0.00 MB/s write      20.09 MB/s ... success
test 18a: write 0x00 and read it back
test 18: sent      62.50 MB read      21.94 MB/s write      16.96 MB/s ... success
test 18b: write 0xff and read it back
test 18: sent      62.50 MB read      19.89 MB/s write      15.51 MB/s ... success
test 18c: write 0x55 and read it back
test 18: sent      62.50 MB read      22.00 MB/s write      16.62 MB/s ... success
test 18d: write 0xaa and read it back
test 18: sent      62.50 MB read      21.81 MB/s write      16.53 MB/s ... success
test 18e: write 0x11 and read it back
test 18: sent      62.50 MB read      22.33 MB/s write      17.00 MB/s ... success
test 18f: write 0x22 and read it back
test 18: sent      62.50 MB read      21.66 MB/s write      16.44 MB/s ... success
test 18g: write 0x44 and read it back
test 18: sent      62.50 MB read      22.23 MB/s write      17.08 MB/s ... success
test 18h: write 0x88 and read it back
test 18: sent      62.50 MB read      21.54 MB/s write      16.17 MB/s ... success
test 18i: write 0x33 and read it back
test 18: sent      62.50 MB read      21.20 MB/s write      16.58 MB/s ... success
test 18j: write 0x66 and read it back
test 18: sent      62.50 MB read      21.82 MB/s write      16.13 MB/s ... success
test 18k: write 0x99 and read it back
test 18: sent      62.50 MB read      21.92 MB/s write      16.36 MB/s ... success
test 18l: write 0xcc and read it back
test 18: sent      62.50 MB read      22.37 MB/s write      16.74 MB/s ... success
test 18m: write 0x77 and read it back
test 18: sent      62.50 MB read      22.34 MB/s write      16.24 MB/s ... success
test 18n: write 0xbb and read it back
test 18: sent      62.50 MB read      21.82 MB/s write      16.23 MB/s ... success
test 18o: write 0xdd and read it back
test 18: sent      62.50 MB read      21.38 MB/s write      16.48 MB/s ... success
test 18p: write 0xee and read it back
test 18: sent      62.50 MB read      22.33 MB/s write      16.15 MB/s ... success
Test suite ended: 2014年 10月 09日 星期四 18:13:36 CST

Thanks,
Rui

Huang Rui (16):
usb: dwc3: add AMD NL support
pci: quirks: add quirk to avoid AMD NL to bind with xhci
usb: dwc3: enable hibernation if to be supported
usb: dwc3: add a flag to check if it is fpga board
usb: dwc3: add quirks support to be compatible for kinds of SoCs
usb: dwc3: add disscramble quirk
usb: dwc3: add lpm erratum support
usb: dwc3: add u2exit lfps quirk
usb: dwc3: add P3 in U2 SS inactive quirk
usb: dwc3: add request p1p2p3 quirk
usb: dwc3: add delay p1p2p3 quirk
usb: dwc3: add delay phy power change quirk
usb: dwc3: add lfps filter quirk
usb: dwc3: enable rx_detect to polling lfps quirk
usb: dwc3: add tx demphasis quirk
usb: dwc3: enable usb suspend phy

 drivers/pci/quirks.c             | 20 ++++++++++++
 drivers/usb/dwc3/core.c          | 66 +++++++++++++++++++++++++++++++++++++++-
 drivers/usb/dwc3/core.h          | 42 +++++++++++++++++++------
 drivers/usb/dwc3/dwc3-pci.c      | 26 ++++++++++++++++
 drivers/usb/dwc3/gadget.c        |  7 +++++
 drivers/usb/dwc3/platform_data.h | 16 ++++++++++
 6 files changed, 167 insertions(+), 10 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v2 1/16 usb: dwc3: add AMD NL support

Add PCI device ID of AMD NL SoC.

---
 drivers/usb/dwc3/dwc3-pci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/dwc3/dwc3-pci.c +2 -0
index a36cf66..3806547 100644
@@ -31,6 +31,7 @@
 #define PCI_DEVICE_ID_INTEL_BYT		0x0f37
 #define PCI_DEVICE_ID_INTEL_MRFLD	0x119e
 #define PCI_DEVICE_ID_INTEL_BSW		0x22B7
+#define PCI_DEVICE_ID_AMD_NL		0x7912
 
 struct dwc3_pci {
 	struct device		*dev;
@@ -185,6 +186,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BSW), },
 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL), },
 	{  }	/* Terminating Entry */
 };
 MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v2 01/16] usb: dwc3: add AMD NL support

HI,

Quoted 3 lines · Huang Rui

Add PCI device ID of AMD NL SoC.

this should be the last patch in the series, with all quirk flags already in place. This avoids bisection points where AMD's platform won't work.

Signature · 1 line
balbi
author
#3 lore raw

PATCH v2 2/16 pci: quirks: add quirk to avoid AMD NL to bind with xhci

In reply to Huang Rui

The dwc3 controller is the PCI-E device in AMD NL platform, but the class code of PCI header is 0x0c0330, the same with xHC. That's because it needs to meet the windows enviroment. The dwc3 controller acted as only host mode to bind with windows xhci driver.
But on linux, sometimes, it would auto-bind with xhci driver as well (class code 0x0c0330) despite it uses Pid/Vid on dwc3 driver.

Heikki suggested to use the quirk to fix this issue, and the detailed discussion is at below thread:
http://marc.info/?l=linux-usb&m=141197934712824&w=2

---
 drivers/pci/quirks.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/pci/quirks.c +20 -0
index 90acb32..3c911b7 100644
@@ -378,6 +378,26 @@ static void quirk_ati_exploding_mce(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI,	PCI_DEVICE_ID_ATI_RS100,   quirk_ati_exploding_mce);
 
+/* FIXME should define in <linux/pci_ids.h> */
+#define PCI_DEVICE_ID_AMD_NL	0x7912
+
+/*
+ * AMD NL SoC 7912 PCI device is dwc3 controller, but the class code of PCI
+ * header is 0x0c0330, the same with xHC. That's because it need to meet the
+ * windows enviroment. The dwc3 controller acted as only host mode to bind with
+ * windows xhci driver. But on linux, sometimes, we auto-bind with xhci driver
+ * as well (class code 0x0c0330) despite we use Pid/Vid on dwc3 driver. So this
+ * quirk used a dummy class code to avoid to bind with xhci driver at booting
+ * phase.
+ */
+static void quirk_amd_nl_class(struct pci_dev *pdev)
+{
+	/* Use a dummy class value instead of PCI header provided */
+	pdev->class = 0x0c03fe;
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL,
+		quirk_amd_nl_class);
+
 /*
  * Let's make the southbridge information explicit instead
  * of having to worry about people probing the ACPI areas,
Signature · 1 line
1.9.1
maintainer
#4 lore raw

Re: [PATCH v2 02/16] pci: quirks: add quirk to avoid AMD NL to bind with xhci

Quoted 6 lines · Huang Rui

The dwc3 controller is the PCI-E device in AMD NL platform, but the class code of PCI header is 0x0c0330, the same with xHC. That's because it needs to meet the windows enviroment. The dwc3 controller acted as only host mode to bind with windows xhci driver.
But on linux, sometimes, it would auto-bind with xhci driver as well (class code 0x0c0330) despite it uses Pid/Vid on dwc3 driver.

This changelog really doesn't make any sense unless the reader already knows everything. I think you mean something like this:

The AMD NL (please explain what "NL" is; Google has no clue) SoC contains a DesignWare USB3 Dual-Role Device that can be operated either as a USB Host or a USB Device. In the AMD NL platform, this device ([1022:7912]) has a class code of PCI_CLASS_SERIAL_USB_XHCI (0x0c0330), which means the xhci driver will claim it.

But the dwc3 driver is a more specific driver for this device, and we'd prefer to use it instead of xhci. To prevent xhci from claiming the device, change the class code to 0x0c03fe, which the PCI r3.0 spec defines as "USB device (not host controller)". The dwc3 driver can then claim it based on its Vendor and Device ID.

Obviously, this means the device won't work at all unless dwc3 is enabled. Previously, it probably would work as a host controller with the xhci driver. I assume this change is what you want.

Quoted 3 lines

Heikki suggested to use the quirk to fix this issue, and the detailed discussion is at below thread:
http://marc.info/?l=linux-usb&m=141197934712824&w=2

This changelog needs to be wrapped so no line is longer than 75 characters.

Please run "git log --oneline --no-merges drivers/pci/quirks.c" and make your subject line match the rest. In particular, "PCI" (not "pci"), drop the "quirks:" part, and capitalize "Add".

Quoted 12 lines
---
 drivers/pci/quirks.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/pci/quirks.c +0 -0
index 90acb32..3c911b7 100644

drivers/pci/quirks.c static void quirk_ati_exploding_mce(struct pci_dev *dev) · line 382

Quoted 5 lines
drivers/pci/quirks.c +2 -0
@@ -378,6 +378,26 @@ static void quirk_ati_exploding_mce(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI,	PCI_DEVICE_ID_ATI_RS100,   quirk_ati_exploding_mce);
 
+/* FIXME should define in <linux/pci_ids.h> */
+#define PCI_DEVICE_ID_AMD_NL	0x7912

If you KNOW this should be in linux/pci_ids.h (and it looks like it COULD go there, since you do use the same definition in patch [01/16]), why don't you just do it? Why are you wasting our time reviewing trivial stuff like this?

drivers/pci/quirks.c static void quirk_ati_exploding_mce(struct pci_dev *dev) · line 395

Quoted 13 lines
drivers/pci/quirks.c +13 -0
+
+/*
+ * AMD NL SoC 7912 PCI device is dwc3 controller, but the class code of PCI
+ * header is 0x0c0330, the same with xHC. That's because it need to meet the
+ * windows enviroment. The dwc3 controller acted as only host mode to bind with
+ * windows xhci driver. But on linux, sometimes, we auto-bind with xhci driver
+ * as well (class code 0x0c0330) despite we use Pid/Vid on dwc3 driver. So this
+ * quirk used a dummy class code to avoid to bind with xhci driver at booting
+ * phase.
+ */
+static void quirk_amd_nl_class(struct pci_dev *pdev)
+{
+	/* Use a dummy class value instead of PCI header provided */

When you say "dummy class value," that makes it sound like you just chose a random invalid value. But this value is actually defined by the spec, so you should use the description from the spec, namely, "USB device (not host controller)".

Bjorn

Quoted 11 lines
drivers/pci/quirks.c +5 -0
+	pdev->class = 0x0c03fe;
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL,
+		quirk_amd_nl_class);
+
 /*
  * Let's make the southbridge information explicit instead
  * of having to worry about people probing the ACPI areas,
Signature · 1 line
1.9.1
author
#5 lore raw

Re: [PATCH v2 02/16] pci: quirks: add quirk to avoid AMD NL to bind with xhci

Quoted 23 lines · Bjorn Helgaas
Quoted 6 lines · Huang Rui

The dwc3 controller is the PCI-E device in AMD NL platform, but the class code of PCI header is 0x0c0330, the same with xHC. That's because it needs to meet the windows enviroment. The dwc3 controller acted as only host mode to bind with windows xhci driver.
But on linux, sometimes, it would auto-bind with xhci driver as well (class code 0x0c0330) despite it uses Pid/Vid on dwc3 driver.

This changelog really doesn't make any sense unless the reader already knows everything. I think you mean something like this:

The AMD NL (please explain what "NL" is; Google has no clue) SoC contains a DesignWare USB3 Dual-Role Device that can be operated either as a USB Host or a USB Device. In the AMD NL platform, this device ([1022:7912]) has a class code of PCI_CLASS_SERIAL_USB_XHCI (0x0c0330), which means the xhci driver will claim it.

But the dwc3 driver is a more specific driver for this device, and we'd prefer to use it instead of xhci. To prevent xhci from claiming the device, change the class code to 0x0c03fe, which the PCI r3.0 spec defines as "USB device (not host controller)". The dwc3 driver can then claim it based on its Vendor and Device ID.

Quoted 4 lines

Obviously, this means the device won't work at all unless dwc3 is enabled. Previously, it probably would work as a host controller with the xhci driver. I assume this change is what you want.

OK, I will update to this changelog in V3.

Quoted 10 lines
Quoted 3 lines

Heikki suggested to use the quirk to fix this issue, and the detailed discussion is at below thread:
http://marc.info/?l=linux-usb&m=141197934712824&w=2

This changelog needs to be wrapped so no line is longer than 75 characters.

Please run "git log --oneline --no-merges drivers/pci/quirks.c" and make your subject line match the rest. In particular, "PCI" (not "pci"), drop the "quirks:" part, and capitalize "Add".

I got it, will update subject.

Quoted 15 lines
Quoted 15 lines
---
 drivers/pci/quirks.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/pci/quirks.c +0 -0
index 90acb32..3c911b7 100644
@@ -378,6 +378,26 @@ static void quirk_ati_exploding_mce(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI,	PCI_DEVICE_ID_ATI_RS100,   quirk_ati_exploding_mce);
 
Quoted 8 lines

drivers/pci/quirks.c static void quirk_ati_exploding_mce(struct pci_dev *dev) · line 382

Quoted 2 lines
drivers/pci/quirks.c +2 -0
+/* FIXME should define in <linux/pci_ids.h> */
+#define PCI_DEVICE_ID_AMD_NL	0x7912

If you KNOW this should be in linux/pci_ids.h (and it looks like it COULD go there, since you do use the same definition in patch [01/16]), why don't you just do it? Why are you wasting our time reviewing trivial stuff like this?

Apology, I was told that it could not add device id into pci_ids.h from my buddy with below thread discussion last year, but I don't confirm at current. I check the git log at pci_ids.h, it looks like it's able to add device id marco again, is that right?

http://marc.info/?l=linux-pci&m=137028614924258&w=2

If I misunderstand your meaning, please correct me.

Quoted 10 lines
Quoted 10 lines
drivers/pci/quirks.c +10 -0
+
+/*
+ * AMD NL SoC 7912 PCI device is dwc3 controller, but the class code of PCI
+ * header is 0x0c0330, the same with xHC. That's because it need to meet the
+ * windows enviroment. The dwc3 controller acted as only host mode to bind with
+ * windows xhci driver. But on linux, sometimes, we auto-bind with xhci driver
+ * as well (class code 0x0c0330) despite we use Pid/Vid on dwc3 driver. So this
+ * quirk used a dummy class code to avoid to bind with xhci driver at booting
+ * phase.
+ */
Quoted 9 lines

drivers/pci/quirks.c static void quirk_ati_exploding_mce(struct pci_dev *dev) · line 395

Quoted 3 lines
drivers/pci/quirks.c +3 -0
+static void quirk_amd_nl_class(struct pci_dev *pdev)
+{
+	/* Use a dummy class value instead of PCI header provided */

When you say "dummy class value," that makes it sound like you just chose a random invalid value. But this value is actually defined by the spec, so you should use the description from the spec, namely, "USB device (not host controller)".

Yes, you're right. Will change this description.

Thanks,
Rui

maintainer
#6 lore raw

Re: [PATCH v2 02/16] pci: quirks: add quirk to avoid AMD NL to bind with xhci

Quoted 12 lines · Huang Rui
Quoted 10 lines · Bjorn Helgaas

drivers/pci/quirks.c static void quirk_ati_exploding_mce(struct pci_dev *dev) · line 382

Quoted 2 lines · Huang Rui
drivers/pci/quirks.c +2 -0
+/* FIXME should define in <linux/pci_ids.h> */
+#define PCI_DEVICE_ID_AMD_NL       0x7912

If you KNOW this should be in linux/pci_ids.h (and it looks like it COULD go there, since you do use the same definition in patch [01/16]), why don't you just do it? Why are you wasting our time reviewing trivial stuff like this?

Quoted 8 lines

Apology, I was told that it could not add device id into pci_ids.h from my buddy with below thread discussion last year, but I don't confirm at current. I check the git log at pci_ids.h, it looks like it's able to add device id marco again, is that right?

http://marc.info/?l=linux-pci&m=137028614924258&w=2

If I misunderstand your meaning, please correct me.

Just read the text at the beginning of pci_ids.h.

If you have to use the same ID in two different files, you should add it to pci_ids.h.

author
#7 lore raw

PATCH v2 3/16 usb: dwc3: enable hibernation if to be supported

In reply to Huang Rui

It enables hibernation if the function is set in coreConsultant.

---
 drivers/usb/dwc3/core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/dwc3/core.c +1 -0
index fa396fc..bf77509 100644
@@ -449,6 +449,7 @@ static int dwc3_core_init(struct dwc3 *dwc)
 	case DWC3_GHWPARAMS1_EN_PWROPT_HIB:
 		/* enable hibernation here */
 		dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4);
+		reg |= DWC3_GCTL_GBLHIBERNATIONEN;
 		break;
 	default:
 		dev_dbg(dwc->dev, "No power optimization available\n");
Signature · 1 line
1.9.1
author
#8 lore raw

PATCH v2 4/16 usb: dwc3: add a flag to check if it is fpga board

In reply to Huang Rui

Some chip vendor is on pre-silicon phase, which needs to use the simulation board. It should have the same product and vendor id with the true soc, but might have some minor different configurations.

Below thread discussion proposes to find a method to distinguish between simulation board and soc.

http://marc.info/?l=linux-usb&m=141194772206369&w=2

In Andvanced Configuration of coreConsultant, there is the parameter of DWC_USB_EN_FPGA. This bit has the function we need. And it would response as 7 bit of GHWPARAMS6 register. So it's able to check this functional bit to confirm if works on FPGA board.

---
 drivers/usb/dwc3/core.c | 6 ++++++
 drivers/usb/dwc3/core.h | 5 +++++
 2 files changed, 11 insertions(+)
drivers/usb/dwc3/core.c +6 -0
index bf77509..ddac372 100644
@@ -455,6 +455,12 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		dev_dbg(dwc->dev, "No power optimization available\n");
 	}
 
+	/* check if current dwc3 is on simulation board */
+	if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) {
+		dev_dbg(dwc->dev, "it is on FPGA board\n");
+		dwc->is_fpga = true;
+	}
+
 	/*
 	 * WORKAROUND: DWC3 revisions <1.90a have a bug
 	 * where the device can fail to connect at SuperSpeed
drivers/usb/dwc3/core.h +5 -0
index a715ee1..f6ee623 100644
@@ -210,6 +210,9 @@
 #define DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(n)	(((n) & (0x0f << 13)) >> 13)
 #define DWC3_MAX_HIBER_SCRATCHBUFS		15
 
+/* Global HWPARAMS6 Register */
+#define DWC3_GHWPARAMS6_EN_FPGA			(1 << 7)
+
 /* Device Configuration Register */
 #define DWC3_DCFG_DEVADDR(addr)	((addr) << 3)
 #define DWC3_DCFG_DEVADDR_MASK	DWC3_DCFG_DEVADDR(0x7f)
@@ -662,6 +665,7 @@ struct dwc3_scratchpad_array {
  * @ep0_expect_in: true when we expect a DATA IN transfer
  * @has_hibernation: true when dwc3 was configured with Hibernation
  * @is_selfpowered: true when we are selfpowered
+ * @is_fpga: true when we are using the FPGA board
  * @needs_fifo_resize: not all users might want fifo resizing, flag it
  * @pullups_connected: true when Run/Stop bit is set
  * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes.
@@ -765,6 +769,7 @@ struct dwc3 {
 	unsigned		ep0_expect_in:1;
 	unsigned		has_hibernation:1;
 	unsigned		is_selfpowered:1;
+	unsigned		is_fpga:1;
 	unsigned		needs_fifo_resize:1;
 	unsigned		pullups_connected:1;
 	unsigned		resize_fifos:1;
Signature · 1 line
1.9.1
author
#9 lore raw

PATCH v2 5/16 usb: dwc3: add quirks support to be compatible for kinds of SoCs

In reply to Huang Rui

This patch adds a quirks flag at dwc3 structure, and SoCs platform vendor is able to define this flag in platform data at bus glue layer. Then do some independent behaviors at dwc3 core level.

---
 drivers/usb/dwc3/core.c          | 2 ++
 drivers/usb/dwc3/core.h          | 3 +++
 drivers/usb/dwc3/dwc3-pci.c      | 9 +++++++++
 drivers/usb/dwc3/platform_data.h | 2 ++
 4 files changed, 16 insertions(+)
drivers/usb/dwc3/core.c +2 -0
index ddac372..50c0eae 100644
@@ -710,6 +710,8 @@ static int dwc3_probe(struct platform_device *pdev)
 
 		dwc->needs_fifo_resize = pdata->tx_fifo_resize;
 		dwc->dr_mode = pdata->dr_mode;
+
+		dwc->quirks = pdata->quirks;
 	}
 
 	/* default to superspeed if no maximum_speed passed */
drivers/usb/dwc3/core.h +3 -0
index f6ee623..cfe0d57 100644
@@ -636,6 +636,7 @@ struct dwc3_scratchpad_array {
  * @u1u2: only used on revisions <1.83a for workaround
  * @maximum_speed: maximum speed requested (mainly for testing purposes)
  * @revision: revision register contents
+ * @quirks: represents different SOCs hardware work-arounds and quirks
  * @dr_mode: requested mode of operation
  * @usb2_phy: pointer to USB2 PHY
  * @usb3_phy: pointer to USB3 PHY
@@ -740,6 +741,8 @@ struct dwc3 {
 #define DWC3_REVISION_270A	0x5533270a
 #define DWC3_REVISION_280A	0x5533280a
 
+	u32			quirks;
+
 	enum dwc3_ep0_next	ep0_next_event;
 	enum dwc3_ep0_state	ep0state;
 	enum dwc3_link_state	link_state;
drivers/usb/dwc3/dwc3-pci.c +9 -0
index 3806547..18569a4 100644
@@ -25,6 +25,8 @@
 #include <linux/usb/otg.h>
 #include <linux/usb/usb_phy_generic.h>
 
+#include "platform_data.h"
+
 /* FIXME define these in <linux/pci_ids.h> */
 #define PCI_VENDOR_ID_SYNOPSYS		0x16c3
 #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3	0xabcd
@@ -103,6 +105,9 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	struct dwc3_pci		*glue;
 	int			ret;
 	struct device		*dev = &pci->dev;
+	struct dwc3_platform_data dwc3_pdata;
+
+	memset(&dwc3_pdata, 0x00, sizeof(dwc3_pdata));
 
 	glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue)
@@ -149,6 +154,10 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 
 	pci_set_drvdata(pci, glue);
 
+	ret = platform_device_add_data(dwc3, &dwc3_pdata, sizeof(dwc3_pdata));
+	if (ret)
+		goto err3;
+
 	dma_set_coherent_mask(&dwc3->dev, dev->coherent_dma_mask);
 
 	dwc3->dev.dma_mask = dev->dma_mask;
drivers/usb/dwc3/platform_data.h +2 -0
index 7db34f0..1d3d65f 100644
@@ -24,4 +24,6 @@ struct dwc3_platform_data {
 	enum usb_device_speed maximum_speed;
 	enum usb_dr_mode dr_mode;
 	bool tx_fifo_resize;
+
+	u32     quirks;
 };
Signature · 1 line
1.9.1
#10 lore raw

Re: [PATCH v2 05/16] usb: dwc3: add quirks support to be compatible for kinds of SoCs

HI,

Quoted 85 lines · Huang Rui

This patch adds a quirks flag at dwc3 structure, and SoCs platform vendor is able to define this flag in platform data at bus glue layer. Then do some independent behaviors at dwc3 core level.

---
 drivers/usb/dwc3/core.c          | 2 ++
 drivers/usb/dwc3/core.h          | 3 +++
 drivers/usb/dwc3/dwc3-pci.c      | 9 +++++++++
 drivers/usb/dwc3/platform_data.h | 2 ++
 4 files changed, 16 insertions(+)
drivers/usb/dwc3/core.c +2 -0
index ddac372..50c0eae 100644
@@ -710,6 +710,8 @@ static int dwc3_probe(struct platform_device *pdev)
 
 		dwc->needs_fifo_resize = pdata->tx_fifo_resize;
 		dwc->dr_mode = pdata->dr_mode;
+
+		dwc->quirks = pdata->quirks;
 	}
 
 	/* default to superspeed if no maximum_speed passed */
drivers/usb/dwc3/core.h +3 -0
index f6ee623..cfe0d57 100644
@@ -636,6 +636,7 @@ struct dwc3_scratchpad_array {
  * @u1u2: only used on revisions <1.83a for workaround
  * @maximum_speed: maximum speed requested (mainly for testing purposes)
  * @revision: revision register contents
+ * @quirks: represents different SOCs hardware work-arounds and quirks
  * @dr_mode: requested mode of operation
  * @usb2_phy: pointer to USB2 PHY
  * @usb3_phy: pointer to USB3 PHY
@@ -740,6 +741,8 @@ struct dwc3 {
 #define DWC3_REVISION_270A	0x5533270a
 #define DWC3_REVISION_280A	0x5533280a
 
+	u32			quirks;
+
 	enum dwc3_ep0_next	ep0_next_event;
 	enum dwc3_ep0_state	ep0state;
 	enum dwc3_link_state	link_state;
drivers/usb/dwc3/dwc3-pci.c +9 -0
index 3806547..18569a4 100644
@@ -25,6 +25,8 @@
 #include <linux/usb/otg.h>
 #include <linux/usb/usb_phy_generic.h>
 
+#include "platform_data.h"
+
 /* FIXME define these in <linux/pci_ids.h> */
 #define PCI_VENDOR_ID_SYNOPSYS		0x16c3
 #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3	0xabcd
@@ -103,6 +105,9 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	struct dwc3_pci		*glue;
 	int			ret;
 	struct device		*dev = &pci->dev;
+	struct dwc3_platform_data dwc3_pdata;
+
+	memset(&dwc3_pdata, 0x00, sizeof(dwc3_pdata));
 
 	glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue)
@@ -149,6 +154,10 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 
 	pci_set_drvdata(pci, glue);
 
+	ret = platform_device_add_data(dwc3, &dwc3_pdata, sizeof(dwc3_pdata));
+	if (ret)
+		goto err3;
+
 	dma_set_coherent_mask(&dwc3->dev, dev->coherent_dma_mask);
 
 	dwc3->dev.dma_mask = dev->dma_mask;
drivers/usb/dwc3/platform_data.h +0 -0
index 7db34f0..1d3d65f 100644

drivers/usb/dwc3/platform_data.h struct dwc3_platform_data { · line 28

Quoted 5 lines
drivers/usb/dwc3/platform_data.h +2 -0
@@ -24,4 +24,6 @@ struct dwc3_platform_data {
 	enum usb_device_speed maximum_speed;
 	enum usb_dr_mode dr_mode;
 	bool tx_fifo_resize;
+
+	u32     quirks;

I prefer to have one-bit fields like we already have for delayed_status, ep0_bounced, ep0_expect_in, and so on. That makes it easier to support the same quirks through devicetree as well.

Signature · 1 line
balbi
author
#11 lore raw

Re: [PATCH v2 05/16] usb: dwc3: add quirks support to be compatible for kinds of SoCs

Quoted 15 lines · Felipe Balbi

HI,

Quoted 12 lines · Huang Rui

This patch adds a quirks flag at dwc3 structure, and SoCs platform vendor is able to define this flag in platform data at bus glue layer. Then do some independent behaviors at dwc3 core level.

---
 drivers/usb/dwc3/core.c          | 2 ++
 drivers/usb/dwc3/core.h          | 3 +++
 drivers/usb/dwc3/dwc3-pci.c      | 9 +++++++++
 drivers/usb/dwc3/platform_data.h | 2 ++
 4 files changed, 16 insertions(+)

<snip>

Quoted 6 lines
Quoted 6 lines
drivers/usb/dwc3/platform_data.h +0 -0
index 7db34f0..1d3d65f 100644
@@ -24,4 +24,6 @@ struct dwc3_platform_data {
 	enum usb_device_speed maximum_speed;
Quoted 9 lines

drivers/usb/dwc3/platform_data.h struct dwc3_platform_data { · line 28

Quoted 4 lines
drivers/usb/dwc3/platform_data.h +2 -0
 	enum usb_dr_mode dr_mode;
 	bool tx_fifo_resize;
+
+	u32     quirks;

I prefer to have one-bit fields like we already have for delayed_status, ep0_bounced, ep0_expect_in, and so on. That makes it easier to support the same quirks through devicetree as well.

So it should define like below:

struct dwc3_platform_data {
        ...
        unsigned one_quirk:1;
}

Then also defined it in dwc3 structure. And when dwc3 probed, put this value from glue layer to dwc3, right?

Thanks,
Rui

#12 lore raw

Re: [PATCH v2 05/16] usb: dwc3: add quirks support to be compatible for kinds of SoCs

Quoted 37 lines · Huang Rui
Quoted 15 lines · Felipe Balbi

HI,

Quoted 12 lines · Huang Rui

This patch adds a quirks flag at dwc3 structure, and SoCs platform vendor is able to define this flag in platform data at bus glue layer. Then do some independent behaviors at dwc3 core level.

---
 drivers/usb/dwc3/core.c          | 2 ++
 drivers/usb/dwc3/core.h          | 3 +++
 drivers/usb/dwc3/dwc3-pci.c      | 9 +++++++++
 drivers/usb/dwc3/platform_data.h | 2 ++
 4 files changed, 16 insertions(+)

<snip>

Quoted 6 lines
Quoted 6 lines
drivers/usb/dwc3/platform_data.h +0 -0
index 7db34f0..1d3d65f 100644
@@ -24,4 +24,6 @@ struct dwc3_platform_data {
 	enum usb_device_speed maximum_speed;
Quoted 9 lines

drivers/usb/dwc3/platform_data.h struct dwc3_platform_data { · line 28

Quoted 4 lines
drivers/usb/dwc3/platform_data.h +2 -0
 	enum usb_dr_mode dr_mode;
 	bool tx_fifo_resize;
+
+	u32     quirks;

I prefer to have one-bit fields like we already have for delayed_status, ep0_bounced, ep0_expect_in, and so on. That makes it easier to support the same quirks through devicetree as well.

So it should define like below:

Quoted 7 lines
struct dwc3_platform_data {
        ...
        unsigned one_quirk:1;
}

Then also defined it in dwc3 structure. And when dwc3 probed, put this value from glue layer to dwc3, right?

that's correct.

Signature · 1 line
balbi
author
#13 lore raw

PATCH v2 6/16 usb: dwc3: add disscramble quirk

In reply to Huang Rui

AMD NL fpga needs to enable disscramble quirk. And this quirk doesn't need on the true soc.

---
 drivers/usb/dwc3/core.c          | 8 +++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 5 +++++
 drivers/usb/dwc3/platform_data.h | 4 ++++
 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +7 -1
index 50c0eae..819e501 100644
@@ -422,7 +422,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	reg = dwc3_readl(dwc->regs, DWC3_GCTL);
 	reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
-	reg &= ~DWC3_GCTL_DISSCRAMBLE;
 
 	switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
 	case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
@@ -461,6 +460,13 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		dwc->is_fpga = true;
 	}
 
+	if ((dwc->quirks & DWC3_QUIRK_AMD_NL) && dwc->is_fpga)
+		dwc->quirks |= DWC3_QUIRK_DISSCRAMBLE;
+
+	if (dwc->quirks & DWC3_QUIRK_DISSCRAMBLE)
+		reg |= DWC3_GCTL_DISSCRAMBLE;
+	else
+		reg &= ~DWC3_GCTL_DISSCRAMBLE;
 	/*
 	 * WORKAROUND: DWC3 revisions <1.90a have a bug
 	 * where the device can fail to connect at SuperSpeed
drivers/usb/dwc3/dwc3-pci.c +5 -0
index 18569a4..a89db6c 100644
@@ -146,6 +146,11 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	res[1].name	= "dwc_usb3";
 	res[1].flags	= IORESOURCE_IRQ;
 
+	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
+			PCI_DEVICE_ID_AMD_NL) {
+		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
+	}
+
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
 	if (ret) {
 		dev_err(dev, "couldn't add resources to dwc3 device\n");
drivers/usb/dwc3/platform_data.h +4 -0
index 1d3d65f..9c5f074 100644
@@ -26,4 +26,8 @@ struct dwc3_platform_data {
 	bool tx_fifo_resize;
 
 	u32     quirks;
+
+#define DWC3_QUIRK_AMD_NL		(1 << 0)
+#define DWC3_QUIRK_DISSCRAMBLE		(1 << 1)
+
 };
Signature · 1 line
1.9.1
#14 lore raw

Re: [PATCH v2 06/16] usb: dwc3: add disscramble quirk

Hi,

Quoted 23 lines · Huang Rui

AMD NL fpga needs to enable disscramble quirk. And this quirk doesn't need on the true soc.

---
 drivers/usb/dwc3/core.c          | 8 +++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 5 +++++
 drivers/usb/dwc3/platform_data.h | 4 ++++
 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -1
index 50c0eae..819e501 100644
@@ -422,7 +422,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	reg = dwc3_readl(dwc->regs, DWC3_GCTL);
 	reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
-	reg &= ~DWC3_GCTL_DISSCRAMBLE;
 
 	switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
 	case DWC3_GHWPARAMS1_EN_PWROPT_CLK:

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 466

Quoted 7 lines
drivers/usb/dwc3/core.c +4 -0
@@ -461,6 +460,13 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		dwc->is_fpga = true;
 	}
 
+	if ((dwc->quirks & DWC3_QUIRK_AMD_NL) && dwc->is_fpga)
+		dwc->quirks |= DWC3_QUIRK_DISSCRAMBLE;
+
+	if (dwc->quirks & DWC3_QUIRK_DISSCRAMBLE)

this should only be set if is_fpga, and this quirk should be a 1-bit flag, so here's what you should do:

	WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga,
		"disable_scramble cannot be used on non-FPGA builds\n");

	if (dwc->disable_scramble && dwc->is_fpga)
		reg |= DWC3_GCTL_DISSCRAMBLE;
	else
		reg &= ~DWC3_GCTL_DISSCRAMBLE;

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 469

Quoted 3 lines
drivers/usb/dwc3/core.c +3 -0
+		reg |= DWC3_GCTL_DISSCRAMBLE;
+	else
+		reg &= ~DWC3_GCTL_DISSCRAMBLE;

add a blank line here, to aid readability.

Quoted 8 lines
drivers/usb/dwc3/core.c +0 -0
 	/*
 	 * WORKAROUND: DWC3 revisions <1.90a have a bug
 	 * where the device can fail to connect at SuperSpeed
drivers/usb/dwc3/dwc3-pci.c +0 -0
index 18569a4..a89db6c 100644

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 152

Quoted 7 lines
drivers/usb/dwc3/dwc3-pci.c +4 -0
@@ -146,6 +146,11 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	res[1].name	= "dwc_usb3";
 	res[1].flags	= IORESOURCE_IRQ;
 
+	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
+			PCI_DEVICE_ID_AMD_NL) {
+		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
+	}

should be part of another patch and the quirk is
"disable_scramble_quirk", not AMD.

Signature · 1 line
balbi
author
#15 lore raw

Re: [PATCH v2 06/16] usb: dwc3: add disscramble quirk

Quoted 37 lines · Felipe Balbi

Hi,

Quoted 23 lines · Huang Rui

AMD NL fpga needs to enable disscramble quirk. And this quirk doesn't need on the true soc.

---
 drivers/usb/dwc3/core.c          | 8 +++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 5 +++++
 drivers/usb/dwc3/platform_data.h | 4 ++++
 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -1
index 50c0eae..819e501 100644
@@ -422,7 +422,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	reg = dwc3_readl(dwc->regs, DWC3_GCTL);
 	reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
-	reg &= ~DWC3_GCTL_DISSCRAMBLE;
 
 	switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
 	case DWC3_GHWPARAMS1_EN_PWROPT_CLK:

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 466

Quoted 7 lines
drivers/usb/dwc3/core.c +4 -0
@@ -461,6 +460,13 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		dwc->is_fpga = true;
 	}
 
+	if ((dwc->quirks & DWC3_QUIRK_AMD_NL) && dwc->is_fpga)
+		dwc->quirks |= DWC3_QUIRK_DISSCRAMBLE;
+
+	if (dwc->quirks & DWC3_QUIRK_DISSCRAMBLE)

this should only be set if is_fpga, and this quirk should be a 1-bit flag, so here's what you should do:

Quoted 8 lines
	WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga,
		"disable_scramble cannot be used on non-FPGA builds\n");

	if (dwc->disable_scramble && dwc->is_fpga)
		reg |= DWC3_GCTL_DISSCRAMBLE;
	else
		reg &= ~DWC3_GCTL_DISSCRAMBLE;

OK, will update it in V3.

Quoted 6 lines

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 469

Quoted 3 lines
drivers/usb/dwc3/core.c +3 -0
+		reg |= DWC3_GCTL_DISSCRAMBLE;
+	else
+		reg &= ~DWC3_GCTL_DISSCRAMBLE;

add a blank line here, to aid readability.

OK, will add it.

Quoted 11 lines
Quoted 11 lines
drivers/usb/dwc3/core.c +0 -0
 	/*
 	 * WORKAROUND: DWC3 revisions <1.90a have a bug
 	 * where the device can fail to connect at SuperSpeed
drivers/usb/dwc3/dwc3-pci.c +0 -0
index 18569a4..a89db6c 100644
@@ -146,6 +146,11 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	res[1].name	= "dwc_usb3";
 	res[1].flags	= IORESOURCE_IRQ;
 
Quoted 8 lines

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 152

Quoted 4 lines
drivers/usb/dwc3/dwc3-pci.c +4 -0
+	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
+			PCI_DEVICE_ID_AMD_NL) {
+		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
+	}

should be part of another patch and the quirk is
"disable_scramble_quirk", not AMD.

Got it, you would like to keep this patch just for fpga disscramble quirk and do not add any 3rd platform info, right?

Thanks,
Rui

#16 lore raw

Re: [PATCH v2 06/16] usb: dwc3: add disscramble quirk

Quoted 78 lines · Huang Rui
Quoted 37 lines · Felipe Balbi

Hi,

Quoted 23 lines · Huang Rui

AMD NL fpga needs to enable disscramble quirk. And this quirk doesn't need on the true soc.

---
 drivers/usb/dwc3/core.c          | 8 +++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 5 +++++
 drivers/usb/dwc3/platform_data.h | 4 ++++
 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -1
index 50c0eae..819e501 100644
@@ -422,7 +422,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	reg = dwc3_readl(dwc->regs, DWC3_GCTL);
 	reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
-	reg &= ~DWC3_GCTL_DISSCRAMBLE;
 
 	switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
 	case DWC3_GHWPARAMS1_EN_PWROPT_CLK:

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 466

Quoted 7 lines
drivers/usb/dwc3/core.c +4 -0
@@ -461,6 +460,13 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		dwc->is_fpga = true;
 	}
 
+	if ((dwc->quirks & DWC3_QUIRK_AMD_NL) && dwc->is_fpga)
+		dwc->quirks |= DWC3_QUIRK_DISSCRAMBLE;
+
+	if (dwc->quirks & DWC3_QUIRK_DISSCRAMBLE)

this should only be set if is_fpga, and this quirk should be a 1-bit flag, so here's what you should do:

Quoted 8 lines
	WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga,
		"disable_scramble cannot be used on non-FPGA builds\n");

	if (dwc->disable_scramble && dwc->is_fpga)
		reg |= DWC3_GCTL_DISSCRAMBLE;
	else
		reg &= ~DWC3_GCTL_DISSCRAMBLE;

OK, will update it in V3.

Quoted 6 lines

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 469

Quoted 3 lines
drivers/usb/dwc3/core.c +3 -0
+		reg |= DWC3_GCTL_DISSCRAMBLE;
+	else
+		reg &= ~DWC3_GCTL_DISSCRAMBLE;

add a blank line here, to aid readability.

OK, will add it.

Quoted 11 lines
Quoted 11 lines
drivers/usb/dwc3/core.c +0 -0
 	/*
 	 * WORKAROUND: DWC3 revisions <1.90a have a bug
 	 * where the device can fail to connect at SuperSpeed
drivers/usb/dwc3/dwc3-pci.c +0 -0
index 18569a4..a89db6c 100644
@@ -146,6 +146,11 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	res[1].name	= "dwc_usb3";
 	res[1].flags	= IORESOURCE_IRQ;
 
Quoted 8 lines

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 152

Quoted 4 lines
drivers/usb/dwc3/dwc3-pci.c +4 -0
+	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
+			PCI_DEVICE_ID_AMD_NL) {
+		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
+	}

should be part of another patch and the quirk is
"disable_scramble_quirk", not AMD.

Quoted 2 lines

Got it, you would like to keep this patch just for fpga disscramble quirk and do not add any 3rd platform info, right?

right. So far only FPGA-based systems need this :-)

Signature · 1 line
balbi
author
#17 lore raw

PATCH v2 7/16 usb: dwc3: add lpm erratum support

In reply to Huang Rui

When parameter DWC_USB3_LPM_ERRATA_ENABLE is enabled in Andvanced Configuration of coreConsultant, it supports of xHCI BESL Errata Dated 10/19/2011 is enabled in host mode. In device mode it adds the capability to send NYET response based on the BESL value received in the LPM token.

This patch add an entry that soc platform is able to define the lpm capacity with their own device tree or bus glue layer.

---
 drivers/usb/dwc3/core.c          |  2 ++
 drivers/usb/dwc3/core.h          | 24 +++++++++++++++---------
 drivers/usb/dwc3/dwc3-pci.c      |  1 +
 drivers/usb/dwc3/gadget.c        |  7 +++++++
 drivers/usb/dwc3/platform_data.h |  1 +
 5 files changed, 26 insertions(+), 9 deletions(-)
drivers/usb/dwc3/core.c +2 -0
index 819e501..25db533 100644
@@ -708,11 +708,13 @@ static int dwc3_probe(struct platform_device *pdev)
 
 	if (node) {
 		dwc->maximum_speed = of_usb_get_maximum_speed(node);
+		dwc->has_lpm_erratum = of_property_read_bool(node, "snps,has-lpm-erratum");
 
 		dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
 		dwc->dr_mode = of_usb_get_dr_mode(node);
 	} else if (pdata) {
 		dwc->maximum_speed = pdata->maximum_speed;
+		dwc->has_lpm_erratum = pdata->has_lpm_erratum;
 
 		dwc->needs_fifo_resize = pdata->tx_fifo_resize;
 		dwc->dr_mode = pdata->dr_mode;
drivers/usb/dwc3/core.h +15 -9
index cfe0d57..d58479e 100644
@@ -246,16 +246,19 @@
 #define DWC3_DCTL_TRGTULST_SS_INACT	(DWC3_DCTL_TRGTULST(6))
 
 /* These apply for core versions 1.94a and later */
-#define DWC3_DCTL_KEEP_CONNECT	(1 << 19)
-#define DWC3_DCTL_L1_HIBER_EN	(1 << 18)
-#define DWC3_DCTL_CRS		(1 << 17)
-#define DWC3_DCTL_CSS		(1 << 16)
+#define DWC3_DCTL_LPM_ERRATA_MASK	DWC3_DCTL_LPM_ERRATA(0xf)
+#define DWC3_DCTL_LPM_ERRATA(n)		((n) << 20)
 
-#define DWC3_DCTL_INITU2ENA	(1 << 12)
-#define DWC3_DCTL_ACCEPTU2ENA	(1 << 11)
-#define DWC3_DCTL_INITU1ENA	(1 << 10)
-#define DWC3_DCTL_ACCEPTU1ENA	(1 << 9)
-#define DWC3_DCTL_TSTCTRL_MASK	(0xf << 1)
+#define DWC3_DCTL_KEEP_CONNECT		(1 << 19)
+#define DWC3_DCTL_L1_HIBER_EN		(1 << 18)
+#define DWC3_DCTL_CRS			(1 << 17)
+#define DWC3_DCTL_CSS			(1 << 16)
+
+#define DWC3_DCTL_INITU2ENA		(1 << 12)
+#define DWC3_DCTL_ACCEPTU2ENA		(1 << 11)
+#define DWC3_DCTL_INITU1ENA		(1 << 10)
+#define DWC3_DCTL_ACCEPTU1ENA		(1 << 9)
+#define DWC3_DCTL_TSTCTRL_MASK		(0xf << 1)
 
 #define DWC3_DCTL_ULSTCHNGREQ_MASK	(0x0f << 5)
 #define DWC3_DCTL_ULSTCHNGREQ(n) (((n) << 5) & DWC3_DCTL_ULSTCHNGREQ_MASK)
@@ -665,6 +668,8 @@ struct dwc3_scratchpad_array {
  * @ep0_bounced: true when we used bounce buffer
  * @ep0_expect_in: true when we expect a DATA IN transfer
  * @has_hibernation: true when dwc3 was configured with Hibernation
+ * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that
+ *			there's now way for software to detect this in runtime.
  * @is_selfpowered: true when we are selfpowered
  * @is_fpga: true when we are using the FPGA board
  * @needs_fifo_resize: not all users might want fifo resizing, flag it
@@ -771,6 +776,7 @@ struct dwc3 {
 	unsigned		ep0_bounced:1;
 	unsigned		ep0_expect_in:1;
 	unsigned		has_hibernation:1;
+	unsigned		has_lpm_erratum:1;
 	unsigned		is_selfpowered:1;
 	unsigned		is_fpga:1;
 	unsigned		needs_fifo_resize:1;
drivers/usb/dwc3/dwc3-pci.c +1 -0
index a89db6c..bbe946c 100644
@@ -148,6 +148,7 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 
 	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
 			PCI_DEVICE_ID_AMD_NL) {
+		dwc3_pdata.has_lpm_erratum = true;
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
 	}
 
drivers/usb/dwc3/gadget.c +7 -0
index 1f2a719..33bfc70 100644
@@ -1581,6 +1581,13 @@ static int dwc3_gadget_start(struct usb_gadget *g,
 	}
 	dwc3_writel(dwc->regs, DWC3_DCFG, reg);
 
+	if (dwc->has_lpm_erratum) {
+		reg = dwc3_readl(dwc->regs, DWC3_DCTL);
+		/* REVISIT should this be configurable ? */
+		reg |= DWC3_DCTL_LPM_ERRATA(0xf);
+		dwc3_writel(dwc->regs, DWC3_DCTL, reg);
+	}
+
 	dwc->start_config_issued = false;
 
 	/* Start with SuperSpeed Default */
drivers/usb/dwc3/platform_data.h +1 -0
index 9c5f074..098ab04 100644
@@ -25,6 +25,7 @@ struct dwc3_platform_data {
 	enum usb_dr_mode dr_mode;
 	bool tx_fifo_resize;
 
+	unsigned has_lpm_erratum:1;
 	u32     quirks;
 
 #define DWC3_QUIRK_AMD_NL		(1 << 0)
Signature · 1 line
1.9.1
#18 lore raw

Re: [PATCH v2 07/16] usb: dwc3: add lpm erratum support

Quoted 90 lines · Huang Rui

When parameter DWC_USB3_LPM_ERRATA_ENABLE is enabled in Andvanced Configuration of coreConsultant, it supports of xHCI BESL Errata Dated 10/19/2011 is enabled in host mode. In device mode it adds the capability to send NYET response based on the BESL value received in the LPM token.

This patch add an entry that soc platform is able to define the lpm capacity with their own device tree or bus glue layer.

---
 drivers/usb/dwc3/core.c          |  2 ++
 drivers/usb/dwc3/core.h          | 24 +++++++++++++++---------
 drivers/usb/dwc3/dwc3-pci.c      |  1 +
 drivers/usb/dwc3/gadget.c        |  7 +++++++
 drivers/usb/dwc3/platform_data.h |  1 +
 5 files changed, 26 insertions(+), 9 deletions(-)
drivers/usb/dwc3/core.c +2 -0
index 819e501..25db533 100644
@@ -708,11 +708,13 @@ static int dwc3_probe(struct platform_device *pdev)
 
 	if (node) {
 		dwc->maximum_speed = of_usb_get_maximum_speed(node);
+		dwc->has_lpm_erratum = of_property_read_bool(node, "snps,has-lpm-erratum");
 
 		dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
 		dwc->dr_mode = of_usb_get_dr_mode(node);
 	} else if (pdata) {
 		dwc->maximum_speed = pdata->maximum_speed;
+		dwc->has_lpm_erratum = pdata->has_lpm_erratum;
 
 		dwc->needs_fifo_resize = pdata->tx_fifo_resize;
 		dwc->dr_mode = pdata->dr_mode;
drivers/usb/dwc3/core.h +15 -9
index cfe0d57..d58479e 100644
@@ -246,16 +246,19 @@
 #define DWC3_DCTL_TRGTULST_SS_INACT	(DWC3_DCTL_TRGTULST(6))
 
 /* These apply for core versions 1.94a and later */
-#define DWC3_DCTL_KEEP_CONNECT	(1 << 19)
-#define DWC3_DCTL_L1_HIBER_EN	(1 << 18)
-#define DWC3_DCTL_CRS		(1 << 17)
-#define DWC3_DCTL_CSS		(1 << 16)
+#define DWC3_DCTL_LPM_ERRATA_MASK	DWC3_DCTL_LPM_ERRATA(0xf)
+#define DWC3_DCTL_LPM_ERRATA(n)		((n) << 20)
-#define DWC3_DCTL_INITU2ENA	(1 << 12)
-#define DWC3_DCTL_ACCEPTU2ENA	(1 << 11)
-#define DWC3_DCTL_INITU1ENA	(1 << 10)
-#define DWC3_DCTL_ACCEPTU1ENA	(1 << 9)
-#define DWC3_DCTL_TSTCTRL_MASK	(0xf << 1)
+#define DWC3_DCTL_KEEP_CONNECT		(1 << 19)
+#define DWC3_DCTL_L1_HIBER_EN		(1 << 18)
+#define DWC3_DCTL_CRS			(1 << 17)
+#define DWC3_DCTL_CSS			(1 << 16)
+
+#define DWC3_DCTL_INITU2ENA		(1 << 12)
+#define DWC3_DCTL_ACCEPTU2ENA		(1 << 11)
+#define DWC3_DCTL_INITU1ENA		(1 << 10)
+#define DWC3_DCTL_ACCEPTU1ENA		(1 << 9)
+#define DWC3_DCTL_TSTCTRL_MASK		(0xf << 1)
 
 #define DWC3_DCTL_ULSTCHNGREQ_MASK	(0x0f << 5)
 #define DWC3_DCTL_ULSTCHNGREQ(n) (((n) << 5) & DWC3_DCTL_ULSTCHNGREQ_MASK)
@@ -665,6 +668,8 @@ struct dwc3_scratchpad_array {
  * @ep0_bounced: true when we used bounce buffer
  * @ep0_expect_in: true when we expect a DATA IN transfer
  * @has_hibernation: true when dwc3 was configured with Hibernation
+ * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that
+ *			there's now way for software to detect this in runtime.
  * @is_selfpowered: true when we are selfpowered
  * @is_fpga: true when we are using the FPGA board
  * @needs_fifo_resize: not all users might want fifo resizing, flag it
@@ -771,6 +776,7 @@ struct dwc3 {
 	unsigned		ep0_bounced:1;
 	unsigned		ep0_expect_in:1;
 	unsigned		has_hibernation:1;
+	unsigned		has_lpm_erratum:1;
 	unsigned		is_selfpowered:1;
 	unsigned		is_fpga:1;
 	unsigned		needs_fifo_resize:1;
drivers/usb/dwc3/dwc3-pci.c +0 -0
index a89db6c..bbe946c 100644

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 154

Quoted 7 lines
drivers/usb/dwc3/dwc3-pci.c +1 -0
@@ -148,6 +148,7 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 
 	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
 			PCI_DEVICE_ID_AMD_NL) {
+		dwc3_pdata.has_lpm_erratum = true;
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
 	}
 

let's combine all AMD patches as the last patch in the series so we add AMD support with all quirks in one place.

drivers/usb/dwc3/gadget.c static int dwc3_gadget_start(struct usb_gadget *g, · line 1587

Quoted 12 lines
drivers/usb/dwc3/gadget.c +4 -0
index 1f2a719..33bfc70 100644
@@ -1581,6 +1581,13 @@ static int dwc3_gadget_start(struct usb_gadget *g,
 	}
 	dwc3_writel(dwc->regs, DWC3_DCFG, reg);
 
+	if (dwc->has_lpm_erratum) {
+		reg = dwc3_readl(dwc->regs, DWC3_DCTL);
+		/* REVISIT should this be configurable ? */
+		reg |= DWC3_DCTL_LPM_ERRATA(0xf);

as Paul mentioned, this should definitely be configurable. So we need to discuss how to make that configurable too.

Signature · 1 line
balbi
author
#19 lore raw

Re: [PATCH v2 07/16] usb: dwc3: add lpm erratum support

Quoted 110 lines · Felipe Balbi
Quoted 90 lines · Huang Rui

When parameter DWC_USB3_LPM_ERRATA_ENABLE is enabled in Andvanced Configuration of coreConsultant, it supports of xHCI BESL Errata Dated 10/19/2011 is enabled in host mode. In device mode it adds the capability to send NYET response based on the BESL value received in the LPM token.

This patch add an entry that soc platform is able to define the lpm capacity with their own device tree or bus glue layer.

---
 drivers/usb/dwc3/core.c          |  2 ++
 drivers/usb/dwc3/core.h          | 24 +++++++++++++++---------
 drivers/usb/dwc3/dwc3-pci.c      |  1 +
 drivers/usb/dwc3/gadget.c        |  7 +++++++
 drivers/usb/dwc3/platform_data.h |  1 +
 5 files changed, 26 insertions(+), 9 deletions(-)
drivers/usb/dwc3/core.c +2 -0
index 819e501..25db533 100644
@@ -708,11 +708,13 @@ static int dwc3_probe(struct platform_device *pdev)
 
 	if (node) {
 		dwc->maximum_speed = of_usb_get_maximum_speed(node);
+		dwc->has_lpm_erratum = of_property_read_bool(node, "snps,has-lpm-erratum");
 
 		dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
 		dwc->dr_mode = of_usb_get_dr_mode(node);
 	} else if (pdata) {
 		dwc->maximum_speed = pdata->maximum_speed;
+		dwc->has_lpm_erratum = pdata->has_lpm_erratum;
 
 		dwc->needs_fifo_resize = pdata->tx_fifo_resize;
 		dwc->dr_mode = pdata->dr_mode;
drivers/usb/dwc3/core.h +15 -9
index cfe0d57..d58479e 100644
@@ -246,16 +246,19 @@
 #define DWC3_DCTL_TRGTULST_SS_INACT	(DWC3_DCTL_TRGTULST(6))
 
 /* These apply for core versions 1.94a and later */
-#define DWC3_DCTL_KEEP_CONNECT	(1 << 19)
-#define DWC3_DCTL_L1_HIBER_EN	(1 << 18)
-#define DWC3_DCTL_CRS		(1 << 17)
-#define DWC3_DCTL_CSS		(1 << 16)
+#define DWC3_DCTL_LPM_ERRATA_MASK	DWC3_DCTL_LPM_ERRATA(0xf)
+#define DWC3_DCTL_LPM_ERRATA(n)		((n) << 20)
-#define DWC3_DCTL_INITU2ENA	(1 << 12)
-#define DWC3_DCTL_ACCEPTU2ENA	(1 << 11)
-#define DWC3_DCTL_INITU1ENA	(1 << 10)
-#define DWC3_DCTL_ACCEPTU1ENA	(1 << 9)
-#define DWC3_DCTL_TSTCTRL_MASK	(0xf << 1)
+#define DWC3_DCTL_KEEP_CONNECT		(1 << 19)
+#define DWC3_DCTL_L1_HIBER_EN		(1 << 18)
+#define DWC3_DCTL_CRS			(1 << 17)
+#define DWC3_DCTL_CSS			(1 << 16)
+
+#define DWC3_DCTL_INITU2ENA		(1 << 12)
+#define DWC3_DCTL_ACCEPTU2ENA		(1 << 11)
+#define DWC3_DCTL_INITU1ENA		(1 << 10)
+#define DWC3_DCTL_ACCEPTU1ENA		(1 << 9)
+#define DWC3_DCTL_TSTCTRL_MASK		(0xf << 1)
 
 #define DWC3_DCTL_ULSTCHNGREQ_MASK	(0x0f << 5)
 #define DWC3_DCTL_ULSTCHNGREQ(n) (((n) << 5) & DWC3_DCTL_ULSTCHNGREQ_MASK)
@@ -665,6 +668,8 @@ struct dwc3_scratchpad_array {
  * @ep0_bounced: true when we used bounce buffer
  * @ep0_expect_in: true when we expect a DATA IN transfer
  * @has_hibernation: true when dwc3 was configured with Hibernation
+ * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that
+ *			there's now way for software to detect this in runtime.
  * @is_selfpowered: true when we are selfpowered
  * @is_fpga: true when we are using the FPGA board
  * @needs_fifo_resize: not all users might want fifo resizing, flag it
@@ -771,6 +776,7 @@ struct dwc3 {
 	unsigned		ep0_bounced:1;
 	unsigned		ep0_expect_in:1;
 	unsigned		has_hibernation:1;
+	unsigned		has_lpm_erratum:1;
 	unsigned		is_selfpowered:1;
 	unsigned		is_fpga:1;
 	unsigned		needs_fifo_resize:1;
drivers/usb/dwc3/dwc3-pci.c +0 -0
index a89db6c..bbe946c 100644

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 154

Quoted 7 lines
drivers/usb/dwc3/dwc3-pci.c +1 -0
@@ -148,6 +148,7 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 
 	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
 			PCI_DEVICE_ID_AMD_NL) {
+		dwc3_pdata.has_lpm_erratum = true;
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
 	}
 

let's combine all AMD patches as the last patch in the series so we add AMD support with all quirks in one place.

Quoted 8 lines
drivers/usb/dwc3/gadget.c +0 -0
index 1f2a719..33bfc70 100644
@@ -1581,6 +1581,13 @@ static int dwc3_gadget_start(struct usb_gadget *g,
 	}
 	dwc3_writel(dwc->regs, DWC3_DCFG, reg);
 
Quoted 8 lines

drivers/usb/dwc3/gadget.c static int dwc3_gadget_start(struct usb_gadget *g, · line 1587

Quoted 4 lines
drivers/usb/dwc3/gadget.c +4 -0
+	if (dwc->has_lpm_erratum) {
+		reg = dwc3_readl(dwc->regs, DWC3_DCTL);
+		/* REVISIT should this be configurable ? */
+		reg |= DWC3_DCTL_LPM_ERRATA(0xf);

as Paul mentioned, this should definitely be configurable. So we need to discuss how to make that configurable too.

Can I define a 4-bits variable (lpm_nyet_thres) to let platform vendor able to configure the besl value at DT or glue layer?

struct dwc3_platform_data {
        ...
        unsigned has_lpm_erratum:1;
        unsigned lpm_nyet_thres:4;
}

Then put the value at probe like:

dwc->has_lpm_erratum = of_property_read_u8(node, "snps,lpm-nyet-thres");

I don't find a 4-bit "Find from a property" interface, so can I use of_property_read_u8 instead for ARM platforms?

Then do:
if (dwc->has_lpm_erratum)

        reg |= DWC3_DCTL_LPM_ERRATA(dwc->lpm_nyet_thres);

Thanks,
Rui

#20 lore raw

Re: [PATCH v2 07/16] usb: dwc3: add lpm erratum support

Hi,

Quoted 120 lines · Huang Rui
Quoted 110 lines · Felipe Balbi
Quoted 90 lines · Huang Rui

When parameter DWC_USB3_LPM_ERRATA_ENABLE is enabled in Andvanced Configuration of coreConsultant, it supports of xHCI BESL Errata Dated 10/19/2011 is enabled in host mode. In device mode it adds the capability to send NYET response based on the BESL value received in the LPM token.

This patch add an entry that soc platform is able to define the lpm capacity with their own device tree or bus glue layer.

---
 drivers/usb/dwc3/core.c          |  2 ++
 drivers/usb/dwc3/core.h          | 24 +++++++++++++++---------
 drivers/usb/dwc3/dwc3-pci.c      |  1 +
 drivers/usb/dwc3/gadget.c        |  7 +++++++
 drivers/usb/dwc3/platform_data.h |  1 +
 5 files changed, 26 insertions(+), 9 deletions(-)
drivers/usb/dwc3/core.c +2 -0
index 819e501..25db533 100644
@@ -708,11 +708,13 @@ static int dwc3_probe(struct platform_device *pdev)
 
 	if (node) {
 		dwc->maximum_speed = of_usb_get_maximum_speed(node);
+		dwc->has_lpm_erratum = of_property_read_bool(node, "snps,has-lpm-erratum");
 
 		dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
 		dwc->dr_mode = of_usb_get_dr_mode(node);
 	} else if (pdata) {
 		dwc->maximum_speed = pdata->maximum_speed;
+		dwc->has_lpm_erratum = pdata->has_lpm_erratum;
 
 		dwc->needs_fifo_resize = pdata->tx_fifo_resize;
 		dwc->dr_mode = pdata->dr_mode;
drivers/usb/dwc3/core.h +15 -9
index cfe0d57..d58479e 100644
@@ -246,16 +246,19 @@
 #define DWC3_DCTL_TRGTULST_SS_INACT	(DWC3_DCTL_TRGTULST(6))
 
 /* These apply for core versions 1.94a and later */
-#define DWC3_DCTL_KEEP_CONNECT	(1 << 19)
-#define DWC3_DCTL_L1_HIBER_EN	(1 << 18)
-#define DWC3_DCTL_CRS		(1 << 17)
-#define DWC3_DCTL_CSS		(1 << 16)
+#define DWC3_DCTL_LPM_ERRATA_MASK	DWC3_DCTL_LPM_ERRATA(0xf)
+#define DWC3_DCTL_LPM_ERRATA(n)		((n) << 20)
-#define DWC3_DCTL_INITU2ENA	(1 << 12)
-#define DWC3_DCTL_ACCEPTU2ENA	(1 << 11)
-#define DWC3_DCTL_INITU1ENA	(1 << 10)
-#define DWC3_DCTL_ACCEPTU1ENA	(1 << 9)
-#define DWC3_DCTL_TSTCTRL_MASK	(0xf << 1)
+#define DWC3_DCTL_KEEP_CONNECT		(1 << 19)
+#define DWC3_DCTL_L1_HIBER_EN		(1 << 18)
+#define DWC3_DCTL_CRS			(1 << 17)
+#define DWC3_DCTL_CSS			(1 << 16)
+
+#define DWC3_DCTL_INITU2ENA		(1 << 12)
+#define DWC3_DCTL_ACCEPTU2ENA		(1 << 11)
+#define DWC3_DCTL_INITU1ENA		(1 << 10)
+#define DWC3_DCTL_ACCEPTU1ENA		(1 << 9)
+#define DWC3_DCTL_TSTCTRL_MASK		(0xf << 1)
 
 #define DWC3_DCTL_ULSTCHNGREQ_MASK	(0x0f << 5)
 #define DWC3_DCTL_ULSTCHNGREQ(n) (((n) << 5) & DWC3_DCTL_ULSTCHNGREQ_MASK)
@@ -665,6 +668,8 @@ struct dwc3_scratchpad_array {
  * @ep0_bounced: true when we used bounce buffer
  * @ep0_expect_in: true when we expect a DATA IN transfer
  * @has_hibernation: true when dwc3 was configured with Hibernation
+ * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that
+ *			there's now way for software to detect this in runtime.
  * @is_selfpowered: true when we are selfpowered
  * @is_fpga: true when we are using the FPGA board
  * @needs_fifo_resize: not all users might want fifo resizing, flag it
@@ -771,6 +776,7 @@ struct dwc3 {
 	unsigned		ep0_bounced:1;
 	unsigned		ep0_expect_in:1;
 	unsigned		has_hibernation:1;
+	unsigned		has_lpm_erratum:1;
 	unsigned		is_selfpowered:1;
 	unsigned		is_fpga:1;
 	unsigned		needs_fifo_resize:1;
drivers/usb/dwc3/dwc3-pci.c +0 -0
index a89db6c..bbe946c 100644

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 154

Quoted 7 lines
drivers/usb/dwc3/dwc3-pci.c +1 -0
@@ -148,6 +148,7 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 
 	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
 			PCI_DEVICE_ID_AMD_NL) {
+		dwc3_pdata.has_lpm_erratum = true;
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
 	}
 

let's combine all AMD patches as the last patch in the series so we add AMD support with all quirks in one place.

Quoted 8 lines
drivers/usb/dwc3/gadget.c +0 -0
index 1f2a719..33bfc70 100644
@@ -1581,6 +1581,13 @@ static int dwc3_gadget_start(struct usb_gadget *g,
 	}
 	dwc3_writel(dwc->regs, DWC3_DCFG, reg);
 
Quoted 8 lines

drivers/usb/dwc3/gadget.c static int dwc3_gadget_start(struct usb_gadget *g, · line 1587

Quoted 4 lines
drivers/usb/dwc3/gadget.c +4 -0
+	if (dwc->has_lpm_erratum) {
+		reg = dwc3_readl(dwc->regs, DWC3_DCTL);
+		/* REVISIT should this be configurable ? */
+		reg |= DWC3_DCTL_LPM_ERRATA(0xf);

as Paul mentioned, this should definitely be configurable. So we need to discuss how to make that configurable too.

Quoted 7 lines

Can I define a 4-bits variable (lpm_nyet_thres) to let platform vendor able to configure the besl value at DT or glue layer?

struct dwc3_platform_data {
        ...
        unsigned has_lpm_erratum:1;
        unsigned lpm_nyet_thres:4;

this threshold can be a u8, no problem :-) (also, please spell out threshold completely :-)

Quoted 3 lines

Then put the value at probe like:

dwc->has_lpm_erratum = of_property_read_u8(node, "snps,lpm-nyet-thres");

yup, that's fine :-)

Quoted 6 lines

I don't find a 4-bit "Find from a property" interface, so can I use of_property_read_u8 instead for ARM platforms?

Then do:
if (dwc->has_lpm_erratum)

        reg |= DWC3_DCTL_LPM_ERRATA(dwc->lpm_nyet_thres);

perfect :-) But then default to highest possible threshold, perhaps ?

lpm_nyet_threshold = 0xff;

if (pdata->lpm_nyet_threshold)

	lpm_nyet_threshold = pdata->lpm_nyet_threshold;

and likewise for DT.

Signature · 1 line
balbi
author
#21 lore raw

PATCH v2 8/16 usb: dwc3: add u2exit lfps quirk

In reply to Huang Rui

AMD NL needs to enable u2exit lfps quirk.

---
 drivers/usb/dwc3/core.c          | 4 ++++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +4 -0
index 25db533..7322d85 100644
@@ -467,6 +467,10 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		reg |= DWC3_GCTL_DISSCRAMBLE;
 	else
 		reg &= ~DWC3_GCTL_DISSCRAMBLE;
+
+	if (dwc->quirks & DWC3_QUIRK_U2EXIT_LFPS)
+		reg |= DWC3_GCTL_U2EXIT_LFPS;
+
 	/*
 	 * WORKAROUND: DWC3 revisions <1.90a have a bug
 	 * where the device can fail to connect at SuperSpeed
drivers/usb/dwc3/core.h +1 -0
index d58479e..3d27f10 100644
@@ -166,6 +166,7 @@
 #define DWC3_GCTL_SCALEDOWN(n)		((n) << 4)
 #define DWC3_GCTL_SCALEDOWN_MASK	DWC3_GCTL_SCALEDOWN(3)
 #define DWC3_GCTL_DISSCRAMBLE		(1 << 3)
+#define DWC3_GCTL_U2EXIT_LFPS		(1 << 2)
 #define DWC3_GCTL_GBLHIBERNATIONEN	(1 << 1)
 #define DWC3_GCTL_DSBLCLKGTNG		(1 << 0)
 
drivers/usb/dwc3/dwc3-pci.c +2 -1
index bbe946c..cdb9b04 100644
@@ -149,7 +149,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
 			PCI_DEVICE_ID_AMD_NL) {
 		dwc3_pdata.has_lpm_erratum = true;
-		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
+		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
+			| DWC3_QUIRK_U2EXIT_LFPS;
 	}
 
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
drivers/usb/dwc3/platform_data.h +1 -0
index 098ab04..a6463c0 100644
@@ -30,5 +30,6 @@ struct dwc3_platform_data {
 
 #define DWC3_QUIRK_AMD_NL		(1 << 0)
 #define DWC3_QUIRK_DISSCRAMBLE		(1 << 1)
+#define DWC3_QUIRK_U2EXIT_LFPS		(1 << 2)
 
 };
Signature · 1 line
1.9.1
#22 lore raw

Re: [PATCH v2 08/16] usb: dwc3: add u2exit lfps quirk

Hi,

Quoted 15 lines · Huang Rui

AMD NL needs to enable u2exit lfps quirk.

---
 drivers/usb/dwc3/core.c          | 4 ++++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index 25db533..7322d85 100644

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 471

Quoted 5 lines
drivers/usb/dwc3/core.c +2 -0
@@ -467,6 +467,10 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		reg |= DWC3_GCTL_DISSCRAMBLE;
 	else
 		reg &= ~DWC3_GCTL_DISSCRAMBLE;
+
+	if (dwc->quirks & DWC3_QUIRK_U2EXIT_LFPS)

this should be:

	if (dwc->u2_exit_lfps_quirk)
Quoted 22 lines
drivers/usb/dwc3/core.c +2 -0
+		reg |= DWC3_GCTL_U2EXIT_LFPS;
+
 	/*
 	 * WORKAROUND: DWC3 revisions <1.90a have a bug
 	 * where the device can fail to connect at SuperSpeed
drivers/usb/dwc3/core.h +1 -0
index d58479e..3d27f10 100644
@@ -166,6 +166,7 @@
 #define DWC3_GCTL_SCALEDOWN(n)		((n) << 4)
 #define DWC3_GCTL_SCALEDOWN_MASK	DWC3_GCTL_SCALEDOWN(3)
 #define DWC3_GCTL_DISSCRAMBLE		(1 << 3)
+#define DWC3_GCTL_U2EXIT_LFPS		(1 << 2)
 #define DWC3_GCTL_GBLHIBERNATIONEN	(1 << 1)
 #define DWC3_GCTL_DSBLCLKGTNG		(1 << 0)
 
drivers/usb/dwc3/dwc3-pci.c +0 -0
index bbe946c..cdb9b04 100644

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 154

Quoted 7 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
@@ -149,7 +149,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
 			PCI_DEVICE_ID_AMD_NL) {
 		dwc3_pdata.has_lpm_erratum = true;
-		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
+		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
+			| DWC3_QUIRK_U2EXIT_LFPS;
 	}

should be combined and the last patch in the series.

Signature · 1 line
balbi
author
#23 lore raw

Re: [PATCH v2 08/16] usb: dwc3: add u2exit lfps quirk

Quoted 26 lines · Felipe Balbi

Hi,

Quoted 15 lines · Huang Rui

AMD NL needs to enable u2exit lfps quirk.

---
 drivers/usb/dwc3/core.c          | 4 ++++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index 25db533..7322d85 100644

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 471

Quoted 5 lines
drivers/usb/dwc3/core.c +2 -0
@@ -467,6 +467,10 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		reg |= DWC3_GCTL_DISSCRAMBLE;
 	else
 		reg &= ~DWC3_GCTL_DISSCRAMBLE;
+
+	if (dwc->quirks & DWC3_QUIRK_U2EXIT_LFPS)

this should be:

Quoted 2 lines
	if (dwc->u2_exit_lfps_quirk)

OK, will update it in V3.

Quoted 17 lines
Quoted 17 lines
drivers/usb/dwc3/core.c +2 -0
+		reg |= DWC3_GCTL_U2EXIT_LFPS;
+
 	/*
 	 * WORKAROUND: DWC3 revisions <1.90a have a bug
 	 * where the device can fail to connect at SuperSpeed
drivers/usb/dwc3/core.h +1 -0
index d58479e..3d27f10 100644
@@ -166,6 +166,7 @@
 #define DWC3_GCTL_SCALEDOWN(n)		((n) << 4)
 #define DWC3_GCTL_SCALEDOWN_MASK	DWC3_GCTL_SCALEDOWN(3)
 #define DWC3_GCTL_DISSCRAMBLE		(1 << 3)
+#define DWC3_GCTL_U2EXIT_LFPS		(1 << 2)
 #define DWC3_GCTL_GBLHIBERNATIONEN	(1 << 1)
 #define DWC3_GCTL_DSBLCLKGTNG		(1 << 0)
 
Quoted 15 lines

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 154

Quoted 12 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
index bbe946c..cdb9b04 100644
@@ -149,7 +149,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
 			PCI_DEVICE_ID_AMD_NL) {
 		dwc3_pdata.has_lpm_erratum = true;
-		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
+		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
+			| DWC3_QUIRK_U2EXIT_LFPS;
 	}

should be combined and the last patch in the series.

You want to make all the AMD quirks enablement info and device id at last patch, right?

Thanks,
Rui

#24 lore raw

Re: [PATCH v2 08/16] usb: dwc3: add u2exit lfps quirk

Quoted 65 lines · Huang Rui
Quoted 26 lines · Felipe Balbi

Hi,

Quoted 15 lines · Huang Rui

AMD NL needs to enable u2exit lfps quirk.

---
 drivers/usb/dwc3/core.c          | 4 ++++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index 25db533..7322d85 100644

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 471

Quoted 5 lines
drivers/usb/dwc3/core.c +2 -0
@@ -467,6 +467,10 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		reg |= DWC3_GCTL_DISSCRAMBLE;
 	else
 		reg &= ~DWC3_GCTL_DISSCRAMBLE;
+
+	if (dwc->quirks & DWC3_QUIRK_U2EXIT_LFPS)

this should be:

Quoted 2 lines
	if (dwc->u2_exit_lfps_quirk)

OK, will update it in V3.

Quoted 17 lines
Quoted 17 lines
drivers/usb/dwc3/core.c +2 -0
+		reg |= DWC3_GCTL_U2EXIT_LFPS;
+
 	/*
 	 * WORKAROUND: DWC3 revisions <1.90a have a bug
 	 * where the device can fail to connect at SuperSpeed
drivers/usb/dwc3/core.h +1 -0
index d58479e..3d27f10 100644
@@ -166,6 +166,7 @@
 #define DWC3_GCTL_SCALEDOWN(n)		((n) << 4)
 #define DWC3_GCTL_SCALEDOWN_MASK	DWC3_GCTL_SCALEDOWN(3)
 #define DWC3_GCTL_DISSCRAMBLE		(1 << 3)
+#define DWC3_GCTL_U2EXIT_LFPS		(1 << 2)
 #define DWC3_GCTL_GBLHIBERNATIONEN	(1 << 1)
 #define DWC3_GCTL_DSBLCLKGTNG		(1 << 0)
 
Quoted 15 lines

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 154

Quoted 12 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
index bbe946c..cdb9b04 100644
@@ -149,7 +149,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 	if (pci->vendor == PCI_VENDOR_ID_AMD && pci->device ==
 			PCI_DEVICE_ID_AMD_NL) {
 		dwc3_pdata.has_lpm_erratum = true;
-		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL;
+		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
+			| DWC3_QUIRK_U2EXIT_LFPS;
 	}

should be combined and the last patch in the series.

Quoted 2 lines

You want to make all the AMD quirks enablement info and device id at last patch, right?

Correct, that way we avoid bisection points were AMD is "supported" but not working.

Signature · 1 line
balbi
author
#25 lore raw

PATCH v2 9/16 usb: dwc3: add P3 in U2 SS inactive quirk

In reply to Huang Rui

AMD NL needs to enable P3 OK for U2/SSInactive on USB3PIPE register.

---
 drivers/usb/dwc3/core.c          | 20 ++++++++++++++++++++
 drivers/usb/dwc3/core.h          |  1 +
 drivers/usb/dwc3/dwc3-pci.c      |  3 ++-
 drivers/usb/dwc3/platform_data.h |  1 +
 4 files changed, 24 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +20 -0
index 7322d85..9d0a249 100644
@@ -365,6 +365,24 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
 }
 
 /**
+ * dwc3_phy_setup - Configure USB3 PHY Interface of DWC3 Core
+ * @dwc: Pointer to our controller context structure
+ */
+static void dwc3_phy_setup(struct dwc3 *dwc)
+{
+	u32 reg;
+
+	reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
+
+	if (dwc->quirks & DWC3_QUIRK_U2SSINP3OK)
+		reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
+
+	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
+
+	mdelay(100);
+}
+
+/**
  * dwc3_core_init - Low-level initialization of DWC3 Core
  * @dwc: Pointer to our controller context structure
  *
@@ -484,6 +502,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	dwc3_writel(dwc->regs, DWC3_GCTL, reg);
 
+	dwc3_phy_setup(dwc);
+
 	ret = dwc3_alloc_scratch_buffers(dwc);
 	if (ret)
 		goto err1;
drivers/usb/dwc3/core.h +1 -0
index 3d27f10..71cb255 100644
@@ -176,6 +176,7 @@
 
 /* Global USB3 PIPE Control Register */
 #define DWC3_GUSB3PIPECTL_PHYSOFTRST	(1 << 31)
+#define DWC3_GUSB3PIPECTL_U2SSINP3OK	(1 << 29)
 #define DWC3_GUSB3PIPECTL_SUSPHY	(1 << 17)
 
 /* Global TX Fifo Size Register */
drivers/usb/dwc3/dwc3-pci.c +2 -1
index cdb9b04..1235eb3 100644
@@ -150,7 +150,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			PCI_DEVICE_ID_AMD_NL) {
 		dwc3_pdata.has_lpm_erratum = true;
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
-			| DWC3_QUIRK_U2EXIT_LFPS;
+			| DWC3_QUIRK_U2EXIT_LFPS
+			| DWC3_QUIRK_U2SSINP3OK;
 	}
 
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
drivers/usb/dwc3/platform_data.h +1 -0
index a6463c0..ad03563 100644
@@ -31,5 +31,6 @@ struct dwc3_platform_data {
 #define DWC3_QUIRK_AMD_NL		(1 << 0)
 #define DWC3_QUIRK_DISSCRAMBLE		(1 << 1)
 #define DWC3_QUIRK_U2EXIT_LFPS		(1 << 2)
+#define DWC3_QUIRK_U2SSINP3OK		(1 << 3)
 
 };
Signature · 1 line
1.9.1
#26 lore raw

Re: [PATCH v2 09/16] usb: dwc3: add P3 in U2 SS inactive quirk

Quoted 18 lines · Huang Rui

AMD NL needs to enable P3 OK for U2/SSInactive on USB3PIPE register.

---
 drivers/usb/dwc3/core.c          | 20 ++++++++++++++++++++
 drivers/usb/dwc3/core.h          |  1 +
 drivers/usb/dwc3/dwc3-pci.c      |  3 ++-
 drivers/usb/dwc3/platform_data.h |  1 +
 4 files changed, 24 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index 7322d85..9d0a249 100644
@@ -365,6 +365,24 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
 }
 
 /**

drivers/usb/dwc3/core.c static void dwc3_cache_hwparams(struct dwc3 *dwc) · line 377

Quoted 10 lines
drivers/usb/dwc3/core.c +10 -0
+ * dwc3_phy_setup - Configure USB3 PHY Interface of DWC3 Core
+ * @dwc: Pointer to our controller context structure
+ */
+static void dwc3_phy_setup(struct dwc3 *dwc)
+{
+	u32 reg;
+
+	reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
+
+	if (dwc->quirks & DWC3_QUIRK_U2SSINP3OK)
	if (dwc->p3_ok_on_ss_inactive_quirk)
Quoted 37 lines
drivers/usb/dwc3/core.c +10 -0
+		reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
+
+	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
+
+	mdelay(100);
+}
+
+/**
  * dwc3_core_init - Low-level initialization of DWC3 Core
  * @dwc: Pointer to our controller context structure
  *
@@ -484,6 +502,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	dwc3_writel(dwc->regs, DWC3_GCTL, reg);
 
+	dwc3_phy_setup(dwc);
+
 	ret = dwc3_alloc_scratch_buffers(dwc);
 	if (ret)
 		goto err1;
drivers/usb/dwc3/core.h +1 -0
index 3d27f10..71cb255 100644
@@ -176,6 +176,7 @@
 
 /* Global USB3 PIPE Control Register */
 #define DWC3_GUSB3PIPECTL_PHYSOFTRST	(1 << 31)
+#define DWC3_GUSB3PIPECTL_U2SSINP3OK	(1 << 29)
 #define DWC3_GUSB3PIPECTL_SUSPHY	(1 << 17)
 
 /* Global TX Fifo Size Register */
drivers/usb/dwc3/dwc3-pci.c +0 -0
index cdb9b04..1235eb3 100644

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 155

Quoted 7 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
@@ -150,7 +150,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			PCI_DEVICE_ID_AMD_NL) {
 		dwc3_pdata.has_lpm_erratum = true;
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
-			| DWC3_QUIRK_U2EXIT_LFPS;
+			| DWC3_QUIRK_U2EXIT_LFPS
+			| DWC3_QUIRK_U2SSINP3OK;
 	}

again to be combined in a single patch as the last patch in the series.

Signature · 1 line
balbi
author
#27 lore raw

PATCH v2 10/16 usb: dwc3: add request p1p2p3 quirk

In reply to Huang Rui

AMD NL needs to enable always request P1/P2/P3 for U1/U2/U3 for AMD own phy.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +3 -0
index 9d0a249..ec8b667 100644
@@ -377,6 +377,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_U2SSINP3OK)
 		reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
 
+	if (dwc->quirks & DWC3_QUIRK_REQP1P2P3)
+		reg |= DWC3_GUSB3PIPECTL_REQP1P2P3;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
 	mdelay(100);
drivers/usb/dwc3/core.h +1 -0
index 71cb255..8f47ade18 100644
@@ -177,6 +177,7 @@
 /* Global USB3 PIPE Control Register */
 #define DWC3_GUSB3PIPECTL_PHYSOFTRST	(1 << 31)
 #define DWC3_GUSB3PIPECTL_U2SSINP3OK	(1 << 29)
+#define DWC3_GUSB3PIPECTL_REQP1P2P3	(1 << 24)
 #define DWC3_GUSB3PIPECTL_SUSPHY	(1 << 17)
 
 /* Global TX Fifo Size Register */
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 1235eb3..7154d18 100644
@@ -151,7 +151,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 		dwc3_pdata.has_lpm_erratum = true;
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
 			| DWC3_QUIRK_U2EXIT_LFPS
-			| DWC3_QUIRK_U2SSINP3OK;
+			| DWC3_QUIRK_U2SSINP3OK
+			| DWC3_QUIRK_REQP1P2P3;
 	}
 
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
drivers/usb/dwc3/platform_data.h +1 -0
index ad03563..850883f 100644
@@ -32,5 +32,6 @@ struct dwc3_platform_data {
 #define DWC3_QUIRK_DISSCRAMBLE		(1 << 1)
 #define DWC3_QUIRK_U2EXIT_LFPS		(1 << 2)
 #define DWC3_QUIRK_U2SSINP3OK		(1 << 3)
+#define DWC3_QUIRK_REQP1P2P3		(1 << 4)
 
 };
Signature · 1 line
1.9.1
#28 lore raw

Re: [PATCH v2 10/16] usb: dwc3: add request p1p2p3 quirk

Quoted 15 lines · Huang Rui

AMD NL needs to enable always request P1/P2/P3 for U1/U2/U3 for AMD own phy.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index 9d0a249..ec8b667 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 380

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -377,6 +377,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_U2SSINP3OK)
 		reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
 
+	if (dwc->quirks & DWC3_QUIRK_REQP1P2P3)
	if (dwc->request_p1p2p3_quirk)

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 155

Quoted 11 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 1235eb3..7154d18 100644
@@ -151,7 +151,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 		dwc3_pdata.has_lpm_erratum = true;
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
 			| DWC3_QUIRK_U2EXIT_LFPS
-			| DWC3_QUIRK_U2SSINP3OK;
+			| DWC3_QUIRK_U2SSINP3OK
+			| DWC3_QUIRK_REQP1P2P3;

to be combined with the last patch in this series.

Signature · 1 line
balbi
author
#29 lore raw

PATCH v2 11/16 usb: dwc3: add delay p1p2p3 quirk

In reply to Huang Rui

AMD NL needs to delay P0 to P1/P2/P3 request when entering U1/U2/U3.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 2 ++
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +3 -0
index ec8b667..a9f1d4c 100644
@@ -380,6 +380,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_REQP1P2P3)
 		reg |= DWC3_GUSB3PIPECTL_REQP1P2P3;
 
+	if (dwc->quirks & DWC3_QUIRK_DEPP1P2P3)
+		reg |= DWC3_GUSB3PIPECTL_DEP1P2P3(1);
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
 	mdelay(100);
drivers/usb/dwc3/core.h +2 -0
index 8f47ade18..cf70fa6 100644
@@ -178,6 +178,8 @@
 #define DWC3_GUSB3PIPECTL_PHYSOFTRST	(1 << 31)
 #define DWC3_GUSB3PIPECTL_U2SSINP3OK	(1 << 29)
 #define DWC3_GUSB3PIPECTL_REQP1P2P3	(1 << 24)
+#define DWC3_GUSB3PIPECTL_DEP1P2P3_MASK	DWC3_GUSB3PIPECTL_DEP1P2P3(7)
+#define DWC3_GUSB3PIPECTL_DEP1P2P3(n)	((n) << 19)
 #define DWC3_GUSB3PIPECTL_SUSPHY	(1 << 17)
 
 /* Global TX Fifo Size Register */
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 7154d18..23ae6a7 100644
@@ -152,7 +152,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
 			| DWC3_QUIRK_U2EXIT_LFPS
 			| DWC3_QUIRK_U2SSINP3OK
-			| DWC3_QUIRK_REQP1P2P3;
+			| DWC3_QUIRK_REQP1P2P3
+			| DWC3_QUIRK_DEPP1P2P3;
 	}
 
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
drivers/usb/dwc3/platform_data.h +1 -0
index 850883f..e668c1f 100644
@@ -33,5 +33,6 @@ struct dwc3_platform_data {
 #define DWC3_QUIRK_U2EXIT_LFPS		(1 << 2)
 #define DWC3_QUIRK_U2SSINP3OK		(1 << 3)
 #define DWC3_QUIRK_REQP1P2P3		(1 << 4)
+#define DWC3_QUIRK_DEPP1P2P3		(1 << 5)
 
 };
Signature · 1 line
1.9.1
#30 lore raw

Re: [PATCH v2 11/16] usb: dwc3: add delay p1p2p3 quirk

Hi,

Quoted 15 lines · Huang Rui

AMD NL needs to delay P0 to P1/P2/P3 request when entering U1/U2/U3.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 2 ++
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index ec8b667..a9f1d4c 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 383

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -380,6 +380,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_REQP1P2P3)
 		reg |= DWC3_GUSB3PIPECTL_REQP1P2P3;
 
+	if (dwc->quirks & DWC3_QUIRK_DEPP1P2P3)
	if (dwc->delay_p1p2p3_quirk)

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 156

Quoted 11 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 7154d18..23ae6a7 100644
@@ -152,7 +152,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 		dwc3_pdata.quirks |= DWC3_QUIRK_AMD_NL
 			| DWC3_QUIRK_U2EXIT_LFPS
 			| DWC3_QUIRK_U2SSINP3OK
-			| DWC3_QUIRK_REQP1P2P3;
+			| DWC3_QUIRK_REQP1P2P3
+			| DWC3_QUIRK_DEPP1P2P3;

combined with last patch.

Signature · 1 line
balbi
author
#31 lore raw

PATCH v2 12/16 usb: dwc3: add delay phy power change quirk

In reply to Huang Rui

AMD NL needs to delay PHY power change from P0 to P1/P2/P3 when link state changing from U0 to U1/U2/U3 respectively.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +3 -0
index a9f1d4c..920a8ab 100644
@@ -383,6 +383,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_DEPP1P2P3)
 		reg |= DWC3_GUSB3PIPECTL_DEP1P2P3(1);
 
+	if (dwc->quirks & DWC3_QUIRK_DEPOCHANGE)
+		reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
 	mdelay(100);
drivers/usb/dwc3/core.h +1 -0
index cf70fa6..4c0200f 100644
@@ -180,6 +180,7 @@
 #define DWC3_GUSB3PIPECTL_REQP1P2P3	(1 << 24)
 #define DWC3_GUSB3PIPECTL_DEP1P2P3_MASK	DWC3_GUSB3PIPECTL_DEP1P2P3(7)
 #define DWC3_GUSB3PIPECTL_DEP1P2P3(n)	((n) << 19)
+#define DWC3_GUSB3PIPECTL_DEPOCHANGE	(1 << 18)
 #define DWC3_GUSB3PIPECTL_SUSPHY	(1 << 17)
 
 /* Global TX Fifo Size Register */
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 23ae6a7..0eb8b2a 100644
@@ -153,7 +153,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_U2EXIT_LFPS
 			| DWC3_QUIRK_U2SSINP3OK
 			| DWC3_QUIRK_REQP1P2P3
-			| DWC3_QUIRK_DEPP1P2P3;
+			| DWC3_QUIRK_DEPP1P2P3
+			| DWC3_QUIRK_DEPOCHANGE;
 	}
 
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
drivers/usb/dwc3/platform_data.h +1 -0
index e668c1f..934c5e1 100644
@@ -34,5 +34,6 @@ struct dwc3_platform_data {
 #define DWC3_QUIRK_U2SSINP3OK		(1 << 3)
 #define DWC3_QUIRK_REQP1P2P3		(1 << 4)
 #define DWC3_QUIRK_DEPP1P2P3		(1 << 5)
+#define DWC3_QUIRK_DEPOCHANGE		(1 << 6)
 
 };
Signature · 1 line
1.9.1
#32 lore raw

Re: [PATCH v2 12/16] usb: dwc3: add delay phy power change quirk

Hi,

Quoted 16 lines · Huang Rui

AMD NL needs to delay PHY power change from P0 to P1/P2/P3 when link state changing from U0 to U1/U2/U3 respectively.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index a9f1d4c..920a8ab 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 386

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -383,6 +383,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_DEPP1P2P3)
 		reg |= DWC3_GUSB3PIPECTL_DEP1P2P3(1);
 
+	if (dwc->quirks & DWC3_QUIRK_DEPOCHANGE)
	if (dwc->delay_p0_change_quirk)

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 157

Quoted 11 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 23ae6a7..0eb8b2a 100644
@@ -153,7 +153,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_U2EXIT_LFPS
 			| DWC3_QUIRK_U2SSINP3OK
 			| DWC3_QUIRK_REQP1P2P3
-			| DWC3_QUIRK_DEPP1P2P3;
+			| DWC3_QUIRK_DEPP1P2P3
+			| DWC3_QUIRK_DEPOCHANGE;

combined with the last patch

Signature · 1 line
balbi
author
#33 lore raw

PATCH v2 13/16 usb: dwc3: add lfps filter quirk

In reply to Huang Rui

AMD NL needs to enable lfps filter quirk.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +3 -0
index 920a8ab..a1ee586 100644
@@ -386,6 +386,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_DEPOCHANGE)
 		reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE;
 
+	if (dwc->quirks & DWC3_QUIRK_LFPSFILT)
+		reg |= DWC3_GUSB3PIPECTL_LFPSFILT;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
 	mdelay(100);
drivers/usb/dwc3/core.h +1 -0
index 4c0200f..5bdd5f5 100644
@@ -182,6 +182,7 @@
 #define DWC3_GUSB3PIPECTL_DEP1P2P3(n)	((n) << 19)
 #define DWC3_GUSB3PIPECTL_DEPOCHANGE	(1 << 18)
 #define DWC3_GUSB3PIPECTL_SUSPHY	(1 << 17)
+#define DWC3_GUSB3PIPECTL_LFPSFILT	(1 << 9)
 
 /* Global TX Fifo Size Register */
 #define DWC3_GTXFIFOSIZ_TXFDEF(n)	((n) & 0xffff)
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 0eb8b2a..d1f0901 100644
@@ -154,7 +154,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_U2SSINP3OK
 			| DWC3_QUIRK_REQP1P2P3
 			| DWC3_QUIRK_DEPP1P2P3
-			| DWC3_QUIRK_DEPOCHANGE;
+			| DWC3_QUIRK_DEPOCHANGE
+			| DWC3_QUIRK_LFPSFILT;
 	}
 
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
drivers/usb/dwc3/platform_data.h +1 -0
index 934c5e1..ac7860ab 100644
@@ -35,5 +35,6 @@ struct dwc3_platform_data {
 #define DWC3_QUIRK_REQP1P2P3		(1 << 4)
 #define DWC3_QUIRK_DEPP1P2P3		(1 << 5)
 #define DWC3_QUIRK_DEPOCHANGE		(1 << 6)
+#define DWC3_QUIRK_LFPSFILT		(1 << 7)
 
 };
Signature · 1 line
1.9.1
#34 lore raw

Re: [PATCH v2 13/16] usb: dwc3: add lfps filter quirk

Quoted 15 lines · Huang Rui

AMD NL needs to enable lfps filter quirk.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index 920a8ab..a1ee586 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 389

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -386,6 +386,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_DEPOCHANGE)
 		reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE;
 
+	if (dwc->quirks & DWC3_QUIRK_LFPSFILT)
	if (dwc->lfps_filter_quirk)

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 158

Quoted 11 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 0eb8b2a..d1f0901 100644
@@ -154,7 +154,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_U2SSINP3OK
 			| DWC3_QUIRK_REQP1P2P3
 			| DWC3_QUIRK_DEPP1P2P3
-			| DWC3_QUIRK_DEPOCHANGE;
+			| DWC3_QUIRK_DEPOCHANGE
+			| DWC3_QUIRK_LFPSFILT;

last patch

Signature · 1 line
balbi
author
#35 lore raw

PATCH v2 14/16 usb: dwc3: enable rx_detect to polling lfps quirk

In reply to Huang Rui

AMD NL needs to enable RX_DETECT to Polling.LFPS control quirk.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +3 -0
index a1ee586..f3c9699 100644
@@ -389,6 +389,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_LFPSFILT)
 		reg |= DWC3_GUSB3PIPECTL_LFPSFILT;
 
+	if (dwc->quirks & DWC3_QUIRK_RX_DETOPOLL)
+		reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
 	mdelay(100);
drivers/usb/dwc3/core.h +1 -0
index 5bdd5f5..1952759 100644
@@ -183,6 +183,7 @@
 #define DWC3_GUSB3PIPECTL_DEPOCHANGE	(1 << 18)
 #define DWC3_GUSB3PIPECTL_SUSPHY	(1 << 17)
 #define DWC3_GUSB3PIPECTL_LFPSFILT	(1 << 9)
+#define DWC3_GUSB3PIPECTL_RX_DETOPOLL	(1 << 8)
 
 /* Global TX Fifo Size Register */
 #define DWC3_GTXFIFOSIZ_TXFDEF(n)	((n) & 0xffff)
drivers/usb/dwc3/dwc3-pci.c +2 -1
index d1f0901..6f789fd 100644
@@ -155,7 +155,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_REQP1P2P3
 			| DWC3_QUIRK_DEPP1P2P3
 			| DWC3_QUIRK_DEPOCHANGE
-			| DWC3_QUIRK_LFPSFILT;
+			| DWC3_QUIRK_LFPSFILT
+			| DWC3_QUIRK_RX_DETOPOLL;
 	}
 
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
drivers/usb/dwc3/platform_data.h +1 -0
index ac7860ab..5df3419 100644
@@ -36,5 +36,6 @@ struct dwc3_platform_data {
 #define DWC3_QUIRK_DEPP1P2P3		(1 << 5)
 #define DWC3_QUIRK_DEPOCHANGE		(1 << 6)
 #define DWC3_QUIRK_LFPSFILT		(1 << 7)
+#define DWC3_QUIRK_RX_DETOPOLL		(1 << 8)
 
 };
Signature · 1 line
1.9.1
#36 lore raw

Re: [PATCH v2 14/16] usb: dwc3: enable rx_detect to polling lfps quirk

Quoted 15 lines · Huang Rui

AMD NL needs to enable RX_DETECT to Polling.LFPS control quirk.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 1 +
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index a1ee586..f3c9699 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 392

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -389,6 +389,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_LFPSFILT)
 		reg |= DWC3_GUSB3PIPECTL_LFPSFILT;
 
+	if (dwc->quirks & DWC3_QUIRK_RX_DETOPOLL)
	if (dwc->rx_detect_to_polling_quirk)

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 159

Quoted 11 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
index d1f0901..6f789fd 100644
@@ -155,7 +155,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_REQP1P2P3
 			| DWC3_QUIRK_DEPP1P2P3
 			| DWC3_QUIRK_DEPOCHANGE
-			| DWC3_QUIRK_LFPSFILT;
+			| DWC3_QUIRK_LFPSFILT
+			| DWC3_QUIRK_RX_DETOPOLL;

last patch.

Signature · 1 line
balbi
author
#37 lore raw

PATCH v2 15/16 usb: dwc3: add tx demphasis quirk

In reply to Huang Rui

AMD NL needs to enable Tx Deemphasis quirk.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 2 ++
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +3 -0
index f3c9699..3ccfe41 100644
@@ -392,6 +392,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_RX_DETOPOLL)
 		reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL;
 
+	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
+		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(1);
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
 	mdelay(100);
drivers/usb/dwc3/core.h +2 -0
index 1952759..1b137f4 100644
@@ -184,6 +184,8 @@
 #define DWC3_GUSB3PIPECTL_SUSPHY	(1 << 17)
 #define DWC3_GUSB3PIPECTL_LFPSFILT	(1 << 9)
 #define DWC3_GUSB3PIPECTL_RX_DETOPOLL	(1 << 8)
+#define DWC3_GUSB3PIPECTL_TX_DEEPH_MASK	DWC3_GUSB3PIPECTL_TX_DEEPH(3)
+#define DWC3_GUSB3PIPECTL_TX_DEEPH(n)	((n) << 1)
 
 /* Global TX Fifo Size Register */
 #define DWC3_GTXFIFOSIZ_TXFDEF(n)	((n) & 0xffff)
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 6f789fd..146eb2f 100644
@@ -156,7 +156,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_DEPP1P2P3
 			| DWC3_QUIRK_DEPOCHANGE
 			| DWC3_QUIRK_LFPSFILT
-			| DWC3_QUIRK_RX_DETOPOLL;
+			| DWC3_QUIRK_RX_DETOPOLL
+			| DWC3_QUIRK_TX_DEEPH;
 	}
 
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
drivers/usb/dwc3/platform_data.h +1 -0
index 5df3419..54f0e45 100644
@@ -37,5 +37,6 @@ struct dwc3_platform_data {
 #define DWC3_QUIRK_DEPOCHANGE		(1 << 6)
 #define DWC3_QUIRK_LFPSFILT		(1 << 7)
 #define DWC3_QUIRK_RX_DETOPOLL		(1 << 8)
+#define DWC3_QUIRK_TX_DEEPH		(1 << 9)
 
 };
Signature · 1 line
1.9.1
#38 lore raw

Re: [PATCH v2 15/16] usb: dwc3: add tx demphasis quirk

HI,

Quoted 15 lines · Huang Rui

AMD NL needs to enable Tx Deemphasis quirk.

---
 drivers/usb/dwc3/core.c          | 3 +++
 drivers/usb/dwc3/core.h          | 2 ++
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +0 -0
index f3c9699..3ccfe41 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 395

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -392,6 +392,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_RX_DETOPOLL)
 		reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL;
 
+	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
	if (dwc->tx_deemphasis_quirk)

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 160

Quoted 11 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 6f789fd..146eb2f 100644
@@ -156,7 +156,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_DEPP1P2P3
 			| DWC3_QUIRK_DEPOCHANGE
 			| DWC3_QUIRK_LFPSFILT
-			| DWC3_QUIRK_RX_DETOPOLL;
+			| DWC3_QUIRK_RX_DETOPOLL
+			| DWC3_QUIRK_TX_DEEPH;

last patch.

Signature · 1 line
balbi
author
#39 lore raw

PATCH v2 16/16 usb: dwc3: enable usb suspend phy

In reply to Huang Rui

AMD NL needs to suspend usb3 ss phy, but this doesn't enable on simulation board.

---
 drivers/usb/dwc3/core.c          | 7 ++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/core.c +6 -1
index 3ccfe41..4a98696 100644
@@ -395,6 +395,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
 		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(1);
 
+	if (dwc->quirks & DWC3_QUIRK_SUSPHY)
+		reg |= DWC3_GUSB3PIPECTL_SUSPHY;
+
 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
 	mdelay(100);
@@ -496,8 +499,10 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		dwc->is_fpga = true;
 	}
 
-	if ((dwc->quirks & DWC3_QUIRK_AMD_NL) && dwc->is_fpga)
+	if ((dwc->quirks & DWC3_QUIRK_AMD_NL) && dwc->is_fpga) {
 		dwc->quirks |= DWC3_QUIRK_DISSCRAMBLE;
+		dwc->quirks &= ~DWC3_QUIRK_SUSPHY;
+	}
 
 	if (dwc->quirks & DWC3_QUIRK_DISSCRAMBLE)
 		reg |= DWC3_GCTL_DISSCRAMBLE;
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 146eb2f..71401a3 100644
@@ -157,7 +157,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_DEPOCHANGE
 			| DWC3_QUIRK_LFPSFILT
 			| DWC3_QUIRK_RX_DETOPOLL
-			| DWC3_QUIRK_TX_DEEPH;
+			| DWC3_QUIRK_TX_DEEPH
+			| DWC3_QUIRK_SUSPHY;
 	}
 
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
drivers/usb/dwc3/platform_data.h +1 -0
index 54f0e45..f68cd97 100644
@@ -38,5 +38,6 @@ struct dwc3_platform_data {
 #define DWC3_QUIRK_LFPSFILT		(1 << 7)
 #define DWC3_QUIRK_RX_DETOPOLL		(1 << 8)
 #define DWC3_QUIRK_TX_DEEPH		(1 << 9)
+#define DWC3_QUIRK_SUSPHY		(1 << 10)
 
 };
Signature · 1 line
1.9.1
#40 lore raw

Re: [PATCH v2 16/16] usb: dwc3: enable usb suspend phy

Hi,

Quoted 15 lines · Huang Rui

AMD NL needs to suspend usb3 ss phy, but this doesn't enable on simulation board.

---
 drivers/usb/dwc3/core.c          | 7 ++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/core.c +0 -0
index 3ccfe41..4a98696 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 398

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -395,6 +395,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
 		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(1);
 
+	if (dwc->quirks & DWC3_QUIRK_SUSPHY)

should be:

	if (!dwc->suspend_usb3_phy_quirk)

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 399

Quoted 1 line
drivers/usb/dwc3/core.c +1 -0
+		reg |= DWC3_GUSB3PIPECTL_SUSPHY;

IIRC, databook asks us to set that bit anyway, so the quirk is disabling that bit. Am I missing something ? Paul ?

drivers/usb/dwc3/dwc3-pci.c static int dwc3_pci_probe(struct pci_dev *pci, · line 161

Quoted 11 lines
drivers/usb/dwc3/dwc3-pci.c +2 -1
index 146eb2f..71401a3 100644
@@ -157,7 +157,8 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 			| DWC3_QUIRK_DEPOCHANGE
 			| DWC3_QUIRK_LFPSFILT
 			| DWC3_QUIRK_RX_DETOPOLL
-			| DWC3_QUIRK_TX_DEEPH;
+			| DWC3_QUIRK_TX_DEEPH
+			| DWC3_QUIRK_SUSPHY;

last patch

Signature · 1 line
balbi
#41 lore raw

RE: [PATCH v2 16/16] usb: dwc3: enable usb suspend phy

Quoted 26 lines

From: Felipe Balbi [mailto:[email protected]]
Sent: Friday, October 17, 2014 8:00 AM

Quoted 15 lines · Huang Rui

AMD NL needs to suspend usb3 ss phy, but this doesn't enable on simulation board.

---
 drivers/usb/dwc3/core.c          | 7 ++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/core.c +0 -0
index 3ccfe41..4a98696 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 398

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -395,6 +395,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
 		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(1);
 
+	if (dwc->quirks & DWC3_QUIRK_SUSPHY)

should be:

Quoted 6 lines
	if (!dwc->suspend_usb3_phy_quirk)

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 399

Quoted 1 line
drivers/usb/dwc3/core.c +1 -0
+		reg |= DWC3_GUSB3PIPECTL_SUSPHY;

IIRC, databook asks us to set that bit anyway, so the quirk is disabling that bit. Am I missing something ? Paul ?

It looks to me that Huang's patch is enabling that bit, not disabling it.

Currently the driver does not set either DWC3_GUSB3PIPECTL_SUSPHY or DWC3_GUSB2PHYCFG_SUSPHY (unless it has been added by that big patch series you just posted). According to the databook, both of those bits should be set to 1 after the core initialization has completed.

So I think the driver should be changed to enable both of those by default, and then maybe you want quirks to disable them if there is some platform out there which needs that.

Signature · 1 line
Paul
#42 lore raw

Re: [PATCH v2 16/16] usb: dwc3: enable usb suspend phy

Hi,

Quoted 28 lines · Paul Zimmerman
Quoted 28 lines

From: Felipe Balbi [mailto:[email protected]]
Sent: Friday, October 17, 2014 8:00 AM

Quoted 15 lines · Huang Rui

AMD NL needs to suspend usb3 ss phy, but this doesn't enable on simulation board.

---
 drivers/usb/dwc3/core.c          | 7 ++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/core.c +0 -0
index 3ccfe41..4a98696 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 398

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -395,6 +395,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
 		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(1);
 
+	if (dwc->quirks & DWC3_QUIRK_SUSPHY)

should be:

	if (!dwc->suspend_usb3_phy_quirk)
Quoted 7 lines
Quoted 4 lines

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 399

Quoted 1 line
drivers/usb/dwc3/core.c +1 -0
+		reg |= DWC3_GUSB3PIPECTL_SUSPHY;

IIRC, databook asks us to set that bit anyway, so the quirk is disabling that bit. Am I missing something ? Paul ?

It looks to me that Huang's patch is enabling that bit, not disabling it.

right, but that's what's actually quirky right ? IIRC, Databook asks us to set usb2 and usb3 suspend phy bits and we're just not doing it.

Quoted 4 lines

Currently the driver does not set either DWC3_GUSB3PIPECTL_SUSPHY or DWC3_GUSB2PHYCFG_SUSPHY (unless it has been added by that big patch series you just posted). According to the databook, both of those bits should be set to 1 after the core initialization has completed.

there you go. So unless that quirk bit flag is set, we're safe of setting SUSPHY bit for everybody.

Quoted 3 lines

So I think the driver should be changed to enable both of those by default, and then maybe you want quirks to disable them if there is some platform out there which needs that.

Yeah, that's what I thought too :-) Thanks for confirming

Signature · 1 line
balbi
author
#43 lore raw

Re: [PATCH v2 16/16] usb: dwc3: enable usb suspend phy

Quoted 42 lines · Felipe Balbi

Hi,

Quoted 28 lines · Paul Zimmerman
Quoted 28 lines

From: Felipe Balbi [mailto:[email protected]]
Sent: Friday, October 17, 2014 8:00 AM

Quoted 15 lines · Huang Rui

AMD NL needs to suspend usb3 ss phy, but this doesn't enable on simulation board.

---
 drivers/usb/dwc3/core.c          | 7 ++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/core.c +0 -0
index 3ccfe41..4a98696 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 398

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -395,6 +395,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
 		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(1);
 
+	if (dwc->quirks & DWC3_QUIRK_SUSPHY)

should be:

	if (!dwc->suspend_usb3_phy_quirk)
Quoted 7 lines
Quoted 4 lines

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 399

Quoted 1 line
drivers/usb/dwc3/core.c +1 -0
+		reg |= DWC3_GUSB3PIPECTL_SUSPHY;

IIRC, databook asks us to set that bit anyway, so the quirk is disabling that bit. Am I missing something ? Paul ?

It looks to me that Huang's patch is enabling that bit, not disabling it.

right, but that's what's actually quirky right ? IIRC, Databook asks us to set usb2 and usb3 suspend phy bits and we're just not doing it.

Quoted 8 lines
Quoted 4 lines

Currently the driver does not set either DWC3_GUSB3PIPECTL_SUSPHY or DWC3_GUSB2PHYCFG_SUSPHY (unless it has been added by that big patch series you just posted). According to the databook, both of those bits should be set to 1 after the core initialization has completed.

there you go. So unless that quirk bit flag is set, we're safe of setting SUSPHY bit for everybody.

So I can update to set these two suspend phy bits defaultly in my next patch set, is it OK? :)

Thanks,
Rui

Quoted 8 lines
Quoted 3 lines

So I think the driver should be changed to enable both of those by default, and then maybe you want quirks to disable them if there is some platform out there which needs that.

Yeah, that's what I thought too :-) Thanks for confirming

Signature · 1 line
balbi
author
#44 lore raw

Re: [PATCH v2 16/16] usb: dwc3: enable usb suspend phy

Quoted 43 lines · Huang Rui
Quoted 42 lines · Felipe Balbi

Hi,

Quoted 28 lines · Paul Zimmerman
Quoted 28 lines

From: Felipe Balbi [mailto:[email protected]]
Sent: Friday, October 17, 2014 8:00 AM

Quoted 15 lines · Huang Rui

AMD NL needs to suspend usb3 ss phy, but this doesn't enable on simulation board.

---
 drivers/usb/dwc3/core.c          | 7 ++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/core.c +0 -0
index 3ccfe41..4a98696 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 398

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -395,6 +395,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
 		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(1);
 
+	if (dwc->quirks & DWC3_QUIRK_SUSPHY)

should be:

	if (!dwc->suspend_usb3_phy_quirk)
Quoted 7 lines
Quoted 4 lines

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 399

Quoted 1 line
drivers/usb/dwc3/core.c +1 -0
+		reg |= DWC3_GUSB3PIPECTL_SUSPHY;

IIRC, databook asks us to set that bit anyway, so the quirk is disabling that bit. Am I missing something ? Paul ?

It looks to me that Huang's patch is enabling that bit, not disabling it.

right, but that's what's actually quirky right ? IIRC, Databook asks us to set usb2 and usb3 suspend phy bits and we're just not doing it.

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

Currently the driver does not set either DWC3_GUSB3PIPECTL_SUSPHY or DWC3_GUSB2PHYCFG_SUSPHY (unless it has been added by that big patch series you just posted). According to the databook, both of those bits should be set to 1 after the core initialization has completed.

there you go. So unless that quirk bit flag is set, we're safe of setting SUSPHY bit for everybody.

I read the databook again, below words (DWC3_GUSB3PIPECTL_SUSPHY) is copied from databook:

For DRD/OTG configurations, it is recommended that this bit is set to‘ 0’ during coreConsultant configuration. If it is set to ’1’, then the application should clear this bit after power-on reset. Application needs to set it to ’1’ after the core initialization is completed. For all other configurations, this bit can be set to ’1’ during core configuration.

I see it's recommended to set '0' if on DRD/OTG configuration.

Thanks,
Rui

#45 lore raw

RE: [PATCH v2 16/16] usb: dwc3: enable usb suspend phy

PiBGcm9tOiBIdWFuZyBSdWkgW21haWx0bzpyYXkuaHVhbmdAYW1kLmNvbV0NCj4gU2VudDogTW9u ZGF5LCBPY3RvYmVyIDIwLCAyMDE0IDI6MDEgQU0NCj4gDQo+IE9uIE1vbiwgT2N0IDIwLCAyMDE0 IGF0IDA0OjQxOjU0UE0gKzA4MDAsIEh1YW5nIFJ1aSB3cm90ZToNCj4gPiBPbiBGcmksIE9jdCAx NywgMjAxNCBhdCAwMTo0ODoxOVBNIC0wNTAwLCBGZWxpcGUgQmFsYmkgd3JvdGU6DQo+ID4gPiBI aSwNCj4gPiA+DQo+ID4gPiBPbiBGcmksIE9jdCAxNywgMjAxNCBhdCAwNjo0MTowNFBNICswMDAw LCBQYXVsIFppbW1lcm1hbiB3cm90ZToNCj4gPiA+ID4gPiBGcm9tOiBGZWxpcGUgQmFsYmkgW21h aWx0bzpiYWxiaUB0aS5jb21dDQo+ID4gPiA+ID4gU2VudDogRnJpZGF5LCBPY3RvYmVyIDE3LCAy MDE0IDg6MDAgQU0NCj4gPiA+ID4gPg0KPiA+ID4gPiA+IE9uIEZyaSwgT2N0IDE3LCAyMDE0IGF0 IDA0OjUzOjQxUE0gKzA4MDAsIEh1YW5nIFJ1aSB3cm90ZToNCj4gPiA+ID4gPiA+IEFNRCBOTCBu ZWVkcyB0byBzdXNwZW5kIHVzYjMgc3MgcGh5LCBidXQgdGhpcyBkb2Vzbid0IGVuYWJsZSBvbiBz aW11bGF0aW9uDQo+ID4gPiA+ID4gPiBib2FyZC4NCj4gPiA+ID4gPiA+DQo+ID4gPiA+ID4gPiBT aWduZWQtb2ZmLWJ5OiBIdWFuZyBSdWkgPHJheS5odWFuZ0BhbWQuY29tPg0KPiA+ID4gPiA+ID4g LS0tDQo+ID4gPiA+ID4gPiAgZHJpdmVycy91c2IvZHdjMy9jb3JlLmMgICAgICAgICAgfCA3ICsr KysrKy0NCj4gPiA+ID4gPiA+ICBkcml2ZXJzL3VzYi9kd2MzL2R3YzMtcGNpLmMgICAgICB8IDMg KystDQo+ID4gPiA+ID4gPiAgZHJpdmVycy91c2IvZHdjMy9wbGF0Zm9ybV9kYXRhLmggfCAxICsN Cj4gPiA+ID4gPiA+ICAzIGZpbGVzIGNoYW5nZWQsIDkgaW5zZXJ0aW9ucygrKSwgMiBkZWxldGlv bnMoLSkNCj4gPiA+ID4gPiA+DQo+ID4gPiA+ID4gPiBkaWZmIC0tZ2l0IGEvZHJpdmVycy91c2Iv ZHdjMy9jb3JlLmMgYi9kcml2ZXJzL3VzYi9kd2MzL2NvcmUuYw0KPiA+ID4gPiA+ID4gaW5kZXgg M2NjZmU0MS4uNGE5ODY5NiAxMDA2NDQNCj4gPiA+ID4gPiA+IC0tLSBhL2RyaXZlcnMvdXNiL2R3 YzMvY29yZS5jDQo+ID4gPiA+ID4gPiArKysgYi9kcml2ZXJzL3VzYi9kd2MzL2NvcmUuYw0KPiA+ ID4gPiA+ID4gQEAgLTM5NSw2ICszOTUsOSBAQCBzdGF0aWMgdm9pZCBkd2MzX3BoeV9zZXR1cChz dHJ1Y3QgZHdjMyAqZHdjKQ0KPiA+ID4gPiA+ID4gIAlpZiAoZHdjLT5xdWlya3MgJiBEV0MzX1FV SVJLX1RYX0RFRVBIKQ0KPiA+ID4gPiA+ID4gIAkJcmVnIHw9IERXQzNfR1VTQjNQSVBFQ1RMX1RY X0RFRVBIKDEpOw0KPiA+ID4gPiA+ID4NCj4gPiA+ID4gPiA+ICsJaWYgKGR3Yy0+cXVpcmtzICYg RFdDM19RVUlSS19TVVNQSFkpDQo+ID4gPiA+ID4NCj4gPiA+ID4gPiBzaG91bGQgYmU6DQo+ID4g PiA+ID4NCj4gPiA+ID4gPiAJaWYgKCFkd2MtPnN1c3BlbmRfdXNiM19waHlfcXVpcmspDQo+ID4g PiA+ID4NCj4gPiA+ID4gPiA+ICsJCXJlZyB8PSBEV0MzX0dVU0IzUElQRUNUTF9TVVNQSFk7DQo+ ID4gPiA+ID4NCj4gPiA+ID4gPiBJSVJDLCBkYXRhYm9vayBhc2tzIHVzIHRvIHNldCB0aGF0IGJp dCBhbnl3YXksIHNvIHRoZSBxdWlyayBpcyBkaXNhYmxpbmcNCj4gPiA+ID4gPiB0aGF0IGJpdC4g QW0gSSBtaXNzaW5nIHNvbWV0aGluZyA/IFBhdWwgPw0KPiA+ID4gPg0KPiA+ID4gPiBJdCBsb29r cyB0byBtZSB0aGF0IEh1YW5nJ3MgcGF0Y2ggaXMgZW5hYmxpbmcgdGhhdCBiaXQsIG5vdCBkaXNh YmxpbmcNCj4gPiA+ID4gaXQuDQo+ID4gPg0KPiA+ID4gcmlnaHQsIGJ1dCB0aGF0J3Mgd2hhdCdz IGFjdHVhbGx5IHF1aXJreSByaWdodCA/IElJUkMsIERhdGFib29rIGFza3MgdXMNCj4gPiA+IHRv IHNldCB1c2IyIGFuZCB1c2IzIHN1c3BlbmQgcGh5IGJpdHMgYW5kIHdlJ3JlIGp1c3Qgbm90IGRv aW5nIGl0Lg0KPiA+ID4NCj4gPiA+ID4gQ3VycmVudGx5IHRoZSBkcml2ZXIgZG9lcyBub3Qgc2V0 IGVpdGhlciBEV0MzX0dVU0IzUElQRUNUTF9TVVNQSFkgb3INCj4gPiA+ID4gRFdDM19HVVNCMlBI WUNGR19TVVNQSFkgKHVubGVzcyBpdCBoYXMgYmVlbiBhZGRlZCBieSB0aGF0IGJpZyBwYXRjaA0K PiA+ID4gPiBzZXJpZXMgeW91IGp1c3QgcG9zdGVkKS4gQWNjb3JkaW5nIHRvIHRoZSBkYXRhYm9v aywgYm90aCBvZiB0aG9zZQ0KPiA+ID4gPiBiaXRzIHNob3VsZCBiZSBzZXQgdG8gMSBhZnRlciB0 aGUgY29yZSBpbml0aWFsaXphdGlvbiBoYXMgY29tcGxldGVkLg0KPiA+ID4NCj4gPiA+IHRoZXJl IHlvdSBnby4gU28gdW5sZXNzIHRoYXQgcXVpcmsgYml0IGZsYWcgaXMgc2V0LCB3ZSdyZSBzYWZl IG9mDQo+ID4gPiBzZXR0aW5nIFNVU1BIWSBiaXQgZm9yIGV2ZXJ5Ym9keS4NCj4gPiA+DQo+ID4N Cj4gDQo+IEkgcmVhZCB0aGUgZGF0YWJvb2sgYWdhaW4sIGJlbG93IHdvcmRzIChEV0MzX0dVU0Iz UElQRUNUTF9TVVNQSFkpIGlzDQo+IGNvcGllZCBmcm9tIGRhdGFib29rOg0KPiANCj4gRm9yIERS RC9PVEcgY29uZmlndXJhdGlvbnMsIGl0IGlzIHJlY29tbWVuZGVkIHRoYXQgdGhpcyBiaXQgaXMg c2V0IHRv4oCYDQo+IDDigJkgZHVyaW5nIGNvcmVDb25zdWx0YW50IGNvbmZpZ3VyYXRpb24uIElm IGl0IGlzIHNldCB0byDigJkx4oCZLCB0aGVuIHRoZQ0KPiBhcHBsaWNhdGlvbiBzaG91bGQgY2xl YXIgdGhpcyBiaXQgYWZ0ZXIgcG93ZXItb24gcmVzZXQuIEFwcGxpY2F0aW9uDQo+IG5lZWRzIHRv IHNldCBpdCB0byDigJkx4oCZIGFmdGVyIHRoZSBjb3JlIGluaXRpYWxpemF0aW9uIGlzIGNvbXBs ZXRlZC4NCj4gRm9yIGFsbCBvdGhlciBjb25maWd1cmF0aW9ucywgdGhpcyBiaXQgY2FuIGJlIHNl dCB0byDigJkx4oCZIGR1cmluZyBjb3JlDQo+IGNvbmZpZ3VyYXRpb24uDQo+IA0KPiBJIHNlZSBp dCdzIHJlY29tbWVuZGVkIHRvIHNldCAnMCcgaWYgb24gRFJEL09URyBjb25maWd1cmF0aW9uLg0K DQpObywgaXQncyByZWNvbW1lbmRlZCB0byBzZXQgaXQgdG8gJzAnIGR1cmluZyBjb3JlQ29uc3Vs dGFudA0KY29uZmlndXJhdGlvbi4gVGhpcyBpcyBhIHBhcnQgb2YgdGhlIHN5bnRoZXNpcyBwcm9j ZXNzLCBpLmUuIHdoZW4NCmJ1aWxkaW5nIHRoZSBSVEwgZm9yIHRoZSBTb0MuIFRoaXMgZGV0ZXJt aW5lcyB3aGF0IHRoZSBkZWZhdWx0IHZhbHVlDQpvZiB0aGUgYml0IHdpbGwgYmUgd2hlbiB0aGUg Y29yZSBpcyByZXNldC4gQXQgcnVudGltZSBpdCBpcyBzdGlsbA0KcmVjb21tZW5kZWQgdG8gc2V0 IGl0IHRvICcxJyB3aGVuIGluIGRldmljZSBtb2RlLCBhZnRlciB0aGUgY29yZQ0KaW5pdGlhbGl6 YXRpb24gaXMgY29tcGxldGVkLg0KDQotLSANClBhdWwNCg0K

#46 lore raw

Re: [PATCH v2 16/16] usb: dwc3: enable usb suspend phy

In reply to Huang Rui
Quoted 57 lines · Huang Rui
Quoted 43 lines · Huang Rui
Quoted 42 lines · Felipe Balbi

Hi,

Quoted 28 lines · Paul Zimmerman
Quoted 28 lines

From: Felipe Balbi [mailto:[email protected]]
Sent: Friday, October 17, 2014 8:00 AM

Quoted 15 lines · Huang Rui

AMD NL needs to suspend usb3 ss phy, but this doesn't enable on simulation board.

---
 drivers/usb/dwc3/core.c          | 7 ++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/core.c +0 -0
index 3ccfe41..4a98696 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 398

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -395,6 +395,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
 		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(1);
 
+	if (dwc->quirks & DWC3_QUIRK_SUSPHY)

should be:

	if (!dwc->suspend_usb3_phy_quirk)
Quoted 7 lines
Quoted 4 lines

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 399

Quoted 1 line
drivers/usb/dwc3/core.c +1 -0
+		reg |= DWC3_GUSB3PIPECTL_SUSPHY;

IIRC, databook asks us to set that bit anyway, so the quirk is disabling that bit. Am I missing something ? Paul ?

It looks to me that Huang's patch is enabling that bit, not disabling it.

right, but that's what's actually quirky right ? IIRC, Databook asks us to set usb2 and usb3 suspend phy bits and we're just not doing it.

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

Currently the driver does not set either DWC3_GUSB3PIPECTL_SUSPHY or DWC3_GUSB2PHYCFG_SUSPHY (unless it has been added by that big patch series you just posted). According to the databook, both of those bits should be set to 1 after the core initialization has completed.

there you go. So unless that quirk bit flag is set, we're safe of setting SUSPHY bit for everybody.

I read the databook again, below words (DWC3_GUSB3PIPECTL_SUSPHY) is copied from databook:

Quoted 8 lines

For DRD/OTG configurations, it is recommended that this bit is set to‘ 0’ during coreConsultant configuration. If it is set to ’1’, then the application should clear this bit after power-on reset. Application needs to set it to ’1’ after the core initialization is completed. For all other configurations, this bit can be set to ’1’ during core configuration.

I see it's recommended to set '0' if on DRD/OTG configuration.

0 at the beginning of probe() sequence so core can communicate with its PHYs, then set it to one at the end of probe().

Signature · 1 line
balbi
#47 lore raw

Re: [PATCH v2 16/16] usb: dwc3: enable usb suspend phy

In reply to Huang Rui

Hi,

Quoted 48 lines · Huang Rui
Quoted 47 lines · Felipe Balbi

Hi,

Quoted 28 lines · Paul Zimmerman
Quoted 28 lines

From: Felipe Balbi [mailto:[email protected]]
Sent: Friday, October 17, 2014 8:00 AM

Quoted 15 lines · Huang Rui

AMD NL needs to suspend usb3 ss phy, but this doesn't enable on simulation board.

---
 drivers/usb/dwc3/core.c          | 7 ++++++-
 drivers/usb/dwc3/dwc3-pci.c      | 3 ++-
 drivers/usb/dwc3/platform_data.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/core.c +0 -0
index 3ccfe41..4a98696 100644

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 398

Quoted 4 lines
drivers/usb/dwc3/core.c +1 -0
@@ -395,6 +395,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 	if (dwc->quirks & DWC3_QUIRK_TX_DEEPH)
 		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(1);
 
+	if (dwc->quirks & DWC3_QUIRK_SUSPHY)

should be:

	if (!dwc->suspend_usb3_phy_quirk)
Quoted 7 lines
Quoted 4 lines

drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 399

Quoted 1 line
drivers/usb/dwc3/core.c +1 -0
+		reg |= DWC3_GUSB3PIPECTL_SUSPHY;

IIRC, databook asks us to set that bit anyway, so the quirk is disabling that bit. Am I missing something ? Paul ?

It looks to me that Huang's patch is enabling that bit, not disabling it.

right, but that's what's actually quirky right ? IIRC, Databook asks us to set usb2 and usb3 suspend phy bits and we're just not doing it.

Quoted 4 lines

Currently the driver does not set either DWC3_GUSB3PIPECTL_SUSPHY or DWC3_GUSB2PHYCFG_SUSPHY (unless it has been added by that big patch series you just posted). According to the databook, both of those bits should be set to 1 after the core initialization has completed.

Quoted 6 lines
Quoted 3 lines

there you go. So unless that quirk bit flag is set, we're safe of setting SUSPHY bit for everybody.

So I can update to set these two suspend phy bits defaultly in my next patch set, is it OK? :)

We need to split this into two patches:

patch 1 adds missing SUSPHY bit for all cores above revision 1.94a at the end of probe()

patch 2 adds a quirk which AMD needs so that setting USB3_SUSPHY bit is conditional on that quirk.

Signature · 1 line
balbi
#48 lore raw
In reply to Huang Rui

Hi,

Quoted 6 lines · Huang Rui

The series of patches add AMD NL SoC support for DesignWare USB3 OTG IP with PCI bus glue layer. This controller supported hibernation, LPM erratum and used the 2.80a IP version and amd own phy. Current implementation support both simulation and SoC platform. And already tested with gadget zero and msc tool. It works well on file storage gadget.

patches look much, much nicer there are still a few things to fix. A global set of issues which I see:

1) Let's get confirmation that all those quirks will be needed in production as well, I have a feeling quite a few of them won't be.

2) All quirks should become 1-bit fields insteads of single-bits on a 32-bit variable.

3) All quirks should have DeviceTree counterparts. They should all become boolean properties should we can:

	dwc->tx_deemphasis_quirk = of_property_read_bool(node,
		"snps,tx_deemphasis_quirk");
Quoted 11 lines

These patches are generated on balbi/testing/next

Changes from v1 -> v2
- remove dual role function temporarily
- add pci quirk to avoid to bind with xhci driver
- distinguish between simulation board and soc
- break down all the special quirks

Patch 1:
- add PCI device id into pci bus glue

this guy should be the last in the series, with all AMD quirks being enabled at once. This will avoid bisection points where AMD's platforms don't work.

Quoted 1 line

Patch 2:

this should become as patch one :-)

Quoted 15 lines

- add PCI quirk to avoid to bind with xhci

Patch 3:
- enable hibernation

Patch 4:
- distinguish between simulation board and soc

Patch 5:
- add quirks flag to be compatible for kinds of soc

Patch 6 - 16:
- as felipe's suggestion, break down all the special quirks of amd nl

Quoted 5 lines

Patch set already passed all the MSC testing, detailed result is below:

root@hr-ub:/home/ray/felipe/usb-tools# ./msc.sh -o /dev/sdb1
test 0e: simple 64k read/write
test  0: sent      62.50 MB read      22.00 MB/s write      16.33 MB/s ... success

Are you still running with VERBOSE_DEBUG on USB2 ? Here's what I get on USB2 connected to my PC with DWC3 running on a single-core cortex-a9 board:

$ ./msc -t0 -o /dev/sdh -s 65536 -c 5000
test  0: sent     312.50 MB read      31.63 MB/s write      29.10 MB/s ... success

And with RAM as backend:

$ ./msc -t0 -o /dev/sdh -s 65536 -c 5000
test  0: sent     312.50 MB read      31.64 MB/s write      29.04 MB/s ... success

cheers

Signature · 1 line
balbi
author
#49 lore raw
Quoted 16 lines · Felipe Balbi

Hi,

Quoted 6 lines · Huang Rui

The series of patches add AMD NL SoC support for DesignWare USB3 OTG IP with PCI bus glue layer. This controller supported hibernation, LPM erratum and used the 2.80a IP version and amd own phy. Current implementation support both simulation and SoC platform. And already tested with gadget zero and msc tool. It works well on file storage gadget.

patches look much, much nicer there are still a few things to fix. A global set of issues which I see:

1) Let's get confirmation that all those quirks will be needed in production as well, I have a feeling quite a few of them won't be.

Quoted 9 lines

2) All quirks should become 1-bit fields insteads of single-bits on a 32-bit variable.

3) All quirks should have DeviceTree counterparts. They should all become boolean properties should we can:

	dwc->tx_deemphasis_quirk = of_property_read_bool(node,
		"snps,tx_deemphasis_quirk");

Thanks to summarize them. Will update in V3.

Quoted 9 lines
Quoted 9 lines

These patches are generated on balbi/testing/next

Changes from v1 -> v2
- remove dual role function temporarily
- add pci quirk to avoid to bind with xhci driver
- distinguish between simulation board and soc
- break down all the special quirks

Quoted 7 lines
Quoted 2 lines

Patch 1:
- add PCI device id into pci bus glue

this guy should be the last in the series, with all AMD quirks being enabled at once. This will avoid bisection points where AMD's platforms don't work.

So all the AMD special configuration and device id should be in one patch, right?

Quoted 29 lines
Quoted 1 line

Patch 2:

this should become as patch one :-)

Quoted 15 lines

- add PCI quirk to avoid to bind with xhci

Patch 3:
- enable hibernation

Patch 4:
- distinguish between simulation board and soc

Patch 5:
- add quirks flag to be compatible for kinds of soc

Patch 6 - 16:
- as felipe's suggestion, break down all the special quirks of amd nl

Quoted 5 lines

Patch set already passed all the MSC testing, detailed result is below:

root@hr-ub:/home/ray/felipe/usb-tools# ./msc.sh -o /dev/sdb1
test 0e: simple 64k read/write
test  0: sent      62.50 MB read      22.00 MB/s write      16.33 MB/s ... success

Are you still running with VERBOSE_DEBUG on USB2 ? Here's what I get on USB2 connected to my PC with DWC3 running on a single-core cortex-a9 board:

Quoted 8 lines
$ ./msc -t0 -o /dev/sdh -s 65536 -c 5000
test  0: sent     312.50 MB read      31.63 MB/s write      29.10 MB/s ... success

And with RAM as backend:

$ ./msc -t0 -o /dev/sdh -s 65536 -c 5000
test  0: sent     312.50 MB read      31.64 MB/s write      29.04 MB/s ... success

Yes, I will disable DEBUG option to test again.

Thanks,
Rui

#50 lore raw

Hi,

Quoted 20 lines · Huang Rui
Quoted 19 lines · Felipe Balbi

Hi,

Quoted 6 lines · Huang Rui

The series of patches add AMD NL SoC support for DesignWare USB3 OTG IP with PCI bus glue layer. This controller supported hibernation, LPM erratum and used the 2.80a IP version and amd own phy. Current implementation support both simulation and SoC platform. And already tested with gadget zero and msc tool. It works well on file storage gadget.

patches look much, much nicer there are still a few things to fix. A global set of issues which I see:

1) Let's get confirmation that all those quirks will be needed in production as well, I have a feeling quite a few of them won't be.

2) All quirks should become 1-bit fields insteads of single-bits on a 32-bit variable.

Quoted 8 lines
Quoted 6 lines

3) All quirks should have DeviceTree counterparts. They should all become boolean properties should we can:

	dwc->tx_deemphasis_quirk = of_property_read_bool(node,
		"snps,tx_deemphasis_quirk");

Thanks to summarize them. Will update in V3.

hey, no problem.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines

These patches are generated on balbi/testing/next

Changes from v1 -> v2
- remove dual role function temporarily
- add pci quirk to avoid to bind with xhci driver
- distinguish between simulation board and soc
- break down all the special quirks

Patch 1:
- add PCI device id into pci bus glue

Quoted 7 lines
Quoted 4 lines

this guy should be the last in the series, with all AMD quirks being enabled at once. This will avoid bisection points where AMD's platforms don't work.

So all the AMD special configuration and device id should be in one patch, right?

correct :-)

Signature · 1 line
balbi