Commit Graph

136 Commits

Author SHA1 Message Date
Tomas Rezucha
67c10eafaa Merge branch 'feature/usb_host_multi_configuration' into 'master'
USB Host multiconfiguration support pt1 (getting the configuration descriptor)

Closes IDFGH-11532 and IDF-8732

See merge request espressif/esp-idf!26760
2024-06-20 20:29:12 +08:00
Peter Marcisovsky
6cabb68d12 feat(usb/host): multiconfiguration support
- usb host reads device's configuration on request
    - a control transfer is sent
    - memory is allocated for a new descriptor
    - user must manually free the memory
2024-06-19 09:40:57 +02:00
Alexey Lapshin
ed6e497c6f feat(build): add COMPILER_STATIC_ANALYZER option 2024-06-18 14:25:37 +08:00
Alexey Lapshin
e1b9985bd0 fix(usb): fix warnings found by GNU static analyzer 2024-06-18 14:25:37 +08:00
Roman Leonov
f5c1039de3 fix(enum): Returned usb_round_up_to_mps for control request of string descriptors 2024-06-13 09:23:34 +02:00
Roman Leonov
b688ee2cba feat(hub): Added device tree nodes list and uid calculation 2024-06-11 09:20:42 +02:00
Roman Leonov
d214c482f6 fix(enum): Added STALL handling on descriptor fetching 2024-06-10 19:45:15 +02:00
Roman Leonov
db1f13d259 fix(enum): Removed unused value 2024-06-10 19:45:15 +02:00
Roman Leonov
39f91a3d5a refactor(enum): Curved out Enumeration process from Hub Driver 2024-06-03 10:27:37 +02:00
Darian Leung
4954884527
fix(usb): Make string descriptor checks in unit tests optional
Checking for an exact match for product or serial and string descriptors can
lead to test failures if the USB devices connected to the runner is changed. This
commit adds some kconfig options to make the string descriptor checks optional,
with the product and serial string checks being disabled by default.
2024-05-30 19:25:18 +08:00
Darian Leung
6a3bb3294d
refactor(usb): Split test device descriptors from mock class files
Previously, descriptors of the test devices were stored direclty in the mock
device files (e.g., "mock_[hid|msc].[h|c]"). This commit splits out the device
descriptors to separate files (e.g., "dev_[hid|msc].c") along with getter
functions.

Users that want to run the tests locally on a different device simply need to
update the "dev_[hid|msc].c" file for their device.
2024-05-24 17:43:40 +08:00
Darian Leung
94e3b83bc0
refactor(usb): Rename mock class files
- Rename "test_usb_mock_..." class files to "mock_..."
- Fixed some codespell issues
- Fixed comment spacing
2024-05-23 17:47:24 +08:00
Roman Leonov
325bbfb8d5 refactor(hub): Updated HUB api (enum driver) 2024-05-07 15:09:06 +02:00
Roman Leonov
596672fdcd refactor(usbh): Updated USBH api (enum driver) 2024-05-07 15:07:51 +02:00
Darian Leung
99ec1c98f5
refactor(usb/usbh): Update USBH device creation and enumeration handling
This commit updates how the USBH handles device creation and enumeration so that
upper layers (such as the Hub driver) can use the USBH API for enumeration instead
of calling the HCD.

USBH Updates:

USBH now creates unenumerated devices set to address 0 with no device/config
descriptor. A newly created device can be opened and communicated with immediately
(using control transfers). This allows the Hub driver to call the USBH instead of
the HCD. Summary of USBH changes:

- Added new APIs to add/remove a device. Devices are now created as unenumerated
and can be immediately opened and communicated with.
- Added new APIs to enumerate a device (see 'usbh_dev_set_...()' functions). Device
must be locked (see 'usbh_dev_enum_lock()') before enumeration functions can be called.
- Added UID for each device. This allows the particular USBH without needing to
use the device's handle (which implies opening the device).

Hub Driver Updates:

Hub driver now calls the USBH for enumeration. Summary of USBH changes:

- Replace all 'hcd_pipe_...()' calls with 'usbh_dev_...()' calls
- Refactored port event handling to fit with new USBH API
- Updated to use UID to uniquely identify devices without opening them

USB Host Updates:

- Reroute USBH control transfers to clients and hub driver
2024-04-23 17:18:56 +08:00
Darian Leung
550aaaa8b4
refactor(usb/hub): Update Hub driver port request logic 2024-04-23 16:50:54 +08:00
Darian Leung
c10fe6ca48
refactor(usb/hcd): Allow port resets with allocated pipes
This commit updates the HCD API to allow port resets to occur even if pipes
are allocated. The pipes cannot be active and the port reset will simply
restore the pipes (by reinitializing their channel registers) following the
reset.

Changes:

- Allow port resets while channels are allocated
- Remove pipe persistance API 'hcd_pipe_set_persist_reset()'
2024-04-23 16:50:53 +08:00
Darian Leung
b05cf70b77
refactor(usb/usbh): Rename device pool functions and ref_count
This commit renames the following APIs and variables in the USBH:

- Rename the prefix of device pool functions from 'usbh_dev_...' to
  'usbh_devs_...'.
- Rename 'ref_count' to 'open_count'. This variable tracks the number of times
  a device has been opened.
2024-04-23 16:50:53 +08:00
Darian Leung
4569ac7550
refactor(usb/host): Refactor USBH function grouping
This commit rearranges the USBH functions into new groupings to provide a
clearer abstraction. This is in preparation for refactoring/removing the Hub
related functions in the USBH API. This commit DOES NOT MAKE ANY BEHAVIORAL
CHANGES to the code.

Functions are now grouped into...

- USBH Processing: Functions dealing with overall USBH processing
- Device Pool: Functions that add/remove/open/close devices from the internal
               device pool
- Device: Functions that pertain to setting/getting a particular device
- Endpoints: Functions that pertain to a particular endpoint
- Transfer: Functions that pertain to sending transfers
2024-04-23 16:50:52 +08:00
Armando
d341540a5e change(drivers): other driver changes for cache malloc 2024-04-15 15:34:51 +08:00
Darian Leung
778c2e6863
refactor(hal/usb): Add new USB PHY related HAL API
This commit adds/updates the USB PHY related HAL APIs. The following changes
are made:

- Updated 'usb_wrap_hal.h' API
- Added 'usb_serial_jtag_hal.h' API
2024-04-04 02:47:00 +08:00
Darian Leung
023eae4f0b
feat(hal/usb): Update USB WRAP and USJ LL, add missing ESP32-P4 LL
This commit updates updates the LLs of USB WRAP and USJ as follows:

- Added missing 'usb_wrap_ll.h' and 'usb_serial_jtag_ll.h' for the ESP32-P4
- Added LL cap macros to distinguish feature differences between the LLs of
  different targets:
    - '..._LL_EXT_PHY_SUPPORTED' indicates whether the USB WRAP/USJ supports
      routing to an external FSLS PHY.
    - '..._LL_SWAP_PHY_SUPPORTED' indicates whether the USB WRAP/USJ supports
      swapping between multiple internal FSLS PHYs.
- Tidied up some RCC LL functions and their callers.
- Added 'usb_wrap_types.h' and 'usb_serial_jtag_types.h' to provide types used
  in LLs.
- Fixed some spelling/naming issues as part of code-spell pre-commit
2024-04-04 02:47:00 +08:00
Gao Xu
db3e43908a Merge branch 'feat/add_esp_dma_capable_malloc' into 'master'
dma_utils: add esp dma capable malloc function

Closes IDF-9638

See merge request espressif/esp-idf!29869
2024-04-02 21:31:45 +08:00
Roman Leonov
dbad0df765 refactor(hcd_dwc): Added mps request from hcd_dwc 2024-04-02 10:23:52 +02:00
gaoxu
40f38bea6f feat(dma): refactor dma calloc function 2024-04-02 14:30:14 +08:00
Armando
f0518b3c16 feat(dma): advanced dma malloc helper 2024-04-02 14:30:14 +08:00
Darian
f66a23a8fb Merge branch 'refactor/usb_host_usbh_hub_interaction' into 'master'
refactor(usb/host): Refactor USBH interaction with Hub

See merge request espressif/esp-idf!29783
2024-03-29 21:16:14 +08:00
Tomas Rezucha
e9daf4912b fix(usb/host): Do not allow unaligned cache access for M2C direction 2024-03-26 16:41:12 +01:00
Darian Leung
64f5d7d983
refactor(usb/host): Simplify USBH and Hub interaction
Previously, on a device disconnection, the USBH and Hub would the require the
following 2-way interaction:

- Hub -> usbh_hub_pass_event() -> USBH to indicate a port error
- USBH -> usbh_hub_req_cb_t -> Hub to request port recovery after the device
has been freed.

The 2-way interaction has been simplified:

- USBH now nofities upper layers of devices being freed via the
USBH_EVENT_DEV_FREE event
- Hub now handles port recovery only after a device has been freed
2024-03-22 18:14:50 +08:00
Roman Leonov
b90c7e585a refactor(usb_host): Renamed hub_driver_state to root_port_state 2024-03-21 13:16:28 +01:00
Darian Leung
6d40e191f8
refactor(hal/usb): Refactor usb_wrap_ll.h
This commit rewrite the 'usb_wrap_ll.h' API as follows:

- All APIs renamed from 'usb_fsls_phy_ll_...()' to 'usb_wrap_ll_...()'
- APIs now match their equivalent counter parts in 'usb_serial_jtag_ll.h'
2024-03-18 19:23:44 +08:00
Darian Leung
a77e5cc718
refactor(hal/usb): Remove usb_fsls_phy_ll.h
For targets that only contain a USJ peripheral (and not a DWC OTG), their
'usb_fsls_phy_ll.h' headers only contain a single function
('usb_fsls_phy_ll_int_jtag_enable()') whose feature is already covered by
functions in 'usb_serial_jtag_ll.h'. Thus, this header is redundant.

This commit does the following:

- Remove 'usb_fsls_phy_ll.h' for targets that only contain a USJ peripheral
- Rename 'usb_fsls_phy_[hal|ll].[h|c]' to `usb_wrap_[hal|ll].[h|c]` for targets
that contain a DWC OTG peripheral. This better reflects the underlying peripheral
that the LL header accesses.
2024-03-18 19:23:43 +08:00
Roman Leonov
029c286a21 feat(usb_host): Added KConfig parameter for External HUB support enable 2024-03-14 21:06:34 +01:00
Roman Leonov
8d93d18451 refactor(usb_host): Added chapter11 header, refactor chapter9 header 2024-03-14 21:06:34 +01:00
Tomas Rezucha
fa2986fdef Merge branch 'feat/usb_host_sync_types' into 'master'
Add synchronization types from USB specs table 9-13

See merge request espressif/esp-idf!29263
2024-03-12 14:48:16 +08:00
Darian Leung
411e5481e7
refactor(usb): Remove USBH control transfer callback
This commit merges the USBH control transfer callback into the USBH event
callback. This simplifies the code as the USBH now uses a single callback.
2024-03-06 23:09:17 +08:00
Darian Leung
ec2f08ace6
refactor(usb): Update USBH event callback arguments
This commit does the following:

- Updates the USBH event callback arguments to now pass a usbh_event_data_t
which can contain different data for each event
- Updated event names
2024-03-06 23:09:16 +08:00
Tomas Rezucha
72f00d7c6d feat(usb/host): Update ISOC scheduler for HS endpoints
USB-OTG uses 'sched_info' field of HCTSIZ register to schedule transactions
in USB microframes.
2024-03-01 18:05:40 +01:00
Peter Marcisovsky
51d6296fde ci: Added esp32p4 usb tests to CI:
- added new test for usb_host_lib example for all targets
    - CI USB host test are run on esp32p4
    - CI USB device tests temporarily disabled until usb_device runner is fixed
    - hcd and usb_host tests which do not require PHY are run on esp32p4
2024-02-29 10:35:09 +01:00
Darian Leung
3887441b37
fix(usb): Fix bug where usbh_process() misses an event
This commit fixes a bug where if multiple concurrent USBH API calls trigger
multiple events on the same device, some events will be lost. As a result,
those lost events don't get processed by the subsequent usbh_process() call.
2024-02-27 18:22:48 +08:00
Tomas Rezucha
5863a27bd2 feat(usb/host): Add missing sync types from USB specification 2024-02-26 10:50:20 +01:00
Erhan Kurubas
f4acf0b378 refactor(espcoredump): format coredump component with astyle 2024-02-19 21:57:28 +01:00
Tomas Rezucha
f13ae0fc08 feat(esp32p4): Add USB-OTG support for ESP32-P4 2024-01-30 15:07:11 +01:00
Tomas Rezucha
ed1f20a972 feat(hal/usb): Add HS PHY configuration 2024-01-22 12:14:11 +01:00
Darian Leung
6a43b623dc refactor(soc): Rename usb_otg_periph to usb_dwc_periph
- Renamed usb_otg_periph.h/c to usb_dwc_periph.h/c to match naming convention
of other DWC OTG related files
- Added compatibility header for usb_otg_periph.h
2024-01-17 21:28:25 +08:00
Fu Hanxi
37a4c2ea01 Merge branch 'ci/nested_dynamic_pipeline' into 'master'
CI: Dynamic Pipeline!!!

Closes IDFCI-1211, IDFCI-1729, IDF-8500, IDF-8456, IDFCI-1828, RDT-610, and RDT-615

See merge request espressif/esp-idf!26662
2024-01-11 13:08:28 +08:00
Fu Hanxi
d44f236f7b
ci(usb): migrate from .gitlab/ci/rules.yml to .build-test-rules.yml 2024-01-10 15:29:44 +01:00
Tomas Rezucha
ec004c788b fix(usb/host): Sync cache for memory shared by CPU and USB-OTG
Transfer descriptor list, frame list and transfer data buffers
are accessed by both CPU and USB-OTG. Sync CPU cache between the accesses.
2024-01-10 15:23:24 +01:00
Peter Marcisovsky
24adb6ed3c feat(us/host): set device cfg during enumeration
- user callback funciton to set device configuration
      as a part of usb_host_install
    - callback provides device descriptor of a device being enumerated
    - user can set which cfg descriptor the USB device will be set with
    - user can filter device enumeration
    - Kconfig menu to enable callback function
    - usb_host_lib example demonstration
2024-01-04 16:09:13 +01:00
Darian Leung
2bb30e6493 refactor(usb): Deprecate CONFIG_USB_OTG_SUPPORTED, use SOC_USB_OTG_SUPPORTED instead
Previously, USB build dependencies used the CONFIG_USB_OTG_SUPPORTED. However,
they could depend on `soc_caps.h` instead.
2024-01-01 21:37:34 +08:00