i915_pci.c 14 KB

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