diff mbox series

[v2,01/15] usb: dwc2: Update exit hibernation when port reset is asserted

Message ID 20210416124651.51C8DA005C@mailhost.synopsys.com
State New
Headers show
Series [v2,01/15] usb: dwc2: Update exit hibernation when port reset is asserted | expand

Commit Message

Artur Petrosyan April 16, 2021, 12:46 p.m. UTC
No need to check for "DWC2_POWER_DOWN_PARAM_HIBERNATION" param
as "hsotg->hibernated" flag is already enough for exiting from
hibernation mode.

- Removes checking of "DWC2_POWER_DOWN_PARAM_HIBERNATION" param.

- For code readability Hibernation exit code moved after
debug message print.

- Added "dwc2_exit_hibernation()" function error checking.

Signed-off-by: Artur Petrosyan <Arthur.Petrosyan@synopsys.com>
---
 Changes in v2:
 - None

 drivers/usb/dwc2/hcd.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Comments

Minas Harutyunyan April 19, 2021, 7:30 a.m. UTC | #1
On 4/16/2021 4:46 PM, Artur Petrosyan wrote:
> No need to check for "DWC2_POWER_DOWN_PARAM_HIBERNATION" param

> as "hsotg->hibernated" flag is already enough for exiting from

> hibernation mode.

> 

> - Removes checking of "DWC2_POWER_DOWN_PARAM_HIBERNATION" param.

> 

> - For code readability Hibernation exit code moved after

> debug message print.

> 

> - Added "dwc2_exit_hibernation()" function error checking.

> 

> Signed-off-by: Artur Petrosyan <Arthur.Petrosyan@synopsys.com>


Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>


> ---

>   Changes in v2:

>   - None

> 

>   drivers/usb/dwc2/hcd.c | 17 +++++++++++------

>   1 file changed, 11 insertions(+), 6 deletions(-)

> 

> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c

> index 04a1b53d65af..cda3f931195d 100644

> --- a/drivers/usb/dwc2/hcd.c

> +++ b/drivers/usb/dwc2/hcd.c

> @@ -3668,9 +3668,17 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,

>   			break;

>   

>   		case USB_PORT_FEAT_RESET:

> -			if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_HIBERNATION &&

> -			    hsotg->hibernated)

> -				dwc2_exit_hibernation(hsotg, 0, 1, 1);

> +			dev_dbg(hsotg->dev,

> +				"SetPortFeature - USB_PORT_FEAT_RESET\n");

> +

> +			hprt0 = dwc2_read_hprt0(hsotg);

> +

> +			if (hsotg->hibernated) {

> +				retval = dwc2_exit_hibernation(hsotg, 0, 1, 1);

> +				if (retval)

> +					dev_err(hsotg->dev,

> +						"exit hibernation failed\n");

> +			}

>   

>   			if (hsotg->in_ppd) {

>   				retval = dwc2_exit_partial_power_down(hsotg, 1,

> @@ -3684,9 +3692,6 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,

>   			    DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended)

>   				dwc2_host_exit_clock_gating(hsotg, 0);

>   

> -			hprt0 = dwc2_read_hprt0(hsotg);

> -			dev_dbg(hsotg->dev,

> -				"SetPortFeature - USB_PORT_FEAT_RESET\n");

>   			pcgctl = dwc2_readl(hsotg, PCGCTL);

>   			pcgctl &= ~(PCGCTL_ENBL_SLEEP_GATING | PCGCTL_STOPPCLK);

>   			dwc2_writel(hsotg, pcgctl, PCGCTL);

>
diff mbox series

Patch

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 04a1b53d65af..cda3f931195d 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -3668,9 +3668,17 @@  static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,
 			break;
 
 		case USB_PORT_FEAT_RESET:
-			if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_HIBERNATION &&
-			    hsotg->hibernated)
-				dwc2_exit_hibernation(hsotg, 0, 1, 1);
+			dev_dbg(hsotg->dev,
+				"SetPortFeature - USB_PORT_FEAT_RESET\n");
+
+			hprt0 = dwc2_read_hprt0(hsotg);
+
+			if (hsotg->hibernated) {
+				retval = dwc2_exit_hibernation(hsotg, 0, 1, 1);
+				if (retval)
+					dev_err(hsotg->dev,
+						"exit hibernation failed\n");
+			}
 
 			if (hsotg->in_ppd) {
 				retval = dwc2_exit_partial_power_down(hsotg, 1,
@@ -3684,9 +3692,6 @@  static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,
 			    DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended)
 				dwc2_host_exit_clock_gating(hsotg, 0);
 
-			hprt0 = dwc2_read_hprt0(hsotg);
-			dev_dbg(hsotg->dev,
-				"SetPortFeature - USB_PORT_FEAT_RESET\n");
 			pcgctl = dwc2_readl(hsotg, PCGCTL);
 			pcgctl &= ~(PCGCTL_ENBL_SLEEP_GATING | PCGCTL_STOPPCLK);
 			dwc2_writel(hsotg, pcgctl, PCGCTL);