xref: /openbmc/linux/drivers/gpu/drm/i915/intel_step.c (revision cd6d421e)
1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright © 2020,2021 Intel Corporation
4  */
5 
6 #include "i915_drv.h"
7 #include "intel_step.h"
8 
9 /*
10  * KBL revision ID ordering is bizarre; higher revision ID's map to lower
11  * steppings in some cases.  So rather than test against the revision ID
12  * directly, let's map that into our own range of increasing ID's that we
13  * can test against in a regular manner.
14  */
15 
16 
17 /* FIXME: what about REVID_E0 */
18 static const struct intel_step_info kbl_revids[] = {
19 	[0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
20 	[1] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
21 	[2] = { .gt_step = STEP_C0, .display_step = STEP_B0 },
22 	[3] = { .gt_step = STEP_D0, .display_step = STEP_B0 },
23 	[4] = { .gt_step = STEP_F0, .display_step = STEP_C0 },
24 	[5] = { .gt_step = STEP_C0, .display_step = STEP_B1 },
25 	[6] = { .gt_step = STEP_D1, .display_step = STEP_B1 },
26 	[7] = { .gt_step = STEP_G0, .display_step = STEP_C0 },
27 };
28 
29 static const struct intel_step_info tgl_uy_revid_step_tbl[] = {
30 	[0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
31 	[1] = { .gt_step = STEP_B0, .display_step = STEP_C0 },
32 	[2] = { .gt_step = STEP_B1, .display_step = STEP_C0 },
33 	[3] = { .gt_step = STEP_C0, .display_step = STEP_D0 },
34 };
35 
36 /* Same GT stepping between tgl_uy_revids and tgl_revids don't mean the same HW */
37 static const struct intel_step_info tgl_revid_step_tbl[] = {
38 	[0] = { .gt_step = STEP_A0, .display_step = STEP_B0 },
39 	[1] = { .gt_step = STEP_B0, .display_step = STEP_D0 },
40 };
41 
42 static const struct intel_step_info adls_revid_step_tbl[] = {
43 	[0x0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
44 	[0x1] = { .gt_step = STEP_A0, .display_step = STEP_A2 },
45 	[0x4] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
46 	[0x8] = { .gt_step = STEP_C0, .display_step = STEP_B0 },
47 	[0xC] = { .gt_step = STEP_D0, .display_step = STEP_C0 },
48 };
49 
50 void intel_step_init(struct drm_i915_private *i915)
51 {
52 	const struct intel_step_info *revids = NULL;
53 	int size = 0;
54 	int revid = INTEL_REVID(i915);
55 	struct intel_step_info step = {};
56 
57 	if (IS_ALDERLAKE_S(i915)) {
58 		revids = adls_revid_step_tbl;
59 		size = ARRAY_SIZE(adls_revid_step_tbl);
60 	} else if (IS_TGL_U(i915) || IS_TGL_Y(i915)) {
61 		revids = tgl_uy_revid_step_tbl;
62 		size = ARRAY_SIZE(tgl_uy_revid_step_tbl);
63 	} else if (IS_TIGERLAKE(i915)) {
64 		revids = tgl_revid_step_tbl;
65 		size = ARRAY_SIZE(tgl_revid_step_tbl);
66 	} else if (IS_KABYLAKE(i915)) {
67 		revids = kbl_revids;
68 		size = ARRAY_SIZE(kbl_revids);
69 	}
70 
71 	/* Not using the stepping scheme for the platform yet. */
72 	if (!revids)
73 		return;
74 
75 	if (revid < size && revids[revid].gt_step != STEP_NONE) {
76 		step = revids[revid];
77 	} else {
78 		drm_warn(&i915->drm, "Unknown revid 0x%02x\n", revid);
79 
80 		/*
81 		 * If we hit a gap in the revid array, use the information for
82 		 * the next revid.
83 		 *
84 		 * This may be wrong in all sorts of ways, especially if the
85 		 * steppings in the array are not monotonically increasing, but
86 		 * it's better than defaulting to 0.
87 		 */
88 		while (revid < size && revids[revid].gt_step == STEP_NONE)
89 			revid++;
90 
91 		if (revid < size) {
92 			drm_dbg(&i915->drm, "Using steppings for revid 0x%02x\n",
93 				revid);
94 			step = revids[revid];
95 		} else {
96 			drm_dbg(&i915->drm, "Using future steppings\n");
97 			step.gt_step = STEP_FUTURE;
98 			step.display_step = STEP_FUTURE;
99 		}
100 	}
101 
102 	if (drm_WARN_ON(&i915->drm, step.gt_step == STEP_NONE))
103 		return;
104 
105 	RUNTIME_INFO(i915)->step = step;
106 }
107