Skip to contentSkip to conversation

usb: dwc3: core: enable CCI support

PATCH In review Piyush Mehta 2 participants 6 messages Oct 13, 2023 – Feb 23, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc3: core: enable CCI support

The GSBUSCFG0 register bits [31:16] are used to configure the cache type settings of the descriptor and data write/read transfers (Cacheable, Bufferable/ Posted). When CCI is enabled in the design, DWC3 core GSBUSCFG0 cache bits must be updated to support CCI enabled transfers in USB.

---
DWC3 Register Map Link:
https://docs.xilinx.com/r/en-US/ug1087-zynq-ultrascale-registers/GSBUSCFG0-USB3_XHCI-Register
Register Name GSBUSCFG0
Description Global SoC Bus Configuration Register 0

GSBUSCFG0 (USB3_XHCI) Register Bit-Field:
DATRDREQINFO 31:28
DESRDREQINFO 27:24
DATWRREQINFO 23:20
DESWRREQINFO 19:16

---
 drivers/usb/dwc3/core.c | 17 +++++++++++++++++
 drivers/usb/dwc3/core.h |  5 +++++
 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c +17 -0
index 9c6bf054f15d..fc6892c63abf 100644
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_graph.h>
 #include <linux/acpi.h>
 #include <linux/pinctrl/consumer.h>
@@ -559,6 +560,20 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
 		parms->hwparams9 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS9);
 }
 
+static void dwc3_config_soc_bus(struct dwc3 *dwc)
+{
+	if (of_dma_is_coherent(dwc->dev->of_node)) {
+		u32 reg;
+
+		reg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);
+		reg |= DWC3_GSBUSCFG0_DATRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DATWRREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESWRREQINFO_MASK;
+		dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, reg);
+	}
+}
+
 static int dwc3_core_ulpi_init(struct dwc3 *dwc)
 {
 	int intf;
@@ -1137,6 +1152,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	dwc3_set_incr_burst_type(dwc);
 
+	dwc3_config_soc_bus(dwc);
+
 	ret = dwc3_phy_power_on(dwc);
 	if (ret)
 		goto err_exit_phy;
drivers/usb/dwc3/core.h +5 -0
index a69ac67d89fe..bd937025ce05 100644
@@ -173,6 +173,11 @@
 #define DWC3_OSTS		0xcc10
 
 /* Bit fields */
+/* Global SoC Bus Configuration Register: AHB-prot/AXI-cache/OCP-ReqInfo */
+#define DWC3_GSBUSCFG0_DATRDREQINFO_MASK	GENMASK(31, 28)
+#define DWC3_GSBUSCFG0_DESRDREQINFO_MASK	GENMASK(27, 24)
+#define DWC3_GSBUSCFG0_DATWRREQINFO_MASK	GENMASK(23, 20)
+#define DWC3_GSBUSCFG0_DESWRREQINFO_MASK	GENMASK(19, 16)
 
 /* Global SoC Bus Configuration INCRx Register 0 */
 #define DWC3_GSBUSCFG0_INCR256BRSTENA	(1 << 7) /* INCR256 burst */
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 42 lines · Piyush Mehta

The GSBUSCFG0 register bits [31:16] are used to configure the cache type settings of the descriptor and data write/read transfers (Cacheable, Bufferable/ Posted). When CCI is enabled in the design, DWC3 core GSBUSCFG0 cache bits must be updated to support CCI enabled transfers in USB.

---
DWC3 Register Map Link:
https://urldefense.com/v3/__https://docs.xilinx.com/r/en-US/ug1087-zynq-ultrascale-registers/GSBUSCFG0-USB3_XHCI-Register__;!!A4F2R9G_pg!cbLbYLk9xu54DZMkiTQzMhdCaPA4gmIVInes4ZeNb28AI2pgesEvHNYtjoZfWvE_t7wlUdZvYn-Pio8WjA55ekal$
Register Name GSBUSCFG0
Description Global SoC Bus Configuration Register 0

GSBUSCFG0 (USB3_XHCI) Register Bit-Field:
DATRDREQINFO 31:28
DESRDREQINFO 27:24
DATWRREQINFO 23:20
DESWRREQINFO 19:16

---
 drivers/usb/dwc3/core.c | 17 +++++++++++++++++
 drivers/usb/dwc3/core.h |  5 +++++
 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c +5 -0
index 9c6bf054f15d..fc6892c63abf 100644
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_graph.h>
 #include <linux/acpi.h>
 #include <linux/pinctrl/consumer.h>
@@ -559,6 +560,20 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
 		parms->hwparams9 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS9);
 }
 
+static void dwc3_config_soc_bus(struct dwc3 *dwc)
+{
+	if (of_dma_is_coherent(dwc->dev->of_node)) {
+		u32 reg;

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

Quoted 10 lines
drivers/usb/dwc3/core.c +10 -0
+
+		reg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);
+		reg |= DWC3_GSBUSCFG0_DATRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DATWRREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESWRREQINFO_MASK;
+		dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, reg);
+	}
+}
+

You're overwriting default values for all platforms. Don't do that. Not every platform supports this setting. Only apply these specific settings to your platform.

BR,
Thinh

Quoted 31 lines
drivers/usb/dwc3/core.c +2 -0
 static int dwc3_core_ulpi_init(struct dwc3 *dwc)
 {
 	int intf;
@@ -1137,6 +1152,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	dwc3_set_incr_burst_type(dwc);
 
+	dwc3_config_soc_bus(dwc);
+
 	ret = dwc3_phy_power_on(dwc);
 	if (ret)
 		goto err_exit_phy;
drivers/usb/dwc3/core.h +5 -0
index a69ac67d89fe..bd937025ce05 100644
@@ -173,6 +173,11 @@
 #define DWC3_OSTS		0xcc10
 
 /* Bit fields */
+/* Global SoC Bus Configuration Register: AHB-prot/AXI-cache/OCP-ReqInfo */
+#define DWC3_GSBUSCFG0_DATRDREQINFO_MASK	GENMASK(31, 28)
+#define DWC3_GSBUSCFG0_DESRDREQINFO_MASK	GENMASK(27, 24)
+#define DWC3_GSBUSCFG0_DATWRREQINFO_MASK	GENMASK(23, 20)
+#define DWC3_GSBUSCFG0_DESWRREQINFO_MASK	GENMASK(19, 16)
 
 /* Global SoC Bus Configuration INCRx Register 0 */
 #define DWC3_GSBUSCFG0_INCR256BRSTENA	(1 << 7) /* INCR256 burst */
Signature · 1 line
2.17.1
#2 lore raw

Hi Thinh,

Quoted 62 lines

-----Original Message-----
From: Thinh Nguyen <[email protected]>
Sent: Saturday, October 21, 2023 4:46 AM
To: Mehta, Piyush <[email protected]>
Cc: [email protected]; Simek, Michal <[email protected]>; Thinh Nguyen <[email protected]>; [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH] usb: dwc3: core: enable CCI support

Quoted 4 lines · Piyush Mehta

The GSBUSCFG0 register bits [31:16] are used to configure the cache type settings of the descriptor and data write/read transfers (Cacheable, Bufferable/ Posted). When CCI is enabled in the design, DWC3 core GSBUSCFG0 cache bits must be updated to support CCI enabled

transfers in USB.

Quoted 5 lines

---
DWC3 Register Map Link:
https://urldefense.com/v3/__https://docs.xilinx.com/r/en-US/ug1087-zynq-

ultrascale-registers/GSBUSCFG0-USB3_XHCI- Register__;!!A4F2R9G_pg!cbLbYLk9xu54DZMkiTQzMhdCaPA4gmIVInes4ZeNb28 AI2pgesEvHNYtjoZfWvE_t7wlUdZvYn-Pio8WjA55ekal$

drivers/usb/dwc3/core.c static void dwc3_cache_hwparams(struct dwc3

Quoted 26 lines

Register Name GSBUSCFG0
Description Global SoC Bus Configuration Register 0

GSBUSCFG0 (USB3_XHCI) Register Bit-Field:
DATRDREQINFO 31:28
DESRDREQINFO 27:24
DATWRREQINFO 23:20
DESWRREQINFO 19:16

---
 drivers/usb/dwc3/core.c | 17 +++++++++++++++++
drivers/usb/dwc3/core.h |  5 +++++
 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c index renamed from drivers/usb/dwc3/core.c +0 -0

9c6bf054f15d..fc6892c63abf 100644

drivers/usb/dwc3/core.c +1 -0
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_graph.h>
 #include <linux/acpi.h>
 #include <linux/pinctrl/consumer.h>
@@ -559,6 +560,20 @@ static void dwc3_cache_hwparams(struct dwc3

*dwc)

drivers/usb/dwc3/core.c static void dwc3_cache_hwparams(struct dwc3 · line 560

Quoted 1 line
drivers/usb/dwc3/core.c +0 -0
 		parms->hwparams9 = dwc3_readl(dwc->regs,

DWC3_GHWPARAMS9); }

Quoted 10 lines
drivers/usb/dwc3/core.c +9 -0
+static void dwc3_config_soc_bus(struct dwc3 *dwc) {
+	if (of_dma_is_coherent(dwc->dev->of_node)) {
+		u32 reg;
+
+		reg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);
+		reg |= DWC3_GSBUSCFG0_DATRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DATWRREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESWRREQINFO_MASK;
Quoted 8 lines

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

Quoted 4 lines
drivers/usb/dwc3/core.c +4 -0
+		dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, reg);
+	}
+}
+

You're overwriting default values for all platforms. Don't do that. Not every platform supports this setting. Only apply these specific settings to your platform.

This DWC3_GSBUSCFG0 register is part of the DWC3/Core system. In glue/vendor drivers, I couldn't find a way to access the DWC3/Core access register. Could you please provide a suggestion for the Xilinx glue driver (dwc3/dwc3-xilinx.c) to access dwc3 registers?

Quoted 30 lines

BR,
Thinh

Quoted 16 lines
drivers/usb/dwc3/core.c +2 -0
 static int dwc3_core_ulpi_init(struct dwc3 *dwc)  {
 	int intf;
@@ -1137,6 +1152,8 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
 	dwc3_set_incr_burst_type(dwc);
 
+	dwc3_config_soc_bus(dwc);
+
 	ret = dwc3_phy_power_on(dwc);
 	if (ret)
 		goto err_exit_phy;
drivers/usb/dwc3/core.h index renamed from drivers/usb/dwc3/core.h +0 -0

a69ac67d89fe..bd937025ce05 100644

drivers/usb/dwc3/core.h line 176

Quoted 4 lines
drivers/usb/dwc3/core.h +1 -0
@@ -173,6 +173,11 @@
 #define DWC3_OSTS		0xcc10
 
 /* Bit fields */
+/* Global SoC Bus Configuration Register: AHB-prot/AXI-cache/OCP-ReqInfo

*/

Quoted 5 lines
drivers/usb/dwc3/core.h +4 -0
+#define DWC3_GSBUSCFG0_DATRDREQINFO_MASK	GENMASK(31, 28)
+#define DWC3_GSBUSCFG0_DESRDREQINFO_MASK	GENMASK(27, 24)
+#define DWC3_GSBUSCFG0_DATWRREQINFO_MASK	GENMASK(23, 20)
+#define DWC3_GSBUSCFG0_DESWRREQINFO_MASK	GENMASK(19, 16)
 
Quoted 5 lines
Quoted 5 lines
drivers/usb/dwc3/core.h +0 -1
 /* Global SoC Bus Configuration INCRx Register 0 */
 #define DWC3_GSBUSCFG0_INCR256BRSTENA	(1 << 7) /* INCR256 burst */
--

2.17.1

PM

maintainer
#3 lore raw
Quoted 73 lines · Piyush

Hi Thinh,

Quoted 62 lines

-----Original Message-----
From: Thinh Nguyen <[email protected]>
Sent: Saturday, October 21, 2023 4:46 AM
To: Mehta, Piyush <[email protected]>
Cc: [email protected]; Simek, Michal <[email protected]>; Thinh Nguyen <[email protected]>; [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH] usb: dwc3: core: enable CCI support

Quoted 4 lines · Piyush Mehta

The GSBUSCFG0 register bits [31:16] are used to configure the cache type settings of the descriptor and data write/read transfers (Cacheable, Bufferable/ Posted). When CCI is enabled in the design, DWC3 core GSBUSCFG0 cache bits must be updated to support CCI enabled

transfers in USB.

Quoted 5 lines

---
DWC3 Register Map Link:
https://urldefense.com/v3/__https://docs.xilinx.com/r/en-US/ug1087-zynq-

ultrascale-registers/GSBUSCFG0-USB3_XHCI- Register__;!!A4F2R9G_pg!cbLbYLk9xu54DZMkiTQzMhdCaPA4gmIVInes4ZeNb28 AI2pgesEvHNYtjoZfWvE_t7wlUdZvYn-Pio8WjA55ekal$

drivers/usb/dwc3/core.c static void dwc3_cache_hwparams(struct dwc3

Quoted 26 lines

Register Name GSBUSCFG0
Description Global SoC Bus Configuration Register 0

GSBUSCFG0 (USB3_XHCI) Register Bit-Field:
DATRDREQINFO 31:28
DESRDREQINFO 27:24
DATWRREQINFO 23:20
DESWRREQINFO 19:16

---
 drivers/usb/dwc3/core.c | 17 +++++++++++++++++
drivers/usb/dwc3/core.h |  5 +++++
 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c index renamed from drivers/usb/dwc3/core.c +0 -0

9c6bf054f15d..fc6892c63abf 100644

drivers/usb/dwc3/core.c +1 -0
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_graph.h>
 #include <linux/acpi.h>
 #include <linux/pinctrl/consumer.h>
@@ -559,6 +560,20 @@ static void dwc3_cache_hwparams(struct dwc3

*dwc)

drivers/usb/dwc3/core.c static void dwc3_cache_hwparams(struct dwc3 · line 560

Quoted 1 line
drivers/usb/dwc3/core.c +0 -0
 		parms->hwparams9 = dwc3_readl(dwc->regs,

DWC3_GHWPARAMS9); }

Quoted 10 lines
drivers/usb/dwc3/core.c +9 -0
+static void dwc3_config_soc_bus(struct dwc3 *dwc) {
+	if (of_dma_is_coherent(dwc->dev->of_node)) {
+		u32 reg;
+
+		reg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);
+		reg |= DWC3_GSBUSCFG0_DATRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DATWRREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESWRREQINFO_MASK;
Quoted 8 lines

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

Quoted 4 lines
drivers/usb/dwc3/core.c +4 -0
+		dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, reg);
+	}
+}
+

You're overwriting default values for all platforms. Don't do that. Not every platform supports this setting. Only apply these specific settings to your platform.

Quoted 3 lines

This DWC3_GSBUSCFG0 register is part of the DWC3/Core system. In glue/vendor drivers, I couldn't find a way to access the DWC3/Core access register. Could you please provide a suggestion for the Xilinx glue driver (dwc3/dwc3-xilinx.c) to access dwc3 registers?

We may need to pass the hardware configuration from the dt binding.

Thanks,
Thinh

#4 lore raw

Hi,

Quoted 90 lines

-----Original Message-----
From: Thinh Nguyen <[email protected]>
Sent: Friday, November 10, 2023 8:07 AM
To: Mehta, Piyush <[email protected]>
Cc: Thinh Nguyen <[email protected]>; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; [email protected]; Paladugu, Siva Durga Prasad <[email protected]>; Pandey, Radhey Shyam <[email protected]>
Subject: Re: [PATCH] usb: dwc3: core: enable CCI support

Quoted 28 lines · Piyush

Hi Thinh,

Quoted 26 lines

-----Original Message-----
From: Thinh Nguyen <[email protected]>
Sent: Saturday, October 21, 2023 4:46 AM
To: Mehta, Piyush <[email protected]>
Cc: [email protected]; Simek, Michal <[email protected]>; Thinh Nguyen <[email protected]>; [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH] usb: dwc3: core: enable CCI support

Quoted 6 lines · Piyush Mehta

The GSBUSCFG0 register bits [31:16] are used to configure the cache type settings of the descriptor and data write/read transfers (Cacheable, Bufferable/ Posted). When CCI is enabled in the design,
DWC3 core GSBUSCFG0 cache bits must be updated to support CCI enabled

transfers in USB.

Quoted 6 lines

---
DWC3 Register Map Link:
https://urldefense.com/v3/__https://docs.xilinx.com/r/en-US/ug1087
-zynq-

ultrascale-registers/GSBUSCFG0-USB3_XHCI-

Register__;!!A4F2R9G_pg!cbLbYLk9xu54DZMkiTQzMhdCaPA4gmIVInes4ZeNb28

Quoted 49 lines
Quoted 48 lines

AI2pgesEvHNYtjoZfWvE_t7wlUdZvYn-Pio8WjA55ekal$

Quoted 25 lines

Register Name GSBUSCFG0
Description Global SoC Bus Configuration Register 0

GSBUSCFG0 (USB3_XHCI) Register Bit-Field:
DATRDREQINFO 31:28
DESRDREQINFO 27:24
DATWRREQINFO 23:20
DESWRREQINFO 19:16

---
 drivers/usb/dwc3/core.c | 17 +++++++++++++++++
drivers/usb/dwc3/core.h |  5 +++++
 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c +1 -0
index 9c6bf054f15d..fc6892c63abf 100644
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_graph.h>
 #include <linux/acpi.h>
 #include <linux/pinctrl/consumer.h> @@ -559,6 +560,20 @@ static
Quoted 1 line

void dwc3_cache_hwparams(struct dwc3

*dwc)

Quoted 1 line

parms->hwparams9 = dwc3_readl(dwc->regs,

DWC3_GHWPARAMS9); }

Quoted 4 lines
drivers/usb/dwc3/core.c +3 -0
+static void dwc3_config_soc_bus(struct dwc3 *dwc) {
+	if (of_dma_is_coherent(dwc->dev->of_node)) {
+		u32 reg;

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

Quoted 10 lines
drivers/usb/dwc3/core.c +10 -0
+
+		reg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);
+		reg |= DWC3_GSBUSCFG0_DATRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DATWRREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESWRREQINFO_MASK;
+		dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, reg);
+	}
+}
+

You're overwriting default values for all platforms. Don't do that. Not every platform supports this setting. Only apply these specific settings to your platform.

Quoted 6 lines
Quoted 3 lines

This DWC3_GSBUSCFG0 register is part of the DWC3/Core system. In glue/vendor drivers, I couldn't find a way to access the DWC3/Core access register. Could you please provide a suggestion for the Xilinx glue

driver (dwc3/dwc3-xilinx.c) to access dwc3 registers?

We may need to pass the hardware configuration from the dt binding.

DWC3_GSBUSCFG0 register is implementation defined and part of DWC3/Core (Databook 2.90). Below is example code to make this logic platform specific. It conditionally validates the dma-coherent property and only performs DWC3_GSBUSCFG0 configuration for AMD/Xilinx platform. (DT compatible "xlnx,zynqmp-dwc3").

Example Code:

       if (of_dma_is_coherent(dwc->dev->of_node) && of_device_is_compatible(dwc->dev->parent->of_node, "xlnx,zynqmp-dwc3")) {
               u32 reg;                                                       
                                                                              
               reg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);                   
               reg |= DWC3_GSBUSCFG0_DATRDREQINFO |                           
                      DWC3_GSBUSCFG0_DESRDREQINFO |                           
                      DWC3_GSBUSCFG0_DATWRREQINFO |                           
                      DWC3_GSBUSCFG0_DESWRREQINFO;                           
               dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, reg);                   
       }
Quoted 3 lines

Thanks,
Thinh

maintainer
#5 lore raw
Quoted 104 lines · Piyush

Hi,

Quoted 90 lines

-----Original Message-----
From: Thinh Nguyen <[email protected]>
Sent: Friday, November 10, 2023 8:07 AM
To: Mehta, Piyush <[email protected]>
Cc: Thinh Nguyen <[email protected]>; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; [email protected]; Paladugu, Siva Durga Prasad <[email protected]>; Pandey, Radhey Shyam <[email protected]>
Subject: Re: [PATCH] usb: dwc3: core: enable CCI support

Quoted 28 lines · Piyush

Hi Thinh,

Quoted 26 lines

-----Original Message-----
From: Thinh Nguyen <[email protected]>
Sent: Saturday, October 21, 2023 4:46 AM
To: Mehta, Piyush <[email protected]>
Cc: [email protected]; Simek, Michal <[email protected]>; Thinh Nguyen <[email protected]>; [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH] usb: dwc3: core: enable CCI support

Quoted 6 lines · Piyush Mehta

The GSBUSCFG0 register bits [31:16] are used to configure the cache type settings of the descriptor and data write/read transfers (Cacheable, Bufferable/ Posted). When CCI is enabled in the design,
DWC3 core GSBUSCFG0 cache bits must be updated to support CCI enabled

transfers in USB.

Quoted 6 lines

---
DWC3 Register Map Link:
https://urldefense.com/v3/__https://docs.xilinx.com/r/en-US/ug1087
-zynq-

ultrascale-registers/GSBUSCFG0-USB3_XHCI-

Register__;!!A4F2R9G_pg!cbLbYLk9xu54DZMkiTQzMhdCaPA4gmIVInes4ZeNb28

Quoted 49 lines
Quoted 48 lines

AI2pgesEvHNYtjoZfWvE_t7wlUdZvYn-Pio8WjA55ekal$

Quoted 25 lines

Register Name GSBUSCFG0
Description Global SoC Bus Configuration Register 0

GSBUSCFG0 (USB3_XHCI) Register Bit-Field:
DATRDREQINFO 31:28
DESRDREQINFO 27:24
DATWRREQINFO 23:20
DESWRREQINFO 19:16

---
 drivers/usb/dwc3/core.c | 17 +++++++++++++++++
drivers/usb/dwc3/core.h |  5 +++++
 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c +1 -0
index 9c6bf054f15d..fc6892c63abf 100644
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_graph.h>
 #include <linux/acpi.h>
 #include <linux/pinctrl/consumer.h> @@ -559,6 +560,20 @@ static
Quoted 1 line

void dwc3_cache_hwparams(struct dwc3

*dwc)

Quoted 1 line

parms->hwparams9 = dwc3_readl(dwc->regs,

DWC3_GHWPARAMS9); }

Quoted 4 lines
drivers/usb/dwc3/core.c +3 -0
+static void dwc3_config_soc_bus(struct dwc3 *dwc) {
+	if (of_dma_is_coherent(dwc->dev->of_node)) {
+		u32 reg;

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

Quoted 10 lines
drivers/usb/dwc3/core.c +10 -0
+
+		reg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);
+		reg |= DWC3_GSBUSCFG0_DATRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESRDREQINFO_MASK |
+			DWC3_GSBUSCFG0_DATWRREQINFO_MASK |
+			DWC3_GSBUSCFG0_DESWRREQINFO_MASK;
+		dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, reg);
+	}
+}
+

You're overwriting default values for all platforms. Don't do that. Not every platform supports this setting. Only apply these specific settings to your platform.

Quoted 6 lines
Quoted 3 lines

This DWC3_GSBUSCFG0 register is part of the DWC3/Core system. In glue/vendor drivers, I couldn't find a way to access the DWC3/Core access register. Could you please provide a suggestion for the Xilinx glue

driver (dwc3/dwc3-xilinx.c) to access dwc3 registers?

We may need to pass the hardware configuration from the dt binding.

DWC3_GSBUSCFG0 register is implementation defined and part of DWC3/Core (Databook 2.90). Below is example code to make this logic platform specific. It conditionally validates the dma-coherent property and only performs DWC3_GSBUSCFG0 configuration for AMD/Xilinx platform. (DT compatible "xlnx,zynqmp-dwc3").

Example Code:

Quoted 10 lines
       if (of_dma_is_coherent(dwc->dev->of_node) && of_device_is_compatible(dwc->dev->parent->of_node, "xlnx,zynqmp-dwc3")) {
               u32 reg;                                                       
                                                                              
               reg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0);                   
               reg |= DWC3_GSBUSCFG0_DATRDREQINFO |                           
                      DWC3_GSBUSCFG0_DESRDREQINFO |                           
                      DWC3_GSBUSCFG0_DATWRREQINFO |                           
                      DWC3_GSBUSCFG0_DESWRREQINFO;                           
               dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, reg);                   
       }

I just realized I missed this in the inbox after your latest patch. Sorry for the delay response.

Since this is platform specific, can we do this in your glue driver? Split and share some of the defined register definitions from core.h to regs.h. You can temporarily memory map and update this register in your Xilinx glue driver. Its value should retain after soft reset.

Thanks,
Thinh