blob: e0af9807f1a70754ed56c5dcb30a10e4a475380d [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,
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020058 ETHOSU_PMU_MAC_ACTIVE,
59 ETHOSU_PMU_MAC_ACTIVE_8BIT,
60 ETHOSU_PMU_MAC_ACTIVE_16BIT,
61 ETHOSU_PMU_MAC_DPU_ACTIVE,
62 ETHOSU_PMU_MAC_STALLED_BY_WD_ACC,
63 ETHOSU_PMU_MAC_STALLED_BY_WD,
64 ETHOSU_PMU_MAC_STALLED_BY_ACC,
65 ETHOSU_PMU_MAC_STALLED_BY_IB,
Diqing Zhong25e2c812020-04-27 13:47:25 +020066 ETHOSU_PMU_MAC_ACTIVE_32BIT,
Douglas Trohaf6a85da2020-05-11 11:45:28 +020067 ETHOSU_PMU_MAC_STALLED_BY_INT_W,
68 ETHOSU_PMU_MAC_STALLED_BY_INT_ACC,
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020069 ETHOSU_PMU_AO_ACTIVE,
70 ETHOSU_PMU_AO_ACTIVE_8BIT,
71 ETHOSU_PMU_AO_ACTIVE_16BIT,
72 ETHOSU_PMU_AO_STALLED_BY_OFMP_OB,
73 ETHOSU_PMU_AO_STALLED_BY_OFMP,
74 ETHOSU_PMU_AO_STALLED_BY_OB,
75 ETHOSU_PMU_AO_STALLED_BY_ACC_IB,
76 ETHOSU_PMU_AO_STALLED_BY_ACC,
77 ETHOSU_PMU_AO_STALLED_BY_IB,
78 ETHOSU_PMU_WD_ACTIVE,
79 ETHOSU_PMU_WD_STALLED,
80 ETHOSU_PMU_WD_STALLED_BY_WS,
81 ETHOSU_PMU_WD_STALLED_BY_WD_BUF,
82 ETHOSU_PMU_WD_PARSE_ACTIVE,
83 ETHOSU_PMU_WD_PARSE_STALLED,
84 ETHOSU_PMU_WD_PARSE_STALLED_IN,
85 ETHOSU_PMU_WD_PARSE_STALLED_OUT,
Diqing Zhong25e2c812020-04-27 13:47:25 +020086 ETHOSU_PMU_WD_TRANS_WS,
87 ETHOSU_PMU_WD_TRANS_WB,
88 ETHOSU_PMU_WD_TRANS_DW0,
89 ETHOSU_PMU_WD_TRANS_DW1,
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020090 ETHOSU_PMU_AXI0_RD_TRANS_ACCEPTED,
91 ETHOSU_PMU_AXI0_RD_TRANS_COMPLETED,
92 ETHOSU_PMU_AXI0_RD_DATA_BEAT_RECEIVED,
93 ETHOSU_PMU_AXI0_RD_TRAN_REQ_STALLED,
94 ETHOSU_PMU_AXI0_WR_TRANS_ACCEPTED,
95 ETHOSU_PMU_AXI0_WR_TRANS_COMPLETED_M,
96 ETHOSU_PMU_AXI0_WR_TRANS_COMPLETED_S,
97 ETHOSU_PMU_AXI0_WR_DATA_BEAT_WRITTEN,
98 ETHOSU_PMU_AXI0_WR_TRAN_REQ_STALLED,
99 ETHOSU_PMU_AXI0_WR_DATA_BEAT_STALLED,
100 ETHOSU_PMU_AXI0_ENABLED_CYCLES,
101 ETHOSU_PMU_AXI0_RD_STALL_LIMIT,
102 ETHOSU_PMU_AXI0_WR_STALL_LIMIT,
103 ETHOSU_PMU_AXI1_RD_TRANS_ACCEPTED,
104 ETHOSU_PMU_AXI1_RD_TRANS_COMPLETED,
105 ETHOSU_PMU_AXI1_RD_DATA_BEAT_RECEIVED,
106 ETHOSU_PMU_AXI1_RD_TRAN_REQ_STALLED,
107 ETHOSU_PMU_AXI1_WR_TRANS_ACCEPTED,
108 ETHOSU_PMU_AXI1_WR_TRANS_COMPLETED_M,
109 ETHOSU_PMU_AXI1_WR_TRANS_COMPLETED_S,
110 ETHOSU_PMU_AXI1_WR_DATA_BEAT_WRITTEN,
111 ETHOSU_PMU_AXI1_WR_TRAN_REQ_STALLED,
112 ETHOSU_PMU_AXI1_WR_DATA_BEAT_STALLED,
113 ETHOSU_PMU_AXI1_ENABLED_CYCLES,
114 ETHOSU_PMU_AXI1_RD_STALL_LIMIT,
115 ETHOSU_PMU_AXI1_WR_STALL_LIMIT,
116 ETHOSU_PMU_AXI_LATENCY_ANY,
117 ETHOSU_PMU_AXI_LATENCY_32,
118 ETHOSU_PMU_AXI_LATENCY_64,
119 ETHOSU_PMU_AXI_LATENCY_128,
120 ETHOSU_PMU_AXI_LATENCY_256,
121 ETHOSU_PMU_AXI_LATENCY_512,
122 ETHOSU_PMU_AXI_LATENCY_1024,
123
124 ETHOSU_PMU_SENTINEL // End-marker (not event)
125};
126
127extern PMU_Ethosu_ctrl_Type *ethosu_pmu_ctrl;
128extern PMU_Ethosu_cntr_Type *ethosu_pmu_cntr;
129extern PMU_Ethosu_evnt_Type *ethosu_pmu_evnt;
130
131#define ETHOSU_PMU_CTRL_ENABLE_Msk (0x0001)
132#define ETHOSU_PMU_CTRL_EVENTCNT_RESET_Msk (0x0002)
133#define ETHOSU_PMU_CTRL_CYCCNT_RESET_Msk (0x0004)
134#define ETHOSU_PMU_CNT1_Msk (1UL << 0)
135#define ETHOSU_PMU_CNT2_Msk (1UL << 1)
136#define ETHOSU_PMU_CNT3_Msk (1UL << 2)
137#define ETHOSU_PMU_CNT4_Msk (1UL << 3)
138#define ETHOSU_PMU_CCNT_Msk (1UL << 31)
Bhavik Patel4e8dbf52020-06-15 10:09:28 +0200139#define ETHOSU_PMCCNTR_CFG_START_EVENT_MASK (0x3FF)
140#define ETHOSU_PMCCNTR_CFG_STOP_EVENT_MASK (0x3FF << 16)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200141
142/* Transpose functions between HW-event-type and event-id*/
143enum ethosu_pmu_event_type pmu_event_type(uint32_t);
144uint32_t pmu_event_value(enum ethosu_pmu_event_type);
145
146// CMSIS ref API
147/** \brief PMU Functions */
148
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200149static inline void ETHOSU_PMU_Enable(void);
150static inline void ETHOSU_PMU_Disable(void);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200151
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200152static inline void ETHOSU_PMU_Set_EVTYPER(uint32_t num, enum ethosu_pmu_event_type type);
153static inline enum ethosu_pmu_event_type ETHOSU_PMU_Get_EVTYPER(uint32_t num);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200154
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200155static inline void ETHOSU_PMU_CYCCNT_Reset(void);
156static inline void ETHOSU_PMU_EVCNTR_ALL_Reset(void);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200157
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200158static inline void ETHOSU_PMU_CNTR_Enable(uint32_t mask);
159static inline void ETHOSU_PMU_CNTR_Disable(uint32_t mask);
160static inline uint32_t ETHOSU_PMU_CNTR_Status();
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200161
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200162static inline uint64_t ETHOSU_PMU_Get_CCNTR(void);
163static inline void ETHOSU_PMU_Set_CCNTR(uint64_t val);
164static inline uint32_t ETHOSU_PMU_Get_EVCNTR(uint32_t num);
165static inline void ETHOSU_PMU_Set_EVCNTR(uint32_t num, uint32_t val);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200166
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200167static inline uint32_t ETHOSU_PMU_Get_CNTR_OVS(void);
168static inline void ETHOSU_PMU_Set_CNTR_OVS(uint32_t mask);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200169
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200170static inline void ETHOSU_PMU_Set_CNTR_IRQ_Enable(uint32_t mask);
171static inline void ETHOSU_PMU_Set_CNTR_IRQ_Disable(uint32_t mask);
172static inline uint32_t ETHOSU_PMU_Get_IRQ_Enable();
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200173
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200174static inline void ETHOSU_PMU_CNTR_Increment(uint32_t mask);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200175
176/**
177 \brief Enable the PMU
178*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200179static inline void ETHOSU_PMU_Enable(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200180{
181 ethosu_pmu_ctrl->PMCR |= ETHOSU_PMU_CTRL_ENABLE_Msk;
182}
183
184/**
185 \brief Disable the PMU
186*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200187static inline void ETHOSU_PMU_Disable(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200188{
189 ethosu_pmu_ctrl->PMCR &= ~ETHOSU_PMU_CTRL_ENABLE_Msk;
190}
191
192/**
193 \brief Set event to count for PMU eventer counter
194 \param [in] num Event counter (0-ETHOSU_PMU_NCOUNTERS) to configure
195 \param [in] type Event to count
196*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200197static inline void ETHOSU_PMU_Set_EVTYPER(uint32_t num, enum ethosu_pmu_event_type type)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200198{
199 (*ethosu_pmu_evnt)[num] = pmu_event_value(type);
200}
201
202/**
203 \brief Get event to count for PMU eventer counter
204 \param [in] num Event counter (0-ETHOSU_PMU_NCOUNTERS) to configure
205 \return type Event to count
206*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200207static inline enum ethosu_pmu_event_type ETHOSU_PMU_Get_EVTYPER(uint32_t num)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200208{
209 return pmu_event_type((*ethosu_pmu_evnt)[num]);
210}
211
212/**
213 \brief Reset cycle counter
214*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200215static inline void ETHOSU_PMU_CYCCNT_Reset(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200216{
217 ethosu_pmu_ctrl->PMCR |= ETHOSU_PMU_CTRL_CYCCNT_RESET_Msk;
218}
219
220/**
221 \brief Reset all event counters
222*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200223static inline void ETHOSU_PMU_EVCNTR_ALL_Reset(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200224{
225 ethosu_pmu_ctrl->PMCR |= ETHOSU_PMU_CTRL_EVENTCNT_RESET_Msk;
226}
227
228/**
229 \brief Enable counters
230 \param [in] mask Counters to enable
231 \note Enables one or more of the following:
232 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
233 - cycle counter (bit 31)
234*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200235static inline void ETHOSU_PMU_CNTR_Enable(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200236{
237 ethosu_pmu_ctrl->PMCNTENSET = mask;
238}
239
240/**
241 \brief Disable counters
242 \param [in] mask Counters to disable
243 \note Disables one or more of the following:
244 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
245 - cycle counter (bit 31)
246*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200247static inline void ETHOSU_PMU_CNTR_Disable(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200248{
249 ethosu_pmu_ctrl->PMCNTENCLR = mask;
250}
251
252/**
253 \brief Determine counters activation
254
255 \return Event count
256 \param [in] mask Counters to enable
257 \return a bitmask where bit-set means:
258 - event counters activated (bit 0-ETHOSU_PMU_NCOUNTERS)
259 - cycle counter activate (bit 31)
260 \note ETHOSU specific. Usage breaks CMSIS complience
261*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200262static inline uint32_t ETHOSU_PMU_CNTR_Status()
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200263{
264 return ethosu_pmu_ctrl->PMCNTENSET;
265}
266
267/**
268 \brief Read cycle counter (64 bit)
269 \return Cycle count
270 \note Two HW 32-bit registers that can increment independently in-between reads.
271 To work-around raciness yet still avoid turning
272 off the event both are read as one value twice. If the latter read
273 is not greater than the former, it means overflow of LSW without
274 incrementing MSW has occurred, in which case the former value is used.
275*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200276static inline uint64_t ETHOSU_PMU_Get_CCNTR(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200277{
278 uint64_t val1 = ethosu_pmu_ctrl->PMCCNTR;
279 uint64_t val2 = ethosu_pmu_ctrl->PMCCNTR;
280
281 if (val2 > val1)
282 {
283 return val2;
284 }
285 return val1;
286}
287
288/**
289 \brief Set cycle counter (64 bit)
290 \param [in] val Conter value
291 \note Two HW 32-bit registers that can increment independently in-between reads.
292 To work-around raciness, counter is temporary disabled if enabled.
293 \note ETHOSU specific. Usage breaks CMSIS complience
294*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200295static inline void ETHOSU_PMU_Set_CCNTR(uint64_t val)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200296{
297 uint32_t mask = ETHOSU_PMU_CNTR_Status();
298
299 if (mask & ETHOSU_PMU_CCNT_Msk)
300 {
301 ETHOSU_PMU_CNTR_Disable(ETHOSU_PMU_CCNT_Msk);
302 }
303
304 ethosu_pmu_ctrl->PMCCNTR = val;
305
306 if (mask & ETHOSU_PMU_CCNT_Msk)
307 {
308 ETHOSU_PMU_CNTR_Enable(ETHOSU_PMU_CCNT_Msk);
309 }
310}
311
312/**
313 \brief Read event counter
314 \param [in] num Event counter (0-ETHOSU_PMU_NCOUNTERS)
315 \return Event count
316*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200317static inline uint32_t ETHOSU_PMU_Get_EVCNTR(uint32_t num)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200318{
319 return (*ethosu_pmu_cntr)[num];
320}
321
322/**
323 \brief Set event counter value
324 \param [in] num Event counter (0-ETHOSU_PMU_NCOUNTERS)
325 \param [in] val Conter value
326 \note ETHOSU specific. Usage breaks CMSIS complience
327*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200328static inline void ETHOSU_PMU_Set_EVCNTR(uint32_t num, uint32_t val)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200329{
330 (*ethosu_pmu_cntr)[num] = val;
331}
332/**
333 \brief Read counter overflow status
334 \return Counter overflow status bits for the following:
335 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS))
336 - cycle counter (bit 31)
337*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200338static inline uint32_t ETHOSU_PMU_Get_CNTR_OVS(void)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200339{
340 return ethosu_pmu_ctrl->PMOVSSET;
341}
342
343/**
344 \brief Clear counter overflow status
345 \param [in] mask Counter overflow status bits to clear
346 \note Clears overflow status bits for one or more of the following:
347 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
348 - cycle counter (bit 31)
349*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200350static inline void ETHOSU_PMU_Set_CNTR_OVS(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200351{
352 ethosu_pmu_ctrl->PMOVSCLR = mask;
353}
354
355/**
356 \brief Enable counter overflow interrupt request
357 \param [in] mask Counter overflow interrupt request bits to set
358 \note Sets overflow interrupt request bits for one or more of the following:
359 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
360 - cycle counter (bit 31)
361*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200362static inline void ETHOSU_PMU_Set_CNTR_IRQ_Enable(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200363{
364 ethosu_pmu_ctrl->PMINTSET = mask;
365}
366
367/**
368 \brief Disable counter overflow interrupt request
369 \param [in] mask Counter overflow interrupt request bits to clear
370 \note Clears overflow interrupt request bits for one or more of the following:
371 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
372 - cycle counter (bit 31)
373*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200374static inline void ETHOSU_PMU_Set_CNTR_IRQ_Disable(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200375{
376 ethosu_pmu_ctrl->PMINTCLR = mask;
377}
378
379/**
380 \brief Get counters overflow interrupt request stiinings
381 \return mask Counter overflow interrupt request bits
382 \note Sets overflow interrupt request bits for one or more of the following:
383 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
384 - cycle counter (bit 31)
385 \note ETHOSU specific. Usage breaks CMSIS complience
386*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200387static inline uint32_t ETHOSU_PMU_Get_IRQ_Enable()
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200388{
389 return ethosu_pmu_ctrl->PMINTSET;
390}
391
392/**
393 \brief Software increment event counter
394 \param [in] mask Counters to increment
395 - event counters (bit 0-ETHOSU_PMU_NCOUNTERS)
396 - cycle counter (bit 31)
397 \note Software increment bits for one or more event counters.
398*/
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200399static inline void ETHOSU_PMU_CNTR_Increment(uint32_t mask)
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200400{
401 uint32_t cntrs_active = ETHOSU_PMU_CNTR_Status();
402
403 if (mask & ETHOSU_PMU_CCNT_Msk)
404 {
405 if (mask & ETHOSU_PMU_CCNT_Msk)
406 {
407 ETHOSU_PMU_CNTR_Disable(ETHOSU_PMU_CCNT_Msk);
408 ethosu_pmu_ctrl->PMCCNTR = ETHOSU_PMU_Get_CCNTR() + 1;
409 if (cntrs_active & ETHOSU_PMU_CCNT_Msk)
410 {
411 ETHOSU_PMU_CNTR_Enable(ETHOSU_PMU_CCNT_Msk);
412 }
413 }
414 }
415 for (int i = 0; i < ETHOSU_PMU_NCOUNTERS; i++)
416 {
417 uint32_t cntr = (0x0001 << i);
418
419 if (mask & cntr)
420 {
421 ETHOSU_PMU_CNTR_Disable(cntr);
422 (*ethosu_pmu_cntr)[i]++;
423 if (cntrs_active & cntr)
424 {
425 ETHOSU_PMU_CNTR_Enable(cntr);
426 }
427 }
428 }
429}
430
Bhavik Patel4e8dbf52020-06-15 10:09:28 +0200431/**
432 \brief Set start event number for the cycle counter
433 \param [in] start_event Event number
434 - Start event (bits [9:0])
435 \note Sets the event number that starts the cycle counter.
436 - Event number in the range 0..1023
437*/
438static inline void ETHOSU_PMU_PMCCNTR_CFG_Set_Start_Event(uint32_t start_event)
439{
440 uint32_t val = ethosu_pmu_ctrl->PMCCNTR_CFG & ~ETHOSU_PMCCNTR_CFG_START_EVENT_MASK;
441 ethosu_pmu_ctrl->PMCCNTR_CFG = val | (start_event & ETHOSU_PMCCNTR_CFG_START_EVENT_MASK);
442}
443
444/**
445 \brief Set stop event number for the cycle counter
446 \param [in] stop_event Event number
447 - Stop event (bits [25:16])
448 \note Sets the event number that stops the cycle counter.
449 - Event number in the range 0..1023
450*/
451static inline void ETHOSU_PMU_PMCCNTR_CFG_Set_Stop_Event(uint32_t stop_event)
452{
453 uint32_t val = ethosu_pmu_ctrl->PMCCNTR_CFG & ~ETHOSU_PMCCNTR_CFG_STOP_EVENT_MASK;
454 ethosu_pmu_ctrl->PMCCNTR_CFG = val | ((stop_event << 16) & ETHOSU_PMCCNTR_CFG_STOP_EVENT_MASK);
455}
456
Kristofer Jonsson537c71c2020-05-05 14:17:22 +0200457#ifdef __cplusplus
458}
459#endif
460
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200461#endif /* PMU_ETHOSU_H */