[PATCH 2/2] usb: dwc2: add true DWC2_POWER_DOWN_PARAM_NONE state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Refactor no_clock_gating flag into separate DWC2_POWER_DOWN_PARAM_NONE
power down state.

Suggested-by: Minas Harutyunyan <Minas.Harutyunyan@xxxxxxxxxxxx>
Signed-off-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
---
This is a follow-up of this discussion:
https://lore.kernel.org/linux-usb/26099de1-826f-42bf-0de7-759a47faf4a0@xxxxxxxxxxx/

This should be applied on top of v5.14-rc3.
---
 drivers/usb/dwc2/core.h      | 6 ++----
 drivers/usb/dwc2/core_intr.c | 6 ++++--
 drivers/usb/dwc2/hcd.c       | 8 ++++----
 drivers/usb/dwc2/params.c    | 4 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 38b6733d26ec..d590eda952a2 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -382,12 +382,10 @@ enum dwc2_ep0_state {
  *			If power_down is enabled, the controller will enter
  *			power_down in both peripheral and host mode when
  *			needed.
+ *			(-1) - None
  *			0 - Clock gating (default)
  *			1 - Partial power down
  *			2 - Hibernation
- * @no_clock_gating:	Specifies whether to avoid clock gating feature.
- *			0 - No (use clock gating)
- *			1 - Yes (avoid it)
  * @lpm:		Enable LPM support.
  *			0 - No
  *			1 - Yes
@@ -482,10 +480,10 @@ struct dwc2_core_params {
 	bool external_id_pin_ctl;
 
 	int power_down;
+#define DWC2_POWER_DOWN_PARAM_NONE		(-1)
 #define DWC2_POWER_DOWN_PARAM_CLOCK_GATING	0
 #define DWC2_POWER_DOWN_PARAM_PARTIAL		1
 #define DWC2_POWER_DOWN_PARAM_HIBERNATION	2
-	bool no_clock_gating;
 
 	bool lpm;
 	bool lpm_clock_gating;
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 660abff1d42b..cdd39199780e 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -556,8 +556,10 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg *hsotg)
 				 * If neither hibernation nor partial power down are supported,
 				 * clock gating is used to save power.
 				 */
-				if (!hsotg->params.no_clock_gating)
-					dwc2_gadget_enter_clock_gating(hsotg);
+				dwc2_gadget_enter_clock_gating(hsotg);
+				break;
+			case DWC2_POWER_DOWN_PARAM_NONE:
+				break;
 			}
 
 			/*
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 067f2770c2ef..d06bb927a073 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -3338,8 +3338,9 @@ 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)
-			dwc2_host_enter_clock_gating(hsotg);
+		dwc2_host_enter_clock_gating(hsotg);
+		break;
+	case DWC2_POWER_DOWN_PARAM_NONE:
 		break;
 	}
 
@@ -4403,8 +4404,7 @@ 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)
-			dwc2_host_enter_clock_gating(hsotg);
+		dwc2_host_enter_clock_gating(hsotg);
 
 		/* After entering suspend, hardware is not accessible */
 		clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index dac26410b575..2ad9f407ca40 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -75,8 +75,7 @@ static void dwc2_set_s3c6400_params(struct dwc2_hsotg *hsotg)
 {
 	struct dwc2_core_params *p = &hsotg->params;
 
-	p->power_down = DWC2_POWER_DOWN_PARAM_CLOCK_GATING;
-	p->no_clock_gating = true;
+	p->power_down = DWC2_POWER_DOWN_PARAM_NONE;
 	p->phy_utmi_width = 8;
 }
 
@@ -585,6 +584,7 @@ static void dwc2_check_param_power_down(struct dwc2_hsotg *hsotg)
 	int param = hsotg->params.power_down;
 
 	switch (param) {
+	case DWC2_POWER_DOWN_PARAM_NONE:
 	case DWC2_POWER_DOWN_PARAM_CLOCK_GATING:
 		break;
 	case DWC2_POWER_DOWN_PARAM_PARTIAL:
-- 
2.17.1




[Index of Archives]     [Linux SoC Development]     [Linux Rockchip Development]     [Linux for Synopsys ARC Processors]    
  • [Linux on Unisoc (RDA Micro) SoCs]     [Linux Actions SoC]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Linux SCSI]     [Yosemite News]

  •   Powered by Linux