1 /*************************************************************************/ /*!
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
8 The contents of this file are subject to the MIT license as set out below.
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:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
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.
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.
32 This License is also included in this distribution in the file called
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 */ /**************************************************************************/
44 #include "rgxregconfig.h"
45 #include "pvr_debug.h"
47 #include "rgxfwutils.h"
49 #include "sync_internal.h"
52 PVRSRV_ERROR PVRSRVRGXSetRegConfigPIKM(PVRSRV_DEVICE_NODE *psDeviceNode,
53 IMG_UINT8 ui8RegPowerIsland)
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;
62 if (ePowerIsland < psRegCfg->ePowerIslandToPush)
64 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Register configuration must be in power island order."));
65 return PVRSRV_ERROR_REG_CONFIG_INVALID_PI;
68 psRegCfg->ePowerIslandToPush = ePowerIsland;
72 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
73 return PVRSRV_ERROR_FEATURE_DISABLED;
77 PVRSRV_ERROR PVRSRVRGXAddRegConfigKM(PVRSRV_DEVICE_NODE *psDeviceNode,
78 IMG_UINT32 ui32RegAddr,
79 IMG_UINT64 ui64RegValue)
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;
87 if (psRegCfg->bEnabled)
89 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Cannot add record whilst register configuration active."));
90 return PVRSRV_ERROR_REG_CONFIG_ENABLED;
92 if (psRegCfg->ui32NumRegRecords == RGXFWIF_REG_CFG_MAX_SIZE)
94 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Register configuration full."));
95 return PVRSRV_ERROR_REG_CONFIG_FULL;
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;
104 eError = RGXScheduleCommand(psDeviceNode->pvDevice,
109 if (eError != PVRSRV_OK)
111 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXAddRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
115 psRegCfg->ui32NumRegRecords++;
119 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
120 return PVRSRV_ERROR_FEATURE_DISABLED;
124 PVRSRV_ERROR PVRSRVRGXClearRegConfigKM(PVRSRV_DEVICE_NODE *psDeviceNode)
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;
132 if (psRegCfg->bEnabled)
134 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Attempt to clear register configuration whilst active."));
135 return PVRSRV_ERROR_REG_CONFIG_ENABLED;
138 sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
139 sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_CLEAR;
141 eError = RGXScheduleCommand(psDeviceNode->pvDevice,
146 if (eError != PVRSRV_OK)
148 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXClearRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
152 psRegCfg->ui32NumRegRecords = 0;
153 psRegCfg->ePowerIslandToPush = RGXFWIF_PWR_EVT_PWR_ON; /* Default first PI */
157 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXClearRegConfigKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
158 return PVRSRV_ERROR_FEATURE_DISABLED;
162 PVRSRV_ERROR PVRSRVRGXEnableRegConfigKM(PVRSRV_DEVICE_NODE *psDeviceNode)
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;
170 sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
171 sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_ENABLE;
173 eError = RGXScheduleCommand(psDeviceNode->pvDevice,
178 if (eError != PVRSRV_OK)
180 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXEnableRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
184 psRegCfg->bEnabled = IMG_TRUE;
188 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXEnableRegConfigKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
189 return PVRSRV_ERROR_FEATURE_DISABLED;
193 PVRSRV_ERROR PVRSRVRGXDisableRegConfigKM(PVRSRV_DEVICE_NODE *psDeviceNode)
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;
201 sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
202 sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_DISABLE;
204 eError = RGXScheduleCommand(psDeviceNode->pvDevice,
209 if (eError != PVRSRV_OK)
211 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXDisableRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
215 psRegCfg->bEnabled = IMG_FALSE;
219 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXDisableRegConfigKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
220 return PVRSRV_ERROR_FEATURE_DISABLED;
225 /******************************************************************************
226 End of file (rgxregconfig.c)
227 ******************************************************************************/