blob: d1d4b97b86f59a96307c75f693d4434e15a1eea6 [file] [log] [blame]
Jani Nikula707d26d2019-08-07 15:04:15 +03001// SPDX-License-Identifier: MIT
2/*
3 * Copyright 2019 Intel Corporation.
4 */
5
6#include "i915_drv.h"
7#include "intel_pch.h"
8
9/* Map PCH device id to PCH type, or PCH_NONE if unknown. */
10static enum intel_pch
11intel_pch_type(const struct drm_i915_private *dev_priv, unsigned short id)
12{
13 switch (id) {
14 case INTEL_PCH_IBX_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030015 drm_dbg_kms(&dev_priv->drm, "Found Ibex Peak PCH\n");
Lucas De Marchi651e7d42021-06-05 21:50:49 -070016 drm_WARN_ON(&dev_priv->drm, GRAPHICS_VER(dev_priv) != 5);
Jani Nikula707d26d2019-08-07 15:04:15 +030017 return PCH_IBX;
18 case INTEL_PCH_CPT_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030019 drm_dbg_kms(&dev_priv->drm, "Found CougarPoint PCH\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +053020 drm_WARN_ON(&dev_priv->drm,
Lucas De Marchi651e7d42021-06-05 21:50:49 -070021 GRAPHICS_VER(dev_priv) != 6 && !IS_IVYBRIDGE(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030022 return PCH_CPT;
23 case INTEL_PCH_PPT_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030024 drm_dbg_kms(&dev_priv->drm, "Found PantherPoint PCH\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +053025 drm_WARN_ON(&dev_priv->drm,
Lucas De Marchi651e7d42021-06-05 21:50:49 -070026 GRAPHICS_VER(dev_priv) != 6 && !IS_IVYBRIDGE(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030027 /* PantherPoint is CPT compatible */
28 return PCH_CPT;
29 case INTEL_PCH_LPT_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030030 drm_dbg_kms(&dev_priv->drm, "Found LynxPoint PCH\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +053031 drm_WARN_ON(&dev_priv->drm,
32 !IS_HASWELL(dev_priv) && !IS_BROADWELL(dev_priv));
33 drm_WARN_ON(&dev_priv->drm,
34 IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030035 return PCH_LPT;
36 case INTEL_PCH_LPT_LP_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030037 drm_dbg_kms(&dev_priv->drm, "Found LynxPoint LP PCH\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +053038 drm_WARN_ON(&dev_priv->drm,
39 !IS_HASWELL(dev_priv) && !IS_BROADWELL(dev_priv));
40 drm_WARN_ON(&dev_priv->drm,
41 !IS_HSW_ULT(dev_priv) && !IS_BDW_ULT(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030042 return PCH_LPT;
43 case INTEL_PCH_WPT_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030044 drm_dbg_kms(&dev_priv->drm, "Found WildcatPoint PCH\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +053045 drm_WARN_ON(&dev_priv->drm,
46 !IS_HASWELL(dev_priv) && !IS_BROADWELL(dev_priv));
47 drm_WARN_ON(&dev_priv->drm,
48 IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030049 /* WildcatPoint is LPT compatible */
50 return PCH_LPT;
51 case INTEL_PCH_WPT_LP_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030052 drm_dbg_kms(&dev_priv->drm, "Found WildcatPoint LP PCH\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +053053 drm_WARN_ON(&dev_priv->drm,
54 !IS_HASWELL(dev_priv) && !IS_BROADWELL(dev_priv));
55 drm_WARN_ON(&dev_priv->drm,
56 !IS_HSW_ULT(dev_priv) && !IS_BDW_ULT(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030057 /* WildcatPoint is LPT compatible */
58 return PCH_LPT;
59 case INTEL_PCH_SPT_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030060 drm_dbg_kms(&dev_priv->drm, "Found SunrisePoint PCH\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +053061 drm_WARN_ON(&dev_priv->drm,
62 !IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030063 return PCH_SPT;
64 case INTEL_PCH_SPT_LP_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030065 drm_dbg_kms(&dev_priv->drm, "Found SunrisePoint LP PCH\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +053066 drm_WARN_ON(&dev_priv->drm,
Chris Wilson5f4ae272020-06-02 15:05:40 +010067 !IS_SKYLAKE(dev_priv) &&
68 !IS_KABYLAKE(dev_priv) &&
69 !IS_COFFEELAKE(dev_priv) &&
70 !IS_COMETLAKE(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030071 return PCH_SPT;
72 case INTEL_PCH_KBP_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030073 drm_dbg_kms(&dev_priv->drm, "Found Kaby Lake PCH (KBP)\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +053074 drm_WARN_ON(&dev_priv->drm,
Chris Wilson5f4ae272020-06-02 15:05:40 +010075 !IS_SKYLAKE(dev_priv) &&
76 !IS_KABYLAKE(dev_priv) &&
77 !IS_COFFEELAKE(dev_priv) &&
78 !IS_COMETLAKE(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030079 /* KBP is SPT compatible */
80 return PCH_SPT;
81 case INTEL_PCH_CNP_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030082 drm_dbg_kms(&dev_priv->drm, "Found Cannon Lake PCH (CNP)\n");
Chris Wilson5f4ae272020-06-02 15:05:40 +010083 drm_WARN_ON(&dev_priv->drm,
Chris Wilson5f4ae272020-06-02 15:05:40 +010084 !IS_COFFEELAKE(dev_priv) &&
85 !IS_COMETLAKE(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030086 return PCH_CNP;
87 case INTEL_PCH_CNP_LP_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030088 drm_dbg_kms(&dev_priv->drm,
89 "Found Cannon Lake LP PCH (CNP-LP)\n");
Chris Wilson5f4ae272020-06-02 15:05:40 +010090 drm_WARN_ON(&dev_priv->drm,
Chris Wilson5f4ae272020-06-02 15:05:40 +010091 !IS_COFFEELAKE(dev_priv) &&
92 !IS_COMETLAKE(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +030093 return PCH_CNP;
94 case INTEL_PCH_CMP_DEVICE_ID_TYPE:
Matt Roper8698ba52019-09-16 16:32:51 -070095 case INTEL_PCH_CMP2_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +030096 drm_dbg_kms(&dev_priv->drm, "Found Comet Lake PCH (CMP)\n");
Chris Wilson5f4ae272020-06-02 15:05:40 +010097 drm_WARN_ON(&dev_priv->drm,
98 !IS_COFFEELAKE(dev_priv) &&
99 !IS_COMETLAKE(dev_priv) &&
Matt Ropera09e89e2020-05-04 15:52:10 -0700100 !IS_ROCKETLAKE(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +0300101 /* CometPoint is CNP Compatible */
102 return PCH_CNP;
Imre Deak50a50652019-11-12 12:46:08 +0200103 case INTEL_PCH_CMP_V_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +0300104 drm_dbg_kms(&dev_priv->drm, "Found Comet Lake V PCH (CMP-V)\n");
Chris Wilson5f4ae272020-06-02 15:05:40 +0100105 drm_WARN_ON(&dev_priv->drm,
106 !IS_COFFEELAKE(dev_priv) &&
107 !IS_COMETLAKE(dev_priv));
Imre Deak50a50652019-11-12 12:46:08 +0200108 /* Comet Lake V PCH is based on KBP, which is SPT compatible */
109 return PCH_SPT;
Jani Nikula707d26d2019-08-07 15:04:15 +0300110 case INTEL_PCH_ICP_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +0300111 drm_dbg_kms(&dev_priv->drm, "Found Ice Lake PCH\n");
Pankaj Bharadiya48a1b8d2020-01-15 09:14:53 +0530112 drm_WARN_ON(&dev_priv->drm, !IS_ICELAKE(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +0300113 return PCH_ICP;
114 case INTEL_PCH_MCC_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +0300115 drm_dbg_kms(&dev_priv->drm, "Found Mule Creek Canyon PCH\n");
Tejas Upadhyay24ea0982020-10-14 00:59:48 +0530116 drm_WARN_ON(&dev_priv->drm, !IS_JSL_EHL(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +0300117 return PCH_MCC;
118 case INTEL_PCH_TGP_DEVICE_ID_TYPE:
James Ausmus6cf6e592019-11-05 16:55:26 -0800119 case INTEL_PCH_TGP2_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +0300120 drm_dbg_kms(&dev_priv->drm, "Found Tiger Lake LP PCH\n");
Matt Ropera09e89e2020-05-04 15:52:10 -0700121 drm_WARN_ON(&dev_priv->drm, !IS_TIGERLAKE(dev_priv) &&
Lyude Paul4b970392021-02-09 14:13:05 -0500122 !IS_ROCKETLAKE(dev_priv) &&
123 !IS_GEN9_BC(dev_priv));
Jani Nikula707d26d2019-08-07 15:04:15 +0300124 return PCH_TGP;
Matt Roper943682e2019-10-15 09:28:54 -0700125 case INTEL_PCH_JSP_DEVICE_ID_TYPE:
126 case INTEL_PCH_JSP2_DEVICE_ID_TYPE:
Wambui Karuga0f699582020-01-07 18:13:29 +0300127 drm_dbg_kms(&dev_priv->drm, "Found Jasper Lake PCH\n");
Tejas Upadhyay24ea0982020-10-14 00:59:48 +0530128 drm_WARN_ON(&dev_priv->drm, !IS_JSL_EHL(dev_priv));
Matt Roper943682e2019-10-15 09:28:54 -0700129 return PCH_JSP;
Anusha Srivatsafb519702021-01-25 06:07:45 -0800130 case INTEL_PCH_ADP_DEVICE_ID_TYPE:
Clinton Taylor83c81a02021-05-11 21:21:43 -0700131 case INTEL_PCH_ADP2_DEVICE_ID_TYPE:
Anusha Srivatsafb519702021-01-25 06:07:45 -0800132 drm_dbg_kms(&dev_priv->drm, "Found Alder Lake PCH\n");
Clinton Taylor83c81a02021-05-11 21:21:43 -0700133 drm_WARN_ON(&dev_priv->drm, !IS_ALDERLAKE_S(dev_priv) &&
134 !IS_ALDERLAKE_P(dev_priv));
Anusha Srivatsafb519702021-01-25 06:07:45 -0800135 return PCH_ADP;
Jani Nikula707d26d2019-08-07 15:04:15 +0300136 default:
137 return PCH_NONE;
138 }
139}
140
141static bool intel_is_virt_pch(unsigned short id,
142 unsigned short svendor, unsigned short sdevice)
143{
144 return (id == INTEL_PCH_P2X_DEVICE_ID_TYPE ||
145 id == INTEL_PCH_P3X_DEVICE_ID_TYPE ||
146 (id == INTEL_PCH_QEMU_DEVICE_ID_TYPE &&
147 svendor == PCI_SUBVENDOR_ID_REDHAT_QUMRANET &&
148 sdevice == PCI_SUBDEVICE_ID_QEMU));
149}
150
Zhenyu Wanga1f6bfe2021-01-14 08:58:19 +0800151static void
152intel_virt_detect_pch(const struct drm_i915_private *dev_priv,
153 unsigned short *pch_id, enum intel_pch *pch_type)
Jani Nikula707d26d2019-08-07 15:04:15 +0300154{
155 unsigned short id = 0;
156
157 /*
158 * In a virtualized passthrough environment we can be in a
159 * setup where the ISA bridge is not able to be passed through.
160 * In this case, a south bridge can be emulated and we have to
161 * make an educated guess as to which PCH is really there.
162 */
163
Clinton Taylor83c81a02021-05-11 21:21:43 -0700164 if (IS_ALDERLAKE_S(dev_priv) || IS_ALDERLAKE_P(dev_priv))
Anusha Srivatsafb519702021-01-25 06:07:45 -0800165 id = INTEL_PCH_ADP_DEVICE_ID_TYPE;
166 else if (IS_TIGERLAKE(dev_priv) || IS_ROCKETLAKE(dev_priv))
Jani Nikula707d26d2019-08-07 15:04:15 +0300167 id = INTEL_PCH_TGP_DEVICE_ID_TYPE;
Tejas Upadhyay24ea0982020-10-14 00:59:48 +0530168 else if (IS_JSL_EHL(dev_priv))
Jani Nikula707d26d2019-08-07 15:04:15 +0300169 id = INTEL_PCH_MCC_DEVICE_ID_TYPE;
170 else if (IS_ICELAKE(dev_priv))
171 id = INTEL_PCH_ICP_DEVICE_ID_TYPE;
Lucas De Marchicf9fb292021-07-28 14:59:39 -0700172 else if (IS_COFFEELAKE(dev_priv) ||
Chris Wilson5f4ae272020-06-02 15:05:40 +0100173 IS_COMETLAKE(dev_priv))
Jani Nikula707d26d2019-08-07 15:04:15 +0300174 id = INTEL_PCH_CNP_DEVICE_ID_TYPE;
175 else if (IS_KABYLAKE(dev_priv) || IS_SKYLAKE(dev_priv))
176 id = INTEL_PCH_SPT_DEVICE_ID_TYPE;
177 else if (IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv))
178 id = INTEL_PCH_LPT_LP_DEVICE_ID_TYPE;
179 else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
180 id = INTEL_PCH_LPT_DEVICE_ID_TYPE;
Lucas De Marchi651e7d42021-06-05 21:50:49 -0700181 else if (GRAPHICS_VER(dev_priv) == 6 || IS_IVYBRIDGE(dev_priv))
Jani Nikula707d26d2019-08-07 15:04:15 +0300182 id = INTEL_PCH_CPT_DEVICE_ID_TYPE;
Lucas De Marchi651e7d42021-06-05 21:50:49 -0700183 else if (GRAPHICS_VER(dev_priv) == 5)
Jani Nikula707d26d2019-08-07 15:04:15 +0300184 id = INTEL_PCH_IBX_DEVICE_ID_TYPE;
185
186 if (id)
Wambui Karuga0f699582020-01-07 18:13:29 +0300187 drm_dbg_kms(&dev_priv->drm, "Assuming PCH ID %04x\n", id);
Jani Nikula707d26d2019-08-07 15:04:15 +0300188 else
Wambui Karuga0f699582020-01-07 18:13:29 +0300189 drm_dbg_kms(&dev_priv->drm, "Assuming no PCH\n");
Jani Nikula707d26d2019-08-07 15:04:15 +0300190
Zhenyu Wanga1f6bfe2021-01-14 08:58:19 +0800191 *pch_type = intel_pch_type(dev_priv, id);
192
193 /* Sanity check virtual PCH id */
194 if (drm_WARN_ON(&dev_priv->drm,
195 id && *pch_type == PCH_NONE))
196 id = 0;
197
198 *pch_id = id;
Jani Nikula707d26d2019-08-07 15:04:15 +0300199}
200
201void intel_detect_pch(struct drm_i915_private *dev_priv)
202{
203 struct pci_dev *pch = NULL;
Zhenyu Wanga1f6bfe2021-01-14 08:58:19 +0800204 unsigned short id;
205 enum intel_pch pch_type;
Jani Nikula707d26d2019-08-07 15:04:15 +0300206
Lucas De Marchi51e3a642020-07-13 11:23:21 -0700207 /* DG1 has south engine display on the same PCI device */
208 if (IS_DG1(dev_priv)) {
209 dev_priv->pch_type = PCH_DG1;
210 return;
Matt Roper3176fb62021-07-21 15:30:35 -0700211 } else if (IS_DG2(dev_priv)) {
212 dev_priv->pch_type = PCH_DG2;
213 return;
Lucas De Marchi51e3a642020-07-13 11:23:21 -0700214 }
215
Jani Nikula707d26d2019-08-07 15:04:15 +0300216 /*
217 * The reason to probe ISA bridge instead of Dev31:Fun0 is to
218 * make graphics device passthrough work easy for VMM, that only
219 * need to expose ISA bridge to let driver know the real hardware
220 * underneath. This is a requirement from virtualization team.
221 *
222 * In some virtualized environments (e.g. XEN), there is irrelevant
223 * ISA bridge in the system. To work reliably, we should scan trhough
224 * all the ISA bridge devices and check for the first match, instead
225 * of only checking the first one.
226 */
227 while ((pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, pch))) {
Jani Nikula707d26d2019-08-07 15:04:15 +0300228 if (pch->vendor != PCI_VENDOR_ID_INTEL)
229 continue;
230
231 id = pch->device & INTEL_PCH_DEVICE_ID_MASK;
232
233 pch_type = intel_pch_type(dev_priv, id);
234 if (pch_type != PCH_NONE) {
235 dev_priv->pch_type = pch_type;
236 dev_priv->pch_id = id;
237 break;
238 } else if (intel_is_virt_pch(id, pch->subsystem_vendor,
239 pch->subsystem_device)) {
Zhenyu Wanga1f6bfe2021-01-14 08:58:19 +0800240 intel_virt_detect_pch(dev_priv, &id, &pch_type);
Jani Nikula707d26d2019-08-07 15:04:15 +0300241 dev_priv->pch_type = pch_type;
242 dev_priv->pch_id = id;
243 break;
244 }
245 }
246
247 /*
248 * Use PCH_NOP (PCH but no South Display) for PCH platforms without
249 * display.
250 */
251 if (pch && !HAS_DISPLAY(dev_priv)) {
Wambui Karuga0f699582020-01-07 18:13:29 +0300252 drm_dbg_kms(&dev_priv->drm,
253 "Display disabled, reverting to NOP PCH\n");
Jani Nikula707d26d2019-08-07 15:04:15 +0300254 dev_priv->pch_type = PCH_NOP;
255 dev_priv->pch_id = 0;
Zhenyu Wanga1f6bfe2021-01-14 08:58:19 +0800256 } else if (!pch) {
257 if (run_as_guest() && HAS_DISPLAY(dev_priv)) {
258 intel_virt_detect_pch(dev_priv, &id, &pch_type);
259 dev_priv->pch_type = pch_type;
260 dev_priv->pch_id = id;
261 } else {
262 drm_dbg_kms(&dev_priv->drm, "No PCH found.\n");
263 }
Jani Nikula707d26d2019-08-07 15:04:15 +0300264 }
265
Jani Nikula707d26d2019-08-07 15:04:15 +0300266 pci_dev_put(pch);
267}