drm/GPU: Add support Imagination PowerVR GPU driver v1.17
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / img / img-rogue / services / shared / devices / rogue / rgx_hwperf_table.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          HWPerf counter table header
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Utility functions used internally for HWPerf data retrieval
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43
44 #ifndef RGX_HWPERF_TABLE_H
45 #define RGX_HWPERF_TABLE_H
46
47 #include "img_types.h"
48 #include "img_defs.h"
49 #include "rgx_fwif_hwperf.h"
50 #if defined(__KERNEL__)
51 #include "rgxdevice.h"
52 #endif
53 /*****************************************************************************/
54
55 /* Forward declaration */
56 typedef struct RGXFW_HWPERF_CNTBLK_TYPE_MODEL_ RGXFW_HWPERF_CNTBLK_TYPE_MODEL;
57
58 /* Function pointer type for functions to check dynamic power state of
59  * counter block instance. Used only in firmware. */
60 typedef bool (*PFN_RGXFW_HWPERF_CNTBLK_POWERED)(
61                 RGX_HWPERF_CNTBLK_ID eBlkType,
62                 IMG_UINT8 ui8UnitId);
63
64 #if defined(__KERNEL__)
65 /* Counter block run-time info */
66 typedef struct
67 {
68         IMG_UINT32 ui32IndirectReg;          /* 0 if direct type otherwise the indirect control register to select indirect unit */
69         IMG_UINT32 ui32NumUnits;             /* Number of instances of this block type in the core */
70 } RGX_HWPERF_CNTBLK_RT_INFO;
71 #endif
72
73 /* Function pointer type for functions to check block is valid and present
74  * on that RGX Device at runtime. It may have compile logic or run-time
75  * logic depending on where the code executes: server, srvinit or firmware.
76  * Values in the psRtInfo output parameter are only valid if true returned.
77  */
78 typedef IMG_BOOL (*PFN_RGXFW_HWPERF_CNTBLK_PRESENT)(
79                 const struct RGXFW_HWPERF_CNTBLK_TYPE_MODEL_* psBlkTypeDesc,
80                 const void *pvDev_km,
81                 void *pvRtInfo);
82
83 /* This structure encodes properties of a type of performance counter block.
84  * The structure is sometimes referred to as a block type descriptor. These
85  * properties contained in this structure represent the columns in the block
86  * type model table variable below. These values vary depending on the build
87  * BVNC and core type.
88  * Each direct block has a unique type descriptor and each indirect group has
89  * a type descriptor.
90  */
91 struct RGXFW_HWPERF_CNTBLK_TYPE_MODEL_
92 {
93         /* Could use RGXFW_ALIGN_DCACHEL here but then we would waste 40% of the cache line? */
94         IMG_UINT32 ui32CntBlkIdBase;         /* The starting block id for this block type */
95         IMG_UINT32 ui32IndirectReg;          /* 0 if direct type otherwise the indirect control register to select indirect unit */
96         IMG_UINT32 ui32PerfReg;              /* RGX_CR_*_PERF register for this block type */
97         IMG_UINT32 ui32Select0BaseReg;       /* RGX_CR_*_PERF_SELECT0 register for this block type */
98         IMG_UINT32 ui32Counter0BaseReg;      /* RGX_CR_*_PERF_COUNTER_0 register for this block type */
99         IMG_UINT8  ui8NumCounters;          /* Number of counters in this block type */
100         IMG_UINT8  ui8NumUnits;             /* Number of instances of this block type in the core */
101         IMG_UINT8  ui8SelectRegModeShift;   /* Mode field shift value of select registers */
102         IMG_UINT8  ui8SelectRegOffsetShift; /* Interval between select registers, either 8 bytes or 16, hence << 3 or << 4 */
103         const IMG_CHAR *pszBlockNameComment;             /* Name of the PERF register. Used while dumping the perf counters to pdumps */
104         PFN_RGXFW_HWPERF_CNTBLK_POWERED pfnIsBlkPowered; /* A function to determine dynamic power state for the block type */
105         PFN_RGXFW_HWPERF_CNTBLK_PRESENT pfnIsBlkPresent; /* A function to determine presence on RGX Device at run-time */
106 };
107
108 /*****************************************************************************/
109
110 IMG_INTERNAL IMG_UINT32 RGXGetHWPerfBlockConfig(const RGXFW_HWPERF_CNTBLK_TYPE_MODEL **ppsModel);
111
112 #endif /* RGX_HWPERF_TABLE_H */
113
114 /******************************************************************************
115  End of file (rgx_hwperf_table.h)
116 ******************************************************************************/