1 /*
2  * Copyright (C) 2019 ETH Zurich and University of Bologna
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /* Driver to control and configure the PULP event unit */
18 /* Author: Robert Balas (balasr@iis.ee.ethz.ch)
19  */
20 
21 #include <pulp_io.h>
22 #include <stdint.h>
23 #include "core-v-mcu-config.h"
24 #include "core-v-mcu-memory-map.h" //ToDo: this should be merged into config.h
25 #include "hal_soc_eu.h"
26 
soc_eu_mask_set(uint32_t offset,uint32_t mask)27 void soc_eu_mask_set(uint32_t offset, uint32_t mask)
28 {
29 	writew(mask, (uintptr_t)(SOC_EU_ADDR + offset));
30 }
31 
soc_eu_mask_get(uint32_t offset)32 uint32_t soc_eu_mask_get(uint32_t offset)
33 {
34 	return readw((uintptr_t)(SOC_EU_ADDR + offset));
35 }
36 
pulp_soc_eu_event_init()37 void pulp_soc_eu_event_init()
38 {
39 	/* deactivate all soc events */
40 	for (int i = 0; i < SOC_NB_EVENT_REGS; i++) {
41 		soc_eu_mask_set(SOC_FC_FIRST_MASK + i * 4, 0xffffffff);
42 	}
43 }
44