mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com>
To: John Youn <John.Youn@synopsys.com>,
	Felipe Balbi <balbi@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com>
Subject: [PATCH 2/9] usb: dwc2: Add core parameters for LPM support
Date: Fri, 28 Apr 2017 12:48:00 +0400	[thread overview]
Message-ID: <c61cd7fb0e7705c5756f2267dec77c467fcdc8a6.1493369198.git.sevaka@synopsys.com> (raw)
In-Reply-To: <cover.1493369198.git.sevaka@synopsys.com>

Add lpm, lpm_clock_gating, besl, hird_threshold_en and hird_threshold
core parameters. These will indicate LPM and LPM Errata support
as well as chosen L1 sleeping mode for the core and PHY.

Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com>
---
 drivers/usb/dwc2/core.h    | 20 ++++++++++++++++++++
 drivers/usb/dwc2/debugfs.c |  5 +++++
 drivers/usb/dwc2/params.c  | 13 +++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 8367d4f985c1..13e0cb643678 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -423,6 +423,19 @@ enum dwc2_ep0_state {
  *			needed.
  *			0 - No (default)
  *			1 - Yes
+ * @lpm:		Enable LPM support.
+ *			0 - No (default)
+ *			1 - Yes
+ * @lpm_clock_gating:		Enable core PHY clock gating.
+ *			0 - No (default)
+ *			1 - Yes
+ * @besl:		Enable LPM Errata support.
+ *			0 - No (default)
+ *			1 - Yes
+ * @hird_threshold_en:	HIRD or HIRD Threshold enable.
+ *			0 - No (default)
+ *			1 - Yes
+ * @hird_threshold:	Value of BESL or HIRD Threshold.
  * @activate_stm_fs_transceiver: Activate internal transceiver using GGPIO
  *			register.
  *			0 - Deactivate the transceiver (default)
@@ -481,6 +494,11 @@ struct dwc2_core_params {
 	bool uframe_sched;
 	bool external_id_pin_ctl;
 	bool hibernation;
+	bool lpm;
+	bool lpm_clock_gating;
+	bool besl;
+	bool hird_threshold_en;
+	u8 hird_threshold;
 	bool activate_stm_fs_transceiver;
 	u16 max_packet_count;
 	u32 max_transfer_size;
@@ -585,6 +603,7 @@ struct dwc2_hw_params {
 	unsigned total_fifo_size:16;
 	unsigned power_optimized:1;
 	unsigned utmi_phy_data_width:2;
+	unsigned lpm_mode:1;
 	u32 snpsid;
 	u32 dev_ep_dirs;
 };
@@ -937,6 +956,7 @@ struct dwc2_hsotg {
 
 	/* DWC OTG HW Release versions */
 #define DWC2_CORE_REV_2_71a	0x4f54271a
+#define DWC2_CORE_REV_2_80a	0x4f54280a
 #define DWC2_CORE_REV_2_90a	0x4f54290a
 #define DWC2_CORE_REV_2_91a	0x4f54291a
 #define DWC2_CORE_REV_2_92a	0x4f54292a
diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
index 794b959a7c8c..725bd256cd50 100644
--- a/drivers/usb/dwc2/debugfs.c
+++ b/drivers/usb/dwc2/debugfs.c
@@ -763,6 +763,11 @@ static int params_show(struct seq_file *seq, void *v)
 	print_param(seq, p, uframe_sched);
 	print_param(seq, p, external_id_pin_ctl);
 	print_param(seq, p, hibernation);
+	print_param(seq, p, lpm);
+	print_param(seq, p, lpm_clock_gating);
+	print_param(seq, p, besl);
+	print_param(seq, p, hird_threshold_en);
+	print_param(seq, p, hird_threshold);
 	print_param(seq, p, host_dma);
 	print_param(seq, p, g_dma);
 	print_param(seq, p, g_dma_desc);
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 9cd8722f24f6..b9310cd121a3 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -264,6 +264,11 @@ static void dwc2_set_default_params(struct dwc2_hsotg *hsotg)
 	p->uframe_sched = true;
 	p->external_id_pin_ctl = false;
 	p->hibernation = false;
+	p->lpm = false;
+	p->lpm_clock_gating = false;
+	p->besl = false;
+	p->hird_threshold_en = false;
+	p->hird_threshold = 0;
 	p->max_packet_count = hw->max_packet_count;
 	p->max_transfer_size = hw->max_transfer_size;
 	p->ahbcfg = GAHBCFG_HBSTLEN_INCR4 << GAHBCFG_HBSTLEN_SHIFT;
@@ -511,6 +516,13 @@ static void dwc2_check_params(struct dwc2_hsotg *hsotg)
 	CHECK_BOOL(en_multiple_tx_fifo, hw->en_multiple_tx_fifo);
 	CHECK_BOOL(i2c_enable, hw->i2c_enable);
 	CHECK_BOOL(reload_ctl, (hsotg->hw_params.snpsid > DWC2_CORE_REV_2_92a));
+	CHECK_BOOL(lpm, (hsotg->hw_params.snpsid >= DWC2_CORE_REV_2_80a));
+	CHECK_BOOL(lpm, hw->lpm_mode);
+	CHECK_BOOL(lpm_clock_gating, hsotg->params.lpm);
+	CHECK_BOOL(besl, hsotg->params.lpm);
+	CHECK_BOOL(besl, (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a));
+	CHECK_BOOL(hird_threshold_en, hsotg->params.lpm);
+	CHECK_RANGE(hird_threshold, 0, hsotg->params.besl ? 12 : 7, 0);
 	CHECK_RANGE(max_packet_count,
 		    15, hw->max_packet_count,
 		    hw->max_packet_count);
@@ -689,6 +701,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
 	hw->i2c_enable = !!(hwcfg3 & GHWCFG3_I2C);
 	hw->total_fifo_size = (hwcfg3 & GHWCFG3_DFIFO_DEPTH_MASK) >>
 			      GHWCFG3_DFIFO_DEPTH_SHIFT;
+	hw->lpm_mode = !!(hwcfg3 & GHWCFG3_OTG_LPM_EN);
 
 	/* hwcfg4 */
 	hw->en_multiple_tx_fifo = !!(hwcfg4 & GHWCFG4_DED_FIFO_EN);
-- 
2.11.0

  parent reply	other threads:[~2017-04-28  8:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28  8:46 [PATCH 0/9] usb: dwc2: gadget: Add LPM functionality Sevak Arakelyan
2017-04-28  8:47 ` [PATCH 1/9] usb: dwc2: Fix GLPMCFG... definitions Sevak Arakelyan
2017-04-28  8:48 ` Sevak Arakelyan [this message]
2017-04-28  8:48 ` [PATCH 3/9] usb: dwc2: gadget: Add functionality to exit from LPM L1 state Sevak Arakelyan
2017-04-28  8:48 ` [PATCH 4/9] usb: dwc2: gadget: LPM interrupt handler Sevak Arakelyan
2017-04-28  8:55 ` [PATCH 5/9] usb: dwc2: Enable LPM Transaction Received interrupt Sevak Arakelyan
2017-04-28  8:55 ` [PATCH 6/9] usb: dwc2: gadget: Configure the core to enable LPM Sevak Arakelyan
2017-04-28  8:55 ` [PATCH 7/9] [HSLPM] usb: gadget: composite: Exclude SS Dev Cap Desc Sevak Arakelyan
2017-04-28  8:55 ` [PATCH 8/9] [HSLPM] usb: gadget: Allow a non-SuperSpeed gadget to support LPM Sevak Arakelyan
2017-04-28  8:56 ` [PATCH 9/9] [HSLPM] usb: dwc2: Enable LPM Sevak Arakelyan
2017-04-28  9:24   ` Greg Kroah-Hartman
2017-06-02  8:20     ` Felipe Balbi

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=c61cd7fb0e7705c5756f2267dec77c467fcdc8a6.1493369198.git.sevaka@synopsys.com \
    --to=sevak.arakelyan@synopsys.com \
    --cc=John.Youn@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®