blob: ba9479a67521190a3c76fbae6c33f7b8210641ab [file] [log] [blame]
Jani Nikula7eb186b2021-03-26 15:21:32 +02001// 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
Jani Nikulaef47b7a2021-03-26 15:21:34 +020016
17/* FIXME: what about REVID_E0 */
Jani Nikula5644dc02021-03-26 15:21:38 +020018static const struct intel_step_info kbl_revids[] = {
Jani Nikula26475ca2021-03-26 15:21:37 +020019 [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 },
Jani Nikula7eb186b2021-03-26 15:21:32 +020027};
28
Jani Nikula5644dc02021-03-26 15:21:38 +020029static const struct intel_step_info tgl_uy_revid_step_tbl[] = {
Jani Nikula26475ca2021-03-26 15:21:37 +020030 [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 },
Jani Nikula7eb186b2021-03-26 15:21:32 +020034};
35
36/* Same GT stepping between tgl_uy_revids and tgl_revids don't mean the same HW */
Jani Nikula5644dc02021-03-26 15:21:38 +020037static const struct intel_step_info tgl_revid_step_tbl[] = {
Jani Nikula26475ca2021-03-26 15:21:37 +020038 [0] = { .gt_step = STEP_A0, .display_step = STEP_B0 },
39 [1] = { .gt_step = STEP_B0, .display_step = STEP_D0 },
Jani Nikula7eb186b2021-03-26 15:21:32 +020040};
41
Jani Nikula5644dc02021-03-26 15:21:38 +020042static const struct intel_step_info adls_revid_step_tbl[] = {
Jani Nikula26475ca2021-03-26 15:21:37 +020043 [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 },
Jani Nikula7eb186b2021-03-26 15:21:32 +020048};
Jani Nikulaef47b7a2021-03-26 15:21:34 +020049
José Roberto de Souzab2c6eaf2021-05-14 08:37:08 -070050static const struct intel_step_info adlp_revid_step_tbl[] = {
51 [0x0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
52 [0x4] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
53 [0x8] = { .gt_step = STEP_C0, .display_step = STEP_C0 },
54 [0xC] = { .gt_step = STEP_C0, .display_step = STEP_D0 },
55};
56
Jani Nikulaef47b7a2021-03-26 15:21:34 +020057void intel_step_init(struct drm_i915_private *i915)
58{
Jani Nikula5644dc02021-03-26 15:21:38 +020059 const struct intel_step_info *revids = NULL;
Jani Nikulaef47b7a2021-03-26 15:21:34 +020060 int size = 0;
61 int revid = INTEL_REVID(i915);
Jani Nikula5644dc02021-03-26 15:21:38 +020062 struct intel_step_info step = {};
Jani Nikulaef47b7a2021-03-26 15:21:34 +020063
José Roberto de Souzab2c6eaf2021-05-14 08:37:08 -070064 if (IS_ALDERLAKE_P(i915)) {
65 revids = adlp_revid_step_tbl;
66 size = ARRAY_SIZE(adlp_revid_step_tbl);
67 } else if (IS_ALDERLAKE_S(i915)) {
Jani Nikula34b7e272021-03-26 15:21:35 +020068 revids = adls_revid_step_tbl;
69 size = ARRAY_SIZE(adls_revid_step_tbl);
70 } else if (IS_TGL_U(i915) || IS_TGL_Y(i915)) {
71 revids = tgl_uy_revid_step_tbl;
72 size = ARRAY_SIZE(tgl_uy_revid_step_tbl);
73 } else if (IS_TIGERLAKE(i915)) {
74 revids = tgl_revid_step_tbl;
75 size = ARRAY_SIZE(tgl_revid_step_tbl);
76 } else if (IS_KABYLAKE(i915)) {
Jani Nikulaef47b7a2021-03-26 15:21:34 +020077 revids = kbl_revids;
78 size = ARRAY_SIZE(kbl_revids);
79 }
80
81 /* Not using the stepping scheme for the platform yet. */
82 if (!revids)
83 return;
84
Jani Nikula26475ca2021-03-26 15:21:37 +020085 if (revid < size && revids[revid].gt_step != STEP_NONE) {
Jani Nikulaef47b7a2021-03-26 15:21:34 +020086 step = revids[revid];
87 } else {
88 drm_warn(&i915->drm, "Unknown revid 0x%02x\n", revid);
89
90 /*
91 * If we hit a gap in the revid array, use the information for
92 * the next revid.
93 *
94 * This may be wrong in all sorts of ways, especially if the
95 * steppings in the array are not monotonically increasing, but
96 * it's better than defaulting to 0.
97 */
Jani Nikula26475ca2021-03-26 15:21:37 +020098 while (revid < size && revids[revid].gt_step == STEP_NONE)
Jani Nikulaef47b7a2021-03-26 15:21:34 +020099 revid++;
100
101 if (revid < size) {
102 drm_dbg(&i915->drm, "Using steppings for revid 0x%02x\n",
103 revid);
104 step = revids[revid];
105 } else {
106 drm_dbg(&i915->drm, "Using future steppings\n");
Jani Nikula26475ca2021-03-26 15:21:37 +0200107 step.gt_step = STEP_FUTURE;
108 step.display_step = STEP_FUTURE;
Jani Nikulaef47b7a2021-03-26 15:21:34 +0200109 }
110 }
111
Jani Nikula26475ca2021-03-26 15:21:37 +0200112 if (drm_WARN_ON(&i915->drm, step.gt_step == STEP_NONE))
Jani Nikulaef47b7a2021-03-26 15:21:34 +0200113 return;
114
115 RUNTIME_INFO(i915)->step = step;
116}