[RFC PATCH v1] phy: rockchip: add basic rk3328 support to phy-rockchip-inno-usb2.c

Johan Jonker jbx6244 at gmail.com
Wed Aug 11 13:24:41 CEST 2021


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 at 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 at 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
>>


More information about the U-Boot mailing list