blob: dc167b0e0b7480f1fc63c3fb4aa1b37150b2c60e [file] [log] [blame]
Chris Wilson42f55512016-06-24 14:00:26 +01001/*
2 * Copyright © 2016 Intel Corporation
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
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
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24
Chris Wilsona09d0ba2016-06-24 14:00:27 +010025#include <linux/console.h>
Chris Wilson42f55512016-06-24 14:00:26 +010026#include <linux/vgaarb.h>
27#include <linux/vga_switcheroo.h>
28
29#include "i915_drv.h"
30
31#define GEN_DEFAULT_PIPEOFFSETS \
32 .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
33 PIPE_C_OFFSET, PIPE_EDP_OFFSET }, \
34 .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
35 TRANSCODER_C_OFFSET, TRANSCODER_EDP_OFFSET }, \
36 .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET }
37
38#define GEN_CHV_PIPEOFFSETS \
39 .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
40 CHV_PIPE_C_OFFSET }, \
41 .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
42 CHV_TRANSCODER_C_OFFSET, }, \
43 .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET, \
44 CHV_PALETTE_C_OFFSET }
45
46#define CURSOR_OFFSETS \
47 .cursor_offsets = { CURSOR_A_OFFSET, CURSOR_B_OFFSET, CHV_CURSOR_C_OFFSET }
48
49#define IVB_CURSOR_OFFSETS \
50 .cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }
51
52#define BDW_COLORS \
53 .color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
54#define CHV_COLORS \
55 .color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }
56
Carlos Santa0eec8dc2016-08-17 12:30:51 -070057#define GEN2_FEATURES \
58 .gen = 2, .num_pipes = 1, \
59 .has_overlay = 1, .overlay_needs_physical = 1, \
60 .ring_mask = RENDER_RING, \
61 GEN_DEFAULT_PIPEOFFSETS, \
62 CURSOR_OFFSETS
63
Chris Wilson42f55512016-06-24 14:00:26 +010064static const struct intel_device_info intel_i830_info = {
Carlos Santa0eec8dc2016-08-17 12:30:51 -070065 GEN2_FEATURES,
66 .is_mobile = 1, .cursor_needs_physical = 1,
67 .num_pipes = 2, /* legal, last one wins */
Chris Wilson42f55512016-06-24 14:00:26 +010068};
69
70static const struct intel_device_info intel_845g_info = {
Carlos Santa0eec8dc2016-08-17 12:30:51 -070071 GEN2_FEATURES,
Chris Wilson42f55512016-06-24 14:00:26 +010072};
73
74static const struct intel_device_info intel_i85x_info = {
Carlos Santa0eec8dc2016-08-17 12:30:51 -070075 GEN2_FEATURES,
76 .is_i85x = 1, .is_mobile = 1,
77 .num_pipes = 2, /* legal, last one wins */
Chris Wilson42f55512016-06-24 14:00:26 +010078 .cursor_needs_physical = 1,
Chris Wilson42f55512016-06-24 14:00:26 +010079 .has_fbc = 1,
Chris Wilson42f55512016-06-24 14:00:26 +010080};
81
82static const struct intel_device_info intel_i865g_info = {
Carlos Santa0eec8dc2016-08-17 12:30:51 -070083 GEN2_FEATURES,
Chris Wilson42f55512016-06-24 14:00:26 +010084};
85
Carlos Santa54d2a6a2016-08-17 12:30:50 -070086#define GEN3_FEATURES \
87 .gen = 3, .num_pipes = 2, \
88 .ring_mask = RENDER_RING, \
89 GEN_DEFAULT_PIPEOFFSETS, \
90 CURSOR_OFFSETS
91
Chris Wilson42f55512016-06-24 14:00:26 +010092static const struct intel_device_info intel_i915g_info = {
Carlos Santa54d2a6a2016-08-17 12:30:50 -070093 GEN3_FEATURES,
94 .is_i915g = 1, .cursor_needs_physical = 1,
Chris Wilson42f55512016-06-24 14:00:26 +010095 .has_overlay = 1, .overlay_needs_physical = 1,
Chris Wilson42f55512016-06-24 14:00:26 +010096};
97static const struct intel_device_info intel_i915gm_info = {
Carlos Santa54d2a6a2016-08-17 12:30:50 -070098 GEN3_FEATURES,
99 .is_mobile = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100100 .cursor_needs_physical = 1,
101 .has_overlay = 1, .overlay_needs_physical = 1,
102 .supports_tv = 1,
103 .has_fbc = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100104};
105static const struct intel_device_info intel_i945g_info = {
Carlos Santa54d2a6a2016-08-17 12:30:50 -0700106 GEN3_FEATURES,
107 .has_hotplug = 1, .cursor_needs_physical = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100108 .has_overlay = 1, .overlay_needs_physical = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100109};
110static const struct intel_device_info intel_i945gm_info = {
Carlos Santa54d2a6a2016-08-17 12:30:50 -0700111 GEN3_FEATURES,
112 .is_i945gm = 1, .is_mobile = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100113 .has_hotplug = 1, .cursor_needs_physical = 1,
114 .has_overlay = 1, .overlay_needs_physical = 1,
115 .supports_tv = 1,
116 .has_fbc = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100117};
118
Carlos Santa4d495be2016-08-17 12:30:49 -0700119#define GEN4_FEATURES \
120 .gen = 4, .num_pipes = 2, \
121 .has_hotplug = 1, \
122 .ring_mask = RENDER_RING, \
123 GEN_DEFAULT_PIPEOFFSETS, \
124 CURSOR_OFFSETS
125
Chris Wilson42f55512016-06-24 14:00:26 +0100126static const struct intel_device_info intel_i965g_info = {
Carlos Santa4d495be2016-08-17 12:30:49 -0700127 GEN4_FEATURES,
128 .is_broadwater = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100129 .has_overlay = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100130};
131
132static const struct intel_device_info intel_i965gm_info = {
Carlos Santa4d495be2016-08-17 12:30:49 -0700133 GEN4_FEATURES,
134 .is_crestline = 1,
135 .is_mobile = 1, .has_fbc = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100136 .has_overlay = 1,
137 .supports_tv = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100138};
139
140static const struct intel_device_info intel_g33_info = {
Carlos Santa54d2a6a2016-08-17 12:30:50 -0700141 GEN3_FEATURES,
142 .is_g33 = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100143 .need_gfx_hws = 1, .has_hotplug = 1,
144 .has_overlay = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100145};
146
147static const struct intel_device_info intel_g45_info = {
Carlos Santa4d495be2016-08-17 12:30:49 -0700148 GEN4_FEATURES,
149 .is_g4x = 1, .need_gfx_hws = 1,
150 .has_pipe_cxsr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100151 .ring_mask = RENDER_RING | BSD_RING,
Chris Wilson42f55512016-06-24 14:00:26 +0100152};
153
154static const struct intel_device_info intel_gm45_info = {
Carlos Santa4d495be2016-08-17 12:30:49 -0700155 GEN4_FEATURES,
156 .is_g4x = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100157 .is_mobile = 1, .need_gfx_hws = 1, .has_fbc = 1,
Carlos Santa4d495be2016-08-17 12:30:49 -0700158 .has_pipe_cxsr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100159 .supports_tv = 1,
160 .ring_mask = RENDER_RING | BSD_RING,
Chris Wilson42f55512016-06-24 14:00:26 +0100161};
162
163static const struct intel_device_info intel_pineview_info = {
Carlos Santa54d2a6a2016-08-17 12:30:50 -0700164 GEN3_FEATURES,
165 .is_g33 = 1, .is_pineview = 1, .is_mobile = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100166 .need_gfx_hws = 1, .has_hotplug = 1,
167 .has_overlay = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100168};
169
Carlos Santaa1323382016-08-17 12:30:47 -0700170#define GEN5_FEATURES \
171 .gen = 5, .num_pipes = 2, \
172 .need_gfx_hws = 1, .has_hotplug = 1, \
Carlos Santab355f102016-08-17 12:30:48 -0700173 .has_gmbus_irq = 1, \
Carlos Santaa1323382016-08-17 12:30:47 -0700174 .ring_mask = RENDER_RING | BSD_RING, \
175 GEN_DEFAULT_PIPEOFFSETS, \
176 CURSOR_OFFSETS
177
Chris Wilson42f55512016-06-24 14:00:26 +0100178static const struct intel_device_info intel_ironlake_d_info = {
Carlos Santaa1323382016-08-17 12:30:47 -0700179 GEN5_FEATURES,
Chris Wilson42f55512016-06-24 14:00:26 +0100180};
181
182static const struct intel_device_info intel_ironlake_m_info = {
Carlos Santaa1323382016-08-17 12:30:47 -0700183 GEN5_FEATURES,
184 .is_mobile = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100185};
186
Carlos Santa07db6be2016-08-17 12:30:38 -0700187#define GEN6_FEATURES \
188 .gen = 6, .num_pipes = 2, \
189 .need_gfx_hws = 1, .has_hotplug = 1, \
190 .has_fbc = 1, \
191 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
192 .has_llc = 1, \
Carlos Santa86f36242016-08-17 12:30:44 -0700193 .has_rc6 = 1, \
Carlos Santa33b5bf82016-08-17 12:30:45 -0700194 .has_rc6p = 1, \
Carlos Santab355f102016-08-17 12:30:48 -0700195 .has_gmbus_irq = 1, \
Carlos Santae1a525362016-08-17 12:30:52 -0700196 .has_hw_contexts = 1, \
Carlos Santa07db6be2016-08-17 12:30:38 -0700197 GEN_DEFAULT_PIPEOFFSETS, \
198 CURSOR_OFFSETS
199
Chris Wilson42f55512016-06-24 14:00:26 +0100200static const struct intel_device_info intel_sandybridge_d_info = {
Carlos Santa07db6be2016-08-17 12:30:38 -0700201 GEN6_FEATURES,
Chris Wilson42f55512016-06-24 14:00:26 +0100202};
203
204static const struct intel_device_info intel_sandybridge_m_info = {
Carlos Santa07db6be2016-08-17 12:30:38 -0700205 GEN6_FEATURES,
206 .is_mobile = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100207};
208
209#define GEN7_FEATURES \
210 .gen = 7, .num_pipes = 3, \
211 .need_gfx_hws = 1, .has_hotplug = 1, \
212 .has_fbc = 1, \
213 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
214 .has_llc = 1, \
Carlos Santa86f36242016-08-17 12:30:44 -0700215 .has_rc6 = 1, \
Carlos Santa33b5bf82016-08-17 12:30:45 -0700216 .has_rc6p = 1, \
Carlos Santab355f102016-08-17 12:30:48 -0700217 .has_gmbus_irq = 1, \
Carlos Santae1a525362016-08-17 12:30:52 -0700218 .has_hw_contexts = 1, \
Chris Wilson42f55512016-06-24 14:00:26 +0100219 GEN_DEFAULT_PIPEOFFSETS, \
220 IVB_CURSOR_OFFSETS
221
222static const struct intel_device_info intel_ivybridge_d_info = {
223 GEN7_FEATURES,
224 .is_ivybridge = 1,
225};
226
227static const struct intel_device_info intel_ivybridge_m_info = {
228 GEN7_FEATURES,
229 .is_ivybridge = 1,
230 .is_mobile = 1,
231};
232
233static const struct intel_device_info intel_ivybridge_q_info = {
234 GEN7_FEATURES,
235 .is_ivybridge = 1,
236 .num_pipes = 0, /* legal, last one wins */
237};
238
239#define VLV_FEATURES \
240 .gen = 7, .num_pipes = 2, \
Carlos Santa6e3b84d2016-08-17 12:30:36 -0700241 .has_psr = 1, \
Carlos Santa4aa4c232016-08-17 12:30:39 -0700242 .has_runtime_pm = 1, \
Carlos Santa86f36242016-08-17 12:30:44 -0700243 .has_rc6 = 1, \
Carlos Santab355f102016-08-17 12:30:48 -0700244 .has_gmbus_irq = 1, \
Carlos Santae1a525362016-08-17 12:30:52 -0700245 .has_hw_contexts = 1, \
Chris Wilson42f55512016-06-24 14:00:26 +0100246 .need_gfx_hws = 1, .has_hotplug = 1, \
247 .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
248 .display_mmio_offset = VLV_DISPLAY_BASE, \
249 GEN_DEFAULT_PIPEOFFSETS, \
250 CURSOR_OFFSETS
251
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700252static const struct intel_device_info intel_valleyview_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100253 VLV_FEATURES,
254 .is_valleyview = 1,
255};
256
257#define HSW_FEATURES \
258 GEN7_FEATURES, \
259 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
260 .has_ddi = 1, \
Carlos Santa6e3b84d2016-08-17 12:30:36 -0700261 .has_fpga_dbg = 1, \
Carlos Santa4aa4c232016-08-17 12:30:39 -0700262 .has_psr = 1, \
Carlos Santa53233f02016-08-17 12:30:43 -0700263 .has_resource_streamer = 1, \
Carlos Santa1d3fe532016-08-17 12:30:46 -0700264 .has_dp_mst = 1, \
Carlos Santa33b5bf82016-08-17 12:30:45 -0700265 .has_rc6p = 0 /* RC6p removed-by HSW */, \
Carlos Santa4aa4c232016-08-17 12:30:39 -0700266 .has_runtime_pm = 1
Chris Wilson42f55512016-06-24 14:00:26 +0100267
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700268static const struct intel_device_info intel_haswell_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100269 HSW_FEATURES,
270 .is_haswell = 1,
271};
272
Chris Wilson42f55512016-06-24 14:00:26 +0100273#define BDW_FEATURES \
274 HSW_FEATURES, \
Carlos Santa4586f1d2016-08-17 12:30:53 -0700275 BDW_COLORS, \
276 .has_logical_ring_contexts = 1
Chris Wilson42f55512016-06-24 14:00:26 +0100277
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700278static const struct intel_device_info intel_broadwell_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100279 BDW_FEATURES,
280 .gen = 8,
281 .is_broadwell = 1,
282};
283
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700284static const struct intel_device_info intel_broadwell_gt3_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100285 BDW_FEATURES,
286 .gen = 8,
287 .is_broadwell = 1,
288 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
289};
290
Chris Wilson42f55512016-06-24 14:00:26 +0100291static const struct intel_device_info intel_cherryview_info = {
292 .gen = 8, .num_pipes = 3,
293 .need_gfx_hws = 1, .has_hotplug = 1,
294 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
295 .is_cherryview = 1,
Carlos Santa6e3b84d2016-08-17 12:30:36 -0700296 .has_psr = 1,
Carlos Santa4aa4c232016-08-17 12:30:39 -0700297 .has_runtime_pm = 1,
Carlos Santa53233f02016-08-17 12:30:43 -0700298 .has_resource_streamer = 1,
Carlos Santa86f36242016-08-17 12:30:44 -0700299 .has_rc6 = 1,
Carlos Santab355f102016-08-17 12:30:48 -0700300 .has_gmbus_irq = 1,
Carlos Santae1a525362016-08-17 12:30:52 -0700301 .has_hw_contexts = 1,
Carlos Santa4586f1d2016-08-17 12:30:53 -0700302 .has_logical_ring_contexts = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100303 .display_mmio_offset = VLV_DISPLAY_BASE,
304 GEN_CHV_PIPEOFFSETS,
305 CURSOR_OFFSETS,
306 CHV_COLORS,
307};
308
309static const struct intel_device_info intel_skylake_info = {
310 BDW_FEATURES,
311 .is_skylake = 1,
312 .gen = 9,
Carlos Santa3bacde12016-08-17 12:30:42 -0700313 .has_csr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100314};
315
316static const struct intel_device_info intel_skylake_gt3_info = {
317 BDW_FEATURES,
318 .is_skylake = 1,
319 .gen = 9,
Carlos Santa3bacde12016-08-17 12:30:42 -0700320 .has_csr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100321 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
322};
323
324static const struct intel_device_info intel_broxton_info = {
Chris Wilson42f55512016-06-24 14:00:26 +0100325 .is_broxton = 1,
326 .gen = 9,
327 .need_gfx_hws = 1, .has_hotplug = 1,
328 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
329 .num_pipes = 3,
330 .has_ddi = 1,
331 .has_fpga_dbg = 1,
332 .has_fbc = 1,
Carlos Santa4aa4c232016-08-17 12:30:39 -0700333 .has_runtime_pm = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100334 .has_pooled_eu = 0,
Carlos Santa3bacde12016-08-17 12:30:42 -0700335 .has_csr = 1,
Carlos Santa53233f02016-08-17 12:30:43 -0700336 .has_resource_streamer = 1,
Carlos Santa86f36242016-08-17 12:30:44 -0700337 .has_rc6 = 1,
Carlos Santa1d3fe532016-08-17 12:30:46 -0700338 .has_dp_mst = 1,
Carlos Santab355f102016-08-17 12:30:48 -0700339 .has_gmbus_irq = 1,
Carlos Santae1a525362016-08-17 12:30:52 -0700340 .has_hw_contexts = 1,
Carlos Santa4586f1d2016-08-17 12:30:53 -0700341 .has_logical_ring_contexts = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100342 GEN_DEFAULT_PIPEOFFSETS,
343 IVB_CURSOR_OFFSETS,
344 BDW_COLORS,
345};
346
347static const struct intel_device_info intel_kabylake_info = {
348 BDW_FEATURES,
349 .is_kabylake = 1,
350 .gen = 9,
Carlos Santa3bacde12016-08-17 12:30:42 -0700351 .has_csr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100352};
353
354static const struct intel_device_info intel_kabylake_gt3_info = {
355 BDW_FEATURES,
356 .is_kabylake = 1,
357 .gen = 9,
Carlos Santa3bacde12016-08-17 12:30:42 -0700358 .has_csr = 1,
Chris Wilson42f55512016-06-24 14:00:26 +0100359 .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
360};
361
362/*
363 * Make sure any device matches here are from most specific to most
364 * general. For example, since the Quanta match is based on the subsystem
365 * and subvendor IDs, we need it to come before the more general IVB
366 * PCI ID matches, otherwise we'll use the wrong info struct above.
367 */
368static const struct pci_device_id pciidlist[] = {
369 INTEL_I830_IDS(&intel_i830_info),
370 INTEL_I845G_IDS(&intel_845g_info),
371 INTEL_I85X_IDS(&intel_i85x_info),
372 INTEL_I865G_IDS(&intel_i865g_info),
373 INTEL_I915G_IDS(&intel_i915g_info),
374 INTEL_I915GM_IDS(&intel_i915gm_info),
375 INTEL_I945G_IDS(&intel_i945g_info),
376 INTEL_I945GM_IDS(&intel_i945gm_info),
377 INTEL_I965G_IDS(&intel_i965g_info),
378 INTEL_G33_IDS(&intel_g33_info),
379 INTEL_I965GM_IDS(&intel_i965gm_info),
380 INTEL_GM45_IDS(&intel_gm45_info),
381 INTEL_G45_IDS(&intel_g45_info),
382 INTEL_PINEVIEW_IDS(&intel_pineview_info),
383 INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),
384 INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
385 INTEL_SNB_D_IDS(&intel_sandybridge_d_info),
386 INTEL_SNB_M_IDS(&intel_sandybridge_m_info),
387 INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
388 INTEL_IVB_M_IDS(&intel_ivybridge_m_info),
389 INTEL_IVB_D_IDS(&intel_ivybridge_d_info),
Carlos Santa8d9c20e2016-08-17 12:30:37 -0700390 INTEL_HSW_IDS(&intel_haswell_info),
391 INTEL_VLV_IDS(&intel_valleyview_info),
392 INTEL_BDW_GT12_IDS(&intel_broadwell_info),
393 INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
Chris Wilson42f55512016-06-24 14:00:26 +0100394 INTEL_CHV_IDS(&intel_cherryview_info),
395 INTEL_SKL_GT1_IDS(&intel_skylake_info),
396 INTEL_SKL_GT2_IDS(&intel_skylake_info),
397 INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
398 INTEL_SKL_GT4_IDS(&intel_skylake_gt3_info),
399 INTEL_BXT_IDS(&intel_broxton_info),
400 INTEL_KBL_GT1_IDS(&intel_kabylake_info),
401 INTEL_KBL_GT2_IDS(&intel_kabylake_info),
402 INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
403 INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
404 {0, 0, 0}
405};
406MODULE_DEVICE_TABLE(pci, pciidlist);
407
408extern int i915_driver_load(struct pci_dev *pdev,
409 const struct pci_device_id *ent);
410
411static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
412{
413 struct intel_device_info *intel_info =
414 (struct intel_device_info *) ent->driver_data;
415
416 if (IS_PRELIMINARY_HW(intel_info) && !i915.preliminary_hw_support) {
417 DRM_INFO("This hardware requires preliminary hardware support.\n"
418 "See CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT, and/or modparam preliminary_hw_support\n");
419 return -ENODEV;
420 }
421
422 /* Only bind to function 0 of the device. Early generations
423 * used function 1 as a placeholder for multi-head. This causes
424 * us confusion instead, especially on the systems where both
425 * functions have the same PCI-ID!
426 */
427 if (PCI_FUNC(pdev->devfn))
428 return -ENODEV;
429
430 /*
431 * apple-gmux is needed on dual GPU MacBook Pro
432 * to probe the panel if we're the inactive GPU.
433 */
434 if (vga_switcheroo_client_probe_defer(pdev))
435 return -EPROBE_DEFER;
436
437 return i915_driver_load(pdev, ent);
438}
439
440extern void i915_driver_unload(struct drm_device *dev);
441
442static void i915_pci_remove(struct pci_dev *pdev)
443{
444 struct drm_device *dev = pci_get_drvdata(pdev);
445
446 i915_driver_unload(dev);
447 drm_dev_unref(dev);
448}
449
450extern const struct dev_pm_ops i915_pm_ops;
451
Chris Wilsona09d0ba2016-06-24 14:00:27 +0100452static struct pci_driver i915_pci_driver = {
Chris Wilson42f55512016-06-24 14:00:26 +0100453 .name = DRIVER_NAME,
454 .id_table = pciidlist,
455 .probe = i915_pci_probe,
456 .remove = i915_pci_remove,
457 .driver.pm = &i915_pm_ops,
458};
Chris Wilsona09d0ba2016-06-24 14:00:27 +0100459
460static int __init i915_init(void)
461{
462 bool use_kms = true;
463
464 /*
465 * Enable KMS by default, unless explicitly overriden by
466 * either the i915.modeset prarameter or by the
467 * vga_text_mode_force boot option.
468 */
469
470 if (i915.modeset == 0)
471 use_kms = false;
472
473 if (vgacon_text_force() && i915.modeset == -1)
474 use_kms = false;
475
476 if (!use_kms) {
477 /* Silently fail loading to not upset userspace. */
478 DRM_DEBUG_DRIVER("KMS disabled.\n");
479 return 0;
480 }
481
482 return pci_register_driver(&i915_pci_driver);
483}
484
485static void __exit i915_exit(void)
486{
487 if (!i915_pci_driver.driver.owner)
488 return;
489
490 pci_unregister_driver(&i915_pci_driver);
491}
492
493module_init(i915_init);
494module_exit(i915_exit);
495
496MODULE_AUTHOR("Tungsten Graphics, Inc.");
497MODULE_AUTHOR("Intel Corporation");
498
499MODULE_DESCRIPTION(DRIVER_DESC);
500MODULE_LICENSE("GPL and additional rights");