linux-samsung-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Minas Harutyunyan <hminas@synopsys.com>,
	Artur Petrosyan <Arthur.Petrosyan@synopsys.com>,
	Felipe Balbi <balbi@kernel.org>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>
Subject: [PATCH 2/2] usb: dwc2: add true DWC2_POWER_DOWN_PARAM_NONE state
Date: Wed,  4 Aug 2021 13:44:21 +0200	[thread overview]
Message-ID: <20210804114421.10282-2-m.szyprowski@samsung.com> (raw)
In-Reply-To: <20210804114421.10282-1-m.szyprowski@samsung.com>

Refactor no_clock_gating flag into separate DWC2_POWER_DOWN_PARAM_NONE
power down state.

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

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


  parent reply	other threads:[~2021-08-04 11:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210804114433eucas1p134417b605abeb57728d358fc2f42162b@eucas1p1.samsung.com>
2021-08-04 11:44 ` [PATCH 1/2] usb: dwc2: rename DWC2_POWER_DOWN_PARAM_NONE state Marek Szyprowski
     [not found]   ` <CGME20210804114433eucas1p255ac5db7e56a8d5e50b8937c07559587@eucas1p2.samsung.com>
2021-08-04 11:44     ` Marek Szyprowski [this message]
2021-08-05  9:15   ` Greg KH
2021-08-05  9:22     ` Minas Harutyunyan
2021-08-05  9:41       ` Greg KH
2021-08-05 13:49   ` Artur Petrosyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210804114421.10282-2-m.szyprowski@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=Arthur.Petrosyan@synopsys.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=balbi@kernel.org \
    --cc=hminas@synopsys.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).