blob: 19c00572545a6140e40f0a609043691df71bac39 [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"
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000021#include "peripheral_memmap.h"
22
23
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000024#include <string.h>
25
Isabella Gottardiee4920b2022-02-25 14:29:32 +000026#if defined(ARM_NPU)
27#include "ethosu_npu_init.h"
28
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000029#if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
Isabella Gottardiee4920b2022-02-25 14:29:32 +000030#include "ethosu_ta_init.h"
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000031#endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */
Isabella Gottardiee4920b2022-02-25 14:29:32 +000032
33#endif /* ARM_NPU */
34
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000035int platform_init(void)
36{
37 SystemCoreClockUpdate(); /* From start up code */
38
39 /* UART init - will enable valid use of printf (stdout
40 * re-directed at this UART (UART0) */
41 UartStdOutInit();
42
43 info("%s: complete\n", __FUNCTION__);
44
Isabella Gottardiee4920b2022-02-25 14:29:32 +000045#if defined(ARM_NPU)
46
47 int state;
48
49 /* If the platform has timing adapter blocks along with Ethos-U core
50 * block, initialise them here. */
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000051#if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
Isabella Gottardiee4920b2022-02-25 14:29:32 +000052 int err;
53
54 if (0 != (err = arm_ethosu_timing_adapter_init())) {
55 return err;
56 }
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000057#endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */
Isabella Gottardiee4920b2022-02-25 14:29:32 +000058
59 /* If Arm Ethos-U NPU is to be used, we initialise it here */
60 if (0 != (state = arm_ethosu_npu_init())) {
61 return state;
62 }
63
64#endif /* ARM_NPU */
65
66 /* Print target design info */
67 info("Target system design: %s\n", DESIGN_NAME);
68
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000069 return 0;
70}
71
72void platform_release(void)
73{
74 __disable_irq();
75}
76
77void platform_name(char* name, size_t size)
78{
79 strncpy(name, DESIGN_NAME, size);
80}