/*! ****************************************************************************** @Function SysFinalise @Description Final part of initialisation @Return PVRSRV_ERROR : ******************************************************************************/ PVRSRV_ERROR SysFinalise(IMG_VOID) { PVRSRV_ERROR eError; #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) eError = EnableSGXClocks(); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to Enable SGX clocks (%d)", eError)); (IMG_VOID)SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } #endif eError = OSInstallMISR(gpsSysData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"OSInstallMISR: Failed to install MISR")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_MISR; #if defined(SYS_USING_INTERRUPTS) /* install a system ISR */ eError = OSInstallSystemLISR(gpsSysData, gsSGXDeviceMap.ui32IRQ); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"OSInstallSystemLISR: Failed to install ISR")); OSUninstallMISR(gpsSysData); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_LISR; gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_IRQ; #endif /* defined(SYS_USING_INTERRUPTS) */ /* Create a human readable version string for this system */ gpsSysData->pszVersionString = gszVersionString; if (!gpsSysData->pszVersionString) { PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to create a system version string")); } else { PVR_DPF((PVR_DBG_WARNING, "SysFinalise: Version string: %s", gpsSysData->pszVersionString)); } #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) DisableSGXClocks(); #ifndef CONFIG_DVFS_LIMIT cpufreq_register_notifier(&cpufreq_limit_notifier, CPUFREQ_POLICY_NOTIFIER); #endif #endif return PVRSRV_OK; }
/*! ****************************************************************************** @Function SysInitialise @Description Initialises kernel services at 'driver load' time @Return PVRSRV_ERROR : ******************************************************************************/ PVRSRV_ERROR SysInitialise(IMG_VOID) { IMG_UINT32 i; PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode; SGX_TIMING_INFORMATION* psTimingInfo; gpsSysData = &gsSysData; OSMemSet(gpsSysData, 0, sizeof(SYS_DATA)); #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) { extern struct platform_device *gpsPVRLDMDev; g3d_pd_regulator = regulator_get(&gpsPVRLDMDev->dev, "pd"); if (IS_ERR(g3d_pd_regulator)) { PVR_DPF((PVR_DBG_ERROR, "G3D failed to find g3d power domain")); return PVRSRV_ERROR_INIT_FAILURE; } g3d_clock = clk_get(&gpsPVRLDMDev->dev, "sclk"); if (IS_ERR(g3d_clock)) { PVR_DPF((PVR_DBG_ERROR, "G3D failed to find g3d clock source-enable")); return PVRSRV_ERROR_INIT_FAILURE; } EnableSGXClocks(); } #endif eError = OSInitEnvData(&gpsSysData->pvEnvSpecificData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to setup env structure")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } gpsSysData->pvSysSpecificData = (IMG_PVOID)&gsSysSpecificData; OSMemSet(&gsSGXDeviceMap, 0, sizeof(SGX_DEVICE_MAP)); /* Set up timing information*/ psTimingInfo = &gsSGXDeviceMap.sTimingInfo; psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED; psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ; psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS; psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ; #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) psTimingInfo->bEnableActivePM = IMG_TRUE; #else psTimingInfo->bEnableActivePM = IMG_FALSE; #endif gpsSysData->ui32NumDevices = SYS_DEVICE_COUNT; /* init device ID's */ for(i=0; i<SYS_DEVICE_COUNT; i++) { gpsSysData->sDeviceID[i].uiID = i; gpsSysData->sDeviceID[i].bInUse = IMG_FALSE; } gpsSysData->psDeviceNodeList = IMG_NULL; gpsSysData->psQueueList = IMG_NULL; eError = SysInitialiseCommon(gpsSysData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed in SysInitialiseCommon")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } /* Locate the devices within the system, specifying the physical addresses of each devices components (regs, mem, ports etc.) */ eError = SysLocateDevices(gpsSysData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to locate devices")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } /* Register devices with the system This also sets up their memory maps/heaps */ eError = PVRSRVRegisterDevice(gpsSysData, SGXRegisterDevice, 1, &gui32SGXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register device!")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } /* Once all devices are registered, specify the backing store and, if required, customise the memory heap config */ psDeviceNode = gpsSysData->psDeviceNodeList; while(psDeviceNode) { /* perform any OEM SOC address space customisations here */ switch(psDeviceNode->sDevId.eDeviceType) { case PVRSRV_DEVICE_TYPE_SGX: { DEVICE_MEMORY_INFO *psDevMemoryInfo; DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; IMG_UINT32 ui32MemConfig; if(gpsSysData->apsLocalDevMemArena[0] != IMG_NULL) { /* specify the backing store to use for the device's MMU PT/PDs */ psDeviceNode->psLocalDevMemArena = gpsSysData->apsLocalDevMemArena[0]; ui32MemConfig = PVRSRV_BACKINGSTORE_LOCALMEM_CONTIG; } else { /* specify the backing store to use for the devices MMU PT/PDs - the PT/PDs are always UMA in this system */ psDeviceNode->psLocalDevMemArena = IMG_NULL; ui32MemConfig = PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG; } /* useful pointers */ psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo; psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; /* specify the backing store for all SGX heaps */ for(i=0; i<psDevMemoryInfo->ui32HeapCount; i++) { #if defined(SGX_FEATURE_VARIABLE_MMU_PAGE_SIZE) IMG_CHAR *pStr; switch(psDeviceMemoryHeap[i].ui32HeapID) { case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_GENERAL_HEAP_ID): { pStr = "GeneralHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_GENERAL_MAPPING_HEAP_ID): { pStr = "GeneralMappingHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_TADATA_HEAP_ID): { pStr = "TADataHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_KERNEL_CODE_HEAP_ID): { pStr = "KernelCodeHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_KERNEL_DATA_HEAP_ID): { pStr = "KernelDataHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_PIXELSHADER_HEAP_ID): { pStr = "PixelShaderHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_VERTEXSHADER_HEAP_ID): { pStr = "VertexShaderHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_PDSPIXEL_CODEDATA_HEAP_ID): { pStr = "PDSPixelHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_PDSVERTEX_CODEDATA_HEAP_ID): { pStr = "PDSVertexHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_SYNCINFO_HEAP_ID): { pStr = "SyncInfoHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_3DPARAMETERS_HEAP_ID): { pStr = "3DParametersHeapPageSize"; break; } default: { /* not interested in other heaps */ pStr = IMG_NULL; break; } } if (pStr && OSReadRegistryDWORDFromString(0, PVRSRV_REGISTRY_ROOT, pStr, &psDeviceMemoryHeap[i].ui32DataPageSize) == IMG_TRUE) { PVR_DPF((PVR_DBG_VERBOSE,"SysInitialise: set Heap %s page size to %d", pStr, psDeviceMemoryHeap[i].ui32DataPageSize)); } #endif /* map the device memory allocator(s) onto the device memory heaps as required */ psDeviceMemoryHeap[i].psLocalDevMemArena = gpsSysData->apsLocalDevMemArena[0]; /* set the memory config (uma | non-uma) */ psDeviceMemoryHeap[i].ui32Attribs |= ui32MemConfig; } break; } default: PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to find SGX device node!")); return PVRSRV_ERROR_INIT_FAILURE; } /* advance to next device */ psDeviceNode = psDeviceNode->psNext; } /* Initialise all devices 'managed' by services: */ eError = PVRSRVInitialiseDevice (gui32SGXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialise device!")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) DisableSGXClocks(); #endif return PVRSRV_OK; }
PVRSRV_ERROR SysFinalise(IMG_VOID) { PVRSRV_ERROR eError; #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) eError = EnableSGXClocks(); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to Enable SGX clocks (%d)", eError)); (IMG_VOID)SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } #endif #if defined(SYS_USING_INTERRUPTS) eError = OSInstallMISR(gpsSysData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"OSInstallMISR: Failed to install MISR")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_MISR; eError = OSInstallSystemLISR(gpsSysData, gsSGXDeviceMap.ui32IRQ); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"OSInstallSystemLISR: Failed to install ISR")); OSUninstallMISR(gpsSysData); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_LISR; // SysEnableInterrupts(gpsSysData); gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_IRQ; #endif #if 0 gpsSysData->pszVersionString = SysCreateVersionString(gsSGXDeviceMap.sRegsCpuPBase); #else gpsSysData->pszVersionString=version_string; #endif if (!gpsSysData->pszVersionString) { PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to create a system version string")); } else { ;//PVR_DPF((PVR_DBG_WARNING, "SysFinalise: Version string: %s", gpsSysData->pszVersionString));// } #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) DisableSGXClocks(); #endif // gsSysSpecificData.bSGXInitComplete= IMG_TRUE; don't know return PVRSRV_OK; }
static INLINE PVRSRV_ERROR EnableSGXClocksWrap(SYS_DATA *psSysData) { return EnableSGXClocks(psSysData); }
PVRSRV_ERROR SysInitialise() { IMG_UINT32 i; PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode; SGX_TIMING_INFORMATION* psTimingInfo; struct platform_device *pdev; gpsSysData = &gsSysData; OSMemSet(gpsSysData, 0, sizeof(SYS_DATA)); pdev = gpsPVRLDMDev; g3d_pd_regulator = regulator_get(&pdev->dev, "pd"); if (IS_ERR(g3d_pd_regulator)) { printk("\nG3D failed to find g3d power domain\n"); return PVRSRV_ERROR_INIT_FAILURE; } g3d_clock = clk_get(&pdev->dev, "sclk"); if (IS_ERR(g3d_clock)) { printk("\n3D failed to find g3d clock source-enable\n"); return PVRSRV_ERROR_INIT_FAILURE; } EnableSGXClocks(); eError = OSInitEnvData(&gpsSysData->pvEnvSpecificData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to setup env structure")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } #if defined(SGX540) //printk("SGX540 defined\n"); #endif //printk("SGX_CORE_REV=%d\n",SGX_CORE_REV); #if defined(SGX_FEATURE_SYSTEM_CACHE) //printk("SGX_FEATURE_SYSTEM_CACHE defined!!!!!!!!!!!!!!\n"); #if defined(FIX_HW_BRN_25659) //printk("FIX_HW_BRN_25659 defined!!!!!!!!!!!!!!\n"); #endif #endif #if defined(SGX_BYPASS_SYSTEM_CACHE) // printk("SGX_BYPASS_SYSTEM_CACHE defined!!!!!!!!!!!!!!!\n"); #endif gpsSysData->pvSysSpecificData = (IMG_PVOID)&gsSysSpecificData; OSMemSet(&gsSGXDeviceMap, 0, sizeof(SGX_DEVICE_MAP)); psTimingInfo = &gsSGXDeviceMap.sTimingInfo; psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED; psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ; psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS; psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ; #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) psTimingInfo->bEnableActivePM = IMG_TRUE; #else psTimingInfo->bEnableActivePM = IMG_FALSE; #endif gpsSysData->ui32NumDevices = SYS_DEVICE_COUNT; for(i=0; i<SYS_DEVICE_COUNT; i++) { gpsSysData->sDeviceID[i].uiID = i; gpsSysData->sDeviceID[i].bInUse = IMG_FALSE; } gpsSysData->psDeviceNodeList = IMG_NULL; gpsSysData->psQueueList = IMG_NULL; eError = SysInitialiseCommon(gpsSysData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed in SysInitialiseCommon")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } eError = SysLocateDevices(gpsSysData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to locate devices")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } eError = PVRSRVRegisterDevice(gpsSysData, SGXRegisterDevice, 1, &gui32SGXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register device!")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } psDeviceNode = gpsSysData->psDeviceNodeList; while(psDeviceNode) { switch(psDeviceNode->sDevId.eDeviceType) { case PVRSRV_DEVICE_TYPE_SGX: { DEVICE_MEMORY_INFO *psDevMemoryInfo; DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; IMG_UINT32 ui32MemConfig; if(gpsSysData->apsLocalDevMemArena[0] != IMG_NULL) { psDeviceNode->psLocalDevMemArena = gpsSysData->apsLocalDevMemArena[0]; ui32MemConfig = PVRSRV_BACKINGSTORE_LOCALMEM_CONTIG; } else { psDeviceNode->psLocalDevMemArena = IMG_NULL; ui32MemConfig = PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG; } psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo; psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; for(i=0; i<psDevMemoryInfo->ui32HeapCount; i++) { #if defined(SGX_FEATURE_VARIABLE_MMU_PAGE_SIZE) IMG_CHAR *pStr; switch(psDeviceMemoryHeap[i].ui32HeapID) { case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_GENERAL_HEAP_ID): { pStr = "GeneralHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_GENERAL_MAPPING_HEAP_ID): { pStr = "GeneralMappingHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_TADATA_HEAP_ID): { pStr = "TADataHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_KERNEL_CODE_HEAP_ID): { pStr = "KernelCodeHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_KERNEL_DATA_HEAP_ID): { pStr = "KernelDataHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_PIXELSHADER_HEAP_ID): { pStr = "PixelShaderHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_VERTEXSHADER_HEAP_ID): { pStr = "VertexShaderHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_PDSPIXEL_CODEDATA_HEAP_ID): { pStr = "PDSPixelHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_PDSVERTEX_CODEDATA_HEAP_ID): { pStr = "PDSVertexHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_SYNCINFO_HEAP_ID): { pStr = "SyncInfoHeapPageSize"; break; } case HEAP_ID(PVRSRV_DEVICE_TYPE_SGX, SGX_3DPARAMETERS_HEAP_ID): { pStr = "3DParametersHeapPageSize"; break; } default: { pStr = IMG_NULL; break; } } if (pStr && OSReadRegistryDWORDFromString(0, PVRSRV_REGISTRY_ROOT, pStr, &psDeviceMemoryHeap[i].ui32DataPageSize) == IMG_TRUE) { PVR_DPF((PVR_DBG_VERBOSE,"SysInitialise: set Heap %s page size to %d", pStr, psDeviceMemoryHeap[i].ui32DataPageSize)); } #endif psDeviceMemoryHeap[i].psLocalDevMemArena = gpsSysData->apsLocalDevMemArena[0]; psDeviceMemoryHeap[i].ui32Attribs |= ui32MemConfig; } break; } default: PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to find SGX device node!")); return PVRSRV_ERROR_INIT_FAILURE; } psDeviceNode = psDeviceNode->psNext; } PDUMPINIT(); eError = PVRSRVInitialiseDevice (gui32SGXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialise device!")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) DisableSGXClocks(); #endif return PVRSRV_OK; }