1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev  * Copyright 2012-15 Advanced Micro Devices, Inc.
3*b843c749SSergey Zigachev  *
4*b843c749SSergey Zigachev  * Permission is hereby granted, free of charge, to any person obtaining a
5*b843c749SSergey Zigachev  * copy of this software and associated documentation files (the "Software"),
6*b843c749SSergey Zigachev  * to deal in the Software without restriction, including without limitation
7*b843c749SSergey Zigachev  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*b843c749SSergey Zigachev  * and/or sell copies of the Software, and to permit persons to whom the
9*b843c749SSergey Zigachev  * Software is furnished to do so, subject to the following conditions:
10*b843c749SSergey Zigachev  *
11*b843c749SSergey Zigachev  * The above copyright notice and this permission notice shall be included in
12*b843c749SSergey Zigachev  * all copies or substantial portions of the Software.
13*b843c749SSergey Zigachev  *
14*b843c749SSergey Zigachev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*b843c749SSergey Zigachev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*b843c749SSergey Zigachev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17*b843c749SSergey Zigachev  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*b843c749SSergey Zigachev  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*b843c749SSergey Zigachev  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*b843c749SSergey Zigachev  * OTHER DEALINGS IN THE SOFTWARE.
21*b843c749SSergey Zigachev  *
22*b843c749SSergey Zigachev  * Authors: AMD
23*b843c749SSergey Zigachev  *
24*b843c749SSergey Zigachev  */
25*b843c749SSergey Zigachev 
26*b843c749SSergey Zigachev #include "dm_services.h"
27*b843c749SSergey Zigachev 
28*b843c749SSergey Zigachev #include "include/logger_interface.h"
29*b843c749SSergey Zigachev 
30*b843c749SSergey Zigachev #include "irq_service_dce110.h"
31*b843c749SSergey Zigachev 
32*b843c749SSergey Zigachev #include "dce/dce_11_0_d.h"
33*b843c749SSergey Zigachev #include "dce/dce_11_0_sh_mask.h"
34*b843c749SSergey Zigachev 
35*b843c749SSergey Zigachev #include "ivsrcid/ivsrcid_vislands30.h"
36*b843c749SSergey Zigachev 
37*b843c749SSergey Zigachev #include "dc.h"
38*b843c749SSergey Zigachev #include "core_types.h"
39*b843c749SSergey Zigachev #define DC_LOGGER \
40*b843c749SSergey Zigachev 	irq_service->ctx->logger
41*b843c749SSergey Zigachev 
hpd_ack(struct irq_service * irq_service,const struct irq_source_info * info)42*b843c749SSergey Zigachev static bool hpd_ack(struct irq_service *irq_service,
43*b843c749SSergey Zigachev 		    const struct irq_source_info *info)
44*b843c749SSergey Zigachev {
45*b843c749SSergey Zigachev 	uint32_t addr = info->status_reg;
46*b843c749SSergey Zigachev 	uint32_t value = dm_read_reg(irq_service->ctx, addr);
47*b843c749SSergey Zigachev 	uint32_t current_status = get_reg_field_value(value,
48*b843c749SSergey Zigachev 						      DC_HPD_INT_STATUS,
49*b843c749SSergey Zigachev 						      DC_HPD_SENSE_DELAYED);
50*b843c749SSergey Zigachev 
51*b843c749SSergey Zigachev 	dal_irq_service_ack_generic(irq_service, info);
52*b843c749SSergey Zigachev 
53*b843c749SSergey Zigachev 	value = dm_read_reg(irq_service->ctx, info->enable_reg);
54*b843c749SSergey Zigachev 
55*b843c749SSergey Zigachev 	set_reg_field_value(value, current_status ? 0 : 1,
56*b843c749SSergey Zigachev 			    DC_HPD_INT_CONTROL,
57*b843c749SSergey Zigachev 			    DC_HPD_INT_POLARITY);
58*b843c749SSergey Zigachev 
59*b843c749SSergey Zigachev 	dm_write_reg(irq_service->ctx, info->enable_reg, value);
60*b843c749SSergey Zigachev 
61*b843c749SSergey Zigachev 	return true;
62*b843c749SSergey Zigachev }
63*b843c749SSergey Zigachev 
64*b843c749SSergey Zigachev static const struct irq_source_info_funcs hpd_irq_info_funcs = {
65*b843c749SSergey Zigachev 	.set = NULL,
66*b843c749SSergey Zigachev 	.ack = hpd_ack
67*b843c749SSergey Zigachev };
68*b843c749SSergey Zigachev 
69*b843c749SSergey Zigachev static const struct irq_source_info_funcs hpd_rx_irq_info_funcs = {
70*b843c749SSergey Zigachev 	.set = NULL,
71*b843c749SSergey Zigachev 	.ack = NULL
72*b843c749SSergey Zigachev };
73*b843c749SSergey Zigachev 
74*b843c749SSergey Zigachev static const struct irq_source_info_funcs pflip_irq_info_funcs = {
75*b843c749SSergey Zigachev 	.set = NULL,
76*b843c749SSergey Zigachev 	.ack = NULL
77*b843c749SSergey Zigachev };
78*b843c749SSergey Zigachev 
79*b843c749SSergey Zigachev static const struct irq_source_info_funcs vblank_irq_info_funcs = {
80*b843c749SSergey Zigachev 	.set = dce110_vblank_set,
81*b843c749SSergey Zigachev 	.ack = NULL
82*b843c749SSergey Zigachev };
83*b843c749SSergey Zigachev 
84*b843c749SSergey Zigachev #define hpd_int_entry(reg_num)\
85*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_HPD1 + reg_num] = {\
86*b843c749SSergey Zigachev 		.enable_reg = mmHPD ## reg_num ## _DC_HPD_INT_CONTROL,\
87*b843c749SSergey Zigachev 		.enable_mask = DC_HPD_INT_CONTROL__DC_HPD_INT_EN_MASK,\
88*b843c749SSergey Zigachev 		.enable_value = {\
89*b843c749SSergey Zigachev 			DC_HPD_INT_CONTROL__DC_HPD_INT_EN_MASK,\
90*b843c749SSergey Zigachev 			~DC_HPD_INT_CONTROL__DC_HPD_INT_EN_MASK\
91*b843c749SSergey Zigachev 		},\
92*b843c749SSergey Zigachev 		.ack_reg = mmHPD ## reg_num ## _DC_HPD_INT_CONTROL,\
93*b843c749SSergey Zigachev 		.ack_mask = DC_HPD_INT_CONTROL__DC_HPD_INT_ACK_MASK,\
94*b843c749SSergey Zigachev 		.ack_value = DC_HPD_INT_CONTROL__DC_HPD_INT_ACK_MASK,\
95*b843c749SSergey Zigachev 		.status_reg = mmHPD ## reg_num ## _DC_HPD_INT_STATUS,\
96*b843c749SSergey Zigachev 		.funcs = &hpd_irq_info_funcs\
97*b843c749SSergey Zigachev 	}
98*b843c749SSergey Zigachev 
99*b843c749SSergey Zigachev #define hpd_rx_int_entry(reg_num)\
100*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_HPD1RX + reg_num] = {\
101*b843c749SSergey Zigachev 		.enable_reg = mmHPD ## reg_num ## _DC_HPD_INT_CONTROL,\
102*b843c749SSergey Zigachev 		.enable_mask = DC_HPD_INT_CONTROL__DC_HPD_RX_INT_EN_MASK,\
103*b843c749SSergey Zigachev 		.enable_value = {\
104*b843c749SSergey Zigachev 			DC_HPD_INT_CONTROL__DC_HPD_RX_INT_EN_MASK,\
105*b843c749SSergey Zigachev 			~DC_HPD_INT_CONTROL__DC_HPD_RX_INT_EN_MASK },\
106*b843c749SSergey Zigachev 		.ack_reg = mmHPD ## reg_num ## _DC_HPD_INT_CONTROL,\
107*b843c749SSergey Zigachev 		.ack_mask = DC_HPD_INT_CONTROL__DC_HPD_RX_INT_ACK_MASK,\
108*b843c749SSergey Zigachev 		.ack_value = DC_HPD_INT_CONTROL__DC_HPD_RX_INT_ACK_MASK,\
109*b843c749SSergey Zigachev 		.status_reg = mmHPD ## reg_num ## _DC_HPD_INT_STATUS,\
110*b843c749SSergey Zigachev 		.funcs = &hpd_rx_irq_info_funcs\
111*b843c749SSergey Zigachev 	}
112*b843c749SSergey Zigachev #define pflip_int_entry(reg_num)\
113*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_PFLIP1 + reg_num] = {\
114*b843c749SSergey Zigachev 		.enable_reg = mmDCP ## reg_num ## _GRPH_INTERRUPT_CONTROL,\
115*b843c749SSergey Zigachev 		.enable_mask =\
116*b843c749SSergey Zigachev 		GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK,\
117*b843c749SSergey Zigachev 		.enable_value = {\
118*b843c749SSergey Zigachev 			GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK,\
119*b843c749SSergey Zigachev 			~GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK},\
120*b843c749SSergey Zigachev 		.ack_reg = mmDCP ## reg_num ## _GRPH_INTERRUPT_STATUS,\
121*b843c749SSergey Zigachev 		.ack_mask = GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_CLEAR_MASK,\
122*b843c749SSergey Zigachev 		.ack_value = GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_CLEAR_MASK,\
123*b843c749SSergey Zigachev 		.status_reg = mmDCP ## reg_num ##_GRPH_INTERRUPT_STATUS,\
124*b843c749SSergey Zigachev 		.funcs = &pflip_irq_info_funcs\
125*b843c749SSergey Zigachev 	}
126*b843c749SSergey Zigachev 
127*b843c749SSergey Zigachev #define vupdate_int_entry(reg_num)\
128*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_VUPDATE1 + reg_num] = {\
129*b843c749SSergey Zigachev 		.enable_reg = mmCRTC ## reg_num ## _CRTC_INTERRUPT_CONTROL,\
130*b843c749SSergey Zigachev 		.enable_mask =\
131*b843c749SSergey Zigachev 		CRTC_INTERRUPT_CONTROL__CRTC_V_UPDATE_INT_MSK_MASK,\
132*b843c749SSergey Zigachev 		.enable_value = {\
133*b843c749SSergey Zigachev 			CRTC_INTERRUPT_CONTROL__CRTC_V_UPDATE_INT_MSK_MASK,\
134*b843c749SSergey Zigachev 			~CRTC_INTERRUPT_CONTROL__CRTC_V_UPDATE_INT_MSK_MASK},\
135*b843c749SSergey Zigachev 		.ack_reg = mmCRTC ## reg_num ## _CRTC_V_UPDATE_INT_STATUS,\
136*b843c749SSergey Zigachev 		.ack_mask =\
137*b843c749SSergey Zigachev 		CRTC_V_UPDATE_INT_STATUS__CRTC_V_UPDATE_INT_CLEAR_MASK,\
138*b843c749SSergey Zigachev 		.ack_value =\
139*b843c749SSergey Zigachev 		CRTC_V_UPDATE_INT_STATUS__CRTC_V_UPDATE_INT_CLEAR_MASK,\
140*b843c749SSergey Zigachev 		.funcs = &vblank_irq_info_funcs\
141*b843c749SSergey Zigachev 	}
142*b843c749SSergey Zigachev 
143*b843c749SSergey Zigachev #define vblank_int_entry(reg_num)\
144*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_VBLANK1 + reg_num] = {\
145*b843c749SSergey Zigachev 		.enable_reg = mmCRTC ## reg_num ## _CRTC_VERTICAL_INTERRUPT0_CONTROL,\
146*b843c749SSergey Zigachev 		.enable_mask =\
147*b843c749SSergey Zigachev 		CRTC_VERTICAL_INTERRUPT0_CONTROL__CRTC_VERTICAL_INTERRUPT0_INT_ENABLE_MASK,\
148*b843c749SSergey Zigachev 		.enable_value = {\
149*b843c749SSergey Zigachev 			CRTC_VERTICAL_INTERRUPT0_CONTROL__CRTC_VERTICAL_INTERRUPT0_INT_ENABLE_MASK,\
150*b843c749SSergey Zigachev 			~CRTC_VERTICAL_INTERRUPT0_CONTROL__CRTC_VERTICAL_INTERRUPT0_INT_ENABLE_MASK},\
151*b843c749SSergey Zigachev 		.ack_reg = mmCRTC ## reg_num ## _CRTC_VERTICAL_INTERRUPT0_CONTROL,\
152*b843c749SSergey Zigachev 		.ack_mask =\
153*b843c749SSergey Zigachev 		CRTC_VERTICAL_INTERRUPT0_CONTROL__CRTC_VERTICAL_INTERRUPT0_CLEAR_MASK,\
154*b843c749SSergey Zigachev 		.ack_value =\
155*b843c749SSergey Zigachev 		CRTC_VERTICAL_INTERRUPT0_CONTROL__CRTC_VERTICAL_INTERRUPT0_CLEAR_MASK,\
156*b843c749SSergey Zigachev 		.funcs = &vblank_irq_info_funcs,\
157*b843c749SSergey Zigachev 		.src_id = VISLANDS30_IV_SRCID_D1_VERTICAL_INTERRUPT0 + reg_num\
158*b843c749SSergey Zigachev 	}
159*b843c749SSergey Zigachev 
160*b843c749SSergey Zigachev #define dummy_irq_entry() \
161*b843c749SSergey Zigachev 	{\
162*b843c749SSergey Zigachev 		.funcs = &dummy_irq_info_funcs\
163*b843c749SSergey Zigachev 	}
164*b843c749SSergey Zigachev 
165*b843c749SSergey Zigachev #define i2c_int_entry(reg_num) \
166*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_I2C_DDC ## reg_num] = dummy_irq_entry()
167*b843c749SSergey Zigachev 
168*b843c749SSergey Zigachev #define dp_sink_int_entry(reg_num) \
169*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_DPSINK ## reg_num] = dummy_irq_entry()
170*b843c749SSergey Zigachev 
171*b843c749SSergey Zigachev #define gpio_pad_int_entry(reg_num) \
172*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_GPIOPAD ## reg_num] = dummy_irq_entry()
173*b843c749SSergey Zigachev 
174*b843c749SSergey Zigachev #define dc_underflow_int_entry(reg_num) \
175*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_DC ## reg_num ## UNDERFLOW] = dummy_irq_entry()
176*b843c749SSergey Zigachev 
dal_irq_service_dummy_set(struct irq_service * irq_service,const struct irq_source_info * info,bool enable)177*b843c749SSergey Zigachev bool dal_irq_service_dummy_set(struct irq_service *irq_service,
178*b843c749SSergey Zigachev 			       const struct irq_source_info *info,
179*b843c749SSergey Zigachev 			       bool enable)
180*b843c749SSergey Zigachev {
181*b843c749SSergey Zigachev 	DC_LOG_ERROR("%s: called for non-implemented irq source\n",
182*b843c749SSergey Zigachev 		     __func__);
183*b843c749SSergey Zigachev 	return false;
184*b843c749SSergey Zigachev }
185*b843c749SSergey Zigachev 
dal_irq_service_dummy_ack(struct irq_service * irq_service,const struct irq_source_info * info)186*b843c749SSergey Zigachev bool dal_irq_service_dummy_ack(struct irq_service *irq_service,
187*b843c749SSergey Zigachev 			       const struct irq_source_info *info)
188*b843c749SSergey Zigachev {
189*b843c749SSergey Zigachev 	DC_LOG_ERROR("%s: called for non-implemented irq source\n",
190*b843c749SSergey Zigachev 		     __func__);
191*b843c749SSergey Zigachev 	return false;
192*b843c749SSergey Zigachev }
193*b843c749SSergey Zigachev 
194*b843c749SSergey Zigachev 
dce110_vblank_set(struct irq_service * irq_service,const struct irq_source_info * info,bool enable)195*b843c749SSergey Zigachev bool dce110_vblank_set(struct irq_service *irq_service,
196*b843c749SSergey Zigachev 		       const struct irq_source_info *info,
197*b843c749SSergey Zigachev 		       bool enable)
198*b843c749SSergey Zigachev {
199*b843c749SSergey Zigachev 	struct dc_context *dc_ctx = irq_service->ctx;
200*b843c749SSergey Zigachev 	struct dc *core_dc = irq_service->ctx->dc;
201*b843c749SSergey Zigachev 	enum dc_irq_source dal_irq_src =
202*b843c749SSergey Zigachev 			dc_interrupt_to_irq_source(irq_service->ctx->dc,
203*b843c749SSergey Zigachev 						   info->src_id,
204*b843c749SSergey Zigachev 						   info->ext_id);
205*b843c749SSergey Zigachev 	uint8_t pipe_offset = dal_irq_src - IRQ_TYPE_VBLANK;
206*b843c749SSergey Zigachev 
207*b843c749SSergey Zigachev 	struct timing_generator *tg =
208*b843c749SSergey Zigachev 			core_dc->current_state->res_ctx.pipe_ctx[pipe_offset].stream_res.tg;
209*b843c749SSergey Zigachev 
210*b843c749SSergey Zigachev 	if (enable) {
211*b843c749SSergey Zigachev 		if (!tg || !tg->funcs->arm_vert_intr(tg, 2)) {
212*b843c749SSergey Zigachev 			DC_ERROR("Failed to get VBLANK!\n");
213*b843c749SSergey Zigachev 			return false;
214*b843c749SSergey Zigachev 		}
215*b843c749SSergey Zigachev 	}
216*b843c749SSergey Zigachev 
217*b843c749SSergey Zigachev 	dal_irq_service_set_generic(irq_service, info, enable);
218*b843c749SSergey Zigachev 	return true;
219*b843c749SSergey Zigachev }
220*b843c749SSergey Zigachev 
221*b843c749SSergey Zigachev static const struct irq_source_info_funcs dummy_irq_info_funcs = {
222*b843c749SSergey Zigachev 	.set = dal_irq_service_dummy_set,
223*b843c749SSergey Zigachev 	.ack = dal_irq_service_dummy_ack
224*b843c749SSergey Zigachev };
225*b843c749SSergey Zigachev 
226*b843c749SSergey Zigachev static const struct irq_source_info
227*b843c749SSergey Zigachev irq_source_info_dce110[DAL_IRQ_SOURCES_NUMBER] = {
228*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_INVALID] = dummy_irq_entry(),
229*b843c749SSergey Zigachev 	hpd_int_entry(0),
230*b843c749SSergey Zigachev 	hpd_int_entry(1),
231*b843c749SSergey Zigachev 	hpd_int_entry(2),
232*b843c749SSergey Zigachev 	hpd_int_entry(3),
233*b843c749SSergey Zigachev 	hpd_int_entry(4),
234*b843c749SSergey Zigachev 	hpd_int_entry(5),
235*b843c749SSergey Zigachev 	hpd_rx_int_entry(0),
236*b843c749SSergey Zigachev 	hpd_rx_int_entry(1),
237*b843c749SSergey Zigachev 	hpd_rx_int_entry(2),
238*b843c749SSergey Zigachev 	hpd_rx_int_entry(3),
239*b843c749SSergey Zigachev 	hpd_rx_int_entry(4),
240*b843c749SSergey Zigachev 	hpd_rx_int_entry(5),
241*b843c749SSergey Zigachev 	i2c_int_entry(1),
242*b843c749SSergey Zigachev 	i2c_int_entry(2),
243*b843c749SSergey Zigachev 	i2c_int_entry(3),
244*b843c749SSergey Zigachev 	i2c_int_entry(4),
245*b843c749SSergey Zigachev 	i2c_int_entry(5),
246*b843c749SSergey Zigachev 	i2c_int_entry(6),
247*b843c749SSergey Zigachev 	dp_sink_int_entry(1),
248*b843c749SSergey Zigachev 	dp_sink_int_entry(2),
249*b843c749SSergey Zigachev 	dp_sink_int_entry(3),
250*b843c749SSergey Zigachev 	dp_sink_int_entry(4),
251*b843c749SSergey Zigachev 	dp_sink_int_entry(5),
252*b843c749SSergey Zigachev 	dp_sink_int_entry(6),
253*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_TIMER] = dummy_irq_entry(),
254*b843c749SSergey Zigachev 	pflip_int_entry(0),
255*b843c749SSergey Zigachev 	pflip_int_entry(1),
256*b843c749SSergey Zigachev 	pflip_int_entry(2),
257*b843c749SSergey Zigachev 	pflip_int_entry(3),
258*b843c749SSergey Zigachev 	pflip_int_entry(4),
259*b843c749SSergey Zigachev 	pflip_int_entry(5),
260*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_PFLIP_UNDERLAY0] = dummy_irq_entry(),
261*b843c749SSergey Zigachev 	gpio_pad_int_entry(0),
262*b843c749SSergey Zigachev 	gpio_pad_int_entry(1),
263*b843c749SSergey Zigachev 	gpio_pad_int_entry(2),
264*b843c749SSergey Zigachev 	gpio_pad_int_entry(3),
265*b843c749SSergey Zigachev 	gpio_pad_int_entry(4),
266*b843c749SSergey Zigachev 	gpio_pad_int_entry(5),
267*b843c749SSergey Zigachev 	gpio_pad_int_entry(6),
268*b843c749SSergey Zigachev 	gpio_pad_int_entry(7),
269*b843c749SSergey Zigachev 	gpio_pad_int_entry(8),
270*b843c749SSergey Zigachev 	gpio_pad_int_entry(9),
271*b843c749SSergey Zigachev 	gpio_pad_int_entry(10),
272*b843c749SSergey Zigachev 	gpio_pad_int_entry(11),
273*b843c749SSergey Zigachev 	gpio_pad_int_entry(12),
274*b843c749SSergey Zigachev 	gpio_pad_int_entry(13),
275*b843c749SSergey Zigachev 	gpio_pad_int_entry(14),
276*b843c749SSergey Zigachev 	gpio_pad_int_entry(15),
277*b843c749SSergey Zigachev 	gpio_pad_int_entry(16),
278*b843c749SSergey Zigachev 	gpio_pad_int_entry(17),
279*b843c749SSergey Zigachev 	gpio_pad_int_entry(18),
280*b843c749SSergey Zigachev 	gpio_pad_int_entry(19),
281*b843c749SSergey Zigachev 	gpio_pad_int_entry(20),
282*b843c749SSergey Zigachev 	gpio_pad_int_entry(21),
283*b843c749SSergey Zigachev 	gpio_pad_int_entry(22),
284*b843c749SSergey Zigachev 	gpio_pad_int_entry(23),
285*b843c749SSergey Zigachev 	gpio_pad_int_entry(24),
286*b843c749SSergey Zigachev 	gpio_pad_int_entry(25),
287*b843c749SSergey Zigachev 	gpio_pad_int_entry(26),
288*b843c749SSergey Zigachev 	gpio_pad_int_entry(27),
289*b843c749SSergey Zigachev 	gpio_pad_int_entry(28),
290*b843c749SSergey Zigachev 	gpio_pad_int_entry(29),
291*b843c749SSergey Zigachev 	gpio_pad_int_entry(30),
292*b843c749SSergey Zigachev 	dc_underflow_int_entry(1),
293*b843c749SSergey Zigachev 	dc_underflow_int_entry(2),
294*b843c749SSergey Zigachev 	dc_underflow_int_entry(3),
295*b843c749SSergey Zigachev 	dc_underflow_int_entry(4),
296*b843c749SSergey Zigachev 	dc_underflow_int_entry(5),
297*b843c749SSergey Zigachev 	dc_underflow_int_entry(6),
298*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_DMCU_SCP] = dummy_irq_entry(),
299*b843c749SSergey Zigachev 	[DC_IRQ_SOURCE_VBIOS_SW] = dummy_irq_entry(),
300*b843c749SSergey Zigachev 	vupdate_int_entry(0),
301*b843c749SSergey Zigachev 	vupdate_int_entry(1),
302*b843c749SSergey Zigachev 	vupdate_int_entry(2),
303*b843c749SSergey Zigachev 	vupdate_int_entry(3),
304*b843c749SSergey Zigachev 	vupdate_int_entry(4),
305*b843c749SSergey Zigachev 	vupdate_int_entry(5),
306*b843c749SSergey Zigachev 	vblank_int_entry(0),
307*b843c749SSergey Zigachev 	vblank_int_entry(1),
308*b843c749SSergey Zigachev 	vblank_int_entry(2),
309*b843c749SSergey Zigachev 	vblank_int_entry(3),
310*b843c749SSergey Zigachev 	vblank_int_entry(4),
311*b843c749SSergey Zigachev 	vblank_int_entry(5),
312*b843c749SSergey Zigachev 
313*b843c749SSergey Zigachev };
314*b843c749SSergey Zigachev 
to_dal_irq_source_dce110(struct irq_service * irq_service,uint32_t src_id,uint32_t ext_id)315*b843c749SSergey Zigachev enum dc_irq_source to_dal_irq_source_dce110(
316*b843c749SSergey Zigachev 		struct irq_service *irq_service,
317*b843c749SSergey Zigachev 		uint32_t src_id,
318*b843c749SSergey Zigachev 		uint32_t ext_id)
319*b843c749SSergey Zigachev {
320*b843c749SSergey Zigachev 	switch (src_id) {
321*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D1_VERTICAL_INTERRUPT0:
322*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VBLANK1;
323*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D2_VERTICAL_INTERRUPT0:
324*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VBLANK2;
325*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D3_VERTICAL_INTERRUPT0:
326*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VBLANK3;
327*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D4_VERTICAL_INTERRUPT0:
328*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VBLANK4;
329*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D5_VERTICAL_INTERRUPT0:
330*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VBLANK5;
331*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D6_VERTICAL_INTERRUPT0:
332*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VBLANK6;
333*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D1_V_UPDATE_INT:
334*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VUPDATE1;
335*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D2_V_UPDATE_INT:
336*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VUPDATE2;
337*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D3_V_UPDATE_INT:
338*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VUPDATE3;
339*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D4_V_UPDATE_INT:
340*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VUPDATE4;
341*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D5_V_UPDATE_INT:
342*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VUPDATE5;
343*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D6_V_UPDATE_INT:
344*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_VUPDATE6;
345*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D1_GRPH_PFLIP:
346*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_PFLIP1;
347*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D2_GRPH_PFLIP:
348*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_PFLIP2;
349*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D3_GRPH_PFLIP:
350*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_PFLIP3;
351*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D4_GRPH_PFLIP:
352*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_PFLIP4;
353*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D5_GRPH_PFLIP:
354*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_PFLIP5;
355*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_D6_GRPH_PFLIP:
356*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_PFLIP6;
357*b843c749SSergey Zigachev 
358*b843c749SSergey Zigachev 	case VISLANDS30_IV_SRCID_HOTPLUG_DETECT_A:
359*b843c749SSergey Zigachev 		/* generic src_id for all HPD and HPDRX interrupts */
360*b843c749SSergey Zigachev 		switch (ext_id) {
361*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HOTPLUG_DETECT_A:
362*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD1;
363*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HOTPLUG_DETECT_B:
364*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD2;
365*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HOTPLUG_DETECT_C:
366*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD3;
367*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HOTPLUG_DETECT_D:
368*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD4;
369*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HOTPLUG_DETECT_E:
370*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD5;
371*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HOTPLUG_DETECT_F:
372*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD6;
373*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HPD_RX_A:
374*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD1RX;
375*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HPD_RX_B:
376*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD2RX;
377*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HPD_RX_C:
378*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD3RX;
379*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HPD_RX_D:
380*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD4RX;
381*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HPD_RX_E:
382*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD5RX;
383*b843c749SSergey Zigachev 		case VISLANDS30_IV_EXTID_HPD_RX_F:
384*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_HPD6RX;
385*b843c749SSergey Zigachev 		default:
386*b843c749SSergey Zigachev 			return DC_IRQ_SOURCE_INVALID;
387*b843c749SSergey Zigachev 		}
388*b843c749SSergey Zigachev 		break;
389*b843c749SSergey Zigachev 
390*b843c749SSergey Zigachev 	default:
391*b843c749SSergey Zigachev 		return DC_IRQ_SOURCE_INVALID;
392*b843c749SSergey Zigachev 	}
393*b843c749SSergey Zigachev }
394*b843c749SSergey Zigachev 
395*b843c749SSergey Zigachev static const struct irq_service_funcs irq_service_funcs_dce110 = {
396*b843c749SSergey Zigachev 		.to_dal_irq_source = to_dal_irq_source_dce110
397*b843c749SSergey Zigachev };
398*b843c749SSergey Zigachev 
construct(struct irq_service * irq_service,struct irq_service_init_data * init_data)399*b843c749SSergey Zigachev static void construct(struct irq_service *irq_service,
400*b843c749SSergey Zigachev 		      struct irq_service_init_data *init_data)
401*b843c749SSergey Zigachev {
402*b843c749SSergey Zigachev 	dal_irq_service_construct(irq_service, init_data);
403*b843c749SSergey Zigachev 
404*b843c749SSergey Zigachev 	irq_service->info = irq_source_info_dce110;
405*b843c749SSergey Zigachev 	irq_service->funcs = &irq_service_funcs_dce110;
406*b843c749SSergey Zigachev }
407*b843c749SSergey Zigachev 
408*b843c749SSergey Zigachev struct irq_service *
dal_irq_service_dce110_create(struct irq_service_init_data * init_data)409*b843c749SSergey Zigachev dal_irq_service_dce110_create(struct irq_service_init_data *init_data)
410*b843c749SSergey Zigachev {
411*b843c749SSergey Zigachev 	struct irq_service *irq_service = kzalloc(sizeof(*irq_service),
412*b843c749SSergey Zigachev 						  GFP_KERNEL);
413*b843c749SSergey Zigachev 
414*b843c749SSergey Zigachev 	if (!irq_service)
415*b843c749SSergey Zigachev 		return NULL;
416*b843c749SSergey Zigachev 
417*b843c749SSergey Zigachev 	construct(irq_service, init_data);
418*b843c749SSergey Zigachev 	return irq_service;
419*b843c749SSergey Zigachev }
420