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

usb_otg: Add support for esp32s3 #411

Open
wants to merge 2 commits into
base: zephyr
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/usb/.build-test-rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps

components/usb/test_apps:
enable:
- if: SOC_USB_OTG_SUPPORTED == 1
25 changes: 25 additions & 0 deletions components/usb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set(srcs)
set(include)
set(priv_includes)
# As CONFIG_SOC_USB_OTG_SUPPORTED comes from Kconfig, it is not evaluated yet
# when components are being registered.
# Thus, always add the (private) requirements, regardless of Kconfig
set(priv_requires driver) # usb_phy driver relies on gpio driver API

if(CONFIG_SOC_USB_OTG_SUPPORTED)
list(APPEND srcs "hcd_dwc.c"
"hub.c"
"usb_helpers.c"
"usb_host.c"
"usb_private.c"
"usbh.c"
"usb_phy.c")
list(APPEND include "include")
list(APPEND priv_includes "private_include")
endif()

idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${include}
PRIV_INCLUDE_DIRS ${priv_includes}
PRIV_REQUIRES ${priv_requires}
)
124 changes: 124 additions & 0 deletions components/usb/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
menu "USB-OTG"
depends on SOC_USB_OTG_SUPPORTED

config USB_HOST_CONTROL_TRANSFER_MAX_SIZE
int "Largest size (in bytes) of transfers to/from default endpoints"
default 256
help
Each USB device attached is allocated a dedicated buffer for its OUT/IN transfers to/from the device's
control endpoint. The maximum size of that buffer is determined by this option. The limited size of the
transfer buffer have the following implications:
- The maximum length of control transfers is limited
- Device's with configuration descriptors larger than this limit cannot be supported

choice USB_HOST_HW_BUFFER_BIAS
prompt "Hardware FIFO size biasing"
default USB_HOST_HW_BUFFER_BIAS_BALANCED
help
The underlying hardware has size adjustable FIFOs to cache USB packets on reception (IN) or for
transmission (OUT). The size of these FIFOs will affect the largest MPS (maximum packet size) and the
maximum number of packets that can be cached at any one time. The hardware contains the following
FIFOS: RX (for all IN packets), Non-periodic TX (for Bulk and Control OUT packets), and Periodic TX
(for Interrupt and Isochronous OUT packets). This configuration option allows biasing the FIFO sizes
towards a particular use case, which may be necessary for devices that have endpoints with large MPS.
The MPS limits for each biasing are listed below:

Balanced:
- IN (all transfer types), 408 bytes
- OUT non-periodic (Bulk/Control), 192 bytes (i.e., 3 x 64 byte packets)
- OUT periodic (Interrupt/Isochronous), 192 bytes

Bias IN:
- IN (all transfer types), 600 bytes
- OUT non-periodic (Bulk/Control), 64 bytes (i.e., 1 x 64 byte packets)
- OUT periodic (Interrupt/Isochronous), 128 bytes

Bias Periodic OUT:
- IN (all transfer types), 128 bytes
- OUT non-periodic (Bulk/Control), 64 bytes (i.e., 1 x 64 byte packets)
- OUT periodic (Interrupt/Isochronous), 600 bytes

config USB_HOST_HW_BUFFER_BIAS_BALANCED
bool "Balanced"
config USB_HOST_HW_BUFFER_BIAS_IN
bool "Bias IN"
config USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT
bool "Periodic OUT"
endchoice

menu "Root Hub configuration"

config USB_HOST_DEBOUNCE_DELAY_MS
int "Debounce delay in ms"
default 250
help
On connection of a USB device, the USB 2.0 specification requires a "debounce interval with a minimum
duration of 100ms" to allow the connection to stabilize (see USB 2.0 chapter 7.1.7.3 for more details).
During the debounce interval, no new connection/disconnection events are registered.

The default value is set to 250 ms to be safe.

config USB_HOST_RESET_HOLD_MS
int "Reset hold in ms"
default 30
help
The reset signaling can be generated on any Hub or Host Controller port by request from the USB System
Software. The USB 2.0 specification requires that "the reset signaling must be driven for a minimum of
10ms" (see USB 2.0 chapter 7.1.7.5 for more details). After the reset, the hub port will transition to
the Enabled state (refer to Section 11.5).

The default value is set to 30 ms to be safe.

config USB_HOST_RESET_RECOVERY_MS
int "Reset recovery delay in ms"
default 30
help
After a port stops driving the reset signal, the USB 2.0 specification requires that the "USB System
Software guarantees a minimum of 10 ms for reset recovery" before the attached device is expected to
respond to data transfers (see USB 2.0 chapter 7.1.7.3 for more details). The device may ignore any
data transfers during the recovery interval.

The default value is set to 30 ms to be safe.


config USB_HOST_SET_ADDR_RECOVERY_MS
int "SetAddress() recovery time in ms"
default 10
help
"After successful completion of the Status stage, the device is allowed a SetAddress() recovery
interval of 2 ms. At the end of this interval, the device must be able to accept Setup packets
addressed to the new address. Also, at the end of the recovery interval, the device must not respond to
tokens sent to the old address (unless, of course, the old and new address is the same)." See USB 2.0
chapter 9.2.6.3 for more details.

The default value is set to 10 ms to be safe.

endmenu #Root Hub configuration

# Hidden or compatibility options

config USB_OTG_SUPPORTED
# Invisible config kept for compatibility
# Todo: Remove in v6.0 (IDF-8936)
bool
default y

config USB_HOST_ENABLE_ENUM_FILTER_CALLBACK
bool "Enable enumeration filter callback"
default n
help
The enumeration filter callback is called before enumeration of each newly attached device. This callback
allows users to control whether a device should be enumerated, and what configuration number to use when
enumerating a device.

If enabled, the enumeration filter callback can be set via 'usb_host_config_t' when calling
'usb_host_install()'.

config USB_HOST_EXT_HUB_SUPPORT
depends on IDF_EXPERIMENTAL_FEATURES
bool "Support USB HUB (Experimental)"
default n
help
Feature is under development.

endmenu #USB-OTG
Loading