blob: f842b1c591f804e657a4dc79a068af81df0df0f2 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
Richard Burtonf32a86a2022-11-15 11:46:11 +00002 * SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
alexander3c798932021-03-26 21:42:19 +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#ifndef TIMER_MPS3_H
18#define TIMER_MPS3_H
19
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010020#include "platform_pmu.h"
21
alexander3c798932021-03-26 21:42:19 +000022#include <stdint.h>
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010023#include <stdbool.h>
24
25#if defined (ARM_NPU)
26 #include "ethosu_profiler.h" /* Arm Ethos-U NPU profiling functions. */
27#endif /* defined (ARM_NPU) */
alexander3c798932021-03-26 21:42:19 +000028
29/* Container for timestamp up-counters. */
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010030typedef struct mps3_pmu_counters_ {
alexander3c798932021-03-26 21:42:19 +000031 uint32_t counter_1Hz;
32 uint32_t counter_100Hz;
33
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000034 /* Running at FPGA clock rate. See get_mps3_core_clock(). */
alexander3c798932021-03-26 21:42:19 +000035 uint32_t counter_fpga;
36
37 /* Running at processor core's internal clock rate, triggered by SysTick. */
38 uint64_t counter_systick;
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010039} mps3_pmu_counters;
alexander3c798932021-03-26 21:42:19 +000040
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010041/**
42 * @brief Resets the counters.
43 */
44void platform_reset_counters(void);
45
46/**
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010047 * @brief Gets the current counter values.
48 * @param[out] Pointer to a pmu_counters object.
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010049 **/
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010050void platform_get_counters(pmu_counters* counters);
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000051
52/**
53 * @brief Gets the MPS3 core clock
54 * @return Clock rate in Hz expressed as 32 bit unsigned integer.
55 */
56uint32_t get_mps3_core_clock(void);
57
alexander3c798932021-03-26 21:42:19 +000058/**
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000059 * @brief System tick interrupt handler.
60 **/
61void SysTick_Handler(void);
62
alexander3c798932021-03-26 21:42:19 +000063#endif /* TIMER_MPS3_H */