From 7305eab358da446155024abfa01d5fdb21690d86 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Sun, 22 Mar 2020 23:47:38 -0700 Subject: [PATCH] MLK-23656 imx8: Power off connectivty SS when boot from usb When boot from usb, scfw won't re-initialize the connectivity subsystem. This special behavior is for uuu virtual console feature. However, it causes entire connectivity SS using settings from ROM. We found the bus clocks are from AVPLL not DPLL and lower than ADD required. It causes OTG performance drop about 20% during fastboot because more NYET handshake added into each transfer. To workaround the issue, we need to power off all usb resources to let connectivity SS power down at early uboot phase. Then power on any resource in conn SS will re-initialize the subsystem. Regard to auto USB port check, we only has this workaround in u-boot not in SPL. SPL uses SDP to download other images, the sizes are very small and not impacted. Signed-off-by: Ye Li Tested-by: Peter Chen Acked-by: Peng Fan (cherry picked from commit 625b061107928377f51859ee9c0558dc7d56c137) (cherry picked from commit b5d057e8fdf7ca91fe41204132cd3bff4f57d57a) --- arch/arm/mach-imx/imx8/cpu.c | 41 +++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index b09cbf1237..698e79fc54 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -56,6 +56,8 @@ int arch_cpu_init(void) return 0; } +static void power_off_all_usb(void); + int arch_cpu_init_dm(void) { struct udevice *devp; @@ -89,6 +91,8 @@ int arch_cpu_init_dm(void) return ret; } + power_off_all_usb(); + return 0; } @@ -1034,7 +1038,9 @@ int board_imx_lpi2c_bind(struct udevice *dev) } #ifdef CONFIG_USB_PORT_AUTO -int board_usb_gadget_port_auto(void) +int usb_boot_index = 0xf; + +static int usb_port_auto_check(void) { int ret; u32 usb2_data; @@ -1079,4 +1085,37 @@ int board_usb_gadget_port_auto(void) } return -1; } + +static void usb_port_record_index(void) +{ + usb_boot_index = usb_port_auto_check(); + if (usb_boot_index < 0) + usb_boot_index = 0; +} + +int board_usb_gadget_port_auto(void) +{ +#if defined(CONFIG_SPL_BUILD) + usb_port_record_index(); #endif + + return usb_boot_index; +} +#endif + +static void power_off_all_usb(void) +{ + if (is_usb_boot()) { +#ifdef CONFIG_USB_PORT_AUTO + usb_port_record_index(); +#endif + /* Turn off all usb resource to let conn SS power down */ + sc_pm_set_resource_power_mode(-1, SC_R_USB_0_PHY, SC_PM_PW_MODE_OFF); + sc_pm_set_resource_power_mode(-1, SC_R_USB_1_PHY, SC_PM_PW_MODE_OFF); + sc_pm_set_resource_power_mode(-1, SC_R_USB_2_PHY, SC_PM_PW_MODE_OFF); + + sc_pm_set_resource_power_mode(-1, SC_R_USB_0, SC_PM_PW_MODE_OFF); + sc_pm_set_resource_power_mode(-1, SC_R_USB_1, SC_PM_PW_MODE_OFF); + sc_pm_set_resource_power_mode(-1, SC_R_USB_2, SC_PM_PW_MODE_OFF); + } +} -- 2.17.1