Skip to content

Commit eb7c0c9

Browse files
AidenHuJosuah Demangeon
authored andcommitted
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 fbe29a6 commit eb7c0c9

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

drivers/usb/uhc/uhc_common.c

Lines changed: 8 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

@@ -109,6 +111,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
109111
}
110112

111113
if (ep_idx == 0) {
114+
interval = 0;
115+
type = USB_EP_TYPE_CONTROL;
112116
mps = udev->dev_desc.bMaxPacketSize0;
113117
} else {
114118
struct usb_ep_descriptor *ep_desc;
@@ -125,6 +129,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
125129
}
126130

127131
mps = ep_desc->wMaxPacketSize;
132+
interval = ep_desc->bInterval;
133+
type = ep_desc->bmAttributes & USB_EP_TRANSFER_TYPE_MASK;
128134
}
129135

130136
LOG_DBG("Allocate xfer, ep 0x%02x mps %u cb %p", ep, mps, cb);
@@ -137,6 +143,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
137143
memset(xfer, 0, sizeof(struct uhc_transfer));
138144
xfer->ep = ep;
139145
xfer->mps = mps;
146+
xfer->interval = interval;
147+
xfer->type = type;
140148
xfer->udev = udev;
141149
xfer->cb = cb;
142150
xfer->priv = cb_priv;

drivers/usb/uhc/uhc_mcux_common.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ static usb_host_pipe_handle uhc_mcux_check_hal_ep(const struct device *dev,
243243
}
244244
}
245245

246-
/* TODO: need to check endpoint type too */
247-
if (mcux_ep != NULL &&
246+
if (mcux_ep != NULL && mcux_ep->pipeType == xfer->type &&
248247
(mcux_ep->maxPacketSize != xfer->mps ||
249248
mcux_ep->interval != xfer->interval)) {
250249
/* re-initialize the ep */
@@ -289,12 +288,7 @@ usb_host_pipe_t *uhc_mcux_init_hal_ep(const struct device *dev, struct uhc_trans
289288
*/
290289
pipe_init.numberPerUframe = 0; /* TODO: need right way to implement it. */
291290
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-
}
291+
pipe_init.pipeType = xfer->type;
298292

299293
status = priv->mcux_if->controllerOpenPipe(priv->mcux_host.controllerHandle,
300294
(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)