1# SPDX-FileCopyrightText: <text>Copyright 2022, 2024 Arm Limited and/or its
2# affiliates <open-source-office@arm.com></text>
3# SPDX-License-Identifier: Apache-2.0
4
5if(CONFIG_ARM_ETHOS_U AND CONFIG_MULTITHREADING)
6    set(ETHOSU_TARGET_NPU_CONFIG ${CONFIG_ARM_ETHOS_U_NPU_NAME})
7
8    # Mapping log level from Zephyr (none=0, err=1, wrn=2, inf=3, dbg=4) to
9    # Ethos-U driver (err=0, warn=1, info=2, debug=3)
10    set(ETHOSU_LOG_SEVERITY_MAP err err warning info debug)
11    list(LENGTH ETHOSU_LOG_SEVERITY_MAP ETHOSU_LOG_SEVERITY_MAP_LENGTH)
12
13    if (${CONFIG_ARM_ETHOS_U_LOG_LEVEL} EQUAL 0)
14        # The Ethos-U driver does not have a corresponding "none" log level. Disable logging instead.
15        set(ETHOSU_LOG_ENABLE OFF CACHE BOOL "")
16    elseif (${CONFIG_ARM_ETHOS_U_LOG_LEVEL} LESS "${ETHOSU_LOG_SEVERITY_MAP_LENGTH}")
17        list(GET ETHOSU_LOG_SEVERITY_MAP ${CONFIG_ARM_ETHOS_U_LOG_LEVEL} ETHOSU_LOG_SEVERITY)
18        set(ETHOSU_LOG_SEVERITY ${ETHOSU_LOG_SEVERITY} CACHE STRING "")
19    else()
20        set(ETHOSU_LOG_SEVERITY debug CACHE STRING "")
21    endif()
22
23    add_subdirectory(${ZEPHYR_CURRENT_MODULE_DIR} ethos-u-core-driver)
24
25    target_link_libraries(ethosu_core_driver PUBLIC
26       zephyr_interface)
27
28    zephyr_link_libraries(ethosu_core_driver)
29endif()
30