Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +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 "ethosu_ta_init.h" |
| 19 | |
| 20 | #include "log_macros.h" /* Logging functions */ |
| 21 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 22 | #include "timing_adapter.h" /* Arm Ethos-U timing adapter driver header */ |
| 23 | #include "timing_adapter_settings.h" /* Arm Ethos-U timing adapter settings */ |
| 24 | |
| 25 | int arm_ethosu_timing_adapter_init(void) |
| 26 | { |
| 27 | #if defined(TA0_BASE) |
| 28 | struct timing_adapter ta_0; |
| 29 | struct timing_adapter_settings ta_0_settings = { |
| 30 | .maxr = TA0_MAXR, |
| 31 | .maxw = TA0_MAXW, |
| 32 | .maxrw = TA0_MAXRW, |
| 33 | .rlatency = TA0_RLATENCY, |
| 34 | .wlatency = TA0_WLATENCY, |
| 35 | .pulse_on = TA0_PULSE_ON, |
| 36 | .pulse_off = TA0_PULSE_OFF, |
| 37 | .bwcap = TA0_BWCAP, |
| 38 | .perfctrl = TA0_PERFCTRL, |
| 39 | .perfcnt = TA0_PERFCNT, |
| 40 | .mode = TA0_MODE, |
| 41 | .maxpending = 0, /* This is a read-only parameter */ |
| 42 | .histbin = TA0_HISTBIN, |
| 43 | .histcnt = TA0_HISTCNT}; |
| 44 | |
| 45 | if (0 != ta_init(&ta_0, TA0_BASE)) |
| 46 | { |
| 47 | printf_err("TA0 initialisation failed\n"); |
| 48 | return 1; |
| 49 | } |
| 50 | |
| 51 | ta_set_all(&ta_0, &ta_0_settings); |
| 52 | #endif /* defined (TA0_BASE) */ |
| 53 | |
| 54 | #if defined(TA1_BASE) |
| 55 | struct timing_adapter ta_1; |
| 56 | struct timing_adapter_settings ta_1_settings = { |
| 57 | .maxr = TA1_MAXR, |
| 58 | .maxw = TA1_MAXW, |
| 59 | .maxrw = TA1_MAXRW, |
| 60 | .rlatency = TA1_RLATENCY, |
| 61 | .wlatency = TA1_WLATENCY, |
| 62 | .pulse_on = TA1_PULSE_ON, |
| 63 | .pulse_off = TA1_PULSE_OFF, |
| 64 | .bwcap = TA1_BWCAP, |
| 65 | .perfctrl = TA1_PERFCTRL, |
| 66 | .perfcnt = TA1_PERFCNT, |
| 67 | .mode = TA1_MODE, |
| 68 | .maxpending = 0, /* This is a read-only parameter */ |
| 69 | .histbin = TA1_HISTBIN, |
| 70 | .histcnt = TA1_HISTCNT}; |
| 71 | |
| 72 | if (0 != ta_init(&ta_1, TA1_BASE)) |
| 73 | { |
| 74 | printf_err("TA1 initialisation failed\n"); |
| 75 | return 1; |
| 76 | } |
| 77 | |
| 78 | ta_set_all(&ta_1, &ta_1_settings); |
| 79 | #endif /* defined (TA1_BASE) */ |
| 80 | |
| 81 | return 0; |
| 82 | } |