blob: 6a89c6140d37137f4ce8bcfc3358017bfbf3a109 [file] [log] [blame]
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +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#include "platform_drivers.h"
19
20#include "uart_stdout.h"
21#include <string.h>
22
Isabella Gottardiee4920b2022-02-25 14:29:32 +000023#if defined(ARM_NPU)
24#include "ethosu_npu_init.h"
25
26#if defined(TIMING_ADAPTER_AVAILABLE)
27#include "ethosu_ta_init.h"
28#endif /* TIMING_ADAPTER_AVAILABLE */
29
30#endif /* ARM_NPU */
31
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000032int platform_init(void)
33{
34 SystemCoreClockUpdate(); /* From start up code */
35
36 /* UART init - will enable valid use of printf (stdout
37 * re-directed at this UART (UART0) */
38 UartStdOutInit();
39
40 info("%s: complete\n", __FUNCTION__);
41
Isabella Gottardiee4920b2022-02-25 14:29:32 +000042#if defined(ARM_NPU)
43
44 int state;
45
46 /* If the platform has timing adapter blocks along with Ethos-U core
47 * block, initialise them here. */
48#if defined(TIMING_ADAPTER_AVAILABLE)
49 int err;
50
51 if (0 != (err = arm_ethosu_timing_adapter_init())) {
52 return err;
53 }
54#endif /* TIMING_ADAPTER_AVAILABLE */
55
56 /* If Arm Ethos-U NPU is to be used, we initialise it here */
57 if (0 != (state = arm_ethosu_npu_init())) {
58 return state;
59 }
60
61#endif /* ARM_NPU */
62
63 /* Print target design info */
64 info("Target system design: %s\n", DESIGN_NAME);
65
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000066 return 0;
67}
68
69void platform_release(void)
70{
71 __disable_irq();
72}
73
74void platform_name(char* name, size_t size)
75{
76 strncpy(name, DESIGN_NAME, size);
77}