xref: /dflybsd-src/sys/dev/drm/i915/i915_pci.c (revision 1487f78699db6b645ec307a207e4611f50a7cc53)
1*1487f786SFrançois Tigeot /*
2*1487f786SFrançois Tigeot  * Copyright © 2016 Intel Corporation
3*1487f786SFrançois Tigeot  *
4*1487f786SFrançois Tigeot  * Permission is hereby granted, free of charge, to any person obtaining a
5*1487f786SFrançois Tigeot  * copy of this software and associated documentation files (the "Software"),
6*1487f786SFrançois Tigeot  * to deal in the Software without restriction, including without limitation
7*1487f786SFrançois Tigeot  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*1487f786SFrançois Tigeot  * and/or sell copies of the Software, and to permit persons to whom the
9*1487f786SFrançois Tigeot  * Software is furnished to do so, subject to the following conditions:
10*1487f786SFrançois Tigeot  *
11*1487f786SFrançois Tigeot  * The above copyright notice and this permission notice (including the next
12*1487f786SFrançois Tigeot  * paragraph) shall be included in all copies or substantial portions of the
13*1487f786SFrançois Tigeot  * Software.
14*1487f786SFrançois Tigeot  *
15*1487f786SFrançois Tigeot  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*1487f786SFrançois Tigeot  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*1487f786SFrançois Tigeot  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18*1487f786SFrançois Tigeot  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*1487f786SFrançois Tigeot  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*1487f786SFrançois Tigeot  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*1487f786SFrançois Tigeot  * IN THE SOFTWARE.
22*1487f786SFrançois Tigeot  *
23*1487f786SFrançois Tigeot  */
24*1487f786SFrançois Tigeot 
25*1487f786SFrançois Tigeot #include <linux/console.h>
26*1487f786SFrançois Tigeot #include <linux/vgaarb.h>
27*1487f786SFrançois Tigeot #include <linux/vga_switcheroo.h>
28*1487f786SFrançois Tigeot 
29*1487f786SFrançois Tigeot #include "i915_drv.h"
30*1487f786SFrançois Tigeot 
31*1487f786SFrançois Tigeot #define GEN_DEFAULT_PIPEOFFSETS \
32*1487f786SFrançois Tigeot 	.pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
33*1487f786SFrançois Tigeot 			  PIPE_C_OFFSET, PIPE_EDP_OFFSET }, \
34*1487f786SFrançois Tigeot 	.trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
35*1487f786SFrançois Tigeot 			   TRANSCODER_C_OFFSET, TRANSCODER_EDP_OFFSET }, \
36*1487f786SFrançois Tigeot 	.palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET }
37*1487f786SFrançois Tigeot 
38*1487f786SFrançois Tigeot #define GEN_CHV_PIPEOFFSETS \
39*1487f786SFrançois Tigeot 	.pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
40*1487f786SFrançois Tigeot 			  CHV_PIPE_C_OFFSET }, \
41*1487f786SFrançois Tigeot 	.trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
42*1487f786SFrançois Tigeot 			   CHV_TRANSCODER_C_OFFSET, }, \
43*1487f786SFrançois Tigeot 	.palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET, \
44*1487f786SFrançois Tigeot 			     CHV_PALETTE_C_OFFSET }
45*1487f786SFrançois Tigeot 
46*1487f786SFrançois Tigeot #define CURSOR_OFFSETS \
47*1487f786SFrançois Tigeot 	.cursor_offsets = { CURSOR_A_OFFSET, CURSOR_B_OFFSET, CHV_CURSOR_C_OFFSET }
48*1487f786SFrançois Tigeot 
49*1487f786SFrançois Tigeot #define IVB_CURSOR_OFFSETS \
50*1487f786SFrançois Tigeot 	.cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }
51*1487f786SFrançois Tigeot 
52*1487f786SFrançois Tigeot #define BDW_COLORS \
53*1487f786SFrançois Tigeot 	.color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
54*1487f786SFrançois Tigeot #define CHV_COLORS \
55*1487f786SFrançois Tigeot 	.color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }
56*1487f786SFrançois Tigeot 
57*1487f786SFrançois Tigeot static const struct intel_device_info intel_i830_info = {
58*1487f786SFrançois Tigeot 	.gen = 2, .is_mobile = 1, .cursor_needs_physical = 1, .num_pipes = 2,
59*1487f786SFrançois Tigeot 	.has_overlay = 1, .overlay_needs_physical = 1,
60*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
61*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
62*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
63*1487f786SFrançois Tigeot };
64*1487f786SFrançois Tigeot 
65*1487f786SFrançois Tigeot static const struct intel_device_info intel_845g_info = {
66*1487f786SFrançois Tigeot 	.gen = 2, .num_pipes = 1,
67*1487f786SFrançois Tigeot 	.has_overlay = 1, .overlay_needs_physical = 1,
68*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
69*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
70*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
71*1487f786SFrançois Tigeot };
72*1487f786SFrançois Tigeot 
73*1487f786SFrançois Tigeot static const struct intel_device_info intel_i85x_info = {
74*1487f786SFrançois Tigeot 	.gen = 2, .is_i85x = 1, .is_mobile = 1, .num_pipes = 2,
75*1487f786SFrançois Tigeot 	.cursor_needs_physical = 1,
76*1487f786SFrançois Tigeot 	.has_overlay = 1, .overlay_needs_physical = 1,
77*1487f786SFrançois Tigeot 	.has_fbc = 1,
78*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
79*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
80*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
81*1487f786SFrançois Tigeot };
82*1487f786SFrançois Tigeot 
83*1487f786SFrançois Tigeot static const struct intel_device_info intel_i865g_info = {
84*1487f786SFrançois Tigeot 	.gen = 2, .num_pipes = 1,
85*1487f786SFrançois Tigeot 	.has_overlay = 1, .overlay_needs_physical = 1,
86*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
87*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
88*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
89*1487f786SFrançois Tigeot };
90*1487f786SFrançois Tigeot 
91*1487f786SFrançois Tigeot static const struct intel_device_info intel_i915g_info = {
92*1487f786SFrançois Tigeot 	.gen = 3, .is_i915g = 1, .cursor_needs_physical = 1, .num_pipes = 2,
93*1487f786SFrançois Tigeot 	.has_overlay = 1, .overlay_needs_physical = 1,
94*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
95*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
96*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
97*1487f786SFrançois Tigeot };
98*1487f786SFrançois Tigeot static const struct intel_device_info intel_i915gm_info = {
99*1487f786SFrançois Tigeot 	.gen = 3, .is_mobile = 1, .num_pipes = 2,
100*1487f786SFrançois Tigeot 	.cursor_needs_physical = 1,
101*1487f786SFrançois Tigeot 	.has_overlay = 1, .overlay_needs_physical = 1,
102*1487f786SFrançois Tigeot 	.supports_tv = 1,
103*1487f786SFrançois Tigeot 	.has_fbc = 1,
104*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
105*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
106*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
107*1487f786SFrançois Tigeot };
108*1487f786SFrançois Tigeot static const struct intel_device_info intel_i945g_info = {
109*1487f786SFrançois Tigeot 	.gen = 3, .has_hotplug = 1, .cursor_needs_physical = 1, .num_pipes = 2,
110*1487f786SFrançois Tigeot 	.has_overlay = 1, .overlay_needs_physical = 1,
111*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
112*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
113*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
114*1487f786SFrançois Tigeot };
115*1487f786SFrançois Tigeot static const struct intel_device_info intel_i945gm_info = {
116*1487f786SFrançois Tigeot 	.gen = 3, .is_i945gm = 1, .is_mobile = 1, .num_pipes = 2,
117*1487f786SFrançois Tigeot 	.has_hotplug = 1, .cursor_needs_physical = 1,
118*1487f786SFrançois Tigeot 	.has_overlay = 1, .overlay_needs_physical = 1,
119*1487f786SFrançois Tigeot 	.supports_tv = 1,
120*1487f786SFrançois Tigeot 	.has_fbc = 1,
121*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
122*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
123*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
124*1487f786SFrançois Tigeot };
125*1487f786SFrançois Tigeot 
126*1487f786SFrançois Tigeot static const struct intel_device_info intel_i965g_info = {
127*1487f786SFrançois Tigeot 	.gen = 4, .is_broadwater = 1, .num_pipes = 2,
128*1487f786SFrançois Tigeot 	.has_hotplug = 1,
129*1487f786SFrançois Tigeot 	.has_overlay = 1,
130*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
131*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
132*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
133*1487f786SFrançois Tigeot };
134*1487f786SFrançois Tigeot 
135*1487f786SFrançois Tigeot static const struct intel_device_info intel_i965gm_info = {
136*1487f786SFrançois Tigeot 	.gen = 4, .is_crestline = 1, .num_pipes = 2,
137*1487f786SFrançois Tigeot 	.is_mobile = 1, .has_fbc = 1, .has_hotplug = 1,
138*1487f786SFrançois Tigeot 	.has_overlay = 1,
139*1487f786SFrançois Tigeot 	.supports_tv = 1,
140*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
141*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
142*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
143*1487f786SFrançois Tigeot };
144*1487f786SFrançois Tigeot 
145*1487f786SFrançois Tigeot static const struct intel_device_info intel_g33_info = {
146*1487f786SFrançois Tigeot 	.gen = 3, .is_g33 = 1, .num_pipes = 2,
147*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1,
148*1487f786SFrançois Tigeot 	.has_overlay = 1,
149*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING,
150*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
151*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
152*1487f786SFrançois Tigeot };
153*1487f786SFrançois Tigeot 
154*1487f786SFrançois Tigeot static const struct intel_device_info intel_g45_info = {
155*1487f786SFrançois Tigeot 	.gen = 4, .is_g4x = 1, .need_gfx_hws = 1, .num_pipes = 2,
156*1487f786SFrançois Tigeot 	.has_pipe_cxsr = 1, .has_hotplug = 1,
157*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING,
158*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
159*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
160*1487f786SFrançois Tigeot };
161*1487f786SFrançois Tigeot 
162*1487f786SFrançois Tigeot static const struct intel_device_info intel_gm45_info = {
163*1487f786SFrançois Tigeot 	.gen = 4, .is_g4x = 1, .num_pipes = 2,
164*1487f786SFrançois Tigeot 	.is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1,
165*1487f786SFrançois Tigeot 	.has_pipe_cxsr = 1, .has_hotplug = 1,
166*1487f786SFrançois Tigeot 	.supports_tv = 1,
167*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING,
168*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
169*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
170*1487f786SFrançois Tigeot };
171*1487f786SFrançois Tigeot 
172*1487f786SFrançois Tigeot static const struct intel_device_info intel_pineview_info = {
173*1487f786SFrançois Tigeot 	.gen = 3, .is_g33 = 1, .is_pineview = 1, .is_mobile = 1, .num_pipes = 2,
174*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1,
175*1487f786SFrançois Tigeot 	.has_overlay = 1,
176*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
177*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
178*1487f786SFrançois Tigeot };
179*1487f786SFrançois Tigeot 
180*1487f786SFrançois Tigeot static const struct intel_device_info intel_ironlake_d_info = {
181*1487f786SFrançois Tigeot 	.gen = 5, .num_pipes = 2,
182*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1,
183*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING,
184*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
185*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
186*1487f786SFrançois Tigeot };
187*1487f786SFrançois Tigeot 
188*1487f786SFrançois Tigeot static const struct intel_device_info intel_ironlake_m_info = {
189*1487f786SFrançois Tigeot 	.gen = 5, .is_mobile = 1, .num_pipes = 2,
190*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1,
191*1487f786SFrançois Tigeot 	.has_fbc = 1,
192*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING,
193*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
194*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
195*1487f786SFrançois Tigeot };
196*1487f786SFrançois Tigeot 
197*1487f786SFrançois Tigeot static const struct intel_device_info intel_sandybridge_d_info = {
198*1487f786SFrançois Tigeot 	.gen = 6, .num_pipes = 2,
199*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1,
200*1487f786SFrançois Tigeot 	.has_fbc = 1,
201*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING,
202*1487f786SFrançois Tigeot 	.has_llc = 1,
203*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
204*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
205*1487f786SFrançois Tigeot };
206*1487f786SFrançois Tigeot 
207*1487f786SFrançois Tigeot static const struct intel_device_info intel_sandybridge_m_info = {
208*1487f786SFrançois Tigeot 	.gen = 6, .is_mobile = 1, .num_pipes = 2,
209*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1,
210*1487f786SFrançois Tigeot 	.has_fbc = 1,
211*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING,
212*1487f786SFrançois Tigeot 	.has_llc = 1,
213*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
214*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
215*1487f786SFrançois Tigeot };
216*1487f786SFrançois Tigeot 
217*1487f786SFrançois Tigeot #define GEN7_FEATURES  \
218*1487f786SFrançois Tigeot 	.gen = 7, .num_pipes = 3, \
219*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1, \
220*1487f786SFrançois Tigeot 	.has_fbc = 1, \
221*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
222*1487f786SFrançois Tigeot 	.has_llc = 1, \
223*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS, \
224*1487f786SFrançois Tigeot 	IVB_CURSOR_OFFSETS
225*1487f786SFrançois Tigeot 
226*1487f786SFrançois Tigeot static const struct intel_device_info intel_ivybridge_d_info = {
227*1487f786SFrançois Tigeot 	GEN7_FEATURES,
228*1487f786SFrançois Tigeot 	.is_ivybridge = 1,
229*1487f786SFrançois Tigeot };
230*1487f786SFrançois Tigeot 
231*1487f786SFrançois Tigeot static const struct intel_device_info intel_ivybridge_m_info = {
232*1487f786SFrançois Tigeot 	GEN7_FEATURES,
233*1487f786SFrançois Tigeot 	.is_ivybridge = 1,
234*1487f786SFrançois Tigeot 	.is_mobile = 1,
235*1487f786SFrançois Tigeot };
236*1487f786SFrançois Tigeot 
237*1487f786SFrançois Tigeot static const struct intel_device_info intel_ivybridge_q_info = {
238*1487f786SFrançois Tigeot 	GEN7_FEATURES,
239*1487f786SFrançois Tigeot 	.is_ivybridge = 1,
240*1487f786SFrançois Tigeot 	.num_pipes = 0, /* legal, last one wins */
241*1487f786SFrançois Tigeot };
242*1487f786SFrançois Tigeot 
243*1487f786SFrançois Tigeot #define VLV_FEATURES  \
244*1487f786SFrançois Tigeot 	.gen = 7, .num_pipes = 2, \
245*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1, \
246*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
247*1487f786SFrançois Tigeot 	.display_mmio_offset = VLV_DISPLAY_BASE, \
248*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS, \
249*1487f786SFrançois Tigeot 	CURSOR_OFFSETS
250*1487f786SFrançois Tigeot 
251*1487f786SFrançois Tigeot static const struct intel_device_info intel_valleyview_m_info = {
252*1487f786SFrançois Tigeot 	VLV_FEATURES,
253*1487f786SFrançois Tigeot 	.is_valleyview = 1,
254*1487f786SFrançois Tigeot 	.is_mobile = 1,
255*1487f786SFrançois Tigeot };
256*1487f786SFrançois Tigeot 
257*1487f786SFrançois Tigeot static const struct intel_device_info intel_valleyview_d_info = {
258*1487f786SFrançois Tigeot 	VLV_FEATURES,
259*1487f786SFrançois Tigeot 	.is_valleyview = 1,
260*1487f786SFrançois Tigeot };
261*1487f786SFrançois Tigeot 
262*1487f786SFrançois Tigeot #define HSW_FEATURES  \
263*1487f786SFrançois Tigeot 	GEN7_FEATURES, \
264*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
265*1487f786SFrançois Tigeot 	.has_ddi = 1, \
266*1487f786SFrançois Tigeot 	.has_fpga_dbg = 1
267*1487f786SFrançois Tigeot 
268*1487f786SFrançois Tigeot static const struct intel_device_info intel_haswell_d_info = {
269*1487f786SFrançois Tigeot 	HSW_FEATURES,
270*1487f786SFrançois Tigeot 	.is_haswell = 1,
271*1487f786SFrançois Tigeot };
272*1487f786SFrançois Tigeot 
273*1487f786SFrançois Tigeot static const struct intel_device_info intel_haswell_m_info = {
274*1487f786SFrançois Tigeot 	HSW_FEATURES,
275*1487f786SFrançois Tigeot 	.is_haswell = 1,
276*1487f786SFrançois Tigeot 	.is_mobile = 1,
277*1487f786SFrançois Tigeot };
278*1487f786SFrançois Tigeot 
279*1487f786SFrançois Tigeot #define BDW_FEATURES \
280*1487f786SFrançois Tigeot 	HSW_FEATURES, \
281*1487f786SFrançois Tigeot 	BDW_COLORS
282*1487f786SFrançois Tigeot 
283*1487f786SFrançois Tigeot static const struct intel_device_info intel_broadwell_d_info = {
284*1487f786SFrançois Tigeot 	BDW_FEATURES,
285*1487f786SFrançois Tigeot 	.gen = 8,
286*1487f786SFrançois Tigeot 	.is_broadwell = 1,
287*1487f786SFrançois Tigeot };
288*1487f786SFrançois Tigeot 
289*1487f786SFrançois Tigeot static const struct intel_device_info intel_broadwell_m_info = {
290*1487f786SFrançois Tigeot 	BDW_FEATURES,
291*1487f786SFrançois Tigeot 	.gen = 8, .is_mobile = 1,
292*1487f786SFrançois Tigeot 	.is_broadwell = 1,
293*1487f786SFrançois Tigeot };
294*1487f786SFrançois Tigeot 
295*1487f786SFrançois Tigeot static const struct intel_device_info intel_broadwell_gt3d_info = {
296*1487f786SFrançois Tigeot 	BDW_FEATURES,
297*1487f786SFrançois Tigeot 	.gen = 8,
298*1487f786SFrançois Tigeot 	.is_broadwell = 1,
299*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
300*1487f786SFrançois Tigeot };
301*1487f786SFrançois Tigeot 
302*1487f786SFrançois Tigeot static const struct intel_device_info intel_broadwell_gt3m_info = {
303*1487f786SFrançois Tigeot 	BDW_FEATURES,
304*1487f786SFrançois Tigeot 	.gen = 8, .is_mobile = 1,
305*1487f786SFrançois Tigeot 	.is_broadwell = 1,
306*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
307*1487f786SFrançois Tigeot };
308*1487f786SFrançois Tigeot 
309*1487f786SFrançois Tigeot static const struct intel_device_info intel_cherryview_info = {
310*1487f786SFrançois Tigeot 	.gen = 8, .num_pipes = 3,
311*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1,
312*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
313*1487f786SFrançois Tigeot 	.is_cherryview = 1,
314*1487f786SFrançois Tigeot 	.display_mmio_offset = VLV_DISPLAY_BASE,
315*1487f786SFrançois Tigeot 	GEN_CHV_PIPEOFFSETS,
316*1487f786SFrançois Tigeot 	CURSOR_OFFSETS,
317*1487f786SFrançois Tigeot 	CHV_COLORS,
318*1487f786SFrançois Tigeot };
319*1487f786SFrançois Tigeot 
320*1487f786SFrançois Tigeot static const struct intel_device_info intel_skylake_info = {
321*1487f786SFrançois Tigeot 	BDW_FEATURES,
322*1487f786SFrançois Tigeot 	.is_skylake = 1,
323*1487f786SFrançois Tigeot 	.gen = 9,
324*1487f786SFrançois Tigeot };
325*1487f786SFrançois Tigeot 
326*1487f786SFrançois Tigeot static const struct intel_device_info intel_skylake_gt3_info = {
327*1487f786SFrançois Tigeot 	BDW_FEATURES,
328*1487f786SFrançois Tigeot 	.is_skylake = 1,
329*1487f786SFrançois Tigeot 	.gen = 9,
330*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
331*1487f786SFrançois Tigeot };
332*1487f786SFrançois Tigeot 
333*1487f786SFrançois Tigeot static const struct intel_device_info intel_broxton_info = {
334*1487f786SFrançois Tigeot 	.is_broxton = 1,
335*1487f786SFrançois Tigeot 	.gen = 9,
336*1487f786SFrançois Tigeot 	.need_gfx_hws = 1, .has_hotplug = 1,
337*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
338*1487f786SFrançois Tigeot 	.num_pipes = 3,
339*1487f786SFrançois Tigeot 	.has_ddi = 1,
340*1487f786SFrançois Tigeot 	.has_fpga_dbg = 1,
341*1487f786SFrançois Tigeot 	.has_fbc = 1,
342*1487f786SFrançois Tigeot 	.has_pooled_eu = 0,
343*1487f786SFrançois Tigeot 	GEN_DEFAULT_PIPEOFFSETS,
344*1487f786SFrançois Tigeot 	IVB_CURSOR_OFFSETS,
345*1487f786SFrançois Tigeot 	BDW_COLORS,
346*1487f786SFrançois Tigeot };
347*1487f786SFrançois Tigeot 
348*1487f786SFrançois Tigeot static const struct intel_device_info intel_kabylake_info = {
349*1487f786SFrançois Tigeot 	BDW_FEATURES,
350*1487f786SFrançois Tigeot 	.is_kabylake = 1,
351*1487f786SFrançois Tigeot 	.gen = 9,
352*1487f786SFrançois Tigeot };
353*1487f786SFrançois Tigeot 
354*1487f786SFrançois Tigeot static const struct intel_device_info intel_kabylake_gt2_info = {
355*1487f786SFrançois Tigeot 	BDW_FEATURES,
356*1487f786SFrançois Tigeot 	.is_kabylake = 1,
357*1487f786SFrançois Tigeot 	.gen = 9,
358*1487f786SFrançois Tigeot };
359*1487f786SFrançois Tigeot 
360*1487f786SFrançois Tigeot static const struct intel_device_info intel_kabylake_gt3_info = {
361*1487f786SFrançois Tigeot 	BDW_FEATURES,
362*1487f786SFrançois Tigeot 	.is_kabylake = 1,
363*1487f786SFrançois Tigeot 	.gen = 9,
364*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
365*1487f786SFrançois Tigeot };
366*1487f786SFrançois Tigeot 
367*1487f786SFrançois Tigeot static const struct intel_device_info intel_coffeelake_gt1_info = {
368*1487f786SFrançois Tigeot 	BDW_FEATURES, \
369*1487f786SFrançois Tigeot 	.is_kabylake = 1,
370*1487f786SFrançois Tigeot 	.gen = 9,
371*1487f786SFrançois Tigeot };
372*1487f786SFrançois Tigeot 
373*1487f786SFrançois Tigeot static const struct intel_device_info intel_coffeelake_gt2_info = {
374*1487f786SFrançois Tigeot 	BDW_FEATURES, \
375*1487f786SFrançois Tigeot 	.is_kabylake = 1,
376*1487f786SFrançois Tigeot 	.gen = 9,
377*1487f786SFrançois Tigeot };
378*1487f786SFrançois Tigeot 
379*1487f786SFrançois Tigeot static const struct intel_device_info intel_coffeelake_gt3_info = {
380*1487f786SFrançois Tigeot 	BDW_FEATURES, \
381*1487f786SFrançois Tigeot 	.is_kabylake = 1,
382*1487f786SFrançois Tigeot 	.gen = 9,
383*1487f786SFrançois Tigeot 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
384*1487f786SFrançois Tigeot };
385*1487f786SFrançois Tigeot 
386*1487f786SFrançois Tigeot /*
387*1487f786SFrançois Tigeot  * Make sure any device matches here are from most specific to most
388*1487f786SFrançois Tigeot  * general.  For example, since the Quanta match is based on the subsystem
389*1487f786SFrançois Tigeot  * and subvendor IDs, we need it to come before the more general IVB
390*1487f786SFrançois Tigeot  * PCI ID matches, otherwise we'll use the wrong info struct above.
391*1487f786SFrançois Tigeot  */
392*1487f786SFrançois Tigeot static const struct pci_device_id pciidlist[] = {
393*1487f786SFrançois Tigeot 	INTEL_I830_IDS(&intel_i830_info),
394*1487f786SFrançois Tigeot 	INTEL_I845G_IDS(&intel_845g_info),
395*1487f786SFrançois Tigeot 	INTEL_I85X_IDS(&intel_i85x_info),
396*1487f786SFrançois Tigeot 	INTEL_I865G_IDS(&intel_i865g_info),
397*1487f786SFrançois Tigeot 	INTEL_I915G_IDS(&intel_i915g_info),
398*1487f786SFrançois Tigeot 	INTEL_I915GM_IDS(&intel_i915gm_info),
399*1487f786SFrançois Tigeot 	INTEL_I945G_IDS(&intel_i945g_info),
400*1487f786SFrançois Tigeot 	INTEL_I945GM_IDS(&intel_i945gm_info),
401*1487f786SFrançois Tigeot 	INTEL_I965G_IDS(&intel_i965g_info),
402*1487f786SFrançois Tigeot 	INTEL_G33_IDS(&intel_g33_info),
403*1487f786SFrançois Tigeot 	INTEL_I965GM_IDS(&intel_i965gm_info),
404*1487f786SFrançois Tigeot 	INTEL_GM45_IDS(&intel_gm45_info),
405*1487f786SFrançois Tigeot 	INTEL_G45_IDS(&intel_g45_info),
406*1487f786SFrançois Tigeot 	INTEL_PINEVIEW_IDS(&intel_pineview_info),
407*1487f786SFrançois Tigeot 	INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),
408*1487f786SFrançois Tigeot 	INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
409*1487f786SFrançois Tigeot 	INTEL_SNB_D_IDS(&intel_sandybridge_d_info),
410*1487f786SFrançois Tigeot 	INTEL_SNB_M_IDS(&intel_sandybridge_m_info),
411*1487f786SFrançois Tigeot 	INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
412*1487f786SFrançois Tigeot 	INTEL_IVB_M_IDS(&intel_ivybridge_m_info),
413*1487f786SFrançois Tigeot 	INTEL_IVB_D_IDS(&intel_ivybridge_d_info),
414*1487f786SFrançois Tigeot 	INTEL_HSW_D_IDS(&intel_haswell_d_info),
415*1487f786SFrançois Tigeot 	INTEL_HSW_M_IDS(&intel_haswell_m_info),
416*1487f786SFrançois Tigeot 	INTEL_VLV_M_IDS(&intel_valleyview_m_info),
417*1487f786SFrançois Tigeot 	INTEL_VLV_D_IDS(&intel_valleyview_d_info),
418*1487f786SFrançois Tigeot 	INTEL_BDW_GT12M_IDS(&intel_broadwell_m_info),
419*1487f786SFrançois Tigeot 	INTEL_BDW_GT12D_IDS(&intel_broadwell_d_info),
420*1487f786SFrançois Tigeot 	INTEL_BDW_GT3M_IDS(&intel_broadwell_gt3m_info),
421*1487f786SFrançois Tigeot 	INTEL_BDW_GT3D_IDS(&intel_broadwell_gt3d_info),
422*1487f786SFrançois Tigeot 	INTEL_CHV_IDS(&intel_cherryview_info),
423*1487f786SFrançois Tigeot 	INTEL_SKL_GT1_IDS(&intel_skylake_info),
424*1487f786SFrançois Tigeot 	INTEL_SKL_GT2_IDS(&intel_skylake_info),
425*1487f786SFrançois Tigeot 	INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
426*1487f786SFrançois Tigeot 	INTEL_SKL_GT4_IDS(&intel_skylake_gt3_info),
427*1487f786SFrançois Tigeot 	INTEL_BXT_IDS(&intel_broxton_info),
428*1487f786SFrançois Tigeot 	INTEL_KBL_GT1_IDS(&intel_kabylake_info),
429*1487f786SFrançois Tigeot 	INTEL_KBL_GT2_IDS(&intel_kabylake_info),
430*1487f786SFrançois Tigeot 	INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
431*1487f786SFrançois Tigeot 	INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
432*1487f786SFrançois Tigeot 	INTEL_AML_GT2_IDS(&intel_kabylake_gt2_info),
433*1487f786SFrançois Tigeot 	INTEL_CFL_S_GT1_IDS(&intel_coffeelake_gt1_info),
434*1487f786SFrançois Tigeot 	INTEL_CFL_S_GT2_IDS(&intel_coffeelake_gt2_info),
435*1487f786SFrançois Tigeot 	INTEL_CFL_H_GT2_IDS(&intel_coffeelake_gt2_info),
436*1487f786SFrançois Tigeot 	INTEL_CFL_U_GT2_IDS(&intel_coffeelake_gt2_info),
437*1487f786SFrançois Tigeot 	INTEL_CFL_U_GT3_IDS(&intel_coffeelake_gt3_info),
438*1487f786SFrançois Tigeot 	INTEL_WHL_U_GT1_IDS(&intel_coffeelake_gt1_info),
439*1487f786SFrançois Tigeot 	INTEL_WHL_U_GT2_IDS(&intel_coffeelake_gt2_info),
440*1487f786SFrançois Tigeot 	INTEL_WHL_U_GT3_IDS(&intel_coffeelake_gt3_info),
441*1487f786SFrançois Tigeot 	{0, 0, 0}
442*1487f786SFrançois Tigeot };
443*1487f786SFrançois Tigeot MODULE_DEVICE_TABLE(pci, pciidlist);
444*1487f786SFrançois Tigeot 
445*1487f786SFrançois Tigeot extern int i915_driver_load(struct pci_dev *pdev,
446*1487f786SFrançois Tigeot 			    const struct pci_device_id *ent);
447*1487f786SFrançois Tigeot 
448*1487f786SFrançois Tigeot static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
449*1487f786SFrançois Tigeot {
450*1487f786SFrançois Tigeot 	struct intel_device_info *intel_info =
451*1487f786SFrançois Tigeot 		(struct intel_device_info *) ent->driver_data;
452*1487f786SFrançois Tigeot 
453*1487f786SFrançois Tigeot 	if (IS_PRELIMINARY_HW(intel_info) && !i915.preliminary_hw_support) {
454*1487f786SFrançois Tigeot 		DRM_INFO("This hardware requires preliminary hardware support.\n"
455*1487f786SFrançois Tigeot 			 "See CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT, and/or modparam preliminary_hw_support\n");
456*1487f786SFrançois Tigeot 		return -ENODEV;
457*1487f786SFrançois Tigeot 	}
458*1487f786SFrançois Tigeot 
459*1487f786SFrançois Tigeot 	/* Only bind to function 0 of the device. Early generations
460*1487f786SFrançois Tigeot 	 * used function 1 as a placeholder for multi-head. This causes
461*1487f786SFrançois Tigeot 	 * us confusion instead, especially on the systems where both
462*1487f786SFrançois Tigeot 	 * functions have the same PCI-ID!
463*1487f786SFrançois Tigeot 	 */
464*1487f786SFrançois Tigeot 	if (PCI_FUNC(pdev->devfn))
465*1487f786SFrançois Tigeot 		return -ENODEV;
466*1487f786SFrançois Tigeot 
467*1487f786SFrançois Tigeot 	/*
468*1487f786SFrançois Tigeot 	 * apple-gmux is needed on dual GPU MacBook Pro
469*1487f786SFrançois Tigeot 	 * to probe the panel if we're the inactive GPU.
470*1487f786SFrançois Tigeot 	 */
471*1487f786SFrançois Tigeot 	if (vga_switcheroo_client_probe_defer(pdev))
472*1487f786SFrançois Tigeot 		return -EPROBE_DEFER;
473*1487f786SFrançois Tigeot 
474*1487f786SFrançois Tigeot 	return i915_driver_load(pdev, ent);
475*1487f786SFrançois Tigeot }
476*1487f786SFrançois Tigeot 
477*1487f786SFrançois Tigeot extern void i915_driver_unload(struct drm_device *dev);
478*1487f786SFrançois Tigeot 
479*1487f786SFrançois Tigeot static void i915_pci_remove(struct pci_dev *pdev)
480*1487f786SFrançois Tigeot {
481*1487f786SFrançois Tigeot 	struct drm_device *dev = pci_get_drvdata(pdev);
482*1487f786SFrançois Tigeot 
483*1487f786SFrançois Tigeot 	i915_driver_unload(dev);
484*1487f786SFrançois Tigeot 	drm_dev_unref(dev);
485*1487f786SFrançois Tigeot }
486*1487f786SFrançois Tigeot 
487*1487f786SFrançois Tigeot extern const struct dev_pm_ops i915_pm_ops;
488*1487f786SFrançois Tigeot 
489*1487f786SFrançois Tigeot static struct pci_driver i915_pci_driver = {
490*1487f786SFrançois Tigeot 	.name = DRIVER_NAME,
491*1487f786SFrançois Tigeot 	.id_table = pciidlist,
492*1487f786SFrançois Tigeot 	.probe = i915_pci_probe,
493*1487f786SFrançois Tigeot 	.remove = i915_pci_remove,
494*1487f786SFrançois Tigeot #if 0
495*1487f786SFrançois Tigeot 	.driver.pm = &i915_pm_ops,
496*1487f786SFrançois Tigeot #endif
497*1487f786SFrançois Tigeot };
498*1487f786SFrançois Tigeot 
499*1487f786SFrançois Tigeot static int __init i915_init(void)
500*1487f786SFrançois Tigeot {
501*1487f786SFrançois Tigeot 	bool use_kms = true;
502*1487f786SFrançois Tigeot 
503*1487f786SFrançois Tigeot 	/*
504*1487f786SFrançois Tigeot 	 * Enable KMS by default, unless explicitly overriden by
505*1487f786SFrançois Tigeot 	 * either the i915.modeset prarameter or by the
506*1487f786SFrançois Tigeot 	 * vga_text_mode_force boot option.
507*1487f786SFrançois Tigeot 	 */
508*1487f786SFrançois Tigeot 
509*1487f786SFrançois Tigeot 	if (i915.modeset == 0)
510*1487f786SFrançois Tigeot 		use_kms = false;
511*1487f786SFrançois Tigeot 
512*1487f786SFrançois Tigeot 	if (vgacon_text_force() && i915.modeset == -1)
513*1487f786SFrançois Tigeot 		use_kms = false;
514*1487f786SFrançois Tigeot 
515*1487f786SFrançois Tigeot 	if (!use_kms) {
516*1487f786SFrançois Tigeot 		/* Silently fail loading to not upset userspace. */
517*1487f786SFrançois Tigeot 		DRM_DEBUG_DRIVER("KMS disabled.\n");
518*1487f786SFrançois Tigeot 		return 0;
519*1487f786SFrançois Tigeot 	}
520*1487f786SFrançois Tigeot 
521*1487f786SFrançois Tigeot 	return pci_register_driver(&i915_pci_driver);
522*1487f786SFrançois Tigeot }
523*1487f786SFrançois Tigeot 
524*1487f786SFrançois Tigeot static void __exit i915_exit(void)
525*1487f786SFrançois Tigeot {
526*1487f786SFrançois Tigeot #if 0
527*1487f786SFrançois Tigeot 	if (!i915_pci_driver.driver.owner)
528*1487f786SFrançois Tigeot 		return;
529*1487f786SFrançois Tigeot #endif
530*1487f786SFrançois Tigeot 
531*1487f786SFrançois Tigeot 	pci_unregister_driver(&i915_pci_driver);
532*1487f786SFrançois Tigeot }
533*1487f786SFrançois Tigeot 
534*1487f786SFrançois Tigeot module_init(i915_init);
535*1487f786SFrançois Tigeot module_exit(i915_exit);
536*1487f786SFrançois Tigeot 
537*1487f786SFrançois Tigeot MODULE_AUTHOR("Tungsten Graphics, Inc.");
538*1487f786SFrançois Tigeot MODULE_AUTHOR("Intel Corporation");
539*1487f786SFrançois Tigeot 
540*1487f786SFrançois Tigeot static int
541*1487f786SFrançois Tigeot i915_pci_probe_dfly(device_t kdev)
542*1487f786SFrançois Tigeot {
543*1487f786SFrançois Tigeot 	int device, i = 0;
544*1487f786SFrançois Tigeot 	const struct pci_device_id *ent;
545*1487f786SFrançois Tigeot 	static struct pci_dev *pdev = NULL;
546*1487f786SFrançois Tigeot 	static device_t bsddev;
547*1487f786SFrançois Tigeot 
548*1487f786SFrançois Tigeot 	if (pci_get_class(kdev) != PCIC_DISPLAY)
549*1487f786SFrançois Tigeot 		return ENXIO;
550*1487f786SFrançois Tigeot 
551*1487f786SFrançois Tigeot 	if (pci_get_vendor(kdev) != PCI_VENDOR_ID_INTEL)
552*1487f786SFrançois Tigeot 		return ENXIO;
553*1487f786SFrançois Tigeot 
554*1487f786SFrançois Tigeot 	device = pci_get_device(kdev);
555*1487f786SFrançois Tigeot 
556*1487f786SFrançois Tigeot 	for (i = 0; pciidlist[i].device != 0; i++) {
557*1487f786SFrançois Tigeot 		if (pciidlist[i].device == device) {
558*1487f786SFrançois Tigeot 			ent = &pciidlist[i];
559*1487f786SFrançois Tigeot 			goto found;
560*1487f786SFrançois Tigeot 		}
561*1487f786SFrançois Tigeot 	}
562*1487f786SFrançois Tigeot 
563*1487f786SFrançois Tigeot 	return ENXIO;
564*1487f786SFrançois Tigeot found:
565*1487f786SFrançois Tigeot 	if (!strcmp(device_get_name(kdev), "drmsub"))
566*1487f786SFrançois Tigeot 		bsddev = device_get_parent(kdev);
567*1487f786SFrançois Tigeot 	else
568*1487f786SFrançois Tigeot 		bsddev = kdev;
569*1487f786SFrançois Tigeot 
570*1487f786SFrançois Tigeot 	drm_init_pdev(bsddev, &pdev);
571*1487f786SFrançois Tigeot 
572*1487f786SFrançois Tigeot 	/* Print the contents of pdev struct. */
573*1487f786SFrançois Tigeot 	drm_print_pdev(pdev);
574*1487f786SFrançois Tigeot 
575*1487f786SFrançois Tigeot 	return i915_pci_probe(pdev, ent);
576*1487f786SFrançois Tigeot }
577*1487f786SFrançois Tigeot 
578*1487f786SFrançois Tigeot static int i915_driver_attach(device_t kdev)
579*1487f786SFrançois Tigeot {
580*1487f786SFrançois Tigeot 	return 0;
581*1487f786SFrançois Tigeot }
582*1487f786SFrançois Tigeot 
583*1487f786SFrançois Tigeot static device_method_t i915_methods[] = {
584*1487f786SFrançois Tigeot 	/* Device interface */
585*1487f786SFrançois Tigeot 	DEVMETHOD(device_probe,		i915_pci_probe_dfly),
586*1487f786SFrançois Tigeot 	DEVMETHOD(device_attach,	i915_driver_attach),
587*1487f786SFrançois Tigeot 	DEVMETHOD(device_suspend,	i915_suspend_switcheroo),
588*1487f786SFrançois Tigeot 	DEVMETHOD(device_resume,	i915_resume_switcheroo),
589*1487f786SFrançois Tigeot 	DEVMETHOD(device_detach,	drm_release),
590*1487f786SFrançois Tigeot 	DEVMETHOD_END
591*1487f786SFrançois Tigeot };
592*1487f786SFrançois Tigeot 
593*1487f786SFrançois Tigeot static driver_t i915_driver = {
594*1487f786SFrançois Tigeot 	"drm",
595*1487f786SFrançois Tigeot 	i915_methods,
596*1487f786SFrançois Tigeot 	sizeof(struct drm_softc)
597*1487f786SFrançois Tigeot };
598*1487f786SFrançois Tigeot 
599*1487f786SFrançois Tigeot extern devclass_t drm_devclass;
600*1487f786SFrançois Tigeot 
601*1487f786SFrançois Tigeot DRIVER_MODULE_ORDERED(i915, vgapci, i915_driver, drm_devclass, NULL, NULL, SI_ORDER_ANY);
602*1487f786SFrançois Tigeot MODULE_DEPEND(i915, drm, 1, 1, 1);
603*1487f786SFrançois Tigeot #ifdef CONFIG_ACPI
604*1487f786SFrançois Tigeot MODULE_DEPEND(i915, acpi, 1, 1, 1);
605*1487f786SFrançois Tigeot #endif
606