[PATCH 6/8] xHCI: calculate HIRD

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

 



Calculate HIRD(Host Initiated Resume Duration) in USB2 PORTPMSC based on
the host's U2 Device Exit Latency field.

Signed-off-by: Andiry Xu <andiry.xu@xxxxxxx>
---
 drivers/usb/host/xhci-mem.c |   17 +++++++++++++++++
 drivers/usb/host/xhci.h     |    2 ++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 2b4cff9..83ba59b 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1927,6 +1927,21 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
 	return 0;
 }
 
+/* Calculate HIRD for USB2 PORTPMSC*/
+static void xhci_calculate_hird(struct xhci_hcd *xhci)
+{
+	int u2del;
+
+	u2del = HCS_U2_LATENCY(xhci->hcs_params3);
+	if (u2del <= 50)
+		xhci->hird = 0;
+	else
+		xhci->hird = (u2del - 51) / 75 + 1;
+
+	if (xhci->hird > 15)
+		xhci->hird = 15;
+}
+
 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 {
 	dma_addr_t	dma;
@@ -2113,6 +2128,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 	if (xhci_setup_port_arrays(xhci, flags))
 		goto fail;
 
+	xhci_calculate_hird(xhci);
+
 	return 0;
 
 fail:
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index e4f7635..983d8e8 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1327,6 +1327,8 @@ struct xhci_hcd {
 	/* Array of pointers to USB 2.0 PORTSC registers */
 	__le32 __iomem		**usb2_ports;
 	unsigned int		num_usb2_ports;
+	/* USB2 PORTPMSC HIRD */
+	int			hird;
 	/* support xHCI 0.96 spec USB2 software LPM */
 	unsigned		sw_lpm_support:1;
 	/* support xHCI 1.0 spec USB2 hardware LPM */
-- 
1.7.1


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

  Powered by Linux