From d036e8956b87dacc7e68aa4423cc9beab72c83d3 Mon Sep 17 00:00:00 2001 From: Jianwei Zheng Date: Tue, 23 Jul 2024 16:20:52 +0800 Subject: [PATCH] usb: dwc2: fix the port cannot suspend when a HUB is connected This patch fix the port cannot suspend when a HUB is connected. The DWC2 IP on Rockchip SOCs does not support clock gating and Current code places the port suspend within the dwc2_host_enter_clock_gating function, which results in the port being unable to suspend. Change-Id: I40fe73d116a30fec6c01a8c3c988653a48175f7f Signed-off-by: William Wu Signed-off-by: Jianwei Zheng --- drivers/usb/dwc2/hcd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 2d7f4b773f4d..1538ebcd29e2 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3327,7 +3327,8 @@ int dwc2_port_suspend(struct dwc2_hsotg *hsotg, u16 windex) * If not hibernation nor partial power down are supported, * clock gating is used to save power. */ - if (!hsotg->params.no_clock_gating) + if (!hsotg->params.no_clock_gating || + IS_REACHABLE(CONFIG_ARCH_ROCKCHIP)) dwc2_host_enter_clock_gating(hsotg); break; } @@ -4392,7 +4393,8 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) * If not hibernation nor partial power down are supported, * clock gating is used to save power. */ - if (!hsotg->params.no_clock_gating) { + if (!hsotg->params.no_clock_gating || + IS_REACHABLE(CONFIG_ARCH_ROCKCHIP)) { dwc2_host_enter_clock_gating(hsotg); /* After entering suspend, hardware is not accessible */ @@ -5921,11 +5923,13 @@ void dwc2_host_enter_clock_gating(struct dwc2_hsotg *hsotg) dwc2_writel(hsotg, pcgctl, PCGCTL); udelay(5); +#ifndef CONFIG_ARCH_ROCKCHIP /* Set the Gate hclk as suspend is received. */ pcgctl = dwc2_readl(hsotg, PCGCTL); pcgctl |= PCGCTL_GATEHCLK; dwc2_writel(hsotg, pcgctl, PCGCTL); udelay(5); +#endif hsotg->bus_suspended = true; hsotg->lx_state = DWC2_L2;