2021-06-14 15:46:15

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 0/4] Add USB2 support for rk3568

The original pacth from Peter Geis is here:
https://gitlab.com/pine64-org/quartz-bsp/linux-next/-/commit/cda136f853628259198d6f70c3e14c9e5c8e097f

I have split the driver part of this patch in two:
- one to update reg usage
- one to add USB2 support for rk3568
I have added patches for the bindings:
- some clean up
- add compatible for rk3568

Benjamin

Benjamin Gaignard (4):
dt-bindings: phy: rockchip: USB2: remove useless #phy-cells property
dt-bindings: phy: rockchip: USB2: Add compatible for rk3568
PHY: rockchip: USB2: Allow 64 bits reg property
phy: rockchip: USB2: Add support for rk3568

.../bindings/phy/phy-rockchip-inno-usb2.yaml | 3 +-
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 85 +++++++++++++++++--
2 files changed, 78 insertions(+), 10 deletions(-)

--
2.25.1


2021-06-14 15:46:28

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 2/4] dt-bindings: phy: rockchip: USB2: Add compatible for rk3568

Add "rockchip,rk3568-usb2phy" in compatible list of the USB2 phy.

Signed-off-by: Benjamin Gaignard <[email protected]>
---
.../devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml b/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml
index b14387a48f6a3..a1420d5e44be7 100644
--- a/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml
+++ b/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml
@@ -18,6 +18,7 @@ properties:
- rockchip,rk3366-usb2phy
- rockchip,rk3399-usb2phy
- rockchip,rv1108-usb2phy
+ - rockchip,rk3568-usb2phy

reg:
maxItems: 1
--
2.25.1

2021-06-14 15:48:43

by Benjamin Gaignard

[permalink] [raw]
Subject: [PATCH 3/4] PHY: rockchip: USB2: Allow 64 bits reg property

In rk356x device-tree "reg" property could be coded on 64 bits.
Change reg type and of_property_read_ to make it works.

Signed-off-by: Peter Geis <[email protected]>
Signed-off-by: Benjamin Gaignard <[email protected]>
---
drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 46ebdb1460a3d..45518f96d7217 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -1068,7 +1068,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
struct rockchip_usb2phy *rphy;
const struct rockchip_usb2phy_cfg *phy_cfgs;
const struct of_device_id *match;
- unsigned int reg;
+ u64 reg;
int index, ret;

rphy = devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL);
@@ -1098,7 +1098,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
rphy->usbgrf = NULL;
}

- if (of_property_read_u32(np, "reg", &reg)) {
+ if (of_property_read_u64(np, "reg", &reg)) {
dev_err(dev, "the reg property is not assigned in %pOFn node\n",
np);
return -EINVAL;
--
2.25.1

2021-06-14 16:36:57

by Peter Geis

[permalink] [raw]
Subject: Re: [PATCH 0/4] Add USB2 support for rk3568

Good Afternoon,

This was a hack just to get it to bind.
If you'll notice I've posted a second revision that works better, but
still is untested against anything other than the rk356x.
https://gitlab.com/pine64-org/quartz-bsp/linux-next/-/commit/51612157d7ae3f3c4267ed56676f5d1a952d698f

Very Respectfully,
Peter Geis

On Mon, Jun 14, 2021 at 11:44 AM Benjamin Gaignard
<[email protected]> wrote:
>
> The original pacth from Peter Geis is here:
> https://gitlab.com/pine64-org/quartz-bsp/linux-next/-/commit/cda136f853628259198d6f70c3e14c9e5c8e097f
>
> I have split the driver part of this patch in two:
> - one to update reg usage
> - one to add USB2 support for rk3568
> I have added patches for the bindings:
> - some clean up
> - add compatible for rk3568
>
> Benjamin
>
> Benjamin Gaignard (4):
> dt-bindings: phy: rockchip: USB2: remove useless #phy-cells property
> dt-bindings: phy: rockchip: USB2: Add compatible for rk3568
> PHY: rockchip: USB2: Allow 64 bits reg property
> phy: rockchip: USB2: Add support for rk3568
>
> .../bindings/phy/phy-rockchip-inno-usb2.yaml | 3 +-
> drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 85 +++++++++++++++++--
> 2 files changed, 78 insertions(+), 10 deletions(-)
>
> --
> 2.25.1
>

2021-06-14 17:13:22

by Robin Murphy

[permalink] [raw]
Subject: Re: [PATCH 3/4] PHY: rockchip: USB2: Allow 64 bits reg property

On 2021-06-14 16:43, Benjamin Gaignard wrote:
> In rk356x device-tree "reg" property could be coded on 64 bits.
> Change reg type and of_property_read_ to make it works.

On platforms with #address-cells=1, this isn't going to do what you
think. Worse, it's not even going to fail, because you *can* read a
64-bit value from an address cell with a size cell after it...

Robin.

> Signed-off-by: Peter Geis <[email protected]>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> ---
> drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 46ebdb1460a3d..45518f96d7217 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -1068,7 +1068,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
> struct rockchip_usb2phy *rphy;
> const struct rockchip_usb2phy_cfg *phy_cfgs;
> const struct of_device_id *match;
> - unsigned int reg;
> + u64 reg;
> int index, ret;
>
> rphy = devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL);
> @@ -1098,7 +1098,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
> rphy->usbgrf = NULL;
> }
>
> - if (of_property_read_u32(np, "reg", &reg)) {
> + if (of_property_read_u64(np, "reg", &reg)) {
> dev_err(dev, "the reg property is not assigned in %pOFn node\n",
> np);
> return -EINVAL;
>

2021-06-14 18:22:37

by Johan Jonker

[permalink] [raw]
Subject: Re: [PATCH 2/4] dt-bindings: phy: rockchip: USB2: Add compatible for rk3568

Hi Benjamin,

The '#phy-cells' in [PATCH 1/4] are already gone.
The nodename is renamed to pattern "usb2phy@[0-9a-f]+$".
phy-rockchip-inno-usb2.yaml is now also part of grf.yaml, so must take
care of both.

From rk3568.dtsi:

usb2phy0_grf: syscon@fdca0000 {
compatible = "rockchip,rk3568-usb2phy-grf", "syscon";
reg = <0x0 0xfdca0000 0x0 0x8000>;
};

usb2phy1_grf: syscon@fdca8000 {
compatible = "rockchip,rk3568-usb2phy-grf", "syscon";
reg = <0x0 0xfdca8000 0x0 0x8000>;
};

usb2phy0: usb2phy@fe8a0000 {
compatible = "rockchip,rk3568-usb2phy";
reg = <0x0 0xfe8a0000 0x0 0x10000>;
interrupts = <GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&pmucru CLK_USBPHY0_REF>;
clock-names = "phyclk";
#clock-cells = <0>;
assigned-clocks = <&cru USB480M>;
assigned-clock-parents = <&usb2phy0>;
clock-output-names = "usb480m_phy";
rockchip,usbgrf = <&usb2phy0_grf>;
status = "disabled";

u2phy0_host: host-port {
#phy-cells = <0>;
status = "disabled";
};

u2phy0_otg: otg-port {
#phy-cells = <0>;
status = "disabled";
};
};

usb2phy1: usb2phy@fe8b0000 {
compatible = "rockchip,rk3568-usb2phy";
reg = <0x0 0xfe8b0000 0x0 0x10000>;
interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&pmucru CLK_USBPHY1_REF>;
clock-names = "phyclk";
#clock-cells = <0>;
rockchip,usbgrf = <&usb2phy1_grf>;
status = "disabled";

u2phy1_host: host-port {
#phy-cells = <0>;
status = "disabled";
};

u2phy1_otg: otg-port {
#phy-cells = <0>;
status = "disabled";
};
};

rockchip,rk3568-usb2phy-grf must also be added to grf.yaml.

See linux-next.

https://lore.kernel.org/linux-devicetree/[email protected]/

Johan

On 6/14/21 5:43 PM, Benjamin Gaignard wrote:
> Add "rockchip,rk3568-usb2phy" in compatible list of the USB2 phy.
>
> Signed-off-by: Benjamin Gaignard <[email protected]>
> ---
> .../devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml b/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml
> index b14387a48f6a3..a1420d5e44be7 100644
> --- a/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml
> +++ b/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml
> @@ -18,6 +18,7 @@ properties:
> - rockchip,rk3366-usb2phy
> - rockchip,rk3399-usb2phy

--->

> - rockchip,rv1108-usb2phy

> + - rockchip,rk3568-usb2phy

Please sort in alphabetical order.

>
> reg:
> maxItems: 1
>

2021-06-14 22:02:06

by Peter Geis

[permalink] [raw]
Subject: Re: [PATCH 3/4] PHY: rockchip: USB2: Allow 64 bits reg property

On Mon, Jun 14, 2021 at 1:09 PM Robin Murphy <[email protected]> wrote:
>
> On 2021-06-14 16:43, Benjamin Gaignard wrote:
> > In rk356x device-tree "reg" property could be coded on 64 bits.
> > Change reg type and of_property_read_ to make it works.
>
> On platforms with #address-cells=1, this isn't going to do what you
> think. Worse, it's not even going to fail, because you *can* read a
> 64-bit value from an address cell with a size cell after it...

Apologies, this was a hack and in no way ready for submission.

While I've got you here, what would be the best way to handle this?
Since previous generations #address-cells=1 and #size-cells=1, where
the rk356x #address-cells=2 and #size-cells=2 and we need to account
for both of them.

Thanks,
Peter

>
> Robin.
>
> > Signed-off-by: Peter Geis <[email protected]>
> > Signed-off-by: Benjamin Gaignard <[email protected]>
> > ---
> > drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > index 46ebdb1460a3d..45518f96d7217 100644
> > --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > @@ -1068,7 +1068,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
> > struct rockchip_usb2phy *rphy;
> > const struct rockchip_usb2phy_cfg *phy_cfgs;
> > const struct of_device_id *match;
> > - unsigned int reg;
> > + u64 reg;
> > int index, ret;
> >
> > rphy = devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL);
> > @@ -1098,7 +1098,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
> > rphy->usbgrf = NULL;
> > }
> >
> > - if (of_property_read_u32(np, "reg", &reg)) {
> > + if (of_property_read_u64(np, "reg", &reg)) {
> > dev_err(dev, "the reg property is not assigned in %pOFn node\n",
> > np);
> > return -EINVAL;
> >