blob: 8ea19f21256a2a530849303b1bb7f54744cccc2d [file] [log] [blame]
Chris Wilsond308bb02016-06-29 08:28:58 +01001#include "intel_chipset.h"
2#include "i915_pciids.h"
3
4#include <strings.h> /* ffs() */
5
6#define BIT(x) (1<<(x))
7
8static const struct intel_device_info intel_generic_info = {
9 .gen = 0,
10};
11
Chris Wilson13d946e2017-03-13 21:43:54 +000012static const struct intel_device_info intel_i810_info = {
Chris Wilsond308bb02016-06-29 08:28:58 +010013 .gen = BIT(0),
14 .is_whitney = true,
15 .codename = "solano" /* 815 == "whitney" ? or vice versa? */
16};
17
Chris Wilson13d946e2017-03-13 21:43:54 +000018static const struct intel_device_info intel_i815_info = {
19 .gen = BIT(0),
20 .is_whitney = true,
21 .codename = "whitney"
22};
23
Chris Wilsond308bb02016-06-29 08:28:58 +010024static const struct intel_device_info intel_i830_info = {
25 .gen = BIT(1),
26 .is_almador = true,
27 .codename = "almador"
28};
29static const struct intel_device_info intel_i845_info = {
30 .gen = BIT(1),
31 .is_brookdale = true,
32 .codename = "brookdale"
33};
34static const struct intel_device_info intel_i855_info = {
35 .gen = BIT(1),
36 .is_mobile = true,
37 .is_montara = true,
38 .codename = "montara"
39};
40static const struct intel_device_info intel_i865_info = {
41 .gen = BIT(1),
42 .is_springdale = true,
43 .codename = "spingdale"
44};
45
46static const struct intel_device_info intel_i915_info = {
47 .gen = BIT(2),
48 .is_grantsdale = true,
49 .codename = "grantsdale"
50};
51static const struct intel_device_info intel_i915m_info = {
52 .gen = BIT(2),
53 .is_mobile = true,
54 .is_alviso = true,
55 .codename = "alviso"
56};
57static const struct intel_device_info intel_i945_info = {
58 .gen = BIT(2),
59 .is_lakeport = true,
60 .codename = "lakeport"
61};
62static const struct intel_device_info intel_i945m_info = {
63 .gen = BIT(2),
64 .is_mobile = true,
65 .is_calistoga = true,
Chris Wilsonbd49df82016-07-14 15:18:13 +010066 .codename = "calistoga"
Chris Wilsond308bb02016-06-29 08:28:58 +010067};
68
69static const struct intel_device_info intel_g33_info = {
70 .gen = BIT(2),
71 .is_bearlake = true,
72 .codename = "bearlake"
73};
74static const struct intel_device_info intel_pineview_info = {
75 .gen = BIT(2),
76 .is_mobile = true,
77 .is_pineview = true,
78 .codename = "pineview"
79};
80
81static const struct intel_device_info intel_i965_info = {
82 .gen = BIT(3),
83 .is_broadwater = true,
84 .codename = "broadwater"
85};
86
87static const struct intel_device_info intel_i965m_info = {
88 .gen = BIT(3),
89 .is_mobile = true,
90 .is_crestline = true,
91 .codename = "crestline"
92};
93
94static const struct intel_device_info intel_g45_info = {
95 .gen = BIT(3),
96 .is_eaglelake = true,
Chris Wilsonf4316132016-07-14 11:49:38 +010097 .codename = "eaglelake"
Chris Wilsond308bb02016-06-29 08:28:58 +010098};
99static const struct intel_device_info intel_gm45_info = {
100 .gen = BIT(3),
101 .is_mobile = true,
102 .is_cantiga = true,
103 .codename = "cantiga"
104};
105
106static const struct intel_device_info intel_ironlake_info = {
107 .gen = BIT(4),
108 .is_ironlake = true,
Chris Wilsonf4316132016-07-14 11:49:38 +0100109 .codename = "ironlake" /* clarkdale? */
Chris Wilsond308bb02016-06-29 08:28:58 +0100110};
111static const struct intel_device_info intel_ironlake_m_info = {
112 .gen = BIT(4),
113 .is_mobile = true,
114 .is_arrandale = true,
115 .codename = "arrandale"
116};
117
118static const struct intel_device_info intel_sandybridge_info = {
119 .gen = BIT(5),
120 .is_sandybridge = true,
121 .codename = "sandybridge"
122};
123static const struct intel_device_info intel_sandybridge_m_info = {
124 .gen = BIT(5),
125 .is_mobile = true,
126 .is_sandybridge = true,
127 .codename = "sandybridge"
128};
129
130static const struct intel_device_info intel_ivybridge_info = {
131 .gen = BIT(6),
132 .is_ivybridge = true,
133 .codename = "ivybridge"
134};
135static const struct intel_device_info intel_ivybridge_m_info = {
136 .gen = BIT(6),
137 .is_mobile = true,
138 .is_ivybridge = true,
139 .codename = "ivybridge"
140};
141
142static const struct intel_device_info intel_valleyview_info = {
143 .gen = BIT(6),
144 .is_valleyview = true,
145 .codename = "valleyview"
146};
Chris Wilsond308bb02016-06-29 08:28:58 +0100147
148static const struct intel_device_info intel_haswell_info = {
149 .gen = BIT(6),
150 .is_haswell = true,
151 .codename = "haswell"
152};
Chris Wilsond308bb02016-06-29 08:28:58 +0100153
154static const struct intel_device_info intel_broadwell_info = {
155 .gen = BIT(7),
156 .is_broadwell = true,
157 .codename = "broadwell"
158};
Chris Wilsond308bb02016-06-29 08:28:58 +0100159
160static const struct intel_device_info intel_cherryview_info = {
161 .gen = BIT(7),
162 .is_cherryview = true,
163 .codename = "cherryview"
164};
165
166static const struct intel_device_info intel_skylake_info = {
167 .gen = BIT(8),
168 .is_skylake = true,
169 .codename = "skylake"
170};
171
172static const struct intel_device_info intel_broxton_info = {
173 .gen = BIT(8),
174 .is_broxton = true,
175 .codename = "broxton"
176};
177
178static const struct intel_device_info intel_kabylake_info = {
179 .gen = BIT(8),
180 .is_kabylake = true,
181 .codename = "kabylake"
182};
183
Ander Conselvan de Oliveirac7c581a2016-12-20 13:51:01 +0200184static const struct intel_device_info intel_geminilake_info = {
185 .gen = BIT(8),
186 .is_geminilake = true,
187 .codename = "geminilake"
188};
189
Rodrigo Vivi68a3eb12017-01-04 15:09:35 -0800190static const struct intel_device_info intel_coffeelake_info = {
191 .gen = BIT(8),
192 .is_coffeelake = true,
193 .codename = "coffeelake"
194};
195
Rodrigo Vivi23536e02017-01-04 15:22:36 -0800196static const struct intel_device_info intel_cannonlake_info = {
197 .gen = BIT(9),
198 .is_cannonlake = true,
199 .codename = "cannonlake"
200};
201
Chris Wilsond308bb02016-06-29 08:28:58 +0100202static const struct pci_id_match intel_device_match[] = {
Chris Wilson13d946e2017-03-13 21:43:54 +0000203 INTEL_I810_IDS(&intel_i810_info),
204 INTEL_I815_IDS(&intel_i815_info),
205
Chris Wilsond308bb02016-06-29 08:28:58 +0100206 INTEL_I830_IDS(&intel_i830_info),
207 INTEL_I845G_IDS(&intel_i845_info),
208 INTEL_I85X_IDS(&intel_i855_info),
209 INTEL_I865G_IDS(&intel_i865_info),
210
211 INTEL_I915G_IDS(&intel_i915_info),
212 INTEL_I915GM_IDS(&intel_i915m_info),
213 INTEL_I945G_IDS(&intel_i945_info),
214 INTEL_I945GM_IDS(&intel_i945m_info),
215
216 INTEL_G33_IDS(&intel_g33_info),
217 INTEL_PINEVIEW_IDS(&intel_pineview_info),
218
219 INTEL_I965G_IDS(&intel_i965_info),
220 INTEL_I965GM_IDS(&intel_i965m_info),
221
222 INTEL_G45_IDS(&intel_g45_info),
223 INTEL_GM45_IDS(&intel_gm45_info),
224
225 INTEL_IRONLAKE_D_IDS(&intel_ironlake_info),
226 INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
227
228 INTEL_SNB_D_IDS(&intel_sandybridge_info),
229 INTEL_SNB_M_IDS(&intel_sandybridge_m_info),
230
231 INTEL_IVB_D_IDS(&intel_ivybridge_info),
232 INTEL_IVB_M_IDS(&intel_ivybridge_m_info),
233
Ander Conselvan de Oliveira770fd182016-12-20 13:45:25 +0200234 INTEL_HSW_IDS(&intel_haswell_info),
Chris Wilsond308bb02016-06-29 08:28:58 +0100235
Ander Conselvan de Oliveira770fd182016-12-20 13:45:25 +0200236 INTEL_VLV_IDS(&intel_valleyview_info),
Chris Wilsond308bb02016-06-29 08:28:58 +0100237
Ander Conselvan de Oliveira770fd182016-12-20 13:45:25 +0200238 INTEL_BDW_IDS(&intel_broadwell_info),
Chris Wilsond308bb02016-06-29 08:28:58 +0100239
240 INTEL_CHV_IDS(&intel_cherryview_info),
241
242 INTEL_SKL_IDS(&intel_skylake_info),
243
244 INTEL_BXT_IDS(&intel_broxton_info),
245
246 INTEL_KBL_IDS(&intel_kabylake_info),
247
Ander Conselvan de Oliveirac7c581a2016-12-20 13:51:01 +0200248 INTEL_GLK_IDS(&intel_geminilake_info),
249
Anusha Srivatsa79f16f32017-06-28 23:16:13 -0700250 INTEL_CFL_IDS(&intel_coffeelake_info),
251
Rodrigo Vivi91fc5312017-01-04 15:36:05 -0800252 INTEL_CNL_IDS(&intel_cannonlake_info),
253
Chris Wilsond308bb02016-06-29 08:28:58 +0100254 INTEL_VGA_DEVICE(PCI_MATCH_ANY, &intel_generic_info),
255};
256
257/**
Daniel Vetter1dfe8482016-07-27 14:28:35 +0200258 * intel_get_device_info:
Chris Wilsond308bb02016-06-29 08:28:58 +0100259 * @devid: pci device id
260 *
261 * Looks up the Intel GFX device info for the given device id.
262 *
263 * Returns:
Daniel Vetter1dfe8482016-07-27 14:28:35 +0200264 * The associated intel_get_device_info
Chris Wilsond308bb02016-06-29 08:28:58 +0100265 */
Daniel Vetter1dfe8482016-07-27 14:28:35 +0200266const struct intel_device_info *intel_get_device_info(uint16_t devid)
Chris Wilsond308bb02016-06-29 08:28:58 +0100267{
268 static const struct intel_device_info *cache = &intel_generic_info;
269 static uint16_t cached_devid;
270 int i;
271
272 if (cached_devid == devid)
273 goto out;
274
275 /* XXX Presort table and bsearch! */
276 for (i = 0; intel_device_match[i].device_id != PCI_MATCH_ANY; i++) {
277 if (devid == intel_device_match[i].device_id)
278 break;
279 }
280
281 cached_devid = devid;
282 cache = (void *)intel_device_match[i].match_data;
283
284out:
285 return cache;
286}
287
288/**
289 * intel_gen:
290 * @devid: pci device id
291 *
292 * Computes the Intel GFX generation for the given device id.
293 *
294 * Returns:
295 * The GFX generation on successful lookup, 0 on failure.
296 */
297unsigned intel_gen(uint16_t devid)
298{
Daniel Vetter1dfe8482016-07-27 14:28:35 +0200299 return ffs(intel_get_device_info(devid)->gen);
Chris Wilsond308bb02016-06-29 08:28:58 +0100300}
Chris Wilson2aa3dc82016-06-29 12:11:28 +0100301
302/**
303 * intel_gt:
304 * @devid: pci device id
305 *
306 * Computes the Intel GFX GT size for the given device id.
307 *
308 * Returns:
309 * The GT size.
310 */
311unsigned intel_gt(uint16_t devid)
312{
313 unsigned mask = intel_gen(devid);
314
315 if (mask >= 8)
316 mask = 0xf;
317 else if (mask >= 6)
318 mask = 0x3;
319 else
320 mask = 0;
321
322 return (devid >> 4) & mask;
323}