diff --git a/boards/arm/bl654_usb/CMakeLists.txt b/boards/arm/bl654_usb/CMakeLists.txt new file mode 100644 index 0000000000000..ed35c14cf6e01 --- /dev/null +++ b/boards/arm/bl654_usb/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright (c) 2021 Laird Connectivity. +# SPDX-License-Identifier: Apache-2.0 + +if (CONFIG_BOARD_BL654_USB AND CONFIG_BOARD_ENABLE_USB_AUTOMATICALLY) +zephyr_library() +zephyr_library_sources(bl654_usb_enable_usb.c) +endif() diff --git a/boards/arm/bl654_usb/Kconfig b/boards/arm/bl654_usb/Kconfig index a445fd15f5e8a..51695165ddf18 100644 --- a/boards/arm/bl654_usb/Kconfig +++ b/boards/arm/bl654_usb/Kconfig @@ -8,3 +8,19 @@ config BOARD_ENABLE_DCDC select SOC_DCDC_NRF52X default y depends on BOARD_BL654_USB + +config BOARD_ENABLE_USB_AUTOMATICALLY + bool "Enable USB automatically" + default y if USB_UART_CONSOLE + depends on BOARD_BL654_USB + help + Will automatically enable the USB peripheral upon boot if USB console + mode is selected, which means manually enabling USB from user-code is + not required + +config BOARD_ENABLE_USB_AUTOMATICALLY_INIT_PRIORITY + int "USB automatic init priority" + default 96 + depends on BOARD_ENABLE_USB_AUTOMATICALLY + help + Automatic USB peripheral enablement initialisation priority diff --git a/boards/arm/bl654_usb/Kconfig.defconfig b/boards/arm/bl654_usb/Kconfig.defconfig index 56125667cbb3e..99e269f524c3a 100644 --- a/boards/arm/bl654_usb/Kconfig.defconfig +++ b/boards/arm/bl654_usb/Kconfig.defconfig @@ -26,7 +26,10 @@ config FLASH_LOAD_OFFSET if USB_DEVICE_STACK config USB_UART_CONSOLE - default y + default y if !USB_DEVICE_BLUETOOTH + +config USB_CDC_ACM + default n if USB_DEVICE_BLUETOOTH config UART_LINE_CTRL default y diff --git a/boards/arm/bl654_usb/bl654_usb_enable_usb.c b/boards/arm/bl654_usb/bl654_usb_enable_usb.c new file mode 100644 index 0000000000000..9c6b771196869 --- /dev/null +++ b/boards/arm/bl654_usb/bl654_usb_enable_usb.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 Laird Connectivity + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +static int usb_enable_boot(const struct device *dev) +{ + ARG_UNUSED(dev); + usb_enable(NULL); + + return 0; +} + +SYS_INIT(usb_enable_boot, POST_KERNEL, + CONFIG_BOARD_ENABLE_USB_AUTOMATICALLY_INIT_PRIORITY);