blob: af854d79e1d21763b3a41a9f3955a4fba8aff3cd [file] [log] [blame]
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +00001/*
Kshitij Sisodia5385a642024-01-17 13:29:43 +00002 * SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or its affiliates
3 * <open-source-office@arm.com> SPDX-License-Identifier: Apache-2.0
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +00004 *
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 Sisodia4cc40212022-04-08 09:54:53 +010035/* Platform name */
36static const char* s_platform_name = DESIGN_NAME;
37
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000038int platform_init(void)
39{
40 SystemCoreClockUpdate(); /* From start up code */
41
42 /* UART init - will enable valid use of printf (stdout
43 * re-directed at this UART (UART0) */
44 UartStdOutInit();
45
46 info("%s: complete\n", __FUNCTION__);
47
Isabella Gottardiee4920b2022-02-25 14:29:32 +000048#if defined(ARM_NPU)
49
50 int state;
51
52 /* If the platform has timing adapter blocks along with Ethos-U core
53 * block, initialise them here. */
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000054#if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
Isabella Gottardiee4920b2022-02-25 14:29:32 +000055 int err;
56
57 if (0 != (err = arm_ethosu_timing_adapter_init())) {
58 return err;
59 }
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000060#endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */
Isabella Gottardiee4920b2022-02-25 14:29:32 +000061
62 /* If Arm Ethos-U NPU is to be used, we initialise it here */
63 if (0 != (state = arm_ethosu_npu_init())) {
64 return state;
65 }
66
67#endif /* ARM_NPU */
68
69 /* Print target design info */
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010070 info("Target system design: %s\n", s_platform_name);
Isabella Gottardiee4920b2022-02-25 14:29:32 +000071
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000072 return 0;
73}
74
75void platform_release(void)
76{
77 __disable_irq();
78}
79
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010080const char* platform_name(void)
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000081{
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010082 return s_platform_name;
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000083}