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 set the period value for a local XCU timer. |
---|
97 | ****************************************************************************************** |
---|
98 | * @ icu : pointer on the local XCU chdev descriptor |
---|
99 | * @ index : timer index = PTI index |
---|
100 | * @ period : Value to be written |
---|
101 | *****************************************************************************************/ |
---|
102 | void soclib_xcu_set_period( chdev_t * icu, |
---|
103 | uint32_t index, |
---|
104 | uint32_t period ); |
---|
105 | |
---|
106 | /****************************************************************************************** |
---|
107 | * This function acknowledge a PTI IRQ for a local XCU timer. |
---|
108 | ****************************************************************************************** |
---|
109 | * @ icu : pointer on the local XCU chdev descriptor |
---|
110 | * @ index : timer index = PTI index |
---|
111 | * @ the returned value in not significant, but acknowledge requires a read. |
---|
112 | *****************************************************************************************/ |
---|
113 | uint32_t soclib_xcu_ack_timer( chdev_t * icu, |
---|
114 | uint32_t index ); |
---|
115 | |
---|
116 | /****************************************************************************************** |
---|
117 | * This function returns the highest priority active interrupt of each type. |
---|
118 | * If no active interrupt => status == 0 / else => status = index + 1 |
---|
119 | ****************************************************************************************** |
---|
120 | * @ icu : pointer on the local XCU chdev descriptor |
---|
121 | * @ lid : core local index. |
---|
122 | * @ hwi_status : buffer for returned HWI status |
---|
123 | * @ wti_status : buffer for returned WTI status |
---|
124 | * @ pti_status : buffer for returned PTI status |
---|
125 | *****************************************************************************************/ |
---|
126 | void soclib_xcu_get_status( chdev_t * icu, |
---|
127 | lid_t lid, |
---|
128 | uint32_t * hwi_status, |
---|
129 | uint32_t * wti_status, |
---|
130 | uint32_t * pti_status ); |
---|
131 | |
---|
132 | /****************************************************************************************** |
---|
133 | * This function send an IPI (Inter Processor Interrupt) to a remote XCU, |
---|
134 | * by writing in a WTI mailbox. |
---|
135 | ****************************************************************************************** |
---|
136 | * @ icu_xp : extended pointer on target ICU device descriptor. |
---|
137 | * @ lid : target core local index == WTI mailbox index. |
---|
138 | *****************************************************************************************/ |
---|
139 | void soclib_xcu_send_ipi( xptr_t icu_xp, |
---|
140 | lid_t lid ); |
---|
141 | |
---|
142 | /****************************************************************************************** |
---|
143 | * This function returns the local pointer on a WTI mailbox identified by its index. |
---|
144 | * This function does not access the SOCLIB_XCU hardware device. |
---|
145 | ****************************************************************************************** |
---|
146 | * @ icu : pointer on the local XCU chdev descriptor |
---|
147 | * @ index : WTI mailbox index. |
---|
148 | *****************************************************************************************/ |
---|
149 | uint32_t * soclib_xcu_wti_ptr( chdev_t * icu, |
---|
150 | uint32_t index ); |
---|
151 | |
---|
152 | |
---|
153 | #endif /* _SOCLIB_XCU_H_ */ |
---|