blob: 6e9d80ed282497356b975187583d4fe387e2b6f3 [file] [log] [blame]
Kristofer Jonsson49bdee82020-04-06 13:21:21 +02001#
2# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the License); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an AS IS BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19cmake_minimum_required(VERSION 3.15.6)
20
21project(ethosu_core_driver VERSION 0.0.1)
22
23#
24# Build options
25#
26
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020027option(DRIVER_PMU_AUTOINIT "Enable PMU boot auto-initialization" OFF)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020028option(LOG_SUPPORT "Enable logging." ON)
29
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020030set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmsis" CACHE PATH "Path to CMSIS.")
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020031
32#
33# Global settings
34#
35
36if(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m0")
37 add_compile_definitions(CPU_CORTEX_M0)
38elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m3")
39 add_compile_definitions(CPU_CORTEX_M3)
40elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m33")
41 add_compile_definitions(CPU_CORTEX_M33)
42 add_compile_definitions(__DSP_PRESENT=1)
43elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m4")
44 add_compile_definitions(CPU_CORTEX_M4)
45elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m55")
46 add_compile_definitions(CPU_CORTEX_M55)
47 add_compile_definitions(__DSP_PRESENT=1)
48 add_compile_definitions(__FPU_PRESENT=1)
49elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m7")
50 add_compile_definitions(CPU_CORTEX_M7)
51else()
52 message(FATAL_ERROR "Unsupported compiler ${CMAKE_SYSTEM_PROCESSOR}.")
53endif()
54
55# Enable logging support
56if (LOG_SUPPORT)
57 add_compile_definitions(LOG_ENABLED)
58endif()
59
60# Make include directories available for current- and sub projects
61include_directories(include src)
62include_directories(${CMSIS_PATH}/CMSIS/Core/Include)
63
64#
65# Build libraries
66#
67
68# Build driver library
69add_library(ethosu_core_driver STATIC)
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020070target_include_directories(ethosu_core_driver PUBLIC include)
71target_sources(ethosu_core_driver PRIVATE src/ethosu_driver.c src/ethosu_device.c src/ethosu_pmu.c)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020072
73# Build PMU
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020074if (DRIVER_PMU_AUTOINIT)
75 set(NPU_PMCR "0x0" CACHE STRING "Register control b0 = CNT_EN = Enable counters (RW), b1 = EVENT_CNT_RST = Reset event counters (WO), b2 = CYCLE_CNT_RST = Reset cycle counter (WO), b[15:11] = Number of event counters (RO)")
76 set(NPU_PMCNTENSET "0x0" CACHE STRING "Bit k enables event counter k. k=31 enables the cycle counter. Read value is current status.")
77 set(NPU_PMCNTENCLR "0x0" CACHE STRING "Bit k disables event counter k. k=31 disables the cycle counter. Reda value is current status.")
78 set(NPU_PMOVSSET "0x0" CACHE STRING "Overflow detection set. Bit k is for counter k. k=31 is cycle counter.")
79 set(NPU_PMOVSCLR "0x0" CACHE STRING "Overflow detection clear. Bit k is for counter k. k=31 is cycle counter.")
80 set(NPU_PMINTSET "0x0" CACHE STRING "Interrupt set. Bit k is for counter k. k=31 is cycle counter.")
81 set(NPU_PMINTCLR "0x8003" CACHE STRING "Interrupt clear. Bit k is for counter k. k=31 is cycle counter.")
82 set(NPU_PMCCNTR "0x0" CACHE STRING "Cycle counter, 48 bits value")
83 set(NPU_PMCCNTR_CFG "0x0" CACHE STRING "b[9:0] Start Event – this event number starts the cycle counter b[25:16] Stop Event – this event number stops the cycle counter")
84
85 target_compile_definitions(ethosu_core_driver PRIVATE
86 PMU_AUTOINIT
87 INIT_PMCR=${NPU_PMCR}
88 INIT_PMCNTENSET=${NPU_PMCNTENSET}
89 INIT_PMCNTENCLR=${NPU_PMCNTENCLR}
90 INIT_PMOVSSET=${NPU_PMOVSSET}
91 INIT_PMOVSCLR=${NPU_PMOVSCLR}
92 INIT_PMINTSET=${NPU_PMINTSET}
93 INIT_PMINTCLR=${NPU_PMINTCLR}
94 INIT_PMCCNTR=${NPU_PMCCNTR}
95 INIT_PMCCNTR_CFG=${NPU_PMCCNTR_CFG}
96 )
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020097endif()
98
99#
100# Print build status
101#
102
103message(STATUS "*******************************************************")
104message(STATUS "PROJECT_NAME : ${PROJECT_NAME}")
105message(STATUS "CMAKE_SYSTEM_PROCESSOR : ${CMAKE_SYSTEM_PROCESSOR}")
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200106message(STATUS "LOG_SUPPORT : ${LOG_SUPPORT}")
107message(STATUS "CMSIS_PATH : ${CMSIS_PATH}")
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200108message(STATUS "*******************************************************")