1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020 Marvell International Ltd.
6 #ifndef __OCTEON_FEATURE_H__
7 #define __OCTEON_FEATURE_H__
10 * Octeon models are declared after the macros in octeon-model.h with the
11 * suffix _FEATURE. The individual features are declared with the
16 * Checks on the critical path are moved to the top (8 positions)
17 * so that the compiler generates one less insn than for the rest
20 OCTEON_FEATURE_PKND, /* CN68XX uses port kinds for packet interface */
21 /* CN68XX has different fields in word0 - word2 */
22 OCTEON_FEATURE_CN68XX_WQE,
28 * Octeon models in the CN5XXX family and higher support atomic
29 * add instructions to memory (saa/saad)
32 /* Does this Octeon support the ZIP offload engine? */
34 /* Does this Octeon support crypto acceleration using COP2? */
35 OCTEON_FEATURE_CRYPTO,
36 /* Can crypto be enabled by calling cvmx_crypto_dormant_enable()? */
37 OCTEON_FEATURE_DORM_CRYPTO,
38 OCTEON_FEATURE_PCIE, /* Does this Octeon support PCI express? */
39 OCTEON_FEATURE_SRIO, /* Does this Octeon support SRIO */
40 OCTEON_FEATURE_ILK, /* Does this Octeon support Interlaken */
42 * Some Octeon models support internal memory for storing
45 OCTEON_FEATURE_KEY_MEMORY,
46 /* Octeon has a LED controller for banks of external LEDs */
47 OCTEON_FEATURE_LED_CONTROLLER,
48 OCTEON_FEATURE_TRA, /* Octeon has a trace buffer */
49 OCTEON_FEATURE_MGMT_PORT, /* Octeon has a management port */
50 OCTEON_FEATURE_RAID, /* Octeon has a raid unit */
51 OCTEON_FEATURE_USB, /* Octeon has a builtin USB */
52 /* Octeon IPD can run without using work queue entries */
53 OCTEON_FEATURE_NO_WPTR,
54 OCTEON_FEATURE_DFA, /* Octeon has DFA state machines */
56 * Octeon MDIO block supports clause 45 transactions for
59 OCTEON_FEATURE_MDIO_CLAUSE_45,
61 * CN52XX and CN56XX used a block named NPEI for PCIe access.
62 * Newer chips replaced this with SLI+DPI
65 OCTEON_FEATURE_HFA, /* Octeon has DFA/HFA */
66 OCTEON_FEATURE_DFM, /* Octeon has DFM */
67 OCTEON_FEATURE_CIU2, /* Octeon has CIU2 */
68 /* Octeon has DMA Instruction Completion Interrupt mode */
69 OCTEON_FEATURE_DICI_MODE,
70 /* Octeon has Bit Select Extractor schedulor */
71 OCTEON_FEATURE_BIT_EXTRACTOR,
72 OCTEON_FEATURE_NAND, /* Octeon has NAND */
73 OCTEON_FEATURE_MMC, /* Octeon has built-in MMC support */
74 OCTEON_FEATURE_ROM, /* Octeon has built-in ROM support */
75 OCTEON_FEATURE_AUTHENTIK, /* Octeon has Authentik ROM support */
76 OCTEON_FEATURE_MULTICAST_TIMER, /* Octeon has multi_cast timer */
77 OCTEON_FEATURE_MULTINODE, /* Octeon has node support */
78 OCTEON_FEATURE_CIU3, /* Octeon has CIU3 */
79 OCTEON_FEATURE_FPA3, /* Octeon has FPA first seen on 78XX */
80 /* CN78XX has different fields in word0 - word2 */
81 OCTEON_FEATURE_CN78XX_WQE,
82 OCTEON_FEATURE_PKO3, /* Octeon has enhanced PKO block */
83 OCTEON_FEATURE_SPI, /* Octeon supports SPI interfaces */
84 OCTEON_FEATURE_ZIP3, /* Octeon has zip first seen on 78XX */
85 OCTEON_FEATURE_BCH, /* Octeon supports BCH ECC */
86 OCTEON_FEATURE_PKI, /* Octeon has PKI block */
87 OCTEON_FEATURE_OCLA, /* Octeon has OCLA */
88 OCTEON_FEATURE_FAU, /* Octeon has FAU */
89 OCTEON_FEATURE_BGX, /* Octeon has BGX */
90 OCTEON_FEATURE_BGX_MIX, /* On of the BGX is used for MIX */
91 OCTEON_FEATURE_HNA, /* Octeon has HNA */
92 OCTEON_FEATURE_BGX_XCV, /* Octeon has BGX XCV RGMII support */
93 OCTEON_FEATURE_TSO, /* Octeon has tcp segmentation offload */
94 OCTEON_FEATURE_TDM, /* Octeon has PCM/TDM support */
95 OCTEON_FEATURE_PTP, /* Octeon has PTP support */
99 static inline int octeon_has_feature_OCTEON_FEATURE_SAAD(void)
104 static inline int octeon_has_feature_OCTEON_FEATURE_ZIP(void)
106 if (OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
107 OCTEON_IS_MODEL(OCTEON_CN70XX) || OCTEON_IS_MODEL(OCTEON_CNF75XX))
110 return !cvmx_fuse_read(121);
113 static inline int octeon_has_feature_OCTEON_FEATURE_ZIP3(void)
115 return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
116 OCTEON_IS_MODEL(OCTEON_CN73XX));
119 static inline int octeon_has_feature_OCTEON_FEATURE_BCH(void)
121 return (OCTEON_IS_MODEL(OCTEON_CN70XX) ||
122 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
123 OCTEON_IS_MODEL(OCTEON_CN73XX));
126 static inline int octeon_has_feature_OCTEON_FEATURE_CRYPTO(void)
128 /* OCTEON II and later */
131 val = csr_rd(CVMX_MIO_FUS_DAT2);
132 if (val & MIO_FUS_DAT2_NOCRYPTO || val & MIO_FUS_DAT2_NOMUL)
134 else if (!(val & MIO_FUS_DAT2_DORM_CRYPTO))
137 val = csr_rd(CVMX_RNM_CTL_STATUS);
138 return val & RNM_CTL_STATUS_EER_VAL;
141 static inline int octeon_has_feature_OCTEON_FEATURE_DORM_CRYPTO(void)
143 /* OCTEON II and later */
146 val = csr_rd(CVMX_MIO_FUS_DAT2);
147 return !(val & MIO_FUS_DAT2_NOCRYPTO) && !(val & MIO_FUS_DAT2_NOMUL) &&
148 (val & MIO_FUS_DAT2_DORM_CRYPTO);
151 static inline int octeon_has_feature_OCTEON_FEATURE_PCIE(void)
153 /* OCTEON II and later have PCIe */
157 static inline int octeon_has_feature_OCTEON_FEATURE_SRIO(void)
159 if (OCTEON_IS_MODEL(OCTEON_CNF75XX)) {
160 if (cvmx_fuse_read(1601) == 0)
165 return (OCTEON_IS_MODEL(OCTEON_CN63XX) ||
166 OCTEON_IS_MODEL(OCTEON_CN66XX));
170 static inline int octeon_has_feature_OCTEON_FEATURE_ILK(void)
172 return (OCTEON_IS_MODEL(OCTEON_CN68XX) ||
173 OCTEON_IS_MODEL(OCTEON_CN78XX));
176 static inline int octeon_has_feature_OCTEON_FEATURE_KEY_MEMORY(void)
178 /* OCTEON II or later */
182 static inline int octeon_has_feature_OCTEON_FEATURE_LED_CONTROLLER(void)
187 static inline int octeon_has_feature_OCTEON_FEATURE_TRA(void)
189 return !OCTEON_IS_OCTEON3();
192 static inline int octeon_has_feature_OCTEON_FEATURE_MGMT_PORT(void)
194 /* OCTEON II or later */
198 static inline int octeon_has_feature_OCTEON_FEATURE_RAID(void)
200 return !OCTEON_IS_MODEL(OCTEON_CNF75XX);
203 static inline int octeon_has_feature_OCTEON_FEATURE_USB(void)
208 static inline int octeon_has_feature_OCTEON_FEATURE_NO_WPTR(void)
213 static inline int octeon_has_feature_OCTEON_FEATURE_DFA(void)
218 static inline int octeon_has_feature_OCTEON_FEATURE_HFA(void)
220 if (OCTEON_IS_MODEL(OCTEON_CNF75XX))
223 return !cvmx_fuse_read(90);
226 static inline int octeon_has_feature_OCTEON_FEATURE_HNA(void)
228 if (OCTEON_IS_MODEL(OCTEON_CN78XX) || OCTEON_IS_MODEL(OCTEON_CN73XX))
229 return !cvmx_fuse_read(134);
234 static inline int octeon_has_feature_OCTEON_FEATURE_DFM(void)
236 if (!(OCTEON_IS_MODEL(OCTEON_CN63XX) || OCTEON_IS_MODEL(OCTEON_CN66XX)))
239 return !cvmx_fuse_read(90);
242 static inline int octeon_has_feature_OCTEON_FEATURE_MDIO_CLAUSE_45(void)
247 static inline int octeon_has_feature_OCTEON_FEATURE_NPEI(void)
252 static inline int octeon_has_feature_OCTEON_FEATURE_PKND(void)
254 return OCTEON_IS_MODEL(OCTEON_CN68XX) ||
255 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
256 OCTEON_IS_MODEL(OCTEON_CN73XX) ||
257 OCTEON_IS_MODEL(OCTEON_CN78XX);
260 static inline int octeon_has_feature_OCTEON_FEATURE_CN68XX_WQE(void)
262 return OCTEON_IS_MODEL(OCTEON_CN68XX);
265 static inline int octeon_has_feature_OCTEON_FEATURE_CIU2(void)
267 return OCTEON_IS_MODEL(OCTEON_CN68XX);
270 static inline int octeon_has_feature_OCTEON_FEATURE_CIU3(void)
272 return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
273 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
274 OCTEON_IS_MODEL(OCTEON_CN73XX));
277 static inline int octeon_has_feature_OCTEON_FEATURE_FPA3(void)
279 return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
280 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
281 OCTEON_IS_MODEL(OCTEON_CN73XX));
284 static inline int octeon_has_feature_OCTEON_FEATURE_NAND(void)
286 return (OCTEON_IS_MODEL(OCTEON_CN63XX) ||
287 OCTEON_IS_MODEL(OCTEON_CN66XX) ||
288 OCTEON_IS_MODEL(OCTEON_CN68XX) ||
289 OCTEON_IS_MODEL(OCTEON_CN73XX) ||
290 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
291 OCTEON_IS_MODEL(OCTEON_CN70XX));
294 static inline int octeon_has_feature_OCTEON_FEATURE_DICI_MODE(void)
296 return (OCTEON_IS_MODEL(OCTEON_CN68XX_PASS2_X) ||
297 OCTEON_IS_MODEL(OCTEON_CN61XX) ||
298 OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
299 OCTEON_IS_MODEL(OCTEON_CN70XX));
302 static inline int octeon_has_feature_OCTEON_FEATURE_BIT_EXTRACTOR(void)
304 return (OCTEON_IS_MODEL(OCTEON_CN68XX_PASS2_X) ||
305 OCTEON_IS_MODEL(OCTEON_CN61XX) ||
306 OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
307 OCTEON_IS_MODEL(OCTEON_CN70XX));
310 static inline int octeon_has_feature_OCTEON_FEATURE_MMC(void)
312 return (OCTEON_IS_MODEL(OCTEON_CN61XX) ||
313 OCTEON_IS_MODEL(OCTEON_CNF71XX) || OCTEON_IS_OCTEON3());
316 static inline int octeon_has_feature_OCTEON_FEATURE_ROM(void)
318 return OCTEON_IS_MODEL(OCTEON_CN66XX) ||
319 OCTEON_IS_MODEL(OCTEON_CN61XX) ||
320 OCTEON_IS_MODEL(OCTEON_CNF71XX);
323 static inline int octeon_has_feature_OCTEON_FEATURE_AUTHENTIK(void)
325 if (OCTEON_IS_MODEL(OCTEON_CN66XX) ||
326 OCTEON_IS_MODEL(OCTEON_CN61XX) ||
327 OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
328 OCTEON_IS_MODEL(OCTEON_CN70XX)) {
331 val = csr_rd(CVMX_MIO_FUS_DAT2);
332 return (val & MIO_FUS_DAT2_NOCRYPTO) &&
333 (val & MIO_FUS_DAT2_DORM_CRYPTO);
339 static inline int octeon_has_feature_OCTEON_FEATURE_MULTICAST_TIMER(void)
341 return (OCTEON_IS_MODEL(OCTEON_CN66XX_PASS1_2) ||
342 OCTEON_IS_MODEL(OCTEON_CN61XX) ||
343 OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
344 OCTEON_IS_MODEL(OCTEON_CN70XX));
347 static inline int octeon_has_feature_OCTEON_FEATURE_MULTINODE(void)
349 return (!OCTEON_IS_MODEL(OCTEON_CN76XX) &&
350 OCTEON_IS_MODEL(OCTEON_CN78XX));
353 static inline int octeon_has_feature_OCTEON_FEATURE_CN78XX_WQE(void)
355 return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
356 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
357 OCTEON_IS_MODEL(OCTEON_CN73XX));
360 static inline int octeon_has_feature_OCTEON_FEATURE_SPI(void)
362 return (OCTEON_IS_MODEL(OCTEON_CN66XX) ||
363 OCTEON_IS_MODEL(OCTEON_CN61XX) ||
364 OCTEON_IS_MODEL(OCTEON_CNF71XX) || OCTEON_IS_OCTEON3());
367 static inline int octeon_has_feature_OCTEON_FEATURE_PKI(void)
369 return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
370 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
371 OCTEON_IS_MODEL(OCTEON_CN73XX));
374 static inline int octeon_has_feature_OCTEON_FEATURE_PKO3(void)
376 return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
377 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
378 OCTEON_IS_MODEL(OCTEON_CN73XX));
381 static inline int octeon_has_feature_OCTEON_FEATURE_OCLA(void)
383 return OCTEON_IS_OCTEON3();
386 static inline int octeon_has_feature_OCTEON_FEATURE_FAU(void)
388 return (!OCTEON_IS_MODEL(OCTEON_CN78XX) &&
389 !OCTEON_IS_MODEL(OCTEON_CNF75XX) &&
390 !OCTEON_IS_MODEL(OCTEON_CN73XX));
393 static inline int octeon_has_feature_OCTEON_FEATURE_BGX(void)
395 return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
396 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
397 OCTEON_IS_MODEL(OCTEON_CN73XX));
400 static inline int octeon_has_feature_OCTEON_FEATURE_BGX_MIX(void)
402 return (OCTEON_IS_MODEL(OCTEON_CN78XX) ||
403 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
404 OCTEON_IS_MODEL(OCTEON_CN73XX));
407 static inline int octeon_has_feature_OCTEON_FEATURE_BGX_XCV(void)
409 return OCTEON_IS_MODEL(OCTEON_CN73XX);
412 static inline int octeon_has_feature_OCTEON_FEATURE_TSO(void)
414 return (OCTEON_IS_MODEL(OCTEON_CN73XX) ||
415 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
416 OCTEON_IS_MODEL(OCTEON_CN78XX_PASS2_X));
419 static inline int octeon_has_feature_OCTEON_FEATURE_TDM(void)
421 return OCTEON_IS_MODEL(OCTEON_CN61XX) ||
422 OCTEON_IS_MODEL(OCTEON_CNF71XX) ||
423 OCTEON_IS_MODEL(OCTEON_CN70XX);
426 static inline int octeon_has_feature_OCTEON_FEATURE_PTP(void)
428 return OCTEON_IS_MODEL(OCTEON_CN6XXX) ||
429 OCTEON_IS_MODEL(OCTEON_CNF7XXX) ||
430 OCTEON_IS_MODEL(OCTEON_CN73XX) ||
431 OCTEON_IS_MODEL(OCTEON_CNF75XX) ||
432 OCTEON_IS_MODEL(OCTEON_CN78XX_PASS2_X);
436 * Answer ``Is the bit for feature set in the bitmap?''
438 * @return 1 when the feature is present and 0 otherwise, -1 in case of error.
440 #define octeon_has_feature(feature_x) octeon_has_feature_##feature_x()
442 #endif /* __OCTEON_FEATURE_H__ */