]> Git Repo - linux.git/blob - drivers/gpu/drm/i915/intel_step.c
Backmerge tag 'v5.13-rc7' into drm-next
[linux.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  * 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 static 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
57 void intel_step_init(struct drm_i915_private *i915)
58 {
59         const struct intel_step_info *revids = NULL;
60         int size = 0;
61         int revid = INTEL_REVID(i915);
62         struct intel_step_info step = {};
63
64         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)) {
68                 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)) {
77                 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
85         if (revid < size && revids[revid].gt_step != STEP_NONE) {
86                 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                  */
98                 while (revid < size && revids[revid].gt_step == STEP_NONE)
99                         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");
107                         step.gt_step = STEP_FUTURE;
108                         step.display_step = STEP_FUTURE;
109                 }
110         }
111
112         if (drm_WARN_ON(&i915->drm, step.gt_step == STEP_NONE))
113                 return;
114
115         RUNTIME_INFO(i915)->step = step;
116 }
This page took 0.040646 seconds and 4 git commands to generate.