-static IMG_VOID SGXGetTimingInfo(PVRSRV_DEVICE_NODE * psDeviceNode)
-{
- PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
- SGX_TIMING_INFORMATION sSGXTimingInfo = { 0 };
- IMG_UINT32 ui32ActivePowManSampleRate;
- SGX_TIMING_INFORMATION *psSGXTimingInfo;
-
- psSGXTimingInfo = &sSGXTimingInfo;
- SysGetSGXTimingInformation(psSGXTimingInfo);
-
- {
- PVRSRV_ERROR eError;
- IMG_UINT32 ui32OlduKernelFreq;
-
- if (psDevInfo->hTimer != IMG_NULL) {
- ui32OlduKernelFreq =
- psDevInfo->ui32CoreClockSpeed /
- psDevInfo->ui32uKernelTimerClock;
- if (ui32OlduKernelFreq !=
- psSGXTimingInfo->ui32uKernelFreq) {
- eError = OSRemoveTimer(psDevInfo->hTimer);
- if (eError != PVRSRV_OK) {
- PVR_DPF((PVR_DBG_ERROR,
- "SGXGetTimingInfo: Failed to remove timer"));
- }
- psDevInfo->hTimer = IMG_NULL;
- }
- }
- if (psDevInfo->hTimer == IMG_NULL) {
-
- psDevInfo->hTimer = OSAddTimer(SGXOSTimer, psDeviceNode,
- 1000 * 50 /
- psSGXTimingInfo->
- ui32uKernelFreq);
- if (psDevInfo->hTimer == IMG_NULL) {
- PVR_DPF((PVR_DBG_ERROR,
- "SGXGetTimingInfo : Failed to register timer callback function"));
- }
- }
-
- psDevInfo->psSGXHostCtl->ui32HWRecoverySampleRate =
- psSGXTimingInfo->ui32uKernelFreq /
- psSGXTimingInfo->ui32HWRecoveryFreq;
- }
-
- psDevInfo->ui32CoreClockSpeed = psSGXTimingInfo->ui32CoreClockSpeed;
- psDevInfo->ui32uKernelTimerClock =
- psSGXTimingInfo->ui32CoreClockSpeed /
- psSGXTimingInfo->ui32uKernelFreq;
-
- ui32ActivePowManSampleRate =
- psSGXTimingInfo->ui32uKernelFreq *
- psSGXTimingInfo->ui32ActivePowManLatencyms / 1000;
- ui32ActivePowManSampleRate += 1;
- psDevInfo->psSGXHostCtl->ui32ActivePowManSampleRate =
- ui32ActivePowManSampleRate;
-}
-
-static IMG_VOID SGXStartTimer(PVRSRV_SGXDEV_INFO * psDevInfo,
- IMG_BOOL bStartOSTimer)
-{
- IMG_UINT32 ui32RegVal;
-
-
- ui32RegVal =
- EUR_CR_EVENT_TIMER_ENABLE_MASK | psDevInfo->ui32uKernelTimerClock;
- OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_EVENT_TIMER, ui32RegVal);
- PDUMPREGWITHFLAGS(EUR_CR_EVENT_TIMER, ui32RegVal,
- PDUMP_FLAGS_CONTINUOUS);
-
- if (bStartOSTimer) {
- PVRSRV_ERROR eError;
- eError = OSEnableTimer(psDevInfo->hTimer);
- if (eError != PVRSRV_OK) {
- PVR_DPF((PVR_DBG_ERROR,
- "SGXStartTimer : Failed to enable host timer"));
- }
- }
-}
-
-static PVRSRV_ERROR SGXPrePowerState(IMG_HANDLE hDevHandle,
- PVR_DEVICE_POWER_STATE eNewPowerState,
- PVR_DEVICE_POWER_STATE eCurrentPowerState)
-{
- if ((eNewPowerState != eCurrentPowerState) &&
- (eNewPowerState != PVR_DEVICE_POWER_STATE_ON)) {
- PVRSRV_ERROR eError;
- PVRSRV_DEVICE_NODE *psDeviceNode = hDevHandle;
- PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
- PVRSRV_SGX_HOST_CTL *psSGXHostCtl = psDevInfo->psSGXHostCtl;
- IMG_UINT32 ui32PowManRequest, ui32PowManComplete;
-
- eError = OSDisableTimer(psDevInfo->hTimer);
- if (eError != PVRSRV_OK) {
- PVR_DPF((PVR_DBG_ERROR,
- "SGXPrePowerState: Failed to disable timer"));
- return eError;
- }
-
- if (eNewPowerState == PVR_DEVICE_POWER_STATE_OFF) {
- ui32PowManRequest =
- PVRSRV_USSE_EDM_POWMAN_POWEROFF_REQUEST;
- ui32PowManComplete =
- PVRSRV_USSE_EDM_POWMAN_POWEROFF_COMPLETE;
- PDUMPCOMMENT
- ("TA/3D CCB Control - SGX power off request");
- } else {
- ui32PowManRequest = PVRSRV_USSE_EDM_POWMAN_IDLE_REQUEST;
- ui32PowManComplete =
- PVRSRV_USSE_EDM_POWMAN_IDLE_COMPLETE;
- PDUMPCOMMENT("TA/3D CCB Control - SGX idle request");
- }
-
- psSGXHostCtl->ui32PowManFlags |= ui32PowManRequest;
-#if defined(PDUMP)
- PDUMPMEM(IMG_NULL, psDevInfo->psKernelSGXHostCtlMemInfo,
- offsetof(PVRSRV_SGX_HOST_CTL, ui32PowManFlags),
- sizeof(IMG_UINT32), PDUMP_FLAGS_CONTINUOUS,
- MAKEUNIQUETAG(psDevInfo->psKernelSGXHostCtlMemInfo));
-#endif
-
- if (PollForValueKM(&psSGXHostCtl->ui32PowManFlags,
- ui32PowManComplete,
- ui32PowManComplete,
- MAX_HW_TIME_US / WAIT_TRY_COUNT,
- WAIT_TRY_COUNT) != PVRSRV_OK) {
- PVR_DPF((PVR_DBG_ERROR,
- "SGXPrePowerState: Wait for SGX ukernel power transition failed."));
- }
-
-#if defined(PDUMP)
- PDUMPCOMMENT
- ("TA/3D CCB Control - Wait for power event on uKernel.");
- PDUMPMEMPOL(psDevInfo->psKernelSGXHostCtlMemInfo,
- offsetof(PVRSRV_SGX_HOST_CTL, ui32PowManFlags),
- ui32PowManComplete, ui32PowManComplete,
- PDUMP_POLL_OPERATOR_EQUAL, IMG_FALSE, IMG_FALSE,
- MAKEUNIQUETAG(psDevInfo->
- psKernelSGXHostCtlMemInfo));
-#endif
-
-
- {
- if (PollForValueKM
- ((IMG_UINT32 *) psDevInfo->pvRegsBaseKM +
- (EUR_CR_CLKGATESTATUS >> 2), 0,
- psDevInfo->ui32ClkGateStatusMask,
- MAX_HW_TIME_US / WAIT_TRY_COUNT,
- WAIT_TRY_COUNT) != PVRSRV_OK) {
- PVR_DPF((PVR_DBG_ERROR,
- "SGXPrePowerState: Wait for SGX clock gating failed."));
- }
-
- PDUMPCOMMENT("Wait for SGX clock gating.");
- PDUMPREGPOL(EUR_CR_CLKGATESTATUS, 0,
- psDevInfo->ui32ClkGateStatusMask);
- }
-
- if (eNewPowerState == PVR_DEVICE_POWER_STATE_OFF) {
- eError = SGXDeinitialise(psDevInfo);
- if (eError != PVRSRV_OK) {
- PVR_DPF((PVR_DBG_ERROR,
- "SGXPrePowerState: SGXDeinitialise failed: %lu",
- eError));
- return eError;
- }
- }
- }
-
- return PVRSRV_OK;
-}
-
-static PVRSRV_ERROR SGXPostPowerState(IMG_HANDLE hDevHandle,
- PVR_DEVICE_POWER_STATE eNewPowerState,
- PVR_DEVICE_POWER_STATE eCurrentPowerState)
-{
- if ((eNewPowerState != eCurrentPowerState) &&
- (eCurrentPowerState != PVR_DEVICE_POWER_STATE_ON)) {
- PVRSRV_ERROR eError;
- PVRSRV_DEVICE_NODE *psDeviceNode = hDevHandle;
- PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
- PVRSRV_SGX_HOST_CTL *psSGXHostCtl = psDevInfo->psSGXHostCtl;
-
- psSGXHostCtl->ui32PowManFlags = 0;
- PDUMPCOMMENT("TA/3D CCB Control - Reset Power Manager flags");
-#if defined(PDUMP)
- PDUMPMEM(IMG_NULL, psDevInfo->psKernelSGXHostCtlMemInfo,
- offsetof(PVRSRV_SGX_HOST_CTL, ui32PowManFlags),
- sizeof(IMG_UINT32), PDUMP_FLAGS_CONTINUOUS,
- MAKEUNIQUETAG(psDevInfo->psKernelSGXHostCtlMemInfo));
-#endif
-
- if (eCurrentPowerState == PVR_DEVICE_POWER_STATE_OFF) {
-
- SGXGetTimingInfo(psDeviceNode);
-
- eError = SGXInitialise(psDevInfo, IMG_FALSE);
- if (eError != PVRSRV_OK) {
- PVR_DPF((PVR_DBG_ERROR,
- "SGXPostPowerState: SGXInitialise failed"));
- return eError;
- }
- }
- }
-
- return PVRSRV_OK;
-}
-
-PVRSRV_ERROR SGXPrePowerStateExt(IMG_HANDLE hDevHandle,
- PVR_POWER_STATE eNewPowerState,
- PVR_POWER_STATE eCurrentPowerState)
-{
- PVR_DEVICE_POWER_STATE eNewDevicePowerState =
- MapDevicePowerState(eNewPowerState);
- PVR_DEVICE_POWER_STATE eCurrentDevicePowerState =
- MapDevicePowerState(eCurrentPowerState);
-
- return SGXPrePowerState(hDevHandle, eNewDevicePowerState,
- eCurrentDevicePowerState);
-}
-
-PVRSRV_ERROR SGXPostPowerStateExt(IMG_HANDLE hDevHandle,
- PVR_POWER_STATE eNewPowerState,
- PVR_POWER_STATE eCurrentPowerState)
-{
- PVRSRV_ERROR eError;
- PVR_DEVICE_POWER_STATE eNewDevicePowerState =
- MapDevicePowerState(eNewPowerState);
- PVR_DEVICE_POWER_STATE eCurrentDevicePowerState =
- MapDevicePowerState(eCurrentPowerState);
-
- eError =
- SGXPostPowerState(hDevHandle, eNewDevicePowerState,
- eCurrentDevicePowerState);
- if (eError != PVRSRV_OK) {
- return eError;
- }
-
- PVR_DPF((PVR_DBG_WARNING,
- "SGXPostPowerState : SGX Power Transition from %d to %d OK",
- eCurrentPowerState, eNewPowerState));
-
- return eError;
-}
-
-static PVRSRV_ERROR SGXPreClockSpeedChange(IMG_HANDLE hDevHandle,
- IMG_BOOL bIdleDevice,
- PVR_POWER_STATE eCurrentPowerState)