RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / services / server / include / pvr_dvfs.h
1 /*************************************************************************/ /*!
2 @File           pvr_dvfs.h
3 @Title          System level interface for DVFS
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    This file defined the API between services and system layer
6                 required for Ion integration.
7 @License        Dual MIT/GPLv2
8
9 The contents of this file are subject to the MIT license as set out below.
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
24
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
32
33 This License is also included in this distribution in the file called
34 "MIT-COPYING".
35
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 */ /**************************************************************************/
44
45 #ifndef _PVR_DVFS_H_
46 #define _PVR_DVFS_H_
47
48 #include "pvrsrv_error.h"
49 #include "img_types.h"
50
51 typedef IMG_VOID (*PFN_SYS_DEV_DVFS_SET_FREQUENCY)(IMG_UINT32 ui64Freq);
52 typedef IMG_VOID (*PFN_SYS_DEV_DVFS_SET_VOLTAGE)(IMG_UINT32 ui64Volt);
53
54 typedef struct _IMG_OPP_
55 {
56         IMG_UINT32                      ui32Volt;
57         IMG_UINT32                      ui32Freq;
58 } IMG_OPP;
59
60 typedef const IMG_OPP* IMG_OPP_TABLE;
61
62 typedef struct _IMG_DVFS_GOVERNOR_CFG_
63 {
64         IMG_UINT32                      ui32UpThreshold;
65         IMG_UINT32                      ui32DownDifferential;
66 } IMG_DVFS_GOVERNOR_CFG;
67
68 typedef struct _IMG_DVFS_DEVICE_CFG_
69 {
70         IMG_OPP_TABLE                   pasOPPTable;
71         IMG_UINT32                      ui32OPPTableSize;
72
73         IMG_UINT32                      ui32FreqMin;
74         IMG_UINT32                      ui32FreqMax;
75         IMG_UINT32                      ui32PollMs;
76         IMG_BOOL                        bIdleReq;
77
78         PFN_SYS_DEV_DVFS_SET_FREQUENCY  pfnSetFrequency;
79         PFN_SYS_DEV_DVFS_SET_VOLTAGE    pfnSetVoltage;
80 } IMG_DVFS_DEVICE_CFG;
81
82 typedef struct _IMG_DVFS_GOVERNOR_
83 {
84         IMG_BOOL                        bEnabled;
85 } IMG_DVFS_GOVERNOR;
86
87 #if defined(__linux__)
88 typedef struct _IMG_DVFS_DEVICE_
89 {
90         POS_LOCK                        hDVFSLock;
91         struct dev_pm_opp               *psOPP;
92         struct devfreq                  *psDevFreq;
93         IMG_BOOL                        bEnabled;
94         IMG_HANDLE                      hGpuUtilUserDVFS;
95 } IMG_DVFS_DEVICE;
96
97 typedef struct _IMG_POWER_AVG_
98 {
99         IMG_UINT32                      ui32Power;
100         IMG_UINT32                      ui32Samples;
101 } IMG_POWER_AVG;
102
103 typedef struct _IMG_DVFS_PA_
104 {
105         IMG_UINT32                      ui32AllocatedPower;
106         IMG_UINT32                      *aui32ConversionTable;
107         IMG_OPP                         sOPPCurrent;
108         IMG_INT32                       i32Temp;
109         IMG_UINT64                      ui64StartTime;
110         IMG_UINT32                      ui32Energy;
111         POS_LOCK                        hDVFSLock;
112         struct power_actor              *psPowerActor;
113         IMG_POWER_AVG                   sPowerAvg;
114 } IMG_DVFS_PA;
115
116 typedef struct _IMG_DVFS_PA_CFG_
117 {
118         /* Coefficients for a curve defining power leakage due to temperature */
119         IMG_INT32                       i32Ta;          /* t^3 */
120         IMG_INT32                       i32Tb;          /* t^2 */
121         IMG_INT32                       i32Tc;          /* t^1 */
122         IMG_INT32                       i32Td;          /* const */
123
124         IMG_UINT32                      ui32Other;      /* Static losses unrelated to GPU */
125         IMG_UINT32                      ui32Weight;     /* Power actor weight */
126 } IMG_DVFS_PA_CFG;
127
128 typedef struct _IMG_DVFS_
129 {
130         IMG_DVFS_DEVICE                 sDVFSDevice;
131         IMG_DVFS_GOVERNOR               sDVFSGovernor;
132         IMG_DVFS_DEVICE_CFG             sDVFSDeviceCfg;
133         IMG_DVFS_GOVERNOR_CFG           sDVFSGovernorCfg;
134 #if defined(PVR_POWER_ACTOR)
135         IMG_DVFS_PA                     sDVFSPA;
136         IMG_DVFS_PA_CFG                 sDVFSPACfg;
137 #endif
138 } PVRSRV_DVFS;
139 #endif/* (__linux__) */
140
141 #endif /* _PVR_DVFS_H_ */