Commit Graph

163 Commits

Author SHA1 Message Date
Roman Leonov
fac1966c9b Merge branch 'refactor/usb_host_ext_hub_cleanup' into 'master'
refactor(hub): Cleaned up dev_tree_node debug output, moved node freeing

See merge request espressif/esp-idf!33380
2024-09-12 16:01:36 +08:00
Wu Zheng Hui
6abe40e590 Merge branch 'feature/optimize_esp32p4_active_power_eco1' into 'master'
feat(system): Optimize esp32p4 active state  power consumption

Closes PM-103 and IDF-7688

See merge request espressif/esp-idf!32950
2024-09-11 23:15:29 +08:00
wuzhenghui
05e74480f5
feat(esp_system): gate some clock by default to optmize esp32p4 active power 2024-09-11 10:53:00 +08:00
Peter Marcisovsky
3362e18432 fix(usb_host): Update log level and error poropagation 2024-09-08 18:43:42 +02:00
Roman Leonov
a9d960a81f refactor(hub): Cleaned up dev_tree_node debug output, moved node freeing 2024-09-06 22:44:37 +02:00
Tomas Rezucha
19bf686d5e feat(usb/host): Enable USB Host tests on P4 2024-09-05 19:41:07 +02:00
Tomas Rezucha
3857f779cc fix(usb/host): Correctly handle unpowered port in HUB 2024-09-05 19:40:52 +02:00
Darian Leung
cac0ef9d11 refactor(usb): Remove use of usb_phy_action() from unit tests
Currently, USB Host unit tests that require a software triggered disconnection/
reconnection rely on the 'usb_phy_action()' function.

This commit replaces those calls with 'hcd_port_command()' or
'usb_host_lib_set_root_port_power()'.

Note: Also removed 'test_usb_common.h/c' as it is no longer necessary are the
function call replacements.
2024-09-05 12:27:27 +02:00
Darian Leung
54db1cda8b feat(usb): Add usb_host_lib_set_root_port_power()
This commit adds the usb_host_lib_set_root_port_power() function. This provides
a public API for users to power the root port OFF or ON at runtime, thus trigger
a disconnection or allow connections respectively.

In addition, the usb_host_config_t.root_port_unpowered install configuration is
provided to allow users to install the USB Host Library without automatically
powering ON the root port.
2024-09-05 12:27:27 +02:00
Peter Marcisovsky
0c388cf576 Merge branch 'refactor/usb_host_add_func_ret_values_description' into 'master'
Refactor: USB Host add function return values description

Closes IDF-10455

See merge request espressif/esp-idf!32106
2024-09-05 15:20:04 +08:00
Roman Leonov
6ee1c300c2 Merge branch 'refactor/usb_host_ext_port_prereq' into 'master'
refactor(ext_hub): Prerequisites for the Ext Port Driver

See merge request espressif/esp-idf!32213
2024-09-03 19:17:22 +08:00
Peter Marcisovsky
f7b31defc9 refactor(usb_host): Fixed function return values in usb_host stack:
- updated doxygen for the whole usb_host stack
    - doxygen for test_apps is not updated
    - fixed error codes propagation problems in the usb_host stack
2024-09-02 16:41:38 +02:00
Tomas Rezucha
ba16f50560 refactor(usb/host): Move P4 HS PHY function to correct LL file
Moved usb_wrap_ll_enable_precise_detection() in usb_wrap_ll.h
to usb_utmi_ll_enable_precise_detection() in usb_utmi_ll.h

Fixes commit 97d30e7c48
2024-09-02 14:39:28 +02:00
Tomas Rezucha
21c6c62087 fix(usb/host): Fix USB Low Speed devices connection on P4
P4 USB UTMI PHY was updated to specification v2.0
2024-09-02 14:39:22 +02:00
Roman Leonov
a971ddf17a refactor(ext_hub): Added port creation and freeing, cleaned up members 2024-09-02 14:25:21 +02:00
Tomas Rezucha
660319ecaf fix(usb/host): Use new cache aligned DMA alloc functions 2024-08-20 08:13:32 +02:00
Roman Leonov
0a9bd7aa50 fix(enum): Added cancellation stage to process, second reset stage, remove dynamic members 2024-08-12 09:11:02 +02:00
Peter Marcisovsky
ddc3c2b78b refactor(usb_host): Update USB Host multiconfig public API
- previous usb_host_get_config_desc_free()
    - updated usb_host_free_config_desc()
2024-07-16 11:32:22 +02:00
Ivan Grokhotkov
d146fb5b84 Merge branch 'bugfix/build_with_clang' into 'master'
fix build errors with clang

Closes IDFGH-13238

See merge request espressif/esp-idf!32099
2024-07-15 21:40:40 +08:00
Roman Leonov
d108ba14ac Merge branch 'fix/usb_host_hcd_dconn_hs' into 'master'
fix(usb_dwc_hal): Enabled precise VBUS detection

Closes IDF-9953

See merge request espressif/esp-idf!32031
2024-07-13 00:45:56 +08:00
Ivan Grokhotkov
df65b3829e
fix(usb): variable declaration after label for clang 2024-07-12 13:58:18 +02:00
Roman Leonov
97d30e7c48 fix(usb_dwc_hal): Enabled precise detection of VBUS 2024-07-12 10:51:31 +02:00
Tomas Rezucha
43c06a5d11 fix(usb/host): Fix occasional ISOC scheduler skipping transfers 2024-07-09 16:59:27 +02:00
Roman Leonov
eceb27a835 fix(usb_host): Changed addr_map to 4x array of uint32 2024-07-03 11:01:17 +02:00
Roman Leonov
1526b80e08 fix(hub): Changed type of next_uid member (uint8_t -> unsigned int) 2024-07-03 10:43:08 +02:00
Tomas Rezucha
04be071dc6 fix(usb/host): Decode error flags in ISOC transfers 2024-07-02 15:08:30 +02:00
Roman Leonov
548b03c69f feat(ext_hub): Added External Hub driver 2024-06-25 11:28:03 +02:00
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