Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gd pwr service #2127

Open
wants to merge 2 commits into
base: sdsc-bundle-2.8.0-rc1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions drivers/usb/udc/Kconfig.dwc2
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ config UDC_DWC2_THREAD_PRIORITY
default 8
help
DWC2 driver thread priority.

config UDC_DWC2_USBHS_VBUS_READY_TIMEOUT
int "UDC DWC2 USBHS VBUS ready event timeout in ms"
depends on UDC_DWC2
depends on NRFS_HAS_VBUS_DETECTOR_SERVICE
default 0
help
UDC DWC2 USBHS VBUS ready event timeout. If the VBUS is not ready
and the Nordic USBHS controller is used, the udc_enable() is
blocked for this amount of time. Set it to zero to wait forever.
14 changes: 12 additions & 2 deletions drivers/usb/udc/udc_dwc2_vendor_quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
* On USBHS, we cannot access the DWC2 register until VBUS is detected and
* valid. If the user tries to force usbd_enable() and the corresponding
* udc_enable() without a "VBUS ready" notification, the event wait will block
* until a valid VBUS signal is detected.
* until a valid VBUS signal is detected or until the
* CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT timeout expires.
*/
static K_EVENT_DEFINE(usbhs_events);
#define USBHS_VBUS_READY BIT(0)
Expand Down Expand Up @@ -182,10 +183,19 @@
static inline int usbhs_enable_core(const struct device *dev)
{
NRF_USBHS_Type *wrapper = USBHS_DT_WRAPPER_REG_ADDR(0);
k_timeout_t timeout = K_FOREVER;

#if CONFIG_NRFS_HAS_VBUS_DETECTOR_SERVICE
if (CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT) {
timeout = K_MSEC(CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT);
}
#endif

Check notice on line 193 in drivers/usb/udc/udc_dwc2_vendor_quirks.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/usb/udc/udc_dwc2_vendor_quirks.h:193 - #if CONFIG_NRFS_HAS_VBUS_DETECTOR_SERVICE +#if CONFIG_NRFS_HAS_VBUS_DETECTOR_SERVICE if (CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT) { timeout = K_MSEC(CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT); } - #endif +#endif
if (!k_event_wait(&usbhs_events, USBHS_VBUS_READY, false, K_NO_WAIT)) {
LOG_WRN("VBUS is not ready, block udc_enable()");
k_event_wait(&usbhs_events, USBHS_VBUS_READY, false, K_FOREVER);
if (!k_event_wait(&usbhs_events, USBHS_VBUS_READY, false, timeout)) {
return -ETIMEDOUT;
}
}

wrapper->ENABLE = USBHS_ENABLE_PHY_Msk | USBHS_ENABLE_CORE_Msk;
Expand Down
1 change: 1 addition & 0 deletions include/zephyr/drivers/usb/udc.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ int udc_init(const struct device *dev,
* @return 0 on success, all other values should be treated as error.
* @retval -EPERM controller is not initialized
* @retval -EALREADY already enabled
* @retval -ETIMEDOUT enable operation timed out
*/
int udc_enable(const struct device *dev);

Expand Down
1 change: 1 addition & 0 deletions modules/hal_nordic/nrfs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if(CONFIG_NRFS)
zephyr_library_sources_ifdef(CONFIG_NRFS_CLOCK_SERVICE_ENABLED ${SRC_DIR}/services/nrfs_clock.c)
zephyr_library_sources_ifdef(CONFIG_NRFS_DIAG_SERVICE_ENABLED ${SRC_DIR}/services/nrfs_diag.c)
zephyr_library_sources_ifdef(CONFIG_NRFS_DVFS_SERVICE_ENABLED ${SRC_DIR}/services/nrfs_dvfs.c)
zephyr_library_sources_ifdef(CONFIG_NRFS_GDPWR_SERVICE_ENABLED ${SRC_DIR}/services/nrfs_gdpwr.c)
zephyr_library_sources_ifdef(CONFIG_NRFS_MRAM_SERVICE_ENABLED ${SRC_DIR}/services/nrfs_mram.c)
zephyr_library_sources_ifdef(CONFIG_NRFS_PMIC_SERVICE_ENABLED ${SRC_DIR}/services/nrfs_pmic.c)
zephyr_library_sources_ifdef(CONFIG_NRFS_RESET_SERVICE_ENABLED ${SRC_DIR}/services/nrfs_reset.c)
Expand Down
9 changes: 9 additions & 0 deletions modules/hal_nordic/nrfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ config NRFS_HAS_DIAG_SERVICE
config NRFS_HAS_DVFS_SERVICE
bool

config NRFS_HAS_GDPWR_SERVICE
bool

config NRFS_HAS_MRAM_SERVICE
bool

Expand Down Expand Up @@ -113,6 +116,12 @@ config NRFS_CLOCK_SERVICE_ENABLED
bool "Clock service"
depends on NRFS_HAS_CLOCK_SERVICE
default y

config NRFS_GDPWR_SERVICE_ENABLED
bool "Global domain power request service"
depends on NRFS_HAS_GDPWR_SERVICE
default y

endmenu

rsource "backends/Kconfig"
Expand Down
4 changes: 4 additions & 0 deletions modules/hal_nordic/nrfs/nrfs_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#define NRFS_CLOCK_SERVICE_ENABLED
#endif

#ifdef CONFIG_NRFS_GDPWR_SERVICE_ENABLED
#define NRFS_GDPWR_SERVICE_ENABLED
#endif

#ifdef CONFIG_SOC_POSIX
#define NRFS_UNIT_TESTS_ENABLED
#endif
Expand Down
2 changes: 2 additions & 0 deletions soc/nordic/nrf54h/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ config SOC_NRF54H20_CPUAPP_COMMON
select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE
select NRFS_HAS_CLOCK_SERVICE
select NRFS_HAS_DVFS_SERVICE
select NRFS_HAS_GDPWR_SERVICE
select NRFS_HAS_MRAM_SERVICE
select NRFS_HAS_TEMP_SERVICE
select NRFS_HAS_VBUS_DETECTOR_SERVICE
Expand All @@ -49,6 +50,7 @@ config SOC_NRF54H20_CPURAD_COMMON
select CPU_HAS_CUSTOM_FIXED_SOC_MPU_REGIONS
select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE
select NRFS_HAS_CLOCK_SERVICE
select NRFS_HAS_GDPWR_SERVICE
select NRFS_HAS_MRAM_SERVICE
select NRFS_HAS_TEMP_SERVICE
select NRFS_HAS_VBUS_DETECTOR_SERVICE
Expand Down
2 changes: 2 additions & 0 deletions soc/nordic/nrf92/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ config SOC_NRF9230_ENGB_CPUAPP
select HAS_NORDIC_DMM
select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE
select NRFS_HAS_CLOCK_SERVICE
select NRFS_HAS_GDPWR_SERVICE
select NRFS_HAS_MRAM_SERVICE
select NRFS_HAS_PMIC_SERVICE
select NRFS_HAS_TEMP_SERVICE
Expand All @@ -40,6 +41,7 @@ config SOC_NRF9230_ENGB_CPURAD
select HAS_NORDIC_DMM
select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE
select NRFS_HAS_CLOCK_SERVICE
select NRFS_HAS_GDPWR_SERVICE
select NRFS_HAS_MRAM_SERVICE
select NRFS_HAS_PMIC_SERVICE
select NRFS_HAS_TEMP_SERVICE
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ manifest:
groups:
- hal
- name: hal_nordic
revision: bc25c094a8cf3064f4f9c1e8060b46e1989edf95
revision: 4a3ba8eaca8f5255f550db7bc54dc3e23212da64
path: modules/hal/nordic
groups:
- hal
Expand Down
Loading