Skip to content

Conversation

@AidenHu
Copy link
Contributor

@AidenHu AidenHu commented Nov 18, 2025

For usb xfer, set endpoint type and interval by the selected endpoint desc.

if (priv->mcux_eps[i] != NULL &&
priv->mcux_eps[i]->endpointAddress == USB_EP_GET_IDX(xfer->ep) &&
priv->mcux_eps[i]->direction == direction &&
priv->mcux_eps[i]->pipeType == xfer->type &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this line in the follow TODO codes. This part wants to find the initialized endpoint number on the udev, and different endpoints use different endpoint number on the same udev.

@AidenHu AidenHu force-pushed the use-correct-type-and-interval-for-usb-xfer branch from ca1495b to e49a9cf Compare November 18, 2025 12:46
if (mcux_ep != NULL && mcux_ep->pipeType == xfer->type &&
(mcux_ep->maxPacketSize != xfer->mps ||
mcux_ep->interval != xfer->interval)) {
mcux_ep->interval != (uint16_t)(1UL << (xfer->interval - 1U)))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what mcux_ep expects in its interval field, but from USB specification point of view bInterval is not always used as exponent. For full-/low-speed interrupt endpoints, bInterval is value from 1 to 255.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the mistake, I have done based on the spec.

@AidenHu AidenHu force-pushed the use-correct-type-and-interval-for-usb-xfer branch 2 times, most recently from 1492868 to 510bf5d Compare November 19, 2025 00:51
}

if (ep_idx == 0) {
mps = udev->dev_desc.bMaxPacketSize0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add:

interval = 0;
type = USB_EP_TYPE_CONTROL;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add:

interval = 0;
type = USB_EP_TYPE_CONTROL;

fixed.

Comment on lines 246 to 297
/* TODO: need to check endpoint type too */
if (mcux_ep != NULL &&
if (xfer->type == USB_EP_TYPE_INTERRUPT) {
if (xfer->udev->speed == USB_SPEED_SPEED_HS) {
actual_interval = (uint16_t)(1UL << (xfer->interval - 1U));
} else {
actual_interval = uhc_get_power_of_2_floor(xfer->interval);
}
} else if (xfer->type == USB_EP_TYPE_ISO) {
actual_interval = (uint16_t)(1UL << (xfer->interval - 1U));
} else {
actual_interval = xfer->interval;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to add one struct member in struct uhc_mcux_data as follow. mcux_ep->interval is different with the interval value of endpoint descriptor.

	usb_host_pipe_t *mcux_eps[USB_HOST_CONFIG_MAX_PIPES];
    uint16_t mcux_eps_interval[USB_HOST_CONFIG_MAX_PIPES];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to add one struct member in struct uhc_mcux_data as follow. mcux_ep->interval is different with the interval value of endpoint descriptor.

	usb_host_pipe_t *mcux_eps[USB_HOST_CONFIG_MAX_PIPES];
    uint16_t mcux_eps_interval[USB_HOST_CONFIG_MAX_PIPES];

applied.

For usb xfer, set endpoint type and interval by the
selected endpoint desc.

Signed-off-by: Aiden Hu <[email protected]>
@AidenHu AidenHu force-pushed the use-correct-type-and-interval-for-usb-xfer branch from 510bf5d to 787ff63 Compare November 19, 2025 11:35
Copy link
Contributor

@MarkWangChinese MarkWangChinese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second commit body description needs updating.

Comment on lines 238 to 240
priv->mcux_eps[i]->endpointAddress == USB_EP_GET_IDX(xfer->ep) &&
priv->mcux_eps[i]->direction == direction &&
priv->mcux_eps[i]->deviceHandle == xfer->udev) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

priv->mcux_eps_interval[i] != xfer->interval)) {
(mcux_ep->maxPacketSize != xfer->mps ||
priv->mcux_eps_interval[i] != xfer->interval)) {
/* re-initialize the ep */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@AidenHu AidenHu force-pushed the use-correct-type-and-interval-for-usb-xfer branch 2 times, most recently from 817a673 to e91426d Compare November 20, 2025 07:01
Comment on lines -292 to +291
/* TODO: need right way to implement it. */
if (pipe_init.endpointAddress == 0) {
pipe_init.pipeType = USB_ENDPOINT_CONTROL;
} else {
pipe_init.pipeType = USB_ENDPOINT_BULK;
}
pipe_init.pipeType = xfer->type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If wanting to also convert the other drivers, here is where it is on MAX3421E:

/*
* TODO: currently we only support control transfers and
* treat all others as bulk.
*/
if (USB_EP_GET_IDX(priv->last_xfer->ep) == 0) {
return max3421e_xfer_control(dev, priv->last_xfer, hrsl);
}
return max3421e_xfer_bulk(dev, priv->last_xfer, hrsl);

But I do not have that hardware to test.

mcux_eps_interval is added as the new member of
uhc_mcux_data. It is used to save endpoint's
original interval value and can be compared
with xfer->interval.

Signed-off-by: Aiden Hu <[email protected]>
maxPacketSize and numberPerUframe of pipe should
be set considering additional transactions.

Signed-off-by: Aiden Hu <[email protected]>
@AidenHu AidenHu force-pushed the use-correct-type-and-interval-for-usb-xfer branch from e91426d to 4a20cea Compare November 21, 2025 11:12
@AidenHu
Copy link
Contributor Author

AidenHu commented Nov 21, 2025

The second commit body description needs updating.

updated.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: USB Universal Serial Bus platform: NXP NXP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants