Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc7fbfa6 authored by Huang Rui's avatar Huang Rui Committed by Jack Pham
Browse files

usb: dwc3: make HIRD threshold configurable



HIRD threshold should be configurable by different platforms.

From DesignWare databook:
When HIRD_Threshold[4] is set to 1b1 and HIRD value is greater than or
equal to the value in HIRD_Threshold[3:0], dwc3 asserts output signals
utmi_l1_suspend_n to put PHY into Deep Low-Power mode in L1.

When HIRD_Threshold[4] is set to 1b0 or the HIRD value is less than
HIRD_Threshold[3:0], dwc3 asserts output signals utmi_sleep_n on L1.

Signed-off-by: default avatarHuang Rui <ray.huang@amd.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Change-Id: I58c9d09085c4643a0448441873b31f5f51482129
Git-commit: 460d098cb6728134e0e4ba3d58e10bb43032daa5
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


[jackp@codeaurora.org: fixed up trivial merge conflicts]
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 9bb95a8d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ Optional properties:
 - snps,disable-clk-gating: If present, disable controller's internal clock gating. Default it is enabled.
 - snps,has-lpm-erratum: true when DWC3 was configured with LPM Erratum enabled
 - snps,lpm-nyet-threshold: LPM NYET threshold
 - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
			utmi_l1_suspend_n, false when asserts utmi_sleep_n
 - snps,hird-threshold: HIRD threshold

This is usually a subnode to DWC3 glue to which it is connected.

+17 −0
Original line number Diff line number Diff line
@@ -786,6 +786,7 @@ static int dwc3_probe(struct platform_device *pdev)
	struct resource		*res;
	struct dwc3		*dwc;
	u8			lpm_nyet_threshold;
	u8			hird_threshold;

	int			ret;

@@ -848,12 +849,22 @@ static int dwc3_probe(struct platform_device *pdev)
	/* default to highest possible threshold */
	lpm_nyet_threshold = 0xff;

	/*
	 * default to assert utmi_sleep_n and use maximum allowed HIRD
	 * threshold value of 0b1100
	 */
	hird_threshold = 12;

	if (node) {
		dwc->maximum_speed = of_usb_get_maximum_speed(node);
		dwc->has_lpm_erratum = of_property_read_bool(node,
				"snps,has-lpm-erratum");
		of_property_read_u8(node, "snps,lpm-nyet-threshold",
				&lpm_nyet_threshold);
		dwc->is_utmi_l1_suspend = of_property_read_bool(node,
				"snps,is-utmi-l1-suspend");
		of_property_read_u8(node, "snps,hird-threshold",
				&hird_threshold);

		dwc->needs_fifo_resize = of_property_read_bool(node,
				"tx-fifo-resize");
@@ -886,6 +897,9 @@ static int dwc3_probe(struct platform_device *pdev)
		dwc->has_lpm_erratum = pdata->has_lpm_erratum;
		if (pdata->lpm_nyet_threshold)
			lpm_nyet_threshold = pdata->lpm_nyet_threshold;
		dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend;
		if (pdata->hird_threshold)
			hird_threshold = pdata->hird_threshold;

		dwc->needs_fifo_resize = pdata->tx_fifo_resize;
		dwc->dr_mode = pdata->dr_mode;
@@ -897,6 +911,9 @@ static int dwc3_probe(struct platform_device *pdev)

	dwc->lpm_nyet_threshold = lpm_nyet_threshold;

	dwc->hird_threshold = hird_threshold
		| (dwc->is_utmi_l1_suspend << 4);

	ret = dwc3_core_get_phy(dwc);
	if (ret)
		return ret;
+6 −0
Original line number Diff line number Diff line
@@ -785,12 +785,16 @@ struct dwc3_scratchpad_array {
 * @test_mode: true when we're entering a USB test mode
 * @test_mode_nr: test feature selector
 * @lpm_nyet_threshold: LPM NYET response threshold
 * @hird_threshold: HIRD threshold
 * @delayed_status: true when gadget driver asks for delayed status
 * @ep0_bounced: true when we used bounce buffer
 * @ep0_expect_in: true when we expect a DATA IN transfer
 * @has_hibernation: true when dwc3 was configured with Hibernation
 * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that
 *			there's now way for software to detect this in runtime.
 * @is_utmi_l1_suspend: the core asserts output signal
 *	0	- utmi_sleep_n
 *	1	- utmi_l1_suspend_n
 * @is_selfpowered: true when we are selfpowered
 * @needs_fifo_resize: not all users might want fifo resizing, flag it
 * @pullups_connected: true when Run/Stop bit is set
@@ -906,6 +910,7 @@ struct dwc3 {
	u8			test_mode;
	u8			test_mode_nr;
	u8			lpm_nyet_threshold;
	u8			hird_threshold;

	void (*notify_event)	(struct dwc3 *, unsigned);
	struct work_struct	wakeup_work;
@@ -915,6 +920,7 @@ struct dwc3 {
	unsigned		ep0_expect_in:1;
	unsigned		has_hibernation:1;
	unsigned		has_lpm_erratum:1;
	unsigned		is_utmi_l1_suspend:1;
	unsigned		is_selfpowered:1;
	unsigned		needs_fifo_resize:1;
	unsigned		pullups_connected:1;
+2 −0
Original line number Diff line number Diff line
@@ -2980,6 +2980,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
			reg |= DWC3_DCTL_LPM_NYET_THRES(dwc->lpm_nyet_thresh);
		}

		reg |= DWC3_DCTL_HIRD_THRES(dwc->hird_threshold);

		/*
		 * When dwc3 revisions >= 2.40a, LPM Erratum is enabled and
		 * DCFG.LPMCap is set, core responses with an ACK and the
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ struct dwc3_platform_data {
	enum usb_dr_mode dr_mode;
	bool tx_fifo_resize;

	unsigned is_utmi_l1_suspend:1;
	u8 hird_threshold;

	u8 lpm_nyet_threshold;

	unsigned has_lpm_erratum:1;