i915_pci.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. /*
  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. #include <linux/console.h>
  25. #include <linux/vgaarb.h>
  26. #include <linux/vga_switcheroo.h>
  27. #include "i915_drv.h"
  28. #define GEN_DEFAULT_PIPEOFFSETS \
  29. .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
  30. PIPE_C_OFFSET, PIPE_EDP_OFFSET }, \
  31. .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
  32. TRANSCODER_C_OFFSET, TRANSCODER_EDP_OFFSET }, \
  33. .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET }
  34. #define GEN_CHV_PIPEOFFSETS \
  35. .pipe_offsets = { PIPE_A_OFFSET, PIPE_B_OFFSET, \
  36. CHV_PIPE_C_OFFSET }, \
  37. .trans_offsets = { TRANSCODER_A_OFFSET, TRANSCODER_B_OFFSET, \
  38. CHV_TRANSCODER_C_OFFSET, }, \
  39. .palette_offsets = { PALETTE_A_OFFSET, PALETTE_B_OFFSET, \
  40. CHV_PALETTE_C_OFFSET }
  41. #define CURSOR_OFFSETS \
  42. .cursor_offsets = { CURSOR_A_OFFSET, CURSOR_B_OFFSET, CHV_CURSOR_C_OFFSET }
  43. #define IVB_CURSOR_OFFSETS \
  44. .cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }
  45. #define BDW_COLORS \
  46. .color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }
  47. #define CHV_COLORS \
  48. .color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }
  49. #define GEN2_FEATURES \
  50. .gen = 2, .num_pipes = 1, \
  51. .has_overlay = 1, .overlay_needs_physical = 1, \
  52. .has_gmch_display = 1, \
  53. .hws_needs_physical = 1, \
  54. .ring_mask = RENDER_RING, \
  55. GEN_DEFAULT_PIPEOFFSETS, \
  56. CURSOR_OFFSETS
  57. static const struct intel_device_info intel_i830_info = {
  58. GEN2_FEATURES,
  59. .is_mobile = 1, .cursor_needs_physical = 1,
  60. .num_pipes = 2, /* legal, last one wins */
  61. };
  62. static const struct intel_device_info intel_845g_info = {
  63. GEN2_FEATURES,
  64. };
  65. static const struct intel_device_info intel_i85x_info = {
  66. GEN2_FEATURES,
  67. .is_i85x = 1, .is_mobile = 1,
  68. .num_pipes = 2, /* legal, last one wins */
  69. .cursor_needs_physical = 1,
  70. .has_fbc = 1,
  71. };
  72. static const struct intel_device_info intel_i865g_info = {
  73. GEN2_FEATURES,
  74. };
  75. #define GEN3_FEATURES \
  76. .gen = 3, .num_pipes = 2, \
  77. .has_gmch_display = 1, \
  78. .ring_mask = RENDER_RING, \
  79. GEN_DEFAULT_PIPEOFFSETS, \
  80. CURSOR_OFFSETS
  81. static const struct intel_device_info intel_i915g_info = {
  82. GEN3_FEATURES,
  83. .is_i915g = 1, .cursor_needs_physical = 1,
  84. .has_overlay = 1, .overlay_needs_physical = 1,
  85. .hws_needs_physical = 1,
  86. };
  87. static const struct intel_device_info intel_i915gm_info = {
  88. GEN3_FEATURES,
  89. .is_mobile = 1,
  90. .cursor_needs_physical = 1,
  91. .has_overlay = 1, .overlay_needs_physical = 1,
  92. .supports_tv = 1,
  93. .has_fbc = 1,
  94. .hws_needs_physical = 1,
  95. };
  96. static const struct intel_device_info intel_i945g_info = {
  97. GEN3_FEATURES,
  98. .has_hotplug = 1, .cursor_needs_physical = 1,
  99. .has_overlay = 1, .overlay_needs_physical = 1,
  100. .hws_needs_physical = 1,
  101. };
  102. static const struct intel_device_info intel_i945gm_info = {
  103. GEN3_FEATURES,
  104. .is_i945gm = 1, .is_mobile = 1,
  105. .has_hotplug = 1, .cursor_needs_physical = 1,
  106. .has_overlay = 1, .overlay_needs_physical = 1,
  107. .supports_tv = 1,
  108. .has_fbc = 1,
  109. .hws_needs_physical = 1,
  110. };
  111. #define GEN4_FEATURES \
  112. .gen = 4, .num_pipes = 2, \
  113. .has_hotplug = 1, \
  114. .has_gmch_display = 1, \
  115. .ring_mask = RENDER_RING, \
  116. GEN_DEFAULT_PIPEOFFSETS, \
  117. CURSOR_OFFSETS
  118. static const struct intel_device_info intel_i965g_info = {
  119. GEN4_FEATURES,
  120. .is_broadwater = 1,
  121. .has_overlay = 1,
  122. .hws_needs_physical = 1,
  123. };
  124. static const struct intel_device_info intel_i965gm_info = {
  125. GEN4_FEATURES,
  126. .is_crestline = 1,
  127. .is_mobile = 1, .has_fbc = 1,
  128. .has_overlay = 1,
  129. .supports_tv = 1,
  130. .hws_needs_physical = 1,
  131. };
  132. static const struct intel_device_info intel_g33_info = {
  133. GEN3_FEATURES,
  134. .is_g33 = 1,
  135. .has_hotplug = 1,
  136. .has_overlay = 1,
  137. };
  138. static const struct intel_device_info intel_g45_info = {
  139. GEN4_FEATURES,
  140. .is_g4x = 1,
  141. .has_pipe_cxsr = 1,
  142. .ring_mask = RENDER_RING | BSD_RING,
  143. };
  144. static const struct intel_device_info intel_gm45_info = {
  145. GEN4_FEATURES,
  146. .is_g4x = 1,
  147. .is_mobile = 1, .has_fbc = 1,
  148. .has_pipe_cxsr = 1,
  149. .supports_tv = 1,
  150. .ring_mask = RENDER_RING | BSD_RING,
  151. };
  152. static const struct intel_device_info intel_pineview_info = {
  153. GEN3_FEATURES,
  154. .is_g33 = 1, .is_pineview = 1, .is_mobile = 1,
  155. .has_hotplug = 1,
  156. .has_overlay = 1,
  157. };
  158. #define GEN5_FEATURES \
  159. .gen = 5, .num_pipes = 2, \
  160. .has_hotplug = 1, \
  161. .has_gmbus_irq = 1, \
  162. .ring_mask = RENDER_RING | BSD_RING, \
  163. GEN_DEFAULT_PIPEOFFSETS, \
  164. CURSOR_OFFSETS
  165. static const struct intel_device_info intel_ironlake_d_info = {
  166. GEN5_FEATURES,
  167. };
  168. static const struct intel_device_info intel_ironlake_m_info = {
  169. GEN5_FEATURES,
  170. .is_mobile = 1,
  171. };
  172. #define GEN6_FEATURES \
  173. .gen = 6, .num_pipes = 2, \
  174. .has_hotplug = 1, \
  175. .has_fbc = 1, \
  176. .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
  177. .has_llc = 1, \
  178. .has_rc6 = 1, \
  179. .has_rc6p = 1, \
  180. .has_gmbus_irq = 1, \
  181. .has_hw_contexts = 1, \
  182. GEN_DEFAULT_PIPEOFFSETS, \
  183. CURSOR_OFFSETS
  184. static const struct intel_device_info intel_sandybridge_d_info = {
  185. GEN6_FEATURES,
  186. };
  187. static const struct intel_device_info intel_sandybridge_m_info = {
  188. GEN6_FEATURES,
  189. .is_mobile = 1,
  190. };
  191. #define GEN7_FEATURES \
  192. .gen = 7, .num_pipes = 3, \
  193. .has_hotplug = 1, \
  194. .has_fbc = 1, \
  195. .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
  196. .has_llc = 1, \
  197. .has_rc6 = 1, \
  198. .has_rc6p = 1, \
  199. .has_gmbus_irq = 1, \
  200. .has_hw_contexts = 1, \
  201. GEN_DEFAULT_PIPEOFFSETS, \
  202. IVB_CURSOR_OFFSETS
  203. static const struct intel_device_info intel_ivybridge_d_info = {
  204. GEN7_FEATURES,
  205. .is_ivybridge = 1,
  206. .has_l3_dpf = 1,
  207. };
  208. static const struct intel_device_info intel_ivybridge_m_info = {
  209. GEN7_FEATURES,
  210. .is_ivybridge = 1,
  211. .is_mobile = 1,
  212. .has_l3_dpf = 1,
  213. };
  214. static const struct intel_device_info intel_ivybridge_q_info = {
  215. GEN7_FEATURES,
  216. .is_ivybridge = 1,
  217. .num_pipes = 0, /* legal, last one wins */
  218. .has_l3_dpf = 1,
  219. };
  220. #define VLV_FEATURES \
  221. .gen = 7, .num_pipes = 2, \
  222. .has_psr = 1, \
  223. .has_runtime_pm = 1, \
  224. .has_rc6 = 1, \
  225. .has_gmbus_irq = 1, \
  226. .has_hw_contexts = 1, \
  227. .has_gmch_display = 1, \
  228. .has_hotplug = 1, \
  229. .ring_mask = RENDER_RING | BSD_RING | BLT_RING, \
  230. .display_mmio_offset = VLV_DISPLAY_BASE, \
  231. GEN_DEFAULT_PIPEOFFSETS, \
  232. CURSOR_OFFSETS
  233. static const struct intel_device_info intel_valleyview_info = {
  234. VLV_FEATURES,
  235. .is_valleyview = 1,
  236. };
  237. #define HSW_FEATURES \
  238. GEN7_FEATURES, \
  239. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING, \
  240. .has_ddi = 1, \
  241. .has_fpga_dbg = 1, \
  242. .has_psr = 1, \
  243. .has_resource_streamer = 1, \
  244. .has_dp_mst = 1, \
  245. .has_rc6p = 0 /* RC6p removed-by HSW */, \
  246. .has_runtime_pm = 1
  247. static const struct intel_device_info intel_haswell_info = {
  248. HSW_FEATURES,
  249. .is_haswell = 1,
  250. .has_l3_dpf = 1,
  251. };
  252. #define BDW_FEATURES \
  253. HSW_FEATURES, \
  254. BDW_COLORS, \
  255. .has_logical_ring_contexts = 1
  256. static const struct intel_device_info intel_broadwell_info = {
  257. BDW_FEATURES,
  258. .gen = 8,
  259. .is_broadwell = 1,
  260. };
  261. static const struct intel_device_info intel_broadwell_gt3_info = {
  262. BDW_FEATURES,
  263. .gen = 8,
  264. .is_broadwell = 1,
  265. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  266. };
  267. static const struct intel_device_info intel_cherryview_info = {
  268. .gen = 8, .num_pipes = 3,
  269. .has_hotplug = 1,
  270. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
  271. .is_cherryview = 1,
  272. .has_psr = 1,
  273. .has_runtime_pm = 1,
  274. .has_resource_streamer = 1,
  275. .has_rc6 = 1,
  276. .has_gmbus_irq = 1,
  277. .has_hw_contexts = 1,
  278. .has_logical_ring_contexts = 1,
  279. .has_gmch_display = 1,
  280. .display_mmio_offset = VLV_DISPLAY_BASE,
  281. GEN_CHV_PIPEOFFSETS,
  282. CURSOR_OFFSETS,
  283. CHV_COLORS,
  284. };
  285. static const struct intel_device_info intel_skylake_info = {
  286. BDW_FEATURES,
  287. .is_skylake = 1,
  288. .gen = 9,
  289. .has_csr = 1,
  290. .has_guc = 1,
  291. .ddb_size = 896,
  292. };
  293. static const struct intel_device_info intel_skylake_gt3_info = {
  294. BDW_FEATURES,
  295. .is_skylake = 1,
  296. .gen = 9,
  297. .has_csr = 1,
  298. .has_guc = 1,
  299. .ddb_size = 896,
  300. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  301. };
  302. static const struct intel_device_info intel_broxton_info = {
  303. .is_broxton = 1,
  304. .gen = 9,
  305. .has_hotplug = 1,
  306. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
  307. .num_pipes = 3,
  308. .has_ddi = 1,
  309. .has_fpga_dbg = 1,
  310. .has_fbc = 1,
  311. .has_runtime_pm = 1,
  312. .has_pooled_eu = 0,
  313. .has_csr = 1,
  314. .has_resource_streamer = 1,
  315. .has_rc6 = 1,
  316. .has_dp_mst = 1,
  317. .has_gmbus_irq = 1,
  318. .has_hw_contexts = 1,
  319. .has_logical_ring_contexts = 1,
  320. .has_guc = 1,
  321. .ddb_size = 512,
  322. GEN_DEFAULT_PIPEOFFSETS,
  323. IVB_CURSOR_OFFSETS,
  324. BDW_COLORS,
  325. };
  326. static const struct intel_device_info intel_kabylake_info = {
  327. BDW_FEATURES,
  328. .is_kabylake = 1,
  329. .gen = 9,
  330. .has_csr = 1,
  331. .has_guc = 1,
  332. .ddb_size = 896,
  333. };
  334. static const struct intel_device_info intel_kabylake_gt3_info = {
  335. BDW_FEATURES,
  336. .is_kabylake = 1,
  337. .gen = 9,
  338. .has_csr = 1,
  339. .has_guc = 1,
  340. .ddb_size = 896,
  341. .ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
  342. };
  343. /*
  344. * Make sure any device matches here are from most specific to most
  345. * general. For example, since the Quanta match is based on the subsystem
  346. * and subvendor IDs, we need it to come before the more general IVB
  347. * PCI ID matches, otherwise we'll use the wrong info struct above.
  348. */
  349. static const struct pci_device_id pciidlist[] = {
  350. INTEL_I830_IDS(&intel_i830_info),
  351. INTEL_I845G_IDS(&intel_845g_info),
  352. INTEL_I85X_IDS(&intel_i85x_info),
  353. INTEL_I865G_IDS(&intel_i865g_info),
  354. INTEL_I915G_IDS(&intel_i915g_info),
  355. INTEL_I915GM_IDS(&intel_i915gm_info),
  356. INTEL_I945G_IDS(&intel_i945g_info),
  357. INTEL_I945GM_IDS(&intel_i945gm_info),
  358. INTEL_I965G_IDS(&intel_i965g_info),
  359. INTEL_G33_IDS(&intel_g33_info),
  360. INTEL_I965GM_IDS(&intel_i965gm_info),
  361. INTEL_GM45_IDS(&intel_gm45_info),
  362. INTEL_G45_IDS(&intel_g45_info),
  363. INTEL_PINEVIEW_IDS(&intel_pineview_info),
  364. INTEL_IRONLAKE_D_IDS(&intel_ironlake_d_info),
  365. INTEL_IRONLAKE_M_IDS(&intel_ironlake_m_info),
  366. INTEL_SNB_D_IDS(&intel_sandybridge_d_info),
  367. INTEL_SNB_M_IDS(&intel_sandybridge_m_info),
  368. INTEL_IVB_Q_IDS(&intel_ivybridge_q_info), /* must be first IVB */
  369. INTEL_IVB_M_IDS(&intel_ivybridge_m_info),
  370. INTEL_IVB_D_IDS(&intel_ivybridge_d_info),
  371. INTEL_HSW_IDS(&intel_haswell_info),
  372. INTEL_VLV_IDS(&intel_valleyview_info),
  373. INTEL_BDW_GT12_IDS(&intel_broadwell_info),
  374. INTEL_BDW_GT3_IDS(&intel_broadwell_gt3_info),
  375. INTEL_BDW_RSVD_IDS(&intel_broadwell_info),
  376. INTEL_CHV_IDS(&intel_cherryview_info),
  377. INTEL_SKL_GT1_IDS(&intel_skylake_info),
  378. INTEL_SKL_GT2_IDS(&intel_skylake_info),
  379. INTEL_SKL_GT3_IDS(&intel_skylake_gt3_info),
  380. INTEL_SKL_GT4_IDS(&intel_skylake_gt3_info),
  381. INTEL_BXT_IDS(&intel_broxton_info),
  382. INTEL_KBL_GT1_IDS(&intel_kabylake_info),
  383. INTEL_KBL_GT2_IDS(&intel_kabylake_info),
  384. INTEL_KBL_GT3_IDS(&intel_kabylake_gt3_info),
  385. INTEL_KBL_GT4_IDS(&intel_kabylake_gt3_info),
  386. {0, 0, 0}
  387. };
  388. MODULE_DEVICE_TABLE(pci, pciidlist);
  389. static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  390. {
  391. struct intel_device_info *intel_info =
  392. (struct intel_device_info *) ent->driver_data;
  393. if (IS_PRELIMINARY_HW(intel_info) && !i915.preliminary_hw_support) {
  394. DRM_INFO("This hardware requires preliminary hardware support.\n"
  395. "See CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT, and/or modparam preliminary_hw_support\n");
  396. return -ENODEV;
  397. }
  398. /* Only bind to function 0 of the device. Early generations
  399. * used function 1 as a placeholder for multi-head. This causes
  400. * us confusion instead, especially on the systems where both
  401. * functions have the same PCI-ID!
  402. */
  403. if (PCI_FUNC(pdev->devfn))
  404. return -ENODEV;
  405. /*
  406. * apple-gmux is needed on dual GPU MacBook Pro
  407. * to probe the panel if we're the inactive GPU.
  408. */
  409. if (vga_switcheroo_client_probe_defer(pdev))
  410. return -EPROBE_DEFER;
  411. return i915_driver_load(pdev, ent);
  412. }
  413. static void i915_pci_remove(struct pci_dev *pdev)
  414. {
  415. struct drm_device *dev = pci_get_drvdata(pdev);
  416. i915_driver_unload(dev);
  417. drm_dev_unref(dev);
  418. }
  419. static struct pci_driver i915_pci_driver = {
  420. .name = DRIVER_NAME,
  421. .id_table = pciidlist,
  422. .probe = i915_pci_probe,
  423. .remove = i915_pci_remove,
  424. .driver.pm = &i915_pm_ops,
  425. };
  426. static int __init i915_init(void)
  427. {
  428. bool use_kms = true;
  429. /*
  430. * Enable KMS by default, unless explicitly overriden by
  431. * either the i915.modeset prarameter or by the
  432. * vga_text_mode_force boot option.
  433. */
  434. if (i915.modeset == 0)
  435. use_kms = false;
  436. if (vgacon_text_force() && i915.modeset == -1)
  437. use_kms = false;
  438. if (!use_kms) {
  439. /* Silently fail loading to not upset userspace. */
  440. DRM_DEBUG_DRIVER("KMS disabled.\n");
  441. return 0;
  442. }
  443. return pci_register_driver(&i915_pci_driver);
  444. }
  445. static void __exit i915_exit(void)
  446. {
  447. if (!i915_pci_driver.driver.owner)
  448. return;
  449. pci_unregister_driver(&i915_pci_driver);
  450. }
  451. module_init(i915_init);
  452. module_exit(i915_exit);
  453. MODULE_AUTHOR("Tungsten Graphics, Inc.");
  454. MODULE_AUTHOR("Intel Corporation");
  455. MODULE_DESCRIPTION(DRIVER_DESC);
  456. MODULE_LICENSE("GPL and additional rights");