[PATCH v1 08/14] usb: dwc2: Add default param to control power optimization.

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

 



- Added a default param "power_saving" to enable or
  disable hibernation or partial power down features.

- Printed hibernation param in hw_params_show and
  power_saving param in params_show.

Signed-off-by: Artur Petrosyan <arturp@xxxxxxxxxxxx>
Signed-off-by: Minas Harutyunyan <hminas@xxxxxxxxxxxx>
---
 drivers/usb/dwc2/core.h    |  3 +++
 drivers/usb/dwc2/debugfs.c |  2 ++
 drivers/usb/dwc2/params.c  | 19 +++++++++++++------
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 30bab8463c96..9221933ab64e 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -373,6 +373,8 @@ enum dwc2_ep0_state {
  *                      case.
  *                      0 - No (default)
  *                      1 - Yes
+ * @power_saving:	Specifies if power saving is enabled or not. If it is
+ *			enabled power_down functionality will be enabled.
  * @power_down:         Specifies whether the controller support power_down.
  *			If power_down is enabled, the controller will enter
  *			power_down in both peripheral and host mode when
@@ -469,6 +471,7 @@ struct dwc2_core_params {
 	bool uframe_sched;
 	bool external_id_pin_ctl;
 
+	unsigned int power_saving:1;
 	int power_down;
 #define DWC2_POWER_DOWN_PARAM_NONE		0
 #define DWC2_POWER_DOWN_PARAM_PARTIAL		1
diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
index 7f62f4cdc265..8b27cf0b682b 100644
--- a/drivers/usb/dwc2/debugfs.c
+++ b/drivers/usb/dwc2/debugfs.c
@@ -695,6 +695,7 @@ static int params_show(struct seq_file *seq, void *v)
 	print_param_hex(seq, p, ahbcfg);
 	print_param(seq, p, uframe_sched);
 	print_param(seq, p, external_id_pin_ctl);
+	print_param(seq, p, power_saving);
 	print_param(seq, p, power_down);
 	print_param(seq, p, lpm);
 	print_param(seq, p, lpm_clock_gating);
@@ -746,6 +747,7 @@ static int hw_params_show(struct seq_file *seq, void *v)
 	print_param(seq, hw, num_dev_perio_in_ep);
 	print_param(seq, hw, total_fifo_size);
 	print_param(seq, hw, power_optimized);
+	print_param(seq, hw, hibernation);
 	print_param(seq, hw, utmi_phy_data_width);
 	print_param_hex(seq, hw, snpsid);
 	print_param_hex(seq, hw, dev_ep_dirs);
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 24ff5f21cb25..d7cc336aa1b7 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -263,12 +263,18 @@ static void dwc2_set_param_power_down(struct dwc2_hsotg *hsotg)
 {
 	int val;
 
-	if (hsotg->hw_params.hibernation)
-		val = 2;
-	else if (hsotg->hw_params.power_optimized)
-		val = 1;
-	else
-		val = 0;
+	if (!hsotg->params.power_saving) {
+		val = DWC2_POWER_DOWN_PARAM_NONE;
+		dev_dbg(hsotg->dev, "%s: Power saving is disabled.\n",
+			__func__);
+	} else {
+		if (hsotg->hw_params.hibernation)
+			val = DWC2_POWER_DOWN_PARAM_HIBERNATION;
+		else if (hsotg->hw_params.power_optimized)
+			val = DWC2_POWER_DOWN_PARAM_PARTIAL;
+		else
+			val = DWC2_POWER_DOWN_PARAM_NONE;
+	}
 
 	hsotg->params.power_down = val;
 }
@@ -290,6 +296,7 @@ static void dwc2_set_default_params(struct dwc2_hsotg *hsotg)
 	dwc2_set_param_phy_type(hsotg);
 	dwc2_set_param_speed(hsotg);
 	dwc2_set_param_phy_utmi_width(hsotg);
+	p->power_saving = true;
 	dwc2_set_param_power_down(hsotg);
 	p->phy_ulpi_ddr = false;
 	p->phy_ulpi_ext_vbus = false;
-- 
2.11.0





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux