9de17bdfe62f42d0c1e1f243662b02ddd656fb99
[linux-2.6-microblaze.git] / drivers / gpu / drm / i915 / intel_step.c
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  * Some platforms have unusual ways of mapping PCI revision ID to GT/display
11  * steppings.  E.g., in some cases a higher PCI revision may translate to a
12  * lower stepping of the GT and/or display IP.  This file provides lookup
13  * tables to map the PCI revision into a standard set of stepping values that
14  * can be compared numerically.
15  *
16  * Also note that some revisions/steppings may have been set aside as
17  * placeholders but never materialized in real hardware; in those cases there
18  * may be jumps in the revision IDs or stepping values in the tables below.
19  */
20
21 /*
22  * Some platforms always have the same stepping value for GT and display;
23  * use a macro to define these to make it easier to identify the platforms
24  * where the two steppings can deviate.
25  */
26 #define COMMON_STEP(x)  .gt_step = STEP_##x, .display_step = STEP_##x
27
28 static const struct intel_step_info skl_revids[] = {
29         [0x6] = { COMMON_STEP(G0) },
30         [0x7] = { COMMON_STEP(H0) },
31         [0x9] = { COMMON_STEP(J0) },
32         [0xA] = { COMMON_STEP(I1) },
33 };
34
35 static const struct intel_step_info kbl_revids[] = {
36         [1] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
37         [2] = { .gt_step = STEP_C0, .display_step = STEP_B0 },
38         [3] = { .gt_step = STEP_D0, .display_step = STEP_B0 },
39         [4] = { .gt_step = STEP_F0, .display_step = STEP_C0 },
40         [5] = { .gt_step = STEP_C0, .display_step = STEP_B1 },
41         [6] = { .gt_step = STEP_D1, .display_step = STEP_B1 },
42         [7] = { .gt_step = STEP_G0, .display_step = STEP_C0 },
43 };
44
45 static const struct intel_step_info bxt_revids[] = {
46         [0xA] = { COMMON_STEP(C0) },
47         [0xB] = { COMMON_STEP(C0) },
48         [0xC] = { COMMON_STEP(D0) },
49         [0xD] = { COMMON_STEP(E0) },
50 };
51
52 static const struct intel_step_info glk_revids[] = {
53         [3] = { COMMON_STEP(B0) },
54 };
55
56 static const struct intel_step_info icl_revids[] = {
57         [7] = { COMMON_STEP(D0) },
58 };
59
60 static const struct intel_step_info jsl_ehl_revids[] = {
61         [0] = { COMMON_STEP(A0) },
62         [1] = { COMMON_STEP(B0) },
63 };
64
65 static const struct intel_step_info tgl_uy_revids[] = {
66         [0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
67         [1] = { .gt_step = STEP_B0, .display_step = STEP_C0 },
68         [2] = { .gt_step = STEP_B1, .display_step = STEP_C0 },
69         [3] = { .gt_step = STEP_C0, .display_step = STEP_D0 },
70 };
71
72 /* Same GT stepping between tgl_uy_revids and tgl_revids don't mean the same HW */
73 static const struct intel_step_info tgl_revids[] = {
74         [0] = { .gt_step = STEP_A0, .display_step = STEP_B0 },
75         [1] = { .gt_step = STEP_B0, .display_step = STEP_D0 },
76 };
77
78 static const struct intel_step_info adls_revids[] = {
79         [0x0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
80         [0x1] = { .gt_step = STEP_A0, .display_step = STEP_A2 },
81         [0x4] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
82         [0x8] = { .gt_step = STEP_C0, .display_step = STEP_B0 },
83         [0xC] = { .gt_step = STEP_D0, .display_step = STEP_C0 },
84 };
85
86 static const struct intel_step_info adlp_revids[] = {
87         [0x0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
88         [0x4] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
89         [0x8] = { .gt_step = STEP_C0, .display_step = STEP_C0 },
90         [0xC] = { .gt_step = STEP_C0, .display_step = STEP_D0 },
91 };
92
93 void intel_step_init(struct drm_i915_private *i915)
94 {
95         const struct intel_step_info *revids = NULL;
96         int size = 0;
97         int revid = INTEL_REVID(i915);
98         struct intel_step_info step = {};
99
100         if (IS_ALDERLAKE_P(i915)) {
101                 revids = adlp_revids;
102                 size = ARRAY_SIZE(adlp_revids);
103         } else if (IS_ALDERLAKE_S(i915)) {
104                 revids = adls_revids;
105                 size = ARRAY_SIZE(adls_revids);
106         } else if (IS_TGL_U(i915) || IS_TGL_Y(i915)) {
107                 revids = tgl_uy_revids;
108                 size = ARRAY_SIZE(tgl_uy_revids);
109         } else if (IS_TIGERLAKE(i915)) {
110                 revids = tgl_revids;
111                 size = ARRAY_SIZE(tgl_revids);
112         } else if (IS_JSL_EHL(i915)) {
113                 revids = jsl_ehl_revids;
114                 size = ARRAY_SIZE(jsl_ehl_revids);
115         } else if (IS_ICELAKE(i915)) {
116                 revids = icl_revids;
117                 size = ARRAY_SIZE(icl_revids);
118         } else if (IS_GEMINILAKE(i915)) {
119                 revids = glk_revids;
120                 size = ARRAY_SIZE(glk_revids);
121         } else if (IS_BROXTON(i915)) {
122                 revids = bxt_revids;
123                 size = ARRAY_SIZE(bxt_revids);
124         } else if (IS_KABYLAKE(i915)) {
125                 revids = kbl_revids;
126                 size = ARRAY_SIZE(kbl_revids);
127         } else if (IS_SKYLAKE(i915)) {
128                 revids = skl_revids;
129                 size = ARRAY_SIZE(skl_revids);
130         }
131
132         /* Not using the stepping scheme for the platform yet. */
133         if (!revids)
134                 return;
135
136         if (revid < size && revids[revid].gt_step != STEP_NONE) {
137                 step = revids[revid];
138         } else {
139                 drm_warn(&i915->drm, "Unknown revid 0x%02x\n", revid);
140
141                 /*
142                  * If we hit a gap in the revid array, use the information for
143                  * the next revid.
144                  *
145                  * This may be wrong in all sorts of ways, especially if the
146                  * steppings in the array are not monotonically increasing, but
147                  * it's better than defaulting to 0.
148                  */
149                 while (revid < size && revids[revid].gt_step == STEP_NONE)
150                         revid++;
151
152                 if (revid < size) {
153                         drm_dbg(&i915->drm, "Using steppings for revid 0x%02x\n",
154                                 revid);
155                         step = revids[revid];
156                 } else {
157                         drm_dbg(&i915->drm, "Using future steppings\n");
158                         step.gt_step = STEP_FUTURE;
159                         step.display_step = STEP_FUTURE;
160                 }
161         }
162
163         if (drm_WARN_ON(&i915->drm, step.gt_step == STEP_NONE))
164                 return;
165
166         RUNTIME_INFO(i915)->step = step;
167 }