xref: /linux/drivers/gpu/drm/amd/display/dc/irq_types.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1 /*
2  * Copyright 2012-15 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: AMD
23  *
24  */
25 
26 #ifndef __DAL_IRQ_TYPES_H__
27 #define __DAL_IRQ_TYPES_H__
28 
29 #include "os_types.h"
30 
31 struct dc_context;
32 
33 typedef void (*interrupt_handler)(void *);
34 
35 typedef void *irq_handler_idx;
36 #define DAL_INVALID_IRQ_HANDLER_IDX NULL
37 
38 /* The order of the IRQ sources is important and MUST match the one's
39 of base driver */
40 enum dc_irq_source {
41 	/* Use as mask to specify invalid irq source */
42 	DC_IRQ_SOURCE_INVALID = 0,
43 
44 	DC_IRQ_SOURCE_HPD1,
45 	DC_IRQ_SOURCE_HPD2,
46 	DC_IRQ_SOURCE_HPD3,
47 	DC_IRQ_SOURCE_HPD4,
48 	DC_IRQ_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	DC_IRQ_SOURCE_GPIOPAD7,
92 	DC_IRQ_SOURCE_GPIOPAD8,
93 	DC_IRQ_SOURCE_GPIOPAD9,
94 	DC_IRQ_SOURCE_GPIOPAD10,
95 	DC_IRQ_SOURCE_GPIOPAD11,
96 	DC_IRQ_SOURCE_GPIOPAD12,
97 	DC_IRQ_SOURCE_GPIOPAD13,
98 	DC_IRQ_SOURCE_GPIOPAD14,
99 	DC_IRQ_SOURCE_GPIOPAD15,
100 	DC_IRQ_SOURCE_GPIOPAD16,
101 	DC_IRQ_SOURCE_GPIOPAD17,
102 	DC_IRQ_SOURCE_GPIOPAD18,
103 	DC_IRQ_SOURCE_GPIOPAD19,
104 	DC_IRQ_SOURCE_GPIOPAD20,
105 	DC_IRQ_SOURCE_GPIOPAD21,
106 	DC_IRQ_SOURCE_GPIOPAD22,
107 	DC_IRQ_SOURCE_GPIOPAD23,
108 	DC_IRQ_SOURCE_GPIOPAD24,
109 	DC_IRQ_SOURCE_GPIOPAD25,
110 	DC_IRQ_SOURCE_GPIOPAD26,
111 	DC_IRQ_SOURCE_GPIOPAD27,
112 	DC_IRQ_SOURCE_GPIOPAD28,
113 	DC_IRQ_SOURCE_GPIOPAD29,
114 	DC_IRQ_SOURCE_GPIOPAD30,
115 
116 	DC_IRQ_SOURCE_DC1UNDERFLOW,
117 	DC_IRQ_SOURCE_DC2UNDERFLOW,
118 	DC_IRQ_SOURCE_DC3UNDERFLOW,
119 	DC_IRQ_SOURCE_DC4UNDERFLOW,
120 	DC_IRQ_SOURCE_DC5UNDERFLOW,
121 	DC_IRQ_SOURCE_DC6UNDERFLOW,
122 
123 	DC_IRQ_SOURCE_DMCU_SCP,
124 	DC_IRQ_SOURCE_VBIOS_SW,
125 
126 	DC_IRQ_SOURCE_VUPDATE1,
127 	DC_IRQ_SOURCE_VUPDATE2,
128 	DC_IRQ_SOURCE_VUPDATE3,
129 	DC_IRQ_SOURCE_VUPDATE4,
130 	DC_IRQ_SOURCE_VUPDATE5,
131 	DC_IRQ_SOURCE_VUPDATE6,
132 
133 	DC_IRQ_SOURCE_VBLANK1,
134 	DC_IRQ_SOURCE_VBLANK2,
135 	DC_IRQ_SOURCE_VBLANK3,
136 	DC_IRQ_SOURCE_VBLANK4,
137 	DC_IRQ_SOURCE_VBLANK5,
138 	DC_IRQ_SOURCE_VBLANK6,
139 
140 	DC_IRQ_SOURCE_DC1_VLINE0,
141 	DC_IRQ_SOURCE_DC2_VLINE0,
142 	DC_IRQ_SOURCE_DC3_VLINE0,
143 	DC_IRQ_SOURCE_DC4_VLINE0,
144 	DC_IRQ_SOURCE_DC5_VLINE0,
145 	DC_IRQ_SOURCE_DC6_VLINE0,
146 
147 	DC_IRQ_SOURCE_DC1_VLINE1,
148 	DC_IRQ_SOURCE_DC2_VLINE1,
149 	DC_IRQ_SOURCE_DC3_VLINE1,
150 	DC_IRQ_SOURCE_DC4_VLINE1,
151 	DC_IRQ_SOURCE_DC5_VLINE1,
152 	DC_IRQ_SOURCE_DC6_VLINE1,
153 	DC_IRQ_SOURCE_DMCUB_OUTBOX,
154 	DC_IRQ_SOURCE_DMCUB_OUTBOX0,
155 	DC_IRQ_SOURCE_DMCUB_GENERAL_DATAOUT,
156 
157 	DC_IRQ_SOURCE_DPCX_TX_PHYA,
158 	DC_IRQ_SOURCE_DPCX_TX_PHYB,
159 	DC_IRQ_SOURCE_DPCX_TX_PHYC,
160 	DC_IRQ_SOURCE_DPCX_TX_PHYD,
161 	DC_IRQ_SOURCE_DPCX_TX_PHYE,
162 	DC_IRQ_SOURCE_DPCX_TX_PHYF,
163 
164 	DAL_IRQ_SOURCES_NUMBER
165 };
166 
167 enum irq_type
168 {
169 	IRQ_TYPE_PFLIP = DC_IRQ_SOURCE_PFLIP1,
170 	IRQ_TYPE_VUPDATE = DC_IRQ_SOURCE_VUPDATE1,
171 	IRQ_TYPE_VBLANK = DC_IRQ_SOURCE_VBLANK1,
172 	IRQ_TYPE_VLINE0 = DC_IRQ_SOURCE_DC1_VLINE0,
173 };
174 
175 #define DAL_VALID_IRQ_SRC_NUM(src) \
176 	((src) < DAL_IRQ_SOURCES_NUMBER && (src) > DC_IRQ_SOURCE_INVALID)
177 
178 /* Number of Page Flip IRQ Sources. */
179 #define DAL_PFLIP_IRQ_SRC_NUM \
180 	(DC_IRQ_SOURCE_PFLIP_LAST - DC_IRQ_SOURCE_PFLIP_FIRST + 1)
181 
182 /* the number of contexts may be expanded in the future based on needs */
183 enum dc_interrupt_context {
184 	INTERRUPT_LOW_IRQ_CONTEXT = 0,
185 	INTERRUPT_HIGH_IRQ_CONTEXT,
186 	INTERRUPT_CONTEXT_NUMBER
187 };
188 
189 enum dc_interrupt_polarity {
190 	INTERRUPT_POLARITY_DEFAULT = 0,
191 	INTERRUPT_POLARITY_LOW = INTERRUPT_POLARITY_DEFAULT,
192 	INTERRUPT_POLARITY_HIGH,
193 	INTERRUPT_POLARITY_BOTH
194 };
195 
196 #define DC_DECODE_INTERRUPT_POLARITY(int_polarity) \
197 	(int_polarity == INTERRUPT_POLARITY_LOW) ? "Low" : \
198 	(int_polarity == INTERRUPT_POLARITY_HIGH) ? "High" : \
199 	(int_polarity == INTERRUPT_POLARITY_BOTH) ? "Both" : "Invalid"
200 
201 struct dc_timer_interrupt_params {
202 	uint32_t micro_sec_interval;
203 	enum dc_interrupt_context int_context;
204 };
205 
206 struct dc_interrupt_params {
207 	/* The polarity *change* which will trigger an interrupt.
208 	 * If 'requested_polarity == INTERRUPT_POLARITY_BOTH', then
209 	 * 'current_polarity' must be initialised. */
210 	enum dc_interrupt_polarity requested_polarity;
211 	/* If 'requested_polarity == INTERRUPT_POLARITY_BOTH',
212 	 * 'current_polarity' should contain the current state, which means
213 	 * the interrupt will be triggered when state changes from what is,
214 	 * in 'current_polarity'. */
215 	enum dc_interrupt_polarity current_polarity;
216 	enum dc_irq_source irq_source;
217 	enum dc_interrupt_context int_context;
218 };
219 
220 #endif
221