blob: 7ef4ed48ccc13b722bde49e9753250446827d013 [file] [log] [blame]
alexander31ae9f02022-02-10 16:15:54 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2022 Arm Limited. All rights reserved.
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#----------------------------------------------------------------------------
17
18#########################################################
19# MPS3 platform support library #
20#########################################################
21
22cmake_minimum_required(VERSION 3.15.6)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000023set(PLATFORM_DRIVERS_TARGET platform_drivers)
alexander31ae9f02022-02-10 16:15:54 +000024project(${PLATFORM_DRIVERS_TARGET}
25 DESCRIPTION "Platform drivers library for MPS3 FPGA/FVP targets"
26 LANGUAGES C CXX ASM)
27
28# 1. We should be cross-compiling (MPS3 taregt only runs Cortex-M targets)
29if (NOT ${CMAKE_CROSSCOMPILING})
30 message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.")
31endif()
32
33# 2. Set the platform cmake descriptor file
34if (NOT DEFINED PLATFORM_CMAKE_DESCRIPTOR_FILE)
35 set(PLATFORM_CMAKE_DESCRIPTOR_FILE
alexandercb8a9872022-02-11 13:23:22 +000036 cmake/subsystem-profiles/${TARGET_SUBSYSTEM}.cmake
alexander31ae9f02022-02-10 16:15:54 +000037 CACHE PATH
38 "Platform's CMake descriptor file path")
39endif()
40
41## Include the platform cmake descriptor file
42include(${PLATFORM_CMAKE_DESCRIPTOR_FILE})
43
44# 3. Generate sources:
45if (NOT DEFINED SOURCE_GEN_DIR)
46 set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp)
47endif()
48
49set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_memmap.h.template)
50set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_irqs.h.template)
51set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/mem_regions.h.template)
52
53configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h")
54configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h")
55configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h")
56
alexander31ae9f02022-02-10 16:15:54 +000057# 4. Create static library
58add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
59
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000060## Include directories - private
61target_include_directories(${PLATFORM_DRIVERS_TARGET}
62 PRIVATE
63 source)
64
alexander31ae9f02022-02-10 16:15:54 +000065## Include directories - public
66target_include_directories(${PLATFORM_DRIVERS_TARGET}
67 PUBLIC
68 include
69 ${SOURCE_GEN_DIR})
70
71## Platform sources
72target_sources(${PLATFORM_DRIVERS_TARGET}
73 PRIVATE
74 source/device_mps3.c
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000075 source/timer_mps3.c
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000076 source/platform_drivers.c
77 source/glcd_mps3.c)
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000078
Isabella Gottardiee4920b2022-02-25 14:29:32 +000079## Directory for additional components required by MPS3:
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000080if (NOT DEFINED COMPONENTS_DIR)
81 set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components)
82endif()
alexander31ae9f02022-02-10 16:15:54 +000083
alexander31ae9f02022-02-10 16:15:54 +000084## This target provides the following definitions for MPS3 specific behaviour
85## TODO: We should aim to remove this now with platform refactoring..
86target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
87 PUBLIC
88 MPS3_PLATFORM
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000089 ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ})
90
91## Platform component: uart
92add_subdirectory(${DEPENDENCY_ROOT_DIR}/core-platform/drivers/uart ${CMAKE_BINARY_DIR}/uart)
alexander31ae9f02022-02-10 16:15:54 +000093
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000094# Add dependencies:
alexander31ae9f02022-02-10 16:15:54 +000095target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000096 log
97 cmsis_device
98 ethosu_uart_cmsdk_apb)
alexander31ae9f02022-02-10 16:15:54 +000099
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000100# If Ethos-U is enabled, we need the driver library too
101if (ETHOS_U_NPU_ENABLED)
102
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000103 target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
104 PUBLIC
105 ARM_NPU)
106
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000107 ## Platform component: Ethos-U initialization
108 add_subdirectory(${COMPONENTS_DIR}/ethosu_npu_init ${CMAKE_BINARY_DIR}/ethosu_npu_init)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000109
110 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
111 PUBLIC
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000112 ethosu_npu_init_component)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000113
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000114 if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
115 ## Platform component: Ethos-U timing adapter initialization
116 add_subdirectory(${COMPONENTS_DIR}/ethosu_ta_init ${CMAKE_BINARY_DIR}/ethosu_ta_init)
117
118 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
119 PUBLIC
120 ethosu_ta_init_component)
121 target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
122 PUBLIC
123 ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000124 endif()
125
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000126endif()
127
128# 5. Display status:
alexander31ae9f02022-02-10 16:15:54 +0000129message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
130message(STATUS "*******************************************************")
131message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
132message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
133message(STATUS "*******************************************************")