MLECO-2984: Refactor components

* Use UART component from Ethos-U core-platform
* Components as cmake project

Change-Id: I053f3a59800abc20216e6a4df8555db357e3f21d
Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
diff --git a/source/hal/components/ethosu_ta_init/CMakeLists.txt b/source/hal/components/ethosu_ta_init/CMakeLists.txt
new file mode 100644
index 0000000..b5f94c1
--- /dev/null
+++ b/source/hal/components/ethosu_ta_init/CMakeLists.txt
@@ -0,0 +1,67 @@
+#----------------------------------------------------------------------------
+#  Copyright (c) 2022 Arm Limited. All rights reserved.
+#  SPDX-License-Identifier: Apache-2.0
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#----------------------------------------------------------------------------
+
+#########################################################
+#  Ethos-U NPU timing adapter initialization library    #
+#########################################################
+
+cmake_minimum_required(VERSION 3.15.6)
+set(ETHOS_U_NPU_TA_COMPONENT ethosu_ta_init_component)
+project(${ETHOS_U_NPU_TA_COMPONENT}
+    DESCRIPTION     "Ethos-U NPU timing adapter initialization library"
+    LANGUAGES       C CXX ASM)
+
+# Checks
+## If a TA config file is provided, we generate a settings file
+if (DEFINED TA_CONFIG_FILE)
+    include(${TA_CONFIG_FILE})
+    set(TA_SETTINGS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/timing_adapter_settings.template)
+    configure_file("${TA_SETTINGS_TEMPLATE}" "${SOURCE_GEN_DIR}/timing_adapter_settings.h")
+endif()
+
+## Timing adapter Source path check
+if (NOT DEFINED ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH)
+    message(FATAL_ERROR "ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH should"
+            " be defined when ETHOS_U_NPU_ENABLED=${ETHOS_U_NPU_ENABLED}")
+endif()
+
+add_subdirectory(${ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH} ${CMAKE_BINARY_DIR}/timing_adapter)
+
+# Create static library
+add_library(${ETHOS_U_NPU_TA_COMPONENT} STATIC)
+
+## Include directories - public
+target_include_directories(${ETHOS_U_NPU_TA_COMPONENT}
+    PUBLIC
+    include
+    ${SOURCE_GEN_DIR})
+
+## Component sources
+target_sources(${ETHOS_U_NPU_TA_COMPONENT}
+    PRIVATE
+    ethosu_ta_init.c)
+
+## Add dependencies
+target_link_libraries(${ETHOS_U_NPU_TA_COMPONENT} PUBLIC
+    timing_adapter
+    log)
+
+# Display status
+message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
+message(STATUS "*******************************************************")
+message(STATUS "Library                                : " ${ETHOS_U_NPU_TA_COMPONENT})
+message(STATUS "*******************************************************")
diff --git a/source/hal/components/ethosu_ta_init/cmake/templates/timing_adapter_settings.template b/source/hal/components/ethosu_ta_init/cmake/templates/timing_adapter_settings.template
new file mode 100644
index 0000000..5b6c43d
--- /dev/null
+++ b/source/hal/components/ethosu_ta_init/cmake/templates/timing_adapter_settings.template
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2021 Arm Limited. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Auto-generated file
+// ** DO NOT EDIT **
+
+#ifndef TIMING_ADAPTER_SETTINGS_H
+#define TIMING_ADAPTER_SETTINGS_H
+
+#cmakedefine TA0_BASE       (@TA0_BASE@)
+#cmakedefine TA1_BASE       (@TA1_BASE@)
+
+/* Timing adapter settings for AXI0 */
+#if defined(TA0_BASE)
+
+#define TA0_MAXR           (@TA0_MAXR@)
+#define TA0_MAXW           (@TA0_MAXW@)
+#define TA0_MAXRW          (@TA0_MAXRW@)
+#define TA0_RLATENCY       (@TA0_RLATENCY@)
+#define TA0_WLATENCY       (@TA0_WLATENCY@)
+#define TA0_PULSE_ON       (@TA0_PULSE_ON@)
+#define TA0_PULSE_OFF      (@TA0_PULSE_OFF@)
+#define TA0_BWCAP          (@TA0_BWCAP@)
+#define TA0_PERFCTRL       (@TA0_PERFCTRL@)
+#define TA0_PERFCNT        (@TA0_PERFCNT@)
+#define TA0_MODE           (@TA0_MODE@)
+#define TA0_HISTBIN        (@TA0_HISTBIN@)
+#define TA0_HISTCNT        (@TA0_HISTCNT@)
+
+#endif /* defined(TA0_BASE) */
+
+/* Timing adapter settings for AXI1 */
+#if defined(TA1_BASE)
+
+#define TA1_MAXR           (@TA1_MAXR@)
+#define TA1_MAXW           (@TA1_MAXW@)
+#define TA1_MAXRW          (@TA1_MAXRW@)
+#define TA1_RLATENCY       (@TA1_RLATENCY@)
+#define TA1_WLATENCY       (@TA1_WLATENCY@)
+#define TA1_PULSE_ON       (@TA1_PULSE_ON@)
+#define TA1_PULSE_OFF      (@TA1_PULSE_OFF@)
+#define TA1_BWCAP          (@TA1_BWCAP@)
+#define TA1_PERFCTRL       (@TA1_PERFCTRL@)
+#define TA1_PERFCNT        (@TA1_PERFCNT@)
+#define TA1_MODE           (@TA1_MODE@)
+#define TA1_HISTBIN        (@TA1_HISTBIN@)
+#define TA1_HISTCNT        (@TA1_HISTCNT@)
+
+#endif /* defined(TA1_BASE) */
+
+#endif /* TIMING_ADAPTER_SETTINGS_H */
diff --git a/source/hal/components/ethosu_ta_init/ethosu_ta_init.c b/source/hal/components/ethosu_ta_init/ethosu_ta_init.c
index 26eeb5c..323ab73 100644
--- a/source/hal/components/ethosu_ta_init/ethosu_ta_init.c
+++ b/source/hal/components/ethosu_ta_init/ethosu_ta_init.c
@@ -19,8 +19,6 @@
 
 #include "log_macros.h"                 /* Logging functions */
 
-#if defined(TIMING_ADAPTER_AVAILABLE)
-
 #include "timing_adapter.h"             /* Arm Ethos-U timing adapter driver header */
 #include "timing_adapter_settings.h"    /* Arm Ethos-U timing adapter settings */
 
@@ -82,5 +80,3 @@
 
     return 0;
 }
-
-#endif /* TIMING_ADAPTER_AVAILABLE */
diff --git a/source/hal/components/ethosu_ta_init/include/ethosu_ta_init.h b/source/hal/components/ethosu_ta_init/include/ethosu_ta_init.h
index 2ab7fb2..7e6df6c 100644
--- a/source/hal/components/ethosu_ta_init/include/ethosu_ta_init.h
+++ b/source/hal/components/ethosu_ta_init/include/ethosu_ta_init.h
@@ -17,14 +17,10 @@
 #ifndef ETHOS_U_TA_INIT_H
 #define ETHOS_U_TA_INIT_H
 
-#if defined(ARM_NPU) && defined(TIMING_ADAPTER_AVAILABLE)
-
 /**
  * @brief   Initialises the Arm Ethos-U NPU timing adapter
  * @return  0 if successful, error code otherwise
  **/
 int arm_ethosu_timing_adapter_init(void);
 
-#endif /* ARM_NPU && TIMING_ADAPTER_AVAILABLE */
-
 #endif /* ETHOS_U_TA_INIT_H */