phy: rockchip: add basic rk3328 support to phy-rockchip-inno-usb2.c
Subsystems (2)
RFC PATCH 1/1 phy: rockchip: add basic rk3328 support to phy-rockchip-inno-usb2.c
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
--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +29 -0
@@ -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, },
Signature · 1 line
2.11.0
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
Quoted 60 lines · Johan Jonker <[email protected]> 于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.cSigned-off-by Johan Jonker <[email protected]>--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)drivers/phy/rockchip/phy-rockchip-inno-usb2.c +29
-1@@ -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
Hi Kever,
Thank you for your comment.
Quoted 2 lines · Kever Yang
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
Quoted 2 lines
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?
Quoted 3 lines
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";
+};
Quoted 20 lines
Quoted 18 lines · Johan Jonker <[email protected]> 于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.cSigned-off-by Johan Jonker <[email protected]>--- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)drivers/phy/rockchip/phy-rockchip-inno-usb2.c +0
-0@@ -243,6 +243,31 @@ static int rockchip_usb2phy_bind(struct udevice *dev)return ret; }
Quoted 5 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_bind(struct udevice *dev) · line 250
Quoted 5 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +5
-0+static const struct rockchip_usb2phy_cfg rk3328_usb2phy_cfgs[] = { + { + .reg =0x100 , + .port_cfgs = { + [USB2PHY_PORT_OTG ] = {
U-boot:
Quoted 1 line
drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_bind(struct udevice *dev) · line 251
Quoted 1 line
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1
-0+ .phy_sus = { 0x0100, 8, 0, 0, 0x1d1 },
Linux:
.phy_sus = { 0x0100, 15, 0, 0, 0x1d1 },Which is correct?
Quoted 7 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_bind(struct udevice *dev) · line 258
Quoted 7 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +7
-0+ .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:
Quoted 1 line
drivers/phy/rockchip/phy-rockchip-inno-usb2.c static int rockchip_usb2phy_bind(struct udevice *dev) · line 259
Quoted 1 line
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +1
-0+ .phy_sus = { 0x104, 8, 0, 0, 0x1d1 },
Linux:
.phy_sus = { 0x104, 15, 0, 0, 0x1d1 },Which is correct?
Quoted 28 lines
Quoted 28 lines
drivers/phy/rockchip/phy-rockchip-inno-usb2.c +15
-1+ .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