Skip to content

Commit 9e8a7b4

Browse files
authored
Merge pull request zephyrproject-rtos#4 from ccli8/nvt_m467_usbd
drivers: usb: numaker: Support USBD controller driver
2 parents d6ea840 + 5bd13aa commit 9e8a7b4

File tree

9 files changed

+2371
-0
lines changed

9 files changed

+2371
-0
lines changed

boards/arm/numaker_pfm_m467/numaker_pfm_m467-pinctrl.dtsi

+8
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,12 @@
2020
<PB3MFP_UART1_TXD 0x0000>,
2121
<PC9MFP_GPIO 0x0000>;
2222
};
23+
24+
/* USBD multi-function pins for VBUS, D+, D-, and ID pins */
25+
usbd_default: usbd_default {
26+
pinmux = <PA12MFP_USB_VBUS 0x0000>,
27+
<PA13MFP_USB_D_N 0x0000>,
28+
<PA14MFP_USB_D_P 0x0000>,
29+
<PA15MFP_USB_OTG_ID 0x0000>;
30+
};
2331
};

boards/arm/numaker_pfm_m467/numaker_pfm_m467.dts

+19
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161

6262
};
6363

64+
&scc {
65+
/* For USB 1.1 Host/Device/OTG, configure to 192MHz, which can generate necessary 48MHz.
66+
* For USB 2.0 Host/Device/OTG or no USB application, comment out to use default. */
67+
core-clock = <192000000>;
68+
};
69+
6470
&gpiob {
6571
status = "okay";
6672
};
@@ -101,3 +107,16 @@
101107
pinctrl-names = "default";
102108
status = "okay";
103109
};
110+
111+
/* Notes for USBD (USB 1.1 Device Controller)
112+
*
113+
* 1. According to doc/releases/release-notes-2.7.rst, to allow generic USB device support
114+
* samples to be built, boards are supposed to add 'zephyr_udc0' node label for support
115+
* USB device controller and make it enabled.
116+
* 2. On enabled, 'core-clock', as above, is required to to be 192MHz.
117+
*/
118+
zephyr_udc0: &usbd {
119+
pinctrl-0 = <&usbd_default>;
120+
pinctrl-names = "default";
121+
status = "okay";
122+
};

drivers/usb/device/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ zephyr_library_sources_ifdef(CONFIG_USB_NATIVE_POSIX
1717
)
1818
zephyr_library_sources_ifdef(CONFIG_USB_NRFX usb_dc_nrfx.c)
1919
zephyr_library_sources_ifdef(CONFIG_USB_MCUX usb_dc_mcux.c)
20+
zephyr_library_sources_ifdef(CONFIG_USB_DC_NUMAKER usb_dc_numaker.c)
2021

2122
endif()

drivers/usb/device/Kconfig

+58
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,64 @@ config USB_DC_MSG_QUEUE_LEN
154154

155155
endif # USB_MCUX
156156

157+
config USB_DC_NUMAKER
158+
bool "Nuvoton NuMaker USB 1.1/2.0 device controller"
159+
depends on SOC_FAMILY_NUMAKER
160+
depends on USB_DC_NUMAKER_USBD || USB_DC_NUMAKER_HSUSBD
161+
default USB_DC_NUMAKER_USBD || USB_DC_NUMAKER_HSUSBD
162+
help
163+
Enables Nuvoton NuMaker USB device controller driver.
164+
165+
DT_COMPAT_NUMAKER_USBD := nuvoton,numaker-usbd
166+
DT_COMPAT_NUMAKER_HSUSBD := nuvoton,numaker-hsusbd
167+
168+
choice USB_DC_NUMAKER_TYPE
169+
prompt "Nuvoton NuMaker USB device controller type"
170+
default USB_DC_NUMAKER_USBD
171+
help
172+
Select the type of Nuvoton NuMaker USB device controller.
173+
174+
config USB_DC_NUMAKER_USBD
175+
bool "Nuvoton NuMaker USB 1.1 device controller"
176+
select HAS_NUMAKER_USBD
177+
depends on $(dt_compat_enabled,$(DT_COMPAT_NUMAKER_USBD))
178+
help
179+
Enable Nuvoton NuMaker USB 1.1 device controller driver.
180+
181+
config USB_DC_NUMAKER_HSUSBD
182+
bool "Nuvoton NuMaker high-speed USB 2.0 device controller"
183+
select HAS_NUMAKER_HSUSBD
184+
depends on $(dt_compat_enabled,$(DT_COMPAT_NUMAKER_HSUSBD))
185+
help
186+
Enable Nuvoton NuMaker high-speed USB 2.0 device controller driver.
187+
188+
endchoice
189+
190+
config USB_DC_NUMAKER_USBD_WORKAROUND_DISALLOW_ISO_IN_OUT_SAME_NUM
191+
bool "Enable workaround for disallowing Isochronous IN/OUT endpoints to be of same numbers"
192+
default $(dt_nodelabel_bool_prop,usbd,disallow-iso-in-out-same-number)
193+
depends on USB_DC_NUMAKER_USBD
194+
help
195+
Enable workaround which can allow Isochronous IN/OUT endpoints to be assigned
196+
the same endpoint numbers. Note this workaround can only work for not more than
197+
one Isochronous IN endpoint enabled, or behavior is undefined.
198+
199+
config USB_DC_NUMAKER_MSG_QUEUE_SIZE
200+
int "USB DC message queue size"
201+
default 32
202+
depends on USB_DC_NUMAKER
203+
help
204+
Maximum number of messages the driver can queue for interrupt bottom half processing.
205+
206+
config USB_DC_NUMAKER_MSG_HANDLER_THREAD_STACK_SIZE
207+
int "USB DC message handler thread stack size"
208+
default 1536
209+
depends on USB_DC_NUMAKER
210+
help
211+
Size of the stack for the message handler thread that is used in the driver
212+
for handling messages from the USB DC ISR, i.e. interrupt bottom half processing,
213+
including callbacks to the USB device stack.
214+
157215
config USB_NATIVE_POSIX
158216
bool "Native Posix USB Device Controller Driver"
159217
help

0 commit comments

Comments
 (0)