diff mbox series

[U-Boot,14/14] usb: xhci: Set 'Average TRB Length' to 8 for control endpoints

Message ID 1505742050-5697-15-git-send-email-bmeng.cn@gmail.com
State Accepted
Delegated to: Marek Vasut
Headers show
Series usb: xhci: Add interrupt transfer support and full speed device support | expand

Commit Message

Bin Meng Sept. 18, 2017, 1:40 p.m. UTC
Update the codes to conform with xHCI spec chapter 6.2.3.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

 drivers/usb/host/xhci-mem.c | 6 ++++++
 drivers/usb/host/xhci.c     | 6 ++++++
 2 files changed, 12 insertions(+)

Comments

Stefan Roese Sept. 22, 2017, 5:13 a.m. UTC | #1
On 18.09.2017 15:40, Bin Meng wrote:
> Update the codes to conform with xHCI spec chapter 6.2.3.
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> 
> ---
> 
>   drivers/usb/host/xhci-mem.c | 6 ++++++
>   drivers/usb/host/xhci.c     | 6 ++++++
>   2 files changed, 12 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 84982a9..0582a9b 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -850,6 +850,12 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
>   	trb_64 = (uintptr_t)virt_dev->eps[0].ring->first_seg->trbs;
>   	ep0_ctx->deq = cpu_to_le64(trb_64 | virt_dev->eps[0].ring->cycle_state);
>   
> +	/*
> +	 * xHCI spec 6.2.3:
> +	 * software shall set 'Average TRB Length' to 8 for control endpoints.
> +	 */
> +	ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(8));
> +
>   	/* Steps 7 and 8 were done in xhci_alloc_virt_device() */
>   
>   	xhci_flush_cache((uintptr_t)ep0_ctx, sizeof(struct xhci_ep_ctx));
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 93737b0..4673738 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -601,6 +601,12 @@ static int xhci_set_configuration(struct usb_device *udev)
>   		ep_ctx[ep_index]->deq = cpu_to_le64(trb_64 |
>   				virt_dev->eps[ep_index].ring->cycle_state);
>   
> +		/*
> +		 * xHCI spec 6.2.3:
> +		 * 'Average TRB Length' should be 8 for control endpoints.
> +		 */
> +		if (usb_endpoint_xfer_control(endpt_desc))
> +			avg_trb_len = 8;
>   		ep_ctx[ep_index]->tx_info =
>   			cpu_to_le32(EP_MAX_ESIT_PAYLOAD_LO(max_esit_payload) |
>   			EP_AVG_TRB_LENGTH(avg_trb_len));
> 

Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 84982a9..0582a9b 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -850,6 +850,12 @@  void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
 	trb_64 = (uintptr_t)virt_dev->eps[0].ring->first_seg->trbs;
 	ep0_ctx->deq = cpu_to_le64(trb_64 | virt_dev->eps[0].ring->cycle_state);
 
+	/*
+	 * xHCI spec 6.2.3:
+	 * software shall set 'Average TRB Length' to 8 for control endpoints.
+	 */
+	ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(8));
+
 	/* Steps 7 and 8 were done in xhci_alloc_virt_device() */
 
 	xhci_flush_cache((uintptr_t)ep0_ctx, sizeof(struct xhci_ep_ctx));
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 93737b0..4673738 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -601,6 +601,12 @@  static int xhci_set_configuration(struct usb_device *udev)
 		ep_ctx[ep_index]->deq = cpu_to_le64(trb_64 |
 				virt_dev->eps[ep_index].ring->cycle_state);
 
+		/*
+		 * xHCI spec 6.2.3:
+		 * 'Average TRB Length' should be 8 for control endpoints.
+		 */
+		if (usb_endpoint_xfer_control(endpt_desc))
+			avg_trb_len = 8;
 		ep_ctx[ep_index]->tx_info =
 			cpu_to_le32(EP_MAX_ESIT_PAYLOAD_LO(max_esit_payload) |
 			EP_AVG_TRB_LENGTH(avg_trb_len));