blob: 1ef4ff543637a7086508c74cf4b2ab3c64cbf79a [file] [log] [blame]
Isabella Gottardiee4920b2022-02-25 14:29:32 +00001/*
Richard Burtonf32a86a2022-11-15 11:46:11 +00002 * SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
Isabella Gottardiee4920b2022-02-25 14:29:32 +00003 * 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 Gottardiee4920b2022-02-25 14:29:32 +000022#include "timing_adapter.h" /* Arm Ethos-U timing adapter driver header */
23#include "timing_adapter_settings.h" /* Arm Ethos-U timing adapter settings */
24
25int 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
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010045 if (0 != ta_init(&ta_0, TA0_BASE)) {
Isabella Gottardiee4920b2022-02-25 14:29:32 +000046 printf_err("TA0 initialisation failed\n");
47 return 1;
48 }
49
50 ta_set_all(&ta_0, &ta_0_settings);
Kshitij Sisodia5385a642024-01-17 13:29:43 +000051 info("Configured TA0@0x%" PRIx32 "\n", TA0_BASE);
Isabella Gottardiee4920b2022-02-25 14:29:32 +000052#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);
Kshitij Sisodia5385a642024-01-17 13:29:43 +000079 info("Configured TA1@0x%" PRIx32 "\n", TA1_BASE);
Isabella Gottardiee4920b2022-02-25 14:29:32 +000080#endif /* defined (TA1_BASE) */
81
82 return 0;
83}