Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 1 | /* |
Kshitij Sisodia | 5385a64 | 2024-01-17 13:29:43 +0000 | [diff] [blame] | 2 | * SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or its affiliates |
| 3 | * <open-source-office@arm.com> SPDX-License-Identifier: Apache-2.0 |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 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 Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 21 | #include "peripheral_memmap.h" |
| 22 | |
| 23 | |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 24 | #include <string.h> |
| 25 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 26 | #if defined(ARM_NPU) |
| 27 | #include "ethosu_npu_init.h" |
| 28 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 29 | #if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 30 | #include "ethosu_ta_init.h" |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 31 | #endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */ |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 32 | |
| 33 | #endif /* ARM_NPU */ |
| 34 | |
Kshitij Sisodia | 4cc4021 | 2022-04-08 09:54:53 +0100 | [diff] [blame] | 35 | /* Platform name */ |
| 36 | static const char* s_platform_name = DESIGN_NAME; |
| 37 | |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 38 | int 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 Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 48 | #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 Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 54 | #if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 55 | int err; |
| 56 | |
| 57 | if (0 != (err = arm_ethosu_timing_adapter_init())) { |
| 58 | return err; |
| 59 | } |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 60 | #endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */ |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 61 | |
| 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 Sisodia | 4cc4021 | 2022-04-08 09:54:53 +0100 | [diff] [blame] | 70 | info("Target system design: %s\n", s_platform_name); |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 71 | |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | void platform_release(void) |
| 76 | { |
| 77 | __disable_irq(); |
| 78 | } |
| 79 | |
Kshitij Sisodia | 4cc4021 | 2022-04-08 09:54:53 +0100 | [diff] [blame] | 80 | const char* platform_name(void) |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 81 | { |
Kshitij Sisodia | 4cc4021 | 2022-04-08 09:54:53 +0100 | [diff] [blame] | 82 | return s_platform_name; |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 83 | } |