2 * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
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:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Kevin Tian <kevin.tian@intel.com>
25 * Zhi Wang <zhi.a.wang@intel.com>
28 * Min he <min.he@intel.com>
32 #ifndef _GVT_INTERRUPT_H_
33 #define _GVT_INTERRUPT_H_
35 #include <linux/types.h>
37 enum intel_gvt_event_type
{
38 RCS_MI_USER_INTERRUPT
= 0,
44 RCS_WATCHDOG_EXCEEDED
,
45 RCS_PAGE_DIRECTORY_FAULT
,
46 RCS_AS_CONTEXT_SWITCH
,
47 RCS_MONITOR_BUFF_HALF_FULL
,
49 VCS_MI_USER_INTERRUPT
,
53 VCS_WATCHDOG_EXCEEDED
,
54 VCS_PAGE_DIRECTORY_FAULT
,
55 VCS_AS_CONTEXT_SWITCH
,
57 VCS2_MI_USER_INTERRUPT
,
59 VCS2_AS_CONTEXT_SWITCH
,
61 BCS_MI_USER_INTERRUPT
,
65 BCS_PAGE_DIRECTORY_FAULT
,
66 BCS_AS_CONTEXT_SWITCH
,
68 VECS_MI_USER_INTERRUPT
,
70 VECS_AS_CONTEXT_SWITCH
,
99 PCU_PCODE2DRIVER_MAILBOX
,
109 ERROR_INTERRUPT_COMBINED
,
111 FDI_RX_INTERRUPTS_TRANSCODER_A
,
112 AUDIO_CP_CHANGE_TRANSCODER_A
,
113 AUDIO_CP_REQUEST_TRANSCODER_A
,
114 FDI_RX_INTERRUPTS_TRANSCODER_B
,
115 AUDIO_CP_CHANGE_TRANSCODER_B
,
116 AUDIO_CP_REQUEST_TRANSCODER_B
,
117 FDI_RX_INTERRUPTS_TRANSCODER_C
,
118 AUDIO_CP_CHANGE_TRANSCODER_C
,
119 AUDIO_CP_REQUEST_TRANSCODER_C
,
130 AUDIO_POWER_STATE_CHANGE_B
,
131 AUDIO_POWER_STATE_CHANGE_C
,
132 AUDIO_POWER_STATE_CHANGE_D
,
134 INTEL_GVT_EVENT_RESERVED
,
138 struct intel_gvt_irq
;
142 typedef void (*gvt_event_virt_handler_t
)(struct intel_gvt_irq
*irq
,
143 enum intel_gvt_event_type event
, struct intel_vgpu
*vgpu
);
145 struct intel_gvt_irq_ops
{
146 void (*init_irq
)(struct intel_gvt_irq
*irq
);
147 void (*check_pending_irq
)(struct intel_vgpu
*vgpu
);
150 /* the list of physical interrupt control register groups */
151 enum intel_gvt_irq_type
{
152 INTEL_GVT_IRQ_INFO_GT
,
153 INTEL_GVT_IRQ_INFO_DPY
,
154 INTEL_GVT_IRQ_INFO_PCH
,
155 INTEL_GVT_IRQ_INFO_PM
,
157 INTEL_GVT_IRQ_INFO_MASTER
,
158 INTEL_GVT_IRQ_INFO_GT0
,
159 INTEL_GVT_IRQ_INFO_GT1
,
160 INTEL_GVT_IRQ_INFO_GT2
,
161 INTEL_GVT_IRQ_INFO_GT3
,
162 INTEL_GVT_IRQ_INFO_DE_PIPE_A
,
163 INTEL_GVT_IRQ_INFO_DE_PIPE_B
,
164 INTEL_GVT_IRQ_INFO_DE_PIPE_C
,
165 INTEL_GVT_IRQ_INFO_DE_PORT
,
166 INTEL_GVT_IRQ_INFO_DE_MISC
,
167 INTEL_GVT_IRQ_INFO_AUD
,
168 INTEL_GVT_IRQ_INFO_PCU
,
170 INTEL_GVT_IRQ_INFO_MAX
,
173 #define INTEL_GVT_IRQ_BITWIDTH 32
175 /* device specific interrupt bit definitions */
176 struct intel_gvt_irq_info
{
179 enum intel_gvt_event_type bit_to_event
[INTEL_GVT_IRQ_BITWIDTH
];
180 unsigned long warned
;
182 DECLARE_BITMAP(downstream_irq_bitmap
, INTEL_GVT_IRQ_BITWIDTH
);
183 bool has_upstream_irq
;
186 /* per-event information */
187 struct intel_gvt_event_info
{
188 int bit
; /* map to register bit */
189 int policy
; /* forwarding policy */
190 struct intel_gvt_irq_info
*info
; /* register info */
191 gvt_event_virt_handler_t v_handler
; /* for v_event */
194 struct intel_gvt_irq_map
{
198 u32 down_irq_bitmask
;
201 struct intel_gvt_vblank_timer
{
202 struct hrtimer timer
;
206 /* structure containing device specific IRQ state */
207 struct intel_gvt_irq
{
208 struct intel_gvt_irq_ops
*ops
;
209 struct intel_gvt_irq_info
*info
[INTEL_GVT_IRQ_INFO_MAX
];
210 DECLARE_BITMAP(irq_info_bitmap
, INTEL_GVT_IRQ_INFO_MAX
);
211 struct intel_gvt_event_info events
[INTEL_GVT_EVENT_MAX
];
212 DECLARE_BITMAP(pending_events
, INTEL_GVT_EVENT_MAX
);
213 struct intel_gvt_irq_map
*irq_map
;
214 struct intel_gvt_vblank_timer vblank_timer
;
217 int intel_gvt_init_irq(struct intel_gvt
*gvt
);
218 void intel_gvt_clean_irq(struct intel_gvt
*gvt
);
220 void intel_vgpu_trigger_virtual_event(struct intel_vgpu
*vgpu
,
221 enum intel_gvt_event_type event
);
223 int intel_vgpu_reg_iir_handler(struct intel_vgpu
*vgpu
, unsigned int reg
,
224 void *p_data
, unsigned int bytes
);
225 int intel_vgpu_reg_ier_handler(struct intel_vgpu
*vgpu
,
226 unsigned int reg
, void *p_data
, unsigned int bytes
);
227 int intel_vgpu_reg_master_irq_handler(struct intel_vgpu
*vgpu
,
228 unsigned int reg
, void *p_data
, unsigned int bytes
);
229 int intel_vgpu_reg_imr_handler(struct intel_vgpu
*vgpu
,
230 unsigned int reg
, void *p_data
, unsigned int bytes
);
232 int gvt_ring_id_to_pipe_control_notify_event(int ring_id
);
233 int gvt_ring_id_to_mi_flush_dw_event(int ring_id
);
234 int gvt_ring_id_to_mi_user_interrupt_event(int ring_id
);
236 #endif /* _GVT_INTERRUPT_H_ */