Skip to content
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

iMX.RT EHCI add dcache support and other fixes + refactor #2061

Merged
merged 16 commits into from
May 19, 2023
Merged

Conversation

hathach
Copy link
Owner

@hathach hathach commented May 12, 2023

Describe the PR

  • EHCI: fix xfer failed with disconnected device as stalled
  • change CFG_TUH_ENDPOINT_MAX to 16 (max endpoint pair per device) if
    not defined
  • change QHD_MAX for EHCI, should be user configurable and more
    optimized in the future
  • fix un-roll recursive call when unplug an hub device #1511 un-roll recursive hub removal with usbh queue. (not perfect but good enough)
  • fix error on EHCI causes xfer error in non-queued qhd which cause memory fault
  • Add support for dcache clean/invalidate when memory is in cachable memory. Rule of thumb is:
    • clean buffer before queuing OUT transfer
    • invalidate buffer before and after queuing IN transfer
    • clean and invalidate queue head and TD before transfer and invalidate after transfer
  • fix issue with removing queue head (similar to one in OCHI)
  • Lots of EHCI refactor: simplify driver to only support 1 TD per QHD (since that is what usbh will schedule).

** other minor usbd tweak **

  • usbd: fix control transfer issue for chipidea hs when previous status and new setup complete in the same isr frame
  • change usbd edpt busy/stalled/claimed value to 0/1 instead of
    (true/false) since they are 1-bit field.

@@ -50,6 +50,10 @@
SCB_InvalidateDCache_by_Addr(addr, (int32_t) data_size);
}

void hcd_dcache_clean_invalidate(void* addr, uint32_t data_size) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about make the cache related function optional (default ON) ?

For IMX.RT in order to have best performance, RAM will be configured to ITCM & DTCM, so they are accessed at CPU clock instead of bus clock (600MHz vs 133MHz)

Since TCM bypass the cache there is no need to flush or invalidate.

image

Copy link
Owner Author

Choose a reason for hiding this comment

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

ah you are right, I think we can check the address to see if it is within the DTCM (non-cachable) and skip the clean/invalidate will update in the next push or so. Circuitpython is currently placing ehci_data and/or user memory randomly and may not be in DTCM.

Copy link
Owner Author

Choose a reason for hiding this comment

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

DTCM is 1MB reserved in 2000000-2010000,this should be good enough.

image

@hathach hathach changed the title improve Imx usb host + device iMX.RT EHCI add dcache support and other fixes + refactor May 19, 2023
@hathach hathach merged commit 6ecd480 into master May 19, 2023
@hathach hathach deleted the imx-usbhost branch May 19, 2023 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

un-roll recursive call when unplug an hub device
2 participants