Skip to content

Commit d44b26a

Browse files
Raffael Rostagnomarekmatej
Raffael Rostagno
authored andcommitted
usb_otg: Add HAL LL files
Add LL files for USB_OTG support. Signed-off-by: Raffael Rostagno <[email protected]>
1 parent 1f61730 commit d44b26a

21 files changed

+10504
-0
lines changed

components/usb/.build-test-rules.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
2+
3+
components/usb/test_apps:
4+
enable:
5+
- if: SOC_USB_OTG_SUPPORTED == 1

components/usb/CMakeLists.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
set(srcs)
2+
set(include)
3+
set(priv_includes)
4+
# As CONFIG_SOC_USB_OTG_SUPPORTED comes from Kconfig, it is not evaluated yet
5+
# when components are being registered.
6+
# Thus, always add the (private) requirements, regardless of Kconfig
7+
set(priv_requires driver) # usb_phy driver relies on gpio driver API
8+
9+
if(CONFIG_SOC_USB_OTG_SUPPORTED)
10+
list(APPEND srcs "hcd_dwc.c"
11+
"hub.c"
12+
"usb_helpers.c"
13+
"usb_host.c"
14+
"usb_private.c"
15+
"usbh.c"
16+
"usb_phy.c")
17+
list(APPEND include "include")
18+
list(APPEND priv_includes "private_include")
19+
endif()
20+
21+
idf_component_register(SRCS ${srcs}
22+
INCLUDE_DIRS ${include}
23+
PRIV_INCLUDE_DIRS ${priv_includes}
24+
PRIV_REQUIRES ${priv_requires}
25+
)

components/usb/Kconfig

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
menu "USB-OTG"
2+
depends on SOC_USB_OTG_SUPPORTED
3+
4+
config USB_HOST_CONTROL_TRANSFER_MAX_SIZE
5+
int "Largest size (in bytes) of transfers to/from default endpoints"
6+
default 256
7+
help
8+
Each USB device attached is allocated a dedicated buffer for its OUT/IN transfers to/from the device's
9+
control endpoint. The maximum size of that buffer is determined by this option. The limited size of the
10+
transfer buffer have the following implications:
11+
- The maximum length of control transfers is limited
12+
- Device's with configuration descriptors larger than this limit cannot be supported
13+
14+
choice USB_HOST_HW_BUFFER_BIAS
15+
prompt "Hardware FIFO size biasing"
16+
default USB_HOST_HW_BUFFER_BIAS_BALANCED
17+
help
18+
The underlying hardware has size adjustable FIFOs to cache USB packets on reception (IN) or for
19+
transmission (OUT). The size of these FIFOs will affect the largest MPS (maximum packet size) and the
20+
maximum number of packets that can be cached at any one time. The hardware contains the following
21+
FIFOS: RX (for all IN packets), Non-periodic TX (for Bulk and Control OUT packets), and Periodic TX
22+
(for Interrupt and Isochronous OUT packets). This configuration option allows biasing the FIFO sizes
23+
towards a particular use case, which may be necessary for devices that have endpoints with large MPS.
24+
The MPS limits for each biasing are listed below:
25+
26+
Balanced:
27+
- IN (all transfer types), 408 bytes
28+
- OUT non-periodic (Bulk/Control), 192 bytes (i.e., 3 x 64 byte packets)
29+
- OUT periodic (Interrupt/Isochronous), 192 bytes
30+
31+
Bias IN:
32+
- IN (all transfer types), 600 bytes
33+
- OUT non-periodic (Bulk/Control), 64 bytes (i.e., 1 x 64 byte packets)
34+
- OUT periodic (Interrupt/Isochronous), 128 bytes
35+
36+
Bias Periodic OUT:
37+
- IN (all transfer types), 128 bytes
38+
- OUT non-periodic (Bulk/Control), 64 bytes (i.e., 1 x 64 byte packets)
39+
- OUT periodic (Interrupt/Isochronous), 600 bytes
40+
41+
config USB_HOST_HW_BUFFER_BIAS_BALANCED
42+
bool "Balanced"
43+
config USB_HOST_HW_BUFFER_BIAS_IN
44+
bool "Bias IN"
45+
config USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT
46+
bool "Periodic OUT"
47+
endchoice
48+
49+
menu "Root Hub configuration"
50+
51+
config USB_HOST_DEBOUNCE_DELAY_MS
52+
int "Debounce delay in ms"
53+
default 250
54+
help
55+
On connection of a USB device, the USB 2.0 specification requires a "debounce interval with a minimum
56+
duration of 100ms" to allow the connection to stabilize (see USB 2.0 chapter 7.1.7.3 for more details).
57+
During the debounce interval, no new connection/disconnection events are registered.
58+
59+
The default value is set to 250 ms to be safe.
60+
61+
config USB_HOST_RESET_HOLD_MS
62+
int "Reset hold in ms"
63+
default 30
64+
help
65+
The reset signaling can be generated on any Hub or Host Controller port by request from the USB System
66+
Software. The USB 2.0 specification requires that "the reset signaling must be driven for a minimum of
67+
10ms" (see USB 2.0 chapter 7.1.7.5 for more details). After the reset, the hub port will transition to
68+
the Enabled state (refer to Section 11.5).
69+
70+
The default value is set to 30 ms to be safe.
71+
72+
config USB_HOST_RESET_RECOVERY_MS
73+
int "Reset recovery delay in ms"
74+
default 30
75+
help
76+
After a port stops driving the reset signal, the USB 2.0 specification requires that the "USB System
77+
Software guarantees a minimum of 10 ms for reset recovery" before the attached device is expected to
78+
respond to data transfers (see USB 2.0 chapter 7.1.7.3 for more details). The device may ignore any
79+
data transfers during the recovery interval.
80+
81+
The default value is set to 30 ms to be safe.
82+
83+
84+
config USB_HOST_SET_ADDR_RECOVERY_MS
85+
int "SetAddress() recovery time in ms"
86+
default 10
87+
help
88+
"After successful completion of the Status stage, the device is allowed a SetAddress() recovery
89+
interval of 2 ms. At the end of this interval, the device must be able to accept Setup packets
90+
addressed to the new address. Also, at the end of the recovery interval, the device must not respond to
91+
tokens sent to the old address (unless, of course, the old and new address is the same)." See USB 2.0
92+
chapter 9.2.6.3 for more details.
93+
94+
The default value is set to 10 ms to be safe.
95+
96+
endmenu #Root Hub configuration
97+
98+
# Hidden or compatibility options
99+
100+
config USB_OTG_SUPPORTED
101+
# Invisible config kept for compatibility
102+
# Todo: Remove in v6.0 (IDF-8936)
103+
bool
104+
default y
105+
106+
config USB_HOST_ENABLE_ENUM_FILTER_CALLBACK
107+
bool "Enable enumeration filter callback"
108+
default n
109+
help
110+
The enumeration filter callback is called before enumeration of each newly attached device. This callback
111+
allows users to control whether a device should be enumerated, and what configuration number to use when
112+
enumerating a device.
113+
114+
If enabled, the enumeration filter callback can be set via 'usb_host_config_t' when calling
115+
'usb_host_install()'.
116+
117+
config USB_HOST_EXT_HUB_SUPPORT
118+
depends on IDF_EXPERIMENTAL_FEATURES
119+
bool "Support USB HUB (Experimental)"
120+
default n
121+
help
122+
Feature is under development.
123+
124+
endmenu #USB-OTG

0 commit comments

Comments
 (0)