1 | /* |
---|
2 | * soclib_xcu.h - soclib XCU driver API definition. |
---|
3 | * |
---|
4 | * Alain Greiner (2016) |
---|
5 | * |
---|
6 | * Copyright (c) UPMC Sorbonne Universites |
---|
7 | * |
---|
8 | * This file is part of ALMOS-MKH. |
---|
9 | * |
---|
10 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
11 | * under the terms of the GNU General Public License as published by |
---|
12 | * the Free Software Foundation; version 2.0 of the License. |
---|
13 | * |
---|
14 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | * General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | */ |
---|
23 | |
---|
24 | #ifndef _SOCLIB_XCU_H_ |
---|
25 | #define _SOCLIB_XCU_H_ |
---|
26 | |
---|
27 | #include <hal_types.h> |
---|
28 | #include <chdev.h> |
---|
29 | |
---|
30 | /****************************************************************************************** |
---|
31 | * SOCLIB_XCU Registers Mnemonics |
---|
32 | *****************************************************************************************/ |
---|
33 | |
---|
34 | #define XCU_WTI_REG 0 |
---|
35 | #define XCU_PTI_PER 1 |
---|
36 | #define XCU_PTI_VAL 2 |
---|
37 | #define XCU_PTI_ACK 3 |
---|
38 | #define XCU_MSK_PTI 4 |
---|
39 | #define XCU_MSK_PTI_ENABLE 5 |
---|
40 | #define XCU_MSK_PTI_DISABLE 6 |
---|
41 | #define XCU_PTI_ACTIVE 6 |
---|
42 | #define XCU_MSK_HWI 8 |
---|
43 | #define XCU_MSK_HWI_ENABLE 9 |
---|
44 | #define XCU_MSK_HWI_DISABLE 10 |
---|
45 | #define XCU_HWI_ACTIVE 10 |
---|
46 | #define XCU_MSK_WTI 12 |
---|
47 | #define XCU_MSK_WTI_ENABLE 13 |
---|
48 | #define XCU_MSK_WTI_DISABLE 14 |
---|
49 | #define XCU_WTI_ACTIVE 14 |
---|
50 | #define XCU_PRIO 15 |
---|
51 | #define XCU_CONFIG 16 |
---|
52 | |
---|
53 | /****************************************************************************************** |
---|
54 | * This function initialises the local XCU masks registers for a given |
---|
55 | * core identified by its local index. |
---|
56 | ****************************************************************************************** |
---|
57 | * @ icu : pointer on the local ICU chdev descriptor. |
---|
58 | * @ lid : core local index. |
---|
59 | *****************************************************************************************/ |
---|
60 | void soclib_xcu_init( chdev_t * icu, |
---|
61 | lid_t lid ); |
---|
62 | |
---|
63 | /****************************************************************************************** |
---|
64 | * This function set bits in the local XCU mask register for a given IRQ type, |
---|
65 | * and a given core. It must be called by a local thread. |
---|
66 | * Only the bits with "1" value in mask argument are set, other bits are not modified. |
---|
67 | * All input IRQs of requested types corresponding to "1" bits in mask are enabled. |
---|
68 | ****************************************************************************************** |
---|
69 | * @ icu : pointer on local XCU chdev descriptor |
---|
70 | * @ mask : mask value |
---|
71 | * @ type : HWI_TYPE / PTI_TYPE / WTI_TYPE |
---|
72 | * @ lid : local core index == output IRQ index |
---|
73 | *****************************************************************************************/ |
---|
74 | void soclib_xcu_enable_irq( chdev_t * icu, |
---|
75 | uint32_t mask, |
---|
76 | uint32_t type, |
---|
77 | lid_t lid ); |
---|
78 | |
---|
79 | /****************************************************************************************** |
---|
80 | * This function clear bits in the local XCU mask register for a given IRQ type, |
---|
81 | * and a given core. It must be called by a local thread. |
---|
82 | * Only the bits with "1" value in mask argument are cleared, other bits are not modified. |
---|
83 | * All input IRQs of requested types corresponding to "1" bits in mask are disabled. |
---|
84 | ****************************************************************************************** |
---|
85 | * @ icu : pointer on local XCU chdev descriptor |
---|
86 | * @ mask : mask value |
---|
87 | * @ type : HWI_TYPE / PTI_TYPE / WTI_TYPE |
---|
88 | * @ lid : local core index == output IRQ index |
---|
89 | *****************************************************************************************/ |
---|
90 | void soclib_xcu_disable_irq( chdev_t * icu, |
---|
91 | uint32_t mask, |
---|
92 | uint32_t type, |
---|
93 | lid_t lid ); |
---|
94 | |
---|
95 | /****************************************************************************************** |
---|
96 | * This function returns the values contained in the HWI/WTI/PTI mask registers for |
---|
97 | * a given core. It must be called by a local thread. |
---|
98 | ****************************************************************************************** |
---|
99 | * @ icu : pointer on local XCU chdev descriptor |
---|
100 | * @ lid : local core index == output IRQ index |
---|
101 | * @ hwi_mask : [out] HWI mask for selected core |
---|
102 | * @ wti_mask : [out] WTI mask for selected core |
---|
103 | * @ pti_mask : [out] PTI mask for selected core |
---|
104 | *****************************************************************************************/ |
---|
105 | void soclib_xcu_get_masks( chdev_t * icu, |
---|
106 | lid_t lid, |
---|
107 | uint32_t * hwi_mask, |
---|
108 | uint32_t * wti_mask, |
---|
109 | uint32_t * pti_mask ); |
---|
110 | |
---|
111 | /****************************************************************************************** |
---|
112 | * This function set the period value for a local XCU timer. |
---|
113 | ****************************************************************************************** |
---|
114 | * @ icu : pointer on the local XCU chdev descriptor |
---|
115 | * @ index : timer index = PTI index |
---|
116 | * @ period : Value to be written |
---|
117 | *****************************************************************************************/ |
---|
118 | void soclib_xcu_set_period( chdev_t * icu, |
---|
119 | uint32_t index, |
---|
120 | uint32_t period ); |
---|
121 | |
---|
122 | /****************************************************************************************** |
---|
123 | * This function acknowledge a PTI IRQ for a local XCU timer. |
---|
124 | ****************************************************************************************** |
---|
125 | * @ icu : pointer on the local XCU chdev descriptor |
---|
126 | * @ index : timer index = PTI index |
---|
127 | * @ the returned value in not significant, but acknowledge requires a read. |
---|
128 | *****************************************************************************************/ |
---|
129 | uint32_t soclib_xcu_ack_timer( chdev_t * icu, |
---|
130 | uint32_t index ); |
---|
131 | |
---|
132 | /****************************************************************************************** |
---|
133 | * This function returns the highest priority active interrupt of each type. |
---|
134 | * If no active interrupt => status == 0 / else => status = index + 1 |
---|
135 | ****************************************************************************************** |
---|
136 | * @ icu : pointer on the local XCU chdev descriptor |
---|
137 | * @ lid : core local index. |
---|
138 | * @ hwi_status : buffer for returned HWI status |
---|
139 | * @ wti_status : buffer for returned WTI status |
---|
140 | * @ pti_status : buffer for returned PTI status |
---|
141 | *****************************************************************************************/ |
---|
142 | void soclib_xcu_get_status( chdev_t * icu, |
---|
143 | lid_t lid, |
---|
144 | uint32_t * hwi_status, |
---|
145 | uint32_t * wti_status, |
---|
146 | uint32_t * pti_status ); |
---|
147 | |
---|
148 | /****************************************************************************************** |
---|
149 | * This function send an IPI (Inter Processor Interrupt) to a remote XCU, |
---|
150 | * by writing in a WTI mailbox. |
---|
151 | ****************************************************************************************** |
---|
152 | * @ icu_xp : extended pointer on target ICU device descriptor. |
---|
153 | * @ lid : target core local index == WTI mailbox index. |
---|
154 | *****************************************************************************************/ |
---|
155 | void soclib_xcu_send_ipi( xptr_t icu_xp, |
---|
156 | lid_t lid ); |
---|
157 | |
---|
158 | /****************************************************************************************** |
---|
159 | * This function returns the local pointer on a WTI mailbox identified by its index. |
---|
160 | * This function does not access the SOCLIB_XCU hardware device. |
---|
161 | ****************************************************************************************** |
---|
162 | * @ icu : pointer on the local XCU chdev descriptor |
---|
163 | * @ index : WTI mailbox index. |
---|
164 | *****************************************************************************************/ |
---|
165 | uint32_t * soclib_xcu_wti_ptr( chdev_t * icu, |
---|
166 | uint32_t index ); |
---|
167 | |
---|
168 | |
---|
169 | #endif /* _SOCLIB_XCU_H_ */ |
---|