* [PATCH v2 03/11] dt-bindings: usb: dwc3: add description for rk3568
2022-02-26 18:41 [PATCH v2 00/11] enable usb support on rk356x Peter Geis
@ 2022-02-26 18:41 ` Peter Geis
2022-03-04 23:13 ` Rob Herring
2022-02-26 18:41 ` [PATCH v2 05/11] usb: dwc3: core: do not use 3.0 clock when operating in 2.0 mode Peter Geis
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Peter Geis @ 2022-02-26 18:41 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
Heiko Stuebner
Cc: linux-rockchip, michael.riesch, Peter Geis, linux-usb, devicetree,
linux-arm-kernel, linux-kernel
The rk3568 dwc3 controllers are backwards compatible with the rk3399.
Add the device tree description for it.
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
Documentation/devicetree/bindings/usb/rockchip,dwc3.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/rockchip,dwc3.yaml b/Documentation/devicetree/bindings/usb/rockchip,dwc3.yaml
index 04077f2d7faf..b3798d94d2fd 100644
--- a/Documentation/devicetree/bindings/usb/rockchip,dwc3.yaml
+++ b/Documentation/devicetree/bindings/usb/rockchip,dwc3.yaml
@@ -30,6 +30,7 @@ select:
enum:
- rockchip,rk3328-dwc3
- rockchip,rk3399-dwc3
+ - rockchip,rk3568-dwc3
required:
- compatible
@@ -39,6 +40,7 @@ properties:
- enum:
- rockchip,rk3328-dwc3
- rockchip,rk3399-dwc3
+ - rockchip,rk3568-dwc3
- const: snps,dwc3
reg:
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 03/11] dt-bindings: usb: dwc3: add description for rk3568
2022-02-26 18:41 ` [PATCH v2 03/11] dt-bindings: usb: dwc3: add description for rk3568 Peter Geis
@ 2022-03-04 23:13 ` Rob Herring
0 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2022-03-04 23:13 UTC (permalink / raw)
To: Peter Geis
Cc: michael.riesch, Heiko Stuebner, Greg Kroah-Hartman,
linux-arm-kernel, linux-kernel, devicetree, linux-rockchip,
Krzysztof Kozlowski, linux-usb, Rob Herring
On Sat, 26 Feb 2022 13:41:39 -0500, Peter Geis wrote:
> The rk3568 dwc3 controllers are backwards compatible with the rk3399.
> Add the device tree description for it.
>
> Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> ---
> Documentation/devicetree/bindings/usb/rockchip,dwc3.yaml | 2 ++
> 1 file changed, 2 insertions(+)
>
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 05/11] usb: dwc3: core: do not use 3.0 clock when operating in 2.0 mode
2022-02-26 18:41 [PATCH v2 00/11] enable usb support on rk356x Peter Geis
2022-02-26 18:41 ` [PATCH v2 03/11] dt-bindings: usb: dwc3: add description for rk3568 Peter Geis
@ 2022-02-26 18:41 ` Peter Geis
2022-02-26 18:41 ` [PATCH v2 06/11] usb: dwc3: reorder dwc-of-simple compatibles Peter Geis
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Peter Geis @ 2022-02-26 18:41 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: linux-rockchip, heiko, michael.riesch, Bin Yang, Peter Geis,
linux-usb, linux-kernel
From: Bin Yang <yangbin@rock-chips.com>
In the 3.0 device core, if the core is programmed to operate in
2.0 only, then setting the GUCTL1.DEV_FORCE_20_CLK_FOR_30_CLK makes
the internal 2.0(utmi/ulpi) clock to be routed as the 3.0 (pipe)
clock. Enabling this feature allows the pipe3 clock to be not-running
when forcibly operating in 2.0 device mode.
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
drivers/usb/dwc3/core.c | 5 +++++
drivers/usb/dwc3/core.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 18adddfba3da..416d83a055fe 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1167,6 +1167,11 @@ static int dwc3_core_init(struct dwc3 *dwc)
if (dwc->parkmode_disable_ss_quirk)
reg |= DWC3_GUCTL1_PARKMODE_DISABLE_SS;
+ if (DWC3_VER_IS_WITHIN(DWC3, 290A, ANY) &&
+ (dwc->maximum_speed == USB_SPEED_HIGH ||
+ dwc->maximum_speed == USB_SPEED_FULL))
+ reg |= DWC3_GUCTL1_DEV_FORCE_20_CLK_FOR_30_CLK;
+
dwc3_writel(dwc->regs, DWC3_GUCTL1, reg);
}
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index eb9c1efced05..ea3ca04406bb 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -259,6 +259,7 @@
/* Global User Control 1 Register */
#define DWC3_GUCTL1_DEV_DECOUPLE_L1L2_EVT BIT(31)
#define DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS BIT(28)
+#define DWC3_GUCTL1_DEV_FORCE_20_CLK_FOR_30_CLK BIT(26)
#define DWC3_GUCTL1_DEV_L1_EXIT_BY_HW BIT(24)
#define DWC3_GUCTL1_PARKMODE_DISABLE_SS BIT(17)
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 06/11] usb: dwc3: reorder dwc-of-simple compatibles
2022-02-26 18:41 [PATCH v2 00/11] enable usb support on rk356x Peter Geis
2022-02-26 18:41 ` [PATCH v2 03/11] dt-bindings: usb: dwc3: add description for rk3568 Peter Geis
2022-02-26 18:41 ` [PATCH v2 05/11] usb: dwc3: core: do not use 3.0 clock when operating in 2.0 mode Peter Geis
@ 2022-02-26 18:41 ` Peter Geis
2022-02-26 18:41 ` [PATCH v2 07/11] usb: dwc3: convert dwc3-of-simple to use match-data Peter Geis
2022-02-26 18:41 ` [PATCH v2 08/11] usb: dwc3: add rk3568 dwc3 support Peter Geis
4 siblings, 0 replies; 9+ messages in thread
From: Peter Geis @ 2022-02-26 18:41 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: linux-rockchip, heiko, michael.riesch, Peter Geis, linux-usb,
linux-kernel
The dwc3-of-simple driver is getting rather disorganized with the new
inclusions.
Reorder the dwc3-of-simple compatibles to be alphabetical.
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
drivers/usb/dwc3/dwc3-of-simple.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index 71fd620c5161..9dc6295df6b1 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -171,12 +171,12 @@ static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = {
};
static const struct of_device_id of_dwc3_simple_match[] = {
- { .compatible = "rockchip,rk3399-dwc3" },
- { .compatible = "cavium,octeon-7130-usb-uctl" },
- { .compatible = "sprd,sc9860-dwc3" },
{ .compatible = "allwinner,sun50i-h6-dwc3" },
+ { .compatible = "cavium,octeon-7130-usb-uctl" },
{ .compatible = "hisilicon,hi3670-dwc3" },
{ .compatible = "intel,keembay-dwc3" },
+ { .compatible = "rockchip,rk3399-dwc3" },
+ { .compatible = "sprd,sc9860-dwc3" },
{ /* Sentinel */ }
};
MODULE_DEVICE_TABLE(of, of_dwc3_simple_match);
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 07/11] usb: dwc3: convert dwc3-of-simple to use match-data
2022-02-26 18:41 [PATCH v2 00/11] enable usb support on rk356x Peter Geis
` (2 preceding siblings ...)
2022-02-26 18:41 ` [PATCH v2 06/11] usb: dwc3: reorder dwc-of-simple compatibles Peter Geis
@ 2022-02-26 18:41 ` Peter Geis
2022-02-26 18:41 ` [PATCH v2 08/11] usb: dwc3: add rk3568 dwc3 support Peter Geis
4 siblings, 0 replies; 9+ messages in thread
From: Peter Geis @ 2022-02-26 18:41 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: linux-rockchip, heiko, michael.riesch, Peter Geis, linux-usb,
linux-kernel
The upcoming support for rk3568 will reuse data from rk3399.
Instead of adding a bunch of of_device_is_compatible as we add support
for new devices, lets get ahead of the problem and use of_match_data
instead.
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
drivers/usb/dwc3/dwc3-of-simple.c | 39 ++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index 9dc6295df6b1..57ba9427ad74 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -30,12 +30,16 @@ struct dwc3_of_simple {
bool need_reset;
};
+struct dwc3_of_simple_data {
+ bool need_reset;
+};
+
static int dwc3_of_simple_probe(struct platform_device *pdev)
{
struct dwc3_of_simple *simple;
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
-
+ const struct dwc3_of_simple_data *data = of_device_get_match_data(dev);
int ret;
simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL);
@@ -49,8 +53,8 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
* Some controllers need to toggle the usb3-otg reset before trying to
* initialize the PHY, otherwise the PHY times out.
*/
- if (of_device_is_compatible(np, "rockchip,rk3399-dwc3"))
- simple->need_reset = true;
+ if (data->need_reset)
+ simple->need_reset = data->need_reset;
simple->resets = of_reset_control_array_get(np, false, true,
true);
@@ -170,13 +174,30 @@ static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = {
dwc3_of_simple_runtime_resume, NULL)
};
+static const struct dwc3_of_simple_data dwc3_of_simple_data_rk3399 = {
+ .need_reset = true,
+};
+
static const struct of_device_id of_dwc3_simple_match[] = {
- { .compatible = "allwinner,sun50i-h6-dwc3" },
- { .compatible = "cavium,octeon-7130-usb-uctl" },
- { .compatible = "hisilicon,hi3670-dwc3" },
- { .compatible = "intel,keembay-dwc3" },
- { .compatible = "rockchip,rk3399-dwc3" },
- { .compatible = "sprd,sc9860-dwc3" },
+ {
+ .compatible = "allwinner,sun50i-h6-dwc3",
+ },
+ {
+ .compatible = "cavium,octeon-7130-usb-uctl",
+ },
+ {
+ .compatible = "hisilicon,hi3670-dwc3",
+ },
+ {
+ .compatible = "intel,keembay-dwc3",
+ },
+ {
+ .compatible = "rockchip,rk3399-dwc3",
+ .data = &dwc3_of_simple_data_rk3399,
+ },
+ {
+ .compatible = "sprd,sc9860-dwc3",
+ },
{ /* Sentinel */ }
};
MODULE_DEVICE_TABLE(of, of_dwc3_simple_match);
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 08/11] usb: dwc3: add rk3568 dwc3 support
2022-02-26 18:41 [PATCH v2 00/11] enable usb support on rk356x Peter Geis
` (3 preceding siblings ...)
2022-02-26 18:41 ` [PATCH v2 07/11] usb: dwc3: convert dwc3-of-simple to use match-data Peter Geis
@ 2022-02-26 18:41 ` Peter Geis
2022-02-26 21:43 ` Johan Jonker
4 siblings, 1 reply; 9+ messages in thread
From: Peter Geis @ 2022-02-26 18:41 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: linux-rockchip, heiko, michael.riesch, Peter Geis, linux-usb,
linux-kernel
The rk3568 dwc3 controller is backwards compatible with the rk3399 dwc3
controller.
Add support for it to the dwc3-of-simple driver.
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
drivers/usb/dwc3/dwc3-of-simple.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index 57ba9427ad74..d9d1c5bfac3f 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -195,6 +195,10 @@ static const struct of_device_id of_dwc3_simple_match[] = {
.compatible = "rockchip,rk3399-dwc3",
.data = &dwc3_of_simple_data_rk3399,
},
+ {
+ .compatible = "rockchip,rk3568-dwc3",
+ .data = &dwc3_of_simple_data_rk3399,
+ },
{
.compatible = "sprd,sc9860-dwc3",
},
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 08/11] usb: dwc3: add rk3568 dwc3 support
2022-02-26 18:41 ` [PATCH v2 08/11] usb: dwc3: add rk3568 dwc3 support Peter Geis
@ 2022-02-26 21:43 ` Johan Jonker
2022-02-26 23:48 ` Peter Geis
0 siblings, 1 reply; 9+ messages in thread
From: Johan Jonker @ 2022-02-26 21:43 UTC (permalink / raw)
To: Peter Geis, Felipe Balbi, Greg Kroah-Hartman
Cc: linux-rockchip, heiko, michael.riesch, linux-usb, linux-kernel
Hi Peter,
See comments by rob+dt:
https://lore.kernel.org/linux-rockchip/CAL_JsqJwNdUfoYM8SZmOgMG9iAyZkJ4-kzjjiDDm_mdmghTEOA@mail.gmail.com/
> Presumably you are getting lucky here (with link order). The kernel
> has no logic to decide which driver to bind to if there are 2 matching
> drivers.
Due to the fall back string you make a mess with two drivers.
Don't use dwc3-of-simple.c
(only for rk3399 and legacy support. Not for new SoCs),
because core.c has now reset support.
You are creating a race which driver get probed first.
Handle your quirks in core.
Johan
On 2/26/22 19:41, Peter Geis wrote:
> The rk3568 dwc3 controller is backwards compatible with the rk3399 dwc3
> controller.
> Add support for it to the dwc3-of-simple driver.
>
> Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> ---
> drivers/usb/dwc3/dwc3-of-simple.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
> index 57ba9427ad74..d9d1c5bfac3f 100644
> --- a/drivers/usb/dwc3/dwc3-of-simple.c
> +++ b/drivers/usb/dwc3/dwc3-of-simple.c
> @@ -195,6 +195,10 @@ static const struct of_device_id of_dwc3_simple_match[] = {
> .compatible = "rockchip,rk3399-dwc3",
> .data = &dwc3_of_simple_data_rk3399,
> },
> + {
> + .compatible = "rockchip,rk3568-dwc3",
> + .data = &dwc3_of_simple_data_rk3399,
> + },
> {
> .compatible = "sprd,sc9860-dwc3",
> },
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 08/11] usb: dwc3: add rk3568 dwc3 support
2022-02-26 21:43 ` Johan Jonker
@ 2022-02-26 23:48 ` Peter Geis
0 siblings, 0 replies; 9+ messages in thread
From: Peter Geis @ 2022-02-26 23:48 UTC (permalink / raw)
To: Johan Jonker
Cc: Felipe Balbi, Greg Kroah-Hartman, open list:ARM/Rockchip SoC...,
Heiko Stuebner, Michael Riesch, linux-usb,
Linux Kernel Mailing List
On Sat, Feb 26, 2022 at 4:43 PM Johan Jonker <jbx6244@gmail.com> wrote:
>
> Hi Peter,
>
> See comments by rob+dt:
>
> https://lore.kernel.org/linux-rockchip/CAL_JsqJwNdUfoYM8SZmOgMG9iAyZkJ4-kzjjiDDm_mdmghTEOA@mail.gmail.com/
>
> > Presumably you are getting lucky here (with link order). The kernel
> > has no logic to decide which driver to bind to if there are 2 matching
> > drivers.
>
> Due to the fall back string you make a mess with two drivers.
> Don't use dwc3-of-simple.c
> (only for rk3399 and legacy support. Not for new SoCs),
> because core.c has now reset support.
> You are creating a race which driver get probed first.
> Handle your quirks in core.
I finally understood what you were trying to get at here.
After some testing, it seems the core driver handles everything we need now.
This makes me want to revisit the rk3399 support.
Thanks!
>
> Johan
>
> On 2/26/22 19:41, Peter Geis wrote:
> > The rk3568 dwc3 controller is backwards compatible with the rk3399 dwc3
> > controller.
> > Add support for it to the dwc3-of-simple driver.
> >
> > Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> > ---
> > drivers/usb/dwc3/dwc3-of-simple.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
> > index 57ba9427ad74..d9d1c5bfac3f 100644
> > --- a/drivers/usb/dwc3/dwc3-of-simple.c
> > +++ b/drivers/usb/dwc3/dwc3-of-simple.c
> > @@ -195,6 +195,10 @@ static const struct of_device_id of_dwc3_simple_match[] = {
> > .compatible = "rockchip,rk3399-dwc3",
> > .data = &dwc3_of_simple_data_rk3399,
> > },
> > + {
> > + .compatible = "rockchip,rk3568-dwc3",
> > + .data = &dwc3_of_simple_data_rk3399,
> > + },
> > {
> > .compatible = "sprd,sc9860-dwc3",
> > },
^ permalink raw reply [flat|nested] 9+ messages in thread