Skip to content

Commit

Permalink
drivers: usb: add usb device driver support for NPCM4XX series.
Browse files Browse the repository at this point in the history
1. add npcm4xx usb device driver.
2. add npcm4xx usb device register define in reg_def.h
3. disable build i3c driver temporarily.
4. enable stack overflow checking.
5. configure the main stack size from 1024 to 2048.
6. disable compiler optimization as default.

Signed-off-by: Adrian Chen <[email protected]>
  • Loading branch information
YAChen0 committed Aug 17, 2023
1 parent 021fa39 commit af54af2
Show file tree
Hide file tree
Showing 12 changed files with 1,394 additions and 5 deletions.
5 changes: 5 additions & 0 deletions boards/arm/npcm400f_evb/fun_def_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,8 @@ FUN_DEFINE(DT_NODELABEL(pinctrl_i3c0_default), I3C1_SCL, I3C1_SDA)
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i3c1), okay) && CONFIG_I3C_NPCM4XX
FUN_DEFINE(DT_NODELABEL(pinctrl_i3c1_default), I3C2_SCL, I3C2_SDA)
#endif

#if DT_NODE_HAS_STATUS(DT_NODELABEL(usbd0), okay) && CONFIG_USB_DC_NPCM4XX
FUN_DEFINE(DT_NODELABEL(pinctrl_usbd_phy_iclk), USBD_PHY_ICLK)
FUN_DEFINE(DT_NODELABEL(pinctrl_usbd_phy_xclk), USBD_PHY_XCLK)
#endif
9 changes: 7 additions & 2 deletions boards/arm/npcm400f_evb/npcm400f_evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@
/* &pinctrl_td4p_default */ /* TD4P - C6 */
&pinctrl_vin3_default>; /* VIN3 - D6 */
};

&spip {
status = "okay";
};

&i3c0 {
status = "okay";
status = "disabled";
assigned-address = <0x20>;
i2c-scl-hz = <100000>;
i3c-scl-hz = <12500000>;
Expand All @@ -179,7 +180,7 @@
};

&i3c1 {
status = "okay";
status = "disabled";
assigned-address = <0x21>;
i2c-scl-hz = <100000>;
i3c-scl-hz = <12500000>;
Expand Down Expand Up @@ -207,3 +208,7 @@
* };
*/
};

&usbd0 {
status = "okay";
};
12 changes: 10 additions & 2 deletions boards/arm/npcm400f_evb/npcm400f_evb_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ CONFIG_SRAM_VECTOR_TABLE=y
# General Kernel Options
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000
CONFIG_XIP=y
CONFIG_STACK_SENTINEL=y
CONFIG_MAIN_STACK_SIZE=2048 #default:1024
CONFIG_NO_OPTIMIZATIONS=y

# subsystem
CONFIG_LOG=y
CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_BUFFER_SIZE=65536 #range:128-65536

# Clock Driver
CONFIG_CLOCK_CONTROL=y
Expand Down Expand Up @@ -80,5 +84,9 @@ CONFIG_SPI=y
CONFIG_SPIP_NPCM4XX=y

# I3C driver
CONFIG_I3C=y
CONFIG_I3C_NPCM4XX=y
#CONFIG_I3C=y
#CONFIG_I3C_NPCM4XX=y

# USB Driver
CONFIG_USB=y
CONFIG_USB_DC_NPCM4XX=y
2 changes: 1 addition & 1 deletion drivers/spi/spi_npcm4xx_spip.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int spip_npcm4xx_configure(const struct device *dev,
const struct npcm4xx_spip_config *cfg = dev->config;
struct npcm4xx_spip_data *data = dev->data;
struct spip_reg *const spip_regs = (struct spip_reg *) cfg->base;
uint32_t u32Div;
uint32_t u32Div = 0;
int ret = 0;

if (SPI_WORD_SIZE_GET(config->operation) != 8) {
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/device/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ zephyr_sources_ifdef(CONFIG_USB_NATIVE_POSIX
usb_dc_native_posix_adapt.c
)
zephyr_sources_ifdef(CONFIG_USB_DC_NXP_EHCI usb_dc_mcux_ehci.c)
zephyr_sources_ifdef(CONFIG_USB_DC_NPCM4XX usb_dc_npcm4xx.c)
8 changes: 8 additions & 0 deletions drivers/usb/device/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,12 @@ config USB_NATIVE_POSIX
help
Native Posix USB Device Controller Driver.

config USB_DC_NPCM4XX
bool "Nuvoton NPCM4XX USB Device Controller Driver"
depends on SOC_FAMILY_NPCM4XX
select USB_DEVICE_DRIVER
help
This option enables the USB device driver for NPCM4XX family of processors.
Say y if you wish to use USB device on NPCM4XX.

endif # USB
Loading

0 comments on commit af54af2

Please sign in to comment.