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_CLEAN_ONLY_SAFE,
25 	HW_FEATURE_3BIT_EXT_RW_L2_MMU_CONFIG,
26 };
27 
28 #define hw_features_t600 (\
29 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
30 	BIT_ULL(HW_FEATURE_V4))
31 
32 #define hw_features_t620 hw_features_t600
33 
34 #define hw_features_t720 hw_features_t600
35 
36 #define hw_features_t760 (\
37 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
38 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
39 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
40 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT))
41 
42 #define hw_features_t860 hw_features_t760
43 
44 #define hw_features_t880 hw_features_t760
45 
46 #define hw_features_t830 hw_features_t760
47 
48 #define hw_features_t820 hw_features_t760
49 
50 #define hw_features_g71 (\
51 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
52 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
53 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
54 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
55 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
56 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
57 	BIT_ULL(HW_FEATURE_COHERENCY_REG))
58 
59 #define hw_features_g72 (\
60 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
61 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
62 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
63 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
64 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
65 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
66 	BIT_ULL(HW_FEATURE_PROTECTED_DEBUG_MODE) | \
67 	BIT_ULL(HW_FEATURE_COHERENCY_REG))
68 
69 #define hw_features_g51 hw_features_g72
70 
71 #define hw_features_g52 (\
72 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
73 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
74 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
75 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
76 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
77 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
78 	BIT_ULL(HW_FEATURE_PROTECTED_DEBUG_MODE) | \
79 	BIT_ULL(HW_FEATURE_IDVS_GROUP_SIZE) | \
80 	BIT_ULL(HW_FEATURE_COHERENCY_REG))
81 
82 #define hw_features_g76 (\
83 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
84 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
85 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
86 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
87 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
88 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
89 	BIT_ULL(HW_FEATURE_PROTECTED_DEBUG_MODE) | \
90 	BIT_ULL(HW_FEATURE_COHERENCY_REG) | \
91 	BIT_ULL(HW_FEATURE_AARCH64_MMU) | \
92 	BIT_ULL(HW_FEATURE_TLS_HASHING) | \
93 	BIT_ULL(HW_FEATURE_IDVS_GROUP_SIZE) | \
94 	BIT_ULL(HW_FEATURE_3BIT_EXT_RW_L2_MMU_CONFIG))
95 
96 #define hw_features_g31 (\
97 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
98 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
99 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
100 	BIT_ULL(HW_FEATURE_THREAD_GROUP_SPLIT) | \
101 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
102 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
103 	BIT_ULL(HW_FEATURE_PROTECTED_DEBUG_MODE) | \
104 	BIT_ULL(HW_FEATURE_COHERENCY_REG) | \
105 	BIT_ULL(HW_FEATURE_AARCH64_MMU) | \
106 	BIT_ULL(HW_FEATURE_TLS_HASHING) | \
107 	BIT_ULL(HW_FEATURE_3BIT_EXT_RW_L2_MMU_CONFIG))
108 
109 #define hw_features_g57 (\
110 	BIT_ULL(HW_FEATURE_JOBCHAIN_DISAMBIGUATION) | \
111 	BIT_ULL(HW_FEATURE_PWRON_DURING_PWROFF_TRANS) | \
112 	BIT_ULL(HW_FEATURE_XAFFINITY) | \
113 	BIT_ULL(HW_FEATURE_FLUSH_REDUCTION) | \
114 	BIT_ULL(HW_FEATURE_PROTECTED_MODE) | \
115 	BIT_ULL(HW_FEATURE_PROTECTED_DEBUG_MODE) | \
116 	BIT_ULL(HW_FEATURE_COHERENCY_REG) | \
117 	BIT_ULL(HW_FEATURE_AARCH64_MMU) | \
118 	BIT_ULL(HW_FEATURE_IDVS_GROUP_SIZE) | \
119 	BIT_ULL(HW_FEATURE_CLEAN_ONLY_SAFE))
120 
121 static inline bool panfrost_has_hw_feature(struct panfrost_device *pfdev,
122 					   enum panfrost_hw_feature feat)
123 {
124 	return test_bit(feat, pfdev->features.hw_features);
125 }
126 
127 #endif
128