summaryrefslogtreecommitdiff
path: root/drivers/soc/qcom/ubwc_config.c
blob: bd0a98aad9f3b222abcf0a7af85a318caffa9841 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
 */

#include <linux/debugfs.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>

#include <linux/soc/qcom/ubwc.h>

static const struct qcom_ubwc_cfg_data msm8937_data = {
	.ubwc_enc_version = UBWC_1_0,
	.ubwc_dec_version = UBWC_1_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL1 |
			UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.highest_bank_bit = 14,
};

static const struct qcom_ubwc_cfg_data msm8998_data = {
	.ubwc_enc_version = UBWC_1_0,
	.ubwc_dec_version = UBWC_1_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL1 |
			UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.highest_bank_bit = 15,
};

static const struct qcom_ubwc_cfg_data qcm2290_data = {
	/* no UBWC */
	.highest_bank_bit = 15,
};

static const struct qcom_ubwc_cfg_data sa8775p_data = {
	.ubwc_enc_version = UBWC_4_0,
	.ubwc_dec_version = UBWC_4_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	.highest_bank_bit = 13,
	.macrotile_mode = true,
};

static const struct qcom_ubwc_cfg_data sar2130p_data = {
	.ubwc_enc_version = UBWC_3_0, /* 4.0.2 in hw */
	.ubwc_dec_version = UBWC_4_3,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	.highest_bank_bit = 13,
	.macrotile_mode = true,
};

static const struct qcom_ubwc_cfg_data sc7180_data = {
	.ubwc_enc_version = UBWC_2_0,
	.ubwc_dec_version = UBWC_2_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	.highest_bank_bit = 14,
};

static const struct qcom_ubwc_cfg_data sc7280_data = {
	.ubwc_enc_version = UBWC_3_0,
	.ubwc_dec_version = UBWC_4_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	.highest_bank_bit = 14,
	.macrotile_mode = true,
};

static const struct qcom_ubwc_cfg_data sc8180x_data = {
	.ubwc_enc_version = UBWC_3_0,
	.ubwc_dec_version = UBWC_3_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.highest_bank_bit = 16,
	.macrotile_mode = true,
};

static const struct qcom_ubwc_cfg_data sc8280xp_data = {
	.ubwc_enc_version = UBWC_4_0,
	.ubwc_dec_version = UBWC_4_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	.highest_bank_bit = 16,
	.macrotile_mode = true,
};

static const struct qcom_ubwc_cfg_data sdm670_data = {
	.ubwc_enc_version = UBWC_2_0,
	.ubwc_dec_version = UBWC_2_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.highest_bank_bit = 14,
};

static const struct qcom_ubwc_cfg_data sdm845_data = {
	.ubwc_enc_version = UBWC_2_0,
	.ubwc_dec_version = UBWC_2_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.highest_bank_bit = 15,
};

static const struct qcom_ubwc_cfg_data sm6115_data = {
	.ubwc_enc_version = UBWC_1_0,
	.ubwc_dec_version = UBWC_2_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL1 |
			UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	.highest_bank_bit = 14,
};

static const struct qcom_ubwc_cfg_data sm6125_data = {
	.ubwc_enc_version = UBWC_1_0,
	.ubwc_dec_version = UBWC_3_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL1 |
			UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.highest_bank_bit = 14,
};

static const struct qcom_ubwc_cfg_data sm6150_data = {
	.ubwc_enc_version = UBWC_2_0,
	.ubwc_dec_version = UBWC_2_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.highest_bank_bit = 14,
};

static const struct qcom_ubwc_cfg_data sm6350_data = {
	.ubwc_enc_version = UBWC_2_0,
	.ubwc_dec_version = UBWC_2_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	.highest_bank_bit = 14,
};

static const struct qcom_ubwc_cfg_data sm7150_data = {
	.ubwc_enc_version = UBWC_2_0,
	.ubwc_dec_version = UBWC_2_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.highest_bank_bit = 14,
};

static const struct qcom_ubwc_cfg_data sm8150_data = {
	.ubwc_enc_version = UBWC_3_0,
	.ubwc_dec_version = UBWC_3_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.highest_bank_bit = 15,
};

static const struct qcom_ubwc_cfg_data sm8250_data = {
	.ubwc_enc_version = UBWC_4_0,
	.ubwc_dec_version = UBWC_4_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	/* TODO: highest_bank_bit = 15 for LP_DDR4 */
	.highest_bank_bit = 16,
	.macrotile_mode = true,
};

static const struct qcom_ubwc_cfg_data sm8350_data = {
	.ubwc_enc_version = UBWC_4_0,
	.ubwc_dec_version = UBWC_4_0,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	/* TODO: highest_bank_bit = 15 for LP_DDR4 */
	.highest_bank_bit = 16,
	.macrotile_mode = true,
};

static const struct qcom_ubwc_cfg_data sm8550_data = {
	.ubwc_enc_version = UBWC_4_0,
	.ubwc_dec_version = UBWC_4_3,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	/* TODO: highest_bank_bit = 15 for LP_DDR4 */
	.highest_bank_bit = 16,
	.macrotile_mode = true,
};

static const struct qcom_ubwc_cfg_data sm8750_data = {
	.ubwc_enc_version = UBWC_5_0,
	.ubwc_dec_version = UBWC_5_0,
	.ubwc_swizzle = 6,
	.ubwc_bank_spread = true,
	/* TODO: highest_bank_bit = 15 for LP_DDR4 */
	.highest_bank_bit = 16,
	.macrotile_mode = true,
};

static const struct qcom_ubwc_cfg_data x1e80100_data = {
	.ubwc_enc_version = UBWC_4_0,
	.ubwc_dec_version = UBWC_4_3,
	.ubwc_swizzle = UBWC_SWIZZLE_ENABLE_LVL2 |
			UBWC_SWIZZLE_ENABLE_LVL3,
	.ubwc_bank_spread = true,
	/* TODO: highest_bank_bit = 15 for LP_DDR4 */
	.highest_bank_bit = 16,
	.macrotile_mode = true,
};

static const struct of_device_id qcom_ubwc_configs[] __maybe_unused = {
	{ .compatible = "qcom,apq8096", .data = &msm8998_data },
	{ .compatible = "qcom,msm8917", .data = &msm8937_data },
	{ .compatible = "qcom,msm8937", .data = &msm8937_data },
	{ .compatible = "qcom,msm8953", .data = &msm8937_data },
	{ .compatible = "qcom,msm8956", .data = &msm8937_data },
	{ .compatible = "qcom,msm8976", .data = &msm8937_data },
	{ .compatible = "qcom,msm8996", .data = &msm8998_data },
	{ .compatible = "qcom,msm8998", .data = &msm8998_data },
	{ .compatible = "qcom,qcm2290", .data = &qcm2290_data, },
	{ .compatible = "qcom,qcm6490", .data = &sc7280_data, },
	{ .compatible = "qcom,sa8155p", .data = &sm8150_data, },
	{ .compatible = "qcom,sa8540p", .data = &sc8280xp_data, },
	{ .compatible = "qcom,sa8775p", .data = &sa8775p_data, },
	{ .compatible = "qcom,sar2130p", .data = &sar2130p_data },
	{ .compatible = "qcom,sc7180", .data = &sc7180_data },
	{ .compatible = "qcom,sc7280", .data = &sc7280_data, },
	{ .compatible = "qcom,sc8180x", .data = &sc8180x_data, },
	{ .compatible = "qcom,sc8280xp", .data = &sc8280xp_data, },
	{ .compatible = "qcom,sdm630", .data = &msm8937_data },
	{ .compatible = "qcom,sdm636", .data = &msm8937_data },
	{ .compatible = "qcom,sdm660", .data = &msm8937_data },
	{ .compatible = "qcom,sdm670", .data = &sdm670_data, },
	{ .compatible = "qcom,sdm845", .data = &sdm845_data, },
	{ .compatible = "qcom,sm4250", .data = &sm6115_data, },
	{ .compatible = "qcom,sm6115", .data = &sm6115_data, },
	{ .compatible = "qcom,sm6125", .data = &sm6125_data, },
	{ .compatible = "qcom,sm6150", .data = &sm6150_data, },
	{ .compatible = "qcom,sm6350", .data = &sm6350_data, },
	{ .compatible = "qcom,sm6375", .data = &sm6350_data, },
	{ .compatible = "qcom,sm7125", .data = &sc7180_data },
	{ .compatible = "qcom,sm7150", .data = &sm7150_data, },
	{ .compatible = "qcom,sm8150", .data = &sm8150_data, },
	{ .compatible = "qcom,sm8250", .data = &sm8250_data, },
	{ .compatible = "qcom,sm8350", .data = &sm8350_data, },
	{ .compatible = "qcom,sm8450", .data = &sm8350_data, },
	{ .compatible = "qcom,sm8550", .data = &sm8550_data, },
	{ .compatible = "qcom,sm8650", .data = &sm8550_data, },
	{ .compatible = "qcom,sm8750", .data = &sm8750_data, },
	{ .compatible = "qcom,x1e80100", .data = &x1e80100_data, },
	{ .compatible = "qcom,x1p42100", .data = &x1e80100_data, },
	{ }
};

const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void)
{
	const struct of_device_id *match;
	struct device_node *root;

	root = of_find_node_by_path("/");
	if (!root)
		return ERR_PTR(-ENODEV);

	match = of_match_node(qcom_ubwc_configs, root);
	of_node_put(root);
	if (!match) {
		pr_err("Couldn't find UBWC config data for this platform!\n");
		return ERR_PTR(-EINVAL);
	}

	return match->data;
}
EXPORT_SYMBOL_GPL(qcom_ubwc_config_get_data);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("UBWC config database for QTI SoCs");