diff --git a/tests/drivers/clock_control/clock_control_api/src/device_subsys.h b/tests/drivers/clock_control/clock_control_api/src/device_subsys.h new file mode 100644 index 00000000000..fdb4e2b0438 --- /dev/null +++ b/tests/drivers/clock_control/clock_control_api/src/device_subsys.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +struct device_subsys_data { + clock_control_subsys_t subsys; + uint32_t startup_us; +}; + +struct device_data { + const struct device *dev; + const struct device_subsys_data *subsys_data; + uint32_t subsys_cnt; +}; diff --git a/tests/drivers/clock_control/clock_control_api/src/esp32_device_subsys.h b/tests/drivers/clock_control/clock_control_api/src/esp32_device_subsys.h new file mode 100644 index 00000000000..425511766b2 --- /dev/null +++ b/tests/drivers/clock_control/clock_control_api/src/esp32_device_subsys.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "device_subsys.h" +#include + +/* Test common modules among espressif SOCs*/ +static const struct device_subsys_data subsys_data[] = { + {.subsys = (void *) ESP32_LEDC_MODULE}, + {.subsys = (void *) ESP32_UART1_MODULE}, + {.subsys = (void *) ESP32_I2C0_MODULE}, + {.subsys = (void *) ESP32_UHCI0_MODULE}, + {.subsys = (void *) ESP32_RMT_MODULE}, + {.subsys = (void *) ESP32_TWAI_MODULE}, + {.subsys = (void *) ESP32_RNG_MODULE}, +}; + +static const struct device_data devices[] = { + { + .dev = DEVICE_DT_GET_ONE(espressif_esp32_rtc), + .subsys_data = subsys_data, + .subsys_cnt = ARRAY_SIZE(subsys_data) + } +}; diff --git a/tests/drivers/clock_control/clock_control_api/src/nrf_device_subsys.h b/tests/drivers/clock_control/clock_control_api/src/nrf_device_subsys.h new file mode 100644 index 00000000000..6d660bda947 --- /dev/null +++ b/tests/drivers/clock_control/clock_control_api/src/nrf_device_subsys.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019, Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "device_subsys.h" +#include + +static const struct device_subsys_data subsys_data[] = { + { + .subsys = CLOCK_CONTROL_NRF_SUBSYS_HF, + .startup_us = + IS_ENABLED(CONFIG_SOC_SERIES_NRF91X) ? + 3000 : 500 + }, +#ifndef CONFIG_SOC_NRF52832 + /* On nrf52832 LF clock cannot be stopped because it leads + * to RTC COUNTER register reset and that is unexpected by + * system clock which is disrupted and may hang in the test. + */ + { + .subsys = CLOCK_CONTROL_NRF_SUBSYS_LF, + .startup_us = (CLOCK_CONTROL_NRF_K32SRC == + NRF_CLOCK_LFCLK_RC) ? 1000 : 500000 + } +#endif /* !CONFIG_SOC_NRF52832 */ +}; + +static const struct device_data devices[] = { + { + .dev = DEVICE_DT_GET_ONE(nordic_nrf_clock), + .subsys_data = subsys_data, + .subsys_cnt = ARRAY_SIZE(subsys_data) + } +}; diff --git a/tests/drivers/clock_control/clock_control_api/src/test_clock_control.c b/tests/drivers/clock_control/clock_control_api/src/test_clock_control.c index a5d11419264..1623335618d 100644 --- a/tests/drivers/clock_control/clock_control_api/src/test_clock_control.c +++ b/tests/drivers/clock_control/clock_control_api/src/test_clock_control.c @@ -9,53 +9,13 @@ LOG_MODULE_REGISTER(test); #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_clock) -#include +#include "nrf_device_subsys.h" +#elif DT_HAS_COMPAT_STATUS_OKAY(espressif_esp32_rtc) +#include "esp32_device_subsys.h" +#else +#error "Unsupported board" #endif -struct device_subsys_data { - clock_control_subsys_t subsys; - uint32_t startup_us; -}; - -struct device_data { - const struct device *dev; - const struct device_subsys_data *subsys_data; - uint32_t subsys_cnt; -}; - -#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_clock) -static const struct device_subsys_data subsys_data[] = { - { - .subsys = CLOCK_CONTROL_NRF_SUBSYS_HF, - .startup_us = - IS_ENABLED(CONFIG_SOC_SERIES_NRF91X) ? - 3000 : 500 - }, -#ifndef CONFIG_SOC_NRF52832 - /* On nrf52832 LF clock cannot be stopped because it leads - * to RTC COUNTER register reset and that is unexpected by - * system clock which is disrupted and may hang in the test. - */ - { - .subsys = CLOCK_CONTROL_NRF_SUBSYS_LF, - .startup_us = (CLOCK_CONTROL_NRF_K32SRC == - NRF_CLOCK_LFCLK_RC) ? 1000 : 500000 - } -#endif /* !CONFIG_SOC_NRF52832 */ -}; -#endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_clock) */ - -static const struct device_data devices[] = { -#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_clock) - { - .dev = DEVICE_DT_GET_ONE(nordic_nrf_clock), - .subsys_data = subsys_data, - .subsys_cnt = ARRAY_SIZE(subsys_data) - } -#endif -}; - - typedef void (*test_func_t)(const struct device *dev, clock_control_subsys_t subsys, uint32_t startup_us); @@ -194,7 +154,9 @@ static bool async_capable(const struct device *dev, clock_control_subsys_t subsy int err; err = clock_control_async_on(dev, subsys, async_capable_callback, NULL); - if (err < 0) { + if (err == -ENOSYS) { + ztest_test_skip(); + } else if (err < 0) { printk("failed %d", err); return false; } diff --git a/tests/drivers/clock_control/clock_control_api/testcase.yaml b/tests/drivers/clock_control/clock_control_api/testcase.yaml index 356893f400f..f14e57971ab 100644 --- a/tests/drivers/clock_control/clock_control_api/testcase.yaml +++ b/tests/drivers/clock_control/clock_control_api/testcase.yaml @@ -1,8 +1,16 @@ +common: + tags: + - drivers + - clock_control tests: + drivers.clock.clock_control_api_default: + platform_allow: + - esp32_devkitc_wroom/esp32/procpu + - esp32_devkitc_wrover/esp32/procpu + - esp32c3_devkitm + - esp32s2_saola + - esp32s3_devkitm/esp32s3/procpu drivers.clock.clock_control_nrf5: - tags: - - drivers - - clock_control platform_allow: - nrf51dk/nrf51822 - nrf52dk/nrf52832 @@ -12,9 +20,6 @@ tests: integration_platforms: - nrf51dk/nrf51822 drivers.clock.clock_control_nrf5_lfclk_rc: - tags: - - drivers - - clock_control platform_allow: - nrf51dk/nrf51822 - nrf52dk/nrf52832