alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 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 | |
| 22 | cmake_minimum_required(VERSION 3.15.6) |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 23 | set(PLATFORM_DRIVERS_TARGET platform_drivers) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 24 | project(${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) |
| 29 | if (NOT ${CMAKE_CROSSCOMPILING}) |
| 30 | message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.") |
| 31 | endif() |
| 32 | |
| 33 | # 2. Set the platform cmake descriptor file |
| 34 | if (NOT DEFINED PLATFORM_CMAKE_DESCRIPTOR_FILE) |
| 35 | set(PLATFORM_CMAKE_DESCRIPTOR_FILE |
alexander | cb8a987 | 2022-02-11 13:23:22 +0000 | [diff] [blame] | 36 | cmake/subsystem-profiles/${TARGET_SUBSYSTEM}.cmake |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 37 | CACHE PATH |
| 38 | "Platform's CMake descriptor file path") |
| 39 | endif() |
| 40 | |
| 41 | ## Include the platform cmake descriptor file |
| 42 | include(${PLATFORM_CMAKE_DESCRIPTOR_FILE}) |
| 43 | |
| 44 | # 3. Generate sources: |
| 45 | if (NOT DEFINED SOURCE_GEN_DIR) |
| 46 | set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp) |
| 47 | endif() |
| 48 | |
| 49 | set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_memmap.h.template) |
| 50 | set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_irqs.h.template) |
| 51 | set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/mem_regions.h.template) |
| 52 | |
| 53 | configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h") |
| 54 | configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h") |
| 55 | configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h") |
| 56 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 57 | # 4. Create static library |
| 58 | add_library(${PLATFORM_DRIVERS_TARGET} STATIC) |
| 59 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 60 | ## Include directories - private |
| 61 | target_include_directories(${PLATFORM_DRIVERS_TARGET} |
| 62 | PRIVATE |
| 63 | source) |
| 64 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 65 | ## Include directories - public |
| 66 | target_include_directories(${PLATFORM_DRIVERS_TARGET} |
| 67 | PUBLIC |
| 68 | include |
| 69 | ${SOURCE_GEN_DIR}) |
| 70 | |
| 71 | ## Platform sources |
| 72 | target_sources(${PLATFORM_DRIVERS_TARGET} |
| 73 | PRIVATE |
| 74 | source/device_mps3.c |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 75 | source/timer_mps3.c |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 76 | source/platform_drivers.c |
| 77 | source/glcd_mps3.c) |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 78 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 79 | ## Directory for additional components required by MPS3: |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 80 | if (NOT DEFINED COMPONENTS_DIR) |
| 81 | set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components) |
| 82 | endif() |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 83 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 84 | ## This target provides the following definitions for MPS3 specific behaviour |
| 85 | ## TODO: We should aim to remove this now with platform refactoring.. |
| 86 | target_compile_definitions(${PLATFORM_DRIVERS_TARGET} |
| 87 | PUBLIC |
| 88 | MPS3_PLATFORM |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 89 | ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ}) |
| 90 | |
| 91 | ## Platform component: uart |
| 92 | add_subdirectory(${DEPENDENCY_ROOT_DIR}/core-platform/drivers/uart ${CMAKE_BINARY_DIR}/uart) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 93 | |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 94 | # Add dependencies: |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 95 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 96 | log |
| 97 | cmsis_device |
| 98 | ethosu_uart_cmsdk_apb) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 99 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 100 | # If Ethos-U is enabled, we need the driver library too |
| 101 | if (ETHOS_U_NPU_ENABLED) |
| 102 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 103 | target_compile_definitions(${PLATFORM_DRIVERS_TARGET} |
| 104 | PUBLIC |
| 105 | ARM_NPU) |
| 106 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 107 | ## Platform component: Ethos-U initialization |
| 108 | add_subdirectory(${COMPONENTS_DIR}/ethosu_npu_init ${CMAKE_BINARY_DIR}/ethosu_npu_init) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 109 | |
| 110 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} |
| 111 | PUBLIC |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 112 | ethosu_npu_init_component) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 113 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame^] | 114 | 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 Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 124 | endif() |
| 125 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 126 | endif() |
| 127 | |
| 128 | # 5. Display status: |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 129 | message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) |
| 130 | message(STATUS "*******************************************************") |
| 131 | message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET}) |
| 132 | message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR}) |
| 133 | message(STATUS "*******************************************************") |