All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1] phy: rockchip: add basic rk3328 support to phy-rockchip-inno-usb2.c
@ 2021-06-30 16:40 Johan Jonker
  2021-08-11 10:01 ` Kever Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Jonker @ 2021-06-30 16:40 UTC (permalink / raw)
  To: kever.yang
  Cc: sjg, philipp.tomsich, heiko, mail, ldevulder, wens,
	banglang.huang, matwey.kornilov, u-boot

The rk3328 uses a usb phy simulair to rk3399 with only
1 instead of 2 usb ports. Reuse existing U-boot driver and
add basic rk3328 support to phy-rockchip-inno-usb2.c

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 62b8ba3a4a..bfb531d3cd 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -243,6 +243,31 @@ static int rockchip_usb2phy_bind(struct udevice *dev)
 	return ret;
 }
 
+static const struct rockchip_usb2phy_cfg rk3328_usb2phy_cfgs[] = {
+	{
+		.reg		= 0x100,
+		.port_cfgs	= {
+			[USB2PHY_PORT_OTG] = {
+				.phy_sus	= { 0x0100, 8, 0, 0, 0x1d1 },
+				.bvalid_det_en	= { 0x0110, 2, 2, 0, 1 },
+				.bvalid_det_st	= { 0x0114, 2, 2, 0, 1 },
+				.bvalid_det_clr = { 0x0118, 2, 2, 0, 1 },
+				.utmi_avalid	= { 0x0120, 10, 10, 0, 1 },
+				.utmi_bvalid	= { 0x0120, 9, 9, 0, 1 },
+			},
+			[USB2PHY_PORT_HOST] = {
+				.phy_sus	= { 0x104, 8, 0, 0, 0x1d1 },
+				.ls_det_en	= { 0x110, 1, 1, 0, 1 },
+				.ls_det_st	= { 0x114, 1, 1, 0, 1 },
+				.ls_det_clr	= { 0x118, 1, 1, 0, 1 },
+				.utmi_ls	= { 0x120, 17, 16, 0, 1 },
+				.utmi_hstdet	= { 0x120, 19, 19, 0, 1 }
+			}
+		},
+	},
+	{ /* sentinel */ }
+};
+
 static const struct rockchip_usb2phy_cfg rk3399_usb2phy_cfgs[] = {
 	{
 		.reg		= 0xe450,
@@ -291,6 +316,10 @@ static const struct rockchip_usb2phy_cfg rk3399_usb2phy_cfgs[] = {
 
 static const struct udevice_id rockchip_usb2phy_ids[] = {
 	{
+		.compatible = "rockchip,rk3328-usb2phy",
+		.data = (ulong)&rk3328_usb2phy_cfgs
+	},
+	{
 		.compatible = "rockchip,rk3399-usb2phy",
 		.data = (ulong)&rk3399_usb2phy_cfgs,
 	},
-- 
2.11.0


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

* Re: [RFC PATCH v1] phy: rockchip: add basic rk3328 support to phy-rockchip-inno-usb2.c
  2021-06-30 16:40 [RFC PATCH v1] phy: rockchip: add basic rk3328 support to phy-rockchip-inno-usb2.c Johan Jonker
@ 2021-08-11 10:01 ` Kever Yang
  2021-08-11 11:24   ` Johan Jonker
  0 siblings, 1 reply; 3+ messages in thread
From: Kever Yang @ 2021-08-11 10:01 UTC (permalink / raw)
  To: Johan Jonker, frank.wang
  Cc: Kever Yang, Simon Glass, Philipp Tomsich, Heiko Stuebner, mail,
	ldevulder, Chen-Yu Tsai, banglang.huang, Matwey V. Kornilov,
	U-Boot-Denx

Hi Johan,
     Thanks for your patch, where does this source code come from? Is
there any code change other than the structure for rk3328?
    Please remove the RFC tag once the patch is ready.

Thanks,
- Kever

Johan Jonker <jbx6244@gmail.com> 于2021年7月1日周四 上午2:50写道:
>
> The rk3328 uses a usb phy simulair to rk3399 with only
> 1 instead of 2 usb ports. Reuse existing U-boot driver and
> add basic rk3328 support to phy-rockchip-inno-usb2.c
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
> ---
>  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 29 +++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 62b8ba3a4a..bfb531d3cd 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -243,6 +243,31 @@ static int rockchip_usb2phy_bind(struct udevice *dev)
>         return ret;
>  }
>
> +static const struct rockchip_usb2phy_cfg rk3328_usb2phy_cfgs[] = {
> +       {
> +               .reg            = 0x100,
> +               .port_cfgs      = {
> +                       [USB2PHY_PORT_OTG] = {
> +                               .phy_sus        = { 0x0100, 8, 0, 0, 0x1d1 },
> +                               .bvalid_det_en  = { 0x0110, 2, 2, 0, 1 },
> +                               .bvalid_det_st  = { 0x0114, 2, 2, 0, 1 },
> +                               .bvalid_det_clr = { 0x0118, 2, 2, 0, 1 },
> +                               .utmi_avalid    = { 0x0120, 10, 10, 0, 1 },
> +                               .utmi_bvalid    = { 0x0120, 9, 9, 0, 1 },
> +                       },
> +                       [USB2PHY_PORT_HOST] = {
> +                               .phy_sus        = { 0x104, 8, 0, 0, 0x1d1 },
> +                               .ls_det_en      = { 0x110, 1, 1, 0, 1 },
> +                               .ls_det_st      = { 0x114, 1, 1, 0, 1 },
> +                               .ls_det_clr     = { 0x118, 1, 1, 0, 1 },
> +                               .utmi_ls        = { 0x120, 17, 16, 0, 1 },
> +                               .utmi_hstdet    = { 0x120, 19, 19, 0, 1 }
> +                       }
> +               },
> +       },
> +       { /* sentinel */ }
> +};
> +
>  static const struct rockchip_usb2phy_cfg rk3399_usb2phy_cfgs[] = {
>         {
>                 .reg            = 0xe450,
> @@ -291,6 +316,10 @@ static const struct rockchip_usb2phy_cfg rk3399_usb2phy_cfgs[] = {
>
>  static const struct udevice_id rockchip_usb2phy_ids[] = {
>         {
> +               .compatible = "rockchip,rk3328-usb2phy",
> +               .data = (ulong)&rk3328_usb2phy_cfgs
> +       },
> +       {
>                 .compatible = "rockchip,rk3399-usb2phy",
>                 .data = (ulong)&rk3399_usb2phy_cfgs,
>         },
> --
> 2.11.0
>

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

* Re: [RFC PATCH v1] phy: rockchip: add basic rk3328 support to phy-rockchip-inno-usb2.c
  2021-08-11 10:01 ` Kever Yang
@ 2021-08-11 11:24   ` Johan Jonker
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Jonker @ 2021-08-11 11:24 UTC (permalink / raw)
  To: Kever Yang, frank.wang
  Cc: Simon Glass, Philipp Tomsich, Heiko Stuebner, mail, ldevulder,
	Chen-Yu Tsai, banglang.huang, Matwey V. Kornilov, U-Boot-Denx

Hi Kever,

Thank you for your comment.
On 8/11/21 12:01 PM, Kever Yang wrote:
> Hi Johan,
>      Thanks for your patch, where does this source code come from?

Copied it from here:
https://github.com/rockchip-linux/u-boot/blame/next-dev/drivers/phy/phy-rockchip-inno-usb2.c

phy: add a new driver for rockchip usb2 phy
https://github.com/rockchip-linux/u-boot/commit/f0c40dcdc2ca7d6522efeee4bd2e42dc8e3e8ab2

Adjusted it for current u-boot driver.
Mainline u-boot has no chg_det.

 Is
> there any code change other than the structure for rk3328?
>     Please remove the RFC tag once the patch is ready.

Anyone with a tested-by tag?
Do I have to resend only to remove a RFC tag or can a maintainer do that
when he/she applies?

> 
> Thanks,
> - Kever

Note:
In the rk3328.dtsi sync from Linux phy dr_mode is standard otg,
but that doesn't work, so all are set to host in a dts.

In rk3318-a95x-z2.dts

+&usb20_otg {
+	dr_mode = "host";
+	status = "okay";
+};

In u-boot to work we must set it back to otg because of:
port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG];

In rk3318-a95x-z2-u-boot.dtsi
+&usb20_otg {
+	dr_mode = "otg";
+};

> 
> Johan Jonker <jbx6244@gmail.com> 于2021年7月1日周四 上午2:50写道:
>>
>> The rk3328 uses a usb phy simulair to rk3399 with only
>> 1 instead of 2 usb ports. Reuse existing U-boot driver and
>> add basic rk3328 support to phy-rockchip-inno-usb2.c
>>
>> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
>> ---
>>  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 29 +++++++++++++++++++++++++++
>>  1 file changed, 29 insertions(+)
>>
>> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
>> index 62b8ba3a4a..bfb531d3cd 100644
>> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
>> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
>> @@ -243,6 +243,31 @@ static int rockchip_usb2phy_bind(struct udevice *dev)
>>         return ret;
>>  }
>>
>> +static const struct rockchip_usb2phy_cfg rk3328_usb2phy_cfgs[] = {
>> +       {
>> +               .reg            = 0x100,
>> +               .port_cfgs      = {
>> +                       [USB2PHY_PORT_OTG] = {

U-boot:
>> +                               .phy_sus        = { 0x0100, 8, 0, 0, 0x1d1 },

Linux:
				.phy_sus	= { 0x0100, 15, 0, 0, 0x1d1 },

Which is correct?

>> +                               .bvalid_det_en  = { 0x0110, 2, 2, 0, 1 },
>> +                               .bvalid_det_st  = { 0x0114, 2, 2, 0, 1 },
>> +                               .bvalid_det_clr = { 0x0118, 2, 2, 0, 1 },
>> +                               .utmi_avalid    = { 0x0120, 10, 10, 0, 1 },
>> +                               .utmi_bvalid    = { 0x0120, 9, 9, 0, 1 },
>> +                       },
>> +                       [USB2PHY_PORT_HOST] = {

U-boot:
>> +                               .phy_sus        = { 0x104, 8, 0, 0, 0x1d1 },

Linux:
				.phy_sus	= { 0x104, 15, 0, 0, 0x1d1 },

Which is correct?

>> +                               .ls_det_en      = { 0x110, 1, 1, 0, 1 },
>> +                               .ls_det_st      = { 0x114, 1, 1, 0, 1 },
>> +                               .ls_det_clr     = { 0x118, 1, 1, 0, 1 },
>> +                               .utmi_ls        = { 0x120, 17, 16, 0, 1 },
>> +                               .utmi_hstdet    = { 0x120, 19, 19, 0, 1 }
>> +                       }
>> +               },
>> +       },
>> +       { /* sentinel */ }
>> +};
>> +
>>  static const struct rockchip_usb2phy_cfg rk3399_usb2phy_cfgs[] = {
>>         {
>>                 .reg            = 0xe450,
>> @@ -291,6 +316,10 @@ static const struct rockchip_usb2phy_cfg rk3399_usb2phy_cfgs[] = {
>>
>>  static const struct udevice_id rockchip_usb2phy_ids[] = {
>>         {
>> +               .compatible = "rockchip,rk3328-usb2phy",
>> +               .data = (ulong)&rk3328_usb2phy_cfgs
>> +       },
>> +       {
>>                 .compatible = "rockchip,rk3399-usb2phy",
>>                 .data = (ulong)&rk3399_usb2phy_cfgs,
>>         },
>> --
>> 2.11.0
>>

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

end of thread, other threads:[~2021-08-11 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 16:40 [RFC PATCH v1] phy: rockchip: add basic rk3328 support to phy-rockchip-inno-usb2.c Johan Jonker
2021-08-11 10:01 ` Kever Yang
2021-08-11 11:24   ` Johan Jonker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.