Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 1 | /* |
| 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 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 | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 35 | int 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 Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 45 | #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 Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 51 | #if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 52 | int err; |
| 53 | |
| 54 | if (0 != (err = arm_ethosu_timing_adapter_init())) { |
| 55 | return err; |
| 56 | } |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 57 | #endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */ |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 58 | |
| 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 Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | void platform_release(void) |
| 73 | { |
| 74 | __disable_irq(); |
| 75 | } |
| 76 | |
| 77 | void platform_name(char* name, size_t size) |
| 78 | { |
| 79 | strncpy(name, DESIGN_NAME, size); |
| 80 | } |