usb: gadget: dwc2: find the Rockchip USB2 PHY for the DM gadget
PATCH 1/1 usb: gadget: dwc2: find the Rockchip USB2 PHY for the DM gadget
rockchip_usb2_phy.c's otg_phy_init() finds its register layout through plat->phy_of_node and calls hang() without it. Only the non-DM board_usb_init() path fills that in, so with the DM gadget (USB ACM console, fastboot, UMS) any gadget on RK3066/RK3188 hangs.
Look up the PHY from the "phys" phandle and set phy_of_node and regs_phy the same way.
Tested on an MK808B (RK3066): USB ACM console, fastboot and UMS.
--- drivers/usb/gadget/dwc2_udc_otg.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/usb/gadget/dwc2_udc_otg.c +23 -0
@@ -20,6 +20,10 @@#include <clk.h> #include <dm.h> #include <generic-phy.h> +#if CONFIG_IS_ENABLED (ROCKCHIP_USB2_PHY ) +#include <asm/arch-rockchip/clock.h> +#include <syscon.h> +#endif #include <log.h> #include <malloc.h> #include <reset.h>
@@ -995,6 +999,25 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev) plat->regs_otg =dev_read_addr (dev); +#if CONFIG_IS_ENABLED (ROCKCHIP_USB2_PHY ) +/* +* rockchip_usb2_phy.c's otg_phy_init() finds its register layout through +* phy_of_node and hang()s without it. The non-DM board_usb_init() fills it in; +* do the same here so the DM gadget (USB console, fastboot) works on RK3066/3188. +*/ + { +struct ofnode_phandle_args args; +u32 offset; + +if (!dev_read_phandle_with_args (dev,"phys" ,"#phy-cells" ,0 ,0 , &args) && + !ofnode_read_u32 (args.node,"reg" , &offset)) { + plat->phy_of_node =ofnode_get_parent (args.node); + plat->regs_phy = offset + + (uintptr_t )syscon_get_first_range (ROCKCHIP_SYSCON_GRF ); + } + } +#endif + plat->rx_fifo_sz =dev_read_u32_default (dev,"g-rx-fifo-size" ,0 ); plat->np_tx_fifo_sz =dev_read_u32_default (dev,"g-np-tx-fifo-size" ,0 );
Signature · 1 line
2.47.3
Hi Yalçın,
Thank you for the patch.
Quoted 11 lines
rockchip_usb2_phy.c's
otg_phy_init()finds its register layout throughplat->phy_of_nodeand callshang()without it. Only the non-DMboard_usb_init()path fills that in, so with the DM gadget (USB ACM console, fastboot, UMS) any gadget on RK3066/RK3188 hangs.Look up the PHY from the "phys" phandle and set
phy_of_nodeandregs_phythe same way.Tested on an MK808B (RK3066): USB ACM console, fastboot and UMS.
Co-Authored-By Claude Opus 5.5 <[email protected]>
Thanks for reporting that LLM has been used to generate this.
checkpatch.pl seems to complain about this trailer. I think it should be removed.
Quoted 32 lines
Signed-off-by Yalçın Can <[email protected]>--- drivers/usb/gadget/dwc2_udc_otg.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/usb/gadget/dwc2_udc_otg.c +12
-0@@ -20,6 +20,10 @@#include <clk.h> #include <dm.h> #include <generic-phy.h> +#if CONFIG_IS_ENABLED (ROCKCHIP_USB2_PHY ) +#include <asm/arch-rockchip/clock.h> +#include <syscon.h> +#endif #include <log.h> #include <malloc.h> #include <reset.h> @@ -995,6 +999,25 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev) plat->regs_otg =dev_read_addr (dev); +#if CONFIG_IS_ENABLED (ROCKCHIP_USB2_PHY ) +/* +* rockchip_usb2_phy.c's otg_phy_init() finds its register layout through +* phy_of_node and hang()s without it. The non-DM board_usb_init() fills it in; +* do the same here so the DM gadget (USB console, fastboot) works on RK3066/3188. +*/ + { +struct ofnode_phandle_args args;
drivers/usb/gadget/dwc2_udc_otg.c static int dwc2_udc_otg_of_to_plat(struct udevice *dev) · line 1019
Quoted 10 lines
drivers/usb/gadget/dwc2_udc_otg.c +10
-0+u32 offset; + +if (!dev_read_phandle_with_args (dev,"phys" ,"#phy-cells" ,0 ,0 , &args) && + !ofnode_read_u32 (args.node,"reg" , &offset)) { + plat->phy_of_node =ofnode_get_parent (args.node); + plat->regs_phy = offset + + (uintptr_t )syscon_get_first_range (ROCKCHIP_SYSCON_GRF ); + } + } +#endif
I've compared this with the code in arch/arm/mach-rockchip/board.c and it looks indeed similar.
What I fail to understand is why we can't do this via a platform compatible. Per my understanding we can use '"rockchip,rk3066-usb", "snps,dwc2"' to match this.
Could we extend this via dev_get_driver_data() instead?
Signature · 1 line
Mattijs Korpershoek <[email protected]>