summaryrefslogtreecommitdiff
path: root/arch/mips/mach-octeon/include/mach/octeon-feature.h
blob: 1202716ba52e87d002ba352681a4de3d6077db91 (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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2020 Marvell International Ltd.
 */

#ifndef __OCTEON_FEATURE_H__
#define __OCTEON_FEATURE_H__

/*
 * Octeon models are declared after the macros in octeon-model.h with the
 * suffix _FEATURE. The individual features are declared with the
 * _FEATURE_ infix.
 */
enum octeon_feature {
	/*
	 * Checks on the critical path are moved to the top (8 positions)
	 * so that the compiler generates one less insn than for the rest
	 * of the checks.
	 */
	OCTEON_FEATURE_PKND, /* CN68XX uses port kinds for packet interface */
	/* CN68XX has different fields in word0 - word2 */
	OCTEON_FEATURE_CN68XX_WQE,

	/*
	 * Features
	 */
	/*
	 * Octeon models in the CN5XXX family and higher support atomic
	 * add instructions to memory (saa/saad)
	 */
	OCTEON_FEATURE_SAAD,
	/* Does this Octeon support the ZIP offload engine? */
	OCTEON_FEATURE_ZIP,
	/* Does this Octeon support crypto acceleration using COP2? */
	OCTEON_FEATURE_CRYPTO,
	/* Can crypto be enabled by calling cvmx_crypto_dormant_enable()? */
	OCTEON_FEATURE_DORM_CRYPTO,
	OCTEON_FEATURE_PCIE,	/* Does this Octeon support PCI express? */
	OCTEON_FEATURE_SRIO,	/* Does this Octeon support SRIO */
	OCTEON_FEATURE_ILK,	/* Does this Octeon support Interlaken */
	/*
	 * Some Octeon models support internal memory for storing
	 * cryptographic keys
	 */
	OCTEON_FEATURE_KEY_MEMORY,
	/* Octeon has a LED controller for banks of external LEDs */
	OCTEON_FEATURE_LED_CONTROLLER,
	OCTEON_FEATURE_TRA,	/* Octeon has a trace buffer */
	OCTEON_FEATURE_MGMT_PORT, /* Octeon has a management port */
	OCTEON_FEATURE_RAID,	/* Octeon has a raid unit */
	OCTEON_FEATURE_USB,	/* Octeon has a builtin USB */
	/* Octeon IPD can run without using work queue entries */
	OCTEON_FEATURE_NO_WPTR,
	OCTEON_FEATURE_DFA,	/* Octeon has DFA state machines */
	/*
	 * Octeon MDIO block supports clause 45 transactions for
	 * 10 Gig support
	 */
	OCTEON_FEATURE_MDIO_CLAUSE_45,
	/*
	 * CN52XX and CN56XX used a block named NPEI for PCIe access.
	 * Newer chips replaced this with SLI+DPI
	 */
	OCTEON_FEATURE_NPEI,
	OCTEON_FEATURE_HFA,	/* Octeon has DFA/HFA */
	OCTEON_FEATURE_DFM,	/* Octeon has DFM */
	OCTEON_FEATURE_CIU2,	/* Octeon has CIU2 */
	/* Octeon has DMA Instruction Completion Interrupt mode */
	OCTEON_FEATURE_DICI_MODE,
	/* Octeon has Bit Select Extractor schedulor */
	OCTEON_FEATURE_BIT_EXTRACTOR,
	OCTEON_FEATURE_NAND,	/* Octeon has NAND */
	OCTEON_FEATURE_MMC,	/* Octeon has built-in MMC support */
	OCTEON_FEATURE_ROM,	/* Octeon has built-in ROM support */
	OCTEON_FEATURE_AUTHENTIK, /* Octeon has Authentik ROM support */
	OCTEON_FEATURE_MULTICAST_TIMER, /* Octeon has multi_cast timer */
	OCTEON_FEATURE_MULTINODE, /* Octeon has node support */
	OCTEON_FEATURE_CIU3,	/* Octeon has CIU3 */
	OCTEON_FEATURE_FPA3,	/* Octeon has FPA first seen on 78XX */
	/* CN78XX has different fields in word0 - word2 */
	OCTEON_FEATURE_CN78XX_WQE,
	OCTEON_FEATURE_PKO3,	/* Octeon has enhanced PKO block */
	OCTEON_FEATURE_SPI,	/* Octeon supports SPI interfaces */
	OCTEON_FEATURE_ZIP3,	/* Octeon has zip first seen on 78XX */
	OCTEON_FEATURE_BCH,	/* Octeon supports BCH ECC */
	OCTEON_FEATURE_PKI,	/* Octeon has PKI block */
	OCTEON_FEATURE_OCLA,	/* Octeon has OCLA */
	OCTEON_FEATURE_FAU,	/* Octeon has FAU */
	OCTEON_FEATURE_BGX,	/* Octeon has BGX */
	OCTEON_FEATURE_BGX_MIX,	/* On of the BGX is used for MIX */
	OCTEON_FEATURE_HNA,	/* Octeon has HNA */
	OCTEON_FEATURE_BGX_XCV,	/* Octeon has BGX XCV RGMII support */
	OCTEON_FEATURE_TSO,	/* Octeon has tcp segmentation offload */
	OCTEON_FEATURE_TDM,	/* Octeon has PCM/TDM support */
	OCTEON_FEATURE_PTP,	/* Octeon has PTP support */
	OCTEON_MAX_FEATURE
};

static inline int octeon_has_feature_OCTEON_FEATURE_SAAD(void)
{
	return true;
}

static inline int octeon_has_feature_OCTEON_FEATURE_ZIP(void)
{
	if (OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
	    OCTEON_IS_MODEL(OCTEON_CN70XX) || OCTEON_IS_MODEL(OCTEON_CNF75XX))
		return 0;
	else
		return !cvmx_fuse_read(121);
}

static inline int octeon_has_feature_OCTEON_FEATURE_ZIP3(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_BCH(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN70XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_CRYPTO(void)
{
	/* OCTEON II and later */
	u64 val;

	val = csr_rd(CVMX_MIO_FUS_DAT2);
	if (val & MIO_FUS_DAT2_NOCRYPTO || val & MIO_FUS_DAT2_NOMUL)
		return 0;
	else if (!(val & MIO_FUS_DAT2_DORM_CRYPTO))
		return 1;

	val = csr_rd(CVMX_RNM_CTL_STATUS);
	return val & RNM_CTL_STATUS_EER_VAL;
}

static inline int octeon_has_feature_OCTEON_FEATURE_DORM_CRYPTO(void)
{
	/* OCTEON II and later */
	u64 val;

	val = csr_rd(CVMX_MIO_FUS_DAT2);
	return !(val & MIO_FUS_DAT2_NOCRYPTO) && !(val & MIO_FUS_DAT2_NOMUL) &&
		(val & MIO_FUS_DAT2_DORM_CRYPTO);
}

static inline int octeon_has_feature_OCTEON_FEATURE_PCIE(void)
{
	/* OCTEON II and later have PCIe */
	return true;
}

static inline int octeon_has_feature_OCTEON_FEATURE_SRIO(void)
{
	if (OCTEON_IS_MODEL(OCTEON_CNF75XX)) {
		if (cvmx_fuse_read(1601) == 0)
			return 0;
		else
			return 1;
	} else {
		return (OCTEON_IS_MODEL(OCTEON_CN63XX) ||
			OCTEON_IS_MODEL(OCTEON_CN66XX));
	}
}

static inline int octeon_has_feature_OCTEON_FEATURE_ILK(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN68XX) ||
		OCTEON_IS_MODEL(OCTEON_CN78XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_KEY_MEMORY(void)
{
	/* OCTEON II or later */
	return true;
}

static inline int octeon_has_feature_OCTEON_FEATURE_LED_CONTROLLER(void)
{
	return false;
}

static inline int octeon_has_feature_OCTEON_FEATURE_TRA(void)
{
	return !OCTEON_IS_OCTEON3();
}

static inline int octeon_has_feature_OCTEON_FEATURE_MGMT_PORT(void)
{
	/* OCTEON II or later */
	return true;
}

static inline int octeon_has_feature_OCTEON_FEATURE_RAID(void)
{
	return !OCTEON_IS_MODEL(OCTEON_CNF75XX);
}

static inline int octeon_has_feature_OCTEON_FEATURE_USB(void)
{
	return true;
}

static inline int octeon_has_feature_OCTEON_FEATURE_NO_WPTR(void)
{
	return true;
}

static inline int octeon_has_feature_OCTEON_FEATURE_DFA(void)
{
	return 0;
}

static inline int octeon_has_feature_OCTEON_FEATURE_HFA(void)
{
	if (OCTEON_IS_MODEL(OCTEON_CNF75XX))
		return 0;
	else
		return !cvmx_fuse_read(90);
}

static inline int octeon_has_feature_OCTEON_FEATURE_HNA(void)
{
	if (OCTEON_IS_MODEL(OCTEON_CN78XX) || OCTEON_IS_MODEL(OCTEON_CN73XX))
		return !cvmx_fuse_read(134);
	else
		return 0;
}

static inline int octeon_has_feature_OCTEON_FEATURE_DFM(void)
{
	if (!(OCTEON_IS_MODEL(OCTEON_CN63XX) || OCTEON_IS_MODEL(OCTEON_CN66XX)))
		return 0;
	else
		return !cvmx_fuse_read(90);
}

static inline int octeon_has_feature_OCTEON_FEATURE_MDIO_CLAUSE_45(void)
{
	return true;
}

static inline int octeon_has_feature_OCTEON_FEATURE_NPEI(void)
{
	return false;
}

static inline int octeon_has_feature_OCTEON_FEATURE_PKND(void)
{
	return OCTEON_IS_MODEL(OCTEON_CN68XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX) ||
		OCTEON_IS_MODEL(OCTEON_CN78XX);
}

static inline int octeon_has_feature_OCTEON_FEATURE_CN68XX_WQE(void)
{
	return OCTEON_IS_MODEL(OCTEON_CN68XX);
}

static inline int octeon_has_feature_OCTEON_FEATURE_CIU2(void)
{
	return OCTEON_IS_MODEL(OCTEON_CN68XX);
}

static inline int octeon_has_feature_OCTEON_FEATURE_CIU3(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_FPA3(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_NAND(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN63XX) ||
		OCTEON_IS_MODEL(OCTEON_CN66XX) ||
		OCTEON_IS_MODEL(OCTEON_CN68XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN70XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_DICI_MODE(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN68XX_PASS2_X) ||
		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
		OCTEON_IS_MODEL(OCTEON_CN70XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_BIT_EXTRACTOR(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN68XX_PASS2_X) ||
		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
		OCTEON_IS_MODEL(OCTEON_CN70XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_MMC(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN61XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF71XX) || OCTEON_IS_OCTEON3());
}

static inline int octeon_has_feature_OCTEON_FEATURE_ROM(void)
{
	return OCTEON_IS_MODEL(OCTEON_CN66XX) ||
		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF71XX);
}

static inline int octeon_has_feature_OCTEON_FEATURE_AUTHENTIK(void)
{
	if (OCTEON_IS_MODEL(OCTEON_CN66XX) ||
	    OCTEON_IS_MODEL(OCTEON_CN61XX) ||
	    OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
	    OCTEON_IS_MODEL(OCTEON_CN70XX)) {
		u64 val;

		val = csr_rd(CVMX_MIO_FUS_DAT2);
		return (val & MIO_FUS_DAT2_NOCRYPTO) &&
			(val & MIO_FUS_DAT2_DORM_CRYPTO);
	}

	return 0;
}

static inline int octeon_has_feature_OCTEON_FEATURE_MULTICAST_TIMER(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN66XX_PASS1_2) ||
		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
		OCTEON_IS_MODEL(OCTEON_CN70XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_MULTINODE(void)
{
	return (!OCTEON_IS_MODEL(OCTEON_CN76XX) &&
		OCTEON_IS_MODEL(OCTEON_CN78XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_CN78XX_WQE(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_SPI(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN66XX) ||
		OCTEON_IS_MODEL(OCTEON_CN61XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF71XX) || OCTEON_IS_OCTEON3());
}

static inline int octeon_has_feature_OCTEON_FEATURE_PKI(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_PKO3(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_OCLA(void)
{
	return OCTEON_IS_OCTEON3();
}

static inline int octeon_has_feature_OCTEON_FEATURE_FAU(void)
{
	return (!OCTEON_IS_MODEL(OCTEON_CN78XX) &&
		!OCTEON_IS_MODEL(OCTEON_CNF75XX) &&
		!OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_BGX(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_BGX_MIX(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX));
}

static inline int octeon_has_feature_OCTEON_FEATURE_BGX_XCV(void)
{
	return OCTEON_IS_MODEL(OCTEON_CN73XX);
}

static inline int octeon_has_feature_OCTEON_FEATURE_TSO(void)
{
	return (OCTEON_IS_MODEL(OCTEON_CN73XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN78XX_PASS2_X));
}

static inline int octeon_has_feature_OCTEON_FEATURE_TDM(void)
{
	return OCTEON_IS_MODEL(OCTEON_CN61XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
		OCTEON_IS_MODEL(OCTEON_CN70XX);
}

static inline int octeon_has_feature_OCTEON_FEATURE_PTP(void)
{
	return OCTEON_IS_MODEL(OCTEON_CN6XXX) ||
		OCTEON_IS_MODEL(OCTEON_CNF7XXX) ||
		OCTEON_IS_MODEL(OCTEON_CN73XX) ||
		OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
		OCTEON_IS_MODEL(OCTEON_CN78XX_PASS2_X);
}

/*
 * Answer ``Is the bit for feature set in the bitmap?''
 * @param feature
 * @return 1 when the feature is present and 0 otherwise, -1 in case of error.
 */
#define octeon_has_feature(feature_x) octeon_has_feature_##feature_x()

#endif /* __OCTEON_FEATURE_H__ */