Skip to contentSkip to conversation

usb: dwc3: core: add support for realtek SoCs custom's global register start address

PATCH In review Stanley Chang 2 participants 4 messages May 5, 2023 – May 11, 2023

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

PATCH v6 1/1 usb: dwc3: core: add support for realtek SoCs custom's global register start address

The Realtek RTD SoCs were designed with the global register address offset at 0x8100. The default address offset is constant at DWC3_GLOBALS_REGS_START (0xc100). Therefore, add a check if the compatible name of the parent is realtek,rtd-dwc3, then global register start address will remap to 0x8100.

---
v5 to v6 change:
Change the compatible name to avoid using the wildcard.

v4 to v5 change:
Use the compatible name of the parent to match this special offset.

v3 to v4 change:
Use the compatible name to specify the global register address offset. If the compatible name is "snps,dwc3-rtk-soc", then the offset use 0x8100. Otherwise, the offset is default value 0xc100.

v2 to v3 change:
1. Fix the dtschema validation error.

v1 to v2 change:
1. Change the name of the property "snps,global-regs-starting-offset".
2. Adjust the format of comment.
3. Add initial value of the global_regs_starting_offset
4. Remove the log of dev_info.

---
 drivers/usb/dwc3/core.c | 11 +++++++++++
 drivers/usb/dwc3/core.h |  2 ++
 2 files changed, 13 insertions(+)
drivers/usb/dwc3/core.c +11 -0
index 0beaab932e7d..278cd1c33841 100644
@@ -1800,6 +1800,17 @@ static int dwc3_probe(struct platform_device *pdev)
 	dwc_res = *res;
 	dwc_res.start += DWC3_GLOBALS_REGS_START;
 
+	if (dev->of_node) {
+		struct device_node *parent = of_get_parent(dev->of_node);
+
+		if (of_device_is_compatible(parent, "realtek,rtd-dwc3")) {
+			dwc_res.start -= DWC3_GLOBALS_REGS_START;
+			dwc_res.start += DWC3_RTK_RTD_GLOBALS_REGS_START;
+		}
+
+		of_node_put(parent);
+	}
+
 	regs = devm_ioremap_resource(dev, &dwc_res);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
drivers/usb/dwc3/core.h +2 -0
index d56457c02996..1968638f29ed 100644
@@ -84,6 +84,8 @@
 #define DWC3_OTG_REGS_START		0xcc00
 #define DWC3_OTG_REGS_END		0xccff
 
+#define DWC3_RTK_RTD_GLOBALS_REGS_START	0x8100
+
 /* Global Registers */
 #define DWC3_GSBUSCFG0		0xc100
 #define DWC3_GSBUSCFG1		0xc104
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 37 lines · Stanley Chang

The Realtek RTD SoCs were designed with the global register address offset at 0x8100. The default address offset is constant at DWC3_GLOBALS_REGS_START (0xc100). Therefore, add a check if the compatible name of the parent is realtek,rtd-dwc3, then global register start address will remap to 0x8100.

---
v5 to v6 change:
Change the compatible name to avoid using the wildcard.

v4 to v5 change:
Use the compatible name of the parent to match this special offset.

v3 to v4 change:
Use the compatible name to specify the global register address offset. If the compatible name is "snps,dwc3-rtk-soc", then the offset use 0x8100. Otherwise, the offset is default value 0xc100.

v2 to v3 change:
1. Fix the dtschema validation error.

v1 to v2 change:
1. Change the name of the property "snps,global-regs-starting-offset".
2. Adjust the format of comment.
3. Add initial value of the global_regs_starting_offset
4. Remove the log of dev_info.

---
 drivers/usb/dwc3/core.c | 11 +++++++++++
 drivers/usb/dwc3/core.h |  2 ++
 2 files changed, 13 insertions(+)
drivers/usb/dwc3/core.c +0 -0
index 0beaab932e7d..278cd1c33841 100644

drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev) · line 1806

Quoted 7 lines
drivers/usb/dwc3/core.c +4 -0
@@ -1800,6 +1800,17 @@ static int dwc3_probe(struct platform_device *pdev)
 	dwc_res = *res;
 	dwc_res.start += DWC3_GLOBALS_REGS_START;
 
+	if (dev->of_node) {
+		struct device_node *parent = of_get_parent(dev->of_node);
+
+		if (of_device_is_compatible(parent, "realtek,rtd-dwc3")) {

Is your platform already released or is it still under development? Just curious since the compatible string isn't fixed. Is it going to be changed in the future?

Quoted 26 lines
drivers/usb/dwc3/core.c +7 -0
+			dwc_res.start -= DWC3_GLOBALS_REGS_START;
+			dwc_res.start += DWC3_RTK_RTD_GLOBALS_REGS_START;
+		}
+
+		of_node_put(parent);
+	}
+
 	regs = devm_ioremap_resource(dev, &dwc_res);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
drivers/usb/dwc3/core.h +2 -0
index d56457c02996..1968638f29ed 100644
@@ -84,6 +84,8 @@
 #define DWC3_OTG_REGS_START		0xcc00
 #define DWC3_OTG_REGS_END		0xccff
 
+#define DWC3_RTK_RTD_GLOBALS_REGS_START	0x8100
+
 /* Global Registers */
 #define DWC3_GSBUSCFG0		0xc100
 #define DWC3_GSBUSCFG1		0xc104
Signature · 1 line
2.34.1

Thanks,
Thinh

#2 lore raw

Hi Thinh,

Quoted 16 lines

drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device

Quoted 5 lines
drivers/usb/dwc3/core.c index renamed from drivers/usb/dwc3/core.c +0 -0

0beaab932e7d..278cd1c33841 100644

drivers/usb/dwc3/core.c +0 -0
@@ -1800,6 +1800,17 @@ static int dwc3_probe(struct platform_device

*pdev)

drivers/usb/dwc3/core.c static int dwc3_probe(struct platform_device *pdev)

Quoted 9 lines
drivers/usb/dwc3/core.c +6 -0
      dwc_res = *res;
      dwc_res.start += DWC3_GLOBALS_REGS_START;
 
+     if (dev->of_node) {
+             struct device_node *parent =
+ of_get_parent(dev->of_node);
+
+             if (of_device_is_compatible(parent, "realtek,rtd-dwc3"))
+ {
Quoted 2 lines

Is your platform already released or is it still under development? Just curious since the compatible string isn't fixed. Is it going to be changed in the future?

Yes, our platform is released.
In our driver (the parent of the dwc3 driver), we used the compatible name "Realtek,dwc3". To support this patch, I will add an alternative name "Realtek,rtd-dwc3" to our driver.

Thanks,
Stanley

maintainer Acked-by on v6 1/1
#3 lore raw
In reply to Stanley Chang
Quoted 70 lines · Stanley Chang

The Realtek RTD SoCs were designed with the global register address offset at 0x8100. The default address offset is constant at DWC3_GLOBALS_REGS_START (0xc100). Therefore, add a check if the compatible name of the parent is realtek,rtd-dwc3, then global register start address will remap to 0x8100.

---
v5 to v6 change:
Change the compatible name to avoid using the wildcard.

v4 to v5 change:
Use the compatible name of the parent to match this special offset.

v3 to v4 change:
Use the compatible name to specify the global register address offset. If the compatible name is "snps,dwc3-rtk-soc", then the offset use 0x8100. Otherwise, the offset is default value 0xc100.

v2 to v3 change:
1. Fix the dtschema validation error.

v1 to v2 change:
1. Change the name of the property "snps,global-regs-starting-offset".
2. Adjust the format of comment.
3. Add initial value of the global_regs_starting_offset
4. Remove the log of dev_info.

---
 drivers/usb/dwc3/core.c | 11 +++++++++++
 drivers/usb/dwc3/core.h |  2 ++
 2 files changed, 13 insertions(+)
drivers/usb/dwc3/core.c +11 -0
index 0beaab932e7d..278cd1c33841 100644
@@ -1800,6 +1800,17 @@ static int dwc3_probe(struct platform_device *pdev)
 	dwc_res = *res;
 	dwc_res.start += DWC3_GLOBALS_REGS_START;
 
+	if (dev->of_node) {
+		struct device_node *parent = of_get_parent(dev->of_node);
+
+		if (of_device_is_compatible(parent, "realtek,rtd-dwc3")) {
+			dwc_res.start -= DWC3_GLOBALS_REGS_START;
+			dwc_res.start += DWC3_RTK_RTD_GLOBALS_REGS_START;
+		}
+
+		of_node_put(parent);
+	}
+
 	regs = devm_ioremap_resource(dev, &dwc_res);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
drivers/usb/dwc3/core.h +2 -0
index d56457c02996..1968638f29ed 100644
@@ -84,6 +84,8 @@
 #define DWC3_OTG_REGS_START		0xcc00
 #define DWC3_OTG_REGS_END		0xccff
 
+#define DWC3_RTK_RTD_GLOBALS_REGS_START	0x8100
+
 /* Global Registers */
 #define DWC3_GSBUSCFG0		0xc100
 #define DWC3_GSBUSCFG1		0xc104
Signature · 1 line
2.34.1

Thanks,
Thinh