i915_pci.c 13 KB

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