RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / services / server / devices / rgx / rgxregconfig.c
1 /*************************************************************************/ /*!
2 @File
3 @Title          RGX Register configuration
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    RGX Regconfig routines
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 #include "rgxregconfig.h"
45 #include "pvr_debug.h"
46 #include "rgxutils.h"
47 #include "rgxfwutils.h"
48 #include "device.h"
49 #include "sync_internal.h"
50 #include "pdump_km.h"
51 #include "pvrsrv.h"
52 PVRSRV_ERROR PVRSRVRGXSetRegConfigPIKM(PVRSRV_DEVICE_NODE       *psDeviceNode,
53                                         IMG_UINT8              ui8RegPowerIsland)
54 {
55 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
56         PVRSRV_ERROR            eError = PVRSRV_OK;
57         PVRSRV_RGXDEV_INFO      *psDevInfo = psDeviceNode->pvDevice;
58         RGX_REG_CONFIG          *psRegCfg = &psDevInfo->sRegCongfig;
59         RGXFWIF_PWR_EVT         ePowerIsland = (RGXFWIF_PWR_EVT) ui8RegPowerIsland;
60
61
62         if (ePowerIsland < psRegCfg->ePowerIslandToPush)
63         {
64                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Register configuration must be in power island order."));
65                 return PVRSRV_ERROR_REG_CONFIG_INVALID_PI;
66         }
67
68         psRegCfg->ePowerIslandToPush = ePowerIsland;
69
70         return eError;
71 #else
72         PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
73         return PVRSRV_ERROR_FEATURE_DISABLED;
74 #endif
75 }
76
77 PVRSRV_ERROR PVRSRVRGXAddRegConfigKM(PVRSRV_DEVICE_NODE *psDeviceNode,
78                                         IMG_UINT32              ui32RegAddr,
79                                         IMG_UINT64              ui64RegValue)
80 {
81 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
82         PVRSRV_ERROR            eError = PVRSRV_OK;
83         RGXFWIF_KCCB_CMD        sRegCfgCmd;
84         PVRSRV_RGXDEV_INFO      *psDevInfo = psDeviceNode->pvDevice;
85         RGX_REG_CONFIG          *psRegCfg = &psDevInfo->sRegCongfig;
86
87         if (psRegCfg->bEnabled)
88         {
89                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Cannot add record whilst register configuration active."));
90                 return PVRSRV_ERROR_REG_CONFIG_ENABLED;
91         }
92         if (psRegCfg->ui32NumRegRecords == RGXFWIF_REG_CFG_MAX_SIZE)
93         {
94                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Register configuration full."));
95                 return PVRSRV_ERROR_REG_CONFIG_FULL;
96         }
97
98         sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
99         sRegCfgCmd.uCmdData.sRegConfigData.sRegConfig.ui64Addr = (IMG_UINT64) ui32RegAddr;
100         sRegCfgCmd.uCmdData.sRegConfigData.sRegConfig.ui64Value = ui64RegValue;
101         sRegCfgCmd.uCmdData.sRegConfigData.eRegConfigPI = psRegCfg->ePowerIslandToPush;
102         sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_ADD;
103
104         eError = RGXScheduleCommand(psDeviceNode->pvDevice,
105                                 RGXFWIF_DM_GP,
106                                 &sRegCfgCmd,
107                                 sizeof(sRegCfgCmd),
108                                 IMG_TRUE);
109         if (eError != PVRSRV_OK)
110         {
111                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXAddRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
112                 return eError;
113         }
114
115         psRegCfg->ui32NumRegRecords++;
116
117         return eError;
118 #else
119         PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
120         return PVRSRV_ERROR_FEATURE_DISABLED;
121 #endif
122 }
123
124 PVRSRV_ERROR PVRSRVRGXClearRegConfigKM(PVRSRV_DEVICE_NODE       *psDeviceNode)
125 {
126 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
127         PVRSRV_ERROR            eError = PVRSRV_OK;
128         RGXFWIF_KCCB_CMD        sRegCfgCmd;
129         PVRSRV_RGXDEV_INFO      *psDevInfo = psDeviceNode->pvDevice;
130         RGX_REG_CONFIG          *psRegCfg = &psDevInfo->sRegCongfig;
131
132         if (psRegCfg->bEnabled)
133         {
134                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Attempt to clear register configuration whilst active."));
135                 return PVRSRV_ERROR_REG_CONFIG_ENABLED;
136         }
137
138         sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
139         sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_CLEAR;
140
141         eError = RGXScheduleCommand(psDeviceNode->pvDevice,
142                                 RGXFWIF_DM_GP,
143                                 &sRegCfgCmd,
144                                 sizeof(sRegCfgCmd),
145                                 IMG_TRUE);
146         if (eError != PVRSRV_OK)
147         {
148                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXClearRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
149                 return eError;
150         }
151
152         psRegCfg->ui32NumRegRecords = 0;
153         psRegCfg->ePowerIslandToPush = RGXFWIF_PWR_EVT_PWR_ON; /* Default first PI */
154
155         return eError;
156 #else
157         PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXClearRegConfigKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
158         return PVRSRV_ERROR_FEATURE_DISABLED;
159 #endif
160 }
161
162 PVRSRV_ERROR PVRSRVRGXEnableRegConfigKM(PVRSRV_DEVICE_NODE      *psDeviceNode)
163 {
164 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
165         PVRSRV_ERROR            eError = PVRSRV_OK;
166         RGXFWIF_KCCB_CMD        sRegCfgCmd;
167         PVRSRV_RGXDEV_INFO      *psDevInfo = psDeviceNode->pvDevice;
168         RGX_REG_CONFIG          *psRegCfg = &psDevInfo->sRegCongfig;
169
170         sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
171         sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_ENABLE;
172
173         eError = RGXScheduleCommand(psDeviceNode->pvDevice,
174                                 RGXFWIF_DM_GP,
175                                 &sRegCfgCmd,
176                                 sizeof(sRegCfgCmd),
177                                 IMG_TRUE);
178         if (eError != PVRSRV_OK)
179         {
180                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXEnableRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
181                 return eError;
182         }
183
184         psRegCfg->bEnabled = IMG_TRUE;
185
186         return eError;
187 #else
188         PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXEnableRegConfigKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
189         return PVRSRV_ERROR_FEATURE_DISABLED;
190 #endif
191 }
192
193 PVRSRV_ERROR PVRSRVRGXDisableRegConfigKM(PVRSRV_DEVICE_NODE     *psDeviceNode)
194 {
195 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
196         PVRSRV_ERROR            eError = PVRSRV_OK;
197         RGXFWIF_KCCB_CMD        sRegCfgCmd;
198         PVRSRV_RGXDEV_INFO      *psDevInfo = psDeviceNode->pvDevice;
199         RGX_REG_CONFIG          *psRegCfg = &psDevInfo->sRegCongfig;
200
201         sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
202         sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_DISABLE;
203
204         eError = RGXScheduleCommand(psDeviceNode->pvDevice,
205                                 RGXFWIF_DM_GP,
206                                 &sRegCfgCmd,
207                                 sizeof(sRegCfgCmd),
208                                 IMG_TRUE);
209         if (eError != PVRSRV_OK)
210         {
211                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXDisableRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
212                 return eError;
213         }
214
215         psRegCfg->bEnabled = IMG_FALSE;
216
217         return eError;
218 #else
219         PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXDisableRegConfigKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
220         return PVRSRV_ERROR_FEATURE_DISABLED;
221 #endif
222 }
223
224
225 /******************************************************************************
226  End of file (rgxregconfig.c)
227 ******************************************************************************/