Skip to content

Commit 64b48c6

Browse files
committed
drivers: uhc: use correct endpoint type and interval
For usb xfer, set endpoint type and interval by the selected endpoint desc. Signed-off-by: Aiden Hu <[email protected]>
1 parent 61a8648 commit 64b48c6

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

drivers/usb/uhc/uhc_common.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
101101
const struct uhc_api *api = dev->api;
102102
struct uhc_transfer *xfer = NULL;
103103
uint16_t mps;
104+
uint16_t interval;
105+
uint8_t type;
104106

105107
api->lock(dev);
106108

@@ -125,6 +127,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
125127
}
126128

127129
mps = ep_desc->wMaxPacketSize;
130+
interval = ep_desc->bInterval;
131+
type = ep_desc->bmAttributes & USB_EP_TRANSFER_TYPE_MASK;
128132
}
129133

130134
LOG_DBG("Allocate xfer, ep 0x%02x mps %u cb %p", ep, mps, cb);
@@ -137,6 +141,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
137141
memset(xfer, 0, sizeof(struct uhc_transfer));
138142
xfer->ep = ep;
139143
xfer->mps = mps;
144+
xfer->interval = interval;
145+
xfer->type = type;
140146
xfer->udev = udev;
141147
xfer->cb = cb;
142148
xfer->priv = cb_priv;

drivers/usb/uhc/uhc_mcux_common.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ static usb_host_pipe_handle uhc_mcux_check_hal_ep(const struct device *dev,
237237
if (priv->mcux_eps[i] != NULL &&
238238
priv->mcux_eps[i]->endpointAddress == USB_EP_GET_IDX(xfer->ep) &&
239239
priv->mcux_eps[i]->direction == direction &&
240+
priv->mcux_eps[i]->pipeType == xfer->type &&
240241
priv->mcux_eps[i]->deviceHandle == xfer->udev) {
241242
mcux_ep = priv->mcux_eps[i];
242243
break;
@@ -289,12 +290,7 @@ usb_host_pipe_t *uhc_mcux_init_hal_ep(const struct device *dev, struct uhc_trans
289290
*/
290291
pipe_init.numberPerUframe = 0; /* TODO: need right way to implement it. */
291292
pipe_init.interval = xfer->interval;
292-
/* TODO: need right way to implement it. */
293-
if (pipe_init.endpointAddress == 0) {
294-
pipe_init.pipeType = USB_ENDPOINT_CONTROL;
295-
} else {
296-
pipe_init.pipeType = USB_ENDPOINT_BULK;
297-
}
293+
pipe_init.pipeType = xfer->type;
298294

299295
status = priv->mcux_if->controllerOpenPipe(priv->mcux_host.controllerHandle,
300296
(usb_host_pipe_handle *)&mcux_ep, &pipe_init);

include/zephyr/drivers/usb/uhc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ struct uhc_transfer {
120120
struct net_buf *buf;
121121
/** Endpoint to which request is associated */
122122
uint8_t ep;
123+
/** Endpoint type */
124+
uint8_t type;
123125
/** Maximum packet size */
124126
uint16_t mps;
125127
/** Interval, used for periodic transfers only */

0 commit comments

Comments
 (0)