-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: uhc: use correct endpoint type and interval #99578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
drivers: uhc: use correct endpoint type and interval #99578
Conversation
drivers/usb/uhc/uhc_mcux_common.c
Outdated
| 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 && |
There was a problem hiding this comment.
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.
ca1495b to
e49a9cf
Compare
drivers/usb/uhc/uhc_mcux_common.c
Outdated
| 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)))) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
1492868 to
510bf5d
Compare
| } | ||
|
|
||
| if (ep_idx == 0) { | ||
| mps = udev->dev_desc.bMaxPacketSize0; |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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.
drivers/usb/uhc/uhc_mcux_common.c
Outdated
| /* 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; | ||
| } |
There was a problem hiding this comment.
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];
There was a problem hiding this comment.
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_dataas follow.mcux_ep->intervalis 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]>
510bf5d to
787ff63
Compare
MarkWangChinese
left a comment
There was a problem hiding this 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.
drivers/usb/uhc/uhc_mcux_common.c
Outdated
| priv->mcux_eps[i]->endpointAddress == USB_EP_GET_IDX(xfer->ep) && | ||
| priv->mcux_eps[i]->direction == direction && | ||
| priv->mcux_eps[i]->deviceHandle == xfer->udev) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect indentation
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
817a673 to
e91426d
Compare
| /* 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; |
There was a problem hiding this comment.
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:
zephyr/drivers/usb/uhc/uhc_max3421e.c
Lines 401 to 409 in 2baee8a
| /* | |
| * 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]>
e91426d to
4a20cea
Compare
updated. |
|



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