mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v5] usb: dwc3: core: add support for realtek SoCs custom's global register start address
@ 2023-05-04  3:44 Stanley Chang
  2023-05-04  7:50 ` Sergei Shtylyov
  0 siblings, 1 reply; 7+ messages in thread
From: Stanley Chang @ 2023-05-04  3:44 UTC (permalink / raw)
  To: Thinh Nguyen; +Cc: Stanley Chang, Greg Kroah-Hartman, linux-usb, linux-kernel

The Realtek RTD1xxx SoCs were designed, 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,rtd1xxx-dwc3", then global
register start address will remap to 0x8100.

Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
---
 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(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 0beaab932e7d..0adafb5439ed 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -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,rtd1xxx-dwc3")) {
+			dwc_res.start -= DWC3_GLOBALS_REGS_START;
+			dwc_res.start += DWC3_RTK_RTD1XXX_GLOBALS_REGS_START;
+		}
+
+		of_node_put(parent);
+	}
+
 	regs = devm_ioremap_resource(dev, &dwc_res);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index d56457c02996..c004e3a548ca 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -84,6 +84,8 @@
 #define DWC3_OTG_REGS_START		0xcc00
 #define DWC3_OTG_REGS_END		0xccff
 
+#define DWC3_RTK_RTD1XXX_GLOBALS_REGS_START	0x8100
+
 /* Global Registers */
 #define DWC3_GSBUSCFG0		0xc100
 #define DWC3_GSBUSCFG1		0xc104
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v5] usb: dwc3: core: add support for realtek SoCs custom's global register start address
  2023-05-04  3:44 [PATCH v5] usb: dwc3: core: add support for realtek SoCs custom's global register start address Stanley Chang
@ 2023-05-04  7:50 ` Sergei Shtylyov
  2023-05-04  8:26   ` Stanley Chang[昌育德]
  0 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2023-05-04  7:50 UTC (permalink / raw)
  To: Stanley Chang, Thinh Nguyen; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

Hello!

On 5/4/23 6:44 AM, Stanley Chang wrote:

> The Realtek RTD1xxx SoCs were designed, the global register address
> offset at 0x8100.

  Can't parse that, perhaps "with" is missing?

> 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,rtd1xxx-dwc3", then global

   Wildcards are not allowed in the "compatible" props...

> register start address will remap to 0x8100.
> 
> Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v5] usb: dwc3: core: add support for realtek SoCs custom's global register start address
  2023-05-04  7:50 ` Sergei Shtylyov
@ 2023-05-04  8:26   ` Stanley Chang[昌育德]
  2023-05-04  8:27     ` Sergei Shtylyov
  0 siblings, 1 reply; 7+ messages in thread
From: Stanley Chang[昌育德] @ 2023-05-04  8:26 UTC (permalink / raw)
  To: Sergei Shtylyov, Thinh Nguyen; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

> On 5/4/23 6:44 AM, Stanley Chang wrote:
> 
> > The Realtek RTD1xxx SoCs were designed, the global register address
> > offset at 0x8100.
> 
>   Can't parse that, perhaps "with" is missing?
> 
> > 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,rtd1xxx-dwc3", then global
> 
>    Wildcards are not allowed in the "compatible" props...

I can't understand your meaning.
Do you mean I can't use rtd1xxx ?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v5] usb: dwc3: core: add support for realtek SoCs custom's global register start address
  2023-05-04  8:26   ` Stanley Chang[昌育德]
@ 2023-05-04  8:27     ` Sergei Shtylyov
  2023-05-04  8:36       ` Stanley Chang[昌育德]
  0 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2023-05-04  8:27 UTC (permalink / raw)
  To: Stanley Chang[昌育德], Thinh Nguyen
  Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On 5/4/23 11:26 AM, Stanley Chang[昌育德] wrote:
[...]

>>> The Realtek RTD1xxx SoCs were designed, the global register address
>>> offset at 0x8100.
>>
>>   Can't parse that, perhaps "with" is missing?
>>
>>> 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,rtd1xxx-dwc3", then global
>>
>>    Wildcards are not allowed in the "compatible" props...
> 
> I can't understand your meaning.
> Do you mean I can't use rtd1xxx ?

   You can't, indeed.

MBR, Sergey

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v5] usb: dwc3: core: add support for realtek SoCs custom's global register start address
  2023-05-04  8:27     ` Sergei Shtylyov
@ 2023-05-04  8:36       ` Stanley Chang[昌育德]
  2023-05-04 15:45         ` Sergei Shtylyov
  0 siblings, 1 reply; 7+ messages in thread
From: Stanley Chang[昌育德] @ 2023-05-04  8:36 UTC (permalink / raw)
  To: Sergei Shtylyov, Thinh Nguyen; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel


> > I can't understand your meaning.
> > Do you mean I can't use rtd1xxx ?
> 
>    You can't, indeed.
> 
The namr rtd1xxx is represent the name of SoCs, for rtd129x, rtd139x, rtd16xx, ... etc.

Must I use a real chip name, example rtd129x?
Or can I use "rtd" only to represent all Socs?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v5] usb: dwc3: core: add support for realtek SoCs custom's global register start address
  2023-05-04  8:36       ` Stanley Chang[昌育德]
@ 2023-05-04 15:45         ` Sergei Shtylyov
  2023-05-05  2:17           ` Stanley Chang[昌育德]
  0 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2023-05-04 15:45 UTC (permalink / raw)
  To: Stanley Chang[昌育德], Thinh Nguyen
  Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On 5/4/23 11:36 AM, Stanley Chang[昌育德] wrote:

>>> I can't understand your meaning.
>>> Do you mean I can't use rtd1xxx ?
>>
>>    You can't, indeed.
>>
> The namr rtd1xxx is represent the name of SoCs, for rtd129x, rtd139x, rtd16xx, ... etc.
> 
> Must I use a real chip name, example rtd129x?

   Yes but iff x is not also a wildcard. rtd1290 would fit iff that SoC actually exists.

> Or can I use "rtd" only to represent all Socs?

   If you have a fallback value of the "compatible" prop, you can use it...

MBR, Sergey

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v5] usb: dwc3: core: add support for realtek SoCs custom's global register start address
  2023-05-04 15:45         ` Sergei Shtylyov
@ 2023-05-05  2:17           ` Stanley Chang[昌育德]
  0 siblings, 0 replies; 7+ messages in thread
From: Stanley Chang[昌育德] @ 2023-05-05  2:17 UTC (permalink / raw)
  To: Sergei Shtylyov, Thinh Nguyen; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

> >>> I can't understand your meaning.
> >>> Do you mean I can't use rtd1xxx ?
> >>
> >>    You can't, indeed.
> >>
> > The namr rtd1xxx is represent the name of SoCs, for rtd129x, rtd139x,
> rtd16xx, ... etc.
> >
> > Must I use a real chip name, example rtd129x?
> 
>    Yes but iff x is not also a wildcard. rtd1290 would fit iff that SoC actually
> exists.
> 
> > Or can I use "rtd" only to represent all Socs?
> 
>    If you have a fallback value of the "compatible" prop, you can use it...

I will use the name "rtd" to instead the "rtd1xxx".

Thanks,
Stanley

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-05  2:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04  3:44 [PATCH v5] usb: dwc3: core: add support for realtek SoCs custom's global register start address Stanley Chang
2023-05-04  7:50 ` Sergei Shtylyov
2023-05-04  8:26   ` Stanley Chang[昌育德]
2023-05-04  8:27     ` Sergei Shtylyov
2023-05-04  8:36       ` Stanley Chang[昌育德]
2023-05-04 15:45         ` Sergei Shtylyov
2023-05-05  2:17           ` Stanley Chang[昌育德]

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®