Skip to content

Commit 40252dd

Browse files
author
Peter Chen
committed
usb: cdns3: gadget: calculate TD_SIZE based on TD
The TRB entry TD_SIZE is the packet number for the TD (request) but not the each TRB, so it only needs to be assigned for the first TRB during the TD, and the value of it is for TD too. Fixes: 7733f6c ("usb: cdns3: Add Cadence USB3 DRD Driver") Signed-off-by: Peter Chen <peter.chen@nxp.com>
1 parent 78e9158 commit 40252dd

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

drivers/usb/cdns3/gadget.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,10 +1193,20 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
11931193

11941194
/* set incorrect Cycle Bit for first trb*/
11951195
control = priv_ep->pcs ? 0 : TRB_CYCLE;
1196+
trb->length = 0;
1197+
if (priv_dev->dev_ver >= DEV_VER_V2) {
1198+
u16 td_size;
1199+
1200+
td_size = DIV_ROUND_UP(request->length,
1201+
priv_ep->endpoint.maxpacket);
1202+
if (priv_dev->gadget.speed == USB_SPEED_SUPER)
1203+
trb->length = TRB_TDL_SS_SIZE(td_size);
1204+
else
1205+
control |= TRB_TDL_HS_SIZE(td_size);
1206+
}
11961207

11971208
do {
11981209
u32 length;
1199-
u16 td_size = 0;
12001210

12011211
/* fill TRB */
12021212
control |= TRB_TYPE(TRB_NORMAL);
@@ -1208,20 +1218,12 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
12081218
length = request->length;
12091219
}
12101220

1211-
if (likely(priv_dev->dev_ver >= DEV_VER_V2))
1212-
td_size = DIV_ROUND_UP(length,
1213-
priv_ep->endpoint.maxpacket);
1214-
else if (priv_ep->flags & EP_TDLCHK_EN)
1221+
if (priv_ep->flags & EP_TDLCHK_EN)
12151222
total_tdl += DIV_ROUND_UP(length,
12161223
priv_ep->endpoint.maxpacket);
12171224

1218-
trb->length = cpu_to_le32(TRB_BURST_LEN(priv_ep->trb_burst_size) |
1225+
trb->length |= cpu_to_le32(TRB_BURST_LEN(priv_ep->trb_burst_size) |
12191226
TRB_LEN(length));
1220-
if (priv_dev->gadget.speed == USB_SPEED_SUPER)
1221-
trb->length |= cpu_to_le32(TRB_TDL_SS_SIZE(td_size));
1222-
else
1223-
control |= TRB_TDL_HS_SIZE(td_size);
1224-
12251227
pcs = priv_ep->pcs ? TRB_CYCLE : 0;
12261228

12271229
/*

0 commit comments

Comments
 (0)