aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Svärd <jonny.svaerd@arm.com>2021-03-18 15:49:27 +0100
committerJonny Svärd <jonny.svaerd@arm.com>2021-03-24 10:14:54 +0100
commitd66709083f08b4c32792d4a93e1e5b3c6b913fb2 (patch)
tree05e278bd3d8102baddbd87ebe6b2ef2404533ac2
parentad2d25e46c7fa521790e1f0f1b72fc9969139751 (diff)
downloadethos-u-core-platform-d66709083f08b4c32792d4a93e1e5b3c6b913fb2.tar.gz
Use new timing adapter driver from core_software
Add basic skeleton to initialize timing adapters. See core_software/drivers/timing_adapter/include/timing_adapter.h for description of settings and API. Change-Id: I0884f8efc5735b1a837d45e0bb7c6612d329ad58
-rw-r--r--targets/corstone-300/CMakeLists.txt9
-rw-r--r--targets/corstone-300/target.cpp21
2 files changed, 27 insertions, 3 deletions
diff --git a/targets/corstone-300/CMakeLists.txt b/targets/corstone-300/CMakeLists.txt
index d41a7d3..7653926 100644
--- a/targets/corstone-300/CMakeLists.txt
+++ b/targets/corstone-300/CMakeLists.txt
@@ -52,6 +52,13 @@ set(TRUSTZONE_BUILD ON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target)
+set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs")
+set(ETHOSU_TARGET_NPU_TA_COUNT 2 CACHE INTERNAL "Number of timing adapters per NPU")
+
+target_compile_definitions(ethosu_target_common INTERFACE
+ ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT}
+ ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT})
+
# Linker script
ethosu_target_link_options(ethosu_target_link INTERFACE
LINK_FILE platform
@@ -64,7 +71,7 @@ target_sources(ethosu_target_startup INTERFACE
target.cpp)
target_compile_definitions(ethosu_core_driver PUBLIC ETHOSU)
-target_link_libraries(ethosu_target_startup INTERFACE ethosu_core_driver)
+target_link_libraries(ethosu_target_startup INTERFACE ethosu_core_driver timing_adapter)
###############################################################################
# Applications
diff --git a/targets/corstone-300/target.cpp b/targets/corstone-300/target.cpp
index 7c902d2..d5c44ea 100644
--- a/targets/corstone-300/target.cpp
+++ b/targets/corstone-300/target.cpp
@@ -26,11 +26,13 @@
#include <ethosu_driver.h>
#endif
+#include <timing_adapter.h>
+
#include "uart.h"
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
-#include <inttypes.h>
using namespace EthosU;
@@ -39,8 +41,10 @@ using namespace EthosU;
****************************************************************************/
#define ETHOSU_BASE_ADDRESS 0x48102000
+#define ETHOSU_IRQ 56
-#define ETHOSU_IRQ 56
+#define ETHOSU0_TA0_BASE_ADDRESS 0x48103000
+#define ETHOSU0_TA1_BASE_ADDRESS 0x48103200
/****************************************************************************
* Variables
@@ -53,6 +57,10 @@ __attribute__((aligned(16), section(".bss.ethosu_scratch"))) uint8_t ethosu_scra
#define ETHOSU_FAST_MEMORY_SIZE 0
#endif
+static uintptr_t ethosu_ta_base_addrs[ETHOSU_NPU_COUNT][ETHOSU_NPU_TA_COUNT] = {
+ {ETHOSU0_TA0_BASE_ADDRESS, ETHOSU0_TA1_BASE_ADDRESS}};
+struct timing_adapter ethosu_ta[ETHOSU_NPU_COUNT][ETHOSU_NPU_TA_COUNT];
+
/****************************************************************************
* Cache maintenance
****************************************************************************/
@@ -133,6 +141,15 @@ void targetSetup() {
// Initialize UART driver
uart_init();
+ // Initialize timing adapter(s)
+ for (int i = 0; i < ETHOSU_NPU_COUNT; i++) {
+ for (int j = 0; j < ETHOSU_NPU_TA_COUNT; j++) {
+ if (ta_init(&ethosu_ta[i][j], ethosu_ta_base_addrs[i][j])) {
+ printf("Failed to initialize timing-adapter %d for NPU %d\n", j, i);
+ }
+ }
+ }
+
#ifdef ETHOSU
// Initialize Ethos-U NPU driver
if (ethosu_init_v3(reinterpret_cast<void *>(ETHOSU_BASE_ADDRESS), ethosu_scratch, ETHOSU_FAST_MEMORY_SIZE, 1, 1)) {