MALI: midgard: RK: add separate src dir of Midgard driver for RK Linux device
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard_for_linux / mali_kbase_gpu_id.h
1 /*
2  *
3  * (C) COPYRIGHT 2015 ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15
16
17 #ifndef _KBASE_GPU_ID_H_
18 #define _KBASE_GPU_ID_H_
19
20 /* GPU_ID register */
21 #define GPU_ID_VERSION_STATUS_SHIFT       0
22 #define GPU_ID_VERSION_MINOR_SHIFT        4
23 #define GPU_ID_VERSION_MAJOR_SHIFT        12
24 #define GPU_ID_VERSION_PRODUCT_ID_SHIFT   16
25 #define GPU_ID_VERSION_STATUS             (0xF  << GPU_ID_VERSION_STATUS_SHIFT)
26 #define GPU_ID_VERSION_MINOR              (0xFF << GPU_ID_VERSION_MINOR_SHIFT)
27 #define GPU_ID_VERSION_MAJOR              (0xF  << GPU_ID_VERSION_MAJOR_SHIFT)
28 #define GPU_ID_VERSION_PRODUCT_ID  (0xFFFF << GPU_ID_VERSION_PRODUCT_ID_SHIFT)
29
30 /* Values for GPU_ID_VERSION_PRODUCT_ID bitfield */
31 #define GPU_ID_PI_T60X                    0x6956
32 #define GPU_ID_PI_T62X                    0x0620
33 #define GPU_ID_PI_T76X                    0x0750
34 #define GPU_ID_PI_T72X                    0x0720
35 #define GPU_ID_PI_TFRX                    0x0880
36 #define GPU_ID_PI_T86X                    0x0860
37 #define GPU_ID_PI_T82X                    0x0820
38 #define GPU_ID_PI_T83X                    0x0830
39
40 /* New GPU ID format when PRODUCT_ID is >= 0x1000 (and not 0x6956) */
41 #define GPU_ID_PI_NEW_FORMAT_START        0x1000
42 #define GPU_ID_IS_NEW_FORMAT(product_id)  ((product_id) != GPU_ID_PI_T60X && \
43                                                 (product_id) >= \
44                                                 GPU_ID_PI_NEW_FORMAT_START)
45
46 #define GPU_ID2_VERSION_STATUS_SHIFT      0
47 #define GPU_ID2_VERSION_MINOR_SHIFT       4
48 #define GPU_ID2_VERSION_MAJOR_SHIFT       12
49 #define GPU_ID2_PRODUCT_MAJOR_SHIFT       16
50 #define GPU_ID2_ARCH_REV_SHIFT            20
51 #define GPU_ID2_ARCH_MINOR_SHIFT          24
52 #define GPU_ID2_ARCH_MAJOR_SHIFT          28
53 #define GPU_ID2_VERSION_STATUS            (0xF << GPU_ID2_VERSION_STATUS_SHIFT)
54 #define GPU_ID2_VERSION_MINOR             (0xFF << GPU_ID2_VERSION_MINOR_SHIFT)
55 #define GPU_ID2_VERSION_MAJOR             (0xF << GPU_ID2_VERSION_MAJOR_SHIFT)
56 #define GPU_ID2_PRODUCT_MAJOR             (0xF << GPU_ID2_PRODUCT_MAJOR_SHIFT)
57 #define GPU_ID2_ARCH_REV                  (0xF << GPU_ID2_ARCH_REV_SHIFT)
58 #define GPU_ID2_ARCH_MINOR                (0xF << GPU_ID2_ARCH_MINOR_SHIFT)
59 #define GPU_ID2_ARCH_MAJOR                (0xF << GPU_ID2_ARCH_MAJOR_SHIFT)
60 #define GPU_ID2_PRODUCT_MODEL  (GPU_ID2_ARCH_MAJOR | GPU_ID2_PRODUCT_MAJOR)
61
62 /* Helper macro to create a partial GPU_ID (new format) that defines
63    a product ignoring its version. */
64 #define GPU_ID2_PRODUCT_MAKE(arch_major, arch_minor, arch_rev, product_major) \
65                 (((arch_major) << GPU_ID2_ARCH_MAJOR_SHIFT)  | \
66                  ((arch_minor) << GPU_ID2_ARCH_MINOR_SHIFT)  | \
67                  ((arch_rev) << GPU_ID2_ARCH_REV_SHIFT)      | \
68                  ((product_major) << GPU_ID2_PRODUCT_MAJOR_SHIFT))
69
70 /* Helper macro to create a partial GPU_ID (new format) that specifies the
71    revision (major, minor, status) of a product */
72 #define GPU_ID2_VERSION_MAKE(version_major, version_minor, version_status) \
73                 (((version_major) << GPU_ID2_VERSION_MAJOR_SHIFT)  | \
74                  ((version_minor) << GPU_ID2_VERSION_MINOR_SHIFT)  | \
75                  ((version_status) << GPU_ID2_VERSION_STATUS_SHIFT))
76
77 /* Helper macro to create a complete GPU_ID (new format) */
78 #define GPU_ID2_MAKE(arch_major, arch_minor, arch_rev, product_major, \
79         version_major, version_minor, version_status) \
80                 (GPU_ID2_PRODUCT_MAKE(arch_major, arch_minor, arch_rev) | \
81                  GPU_ID2_VERSION_MAKE(version_major, version_minor,       \
82                         version_status))
83
84 /* Helper macro to create a partial GPU_ID (new format) that identifies
85    a particular GPU model by its arch_major and product_major. */
86 #define GPU_ID2_MODEL_MAKE(arch_major, product_major) \
87                 (((arch_major) << GPU_ID2_ARCH_MAJOR_SHIFT)  | \
88                 ((product_major) << GPU_ID2_PRODUCT_MAJOR_SHIFT))
89
90 /* Strip off the non-relevant bits from a product_id value and make it suitable
91    for comparison against the GPU_ID2_PRODUCT_xxx values which identify a GPU
92    model. */
93 #define GPU_ID2_MODEL_MATCH_VALUE(product_id) \
94                 (((product_id) << GPU_ID2_PRODUCT_MAJOR_SHIFT) & \
95                     GPU_ID2_PRODUCT_MODEL)
96
97
98 /* Values for GPU_ID_VERSION_STATUS field for PRODUCT_ID GPU_ID_PI_T60X */
99 #define GPU_ID_S_15DEV0                   0x1
100 #define GPU_ID_S_EAC                      0x2
101
102 /* Helper macro to create a GPU_ID assuming valid values for id, major,
103    minor, status */
104 #define GPU_ID_MAKE(id, major, minor, status) \
105                 (((id) << GPU_ID_VERSION_PRODUCT_ID_SHIFT) | \
106                 ((major) << GPU_ID_VERSION_MAJOR_SHIFT) |   \
107                 ((minor) << GPU_ID_VERSION_MINOR_SHIFT) |   \
108                 ((status) << GPU_ID_VERSION_STATUS_SHIFT))
109
110 #endif /* _KBASE_GPU_ID_H_ */