summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/intel_step.c
blob: 1dd6944e7aca9abdcfd95b606f59b94b4ccf4c0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// SPDX-License-Identifier: MIT
/*
 * Copyright © 2020,2021 Intel Corporation
 */

#include "i915_drv.h"
#include "intel_step.h"

/*
 * Some platforms have unusual ways of mapping PCI revision ID to GT/display
 * steppings.  E.g., in some cases a higher PCI revision may translate to a
 * lower stepping of the GT and/or display IP.  This file provides lookup
 * tables to map the PCI revision into a standard set of stepping values that
 * can be compared numerically.
 *
 * Also note that some revisions/steppings may have been set aside as
 * placeholders but never materialized in real hardware; in those cases there
 * may be jumps in the revision IDs or stepping values in the tables below.
 */

/*
 * Some platforms always have the same stepping value for GT and display;
 * use a macro to define these to make it easier to identify the platforms
 * where the two steppings can deviate.
 */
#define COMMON_STEP(x)  .gt_step = STEP_##x, .display_step = STEP_##x

static const struct intel_step_info skl_revids[] = {
	[0x6] = { COMMON_STEP(G0) },
	[0x7] = { COMMON_STEP(H0) },
	[0x9] = { COMMON_STEP(J0) },
	[0xA] = { COMMON_STEP(I1) },
};

static const struct intel_step_info kbl_revids[] = {
	[1] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
	[2] = { .gt_step = STEP_C0, .display_step = STEP_B0 },
	[3] = { .gt_step = STEP_D0, .display_step = STEP_B0 },
	[4] = { .gt_step = STEP_F0, .display_step = STEP_C0 },
	[5] = { .gt_step = STEP_C0, .display_step = STEP_B1 },
	[6] = { .gt_step = STEP_D1, .display_step = STEP_B1 },
	[7] = { .gt_step = STEP_G0, .display_step = STEP_C0 },
};

static const struct intel_step_info tgl_uy_revids[] = {
	[0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
	[1] = { .gt_step = STEP_B0, .display_step = STEP_C0 },
	[2] = { .gt_step = STEP_B1, .display_step = STEP_C0 },
	[3] = { .gt_step = STEP_C0, .display_step = STEP_D0 },
};

/* Same GT stepping between tgl_uy_revids and tgl_revids don't mean the same HW */
static const struct intel_step_info tgl_revids[] = {
	[0] = { .gt_step = STEP_A0, .display_step = STEP_B0 },
	[1] = { .gt_step = STEP_B0, .display_step = STEP_D0 },
};

static const struct intel_step_info adls_revids[] = {
	[0x0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
	[0x1] = { .gt_step = STEP_A0, .display_step = STEP_A2 },
	[0x4] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
	[0x8] = { .gt_step = STEP_C0, .display_step = STEP_B0 },
	[0xC] = { .gt_step = STEP_D0, .display_step = STEP_C0 },
};

static const struct intel_step_info adlp_revids[] = {
	[0x0] = { .gt_step = STEP_A0, .display_step = STEP_A0 },
	[0x4] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
	[0x8] = { .gt_step = STEP_C0, .display_step = STEP_C0 },
	[0xC] = { .gt_step = STEP_C0, .display_step = STEP_D0 },
};

void intel_step_init(struct drm_i915_private *i915)
{
	const struct intel_step_info *revids = NULL;
	int size = 0;
	int revid = INTEL_REVID(i915);
	struct intel_step_info step = {};

	if (IS_ALDERLAKE_P(i915)) {
		revids = adlp_revids;
		size = ARRAY_SIZE(adlp_revids);
	} else if (IS_ALDERLAKE_S(i915)) {
		revids = adls_revids;
		size = ARRAY_SIZE(adls_revids);
	} else if (IS_TGL_U(i915) || IS_TGL_Y(i915)) {
		revids = tgl_uy_revids;
		size = ARRAY_SIZE(tgl_uy_revids);
	} else if (IS_TIGERLAKE(i915)) {
		revids = tgl_revids;
		size = ARRAY_SIZE(tgl_revids);
	} else if (IS_KABYLAKE(i915)) {
		revids = kbl_revids;
		size = ARRAY_SIZE(kbl_revids);
	} else if (IS_SKYLAKE(i915)) {
		revids = skl_revids;
		size = ARRAY_SIZE(skl_revids);
	}

	/* Not using the stepping scheme for the platform yet. */
	if (!revids)
		return;

	if (revid < size && revids[revid].gt_step != STEP_NONE) {
		step = revids[revid];
	} else {
		drm_warn(&i915->drm, "Unknown revid 0x%02x\n", revid);

		/*
		 * If we hit a gap in the revid array, use the information for
		 * the next revid.
		 *
		 * This may be wrong in all sorts of ways, especially if the
		 * steppings in the array are not monotonically increasing, but
		 * it's better than defaulting to 0.
		 */
		while (revid < size && revids[revid].gt_step == STEP_NONE)
			revid++;

		if (revid < size) {
			drm_dbg(&i915->drm, "Using steppings for revid 0x%02x\n",
				revid);
			step = revids[revid];
		} else {
			drm_dbg(&i915->drm, "Using future steppings\n");
			step.gt_step = STEP_FUTURE;
			step.display_step = STEP_FUTURE;
		}
	}

	if (drm_WARN_ON(&i915->drm, step.gt_step == STEP_NONE))
		return;

	RUNTIME_INFO(i915)->step = step;
}