blob: 300a44a67483eb5f5fd017b8eefa54c3df4c5c4c [file] [log] [blame]
Kristofer Jonsson49bdee82020-04-06 13:21:21 +02001/*
2 * Copyright (c) 2019-2020 Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020019#ifndef PMU_ETHOSU_H
20#define PMU_ETHOSU_H
21
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020022#include <stdint.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020028#define ETHOSU_PMU_NCOUNTERS 4
29
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020030typedef volatile struct
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020031{
Kristofer Jonsson537c71c2020-05-05 14:17:22 +020032 uint32_t PMCR;
33 uint32_t PMCNTENSET;
34 uint32_t PMCNTENCLR;
35 uint32_t PMOVSSET;
36 uint32_t PMOVSCLR;
37 uint32_t PMINTSET;
38 uint32_t PMINTCLR;
39 uint64_t PMCCNTR;
40 uint32_t PMCCNTR_CFG;
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020041} PMU_Ethosu_ctrl_Type;
42
43typedef uint32_t PMU_Ethosu_cntr_Type[ETHOSU_PMU_NCOUNTERS];
44typedef uint32_t PMU_Ethosu_evnt_Type[ETHOSU_PMU_NCOUNTERS];
45
46/** \brief HW Supported ETHOSU PMU Events
47 *
48 * Note: These values are symbolic. Actual HW-values may change. I.e. always use API
49 * to set/get actual event-type value.
50 * */
51enum ethosu_pmu_event_type
52{
Diqing Zhong25e2c812020-04-27 13:47:25 +020053 ETHOSU_PMU_NO_EVENT = 0,
54 ETHOSU_PMU_CYCLE,
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020055 ETHOSU_PMU_NPU_IDLE,
Douglas Trohaf6a85da2020-05-11 11:45:28 +020056 ETHOSU_PMU_CC_STALLED_ON_BLOCKDEP,
57 ETHOSU_PMU_CC_STALLED_ON_SHRAM_RECONFIG,
Douglas Troha2407e962020-06-15 14:31:45 +020058 ETHOSU_PMU_NPU_ACTIVE,
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020059 ETHOSU_PMU_MAC_ACTIVE,
60 ETHOSU_PMU_MAC_ACTIVE_8BIT,
61 ETHOSU_PMU_MAC_ACTIVE_16BIT,
62 ETHOSU_PMU_MAC_DPU_ACTIVE,
63 ETHOSU_PMU_MAC_STALLED_BY_WD_ACC,
64 ETHOSU_PMU_MAC_STALLED_BY_WD,
65 ETHOSU_PMU_MAC_STALLED_BY_ACC,
66 ETHOSU_PMU_MAC_STALLED_BY_IB,
Diqing Zhong25e2c812020-04-27 13:47:25 +020067 ETHOSU_PMU_MAC_ACTIVE_32BIT,
Douglas Trohaf6a85da2020-05-11 11:45:28 +020068 ETHOSU_PMU_MAC_STALLED_BY_INT_W,
69 ETHOSU_PMU_MAC_STALLED_BY_INT_ACC,
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020070 ETHOSU_PMU_AO_ACTIVE,
71 ETHOSU_PMU_AO_ACTIVE_8BIT,
72 ETHOSU_PMU_AO_ACTIVE_16BIT,
73 ETHOSU_PMU_AO_STALLED_BY_OFMP_OB,
74 ETHOSU_PMU_AO_STALLED_BY_OFMP,
75 ETHOSU_PMU_AO_STALLED_BY_OB,
76 ETHOSU_PMU_AO_STALLED_BY_ACC_IB,
77 ETHOSU_PMU_AO_STALLED_BY_ACC,
78 ETHOSU_PMU_AO_STALLED_BY_IB,
79 ETHOSU_PMU_WD_ACTIVE,
80 ETHOSU_PMU_WD_STALLED,
81 ETHOSU_PMU_WD_STALLED_BY_WS,
82 ETHOSU_PMU_WD_STALLED_BY_WD_BUF,
83 ETHOSU_PMU_WD_PARSE_ACTIVE,
84 ETHOSU_PMU_WD_PARSE_STALLED,
85 ETHOSU_PMU_WD_PARSE_STALLED_IN,
86 ETHOSU_PMU_WD_PARSE_STALLED_OUT,
Diqing Zhong25e2c812020-04-27 13:47:25 +020087 ETHOSU_PMU_WD_TRANS_WS,
88 ETHOSU_PMU_WD_TRANS_WB,
89 ETHOSU_PMU_WD_TRANS_DW0,
90 ETHOSU_PMU_WD_TRANS_DW1,
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020091 ETHOSU_PMU_AXI0_RD_TRANS_ACCEPTED,
92 ETHOSU_PMU_AXI0_RD_TRANS_COMPLETED,
93 ETHOSU_PMU_AXI0_RD_DATA_BEAT_RECEIVED,
94 ETHOSU_PMU_AXI0_RD_TRAN_REQ_STALLED,
95 ETHOSU_PMU_AXI0_WR_TRANS_ACCEPTED,
96 ETHOSU_PMU_AXI0_WR_TRANS_COMPLETED_M,
97 ETHOSU_PMU_AXI0_WR_TRANS_COMPLETED_S,
98 ETHOSU_PMU_AXI0_WR_DATA_BEAT_WRITTEN,
99 ETHOSU_PMU_AXI0_WR_TRAN_REQ_STALLED,
100 ETHOSU_PMU_AXI0_WR_DATA_BEAT_STALLED,
101 ETHOSU_PMU_AXI0_ENABLED_CYCLES,
102 ETHOSU_PMU_AXI0_RD_STALL_LIMIT,
103 ETHOSU_PMU_AXI0_WR_STALL_LIMIT,
104 ETHOSU_PMU_AXI1_RD_TRANS_ACCEPTED,
105 ETHOSU_PMU_AXI1_RD_TRANS_COMPLETED,
106 ETHOSU_PMU_AXI1_RD_DATA_BEAT_RECEIVED,
107 ETHOSU_PMU_AXI1_RD_TRAN_REQ_STALLED,
108 ETHOSU_PMU_AXI1_WR_TRANS_ACCEPTED,
109 ETHOSU_PMU_AXI1_WR_TRANS_COMPLETED_M,
110 ETHOSU_PMU_AXI1_WR_TRANS_COMPLETED_S,
111 ETHOSU_PMU_AXI1_WR_DATA_BEAT_WRITTEN,
112 ETHOSU_PMU_AXI1_WR_TRAN_REQ_STALLED,
113 ETHOSU_PMU_AXI1_WR_DATA_BEAT_STALLED,
114 ETHOSU_PMU_AXI1_ENABLED_CYCLES,
115 ETHOSU_PMU_AXI1_RD_STALL_LIMIT,
116 ETHOSU_PMU_AXI1_WR_STALL_LIMIT,
117 ETHOSU_PMU_AXI_LATENCY_ANY,
118 ETHOSU_PMU_AXI_LATENCY_32,
119 ETHOSU_PMU_AXI_LATENCY_64,
120 ETHOSU_PMU_AXI_LATENCY_128,
121 ETHOSU_PMU_AXI_LATENCY_256,
122 ETHOSU_PMU_AXI_LATENCY_512,
123 ETHOSU_PMU_AXI_LATENCY_1024,
124
125 ETHOSU_PMU_SENTINEL // End-marker (not event)
126};
127
128extern PMU_Ethosu_ctrl_Type *ethosu_pmu_ctrl;
129extern PMU_Ethosu_cntr_Type *ethosu_pmu_cntr;
130extern PMU_Ethosu_evnt_Type *ethosu_pmu_evnt;
131
132#define ETHOSU_PMU_CTRL_ENABLE_Msk (0x0001)
133#define ETHOSU_PMU_CTRL_EVENTCNT_RESET_Msk (0x0002)
134#define ETHOSU_PMU_CTRL_CYCCNT_RESET_Msk (0x0004)
135#define ETHOSU_PMU_CNT1_Msk (1UL << 0)
136#define ETHOSU_PMU_CNT2_Msk (1UL << 1)
137#define ETHOSU_PMU_CNT3_Msk (1UL << 2)
138#define ETHOSU_PMU_CNT4_Msk (1UL << 3)
139#define ETHOSU_PMU_CCNT_Msk (1UL << 31)
Bhavik Patel4e8dbf52020-06-15 10:09:28 +0200140#define ETHOSU_PMCCNTR_CFG_START_EVENT_MASK (0x3FF)
141#define ETHOSU_PMCCNTR_CFG_STOP_EVENT_MASK (0x3FF << 16)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200142
143/* Transpose functions between HW-event-type and event-id*/
144enum ethosu_pmu_event_type pmu_event_type(uint32_t);
145uint32_t pmu_event_value(enum ethosu_pmu_event_type);
146
147// CMSIS ref API
148/** \brief PMU Functions */
149
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200150static inline void ETHOSU_PMU_Enable(void);
151static inline void ETHOSU_PMU_Disable(void);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200152
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200153static inline void ETHOSU_PMU_Set_EVTYPER(uint32_t num, enum ethosu_pmu_event_type type);
154static inline enum ethosu_pmu_event_type ETHOSU_PMU_Get_EVTYPER(uint32_t num);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200155
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200156static inline void ETHOSU_PMU_CYCCNT_Reset(void);
157static inline void ETHOSU_PMU_EVCNTR_ALL_Reset(void);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200158
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200159static inline void ETHOSU_PMU_CNTR_Enable(uint32_t mask);
160static inline void ETHOSU_PMU_CNTR_Disable(uint32_t mask);
161static inline uint32_t ETHOSU_PMU_CNTR_Status();
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200162
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200163static inline uint64_t ETHOSU_PMU_Get_CCNTR(void);
164static inline void ETHOSU_PMU_Set_CCNTR(uint64_t val);
165static inline uint32_t ETHOSU_PMU_Get_EVCNTR(uint32_t num);
166static inline void ETHOSU_PMU_Set_EVCNTR(uint32_t num, uint32_t val);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200167
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200168static inline uint32_t ETHOSU_PMU_Get_CNTR_OVS(void);
169static inline void ETHOSU_PMU_Set_CNTR_OVS(uint32_t mask);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200170
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200171static inline void ETHOSU_PMU_Set_CNTR_IRQ_Enable(uint32_t mask);
172static inline void ETHOSU_PMU_Set_CNTR_IRQ_Disable(uint32_t mask);
173static inline uint32_t ETHOSU_PMU_Get_IRQ_Enable();
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200174
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200175static inline void ETHOSU_PMU_CNTR_Increment(uint32_t mask);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200176
177/**
178 \brief Enable the PMU
179*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200180static inline void ETHOSU_PMU_Enable(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200181{
182 ethosu_pmu_ctrl->PMCR |= ETHOSU_PMU_CTRL_ENABLE_Msk;
183}
184
185/**
186 \brief Disable the PMU
187*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200188static inline void ETHOSU_PMU_Disable(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200189{
190 ethosu_pmu_ctrl->PMCR &= ~ETHOSU_PMU_CTRL_ENABLE_Msk;
191}
192
193/**
194 \brief Set event to count for PMU eventer counter
195 \param [in] num Event counter (0-ETHOSU_PMU_NCOUNTERS) to configure
196 \param [in] type Event to count
197*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200198static inline void ETHOSU_PMU_Set_EVTYPER(uint32_t num, enum ethosu_pmu_event_type type)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200199{
200 (*ethosu_pmu_evnt)[num] = pmu_event_value(type);
201}
202
203/**
204 \brief Get event to count for PMU eventer counter
205 \param [in] num Event counter (0-ETHOSU_PMU_NCOUNTERS) to configure
206 \return type Event to count
207*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200208static inline enum ethosu_pmu_event_type ETHOSU_PMU_Get_EVTYPER(uint32_t num)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200209{
210 return pmu_event_type((*ethosu_pmu_evnt)[num]);
211}
212
213/**
214 \brief Reset cycle counter
215*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200216static inline void ETHOSU_PMU_CYCCNT_Reset(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200217{
218 ethosu_pmu_ctrl->PMCR |= ETHOSU_PMU_CTRL_CYCCNT_RESET_Msk;
219}
220
221/**
222 \brief Reset all event counters
223*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200224static inline void ETHOSU_PMU_EVCNTR_ALL_Reset(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200225{
226 ethosu_pmu_ctrl->PMCR |= ETHOSU_PMU_CTRL_EVENTCNT_RESET_Msk;
227}
228
229/**
230 \brief Enable counters
231 \param [in] mask Counters to enable
232 \note Enables one or more of the following:
233 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
234 - cycle counter (bit 31)
235*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200236static inline void ETHOSU_PMU_CNTR_Enable(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200237{
238 ethosu_pmu_ctrl->PMCNTENSET = mask;
239}
240
241/**
242 \brief Disable counters
243 \param [in] mask Counters to disable
244 \note Disables one or more of the following:
245 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
246 - cycle counter (bit 31)
247*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200248static inline void ETHOSU_PMU_CNTR_Disable(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200249{
250 ethosu_pmu_ctrl->PMCNTENCLR = mask;
251}
252
253/**
254 \brief Determine counters activation
255
256 \return Event count
257 \param [in] mask Counters to enable
258 \return a bitmask where bit-set means:
259 - event counters activated (bit 0-ETHOSU_PMU_NCOUNTERS)
260 - cycle counter activate (bit 31)
261 \note ETHOSU specific. Usage breaks CMSIS complience
262*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200263static inline uint32_t ETHOSU_PMU_CNTR_Status()
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200264{
265 return ethosu_pmu_ctrl->PMCNTENSET;
266}
267
268/**
269 \brief Read cycle counter (64 bit)
270 \return Cycle count
271 \note Two HW 32-bit registers that can increment independently in-between reads.
272 To work-around raciness yet still avoid turning
273 off the event both are read as one value twice. If the latter read
274 is not greater than the former, it means overflow of LSW without
275 incrementing MSW has occurred, in which case the former value is used.
276*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200277static inline uint64_t ETHOSU_PMU_Get_CCNTR(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200278{
279 uint64_t val1 = ethosu_pmu_ctrl->PMCCNTR;
280 uint64_t val2 = ethosu_pmu_ctrl->PMCCNTR;
281
282 if (val2 > val1)
283 {
284 return val2;
285 }
286 return val1;
287}
288
289/**
290 \brief Set cycle counter (64 bit)
291 \param [in] val Conter value
292 \note Two HW 32-bit registers that can increment independently in-between reads.
293 To work-around raciness, counter is temporary disabled if enabled.
294 \note ETHOSU specific. Usage breaks CMSIS complience
295*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200296static inline void ETHOSU_PMU_Set_CCNTR(uint64_t val)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200297{
298 uint32_t mask = ETHOSU_PMU_CNTR_Status();
299
300 if (mask & ETHOSU_PMU_CCNT_Msk)
301 {
302 ETHOSU_PMU_CNTR_Disable(ETHOSU_PMU_CCNT_Msk);
303 }
304
305 ethosu_pmu_ctrl->PMCCNTR = val;
306
307 if (mask & ETHOSU_PMU_CCNT_Msk)
308 {
309 ETHOSU_PMU_CNTR_Enable(ETHOSU_PMU_CCNT_Msk);
310 }
311}
312
313/**
314 \brief Read event counter
315 \param [in] num Event counter (0-ETHOSU_PMU_NCOUNTERS)
316 \return Event count
317*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200318static inline uint32_t ETHOSU_PMU_Get_EVCNTR(uint32_t num)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200319{
320 return (*ethosu_pmu_cntr)[num];
321}
322
323/**
324 \brief Set event counter value
325 \param [in] num Event counter (0-ETHOSU_PMU_NCOUNTERS)
326 \param [in] val Conter value
327 \note ETHOSU specific. Usage breaks CMSIS complience
328*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200329static inline void ETHOSU_PMU_Set_EVCNTR(uint32_t num, uint32_t val)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200330{
331 (*ethosu_pmu_cntr)[num] = val;
332}
333/**
334 \brief Read counter overflow status
335 \return Counter overflow status bits for the following:
336 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS))
337 - cycle counter (bit 31)
338*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200339static inline uint32_t ETHOSU_PMU_Get_CNTR_OVS(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200340{
341 return ethosu_pmu_ctrl->PMOVSSET;
342}
343
344/**
345 \brief Clear counter overflow status
346 \param [in] mask Counter overflow status bits to clear
347 \note Clears overflow status bits for one or more of the following:
348 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
349 - cycle counter (bit 31)
350*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200351static inline void ETHOSU_PMU_Set_CNTR_OVS(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200352{
353 ethosu_pmu_ctrl->PMOVSCLR = mask;
354}
355
356/**
357 \brief Enable counter overflow interrupt request
358 \param [in] mask Counter overflow interrupt request bits to set
359 \note Sets overflow interrupt request bits for one or more of the following:
360 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
361 - cycle counter (bit 31)
362*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200363static inline void ETHOSU_PMU_Set_CNTR_IRQ_Enable(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200364{
365 ethosu_pmu_ctrl->PMINTSET = mask;
366}
367
368/**
369 \brief Disable counter overflow interrupt request
370 \param [in] mask Counter overflow interrupt request bits to clear
371 \note Clears overflow interrupt request bits for one or more of the following:
372 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
373 - cycle counter (bit 31)
374*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200375static inline void ETHOSU_PMU_Set_CNTR_IRQ_Disable(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200376{
377 ethosu_pmu_ctrl->PMINTCLR = mask;
378}
379
380/**
381 \brief Get counters overflow interrupt request stiinings
382 \return mask Counter overflow interrupt request bits
383 \note Sets overflow interrupt request bits for one or more of the following:
384 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
385 - cycle counter (bit 31)
386 \note ETHOSU specific. Usage breaks CMSIS complience
387*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200388static inline uint32_t ETHOSU_PMU_Get_IRQ_Enable()
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200389{
390 return ethosu_pmu_ctrl->PMINTSET;
391}
392
393/**
394 \brief Software increment event counter
395 \param [in] mask Counters to increment
396 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
397 - cycle counter (bit 31)
398 \note Software increment bits for one or more event counters.
399*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200400static inline void ETHOSU_PMU_CNTR_Increment(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200401{
402 uint32_t cntrs_active = ETHOSU_PMU_CNTR_Status();
403
404 if (mask & ETHOSU_PMU_CCNT_Msk)
405 {
406 if (mask & ETHOSU_PMU_CCNT_Msk)
407 {
408 ETHOSU_PMU_CNTR_Disable(ETHOSU_PMU_CCNT_Msk);
409 ethosu_pmu_ctrl->PMCCNTR = ETHOSU_PMU_Get_CCNTR() + 1;
410 if (cntrs_active & ETHOSU_PMU_CCNT_Msk)
411 {
412 ETHOSU_PMU_CNTR_Enable(ETHOSU_PMU_CCNT_Msk);
413 }
414 }
415 }
416 for (int i = 0; i < ETHOSU_PMU_NCOUNTERS; i++)
417 {
418 uint32_t cntr = (0x0001 << i);
419
420 if (mask & cntr)
421 {
422 ETHOSU_PMU_CNTR_Disable(cntr);
423 (*ethosu_pmu_cntr)[i]++;
424 if (cntrs_active & cntr)
425 {
426 ETHOSU_PMU_CNTR_Enable(cntr);
427 }
428 }
429 }
430}
431
Bhavik Patel4e8dbf52020-06-15 10:09:28 +0200432/**
433 \brief Set start event number for the cycle counter
434 \param [in] start_event Event number
435 - Start event (bits [9:0])
436 \note Sets the event number that starts the cycle counter.
437 - Event number in the range 0..1023
438*/
439static inline void ETHOSU_PMU_PMCCNTR_CFG_Set_Start_Event(uint32_t start_event)
440{
441 uint32_t val = ethosu_pmu_ctrl->PMCCNTR_CFG & ~ETHOSU_PMCCNTR_CFG_START_EVENT_MASK;
442 ethosu_pmu_ctrl->PMCCNTR_CFG = val | (start_event & ETHOSU_PMCCNTR_CFG_START_EVENT_MASK);
443}
444
445/**
446 \brief Set stop event number for the cycle counter
447 \param [in] stop_event Event number
448 - Stop event (bits [25:16])
449 \note Sets the event number that stops the cycle counter.
450 - Event number in the range 0..1023
451*/
452static inline void ETHOSU_PMU_PMCCNTR_CFG_Set_Stop_Event(uint32_t stop_event)
453{
454 uint32_t val = ethosu_pmu_ctrl->PMCCNTR_CFG & ~ETHOSU_PMCCNTR_CFG_STOP_EVENT_MASK;
455 ethosu_pmu_ctrl->PMCCNTR_CFG = val | ((stop_event << 16) & ETHOSU_PMCCNTR_CFG_STOP_EVENT_MASK);
456}
457
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200458#ifdef __cplusplus
459}
460#endif
461
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200462#endif /* PMU_ETHOSU_H */