alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 1 | /* |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 2 | * Copyright (c) 2021-2022 Arm Limited. All rights reserved. |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 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 | #ifndef TIMER_MPS3_H |
| 18 | #define TIMER_MPS3_H |
| 19 | |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame^] | 20 | #include "platform_pmu.h" |
| 21 | |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 22 | #include <stdint.h> |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame^] | 23 | #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) */ |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 28 | |
| 29 | /* Container for timestamp up-counters. */ |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame^] | 30 | typedef struct mps3_pmu_counters_ { |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 31 | uint32_t counter_1Hz; |
| 32 | uint32_t counter_100Hz; |
| 33 | |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 34 | /* Running at FPGA clock rate. See get_mps3_core_clock(). */ |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 35 | uint32_t counter_fpga; |
| 36 | |
| 37 | /* Running at processor core's internal clock rate, triggered by SysTick. */ |
| 38 | uint64_t counter_systick; |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame^] | 39 | } mps3_pmu_counters; |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 40 | |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame^] | 41 | /** |
| 42 | * @brief Resets the counters. |
| 43 | */ |
| 44 | void platform_reset_counters(void); |
| 45 | |
| 46 | /** |
| 47 | * @brief Gets the current counter values. |
| 48 | * @returns A populated instance of pmu_counters struct. |
| 49 | **/ |
| 50 | pmu_counters platform_get_counters(void); |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * @brief Gets the MPS3 core clock |
| 54 | * @return Clock rate in Hz expressed as 32 bit unsigned integer. |
| 55 | */ |
| 56 | uint32_t get_mps3_core_clock(void); |
| 57 | |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 58 | /** |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 59 | * @brief System tick interrupt handler. |
| 60 | **/ |
| 61 | void SysTick_Handler(void); |
| 62 | |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 63 | #endif /* TIMER_MPS3_H */ |