PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) { PVRSRV_ERROR eError; eError = ResManInit(); if (eError != PVRSRV_OK) { goto Error; } eError = PVRSRVPerProcessDataInit(); if(eError != PVRSRV_OK) { goto Error; } eError = PVRSRVHandleInit(); if(eError != PVRSRV_OK) { goto Error; } eError = OSCreateResource(&psSysData->sPowerStateChangeResource); if (eError != PVRSRV_OK) { goto Error; } psSysData->eCurrentPowerState = PVRSRV_SYS_POWER_STATE_D0; psSysData->eFailedPowerState = PVRSRV_SYS_POWER_STATE_Unspecified; if(OSAllocMem( PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_EVENTOBJECT) , (IMG_VOID **)&psSysData->psGlobalEventObject, 0, "Event Object") != PVRSRV_OK) { goto Error; } if(OSEventObjectCreate("PVRSRV_GLOBAL_EVENTOBJECT", psSysData->psGlobalEventObject) != PVRSRV_OK) { goto Error; } PDUMPINIT(); g_ui32InitFlags |= INIT_DATA_ENABLE_PDUMPINIT; return eError; Error: PVRSRVDeInit(psSysData); return eError; }
PVRSRV_ERROR SysInitialise(IMG_VOID) { IMG_UINT32 i = 0; PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode; SGX_TIMING_INFORMATION* psTimingInfo; struct drm_psb_private *dev_priv = (struct drm_psb_private *) gpDrmDevice->dev_private; gpsSysData = &gsSysData; OSMemSet(gpsSysData, 0, sizeof(SYS_DATA)); gpsSysData->pvSysSpecificData = &gsSysSpecificData; gsSysSpecificData.ui32SysSpecificData = 0; #if defined(LDM_PCI) || defined(SUPPORT_DRI_DRM) PVR_ASSERT(gpsPVRLDMDev != IMG_NULL); gsSysSpecificData.psPCIDev = gpsPVRLDMDev; #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; } psTimingInfo = &gsSGXDeviceMap.sTimingInfo; psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED; psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ; #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) /* Note: Enable active PM unconditionally, regardless of runtime PM. */ psTimingInfo->bEnableActivePM = IMG_TRUE; #else psTimingInfo->bEnableActivePM = IMG_FALSE; #endif psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS; psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ; eError = PCIInitDev(gpsSysData); if (eError != PVRSRV_OK) { SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } 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, DEVICE_SGX_INTERRUPT, &gui32SGXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register device!")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } /* register MSVDX, with 0 interrupt bit, no interrupt will be served */ eError = PVRSRVRegisterDevice(gpsSysData, MSVDXRegisterDevice, DEVICE_MSVDX_INTERRUPT, &gui32MRSTMSVDXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register MSVDXdevice!")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } if (!dev_priv->topaz_disabled) { /* register TOPAZ, with 0 interrupt bit, no interrupt will be served */ eError = PVRSRVRegisterDevice(gpsSysData, TOPAZRegisterDevice, DEVICE_TOPAZ_INTERRUPT, &gui32MRSTTOPAZDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register TOPAZdevice!")); 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; psDeviceNode->psLocalDevMemArena = IMG_NULL; psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo; psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; for(i=0; i<psDevMemoryInfo->ui32HeapCount; i++) { psDeviceMemoryHeap[i].ui32Attribs |= PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG; #ifdef OEM_CUSTOMISE #endif } #if defined(SUPPORT_DRI_DRM_EXT) gpsSGXDevNode = psDeviceNode; #endif break; } case PVRSRV_DEVICE_TYPE_MSVDX: /* nothing need to do here */ break; case PVRSRV_DEVICE_TYPE_TOPAZ: break; default: { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to find SGX device node!")); return PVRSRV_ERROR_INIT_FAILURE; } } psDeviceNode = psDeviceNode->psNext; } PDUMPINIT(); SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_PDUMP_INIT); eError = PVRSRVInitialiseDevice (gui32SGXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialise device!")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_SGX_INITIALISED); eError = PVRSRVInitialiseDevice (gui32MRSTMSVDXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialise device!")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } if (!dev_priv->topaz_disabled) { eError = PVRSRVInitialiseDevice (gui32MRSTTOPAZDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialise device!")); SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } } return PVRSRV_OK; }
PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) { PVRSRV_ERROR eError; eError = ResManInit(); if (eError != PVRSRV_OK) { goto Error; } eError = PVRSRVPerProcessDataInit(); if(eError != PVRSRV_OK) { goto Error; } eError = PVRSRVHandleInit(); if(eError != PVRSRV_OK) { goto Error; } eError = OSCreateResource(&psSysData->sPowerStateChangeResource); if (eError != PVRSRV_OK) { goto Error; } psSysData->eCurrentPowerState = PVRSRV_SYS_POWER_STATE_D0; psSysData->eFailedPowerState = PVRSRV_SYS_POWER_STATE_Unspecified; if(OSAllocMem( PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_EVENTOBJECT) , (IMG_VOID **)&psSysData->psGlobalEventObject, 0, "Event Object") != PVRSRV_OK) { goto Error; } if(OSEventObjectCreateKM("PVRSRV_GLOBAL_EVENTOBJECT", psSysData->psGlobalEventObject) != PVRSRV_OK) { goto Error; } psSysData->pfnHighResTimerCreate = OSFuncHighResTimerCreate; psSysData->pfnHighResTimerGetus = OSFuncHighResTimerGetus; psSysData->pfnHighResTimerDestroy = OSFuncHighResTimerDestroy; #if defined(TTRACE) eError = PVRSRVTimeTraceInit(); if (eError != PVRSRV_OK) goto Error; g_ui32InitFlags |= INIT_DATA_ENABLE_TTARCE; #endif PDUMPINIT(); g_ui32InitFlags |= INIT_DATA_ENABLE_PDUMPINIT; return eError; Error: PVRSRVDeInit(psSysData); return eError; }
PVRSRV_ERROR SysInitialise(IMG_VOID) { IMG_UINT32 i; PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode; IMG_CPU_PHYADDR TimerRegPhysBase; #if !defined(SGX_DYNAMIC_TIMING_INFO) SGX_TIMING_INFORMATION* psTimingInfo; #endif gpsSysData = &gsSysData; OSMemSet(gpsSysData, 0, sizeof(SYS_DATA)); gpsSysSpecificData = &gsSysSpecificData; OSMemSet(gpsSysSpecificData, 0, sizeof(SYS_SPECIFIC_DATA)); gpsSysData->pvSysSpecificData = gpsSysSpecificData; eError = OSInitEnvData(&gpsSysData->pvEnvSpecificData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to setup env structure")); (IMG_VOID)SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_ENVDATA); 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")); (IMG_VOID)SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } TimerRegPhysBase.uiAddr = SYS_OMAP3430_GP11TIMER_REGS_SYS_PHYS_BASE; gpsSysData->pvSOCTimerRegisterKM = IMG_NULL; gpsSysData->hSOCTimerRegisterOSMemHandle = 0; OSReservePhys(TimerRegPhysBase, 4, PVRSRV_HAP_MULTI_PROCESS|PVRSRV_HAP_UNCACHED, (IMG_VOID **)&gpsSysData->pvSOCTimerRegisterKM, &gpsSysData->hSOCTimerRegisterOSMemHandle); #if !defined(SGX_DYNAMIC_TIMING_INFO) psTimingInfo = &gsSGXDeviceMap.sTimingInfo; psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED; psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ; #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) psTimingInfo->bEnableActivePM = IMG_TRUE; #else psTimingInfo->bEnableActivePM = IMG_FALSE; #endif psTimingInfo->ui32ActivePowManLatencyms = SYS_SGX_ACTIVE_POWER_LATENCY_MS; psTimingInfo->ui32uKernelFreq = SYS_SGX_PDS_TIMER_FREQ; #endif gpsSysSpecificData->ui32SrcClockDiv = 3; eError = SysLocateDevices(gpsSysData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to locate devices")); (IMG_VOID)SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_LOCATEDEV); #if defined(SGX_OCP_REGS_ENABLED) { IMG_SYS_PHYADDR sOCPRegsSysPBase; IMG_CPU_PHYADDR sOCPRegsCpuPBase; sOCPRegsSysPBase.uiAddr = SYS_OMAP3430_OCP_REGS_SYS_PHYS_BASE; sOCPRegsCpuPBase = SysSysPAddrToCpuPAddr(sOCPRegsSysPBase); gpvOCPRegsLinAddr = OSMapPhysToLin(sOCPRegsCpuPBase, SYS_OMAP3430_OCP_REGS_SIZE, PVRSRV_HAP_UNCACHED|PVRSRV_HAP_KERNEL_ONLY, IMG_NULL); if (gpvOCPRegsLinAddr == IMG_NULL) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to map OCP registers")); return PVRSRV_ERROR_BAD_MAPPING; } } #endif eError = PVRSRVRegisterDevice(gpsSysData, SGXRegisterDevice, DEVICE_SGX_INTERRUPT, &gui32SGXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to register device!")); (IMG_VOID)SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_REGDEV); psDeviceNode = gpsSysData->psDeviceNodeList; while(psDeviceNode) { switch(psDeviceNode->sDevId.eDeviceType) { case PVRSRV_DEVICE_TYPE_SGX: { DEVICE_MEMORY_INFO *psDevMemoryInfo; DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; psDeviceNode->psLocalDevMemArena = IMG_NULL; psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo; psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; for(i=0; i<psDevMemoryInfo->ui32HeapCount; i++) { psDeviceMemoryHeap[i].ui32Attribs |= PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG; } gpsSGXDevNode = psDeviceNode; gsSysSpecificData.psSGXDevNode = psDeviceNode; break; } default: PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to find SGX device node!")); return PVRSRV_ERROR_INIT_FAILURE; } psDeviceNode = psDeviceNode->psNext; } PDUMPINIT(); SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_PDUMPINIT); eError = EnableSystemClocksWrap(gpsSysData); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to Enable system clocks (%d)", eError)); (IMG_VOID)SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_SYSCLOCKS); #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) eError = EnableSGXClocksWrap(gpsSysData); 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 dump_omap34xx_clocks(); eError = PVRSRVInitialiseDevice(gui32SGXDeviceID); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SysInitialise: Failed to initialise device!")); (IMG_VOID)SysDeinitialise(gpsSysData); gpsSysData = IMG_NULL; return eError; } SYS_SPECIFIC_DATA_SET(&gsSysSpecificData, SYS_SPECIFIC_DATA_ENABLE_INITDEV); #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) DisableSGXClocks(gpsSysData); #endif return PVRSRV_OK; }
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; }
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_g3d"); 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; } 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++) { 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; }
/*! ****************************************************************************** @Function PVRSRVInit @Description Initialise services @Input psSysData : sysdata structure @Return PVRSRV_ERROR : ******************************************************************************/ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) { PVRSRV_ERROR eError; /* Initialise Resource Manager */ eError = ResManInit(); if (eError != PVRSRV_OK) { goto Error; } eError = PVRSRVPerProcessDataInit(); if(eError != PVRSRV_OK) { goto Error; } /* Initialise handles */ eError = PVRSRVHandleInit(); if(eError != PVRSRV_OK) { goto Error; } /* Initialise Power Manager Lock */ eError = OSCreateResource(&psSysData->sPowerStateChangeResource); if (eError != PVRSRV_OK) { goto Error; } /* Initialise system power state */ psSysData->eCurrentPowerState = PVRSRV_SYS_POWER_STATE_D0; psSysData->eFailedPowerState = PVRSRV_SYS_POWER_STATE_Unspecified; /* Create an event object */ if(OSAllocMem( PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_EVENTOBJECT) , (IMG_VOID **)&psSysData->psGlobalEventObject, 0, "Event Object") != PVRSRV_OK) { goto Error; } if(OSEventObjectCreateKM("PVRSRV_GLOBAL_EVENTOBJECT", psSysData->psGlobalEventObject) != PVRSRV_OK) { goto Error; } /* Store OS high res timer fallbacks, the system is free to overide these */ psSysData->pfnHighResTimerCreate = OSFuncHighResTimerCreate; psSysData->pfnHighResTimerGetus = OSFuncHighResTimerGetus; psSysData->pfnHighResTimerDestroy = OSFuncHighResTimerDestroy; #if defined(TTRACE) eError = PVRSRVTimeTraceInit(); if (eError != PVRSRV_OK) goto Error; g_ui32InitFlags |= INIT_DATA_ENABLE_TTARCE; #endif /* Initialise pdump */ PDUMPINIT(); g_ui32InitFlags |= INIT_DATA_ENABLE_PDUMPINIT; #if defined(SUPPORT_ION) eError = PVRSRVInitDeviceMem(); if (eError != PVRSRV_OK) goto Error; g_ui32InitFlags |= INIT_DATA_ENABLE_DEVMEM; #endif PERFINIT(); return eError; Error: PVRSRVDeInit(psSysData); return eError; }