Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 1 | #include "intel_chipset.h" |
| 2 | #include "i915_pciids.h" |
| 3 | |
| 4 | #include <strings.h> /* ffs() */ |
| 5 | |
| 6 | #define BIT(x) (1<<(x)) |
| 7 | |
| 8 | static const struct intel_device_info intel_generic_info = { |
| 9 | .gen = 0, |
| 10 | }; |
| 11 | |
Chris Wilson | 13d946e | 2017-03-13 21:43:54 +0000 | [diff] [blame] | 12 | static const struct intel_device_info intel_i810_info = { |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 13 | .gen = BIT(0), |
| 14 | .is_whitney = true, |
| 15 | .codename = "solano" /* 815 == "whitney" ? or vice versa? */ |
| 16 | }; |
| 17 | |
Chris Wilson | 13d946e | 2017-03-13 21:43:54 +0000 | [diff] [blame] | 18 | static const struct intel_device_info intel_i815_info = { |
| 19 | .gen = BIT(0), |
| 20 | .is_whitney = true, |
| 21 | .codename = "whitney" |
| 22 | }; |
| 23 | |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 24 | static const struct intel_device_info intel_i830_info = { |
| 25 | .gen = BIT(1), |
| 26 | .is_almador = true, |
| 27 | .codename = "almador" |
| 28 | }; |
| 29 | static const struct intel_device_info intel_i845_info = { |
| 30 | .gen = BIT(1), |
| 31 | .is_brookdale = true, |
| 32 | .codename = "brookdale" |
| 33 | }; |
| 34 | static const struct intel_device_info intel_i855_info = { |
| 35 | .gen = BIT(1), |
| 36 | .is_mobile = true, |
| 37 | .is_montara = true, |
| 38 | .codename = "montara" |
| 39 | }; |
| 40 | static const struct intel_device_info intel_i865_info = { |
| 41 | .gen = BIT(1), |
| 42 | .is_springdale = true, |
| 43 | .codename = "spingdale" |
| 44 | }; |
| 45 | |
| 46 | static const struct intel_device_info intel_i915_info = { |
| 47 | .gen = BIT(2), |
| 48 | .is_grantsdale = true, |
| 49 | .codename = "grantsdale" |
| 50 | }; |
| 51 | static const struct intel_device_info intel_i915m_info = { |
| 52 | .gen = BIT(2), |
| 53 | .is_mobile = true, |
| 54 | .is_alviso = true, |
| 55 | .codename = "alviso" |
| 56 | }; |
| 57 | static const struct intel_device_info intel_i945_info = { |
| 58 | .gen = BIT(2), |
| 59 | .is_lakeport = true, |
| 60 | .codename = "lakeport" |
| 61 | }; |
| 62 | static const struct intel_device_info intel_i945m_info = { |
| 63 | .gen = BIT(2), |
| 64 | .is_mobile = true, |
| 65 | .is_calistoga = true, |
Chris Wilson | bd49df8 | 2016-07-14 15:18:13 +0100 | [diff] [blame] | 66 | .codename = "calistoga" |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | static const struct intel_device_info intel_g33_info = { |
| 70 | .gen = BIT(2), |
| 71 | .is_bearlake = true, |
| 72 | .codename = "bearlake" |
| 73 | }; |
| 74 | static 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 | |
| 81 | static const struct intel_device_info intel_i965_info = { |
| 82 | .gen = BIT(3), |
| 83 | .is_broadwater = true, |
| 84 | .codename = "broadwater" |
| 85 | }; |
| 86 | |
| 87 | static 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 | |
| 94 | static const struct intel_device_info intel_g45_info = { |
| 95 | .gen = BIT(3), |
| 96 | .is_eaglelake = true, |
Chris Wilson | f431613 | 2016-07-14 11:49:38 +0100 | [diff] [blame] | 97 | .codename = "eaglelake" |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 98 | }; |
| 99 | static 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 | |
| 106 | static const struct intel_device_info intel_ironlake_info = { |
| 107 | .gen = BIT(4), |
| 108 | .is_ironlake = true, |
Chris Wilson | f431613 | 2016-07-14 11:49:38 +0100 | [diff] [blame] | 109 | .codename = "ironlake" /* clarkdale? */ |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 110 | }; |
| 111 | static 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 | |
| 118 | static const struct intel_device_info intel_sandybridge_info = { |
| 119 | .gen = BIT(5), |
| 120 | .is_sandybridge = true, |
| 121 | .codename = "sandybridge" |
| 122 | }; |
| 123 | static 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 | |
| 130 | static const struct intel_device_info intel_ivybridge_info = { |
| 131 | .gen = BIT(6), |
| 132 | .is_ivybridge = true, |
| 133 | .codename = "ivybridge" |
| 134 | }; |
| 135 | static 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 | |
| 142 | static const struct intel_device_info intel_valleyview_info = { |
| 143 | .gen = BIT(6), |
| 144 | .is_valleyview = true, |
| 145 | .codename = "valleyview" |
| 146 | }; |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 147 | |
| 148 | static const struct intel_device_info intel_haswell_info = { |
| 149 | .gen = BIT(6), |
| 150 | .is_haswell = true, |
| 151 | .codename = "haswell" |
| 152 | }; |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 153 | |
| 154 | static const struct intel_device_info intel_broadwell_info = { |
| 155 | .gen = BIT(7), |
| 156 | .is_broadwell = true, |
| 157 | .codename = "broadwell" |
| 158 | }; |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 159 | |
| 160 | static const struct intel_device_info intel_cherryview_info = { |
| 161 | .gen = BIT(7), |
| 162 | .is_cherryview = true, |
| 163 | .codename = "cherryview" |
| 164 | }; |
| 165 | |
| 166 | static const struct intel_device_info intel_skylake_info = { |
| 167 | .gen = BIT(8), |
| 168 | .is_skylake = true, |
| 169 | .codename = "skylake" |
| 170 | }; |
| 171 | |
| 172 | static const struct intel_device_info intel_broxton_info = { |
| 173 | .gen = BIT(8), |
| 174 | .is_broxton = true, |
| 175 | .codename = "broxton" |
| 176 | }; |
| 177 | |
| 178 | static const struct intel_device_info intel_kabylake_info = { |
| 179 | .gen = BIT(8), |
| 180 | .is_kabylake = true, |
| 181 | .codename = "kabylake" |
| 182 | }; |
| 183 | |
Ander Conselvan de Oliveira | c7c581a | 2016-12-20 13:51:01 +0200 | [diff] [blame] | 184 | static const struct intel_device_info intel_geminilake_info = { |
| 185 | .gen = BIT(8), |
| 186 | .is_geminilake = true, |
| 187 | .codename = "geminilake" |
| 188 | }; |
| 189 | |
Rodrigo Vivi | 68a3eb1 | 2017-01-04 15:09:35 -0800 | [diff] [blame] | 190 | static const struct intel_device_info intel_coffeelake_info = { |
| 191 | .gen = BIT(8), |
| 192 | .is_coffeelake = true, |
| 193 | .codename = "coffeelake" |
| 194 | }; |
| 195 | |
Rodrigo Vivi | 23536e0 | 2017-01-04 15:22:36 -0800 | [diff] [blame] | 196 | static const struct intel_device_info intel_cannonlake_info = { |
| 197 | .gen = BIT(9), |
| 198 | .is_cannonlake = true, |
| 199 | .codename = "cannonlake" |
| 200 | }; |
| 201 | |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 202 | static const struct pci_id_match intel_device_match[] = { |
Chris Wilson | 13d946e | 2017-03-13 21:43:54 +0000 | [diff] [blame] | 203 | INTEL_I810_IDS(&intel_i810_info), |
| 204 | INTEL_I815_IDS(&intel_i815_info), |
| 205 | |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 206 | 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 Oliveira | 770fd18 | 2016-12-20 13:45:25 +0200 | [diff] [blame] | 234 | INTEL_HSW_IDS(&intel_haswell_info), |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 235 | |
Ander Conselvan de Oliveira | 770fd18 | 2016-12-20 13:45:25 +0200 | [diff] [blame] | 236 | INTEL_VLV_IDS(&intel_valleyview_info), |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 237 | |
Ander Conselvan de Oliveira | 770fd18 | 2016-12-20 13:45:25 +0200 | [diff] [blame] | 238 | INTEL_BDW_IDS(&intel_broadwell_info), |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 239 | |
| 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 Oliveira | c7c581a | 2016-12-20 13:51:01 +0200 | [diff] [blame] | 248 | INTEL_GLK_IDS(&intel_geminilake_info), |
| 249 | |
Anusha Srivatsa | 79f16f3 | 2017-06-28 23:16:13 -0700 | [diff] [blame] | 250 | INTEL_CFL_IDS(&intel_coffeelake_info), |
| 251 | |
Rodrigo Vivi | 91fc531 | 2017-01-04 15:36:05 -0800 | [diff] [blame] | 252 | INTEL_CNL_IDS(&intel_cannonlake_info), |
| 253 | |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 254 | INTEL_VGA_DEVICE(PCI_MATCH_ANY, &intel_generic_info), |
| 255 | }; |
| 256 | |
| 257 | /** |
Daniel Vetter | 1dfe848 | 2016-07-27 14:28:35 +0200 | [diff] [blame] | 258 | * intel_get_device_info: |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 259 | * @devid: pci device id |
| 260 | * |
| 261 | * Looks up the Intel GFX device info for the given device id. |
| 262 | * |
| 263 | * Returns: |
Daniel Vetter | 1dfe848 | 2016-07-27 14:28:35 +0200 | [diff] [blame] | 264 | * The associated intel_get_device_info |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 265 | */ |
Daniel Vetter | 1dfe848 | 2016-07-27 14:28:35 +0200 | [diff] [blame] | 266 | const struct intel_device_info *intel_get_device_info(uint16_t devid) |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 267 | { |
| 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 | |
| 284 | out: |
| 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 | */ |
| 297 | unsigned intel_gen(uint16_t devid) |
| 298 | { |
Daniel Vetter | 1dfe848 | 2016-07-27 14:28:35 +0200 | [diff] [blame] | 299 | return ffs(intel_get_device_info(devid)->gen); |
Chris Wilson | d308bb0 | 2016-06-29 08:28:58 +0100 | [diff] [blame] | 300 | } |
Chris Wilson | 2aa3dc8 | 2016-06-29 12:11:28 +0100 | [diff] [blame] | 301 | |
| 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 | */ |
| 311 | unsigned 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 | } |