Skip to content

Commit

Permalink
Merge pull request zephyrproject-rtos#4 from ccli8/nvt_m467_usbd
Browse files Browse the repository at this point in the history
drivers: usb: numaker: Support USBD controller driver
  • Loading branch information
cyliangtw authored Nov 18, 2022
2 parents d6ea840 + 5bd13aa commit 9e8a7b4
Show file tree
Hide file tree
Showing 9 changed files with 2,371 additions and 0 deletions.
8 changes: 8 additions & 0 deletions boards/arm/numaker_pfm_m467/numaker_pfm_m467-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@
<PB3MFP_UART1_TXD 0x0000>,
<PC9MFP_GPIO 0x0000>;
};

/* USBD multi-function pins for VBUS, D+, D-, and ID pins */
usbd_default: usbd_default {
pinmux = <PA12MFP_USB_VBUS 0x0000>,
<PA13MFP_USB_D_N 0x0000>,
<PA14MFP_USB_D_P 0x0000>,
<PA15MFP_USB_OTG_ID 0x0000>;
};
};
19 changes: 19 additions & 0 deletions boards/arm/numaker_pfm_m467/numaker_pfm_m467.dts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@

};

&scc {
/* For USB 1.1 Host/Device/OTG, configure to 192MHz, which can generate necessary 48MHz.
* For USB 2.0 Host/Device/OTG or no USB application, comment out to use default. */
core-clock = <192000000>;
};

&gpiob {
status = "okay";
};
Expand Down Expand Up @@ -101,3 +107,16 @@
pinctrl-names = "default";
status = "okay";
};

/* Notes for USBD (USB 1.1 Device Controller)
*
* 1. According to doc/releases/release-notes-2.7.rst, to allow generic USB device support
* samples to be built, boards are supposed to add 'zephyr_udc0' node label for support
* USB device controller and make it enabled.
* 2. On enabled, 'core-clock', as above, is required to to be 192MHz.
*/
zephyr_udc0: &usbd {
pinctrl-0 = <&usbd_default>;
pinctrl-names = "default";
status = "okay";
};
1 change: 1 addition & 0 deletions drivers/usb/device/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ zephyr_library_sources_ifdef(CONFIG_USB_NATIVE_POSIX
)
zephyr_library_sources_ifdef(CONFIG_USB_NRFX usb_dc_nrfx.c)
zephyr_library_sources_ifdef(CONFIG_USB_MCUX usb_dc_mcux.c)
zephyr_library_sources_ifdef(CONFIG_USB_DC_NUMAKER usb_dc_numaker.c)

endif()
58 changes: 58 additions & 0 deletions drivers/usb/device/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,64 @@ config USB_DC_MSG_QUEUE_LEN

endif # USB_MCUX

config USB_DC_NUMAKER
bool "Nuvoton NuMaker USB 1.1/2.0 device controller"
depends on SOC_FAMILY_NUMAKER
depends on USB_DC_NUMAKER_USBD || USB_DC_NUMAKER_HSUSBD
default USB_DC_NUMAKER_USBD || USB_DC_NUMAKER_HSUSBD
help
Enables Nuvoton NuMaker USB device controller driver.

DT_COMPAT_NUMAKER_USBD := nuvoton,numaker-usbd
DT_COMPAT_NUMAKER_HSUSBD := nuvoton,numaker-hsusbd

choice USB_DC_NUMAKER_TYPE
prompt "Nuvoton NuMaker USB device controller type"
default USB_DC_NUMAKER_USBD
help
Select the type of Nuvoton NuMaker USB device controller.

config USB_DC_NUMAKER_USBD
bool "Nuvoton NuMaker USB 1.1 device controller"
select HAS_NUMAKER_USBD
depends on $(dt_compat_enabled,$(DT_COMPAT_NUMAKER_USBD))
help
Enable Nuvoton NuMaker USB 1.1 device controller driver.

config USB_DC_NUMAKER_HSUSBD
bool "Nuvoton NuMaker high-speed USB 2.0 device controller"
select HAS_NUMAKER_HSUSBD
depends on $(dt_compat_enabled,$(DT_COMPAT_NUMAKER_HSUSBD))
help
Enable Nuvoton NuMaker high-speed USB 2.0 device controller driver.

endchoice

config USB_DC_NUMAKER_USBD_WORKAROUND_DISALLOW_ISO_IN_OUT_SAME_NUM
bool "Enable workaround for disallowing Isochronous IN/OUT endpoints to be of same numbers"
default $(dt_nodelabel_bool_prop,usbd,disallow-iso-in-out-same-number)
depends on USB_DC_NUMAKER_USBD
help
Enable workaround which can allow Isochronous IN/OUT endpoints to be assigned
the same endpoint numbers. Note this workaround can only work for not more than
one Isochronous IN endpoint enabled, or behavior is undefined.

config USB_DC_NUMAKER_MSG_QUEUE_SIZE
int "USB DC message queue size"
default 32
depends on USB_DC_NUMAKER
help
Maximum number of messages the driver can queue for interrupt bottom half processing.

config USB_DC_NUMAKER_MSG_HANDLER_THREAD_STACK_SIZE
int "USB DC message handler thread stack size"
default 1536
depends on USB_DC_NUMAKER
help
Size of the stack for the message handler thread that is used in the driver
for handling messages from the USB DC ISR, i.e. interrupt bottom half processing,
including callbacks to the USB device stack.

config USB_NATIVE_POSIX
bool "Native Posix USB Device Controller Driver"
help
Expand Down
Loading

0 comments on commit 9e8a7b4

Please sign in to comment.