1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* (C) COPYRIGHT 2014-2018 ARM Limited. All rights reserved. */
3 /* Copyright 2019 Linaro, Ltd., Rob Herring <robh@kernel.org> */
4 #ifndef __PANFROST_FEATURES_H__
5 #define __PANFROST_FEATURES_H__
6 
7 #include <linux/bitops.h>
8 
9 #include "panfrost_device.h"
10 
11 enum panfrost_hw_feature {
12 	HW_FEATURE_JOBCHAIN_DISAMBIGUATION,
13 	HW_FEATURE_PWRON_DURING_PWROFF_TRANS,
14 	HW_FEATURE_XAFFINITY,
15 	HW_FEATURE_V4,
16 	HW_FEATURE_FLUSH_REDUCTION,
17 	HW_FEATURE_PROTECTED_MODE,
18 	HW_FEATURE_COHERENCY_REG,
19 	HW_FEATURE_PROTECTED_DEBUG_MODE,
20 	HW_FEATURE_AARCH64_MMU,
21 	HW_FEATURE_TLS_HASHING,
22 	HW_FEATURE_THREAD_GROUP_SPLIT,
23 	HW_FEATURE_IDVS_GROUP_SIZE,
24 	HW_FEATURE_3BIT_EXT_RW_L2_MMU_CONFIG,
25 };
26 
27 #define hw_features_t600 (\
28 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
29 	BIT_ULL(HW_FEATURE_V4))
30 
31 #define hw_features_t620 hw_features_t600
32 
33 #define hw_features_t720 hw_features_t600
34 
35 #define hw_features_t760 (\
36 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
37 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
38 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
39 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT))
40 
41 #define hw_features_t860 hw_features_t760
42 
43 #define hw_features_t880 hw_features_t760
44 
45 #define hw_features_t830 hw_features_t760
46 
47 #define hw_features_t820 hw_features_t760
48 
49 #define hw_features_g71 (\
50 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
51 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
52 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
53 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
54 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
55 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
56 	BIT_ULL(HW_FEATURE_COHERENCY_REG))
57 
58 #define hw_features_g72 (\
59 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
60 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
61 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
62 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
63 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
64 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
65 	BIT_ULL(HW_FEATURE_PROTECTED_DEBUG_MODE) | \
66 	BIT_ULL(HW_FEATURE_COHERENCY_REG))
67 
68 #define hw_features_g51 hw_features_g72
69 
70 #define hw_features_g52 (\
71 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
72 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
73 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
74 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
75 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
76 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
77 	BIT_ULL(HW_FEATURE_PROTECTED_DEBUG_MODE) | \
78 	BIT_ULL(HW_FEATURE_IDVS_GROUP_SIZE) | \
79 	BIT_ULL(HW_FEATURE_COHERENCY_REG))
80 
81 #define hw_features_g76 (\
82 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
83 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
84 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
85 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
86 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
87 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
88 	BIT_ULL(HW_FEATURE_PROTECTED_DEBUG_MODE) | \
89 	BIT_ULL(HW_FEATURE_COHERENCY_REG) | \
90 	BIT_ULL(HW_FEATURE_AARCH64_MMU) | \
91 	BIT_ULL(HW_FEATURE_TLS_HASHING) | \
92 	BIT_ULL(HW_FEATURE_IDVS_GROUP_SIZE) | \
93 	BIT_ULL(HW_FEATURE_3BIT_EXT_RW_L2_MMU_CONFIG))
94 
95 #define hw_features_g31 (\
96 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
97 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
98 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
99 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
100 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
101 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
102 	BIT_ULL(HW_FEATURE_PROTECTED_DEBUG_MODE) | \
103 	BIT_ULL(HW_FEATURE_COHERENCY_REG) | \
104 	BIT_ULL(HW_FEATURE_AARCH64_MMU) | \
105 	BIT_ULL(HW_FEATURE_TLS_HASHING) | \
106 	BIT_ULL(HW_FEATURE_3BIT_EXT_RW_L2_MMU_CONFIG))
107 
108 static inline bool panfrost_has_hw_feature(struct panfrost_device *pfdev,
109 					   enum panfrost_hw_feature feat)
110 {
111 	return test_bit(feat, pfdev->features.hw_features);
112 }
113 
114 #endif
115