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